Index: trunk/extensions/Reviews/sql/Reviews.sql |
— | — | @@ -16,7 +16,10 @@ |
17 | 17 | ) /*$wgDBTableOptions*/; |
18 | 18 | |
19 | 19 | CREATE UNIQUE INDEX /*i*/review_page_user ON /*_*/reviews (review_page_id, review_user_id); |
20 | | -CREATE INDEX /*i*/review_time ON /*_*/reviews (review_time); |
| 20 | +CREATE INDEX /*i*/review_user_id ON /*_*/reviews (review_user_id); |
| 21 | +CREATE INDEX /*i*/review_title ON /*_*/reviews (review_title); |
| 22 | +CREATE INDEX /*i*/review_post_time ON /*_*/reviews (review_post_time); |
| 23 | +CREATE INDEX /*i*/review_edit_time ON /*_*/reviews (review_edit_time); |
21 | 24 | CREATE INDEX /*i*/review_state ON /*_*/reviews (review_state); |
22 | 25 | CREATE INDEX /*i*/review_rating ON /*_*/reviews (review_rating); |
23 | 26 | |
— | — | @@ -28,3 +31,4 @@ |
29 | 32 | ) /*$wgDBTableOptions*/; |
30 | 33 | |
31 | 34 | CREATE UNIQUE INDEX /*i*/rrating_review_type ON /*_*/review_ratings (rating_review_id, rating_type); |
| 35 | +CREATE INDEX /*i*/review_rating_type ON /*_*/review_ratings (rating_type); |
Index: trunk/extensions/Reviews/specials/SpecialReviews.php |
— | — | @@ -21,7 +21,7 @@ |
22 | 22 | * @since 0.1 |
23 | 23 | */ |
24 | 24 | public function __construct() { |
25 | | - parent::__construct( 'Reviews', 'reviewer' ); |
| 25 | + parent::__construct( 'Reviews', 'review' ); |
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
— | — | @@ -32,6 +32,7 @@ |
33 | 33 | * @param string $arg |
34 | 34 | */ |
35 | 35 | public function execute( $subPage ) { |
| 36 | + $subPage = is_null( $subPage ) ? '' : $subPage; |
36 | 37 | $this->subPage = str_replace( '_', ' ', $subPage ); |
37 | 38 | |
38 | 39 | $this->setHeaders(); |
— | — | @@ -51,12 +52,23 @@ |
52 | 53 | $this->displayReviewList(); |
53 | 54 | } |
54 | 55 | else { |
55 | | - |
56 | 56 | } |
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
60 | 60 | protected function displayReviewList() { |
| 61 | + $reviewPager = new ReviewPager( array() ); |
| 62 | + |
| 63 | + if ( $reviewPager->getNumRows() ) { |
| 64 | + $this->getOutput()->addHTML( |
| 65 | + $reviewPager->getNavigationBar() . |
| 66 | + $reviewPager->getBody() . |
| 67 | + $reviewPager->getNavigationBar() |
| 68 | + ); |
| 69 | + } |
| 70 | + else { |
| 71 | + $this->getOutput()->addWikiMsg( 'reviews-pager-no-results' ); |
| 72 | + } |
61 | 73 | } |
62 | 74 | |
63 | 75 | } |
Index: trunk/extensions/Reviews/includes/ReviewPager.php |
— | — | @@ -81,7 +81,11 @@ |
82 | 82 | |
83 | 83 | if ( is_null( $headers ) ) { |
84 | 84 | $headers = array( |
85 | | - // TODO |
| 85 | + 'reviews-pager-post-time', |
| 86 | + 'reviews-pager-state', |
| 87 | + 'reviews-pager-title', |
| 88 | + 'reviews-pager-user', |
| 89 | + 'reviews-pager-page', |
86 | 90 | ); |
87 | 91 | |
88 | 92 | $headers = array_map( 'wfMsg', $headers ); |
— | — | @@ -117,7 +121,12 @@ |
118 | 122 | return array( |
119 | 123 | 'tables' => array( 'reviews' ), |
120 | 124 | 'fields' => array( |
121 | | - // TODO |
| 125 | + 'review_id', |
| 126 | + 'review_post_time', |
| 127 | + 'review_state', |
| 128 | + 'review_title', |
| 129 | + 'review_user_id', |
| 130 | + 'review_page_id', |
122 | 131 | ), |
123 | 132 | 'conds' => $this->conds, |
124 | 133 | ); |
— | — | @@ -132,7 +141,7 @@ |
133 | 142 | } |
134 | 143 | |
135 | 144 | function getDefaultSort() { |
136 | | - return 'review_time'; |
| 145 | + return 'review_post_time'; |
137 | 146 | } |
138 | 147 | |
139 | 148 | function isFieldSortable( $name ) { |
Index: trunk/extensions/Reviews/Reviews.i18n.php |
— | — | @@ -25,7 +25,7 @@ |
26 | 26 | |
27 | 27 | // Rights |
28 | 28 | 'right-reviewsadmin' => 'Manage reviews', |
29 | | - 'right-reviewer' => 'Post reviews', |
| 29 | + 'right-review' => 'Post reviews', |
30 | 30 | |
31 | 31 | 'action-reviewsadmin' => 'manage reviews', |
32 | 32 | 'action-reviewer' => 'post reviews', |
— | — | @@ -38,4 +38,7 @@ |
39 | 39 | 'group-reviewer' => 'Reviewer', |
40 | 40 | 'group-reviewer-member' => '{{GENDER:$1|Reviewer}}', |
41 | 41 | 'grouppage-reviewer' => '{{ns:project}}:Reviewers', |
| 42 | + |
| 43 | + // Review control |
| 44 | + 'reviews-submission-submit' => 'Submit', |
42 | 45 | ); |
Index: trunk/extensions/Reviews/api/ApiSubmitReview.php |
— | — | @@ -21,25 +21,29 @@ |
22 | 22 | |
23 | 23 | $params = $this->extractRequestParams(); |
24 | 24 | |
25 | | - if ( !( isset( $params['id'] ) XOR isset( $params['name'] ) ) ) { |
26 | | - $this->dieUsage( wfMsgExt( 'review-err-id-xor-name' ), 'id-xor-name' ); |
27 | | - } |
| 25 | + unset( $params['token'] ); |
| 26 | + $params['edit_time'] = wfTimestampNow(); |
| 27 | + $params['user_id'] = $this->getUser()->getId(); |
28 | 28 | |
29 | | - if ( isset( $params['name'] ) ) { |
30 | | - $review = Review::selectRow( null, array( 'name' => $params['name'] ) ); |
| 29 | + if ( array_key_exists( 'id', $params ) ) { |
| 30 | + $review = Review::selectRow( array( 'id', 'user_id' ), array( 'id' => $params['id'] ) ); |
31 | 31 | |
32 | | - if ( $review === false ) { |
33 | | - $this->dieUsage( wfMsgExt( 'review-err-review-name-unknown', 'parsemag', $params['name'] ), 'review-name-unknown' ); |
| 32 | + if ( $review->getField( 'user_id' ) === $this->getUser()->getId() ) { |
| 33 | + $review->setFields( $params ); |
| 34 | + $review->writeToDB(); |
34 | 35 | } |
35 | | - } else { |
36 | | - $review = Review::selectRow( null, array( 'id' => $params['id'] ) ); |
37 | | - |
38 | | - if ( $review === false ) { |
39 | | - $this->dieUsage( wfMsgExt( 'review-err-review-id-unknown', 'parsemag', $params['id'] ), 'review-id-unknown' ); |
| 36 | + else { |
| 37 | + $this->dieUsageMsg( array( 'badaccess-groups' ) ); |
40 | 38 | } |
41 | 39 | } |
42 | | - |
43 | | - // TODO |
| 40 | + else { |
| 41 | + $review = new Review( $params ); |
| 42 | + |
| 43 | + $review->setField( 'state', Review::STATUS_NEW ); |
| 44 | + $review->setField( 'post_time', wfTimestampNow() ); |
| 45 | + |
| 46 | + $review->writeToDB(); |
| 47 | + } |
44 | 48 | } |
45 | 49 | |
46 | 50 | public function needsToken() { |
— | — | @@ -51,24 +55,49 @@ |
52 | 56 | } |
53 | 57 | |
54 | 58 | public function getAllowedParams() { |
55 | | - return array( |
| 59 | + $params = array( |
56 | 60 | 'id' => array( |
57 | 61 | ApiBase::PARAM_TYPE => 'integer', |
58 | 62 | ), |
59 | | - 'name' => array( |
| 63 | + 'title' => array( |
60 | 64 | ApiBase::PARAM_TYPE => 'string', |
| 65 | + ApiBase::PARAM_REQUIRED => true, |
61 | 66 | ), |
| 67 | + 'text' => array( |
| 68 | + ApiBase::PARAM_TYPE => 'string', |
| 69 | + ApiBase::PARAM_REQUIRED => true, |
| 70 | + ), |
| 71 | + 'rating' => array( |
| 72 | + ApiBase::PARAM_TYPE => 'integer', |
| 73 | + ApiBase::PARAM_REQUIRED => true, |
| 74 | + ), |
| 75 | + 'ratings' => array( |
| 76 | + ApiBase::PARAM_TYPE => 'string', |
| 77 | + ApiBase::PARAM_REQUIRED => true, |
| 78 | + ), |
| 79 | + 'page_id' => array( |
| 80 | + ApiBase::PARAM_TYPE => 'integer', |
| 81 | + ApiBase::PARAM_REQUIRED => true, |
| 82 | + ), |
62 | 83 | // TODO |
63 | 84 | 'token' => null, |
64 | 85 | ); |
| 86 | + |
| 87 | + return $params; |
65 | 88 | } |
66 | 89 | |
67 | 90 | public function getParamDescription() { |
68 | | - return array( |
69 | | - 'id' => 'The ID of the review being submitted.', |
70 | | - 'name' => 'The name of the review being submitted.', |
| 91 | + $descs = array( |
| 92 | + 'id' => 'The ID of the review being submitted, ommit for new review.', |
71 | 93 | 'token' => 'Edit token. You can get one of these through prop=info.', |
| 94 | + 'title' => 'The review title', |
| 95 | + 'text' => 'The review text', |
| 96 | + 'rating' => 'The main rating for the review', |
| 97 | + 'ratings' => 'JSON string holding the rating data', |
| 98 | + 'page_id' => 'The ID of the page to which the review belongs', |
72 | 99 | ); |
| 100 | + |
| 101 | + return $descs; |
73 | 102 | } |
74 | 103 | |
75 | 104 | public function getDescription() { |
Index: trunk/extensions/Reviews/Reviews.php |
— | — | @@ -84,7 +84,7 @@ |
85 | 85 | |
86 | 86 | // Rights |
87 | 87 | $wgAvailableRights[] = 'reviewsadmin'; |
88 | | -$wgAvailableRights[] = 'reviewer'; |
| 88 | +$wgAvailableRights[] = 'review'; |
89 | 89 | |
90 | 90 | # Users that can manage the reviews. |
91 | 91 | $wgGroupPermissions['*' ]['reviewsadmin'] = false; |
— | — | @@ -95,12 +95,12 @@ |
96 | 96 | $wgGroupPermissions['reviewsadmin' ]['reviewsadmin'] = true; |
97 | 97 | |
98 | 98 | # Users that can post reviews. |
99 | | -$wgGroupPermissions['*' ]['reviewer'] = false; |
100 | | -$wgGroupPermissions['user' ]['reviewer'] = true; |
101 | | -//$wgGroupPermissions['autoconfirmed']['reviewer'] = true; |
102 | | -//$wgGroupPermissions['bot' ]['reviewer'] = false; |
103 | | -$wgGroupPermissions['sysop' ]['reviewer'] = true; |
104 | | -$wgGroupPermissions['reviewer']['reviewer'] = true; |
| 99 | +$wgGroupPermissions['*' ]['review'] = false; |
| 100 | +$wgGroupPermissions['user' ]['review'] = true; |
| 101 | +//$wgGroupPermissions['autoconfirmed']['review'] = true; |
| 102 | +//$wgGroupPermissions['bot' ]['review'] = false; |
| 103 | +$wgGroupPermissions['sysop' ]['review'] = true; |
| 104 | +$wgGroupPermissions['reviewer']['review'] = true; |
105 | 105 | |
106 | 106 | |
107 | 107 | // Resource loader modules |
— | — | @@ -125,9 +125,10 @@ |
126 | 126 | 'jquery.reviewControl.css', |
127 | 127 | ), |
128 | 128 | 'messages' => array( |
| 129 | + 'reviews-submission-submit' |
129 | 130 | ), |
130 | 131 | 'dependencies' => array( |
131 | | - 'jquery.json', 'ext.reviews' |
| 132 | + 'jquery.json', 'ext.reviews', 'jquery.ui.button', |
132 | 133 | ), |
133 | 134 | ); |
134 | 135 | |
Index: trunk/extensions/Reviews/resources/jquery.reviewControl.js |
— | — | @@ -27,7 +27,15 @@ |
28 | 28 | |
29 | 29 | $this.append( $( '<textarea />' ).attr( { |
30 | 30 | 'name': this.fieldName( 'text' ) |
31 | | - } ).text( this.review.fields.text ) ); |
| 31 | + } ).text( this.review.fields.text ) ); |
| 32 | + |
| 33 | + this.button = $( '<button />' ) |
| 34 | + .button( { 'label': mw.msg( 'reviews-submission-submit' ) } ) |
| 35 | + .click( function() { |
| 36 | + _this.save(); |
| 37 | + } ); |
| 38 | + |
| 39 | + $this.append( this.button ); |
32 | 40 | }; |
33 | 41 | |
34 | 42 | this.setup = function() { |
— | — | @@ -39,15 +47,16 @@ |
40 | 48 | |
41 | 49 | this.readInputs = function() { |
42 | 50 | |
43 | | - this.review = new reviews.review(); // TODO |
| 51 | + //this.review = new reviews.review(); // TODO |
44 | 52 | }; |
45 | 53 | |
46 | 54 | this.save = function() { |
47 | 55 | this.readInputs(); |
48 | 56 | |
| 57 | + this.button.button( 'disable' ); |
49 | 58 | |
50 | 59 | this.review.save( function() { |
51 | | - |
| 60 | + this.button.button( 'enable' ); |
52 | 61 | } ); |
53 | 62 | }; |
54 | 63 | |
Index: trunk/extensions/Reviews/Reviews.hooks.php |
— | — | @@ -23,7 +23,13 @@ |
24 | 24 | * @return true |
25 | 25 | */ |
26 | 26 | public static function onSchemaUpdate( /* DatabaseUpdater */ $updater = null ) { |
27 | | - |
| 27 | + $updater->addExtensionUpdate( array( |
| 28 | + 'addTable', |
| 29 | + 'reviews', |
| 30 | + dirname( __FILE__ ) . '/sql/Reviews.sql', |
| 31 | + true |
| 32 | + ) ); |
| 33 | + |
28 | 34 | return true; |
29 | 35 | } |
30 | 36 | |