r103936 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103935‎ | r103936 | r103937 >
Date:18:37, 22 November 2011
Author:jeroendedauw
Status:reverted (Comments)
Tags:
Comment:
work on special:myreviews
Modified paths:
  • /trunk/extensions/Reviews/Reviews.i18n.php (modified) (history)
  • /trunk/extensions/Reviews/includes/ReviewPager.php (modified) (history)
  • /trunk/extensions/Reviews/specials/SpecialMyReviews.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Reviews/specials/SpecialMyReviews.php
@@ -58,19 +58,34 @@
5959
6060 }
6161 else {
62 - $this->getOutput()->addWikiMsg( 'reviews-myreviews-header' );
63 -
6462 if ( $subPage === '' ) {
 63+ $this->getOutput()->addWikiMsg( 'reviews-myreviews-header' );
6564 $this->displayReviewList();
6665 }
6766 else {
68 - // TODO
 67+ $review = Review::selectRow( null, array( 'id' => $subPage, 'user_id' => $this->getUser()->getId() ) );
 68+
 69+ if ( $review == false ) {
 70+ $this->getOutput()->addWikiMsg( 'reviews-myreviews-nosuchreview' );
 71+ $this->displayReviewList();
 72+ }
 73+ else {
 74+ $this->displayEditControl( $review );
 75+ }
6976 }
7077 }
7178 }
7279
 80+ /**
 81+ * Display the list of reviews for this user.
 82+ *
 83+ * @since 0.1
 84+ */
7385 protected function displayReviewList() {
74 - $reviewPager = new ReviewPager( array( 'review_user_id' => $this->getUser()->getId() ) );
 86+ $reviewPager = new ReviewPager(
 87+ array( 'review_user_id' => $this->getUser()->getId() ),
 88+ $this->getName()
 89+ );
7590
7691 if ( $reviewPager->getNumRows() ) {
7792 $this->getOutput()->addHTML(
@@ -83,5 +98,17 @@
8499 $this->getOutput()->addWikiMsg( 'reviews-pager-no-results' );
85100 }
86101 }
 102+
 103+ /**
 104+ * Display the review edit control for the provided review.
 105+ *
 106+ * @since 0.1
 107+ *
 108+ * @param Review $review
 109+ */
 110+ protected function displayEditControl( Review $review ) {
 111+ $control = new ReviewControl( $review );
 112+ $control->addToContext( $this );
 113+ }
87114
88115 }
Index: trunk/extensions/Reviews/includes/ReviewPager.php
@@ -14,42 +14,33 @@
1515 class ReviewPager extends TablePager {
1616
1717 /**
18 - * Query conditions, full field names (ie inc prefix).
 18+ * Query conditions, full field names (inc prefix).
1919 * @var array
2020 */
2121 protected $conds;
2222
2323 /**
 24+ * Name of a special page to which the review titles should link.
 25+ * @var string|false $editPage
 26+ */
 27+ protected $editPage;
 28+
 29+ /**
2430 * Constructor.
2531 *
2632 * @param array $conds
 33+ * @param string|false $editPage
2734 */
28 - public function __construct( array $conds ) {
 35+ public function __construct( array $conds, $editPage = false ) {
2936 $this->conds = $conds;
3037 $this->mDefaultDirection = true;
 38+ $this->editPage = $editPage;
3139
3240 // when MW 1.19 becomes min, we want to pass an IContextSource $context here.
3341 parent::__construct();
3442 }
3543
3644 /**
37 - * Gets the title of a challenge given it's id.
38 - *
39 - * @since 0.1
40 - *
41 - * @param integer $challengeId
42 - * @throws MWException
43 - */
44 - protected function getChallengeTitle( $challengeId ) {
45 - if ( array_key_exists( $challengeId, $this->challengeTitles ) ) {
46 - return $this->challengeTitles[$challengeId];
47 - }
48 - else {
49 - throw new MWException( 'Attempt to get non-set challenge title' );
50 - }
51 - }
52 -
53 - /**
5445 * Get the OutputPage being used for this instance.
5546 * IndexPager extends ContextSource as of 1.19.
5647 *
@@ -136,7 +127,13 @@
137128 );
138129 break;
139130 case 'review_title':
140 - // TODO
 131+ if ( $this->editPage !== false ) {
 132+ $value = Html::element(
 133+ 'a',
 134+ array( 'href' => SpecialPage::getTitleFor( $this->editPage, $this->mCurrentRow->review_id )->getLocalURL() ),
 135+ $value
 136+ );
 137+ }
141138 break;
142139 }
143140
Index: trunk/extensions/Reviews/Reviews.i18n.php
@@ -60,6 +60,7 @@
6161
6262 // Special:MyReviews
6363 'reviews-myreviews-header' => 'This page lists all reviews you posted.',
 64+ 'reviews-myreviews-nosuchreview' => 'You do not have a review with the provided ID, it might have been deleted. All your reviews are listed below.',
6465
6566 // Special:Reviews
6667

Comments

#Comment by Johnduhart (talk | contribs)   19:47, 22 November 2011

Please add message documentation for the newly added messages. Thanks.

#Comment by Jeroen De Dauw (talk | contribs)   23:31, 22 November 2011

Status & tagging log