Property changes on: trunk/extensions/SemanticMediaWiki/languages/SMW_Namespaces.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 1 | + native |
Property changes on: trunk/extensions/SemanticForms/languages/SF_Namespaces.php |
___________________________________________________________________ |
Added: svn:eol-style |
2 | 2 | + native |
Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewActivityArticleFeedbackv5.php |
— | — | @@ -1,367 +1,367 @@ |
2 | | -<?php
|
3 | | -/**
|
4 | | - * ApiViewActivityArticleFeedbackv5 class
|
5 | | - *
|
6 | | - * @package ArticleFeedback
|
7 | | - * @subpackage Api
|
8 | | - * @author Elizabeth M Smith <elizabeth@omniti.com>
|
9 | | - * @version $Id$
|
10 | | - */
|
11 | | -
|
12 | | -/**
|
13 | | - * This class pulls the aggregated ratings for display in Bucket #5
|
14 | | - *
|
15 | | - * @package ArticleFeedback
|
16 | | - * @subpackage Api
|
17 | | - */
|
18 | | -class ApiViewActivityArticleFeedbackv5 extends ApiQueryBase {
|
19 | | -
|
20 | | - /**
|
21 | | - * Constructor
|
22 | | - */
|
23 | | - public function __construct( $query, $moduleName ) {
|
24 | | - parent::__construct( $query, $moduleName, 'af' );
|
25 | | - }
|
26 | | -
|
27 | | - /**
|
28 | | - * Execute the API call: Pull max 25 activity log items for page
|
29 | | - */
|
30 | | - public function execute() {
|
31 | | - global $wgUser; // we need to check permissions in here
|
32 | | - global $wgLang; // timestamp formats
|
33 | | -
|
34 | | - // If we can't hide, we can't see activity, return an empty string
|
35 | | - // front-end should never let you get here, but just in case
|
36 | | - if( !$wgUser->isAllowed( 'aftv5-hide-feedback' )) {
|
37 | | - return;
|
38 | | - }
|
39 | | -
|
40 | | - // These are our valid activity log actions
|
41 | | - $valid = array( 'oversight', 'unoversight', 'hidden', 'unhidden',
|
42 | | - 'decline', 'request', 'unrequest','flag','unflag' );
|
43 | | -
|
44 | | - // get our parameter information
|
45 | | - $params = $this->extractRequestParams();
|
46 | | - $feedbackId = $params['feedbackid'];
|
47 | | - $limit = $params['limit'];
|
48 | | - $continue = $params['continue'];
|
49 | | -
|
50 | | - // fetch our activity database information
|
51 | | - $feedback = $this->fetchFeedback( $feedbackId );
|
52 | | -
|
53 | | - // get the string title for the page
|
54 | | - $page = Title::newFromID( $feedback->af_page_id );
|
55 | | - $title = $page->getPartialURL();
|
56 | | -
|
57 | | - // get our activities
|
58 | | - $activities = $this->fetchActivity( $title, $feedbackId, $limit, $continue);
|
59 | | -
|
60 | | - // overwrite previous continue for new value
|
61 | | - $continue = null;
|
62 | | -
|
63 | | - // generate our html
|
64 | | - $html = '';
|
65 | | -
|
66 | | - // <div class="articleFeedbackv5-activity-pane">
|
67 | | - $html .= Html::openElement( 'div', array(
|
68 | | - 'class' => 'articleFeedbackv5-activity-pane'
|
69 | | - ) );
|
70 | | -
|
71 | | - // <div class="articleFeedbackv5-activity-feedback">
|
72 | | - $html .= Html::openElement( 'div', array(
|
73 | | - 'class' => 'articleFeedbackv5-activity-feedback'
|
74 | | - ) );
|
75 | | -
|
76 | | - // <div>Feedback Post #{$feedbackid} by {$user_link}</div>
|
77 | | - $html .= Html::openElement( 'div', array() );
|
78 | | - $html .= wfMessage( 'articlefeedbackv5-activity-feedback-info',
|
79 | | - array($feedback->af_id))->text()
|
80 | | - . $this->getUserLink($feedback->af_user_id, $feedback->af_user_ip);
|
81 | | - $html .= Html::closeElement( 'div' );
|
82 | | -
|
83 | | - //<div>Posted on {$date} (UTC)</div>
|
84 | | - $html .= Html::element( 'div', array(),
|
85 | | - wfMessage( 'articlefeedbackv5-activity-feedback-date',
|
86 | | - array( $wgLang->timeanddate( $feedback->af_created ) ))->text() );
|
87 | | -
|
88 | | - // <div class="articleFeedbackv5-activity-feedback-permalink">
|
89 | | - $html .= Html::openElement( 'div', array(
|
90 | | - 'class' => 'articleFeedbackv5-activity-feedback-permalink'
|
91 | | - ) );
|
92 | | -
|
93 | | - // <a href="{$permalink}">permalink</a>
|
94 | | - $html .= Linker::link(
|
95 | | - SpecialPage::getTitleFor( 'ArticleFeedbackv5', $title . '/'. $feedback->af_id ),
|
96 | | - wfMessage( 'articlefeedbackv5-activity-permalink' )->text());
|
97 | | -
|
98 | | - // </div> for class="articleFeedbackv5-activity-feedback-permalink"
|
99 | | - $html .= Html::closeElement( 'div' );
|
100 | | -
|
101 | | - // </div> for class="articleFeedbackv5-activity-feedback"
|
102 | | - $html .= Html::closeElement( 'div' );
|
103 | | -
|
104 | | - //<div class="articleFeedbackv5-activity-count">$n actions on this post</div>
|
105 | | - $html .= Html::element( 'div', array('class' => 'articleFeedbackv5-activity-count'),
|
106 | | - wfMessage( 'articlefeedbackv5-activity-count',
|
107 | | - array( $feedback->af_activity_count ))->text() );
|
108 | | -
|
109 | | - // </div> for class="articleFeedbackv5-activity-pane"
|
110 | | - $html .= Html::closeElement( 'div' );
|
111 | | -
|
112 | | - //<div class="articleFeedbackv5-activity-log-items">
|
113 | | - $html .= Html::openElement( 'div', array(
|
114 | | - 'class' => 'articleFeedbackv5-activity-log-items'
|
115 | | - ) );
|
116 | | -
|
117 | | - // divs of activity items
|
118 | | - foreach($activities as $item) {
|
119 | | -
|
120 | | - // if we do not have a valid action, skip this item
|
121 | | - if ( !in_array( $item->log_action, $valid )) {
|
122 | | - continue;
|
123 | | - }
|
124 | | -
|
125 | | - // <div class="articleFeedbackv5-activity-item">
|
126 | | - $html .= Html::openElement( 'div', array(
|
127 | | - 'class' => 'articleFeedbackv5-activity-item'
|
128 | | - ) );
|
129 | | -
|
130 | | - // $user $did_something_on $date
|
131 | | - $html .= $this->getUserLink($item->log_user, $item->log_user_text)
|
132 | | - . Html::element( 'span', array(
|
133 | | - 'class' => 'articleFeedbackv5-activity-item-action'
|
134 | | - ),
|
135 | | - wfMessage( 'articlefeedbackv5-activity-' . $item->log_action,
|
136 | | - array())->text() )
|
137 | | - . $wgLang->timeanddate( $item->log_timestamp );
|
138 | | -
|
139 | | - // optional: <div class="articleFeedbackv5-activity-notes">$notes</div>
|
140 | | - if (!empty($item->log_comment)) {
|
141 | | - $html .= Html::element( 'span',
|
142 | | - array('class' => 'articlefeedbackv5-activity-notes'),
|
143 | | - ': ' . $item->log_comment);
|
144 | | - }
|
145 | | -
|
146 | | - // </div> for class="articleFeedbackv5-activity-item"
|
147 | | - $html .= Html::closeElement( 'div' );
|
148 | | -
|
149 | | - // the last item's log_id should be the continue;
|
150 | | - $continue = $item->log_id;
|
151 | | - }
|
152 | | -
|
153 | | - // figure out if we have more based on our new continue value
|
154 | | - $more = $this->fetchHasMore($title, $feedbackId, $continue);
|
155 | | -
|
156 | | - //optional <div class="articleFeedbackv5-activity-more">Show more Activity</div>
|
157 | | - if ($more) {
|
158 | | - $html .= Html::element( 'div', array('class' => 'articleFeedbackv5-activity-more'),
|
159 | | - wfMessage( 'articlefeedbackv5-activity-more', array())->text() );
|
160 | | - }
|
161 | | -
|
162 | | - // </div> for class="acticleFeedbackv5-activity-log-items"
|
163 | | - $html .= Html::closeElement( 'div' );
|
164 | | -
|
165 | | - // finally add our generated html data
|
166 | | - $result = $this->getResult();
|
167 | | - $result->addValue( $this->getModuleName(), 'limit', $limit );
|
168 | | - $result->addValue( $this->getModuleName(), 'activity', $html );
|
169 | | -
|
170 | | - // continue only goes in if it's not empty
|
171 | | - if ($continue > 0) {
|
172 | | - $result->addValue( $this->getModuleName(), 'continue', $continue );
|
173 | | - }
|
174 | | -
|
175 | | - // more only goes in if there are more entries
|
176 | | - if ($more) {
|
177 | | - $result->addValue( $this->getModuleName(), 'more', $more );
|
178 | | - }
|
179 | | - }
|
180 | | -
|
181 | | - /**
|
182 | | - * Sees if there are additional activity rows to view
|
183 | | - *
|
184 | | - * @param string $title the title of the page
|
185 | | - * @param int $feedbackId identifier for the feedback item we are fetching activity for
|
186 | | - * @param mixed $continue used for offsets
|
187 | | - * @return bool true if there are more rows, or false
|
188 | | - */
|
189 | | - protected function fetchHasMore( $title, $feedbackId, $continue = null ) {
|
190 | | - $dbr = wfGetDB( DB_SLAVE );
|
191 | | -
|
192 | | - $feedback = $dbr->selectField(
|
193 | | - array( 'logging' ),
|
194 | | - array( 'log_id'),
|
195 | | - array(
|
196 | | - 'log_type' => 'articlefeedbackv5',
|
197 | | - 'log_title' => "ArticleFeedbackv5/$title/$feedbackId",
|
198 | | - 'log_id < ' . intval($continue)
|
199 | | - ),
|
200 | | - __METHOD__,
|
201 | | - array(
|
202 | | - 'LIMIT' => 1
|
203 | | - )
|
204 | | - );
|
205 | | -
|
206 | | - return ( (bool) $feedback );
|
207 | | - }
|
208 | | -
|
209 | | - /**
|
210 | | - * Gets some base feedback information
|
211 | | - *
|
212 | | - * @param int $feedbackId identifier for the feedback item we are fetching activity for
|
213 | | - * @return int total number of activity items for feedback item
|
214 | | - */
|
215 | | - protected function fetchFeedback( $feedbackId ) {
|
216 | | - $dbr = wfGetDB( DB_SLAVE );
|
217 | | -
|
218 | | - $feedback = $dbr->selectRow(
|
219 | | - array( 'aft_article_feedback' ),
|
220 | | - array( 'af_id',
|
221 | | - 'af_page_id',
|
222 | | - 'af_user_id',
|
223 | | - 'af_user_ip',
|
224 | | - 'af_created',
|
225 | | - 'af_activity_count'),
|
226 | | - array(
|
227 | | - 'af_id' => $feedbackId,
|
228 | | - ),
|
229 | | - __METHOD__,
|
230 | | - array(
|
231 | | - 'LIMIT' => 1
|
232 | | - )
|
233 | | - );
|
234 | | -
|
235 | | - return $feedback;
|
236 | | - }
|
237 | | -
|
238 | | - /**
|
239 | | - * Gets the last 25 (or a requested continuance) of activity rows taken
|
240 | | - * from the log table
|
241 | | - *
|
242 | | - * @param string $title the title of the page
|
243 | | - * @param int $feedbackId identifier for the feedback item we are fetching activity for
|
244 | | - * @param int $limit total limit number
|
245 | | - * @param mixed $continue used for offsets
|
246 | | - * @return array db record rows
|
247 | | - */
|
248 | | - protected function fetchActivity( $title, $feedbackId, $limit = 25, $continue = null) {
|
249 | | -
|
250 | | - $where = array (
|
251 | | - 'log_type' => 'articlefeedbackv5',
|
252 | | - 'log_title' => "ArticleFeedbackv5/$title/$feedbackId"
|
253 | | - );
|
254 | | -
|
255 | | - if ( null !== $continue ) {
|
256 | | - $where[] = 'log_id < ' . intval($continue);
|
257 | | - }
|
258 | | -
|
259 | | - $dbr = wfGetDB( DB_SLAVE );
|
260 | | - $activity = $dbr->select(
|
261 | | - array( 'logging' ),
|
262 | | - array( 'log_id',
|
263 | | - 'log_action',
|
264 | | - 'log_timestamp',
|
265 | | - 'log_user',
|
266 | | - 'log_user_text',
|
267 | | - 'log_title',
|
268 | | - 'log_comment'),
|
269 | | - $where,
|
270 | | - __METHOD__,
|
271 | | - array(
|
272 | | - 'LIMIT' => ($limit + 1),
|
273 | | - 'ORDER BY' => 'log_timestamp DESC'
|
274 | | - )
|
275 | | - );
|
276 | | -
|
277 | | - return $activity;
|
278 | | - }
|
279 | | -
|
280 | | - /**
|
281 | | - * Gets the allowed parameters
|
282 | | - *
|
283 | | - * @return array the params info, indexed by allowed key
|
284 | | - */
|
285 | | - public function getAllowedParams() {
|
286 | | - return array(
|
287 | | - 'feedbackid' => array(
|
288 | | - ApiBase::PARAM_REQUIRED => true,
|
289 | | - ApiBase::PARAM_TYPE => 'integer',
|
290 | | - ),
|
291 | | - 'limit' => array(
|
292 | | - ApiBase::PARAM_DFLT => 25,
|
293 | | - ApiBase::PARAM_TYPE => 'limit',
|
294 | | - ApiBase::PARAM_MIN => 1,
|
295 | | - ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
|
296 | | - ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
|
297 | | - ),
|
298 | | - 'continue' => null,
|
299 | | - );
|
300 | | - }
|
301 | | -
|
302 | | - /**
|
303 | | - * Gets the parameter descriptions
|
304 | | - *
|
305 | | - * @return array the descriptions, indexed by allowed key
|
306 | | - */
|
307 | | - public function getParamDescription() {
|
308 | | - return array(
|
309 | | - 'feedbackid' => 'ID to get feedback activity for',
|
310 | | - 'limit' => 'How many activity results to return',
|
311 | | - 'continue' => 'When more results are available, use this to continue',
|
312 | | - );
|
313 | | - }
|
314 | | -
|
315 | | - /**
|
316 | | - * Gets the api descriptions
|
317 | | - *
|
318 | | - * @return array the description as the first element in an array
|
319 | | - */
|
320 | | - public function getDescription() {
|
321 | | - return array(
|
322 | | - 'List article feedback activity for a specified page'
|
323 | | - );
|
324 | | - }
|
325 | | -
|
326 | | - /**
|
327 | | - * Gets an example
|
328 | | - *
|
329 | | - * @return array the example as the first element in an array
|
330 | | - */
|
331 | | - protected function getExamples() {
|
332 | | - return array(
|
333 | | - 'api.php?action=query&list=articlefeedbackv5-view-activity&affeedbackid=1',
|
334 | | - );
|
335 | | - }
|
336 | | -
|
337 | | - /**
|
338 | | - * Gets the version info
|
339 | | - *
|
340 | | - * @return string the SVN version info
|
341 | | - */
|
342 | | - public function getVersion() {
|
343 | | - return __CLASS__ . ': $Id$';
|
344 | | - }
|
345 | | -
|
346 | | - /**
|
347 | | - * Creates a user link for a log row
|
348 | | - *
|
349 | | - * @param stdClass $item row from log table db
|
350 | | - * @return string the SVN version info
|
351 | | - */
|
352 | | - protected function getUserLink($user_id, $user_ip) {
|
353 | | - $userId = (int) $user_id;
|
354 | | - if ( $userId !== 0 ) { // logged-in users
|
355 | | - $user = User::newFromId( $userId );
|
356 | | - } else { // IP users
|
357 | | - $userText = $user_ip;
|
358 | | - $user = User::newFromName( $userText, false );
|
359 | | - }
|
360 | | -
|
361 | | - $element = Linker::userLink(
|
362 | | - $user->getId(),
|
363 | | - $user->getName()
|
364 | | - );
|
365 | | - return $element;
|
366 | | - }
|
367 | | -}
|
368 | | -
|
| 2 | +<?php |
| 3 | +/** |
| 4 | + * ApiViewActivityArticleFeedbackv5 class |
| 5 | + * |
| 6 | + * @package ArticleFeedback |
| 7 | + * @subpackage Api |
| 8 | + * @author Elizabeth M Smith <elizabeth@omniti.com> |
| 9 | + * @version $Id$ |
| 10 | + */ |
| 11 | + |
| 12 | +/** |
| 13 | + * This class pulls the aggregated ratings for display in Bucket #5 |
| 14 | + * |
| 15 | + * @package ArticleFeedback |
| 16 | + * @subpackage Api |
| 17 | + */ |
| 18 | +class ApiViewActivityArticleFeedbackv5 extends ApiQueryBase { |
| 19 | + |
| 20 | + /** |
| 21 | + * Constructor |
| 22 | + */ |
| 23 | + public function __construct( $query, $moduleName ) { |
| 24 | + parent::__construct( $query, $moduleName, 'af' ); |
| 25 | + } |
| 26 | + |
| 27 | + /** |
| 28 | + * Execute the API call: Pull max 25 activity log items for page |
| 29 | + */ |
| 30 | + public function execute() { |
| 31 | + global $wgUser; // we need to check permissions in here |
| 32 | + global $wgLang; // timestamp formats |
| 33 | + |
| 34 | + // If we can't hide, we can't see activity, return an empty string |
| 35 | + // front-end should never let you get here, but just in case |
| 36 | + if( !$wgUser->isAllowed( 'aftv5-hide-feedback' )) { |
| 37 | + return; |
| 38 | + } |
| 39 | + |
| 40 | + // These are our valid activity log actions |
| 41 | + $valid = array( 'oversight', 'unoversight', 'hidden', 'unhidden', |
| 42 | + 'decline', 'request', 'unrequest','flag','unflag' ); |
| 43 | + |
| 44 | + // get our parameter information |
| 45 | + $params = $this->extractRequestParams(); |
| 46 | + $feedbackId = $params['feedbackid']; |
| 47 | + $limit = $params['limit']; |
| 48 | + $continue = $params['continue']; |
| 49 | + |
| 50 | + // fetch our activity database information |
| 51 | + $feedback = $this->fetchFeedback( $feedbackId ); |
| 52 | + |
| 53 | + // get the string title for the page |
| 54 | + $page = Title::newFromID( $feedback->af_page_id ); |
| 55 | + $title = $page->getPartialURL(); |
| 56 | + |
| 57 | + // get our activities |
| 58 | + $activities = $this->fetchActivity( $title, $feedbackId, $limit, $continue); |
| 59 | + |
| 60 | + // overwrite previous continue for new value |
| 61 | + $continue = null; |
| 62 | + |
| 63 | + // generate our html |
| 64 | + $html = ''; |
| 65 | + |
| 66 | + // <div class="articleFeedbackv5-activity-pane"> |
| 67 | + $html .= Html::openElement( 'div', array( |
| 68 | + 'class' => 'articleFeedbackv5-activity-pane' |
| 69 | + ) ); |
| 70 | + |
| 71 | + // <div class="articleFeedbackv5-activity-feedback"> |
| 72 | + $html .= Html::openElement( 'div', array( |
| 73 | + 'class' => 'articleFeedbackv5-activity-feedback' |
| 74 | + ) ); |
| 75 | + |
| 76 | + // <div>Feedback Post #{$feedbackid} by {$user_link}</div> |
| 77 | + $html .= Html::openElement( 'div', array() ); |
| 78 | + $html .= wfMessage( 'articlefeedbackv5-activity-feedback-info', |
| 79 | + array($feedback->af_id))->text() |
| 80 | + . $this->getUserLink($feedback->af_user_id, $feedback->af_user_ip); |
| 81 | + $html .= Html::closeElement( 'div' ); |
| 82 | + |
| 83 | + //<div>Posted on {$date} (UTC)</div> |
| 84 | + $html .= Html::element( 'div', array(), |
| 85 | + wfMessage( 'articlefeedbackv5-activity-feedback-date', |
| 86 | + array( $wgLang->timeanddate( $feedback->af_created ) ))->text() ); |
| 87 | + |
| 88 | + // <div class="articleFeedbackv5-activity-feedback-permalink"> |
| 89 | + $html .= Html::openElement( 'div', array( |
| 90 | + 'class' => 'articleFeedbackv5-activity-feedback-permalink' |
| 91 | + ) ); |
| 92 | + |
| 93 | + // <a href="{$permalink}">permalink</a> |
| 94 | + $html .= Linker::link( |
| 95 | + SpecialPage::getTitleFor( 'ArticleFeedbackv5', $title . '/'. $feedback->af_id ), |
| 96 | + wfMessage( 'articlefeedbackv5-activity-permalink' )->text()); |
| 97 | + |
| 98 | + // </div> for class="articleFeedbackv5-activity-feedback-permalink" |
| 99 | + $html .= Html::closeElement( 'div' ); |
| 100 | + |
| 101 | + // </div> for class="articleFeedbackv5-activity-feedback" |
| 102 | + $html .= Html::closeElement( 'div' ); |
| 103 | + |
| 104 | + //<div class="articleFeedbackv5-activity-count">$n actions on this post</div> |
| 105 | + $html .= Html::element( 'div', array('class' => 'articleFeedbackv5-activity-count'), |
| 106 | + wfMessage( 'articlefeedbackv5-activity-count', |
| 107 | + array( $feedback->af_activity_count ))->text() ); |
| 108 | + |
| 109 | + // </div> for class="articleFeedbackv5-activity-pane" |
| 110 | + $html .= Html::closeElement( 'div' ); |
| 111 | + |
| 112 | + //<div class="articleFeedbackv5-activity-log-items"> |
| 113 | + $html .= Html::openElement( 'div', array( |
| 114 | + 'class' => 'articleFeedbackv5-activity-log-items' |
| 115 | + ) ); |
| 116 | + |
| 117 | + // divs of activity items |
| 118 | + foreach($activities as $item) { |
| 119 | + |
| 120 | + // if we do not have a valid action, skip this item |
| 121 | + if ( !in_array( $item->log_action, $valid )) { |
| 122 | + continue; |
| 123 | + } |
| 124 | + |
| 125 | + // <div class="articleFeedbackv5-activity-item"> |
| 126 | + $html .= Html::openElement( 'div', array( |
| 127 | + 'class' => 'articleFeedbackv5-activity-item' |
| 128 | + ) ); |
| 129 | + |
| 130 | + // $user $did_something_on $date |
| 131 | + $html .= $this->getUserLink($item->log_user, $item->log_user_text) |
| 132 | + . Html::element( 'span', array( |
| 133 | + 'class' => 'articleFeedbackv5-activity-item-action' |
| 134 | + ), |
| 135 | + wfMessage( 'articlefeedbackv5-activity-' . $item->log_action, |
| 136 | + array())->text() ) |
| 137 | + . $wgLang->timeanddate( $item->log_timestamp ); |
| 138 | + |
| 139 | + // optional: <div class="articleFeedbackv5-activity-notes">$notes</div> |
| 140 | + if (!empty($item->log_comment)) { |
| 141 | + $html .= Html::element( 'span', |
| 142 | + array('class' => 'articlefeedbackv5-activity-notes'), |
| 143 | + ': ' . $item->log_comment); |
| 144 | + } |
| 145 | + |
| 146 | + // </div> for class="articleFeedbackv5-activity-item" |
| 147 | + $html .= Html::closeElement( 'div' ); |
| 148 | + |
| 149 | + // the last item's log_id should be the continue; |
| 150 | + $continue = $item->log_id; |
| 151 | + } |
| 152 | + |
| 153 | + // figure out if we have more based on our new continue value |
| 154 | + $more = $this->fetchHasMore($title, $feedbackId, $continue); |
| 155 | + |
| 156 | + //optional <div class="articleFeedbackv5-activity-more">Show more Activity</div> |
| 157 | + if ($more) { |
| 158 | + $html .= Html::element( 'div', array('class' => 'articleFeedbackv5-activity-more'), |
| 159 | + wfMessage( 'articlefeedbackv5-activity-more', array())->text() ); |
| 160 | + } |
| 161 | + |
| 162 | + // </div> for class="acticleFeedbackv5-activity-log-items" |
| 163 | + $html .= Html::closeElement( 'div' ); |
| 164 | + |
| 165 | + // finally add our generated html data |
| 166 | + $result = $this->getResult(); |
| 167 | + $result->addValue( $this->getModuleName(), 'limit', $limit ); |
| 168 | + $result->addValue( $this->getModuleName(), 'activity', $html ); |
| 169 | + |
| 170 | + // continue only goes in if it's not empty |
| 171 | + if ($continue > 0) { |
| 172 | + $result->addValue( $this->getModuleName(), 'continue', $continue ); |
| 173 | + } |
| 174 | + |
| 175 | + // more only goes in if there are more entries |
| 176 | + if ($more) { |
| 177 | + $result->addValue( $this->getModuleName(), 'more', $more ); |
| 178 | + } |
| 179 | + } |
| 180 | + |
| 181 | + /** |
| 182 | + * Sees if there are additional activity rows to view |
| 183 | + * |
| 184 | + * @param string $title the title of the page |
| 185 | + * @param int $feedbackId identifier for the feedback item we are fetching activity for |
| 186 | + * @param mixed $continue used for offsets |
| 187 | + * @return bool true if there are more rows, or false |
| 188 | + */ |
| 189 | + protected function fetchHasMore( $title, $feedbackId, $continue = null ) { |
| 190 | + $dbr = wfGetDB( DB_SLAVE ); |
| 191 | + |
| 192 | + $feedback = $dbr->selectField( |
| 193 | + array( 'logging' ), |
| 194 | + array( 'log_id'), |
| 195 | + array( |
| 196 | + 'log_type' => 'articlefeedbackv5', |
| 197 | + 'log_title' => "ArticleFeedbackv5/$title/$feedbackId", |
| 198 | + 'log_id < ' . intval($continue) |
| 199 | + ), |
| 200 | + __METHOD__, |
| 201 | + array( |
| 202 | + 'LIMIT' => 1 |
| 203 | + ) |
| 204 | + ); |
| 205 | + |
| 206 | + return ( (bool) $feedback ); |
| 207 | + } |
| 208 | + |
| 209 | + /** |
| 210 | + * Gets some base feedback information |
| 211 | + * |
| 212 | + * @param int $feedbackId identifier for the feedback item we are fetching activity for |
| 213 | + * @return int total number of activity items for feedback item |
| 214 | + */ |
| 215 | + protected function fetchFeedback( $feedbackId ) { |
| 216 | + $dbr = wfGetDB( DB_SLAVE ); |
| 217 | + |
| 218 | + $feedback = $dbr->selectRow( |
| 219 | + array( 'aft_article_feedback' ), |
| 220 | + array( 'af_id', |
| 221 | + 'af_page_id', |
| 222 | + 'af_user_id', |
| 223 | + 'af_user_ip', |
| 224 | + 'af_created', |
| 225 | + 'af_activity_count'), |
| 226 | + array( |
| 227 | + 'af_id' => $feedbackId, |
| 228 | + ), |
| 229 | + __METHOD__, |
| 230 | + array( |
| 231 | + 'LIMIT' => 1 |
| 232 | + ) |
| 233 | + ); |
| 234 | + |
| 235 | + return $feedback; |
| 236 | + } |
| 237 | + |
| 238 | + /** |
| 239 | + * Gets the last 25 (or a requested continuance) of activity rows taken |
| 240 | + * from the log table |
| 241 | + * |
| 242 | + * @param string $title the title of the page |
| 243 | + * @param int $feedbackId identifier for the feedback item we are fetching activity for |
| 244 | + * @param int $limit total limit number |
| 245 | + * @param mixed $continue used for offsets |
| 246 | + * @return array db record rows |
| 247 | + */ |
| 248 | + protected function fetchActivity( $title, $feedbackId, $limit = 25, $continue = null) { |
| 249 | + |
| 250 | + $where = array ( |
| 251 | + 'log_type' => 'articlefeedbackv5', |
| 252 | + 'log_title' => "ArticleFeedbackv5/$title/$feedbackId" |
| 253 | + ); |
| 254 | + |
| 255 | + if ( null !== $continue ) { |
| 256 | + $where[] = 'log_id < ' . intval($continue); |
| 257 | + } |
| 258 | + |
| 259 | + $dbr = wfGetDB( DB_SLAVE ); |
| 260 | + $activity = $dbr->select( |
| 261 | + array( 'logging' ), |
| 262 | + array( 'log_id', |
| 263 | + 'log_action', |
| 264 | + 'log_timestamp', |
| 265 | + 'log_user', |
| 266 | + 'log_user_text', |
| 267 | + 'log_title', |
| 268 | + 'log_comment'), |
| 269 | + $where, |
| 270 | + __METHOD__, |
| 271 | + array( |
| 272 | + 'LIMIT' => ($limit + 1), |
| 273 | + 'ORDER BY' => 'log_timestamp DESC' |
| 274 | + ) |
| 275 | + ); |
| 276 | + |
| 277 | + return $activity; |
| 278 | + } |
| 279 | + |
| 280 | + /** |
| 281 | + * Gets the allowed parameters |
| 282 | + * |
| 283 | + * @return array the params info, indexed by allowed key |
| 284 | + */ |
| 285 | + public function getAllowedParams() { |
| 286 | + return array( |
| 287 | + 'feedbackid' => array( |
| 288 | + ApiBase::PARAM_REQUIRED => true, |
| 289 | + ApiBase::PARAM_TYPE => 'integer', |
| 290 | + ), |
| 291 | + 'limit' => array( |
| 292 | + ApiBase::PARAM_DFLT => 25, |
| 293 | + ApiBase::PARAM_TYPE => 'limit', |
| 294 | + ApiBase::PARAM_MIN => 1, |
| 295 | + ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1, |
| 296 | + ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2 |
| 297 | + ), |
| 298 | + 'continue' => null, |
| 299 | + ); |
| 300 | + } |
| 301 | + |
| 302 | + /** |
| 303 | + * Gets the parameter descriptions |
| 304 | + * |
| 305 | + * @return array the descriptions, indexed by allowed key |
| 306 | + */ |
| 307 | + public function getParamDescription() { |
| 308 | + return array( |
| 309 | + 'feedbackid' => 'ID to get feedback activity for', |
| 310 | + 'limit' => 'How many activity results to return', |
| 311 | + 'continue' => 'When more results are available, use this to continue', |
| 312 | + ); |
| 313 | + } |
| 314 | + |
| 315 | + /** |
| 316 | + * Gets the api descriptions |
| 317 | + * |
| 318 | + * @return array the description as the first element in an array |
| 319 | + */ |
| 320 | + public function getDescription() { |
| 321 | + return array( |
| 322 | + 'List article feedback activity for a specified page' |
| 323 | + ); |
| 324 | + } |
| 325 | + |
| 326 | + /** |
| 327 | + * Gets an example |
| 328 | + * |
| 329 | + * @return array the example as the first element in an array |
| 330 | + */ |
| 331 | + protected function getExamples() { |
| 332 | + return array( |
| 333 | + 'api.php?action=query&list=articlefeedbackv5-view-activity&affeedbackid=1', |
| 334 | + ); |
| 335 | + } |
| 336 | + |
| 337 | + /** |
| 338 | + * Gets the version info |
| 339 | + * |
| 340 | + * @return string the SVN version info |
| 341 | + */ |
| 342 | + public function getVersion() { |
| 343 | + return __CLASS__ . ': $Id$'; |
| 344 | + } |
| 345 | + |
| 346 | + /** |
| 347 | + * Creates a user link for a log row |
| 348 | + * |
| 349 | + * @param stdClass $item row from log table db |
| 350 | + * @return string the SVN version info |
| 351 | + */ |
| 352 | + protected function getUserLink($user_id, $user_ip) { |
| 353 | + $userId = (int) $user_id; |
| 354 | + if ( $userId !== 0 ) { // logged-in users |
| 355 | + $user = User::newFromId( $userId ); |
| 356 | + } else { // IP users |
| 357 | + $userText = $user_ip; |
| 358 | + $user = User::newFromName( $userText, false ); |
| 359 | + } |
| 360 | + |
| 361 | + $element = Linker::userLink( |
| 362 | + $user->getId(), |
| 363 | + $user->getName() |
| 364 | + ); |
| 365 | + return $element; |
| 366 | + } |
| 367 | +} |
| 368 | + |
Property changes on: trunk/extensions/ArticleFeedbackv5/api/ApiViewActivityArticleFeedbackv5.php |
___________________________________________________________________ |
Added: svn:eol-style |
369 | 369 | + native |
Property changes on: trunk/extensions/EducationProgram/includes/EPArticles.php |
___________________________________________________________________ |
Added: svn:eol-style |
370 | 370 | + native |
Property changes on: trunk/extensions/EducationProgram/includes/EPPageTable.php |
___________________________________________________________________ |
Added: svn:eol-style |
371 | 371 | + native |
Property changes on: trunk/extensions/EducationProgram/resources/ep.disenroll.js |
___________________________________________________________________ |
Added: svn:eol-style |
372 | 372 | + native |