r104151 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104150‎ | r104151 | r104152 >
Date:10:42, 24 November 2011
Author:questpc
Status:deferred
Tags:
Comment:
"catreq" attribute is applied to tabular questions. Navigation improvements and code clean-up in [[Special:PollResults]]
Modified paths:
  • /trunk/extensions/QPoll/clientside/qp_results.css (modified) (history)
  • /trunk/extensions/QPoll/ctrl/question/qp_mixedquestion.php (modified) (history)
  • /trunk/extensions/QPoll/ctrl/question/qp_tabularquestion.php (modified) (history)
  • /trunk/extensions/QPoll/specials/qp_results.php (modified) (history)
  • /trunk/extensions/QPoll/specials/qp_special.php (modified) (history)

Diff [purge]

Index: trunk/extensions/QPoll/clientside/qp_results.css
@@ -1,8 +1,8 @@
2 -.qpoll .head {font-weight:bold; color:Gray;}
3 -.qpoll .question_id {font-weight:bold;}
4 -.qpoll .question_name {font-weight:bold; color:blue;}
5 -.qpoll table.qdata {border-collapse: collapse;}
6 -.qpoll table.qdata th {border: 1px Gray solid; background-color:LightGrey; padding: 3px;}
 2+.qpoll .head { font-weight:bold; background-color:Seashell; padding:2px; }
 3+.qpoll .question_id { font-weight:bold; }
 4+.qpoll .question_name { font-weight:bold; color:blue; }
 5+.qpoll table.qdata { border-collapse: collapse; }
 6+.qpoll table.qdata th { border: 1px Gray solid; background-color:LightGrey; padding: 3px; }
77 .qpoll table.qdata tr.spans { color:Navy; }
88 .qpoll table.qdata td {border: 1px Gray solid; text-align: center; padding: 3px;}
99 .qpoll table.qdata td.stats {background-color: Azure;}
Index: trunk/extensions/QPoll/specials/qp_special.php
@@ -64,6 +64,28 @@
6565 return self::$linker->link( $target, $text, $customAttribs, $query, $options );
6666 }
6767
 68+ /**
 69+ * Displays current poll actions links.
 70+ */
 71+ function showPollActionsList( $pid, $poll_id, Title $poll_title ) {
 72+ global $wgContLang;
 73+ return wfMsg(
 74+ 'qp_results_line_qpl',
 75+ # pagename
 76+ qp_Setup::specialchars( $wgContLang->convert( $poll_title->getPrefixedText() ) ),
 77+ # polltitle
 78+ qp_Setup::specialchars( $poll_id ),
 79+ # goto link
 80+ $this->qpLink( $poll_title, wfMsg( 'qp_source_link' ) ),
 81+ # voices link
 82+ $this->qpLink( $this->getTitle(), wfMsg( 'qp_stats_link' ), array(), array( "id" => intval( $pid ), "action" => "stats" ) ),
 83+ # users link
 84+ $this->qpLink( $this->getTitle(), wfMsg( 'qp_users_link' ), array(), array( "id" => intval( $pid ), "action" => "pulist" ) ),
 85+ # not participated link
 86+ $this->qpLink( $this->getTitle(), wfMsg( 'qp_not_participated_link' ), array(), array( "id" => intval( $pid ), "action" => "npulist" ) )
 87+ );
 88+ }
 89+
