Index: trunk/extensions/Reviews/specials/SpecialMyReviews.php |
— | — | @@ -58,19 +58,34 @@ |
59 | 59 | |
60 | 60 | } |
61 | 61 | else { |
62 | | - $this->getOutput()->addWikiMsg( 'reviews-myreviews-header' ); |
63 | | - |
64 | 62 | if ( $subPage === '' ) { |
| 63 | + $this->getOutput()->addWikiMsg( 'reviews-myreviews-header' ); |
65 | 64 | $this->displayReviewList(); |
66 | 65 | } |
67 | 66 | 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 | + } |
69 | 76 | } |
70 | 77 | } |
71 | 78 | } |
72 | 79 | |
| 80 | + /** |
| 81 | + * Display the list of reviews for this user. |
| 82 | + * |
| 83 | + * @since 0.1 |
| 84 | + */ |
73 | 85 | 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 | + ); |
75 | 90 | |
76 | 91 | if ( $reviewPager->getNumRows() ) { |
77 | 92 | $this->getOutput()->addHTML( |
— | — | @@ -83,5 +98,17 @@ |
84 | 99 | $this->getOutput()->addWikiMsg( 'reviews-pager-no-results' ); |
85 | 100 | } |
86 | 101 | } |
| 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 | + } |
87 | 114 | |
88 | 115 | } |
Index: trunk/extensions/Reviews/includes/ReviewPager.php |
— | — | @@ -14,42 +14,33 @@ |
15 | 15 | class ReviewPager extends TablePager { |
16 | 16 | |
17 | 17 | /** |
18 | | - * Query conditions, full field names (ie inc prefix). |
| 18 | + * Query conditions, full field names (inc prefix). |
19 | 19 | * @var array |
20 | 20 | */ |
21 | 21 | protected $conds; |
22 | 22 | |
23 | 23 | /** |
| 24 | + * Name of a special page to which the review titles should link. |
| 25 | + * @var string|false $editPage |
| 26 | + */ |
| 27 | + protected $editPage; |
| 28 | + |
| 29 | + /** |
24 | 30 | * Constructor. |
25 | 31 | * |
26 | 32 | * @param array $conds |
| 33 | + * @param string|false $editPage |
27 | 34 | */ |
28 | | - public function __construct( array $conds ) { |
| 35 | + public function __construct( array $conds, $editPage = false ) { |
29 | 36 | $this->conds = $conds; |
30 | 37 | $this->mDefaultDirection = true; |
| 38 | + $this->editPage = $editPage; |
31 | 39 | |
32 | 40 | // when MW 1.19 becomes min, we want to pass an IContextSource $context here. |
33 | 41 | parent::__construct(); |
34 | 42 | } |
35 | 43 | |
36 | 44 | /** |
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 | | - /** |
54 | 45 | * Get the OutputPage being used for this instance. |
55 | 46 | * IndexPager extends ContextSource as of 1.19. |
56 | 47 | * |
— | — | @@ -136,7 +127,13 @@ |
137 | 128 | ); |
138 | 129 | break; |
139 | 130 | 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 | + } |
141 | 138 | break; |
142 | 139 | } |
143 | 140 | |
Index: trunk/extensions/Reviews/Reviews.i18n.php |
— | — | @@ -60,6 +60,7 @@ |
61 | 61 | |
62 | 62 | // Special:MyReviews |
63 | 63 | '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.', |
64 | 65 | |
65 | 66 | // Special:Reviews |
66 | 67 | |