Index: trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php |
— | — | @@ -51,15 +51,15 @@ |
52 | 52 | */ |
53 | 53 | public static function getRevisionLimit( $pageId ) { |
54 | 54 | global $wgArticleFeedbackv5RatingLifetime; |
55 | | - $dbr = wfGetDB( DB_SLAVE ); |
| 55 | + $dbr = wfGetDB( DB_SLAVE ); |
56 | 56 | $revision = $dbr->selectField( |
57 | 57 | 'revision', 'rev_id', |
58 | 58 | array( 'rev_page' => $pageId ), |
59 | 59 | __METHOD__, |
60 | 60 | array( |
61 | 61 | 'ORDER BY' => 'rev_id DESC', |
62 | | - 'LIMIT' => 1, |
63 | | - 'OFFSET' => $wgArticleFeedbackv5RatingLifetime - 1 |
| 62 | + 'LIMIT' => 1, |
| 63 | + 'OFFSET' => $wgArticleFeedbackv5RatingLifetime - 1 |
64 | 64 | ) |
65 | 65 | ); |
66 | 66 | return $revision ? intval( $revision ) : 0; |
— | — | @@ -73,32 +73,32 @@ |
74 | 74 | public static function getFields() { |
75 | 75 | global $wgMemc; |
76 | 76 | |
77 | | - $key = wfMemcKey( 'articlefeedbackv5', 'getFields' ); |
| 77 | + $key = wfMemcKey( 'articlefeedbackv5', 'getFields' ); |
78 | 78 | $cached = $wgMemc->get( $key ); |
79 | 79 | |
80 | | - if( $cached != '' ) { |
| 80 | + if ( $cached != '' ) { |
81 | 81 | return $cached; |
82 | 82 | } else { |
83 | | - $rv = array(); |
84 | | - $dbr = wfGetDB( DB_SLAVE ); |
| 83 | + $rv = array(); |
| 84 | + $dbr = wfGetDB( DB_SLAVE ); |
85 | 85 | $rows = $dbr->select( |
86 | 86 | 'aft_article_field', |
87 | | - array( |
88 | | - 'afi_name', |
89 | | - 'afi_id', |
90 | | - 'afi_data_type', |
91 | | - 'afi_bucket_id' |
| 87 | + array( |
| 88 | + 'afi_name', |
| 89 | + 'afi_id', |
| 90 | + 'afi_data_type', |
| 91 | + 'afi_bucket_id' |
92 | 92 | ), |
93 | | - null, |
| 93 | + null, |
94 | 94 | __METHOD__ |
95 | 95 | ); |
96 | 96 | |
97 | | - foreach( $rows as $row ) { |
| 97 | + foreach ( $rows as $row ) { |
98 | 98 | $rv[] = array( |
99 | | - 'afi_name' => $row->afi_name, |
100 | | - 'afi_id' => $row->afi_id, |
101 | | - 'afi_data_type' => $row->afi_data_type, |
102 | | - 'afi_bucket_id' => $row->afi_bucket_id |
| 99 | + 'afi_name' => $row->afi_name, |
| 100 | + 'afi_id' => $row->afi_id, |
| 101 | + 'afi_data_type' => $row->afi_data_type, |
| 102 | + 'afi_bucket_id' => $row->afi_bucket_id |
103 | 103 | ); |
104 | 104 | } |
105 | 105 | |
— | — | @@ -112,7 +112,7 @@ |
113 | 113 | /** |
114 | 114 | * Gets the known feedback options |
115 | 115 | * |
116 | | - * Pulls all the rows in the aft_article_field_option table, then |
| 116 | + * Pulls all the rows in the aft_article_field_option table, then |
117 | 117 | * arranges them like so: |
118 | 118 | * {field id} => array( |
119 | 119 | * {option id} => {option name}, |
— | — | @@ -121,32 +121,32 @@ |
122 | 122 | * @return array the rows in the aft_article_field_option table |
123 | 123 | */ |
124 | 124 | public static function getOptions() { |
125 | | - global $wgMemc; |
| 125 | + global $wgMemc; |
126 | 126 | |
127 | | - $key = wfMemcKey( 'articlefeedbackv5', 'getOptions' ); |
128 | | - $cached = $wgMemc->get( $key ); |
| 127 | + $key = wfMemcKey( 'articlefeedbackv5', 'getOptions' ); |
| 128 | + $cached = $wgMemc->get( $key ); |
129 | 129 | |
130 | | - if( $cached != '' ) { |
131 | | - return $cached; |
132 | | - } else { |
133 | | - $rv = array(); |
134 | | - $dbr = wfGetDB( DB_SLAVE ); |
| 130 | + if ( $cached != '' ) { |
| 131 | + return $cached; |
| 132 | + } else { |
| 133 | + $rv = array(); |
| 134 | + $dbr = wfGetDB( DB_SLAVE ); |
135 | 135 | $rows = $dbr->select( |
136 | 136 | 'aft_article_field_option', |
137 | | - array( |
138 | | - 'afo_option_id', |
139 | | - 'afo_field_id', |
140 | | - 'afo_name' |
| 137 | + array( |
| 138 | + 'afo_option_id', |
| 139 | + 'afo_field_id', |
| 140 | + 'afo_name' |
141 | 141 | ), |
142 | | - null, |
| 142 | + null, |
143 | 143 | __METHOD__ |
144 | 144 | ); |
145 | 145 | foreach ( $rows as $row ) { |
146 | 146 | $rv[$row->afo_field_id][$row->afo_option_id] = $row->afo_name; |
147 | 147 | } |
148 | | - // An hour? That might be reasonable for a cache time. |
149 | | - $wgMemc->set( $key, $rv, 60 * 60 ); |
150 | | - } |
| 148 | + // An hour? That might be reasonable for a cache time. |
| 149 | + $wgMemc->set( $key, $rv, 60 * 60 ); |
| 150 | + } |
151 | 151 | return $rv; |
152 | 152 | } |
153 | 153 | } |
Index: trunk/extensions/ArticleFeedbackv5/SpecialArticleFeedbackv5.php |
— | — | @@ -15,12 +15,12 @@ |
16 | 16 | } |
17 | 17 | |
18 | 18 | $ratings = $this->fetchOverallRating( $pageId ); |
19 | | - $found = isset( $ratings['found'] ) ? $ratings['found'] : null; |
20 | | - $rating = isset( $ratings['rating'] ) ? $ratings['rating'] : null; |
| 19 | + $found = isset( $ratings['found'] ) ? $ratings['found'] : null; |
| 20 | + $rating = isset( $ratings['rating'] ) ? $ratings['rating'] : null; |
21 | 21 | |
22 | 22 | $out->setPagetitle( "Feedback for $title" ); |
23 | 23 | |
24 | | - if( !$pageId ) { |
| 24 | + if ( !$pageId ) { |
25 | 25 | $out->addWikiMsg( 'articlefeedbackv5-invalid-page-id' ); |
26 | 26 | } else { |
27 | 27 | $out->addHTML( |
— | — | @@ -28,33 +28,33 @@ |
29 | 29 | Title::newFromText( $param ), |
30 | 30 | $this->msg( 'articlefeedbackv5-go-to-article' )->escaped() |
31 | 31 | ) |
32 | | - .' | '. |
33 | | - Linker::link( |
34 | | - Title::newFromText( $param ), |
35 | | - $this->msg( 'articlefeedbackv5-discussion-page' )->escaped() |
36 | | - ) |
37 | | - .' | '. |
38 | | - Linker::link( |
39 | | - Title::newFromText( $param ), |
40 | | - $this->msg( 'articlefeedbackv5-whats-this' )->escaped() |
41 | | - ) |
| 32 | + . ' | ' . |
| 33 | + Linker::link( |
| 34 | + Title::newFromText( $param ), |
| 35 | + $this->msg( 'articlefeedbackv5-discussion-page' )->escaped() |
| 36 | + ) |
| 37 | + . ' | ' . |
| 38 | + Linker::link( |
| 39 | + Title::newFromText( $param ), |
| 40 | + $this->msg( 'articlefeedbackv5-whats-this' )->escaped() |
| 41 | + ) |
42 | 42 | ); |
43 | 43 | } |
44 | 44 | |
45 | | - if( $found ) { |
| 45 | + if ( $found ) { |
46 | 46 | $out->addWikiMsg( 'articlefeedbackv5-percent-found', $found ); |
47 | 47 | } |
48 | 48 | |
49 | | - if( $rating ) { |
50 | | - $out->addWikiMsg( 'articlefeedbackv5-overall-rating', $rating); |
| 49 | + if ( $rating ) { |
| 50 | + $out->addWikiMsg( 'articlefeedbackv5-overall-rating', $rating ); |
51 | 51 | } |
52 | 52 | |
53 | 53 | $out->addWikiMsg( 'articlefeedbackv5-special-title' ); |
54 | 54 | |
55 | 55 | $showing = $this->msg( |
56 | 56 | 'articlefeedbackv5-special-showing', |
57 | | - Html::element( 'span', array( 'id' => 'aft-feedback-count-shown' ), '0'), |
58 | | - Html::element( 'span', array( 'id' => 'aft-feedback-count-total' ), '0') |
| 57 | + Html::element( 'span', array( 'id' => 'aft-feedback-count-shown' ), '0' ), |
| 58 | + Html::element( 'span', array( 'id' => 'aft-feedback-count-total' ), '0' ) |
59 | 59 | ); |
60 | 60 | |
61 | 61 | $out->addJsConfigVars( 'afPageId', $pageId ); |
— | — | @@ -62,29 +62,37 @@ |
63 | 63 | |
64 | 64 | $filterSelect = new XmlSelect( false, 'aft5-filter' ); |
65 | 65 | $filterSelect->addOptions( $this->selectMsg( array( |
66 | | - 'articlefeedbackv5-special-filter-visible' => 'visible', |
67 | | - 'articlefeedbackv5-special-filter-invisible' => 'invisible', |
68 | | - 'articlefeedbackv5-special-filter-all' => 'all', |
69 | | - ) ) ); |
| 66 | + 'articlefeedbackv5-special-filter-visible' => 'visible', |
| 67 | + 'articlefeedbackv5-special-filter-invisible' => 'invisible', |
| 68 | + 'articlefeedbackv5-special-filter-all' => 'all', |
| 69 | + ) |
| 70 | + ) |
| 71 | + ); |
70 | 72 | |
71 | 73 | $sortSelect = new XmlSelect( false, 'aft5-sort' ); |
72 | 74 | $sortSelect->addOptions( $this->selectMsg( array( |
73 | | - 'articlefeedbackv5-special-sort-newest' => 'newest', |
74 | | - 'articlefeedbackv5-special-sort-oldest' => 'oldest', |
75 | | - ) ) ); |
| 75 | + 'articlefeedbackv5-special-sort-newest' => 'newest', |
| 76 | + 'articlefeedbackv5-special-sort-oldest' => 'oldest', |
| 77 | + ) |
| 78 | + ) |
| 79 | + ); |
76 | 80 | |
77 | | - $out->addHTML($this->msg('articlefeedbackv5-special-filter-label-before')->escaped() |
78 | | - . $filterSelect->getHTML() |
79 | | - . $this->msg('articlefeedbackv5-special-filter-label-after')->escaped() |
80 | | - . ' | ' |
81 | | - . $this->msg('articlefeedbackv5-special-sort-label-before')->escaped() |
82 | | - . $sortSelect->getHTML() |
83 | | - . $this->msg('articlefeedbackv5-special-sort-label-after')->escaped() |
84 | | - . Html::element( 'span', array( 'id' => 'aft-showing' ), $showing ) |
85 | | - . Html::element( 'div', array( 'id' => 'aft5-show-feedback', |
86 | | - 'style' => 'border:1px solid red;' ), '' ) |
87 | | - . Html::element( 'a', array( 'href' => '#', 'id' => 'aft5-show-more' ), |
88 | | - $this->msg( 'articlefeedbackv5-special-more' )->escaped() ) |
| 81 | + $out->addHTML( $this->msg( 'articlefeedbackv5-special-filter-label-before' )->escaped() |
| 82 | + . $filterSelect->getHTML() |
| 83 | + . $this->msg( 'articlefeedbackv5-special-filter-label-after' )->escaped() |
| 84 | + . ' | ' |
| 85 | + . $this->msg( 'articlefeedbackv5-special-sort-label-before' )->escaped() |
| 86 | + . $sortSelect->getHTML() |
| 87 | + . $this->msg( 'articlefeedbackv5-special-sort-label-after' )->escaped() |
| 88 | + . Html::element( 'span', array( 'id' => 'aft-showing' ), $showing ) |
| 89 | + . Html::element( 'div', array( |
| 90 | + 'id' => 'aft5-show-feedback', |
| 91 | + 'style' => 'border:1px solid red;' |
| 92 | + ), '' |
| 93 | + ) |
| 94 | + . Html::element( 'a', array( 'href' => '#', 'id' => 'aft5-show-more' ), |
| 95 | + $this->msg( 'articlefeedbackv5-special-more' )->escaped() |
| 96 | + ) |
89 | 97 | ); |
90 | 98 | } |
91 | 99 | |
— | — | @@ -105,28 +113,28 @@ |
106 | 114 | } |
107 | 115 | |
108 | 116 | private function fetchOverallRating( $pageId ) { |
109 | | - $rv = array(); |
110 | | - $dbr = wfGetDB( DB_SLAVE ); |
| 117 | + $rv = array(); |
| 118 | + $dbr = wfGetDB( DB_SLAVE ); |
111 | 119 | $rows = $dbr->select( |
112 | | - array( |
| 120 | + array( |
113 | 121 | 'aft_article_feedback_ratings_rollup', |
114 | | - 'aft_article_field' |
| 122 | + 'aft_article_field' |
115 | 123 | ), |
116 | | - array( |
| 124 | + array( |
117 | 125 | 'arr_total / arr_count AS rating', |
118 | 126 | 'afi_name' |
119 | 127 | ), |
120 | | - array( |
| 128 | + array( |
121 | 129 | 'arr_page_id' => $pageId, |
122 | 130 | 'arr_field_id = afi_id', |
123 | 131 | "afi_name IN ('found', 'rating')" |
124 | 132 | ) |
125 | 133 | ); |
126 | 134 | |
127 | | - foreach( $rows as $row ) { |
128 | | - if( $row->afi_name == 'found' ) { |
129 | | - $rv['found'] = ( int ) ( 100 * $row->rating ); |
130 | | - } elseif( $row->afi_name == 'rating' ) { |
| 135 | + foreach ( $rows as $row ) { |
| 136 | + if ( $row->afi_name == 'found' ) { |
| 137 | + $rv['found'] = ( int ) ( 100 * $row->rating ); |
| 138 | + } elseif ( $row->afi_name == 'rating' ) { |
131 | 139 | $rv['rating'] = ( int ) $row->rating; |
132 | 140 | } |
133 | 141 | } |