6890 } /* end of qp_SpecialPage class */
6991
7092 /**
Index: trunk/extensions/QPoll/specials/qp_results.php
@@ -186,7 +186,6 @@
187187 $tags[] = array( '__tag' => 'div', wfMsg( 'qp_poll_has_no_interpretation' ) );
188188 return $tags;
189189 }
190 - # 'parentheses' key is unavailable in MediaWiki 1.15.x
191190 $interp_link = $this->qpLink( $interpTitle, $interpTitle->getPrefixedText() );
192191 $tags[] = array( '__tag' => 'div', wfMsg( 'qp_browse_to_interpretation', $interp_link ) );
193192 $interpResultView = new qp_InterpResultView( true );
@@ -213,14 +212,17 @@
214213 if ( !$pollStore->loadUserVote() ) {
215214 return '';
216215 }
217 - $poll_title = $pollStore->getTitle();
218 - # 'parentheses' key is unavailable in MediaWiki 1.15.x
219 - $poll_link = $this->qpLink( $poll_title, $poll_title->getPrefixedText() . wfMsg( 'word-separator' ) . wfMsg( 'qp_parentheses', $pollStore->mPollId ) );
220 - $headerTags = $this->getAnswerHeader( $pollStore );
221 - $output = wfMsg( 'qp_browse_to_user', $user_link ) . "<br />\n" .
222 - wfMsg( 'qp_browse_to_poll', $poll_link ) . "<br />\n" .
223 - qp_Renderer::renderTagArray( $headerTags );
224 - unset( $headerTags );
 216+ $head = array();
 217+ $head[] = $this->showPollActionsList(
 218+ $pollStore->pid,
 219+ $pollStore->mPollId,
 220+ $pollStore->getTitle()
 221+ );
 222+ $head[] = wfMsg( 'qp_browse_to_user', $user_link );
 223+ $head[] = $this->getAnswerHeader( $pollStore );
 224+ qp_Renderer::applyAttrsToRow( $head, array( '__tag' => 'li', '__end' => "\n" ) );
 225+ $head = array( '__tag' => 'ul', 'class' => 'head', '__end' => "\n", $head );
 226+ $output = qp_Renderer::renderTagArray( $head );
225227 foreach ( $pollStore->Questions as $qdata ) {
226228 if ( $pollStore->isUsedQuestion( $qdata->question_id ) ) {
227229 $qview = $qdata->getView();
@@ -238,10 +240,14 @@
239241 $pollStore->loadQuestions();
240242 $pollStore->loadTotals();
241243 $pollStore->calculateStatistics();
242 - $poll_title = $pollStore->getTitle();
243 - # 'parentheses' is unavailable in 1.14.x
244 - $poll_link = $this->qpLink( $poll_title, $poll_title->getPrefixedText() . wfMsg( 'word-separator' ) . wfMsg( 'qp_parentheses', $pollStore->mPollId ) );
245 - $output .= wfMsg( 'qp_browse_to_poll', $poll_link ) . "<br />\n";
 244+ $head = array( '__tag' => 'div', 'class' => 'head', '__end' => "\n",
 245+ $this->showPollActionsList(
 246+ $pollStore->pid,
 247+ $pollStore->mPollId,
 248+ $pollStore->getTitle()
 249+ )
 250+ );
 251+ $output .= qp_Renderer::renderTagArray( $head );
246252 $interpTitle = $pollStore->getInterpTitle();
247253 if ( $interpTitle instanceof Title ) {
248254 $interp_link = $this->qpLink( $interpTitle, $interpTitle->getPrefixedText() );
@@ -408,7 +414,11 @@
409415 }
410416
411417 function getPageHeader() {
412 - return PollResults::getPollsLink() . '<div class="head">' . wfMsg( 'qp_users_list' ) . '<div>' . $this->different_order_by_link . '</div></div>';
 418+ return PollResults::getPollsLink() .
 419+ '<ul class="head">' .
 420+ wfMsg( 'qp_users_list' ) .
 421+ '<li>' . $this->different_order_by_link .
 422+ '</li></ul>';
413423 }
414424
415425 } /* end of qp_UsersList class */
@@ -446,7 +456,14 @@
447457 if ( $userName !== false ) {
448458 $userTitle = Title::makeTitleSafe( NS_USER, $userName );
449459 $user_link = $this->qpLink( $userTitle, $userName );
450 - return PollResults::getPollsLink() . PollResults::getUsersLink() . '<div class="head">' . $user_link . ': ' . ( $this->inverse ? wfMsgExt( 'qp_user_missing_polls_link', 'parsemag', $userName ) : wfMsgExt( 'qp_user_polls_link', array( 'parsemag' ), $pidcount, $userName ) ) . ' ' . '</div>';
 460+ return PollResults::getPollsLink() .
 461+ PollResults::getUsersLink() .
 462+ '<ul class="head">' .
 463+ "<li>{$user_link}: " .
 464+ ( $this->inverse ?
 465+ wfMsgExt( 'qp_user_missing_polls_link', 'parsemag', $userName ) :
 466+ wfMsgExt( 'qp_user_polls_link', array( 'parsemag' ), $pidcount, $userName ) )
 467+ . "</li></ul>\n";
451468 }
452469 }
453470
@@ -519,19 +536,18 @@
520537
521538 function formatResult( $result ) {
522539 global $wgLang, $wgContLang;
523 - $poll_title = Title::makeTitle( $result->ns, $result->title, qp_AbstractPoll::s_getPollTitleFragment( $result->poll_id, '' ) );
524 - $pagename = qp_Setup::specialchars( $wgContLang->convert( $poll_title->getPrefixedText() ) );
525 - $pollname = qp_Setup::specialchars( $result->poll_id );
526 - $goto_link = $this->qpLink( $poll_title, wfMsg( 'qp_source_link' ) );
527 - $voices_link = $this->qpLink( $this->getTitle(), wfMsg( 'qp_stats_link' ), array(), array( "id" => intval( $result->pid ), "action" => "stats" ) );
528 - $users_link = $this->qpLink( $this->getTitle(), wfMsg( 'qp_users_link' ), array(), array( "id" => intval( $result->pid ), "action" => "pulist" ) );
529 - $not_participated_link = $this->qpLink( $this->getTitle(), wfMsg( 'qp_not_participated_link' ), array(), array( "id" => intval( $result->pid ), "action" => "npulist" ) );
530 - $link = wfMsg( 'qp_results_line_qpl', $pagename, $pollname, $goto_link, $voices_link, $users_link, $not_participated_link );
531 - return $link;
 540+ return $this->showPollActionsList(
 541+ intval( $result->pid ),
 542+ $result->poll_id,
 543+ Title::makeTitle( $result->ns, $result->title, qp_AbstractPoll::s_getPollTitleFragment( $result->poll_id, '' ) )
 544+ );
532545 }
533546
534547 function getPageHeader() {
535 - return PollResults::getUsersLink() . '<div class="head">' . wfMsg( 'qp_polls_list' ) . '</div>';
 548+ return PollResults::getUsersLink() .
 549+ '<ul class="head"><li>' .
 550+ wfMsg( 'qp_polls_list' ) .
 551+ '</li></ul>';
536552 }
537553
538554 } /* end of qp_PollsList class */
@@ -566,13 +582,18 @@
567583 $poll_title = Title::makeTitle( intval( $row->ns ), $row->title, qp_AbstractPoll::s_getPollTitleFragment( $row->poll_id, '' ) );
568584 $pagename = qp_Setup::specialchars( $wgContLang->convert( $poll_title->getPrefixedText() ) );
569585 $pollname = qp_Setup::specialchars( $row->poll_id );
570 - $goto_link = $this->qpLink( $poll_title, wfMsg( 'qp_source_link' ) );
571 - $spec = wfMsg( 'qp_header_line_qpul', wfMsg( $this->inverse ? 'qp_not_participated_link' : 'qp_users_link' ), $pagename, $pollname );
572 - $head[] = PollResults::getPollsLink();
573 - $head[] = PollResults::getUsersLink();
574 - $head[] = array( '__tag' => 'div', 'class' => 'head', 0 => $spec );
575 - $head[] = ' (' . $goto_link . ')';
576 - $link = qp_Renderer::renderTagArray( $head );
 586+ $head = array();
 587+ $head[] = $this->showPollActionsList(
 588+ $this->pid,
 589+ $row->poll_id,
 590+ $poll_title
 591+ );
 592+ $head[] = wfMsg( 'qp_header_line_qpul', wfMsg( $this->inverse ? 'qp_not_participated_link' : 'qp_users_link' ), $pagename, $pollname );
 593+ qp_Renderer::applyAttrsToRow( $head, array( '__tag' => 'li', '__end' => "\n" ) );
 594+ $head = array( '__tag' => 'ul', 'class' => 'head', $head );
 595+ $link = PollResults::getPollsLink() .
 596+ PollResults::getUsersLink().
 597+ qp_Renderer::renderTagArray( $head );
