Index: trunk/extensions/Reviews/includes/ReviewControl.php |
— | — | @@ -19,8 +19,8 @@ |
20 | 20 | 'class' => 'review-control', |
21 | 21 | ); |
22 | 22 | |
23 | | - $pageId = is_null( $this->review ) ? $context->getTitle()->getArticleID() : $this->review->getField( 'page_id' ); |
24 | | - $types = ReviewRating::getTypesForPageID( $pageId ); |
| 23 | + $title = is_null( $this->review ) ? $context->getTitle() : Title::newFromID( $this->review->getField( 'page_id' ) ); |
| 24 | + $types = is_null( $title ) ? array() : ReviewRating::getTypesForTitleText( $title->getFullText() ); |
25 | 25 | |
26 | 26 | if ( is_null( $this->review ) ) { |
27 | 27 | $ratings = array(); |
— | — | @@ -30,7 +30,7 @@ |
31 | 31 | } |
32 | 32 | |
33 | 33 | $review = array( |
34 | | - 'page_id' => $pageId, |
| 34 | + 'page_id' => $title->getArticleID(), |
35 | 35 | 'title' => '', |
36 | 36 | 'text' => '', |
37 | 37 | 'rating' => 0, |
Index: trunk/extensions/Reviews/includes/ReviewRating.php |
— | — | @@ -69,11 +69,11 @@ |
70 | 70 | * |
71 | 71 | * @since 0.1 |
72 | 72 | * |
73 | | - * @param integer $pageId |
| 73 | + * @param string $titleText |
74 | 74 | * |
75 | 75 | * @return array |
76 | 76 | */ |
77 | | - public static function getTypesForPageID( $pageId ) { |
| 77 | + public static function getTypesForTitleText( $titleText ) { |
78 | 78 | $ratingsPerCat = ReviewsSettings::get( 'categoryRatings' ); |
79 | 79 | $ratings = array(); |
80 | 80 | |
— | — | @@ -81,7 +81,7 @@ |
82 | 82 | 'action' => 'query', |
83 | 83 | 'format' => 'json', |
84 | 84 | 'prop' => 'categories', |
85 | | - 'titles' => Title::newFromID( $pageId )->getFullText(), |
| 85 | + 'titles' => $titleText, |
86 | 86 | ), true ), true ); |
87 | 87 | |
88 | 88 | $api->execute(); |
— | — | @@ -92,11 +92,13 @@ |
93 | 93 | } |
94 | 94 | |
95 | 95 | foreach ( $result['query']['pages'] as $page ) { |
96 | | - foreach ( $page['categories'] as $cat ) { |
97 | | - $cat = explode( ':', $cat['title'], 2 ); |
98 | | - $cat = $cat[1]; |
99 | | - if ( array_key_exists( $cat, $ratingsPerCat ) ) { |
100 | | - $ratings = array_merge( $ratings, $ratingsPerCat[$cat] ); |
| 96 | + if ( array_key_exists( 'categories', $page ) ) { |
| 97 | + foreach ( $page['categories'] as $cat ) { |
| 98 | + $cat = explode( ':', $cat['title'], 2 ); |
| 99 | + $cat = $cat[1]; |
| 100 | + if ( array_key_exists( $cat, $ratingsPerCat ) ) { |
| 101 | + $ratings = array_merge( $ratings, $ratingsPerCat[$cat] ); |
| 102 | + } |
101 | 103 | } |
102 | 104 | } |
103 | 105 | } |
Index: trunk/extensions/Reviews/Reviews.hooks.php |
— | — | @@ -135,7 +135,7 @@ |
136 | 136 | /* User */ $user = $skin->getUser(); |
137 | 137 | |
138 | 138 | if ( $user->isLoggedIn() && $user->isAllowed( 'postreview' ) && $user->getOption( 'reviews_showcontrol' ) |
139 | | - && $out->isArticle() |
| 139 | + && $out->isArticle() && $skin->getTitle()->exists() |
140 | 140 | && $skin->getRequest()->getText( 'action' ) !== 'edit' ) { |
141 | 141 | |
142 | 142 | $review = Review::selectRow( null, array( |