Use config instead of globals for ImageGallery
[lhc/web/wiklou.git] / includes / specialpage / QueryPage.php
1 <?php
2 /**
3 * Base code for "query" special pages.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup SpecialPage
22 */
23
24 /**
25 * This is a class for doing query pages; since they're almost all the same,
26 * we factor out some of the functionality into a superclass, and let
27 * subclasses derive from it.
28 * @ingroup SpecialPage
29 */
30 abstract class QueryPage extends SpecialPage {
31 /** @var bool Whether or not we want plain listoutput rather than an ordered list */
32 protected $listoutput = false;
33
34 /** @var int The offset and limit in use, as passed to the query() function */
35 protected $offset = 0;
36
37 /** @var int */
38 protected $limit = 0;
39
40 /**
41 * The number of rows returned by the query. Reading this variable
42 * only makes sense in functions that are run after the query has been
43 * done, such as preprocessResults() and formatRow().
44 */
45 protected $numRows;
46
47 protected $cachedTimestamp = null;
48
49 /**
50 * Whether to show prev/next links
51 */
52 protected $shownavigation = true;
53
54 /**
55 * Get a list of query page classes and their associated special pages,
56 * for periodic updates.
57 *
58 * DO NOT CHANGE THIS LIST without testing that
59 * maintenance/updateSpecialPages.php still works.
60 * @return array
61 */
62 public static function getPages() {
63 global $wgDisableCounters;
64 static $qp = null;
65
66 if ( $qp === null ) {
67 // QueryPage subclass, Special page name
68 $qp = array(
69 array( 'AncientPagesPage', 'Ancientpages' ),
70 array( 'BrokenRedirectsPage', 'BrokenRedirects' ),
71 array( 'DeadendPagesPage', 'Deadendpages' ),
72 array( 'DoubleRedirectsPage', 'DoubleRedirects' ),
73 array( 'FileDuplicateSearchPage', 'FileDuplicateSearch' ),
74 array( 'ListDuplicatedFilesPage', 'ListDuplicatedFiles'),
75 array( 'LinkSearchPage', 'LinkSearch' ),
76 array( 'ListredirectsPage', 'Listredirects' ),
77 array( 'LonelyPagesPage', 'Lonelypages' ),
78 array( 'LongPagesPage', 'Longpages' ),
79 array( 'MIMEsearchPage', 'MIMEsearch' ),
80 array( 'MostcategoriesPage', 'Mostcategories' ),
81 array( 'MostimagesPage', 'Mostimages' ),
82 array( 'MostinterwikisPage', 'Mostinterwikis' ),
83 array( 'MostlinkedCategoriesPage', 'Mostlinkedcategories' ),
84 array( 'MostlinkedtemplatesPage', 'Mostlinkedtemplates' ),
85 array( 'MostlinkedPage', 'Mostlinked' ),
86 array( 'MostrevisionsPage', 'Mostrevisions' ),
87 array( 'FewestrevisionsPage', 'Fewestrevisions' ),
88 array( 'ShortPagesPage', 'Shortpages' ),
89 array( 'UncategorizedCategoriesPage', 'Uncategorizedcategories' ),
90 array( 'UncategorizedPagesPage', 'Uncategorizedpages' ),
91 array( 'UncategorizedImagesPage', 'Uncategorizedimages' ),
92 array( 'UncategorizedTemplatesPage', 'Uncategorizedtemplates' ),
93 array( 'UnusedCategoriesPage', 'Unusedcategories' ),
94 array( 'UnusedimagesPage', 'Unusedimages' ),
95 array( 'WantedCategoriesPage', 'Wantedcategories' ),
96 array( 'WantedFilesPage', 'Wantedfiles' ),
97 array( 'WantedPagesPage', 'Wantedpages' ),
98 array( 'WantedTemplatesPage', 'Wantedtemplates' ),
99 array( 'UnwatchedPagesPage', 'Unwatchedpages' ),
100 array( 'UnusedtemplatesPage', 'Unusedtemplates' ),
101 array( 'WithoutInterwikiPage', 'Withoutinterwiki' ),
102 );
103 wfRunHooks( 'wgQueryPages', array( &$qp ) );
104
105 if ( !$wgDisableCounters ) {
106 $qp[] = array( 'PopularPagesPage', 'Popularpages' );
107 }
108 }
109
110 return $qp;
111 }
112
113 /**
114 * A mutator for $this->listoutput;
115 *
116 * @param bool $bool
117 */
118 function setListoutput( $bool ) {
119 $this->listoutput = $bool;
120 }
121
122 /**
123 * Subclasses return an SQL query here, formatted as an array with the
124 * following keys:
125 * tables => Table(s) for passing to Database::select()
126 * fields => Field(s) for passing to Database::select(), may be *
127 * conds => WHERE conditions
128 * options => options
129 * join_conds => JOIN conditions
130 *
131 * Note that the query itself should return the following three columns:
132 * 'namespace', 'title', and 'value'. 'value' is used for sorting.
133 *
134 * These may be stored in the querycache table for expensive queries,
135 * and that cached data will be returned sometimes, so the presence of
136 * extra fields can't be relied upon. The cached 'value' column will be
137 * an integer; non-numeric values are useful only for sorting the
138 * initial query (except if they're timestamps, see usesTimestamps()).
139 *
140 * Don't include an ORDER or LIMIT clause, they will be added.
141 *
142 * If this function is not overridden or returns something other than
143 * an array, getSQL() will be used instead. This is for backwards
144 * compatibility only and is strongly deprecated.
145 * @return array
146 * @since 1.18
147 */
148 function getQueryInfo() {
149 return null;
150 }
151
152 /**
153 * For back-compat, subclasses may return a raw SQL query here, as a string.
154 * This is strongly deprecated; getQueryInfo() should be overridden instead.
155 * @throws MWException
156 * @return string
157 */
158 function getSQL() {
159 /* Implement getQueryInfo() instead */
160 throw new MWException( "Bug in a QueryPage: doesn't implement getQueryInfo() nor "
161 . "getQuery() properly" );
162 }
163
164 /**
165 * Subclasses return an array of fields to order by here. Don't append
166 * DESC to the field names, that'll be done automatically if
167 * sortDescending() returns true.
168 * @return array
169 * @since 1.18
170 */
171 function getOrderFields() {
172 return array( 'value' );
173 }
174
175 /**
176 * Does this query return timestamps rather than integers in its
177 * 'value' field? If true, this class will convert 'value' to a
178 * UNIX timestamp for caching.
179 * NOTE: formatRow() may get timestamps in TS_MW (mysql), TS_DB (pgsql)
180 * or TS_UNIX (querycache) format, so be sure to always run them
181 * through wfTimestamp()
182 * @return bool
183 * @since 1.18
184 */
185 function usesTimestamps() {
186 return false;
187 }
188
189 /**
190 * Override to sort by increasing values
191 *
192 * @return bool
193 */
194 function sortDescending() {
195 return true;
196 }
197
198 /**
199 * Is this query expensive (for some definition of expensive)? Then we
200 * don't let it run in miser mode. $wgDisableQueryPages causes all query
201 * pages to be declared expensive. Some query pages are always expensive.
202 *
203 * @return bool
204 */
205 function isExpensive() {
206 return $this->getConfig()->get( 'DisableQueryPages' );
207 }
208
209 /**
210 * Is the output of this query cacheable? Non-cacheable expensive pages
211 * will be disabled in miser mode and will not have their results written
212 * to the querycache table.
213 * @return bool
214 * @since 1.18
215 */
216 public function isCacheable() {
217 return true;
218 }
219
220 /**
221 * Whether or not the output of the page in question is retrieved from
222 * the database cache.
223 *
224 * @return bool
225 */
226 function isCached() {
227 return $this->isExpensive() && $this->getConfig()->get( 'MiserMode' );
228 }
229
230 /**
231 * Sometime we don't want to build rss / atom feeds.
232 *
233 * @return bool
234 */
235 function isSyndicated() {
236 return true;
237 }
238
239 /**
240 * Formats the results of the query for display. The skin is the current
241 * skin; you can use it for making links. The result is a single row of
242 * result data. You should be able to grab SQL results off of it.
243 * If the function returns false, the line output will be skipped.
244 * @param Skin $skin
245 * @param object $result Result row
246 * @return string|bool String or false to skip
247 */
248 abstract function formatResult( $skin, $result );
249
250 /**
251 * The content returned by this function will be output before any result
252 *
253 * @return string
254 */
255 function getPageHeader() {
256 return '';
257 }
258
259 /**
260 * If using extra form wheely-dealies, return a set of parameters here
261 * as an associative array. They will be encoded and added to the paging
262 * links (prev/next/lengths).
263 *
264 * @return array
265 */
266 function linkParameters() {
267 return array();
268 }
269
270 /**
271 * Some special pages (for example SpecialListusers) might not return the
272 * current object formatted, but return the previous one instead.
273 * Setting this to return true will ensure formatResult() is called
274 * one more time to make sure that the very last result is formatted
275 * as well.
276 * @return bool
277 */
278 function tryLastResult() {
279 return false;
280 }
281
282 /**
283 * Clear the cache and save new results
284 *
285 * @param int|bool $limit Limit for SQL statement
286 * @param bool $ignoreErrors Whether to ignore database errors
287 * @throws DBError|Exception
288 * @return bool|int
289 */
290 function recache( $limit, $ignoreErrors = true ) {
291 if ( !$this->isCacheable() ) {
292 return 0;
293 }
294
295 $fname = get_class( $this ) . '::recache';
296 $dbw = wfGetDB( DB_MASTER );
297 if ( !$dbw ) {
298 return false;
299 }
300
301 try {
302 # Do query
303 $res = $this->reallyDoQuery( $limit, false );
304 $num = false;
305 if ( $res ) {
306 $num = $res->numRows();
307 # Fetch results
308 $vals = array();
309 foreach ( $res as $row ) {
310 if ( isset( $row->value ) ) {
311 if ( $this->usesTimestamps() ) {
312 $value = wfTimestamp( TS_UNIX,
313 $row->value );
314 } else {
315 $value = intval( $row->value ); // @bug 14414
316 }
317 } else {
318 $value = 0;
319 }
320
321 $vals[] = array( 'qc_type' => $this->getName(),
322 'qc_namespace' => $row->namespace,
323 'qc_title' => $row->title,
324 'qc_value' => $value );
325 }
326
327 $dbw->begin( __METHOD__ );
328 # Clear out any old cached data
329 $dbw->delete( 'querycache', array( 'qc_type' => $this->getName() ), $fname );
330 # Save results into the querycache table on the master
331 if ( count( $vals ) ) {
332 $dbw->insert( 'querycache', $vals, __METHOD__ );
333 }
334 # Update the querycache_info record for the page
335 $dbw->delete( 'querycache_info', array( 'qci_type' => $this->getName() ), $fname );
336 $dbw->insert( 'querycache_info',
337 array( 'qci_type' => $this->getName(), 'qci_timestamp' => $dbw->timestamp() ),
338 $fname );
339 $dbw->commit( __METHOD__ );
340 }
341 } catch ( DBError $e ) {
342 if ( !$ignoreErrors ) {
343 throw $e; // report query error
344 }
345 $num = false; // set result to false to indicate error
346 }
347
348 return $num;
349 }
350
351 /**
352 * Get a DB connection to be used for slow recache queries
353 * @return DatabaseBase
354 */
355 function getRecacheDB() {
356 return wfGetDB( DB_SLAVE, array( $this->getName(), 'QueryPage::recache', 'vslow' ) );
357 }
358
359 /**
360 * Run the query and return the result
361 * @param int|bool $limit Numerical limit or false for no limit
362 * @param int|bool $offset Numerical offset or false for no offset
363 * @return ResultWrapper
364 * @since 1.18
365 */
366 function reallyDoQuery( $limit, $offset = false ) {
367 $fname = get_class( $this ) . "::reallyDoQuery";
368 $dbr = $this->getRecacheDB();
369 $query = $this->getQueryInfo();
370 $order = $this->getOrderFields();
371
372 if ( $this->sortDescending() ) {
373 foreach ( $order as &$field ) {
374 $field .= ' DESC';
375 }
376 }
377
378 if ( is_array( $query ) ) {
379 $tables = isset( $query['tables'] ) ? (array)$query['tables'] : array();
380 $fields = isset( $query['fields'] ) ? (array)$query['fields'] : array();
381 $conds = isset( $query['conds'] ) ? (array)$query['conds'] : array();
382 $options = isset( $query['options'] ) ? (array)$query['options'] : array();
383 $join_conds = isset( $query['join_conds'] ) ? (array)$query['join_conds'] : array();
384
385 if ( count( $order ) ) {
386 $options['ORDER BY'] = $order;
387 }
388
389 if ( $limit !== false ) {
390 $options['LIMIT'] = intval( $limit );
391 }
392
393 if ( $offset !== false ) {
394 $options['OFFSET'] = intval( $offset );
395 }
396
397 $res = $dbr->select( $tables, $fields, $conds, $fname,
398 $options, $join_conds
399 );
400 } else {
401 // Old-fashioned raw SQL style, deprecated
402 $sql = $this->getSQL();
403 $sql .= ' ORDER BY ' . implode( ', ', $order );
404 $sql = $dbr->limitResult( $sql, $limit, $offset );
405 $res = $dbr->query( $sql, $fname );
406 }
407
408 return $dbr->resultObject( $res );
409 }
410
411 /**
412 * Somewhat deprecated, you probably want to be using execute()
413 * @param int|bool $offset
414 * @param int|bool $limit
415 * @return ResultWrapper
416 */
417 function doQuery( $offset = false, $limit = false ) {
418 if ( $this->isCached() && $this->isCacheable() ) {
419 return $this->fetchFromCache( $limit, $offset );
420 } else {
421 return $this->reallyDoQuery( $limit, $offset );
422 }
423 }
424
425 /**
426 * Fetch the query results from the query cache
427 * @param int|bool $limit Numerical limit or false for no limit
428 * @param int|bool $offset Numerical offset or false for no offset
429 * @return ResultWrapper
430 * @since 1.18
431 */
432 function fetchFromCache( $limit, $offset = false ) {
433 $dbr = wfGetDB( DB_SLAVE );
434 $options = array();
435 if ( $limit !== false ) {
436 $options['LIMIT'] = intval( $limit );
437 }
438 if ( $offset !== false ) {
439 $options['OFFSET'] = intval( $offset );
440 }
441 if ( $this->sortDescending() ) {
442 $options['ORDER BY'] = 'qc_value DESC';
443 } else {
444 $options['ORDER BY'] = 'qc_value ASC';
445 }
446 $res = $dbr->select( 'querycache', array( 'qc_type',
447 'namespace' => 'qc_namespace',
448 'title' => 'qc_title',
449 'value' => 'qc_value' ),
450 array( 'qc_type' => $this->getName() ),
451 __METHOD__, $options
452 );
453 return $dbr->resultObject( $res );
454 }
455
456 public function getCachedTimestamp() {
457 if ( is_null( $this->cachedTimestamp ) ) {
458 $dbr = wfGetDB( DB_SLAVE );
459 $fname = get_class( $this ) . '::getCachedTimestamp';
460 $this->cachedTimestamp = $dbr->selectField( 'querycache_info', 'qci_timestamp',
461 array( 'qci_type' => $this->getName() ), $fname );
462 }
463 return $this->cachedTimestamp;
464 }
465
466 /**
467 * This is the actual workhorse. It does everything needed to make a
468 * real, honest-to-gosh query page.
469 * @param string $par
470 */
471 function execute( $par ) {
472 $user = $this->getUser();
473 if ( !$this->userCanExecute( $user ) ) {
474 $this->displayRestrictionError();
475 return;
476 }
477
478 $this->setHeaders();
479 $this->outputHeader();
480
481 $out = $this->getOutput();
482
483 if ( $this->isCached() && !$this->isCacheable() ) {
484 $out->addWikiMsg( 'querypage-disabled' );
485 return;
486 }
487
488 $out->setSyndicated( $this->isSyndicated() );
489
490 if ( $this->limit == 0 && $this->offset == 0 ) {
491 list( $this->limit, $this->offset ) = $this->getRequest()->getLimitOffset();
492 }
493
494 // @todo Use doQuery()
495 if ( !$this->isCached() ) {
496 # select one extra row for navigation
497 $res = $this->reallyDoQuery( $this->limit + 1, $this->offset );
498 } else {
499 # Get the cached result, select one extra row for navigation
500 $res = $this->fetchFromCache( $this->limit + 1, $this->offset );
501 if ( !$this->listoutput ) {
502
503 # Fetch the timestamp of this update
504 $ts = $this->getCachedTimestamp();
505 $lang = $this->getLanguage();
506 $maxResults = $lang->formatNum( $this->getConfig()->get( 'QueryCacheLimit' ) );
507
508 if ( $ts ) {
509 $updated = $lang->userTimeAndDate( $ts, $user );
510 $updateddate = $lang->userDate( $ts, $user );
511 $updatedtime = $lang->userTime( $ts, $user );
512 $out->addMeta( 'Data-Cache-Time', $ts );
513 $out->addJsConfigVars( 'dataCacheTime', $ts );
514 $out->addWikiMsg( 'perfcachedts', $updated, $updateddate, $updatedtime, $maxResults );
515 } else {
516 $out->addWikiMsg( 'perfcached', $maxResults );
517 }
518
519 # If updates on this page have been disabled, let the user know
520 # that the data set won't be refreshed for now
521 if ( is_array( $this->getConfig()->get( 'DisableQueryPageUpdate' ) )
522 && in_array( $this->getName(), $this->getConfig()->get( 'DisableQueryPageUpdate' ) )
523 ) {
524 $out->wrapWikiMsg(
525 "<div class=\"mw-querypage-no-updates\">\n$1\n</div>",
526 'querypage-no-updates'
527 );
528 }
529 }
530 }
531
532 $this->numRows = $res->numRows();
533
534 $dbr = wfGetDB( DB_SLAVE );
535 $this->preprocessResults( $dbr, $res );
536
537 $out->addHTML( Xml::openElement( 'div', array( 'class' => 'mw-spcontent' ) ) );
538
539 # Top header and navigation
540 if ( $this->shownavigation ) {
541 $out->addHTML( $this->getPageHeader() );
542 if ( $this->numRows > 0 ) {
543 $out->addHTML( $this->msg( 'showingresultsinrange' )->numParams(
544 min( $this->numRows, $this->limit ), # do not show the one extra row, if exist
545 $this->offset + 1, ( min( $this->numRows, $this->limit ) + $this->offset ) )->parseAsBlock() );
546 # Disable the "next" link when we reach the end
547 $paging = $this->getLanguage()->viewPrevNext( $this->getPageTitle( $par ), $this->offset,
548 $this->limit, $this->linkParameters(), ( $this->numRows <= $this->limit ) );
549 $out->addHTML( '<p>' . $paging . '</p>' );
550 } else {
551 # No results to show, so don't bother with "showing X of Y" etc.
552 # -- just let the user know and give up now
553 $out->addWikiMsg( 'specialpage-empty' );
554 $out->addHTML( Xml::closeElement( 'div' ) );
555 return;
556 }
557 }
558
559 # The actual results; specialist subclasses will want to handle this
560 # with more than a straight list, so we hand them the info, plus
561 # an OutputPage, and let them get on with it
562 $this->outputResults( $out,
563 $this->getSkin(),
564 $dbr, # Should use a ResultWrapper for this
565 $res,
566 min( $this->numRows, $this->limit ), # do not format the one extra row, if exist
567 $this->offset );
568
569 # Repeat the paging links at the bottom
570 if ( $this->shownavigation ) {
571 $out->addHTML( '<p>' . $paging . '</p>' );
572 }
573
574 $out->addHTML( Xml::closeElement( 'div' ) );
575 }
576
577 /**
578 * Format and output report results using the given information plus
579 * OutputPage
580 *
581 * @param OutputPage $out OutputPage to print to
582 * @param Skin $skin User skin to use
583 * @param DatabaseBase $dbr Database (read) connection to use
584 * @param ResultWrapper $res Result pointer
585 * @param int $num Number of available result rows
586 * @param int $offset Paging offset
587 */
588 protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
589 global $wgContLang;
590
591 if ( $num > 0 ) {
592 $html = array();
593 if ( !$this->listoutput ) {
594 $html[] = $this->openList( $offset );
595 }
596
597 # $res might contain the whole 1,000 rows, so we read up to
598 # $num [should update this to use a Pager]
599 // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
600 for ( $i = 0; $i < $num && $row = $res->fetchObject(); $i++ ) {
601 // @codingStandardsIgnoreEnd
602 $line = $this->formatResult( $skin, $row );
603 if ( $line ) {
604 $attr = ( isset( $row->usepatrol ) && $row->usepatrol && $row->patrolled == 0 )
605 ? ' class="not-patrolled"'
606 : '';
607 $html[] = $this->listoutput
608 ? $line
609 : "<li{$attr}>{$line}</li>\n";
610 }
611 }
612
613 # Flush the final result
614 if ( $this->tryLastResult() ) {
615 $row = null;
616 $line = $this->formatResult( $skin, $row );
617 if ( $line ) {
618 $attr = ( isset( $row->usepatrol ) && $row->usepatrol && $row->patrolled == 0 )
619 ? ' class="not-patrolled"'
620 : '';
621 $html[] = $this->listoutput
622 ? $line
623 : "<li{$attr}>{$line}</li>\n";
624 }
625 }
626
627 if ( !$this->listoutput ) {
628 $html[] = $this->closeList();
629 }
630
631 $html = $this->listoutput
632 ? $wgContLang->listToText( $html )
633 : implode( '', $html );
634
635 $out->addHTML( $html );
636 }
637 }
638
639 /**
640 * @param int $offset
641 * @return string
642 */
643 function openList( $offset ) {
644 return "\n<ol start='" . ( $offset + 1 ) . "' class='special'>\n";
645 }
646
647 /**
648 * @return string
649 */
650 function closeList() {
651 return "</ol>\n";
652 }
653
654 /**
655 * Do any necessary preprocessing of the result object.
656 * @param DatabaseBase $db
657 * @param ResultWrapper $res
658 */
659 function preprocessResults( $db, $res ) {
660 }
661
662 /**
663 * Similar to above, but packaging in a syndicated feed instead of a web page
664 * @param string $class
665 * @param int $limit
666 * @return bool
667 */
668 function doFeed( $class = '', $limit = 50 ) {
669 if ( !$this->getConfig()->get( 'Feed' ) ) {
670 $this->getOutput()->addWikiMsg( 'feed-unavailable' );
671 return false;
672 }
673
674 $limit = min( $limit, $this->getConfig()->get( 'FeedLimit' ) );
675
676 $feedClasses = $this->getConfig()->get( 'FeedClasses' );
677 if ( isset( $feedClasses[$class] ) ) {
678 /** @var RSSFeed|AtomFeed $feed */
679 $feed = new $feedClasses[$class](
680 $this->feedTitle(),
681 $this->feedDesc(),
682 $this->feedUrl() );
683 $feed->outHeader();
684
685 $res = $this->reallyDoQuery( $limit, 0 );
686 foreach ( $res as $obj ) {
687 $item = $this->feedResult( $obj );
688 if ( $item ) {
689 $feed->outItem( $item );
690 }
691 }
692
693 $feed->outFooter();
694 return true;
695 } else {
696 return false;
697 }
698 }
699
700 /**
701 * Override for custom handling. If the titles/links are ok, just do
702 * feedItemDesc()
703 * @param object $row
704 * @return FeedItem|null
705 */
706 function feedResult( $row ) {
707 if ( !isset( $row->title ) ) {
708 return null;
709 }
710 $title = Title::makeTitle( intval( $row->namespace ), $row->title );
711 if ( $title ) {
712 $date = isset( $row->timestamp ) ? $row->timestamp : '';
713 $comments = '';
714 if ( $title ) {
715 $talkpage = $title->getTalkPage();
716 $comments = $talkpage->getFullURL();
717 }
718
719 return new FeedItem(
720 $title->getPrefixedText(),
721 $this->feedItemDesc( $row ),
722 $title->getFullURL(),
723 $date,
724 $this->feedItemAuthor( $row ),
725 $comments );
726 } else {
727 return null;
728 }
729 }
730
731 function feedItemDesc( $row ) {
732 return isset( $row->comment ) ? htmlspecialchars( $row->comment ) : '';
733 }
734
735 function feedItemAuthor( $row ) {
736 return isset( $row->user_text ) ? $row->user_text : '';
737 }
738
739 function feedTitle() {
740 $desc = $this->getDescription();
741 $code = $this->getConfig()->get( 'LanguageCode' );
742 $sitename = $this->getConfig()->get( 'Sitename' );
743 return "$sitename - $desc [$code]";
744 }
745
746 function feedDesc() {
747 return $this->msg( 'tagline' )->text();
748 }
749
750 function feedUrl() {
751 return $this->getPageTitle()->getFullURL();
752 }
753 }