577598 }
578599 return $link;
579600 }
@@ -659,13 +680,13 @@
660681 $poll_title = Title::makeTitle( intval( $this->ns ), $this->title, qp_AbstractPoll::s_getPollTitleFragment( $this->poll_id, '' ) );
661682 $pagename = qp_Setup::specialchars( $wgContLang->convert( $poll_title->getPrefixedText() ) );
662683 $pollname = qp_Setup::specialchars( $this->poll_id );
663 - $goto_link = $this->qpLink( $poll_title, wfMsg( 'qp_source_link' ) );
664 - $spec = wfMsg( 'qp_header_line_qpul', wfMsg( 'qp_users_link' ), $pagename, $pollname );
665 - $head[] = PollResults::getPollsLink();
666 - $head[] = PollResults::getUsersLink();
667 - $head[] = array( '__tag' => 'div', 'class' => 'head', 0 => $spec );
668 - # 'parentheses' are unavailable in MW 1.14.x
669 - $head[] = wfMsg( 'qp_parentheses', $goto_link ) . '<br />';
 684+ $head = array();
 685+ $head[] = $this->showPollActionsList(
 686+ $pollStore->pid,
 687+ $pollStore->mPollId,
 688+ $poll_title
 689+ );
 690+ $head[] = wfMsg( 'qp_header_line_qpul', wfMsg( 'qp_users_link' ), $pagename, $pollname );
