MediaWiki  master
ChangesFeed.php
Go to the documentation of this file.
1 <?php
24 
30 class ChangesFeed {
31  private $format;
32 
36  public function __construct( $format ) {
37  $this->format = $format;
38  }
39 
48  public function getFeedObject( $title, $description, $url ) {
50 
51  if ( !isset( $wgFeedClasses[$this->format] ) ) {
52  return false;
53  }
54 
55  if ( !array_key_exists( $this->format, $wgFeedClasses ) ) {
56  // falling back to atom
57  $this->format = 'atom';
58  }
59 
60  $feedTitle = "$wgSitename - {$title} [$wgLanguageCode]";
61  return new $wgFeedClasses[$this->format](
62  $feedTitle, htmlspecialchars( $description ), $url );
63  }
64 
70  public static function buildItems( $rows ) {
71  $items = [];
72 
73  # Merge adjacent edits by one user
74  $sorted = [];
75  $n = 0;
76  foreach ( $rows as $obj ) {
77  if ( $obj->rc_type == RC_EXTERNAL ) {
78  continue;
79  }
80 
81  if ( $n > 0 &&
82  $obj->rc_type == RC_EDIT &&
83  $obj->rc_namespace >= 0 &&
84  $obj->rc_cur_id == $sorted[$n - 1]->rc_cur_id &&
85  $obj->rc_user_text == $sorted[$n - 1]->rc_user_text ) {
86  $sorted[$n - 1]->rc_last_oldid = $obj->rc_last_oldid;
87  } else {
88  $sorted[$n] = $obj;
89  $n++;
90  }
91  }
92 
93  $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
94  foreach ( $sorted as $obj ) {
95  $title = Title::makeTitle( $obj->rc_namespace, $obj->rc_title );
96  $talkpage = $nsInfo->hasTalkNamespace( $obj->rc_namespace )
97  ? $title->getTalkPage()->getFullURL()
98  : '';
99 
100  // Skip items with deleted content (avoids partially complete/inconsistent output)
101  if ( $obj->rc_deleted ) {
102  continue;
103  }
104 
105  if ( $obj->rc_this_oldid ) {
106  $url = $title->getFullURL( [
107  'diff' => $obj->rc_this_oldid,
108  'oldid' => $obj->rc_last_oldid,
109  ] );
110  } else {
111  // log entry or something like that.
112  $url = $title->getFullURL();
113  }
114 
115  $items[] = new FeedItem(
116  $title->getPrefixedText(),
117  FeedUtils::formatDiff( $obj ),
118  $url,
119  $obj->rc_timestamp,
120  ( $obj->rc_deleted & Revision::DELETED_USER )
121  ? wfMessage( 'rev-deleted-user' )->escaped() : $obj->rc_user_text,
122  $talkpage
123  );
124  }
125 
126  return $items;
127  }
128 }
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction $rows
Definition: hooks.txt:2633
$wgSitename
Name of the site.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
__construct( $format)
Definition: ChangesFeed.php:36
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
Feed to Special:RecentChanges and Special:RecentChangesLinked.
Definition: ChangesFeed.php:30
getFeedObject( $title, $description, $url)
Get a ChannelFeed subclass object to use.
Definition: ChangesFeed.php:48
$wgLanguageCode
Site language code.
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:925
A base class for outputting syndication feeds (e.g.
Definition: FeedItem.php:33
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:589
static formatDiff( $row)
Format a diff for the newsfeed.
Definition: FeedUtils.php:80
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
const DELETED_USER
Definition: Revision.php:48
const RC_EXTERNAL
Definition: Defines.php:145
static buildItems( $rows)
Generate the feed items given a row from the database.
Definition: ChangesFeed.php:70
if the prop value should be in the metadata multi language array format
Definition: hooks.txt:1641
const RC_EDIT
Definition: Defines.php:142
$wgFeedClasses
Available feeds objects.