/usr/share/mediawiki-extensions/base/News/News.php is in mediawiki-extensions-base 3.6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | <?php
/**
* News extension - shows recent changes on a wiki page.
*
* @file
* @ingroup Extensions
* @author Daniel Kinzler, brightbyte.de
* @copyright © 2007 Daniel Kinzler
* @licence GNU General Public Licence 2.0 or later
*/
if( !defined( 'MEDIAWIKI' ) ) {
echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
die( 1 );
}
$wgExtensionCredits['other'][] = array(
'path' => __FILE__,
'name' => 'News',
'author' => 'Daniel Kinzler, brightbyte.de',
'url' => 'http://mediawiki.org/wiki/Extension:News',
'descriptionmsg' => 'newsextension-desc',
);
$dir = dirname(__FILE__) . '/';
$wgExtensionMessagesFiles['NewsExtension'] = $dir . 'News.i18n.php';
$wgNewsFeedURLPattern = false; // pattern for feed-URLs; useful when using rewrites for canonical feed URLs
$wgNewsFeedUserPattern = false; // pattern to use for the author-field in feed items.
$wgAutoloadClasses['NewsRenderer'] = dirname( __FILE__ ) . '/NewsRenderer.php';
$wgAutoloadClasses['NewsFeedPage'] = dirname( __FILE__ ) . '/NewsRenderer.php';
$wgHooks['ArticleFromTitle'][] = 'wfNewsArticleFromTitle';
/*-
* disabled to not break page feeds from other sources
* cf. https://evolvis.org/tracker/t_follow.php/2557
*/
//$wgHooks['SkinTemplateOutputPageBeforeExec'][] = 'wfNewsSkinTemplateOutputPageBeforeExec';
$wgHooks['ParserFirstCallInit'][] = 'wfNewsSetHooks';
//FIXME: find a way to override the feed URLs generated by OutputPage::getHeadLinks
function wfNewsSetHooks( $parser ) {
$parser->setHook( 'news', 'wfNewsTag' );
$parser->setHook( 'newsfeed', 'wfNewsFeedTag' );
$parser->setHook( 'newsfeedlink', 'wfNewsFeedLinkTag' );
return true;
}
function wfNewsTag( $templatetext, $argv, $parser ) {
global $wgTitle;
$parser->disableCache(); //TODO: use smart cache & purge...?
$renderer = new NewsRenderer($wgTitle, $templatetext, $argv, $parser);
return $renderer->renderNews();
}
function wfNewsFeedTag( $templatetext, $argv, $parser ) {
global $wgTitle, $wgOut;
$parser->disableCache(); //TODO: use smart cache & purge...?
$wgOut->setSyndicated( true );
$silent = @$argv['silent'];
if ( $silent === 'false' || $silent === 'no' || $silent === '0' )
$silent = false;
if ( $silent ) return "";
$renderer = new NewsRenderer($wgTitle, $templatetext, $argv, $parser);
$html = $renderer->renderFeedPreview();
return $html;
}
function wfNewsFeedLinkTag( $linktext, $argv, $parser ) {
return NewsRenderer::renderFeedLink($linktext, $argv, $parser);
}
function wfNewsArticleFromTitle( $title, &$article ) {
global $wgRequest, $wgFeedClasses, $wgUser, $wgOut;
$fname = 'extension/News: wfNewsArticleFromTitle';
$ns = $title->getNamespace();
if ($ns < 0 || $ns == NS_SPECIAL || $ns == NS_MEDIAWIKI) return true;
$format = $wgRequest->getVal( 'feed' );
if (!$format) return true;
$format = strtolower( trim($format) );
$action = strtolower( trim( $wgRequest->getVal( 'action', 'view' ) ) );
if ($action != 'view' && $action != 'purge') return true;
if ( !isset($wgFeedClasses[$format] ) ) {
wfDebug( "$fname: unknown feed format: $format \n" );
wfHttpError(400, "Bad Request", "unknown feed format: " . $format); //TODO: better code & text
return false;
}
if (!$title->exists()) {
wfDebug( "$fname: feed page not found: " . $title->getPrefixedDBKey() . "\n" );
wfHttpError(404, "Not Found", "feed page not found: " . $title->getPrefixedText()); //TODO: better text
return false;
}
wfDebug( "$fname: handling feed request for " . $title->getPrefixedDBKey() . "\n" );
$article = new NewsFeedPage( $title, $format );
return false;
}
function wfNewsSkinTemplateOutputPageBeforeExec( $skin, $tpl ) {
$feeds = $tpl->data['feeds'];
if (!$feeds) return true;
$title = $skin->getTitle(); //hack...
foreach ($feeds as $format => $e) {
$e['href'] = NewsRenderer::getFeedURL( $title, $format );
$feeds[$format] = $e;
}
$tpl->setRef( 'feeds', $feeds );
return true;
}
|