670691 $ques_found = false;
671692 foreach ( $pollStore->Questions as $qdata ) {
672693 if ( $qdata->question_id == $this->question_id ) {
@@ -682,13 +703,16 @@
683704 if ( array_key_exists( 'spanId', $categ ) ) {
684705 $cat_name = wfMsg( 'qp_full_category_name', $cat_name, $qdata->CategorySpans[ $categ['spanId'] ]['name'] );
685706 }
686 - $qpa = wfMsg( 'qp_header_line_qucl',
 707+ $head[] = wfMsg( 'qp_header_line_qucl',
687708 $this->question_id,
688709 qp_Setup::entities( $qdata->CommonQuestion ),
689710 qp_Setup::entities( $proptext ),
690 - qp_Setup::entities( $cat_name ) ) . '<br />';
691 - $head[] = array( '__tag' => 'div', 'class' => 'head', 'style' => 'padding-left:2em;', 0 => $qpa );
692 - $link = qp_Renderer::renderTagArray( $head );
 711+ qp_Setup::entities( $cat_name ) );
 712+ qp_Renderer::applyAttrsToRow( $head, array( '__tag' => 'li', '__end' => "\n" ) );
 713+ $head = array( '__tag' => 'ul', 'class' => 'head', $head );
 714+ $link = PollResults::getPollsLink() .
 715+ PollResults::getUsersLink() .
 716+ qp_Renderer::renderTagArray( $head );
693717 }
694718 }
695719 }
Index: trunk/extensions/QPoll/ctrl/question/qp_mixedquestion.php
@@ -10,9 +10,6 @@
1111 */
1212 class qp_MixedQuestion extends qp_TabularQuestion {
1313
14 - # required count of single proposal categories that should be filled by user
15 - var $mCatReq = 1;
16 -
1714 /**
1815 * Creates question view which should be renreded and
1916 * also may be altered during the poll generation
Index: trunk/extensions/QPoll/ctrl/question/qp_tabularquestion.php
@@ -10,6 +10,9 @@
1111 */
1212 class qp_TabularQuestion extends qp_StubQuestion {
1313
 14+ # required count of single proposal categories that should be filled by user
 15+ var $mCatReq = 1;
 16+
1417 /**
1518 * Constructor
1619 * @public
@@ -363,12 +366,23 @@
364367 $pview->setErrorMessage( wfMsg( 'qp_error_proposal_text_empty' ), 'error' );
365368 $pview->addCellsClass( 'error' );
366369 }
 370+ ## Check for unanswered categories.
 371+ if ( ( $catreq = $prop_attrs->catreq ) === null ) {
 372+ $catreq = $this->mCatReq;
 373+ }
 374+ if ( $inputType === 'radio' && $catreq > 1 ) {
 375+ # radio buttons row always require not more than one category,
 376+ # otherwise the poll will be impossible to submit sucessfully.
 377+ $catreq = 1;
 378+ }
367379 # If the proposal was submitted but unanswered
368 - if ( $this->poll->mBeingCorrected && !array_key_exists( $proposalId, $this->mProposalCategoryId ) ) {
 380+ if ( $this->poll->mBeingCorrected &&
 381+ $this->hasMissingCategories( $proposalId, $catreq, count( $this->mCategories ) ) ) {
369382 # if there was no previous errors, hightlight the whole row
370383 if ( $this->getState() == '' ) {
371384 $pview->addCellsClass( 'error' );
372385 }
 386+ # the proposal was submitted but has not enough answered categories
373387 $pview->prependErrorMessage( wfMsg( 'qp_error_no_answer' ), 'NA' );
374388 }
375389 if ( $pview->text !== null ) {

Status & tagging log