jenkins-bot has submitted this change and it was merged. Change subject: Convert to extension registration ......................................................................
Convert to extension registration Bug: T88064 Change-Id: Ib1d8743204a3799c16001dc9e55fe64435f49f71 --- M Timeline.body.php M Timeline.php A TimelineSettings.php A extension.json 4 files changed, 88 insertions(+), 65 deletions(-) Approvals: Jforrester: Looks good to me, approved jenkins-bot: Verified diff --git a/Timeline.body.php b/Timeline.body.php index 1491590..0c539a9 100644 --- a/Timeline.body.php +++ b/Timeline.body.php @@ -3,6 +3,14 @@ class Timeline { + public static function registerExtension() { + global $wgTimelineSettings; + $wgTimelineSettings = new TimelineSettings; + $wgTimelineSettings->ploticusCommand = "/usr/bin/ploticus"; + $wgTimelineSettings->perlCommand = "/usr/bin/perl"; + $wgTimelineSettings->timelineFile = __DIR__ . "/EasyTimeline.pl"; + } + /** * @param $parser Parser * @return bool diff --git a/Timeline.php b/Timeline.php index 303ca2d..bc0e649 100644 --- a/Timeline.php +++ b/Timeline.php @@ -1,69 +1,16 @@ <?php -/** - * EasyTimeline - Timeline extension - * To use, include this file from your LocalSettings.php - * To configure, set members of $wgTimelineSettings after the inclusion - * - * @file - * @ingroup Extensions - * @author Erik Zachte <x...@chello.nl (nospam: xxx=epzachte)> - * @license GNU General Public License version 2 - * @link http://www.mediawiki.org/wiki/Extension:EasyTimeline Documentation - */ -$wgExtensionCredits['parserhook'][] = array( - 'path' => __FILE__, - 'name' => 'EasyTimeline', - 'author' => 'Erik Zachte', - 'url' => 'https://www.mediawiki.org/wiki/Extension:EasyTimeline', - 'descriptionmsg' => 'timeline-desc', - 'license-name' => 'GPL-2.0', -); - -class TimelineSettings { - public $ploticusCommand, $perlCommand; - - // Update this timestamp to force older rendered timelines - // to be generated when the page next gets rendered. - // Can help to resolve old image-generation bugs. - public $epochTimestamp = '20120101000000'; - - // Path to the EasyTimeline.pl perl file, which is used to actually generate the timelines. - public $timelineFile; - - // Font name. - // Documentation on how Ploticus handles fonts is available at - // http://ploticus.sourceforge.net/doc/fonts.html section "What fonts are available?" - // and below. If using a TrueType font, the file with .ttf extension - // must be available in path specified by environment variable $GDFONTPATH; - // some other font types are available (see the docs linked above). - // - // Use the fontname 'ascii' to use the internal Ploticus font that does not require - // an external font file. Defaults to FreeSans for backwards compatibility. - // - // Note: according to Ploticus docs, font names with a space may be problematic. - public $fontFile = 'FreeSans'; - - // The name of the FileBackend to use for timeline (see $wgFileBackends) - public $fileBackend = ''; +if ( function_exists( 'wfLoadExtension' ) ) { + wfLoadExtension( 'Timeline' ); + // Keep i18n globals so mergeMessageFileList.php doesn't break + $wgMessagesDirs['Timeline'] = __DIR__ . '/i18n'; +/* wfWarn( + 'Deprecated PHP entry point used for Timeline extension. Please use wfLoadExtension instead, ' . + 'see https://www.mediawiki.org/wiki/Extension_registration for more details.' + ); +*/ + return; +} else { + die( 'This version of the Timeline extension requires MediaWiki 1.28+' ); } -$wgTimelineSettings = new TimelineSettings; -$wgTimelineSettings->ploticusCommand = "/usr/bin/ploticus"; -$wgTimelineSettings->perlCommand = "/usr/bin/perl"; -$wgTimelineSettings->timelineFile = __DIR__ . "/EasyTimeline.pl"; - -$wgHooks['ParserFirstCallInit'][] = 'Timeline::onParserFirstCallInit'; -$wgMessagesDirs['Timeline'] = __DIR__ . '/i18n'; -$wgExtensionMessagesFiles['Timeline'] = __DIR__ . '/Timeline.i18n.php'; -$wgAutoloadClasses['Timeline'] = __DIR__ . '/Timeline.body.php'; - -$wgResourceModules['ext.timeline.styles'] = array( - 'localBasePath' => __DIR__, - 'remoteExtPath' => 'timeline', - 'styles' => array( - 'resources/ext.timeline.styles/timeline.css', - ), - 'position' => 'top', - 'targets' => array( 'mobile', 'desktop' ), -); diff --git a/TimelineSettings.php b/TimelineSettings.php new file mode 100644 index 0000000..ce6d393 --- /dev/null +++ b/TimelineSettings.php @@ -0,0 +1,25 @@ +<?php + +class TimelineSettings { + public $ploticusCommand, $perlCommand; + // Update this timestamp to force older rendered timelines + // to be generated when the page next gets rendered. + // Can help to resolve old image-generation bugs. + public $epochTimestamp = '20120101000000'; + // Path to the EasyTimeline.pl perl file, which is used to actually generate the timelines. + public $timelineFile; + // Font name. + // Documentation on how Ploticus handles fonts is available at + // http://ploticus.sourceforge.net/doc/fonts.html section "What fonts are available?" + // and below. If using a TrueType font, the file with .ttf extension + // must be available in path specified by environment variable $GDFONTPATH; + // some other font types are available (see the docs linked above). + // + // Use the fontname 'ascii' to use the internal Ploticus font that does not require + // an external font file. Defaults to FreeSans for backwards compatibility. + // + // Note: according to Ploticus docs, font names with a space may be problematic. + public $fontFile = 'FreeSans'; + // The name of the FileBackend to use for timeline (see $wgFileBackends) + public $fileBackend = ''; +} diff --git a/extension.json b/extension.json new file mode 100644 index 0000000..7021180 --- /dev/null +++ b/extension.json @@ -0,0 +1,43 @@ +{ + "name": "EasyTimeline", + "author": "Erik Zachte", + "url": "https://www.mediawiki.org/wiki/Extension:EasyTimeline", + "descriptionmsg": "timeline-desc", + "license-name": "GPL-2.0", + "type": "parserhook", + "callback": "Timeline::registerExtension", + "MessagesDirs": { + "Timeline": [ + "i18n" + ] + }, + "AutoloadClasses": { + "Timeline": "Timeline.body.php", + "TimelineSettings": "TimelineSettings.php" + }, + "ResourceModules": { + "ext.timeline.styles": { + "styles": [ + "resources/ext.timeline.styles/timeline.css" + ], + "position": "top", + "targets": [ + "mobile", + "desktop" + ] + } + }, + "ResourceFileModulePaths": { + "localBasePath": "", + "remoteExtPath": "timeline" + }, + "Hooks": { + "ParserFirstCallInit": "Timeline::onParserFirstCallInit" + }, + "config": { + "TimelineSettings": { + "value": null + } + }, + "manifest_version": 2 +} -- To view, visit https://gerrit.wikimedia.org/r/303248 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib1d8743204a3799c16001dc9e55fe64435f49f71 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/timeline Gerrit-Branch: master Gerrit-Owner: Reedy <re...@wikimedia.org> Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: Reedy <re...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits