Revision: 46150
Author: ashley
Date: 2009-01-24 17:26:54 +0000 (Sat, 24 Jan 2009)
Log Message:
-----------
EasyTimeline:
*allow the path to EasyTimeline.pl be customized like ploticus/perl paths by
moving it to TimelineSettings class
*some spacing tweaks
*added/tweaked doxygen comments
Modified Paths:
--------------
trunk/extensions/timeline/Timeline.i18n.php
trunk/extensions/timeline/Timeline.php
Modified: trunk/extensions/timeline/Timeline.i18n.php
===================================================================
--- trunk/extensions/timeline/Timeline.i18n.php 2009-01-24 17:15:21 UTC (rev
46149)
+++ trunk/extensions/timeline/Timeline.i18n.php 2009-01-24 17:26:54 UTC (rev
46150)
@@ -1,12 +1,14 @@
<?php
/**
- * Internationalisation file for Timeline extension.
+ * Internationalisation file for EasyTimeline extension.
*
- * @addtogroup Extensions
+ * @file
+ * @ingroup Extensions
*/
$messages = array();
+/** English */
$messages['en'] = array(
'timeline-desc' => 'Adds <tt><timeline></tt> tag to create
timelines',
);
Modified: trunk/extensions/timeline/Timeline.php
===================================================================
--- trunk/extensions/timeline/Timeline.php 2009-01-24 17:15:21 UTC (rev
46149)
+++ trunk/extensions/timeline/Timeline.php 2009-01-24 17:26:54 UTC (rev
46150)
@@ -1,9 +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 <[email protected] (nospam: xxx=epzachte)>
+ * @license GNU General Public License version 2
+ * @link http://www.mediawiki.org/wiki/Extension:EasyTimeline Documentation
+ */
-# Timeline extension
-# To use, include this file from your LocalSettings.php
-# To configure, set members of $wgTimelineSettings after the inclusion
-
class TimelineSettings {
var $ploticusCommand, $perlCommand;
@@ -11,10 +18,14 @@
// to be generated when the page next gets rendered.
// Can help to resolve old image-generation bugs.
var $epochTimestamp = '20010115000000';
+
+ // Path to the EasyTimeline.pl perl file, which is used to actually
generate the timelines.
+ var $timelineFile;
};
$wgTimelineSettings = new TimelineSettings;
$wgTimelineSettings->ploticusCommand = "/usr/bin/ploticus";
$wgTimelineSettings->perlCommand = "/usr/bin/perl";
+$wgTimelineSettings->timelineFile = '/extensions/timeline/EasyTimeline.pl';
if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
$wgHooks['ParserFirstCallInit'][] = 'wfTimelineExtension';
@@ -23,24 +34,23 @@
}
$wgExtensionCredits['parserhook'][] = array(
- 'name' => 'EasyTimeline',
- 'author' => 'Erik Zachte',
- 'url' =>
'http://www.mediawiki.org/wiki/Extension:EasyTimeline',
+ 'name' => 'EasyTimeline',
+ 'author' => 'Erik Zachte',
+ 'url' => 'http://www.mediawiki.org/wiki/Extension:EasyTimeline',
'svn-date' => '$LastChangedDate$',
'svn-revision' => '$LastChangedRevision$',
- 'description' => 'Timeline extension',
+ 'description' => 'Adds <tt><timeline></tt> tag to create
timelines',
'descriptionmsg' => 'timeline-desc',
);
$wgExtensionMessagesFiles['Timeline'] = dirname(__FILE__) .
'/Timeline.i18n.php';
function wfTimelineExtension() {
global $wgParser;
- $wgParser->setHook( "timeline", "renderTimeline" );
+ $wgParser->setHook( 'timeline', 'renderTimeline' );
return true;
}
-function renderTimeline( $timelinesrc )
-{
+function renderTimeline( $timelinesrc ){
global $wgUploadDirectory, $wgUploadPath, $IP, $wgTimelineSettings,
$wgArticlePath, $wgTmpDirectory;
$hash = md5( $timelinesrc );
$dest = $wgUploadDirectory."/timeline/";
@@ -48,20 +58,19 @@
if ( ! is_dir( $wgTmpDirectory ) ) { mkdir( $wgTmpDirectory, 0777 ); }
$fname = $dest . $hash;
-
+
$previouslyFailed = file_exists( $fname.".err" );
$previouslyRendered = file_exists( $fname.".png" );
$expired = $previouslyRendered &&
- (filemtime( $fname.".png" ) <
+ ( filemtime( $fname.".png" ) <
wfTimestamp( TS_UNIX,
$wgTimelineSettings->epochTimestamp ) );
-
- if ( $expired || ( !$previouslyRendered && !$previouslyFailed ) )
- {
+
+ if ( $expired || ( !$previouslyRendered && !$previouslyFailed ) ){
$handle = fopen($fname, "w");
fwrite($handle, $timelinesrc);
fclose($handle);
- $cmdline = wfEscapeShellArg( $wgTimelineSettings->perlCommand,
$IP . "/extensions/timeline/EasyTimeline.pl" ) .
+ $cmdline = wfEscapeShellArg( $wgTimelineSettings->perlCommand,
$IP . $wgTimelineSettings->timelineFile ) .
" -i " . wfEscapeShellArg( $fname ) . " -m -P " .
wfEscapeShellArg( $wgTimelineSettings->ploticusCommand ) .
" -T " . wfEscapeShellArg( $wgTmpDirectory ) . " -A " .
wfEscapeShellArg( $wgArticlePath );
@@ -76,14 +85,14 @@
}
- @$err=file_get_contents( $fname.".err" );
+ @$err = file_get_contents( $fname.".err" );
if ( $err != "" ) {
$txt = "<div id=\"toc\"><tt>$err</tt></div>";
} else {
@$map = file_get_contents( $fname.".map" );
- if (substr(php_uname(), 0, 7) == "Windows") {
+ if( substr( php_uname(), 0, 7 ) == "Windows" ) {
$ext = "gif";
} else {
$ext = "png";
@@ -92,7 +101,7 @@
$url = "{$wgUploadPath}/timeline/{$hash}.{$ext}";
$txt = "<map name=\"$hash\">{$map}</map>".
"<img usemap=\"#{$hash}\" src=\"$url\">";
-
+
if( $expired ) {
// Replacing an older file, we may need to purge the
old one.
global $wgUseSquid;
@@ -103,4 +112,4 @@
}
}
return $txt;
-}
+}
\ No newline at end of file
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs