I haven't tested these modifications with PEAR, but without PEAR they work well. The improvements are:
- until four timezones (2 optional)
- correct a little bug in the first timezone without using PEAR (now also the first timezone is set according to user's choise and not set just to localtime machine)
Attention: I've just added some lines of code according to the Author's coding guidlines.
Code: Select all
lang_en.inc.phpCode: Select all
<?php # $Id: lang_en.inc.php,v 1.2 2005/11/21 09:47:16 garvinhicking Exp $
/**
* @version $Revision: 1.2 $
* @author Translator Name <yourmail@example.com>
* EN-Revision: Revision of lang_en.inc.php
*/
@define('PLUGIN_TIMEZONES_TITLE', "Timezones");
@define('PLUGIN_TIMEZONES_BLAHBLAH', "Shows the time of up to four timezones");
@define('PLUGIN_TIMEZONES_NUGGET_TITLE', "Heading");
@define('PLUGIN_TIMEZONES_NUGGET_TITLE_BLABLAH', "One line of text");
@define('PLUGIN_TIMEZONES_ZONE1_TEXT', "First Text");
@define('PLUGIN_TIMEZONES_ZONE1_TEXT_BLABLAH', "One describing line of text for the first date.");
@define('PLUGIN_TIMEZONES_ZONE1_NAME', "First zone");
@define('PLUGIN_TIMEZONES_ZONE1_NAME_BLABLAH', "Shortname for the first timezone. (e.g. CET)");
@define('PLUGIN_TIMEZONES_ZONE1_FORMAT', "Format of the first timezone");
@define('PLUGIN_TIMEZONES_ZONE1_FORMAT_BLABLAH', "Formatstring passed to php, see http://pear.php.net/package/Date/docs/1.4.5/apidoc/Date/Date.html#methodformat or http://uk2.php.net/date (if PEAR is not Available)");
@define('PLUGIN_TIMEZONES_TIMESHIFT1', "First Timeshift");
@define('PLUGIN_TIMEZONES_TIMESHIFT1_BLABLAH', "The timeshift in SECONDS from local machine time(only used when PEAR::Date not available).");
@define('PLUGIN_TIMEZONES_ZONE2_TEXT', "Second text");
@define('PLUGIN_TIMEZONES_ZONE2_TEXT_BLABLAH', "One describing line of text for the second date.");
@define('PLUGIN_TIMEZONES_ZONE2_NAME', "Second zone");
@define('PLUGIN_TIMEZONES_ZONE2_NAME_BLABLAH', "Shortname for the second timezone. (e.g. PST)");
@define('PLUGIN_TIMEZONES_ZONE2_FORMAT', "Format of the second timezone");
@define('PLUGIN_TIMEZONES_ZONE2_FORMAT_BLABLAH', "Formatstring passed to php");
@define('PLUGIN_TIMEZONES_TIMESHIFT2', "Second Timeshift");
@define('PLUGIN_TIMEZONES_TIMESHIFT2_BLABLAH', "The timeshift in SECONDS from local machine time(only used when PEAR::Date not available).");
@define('PLUGIN_TIMEZONES_ZONE3_TEXT', "Third Text");
@define('PLUGIN_TIMEZONES_ZONE3_TEXT_BLABLAH', "(Leave empty if you don't need it)One describing line of text for the third date.");
@define('PLUGIN_TIMEZONES_ZONE3_NAME', "Third zone");
@define('PLUGIN_TIMEZONES_ZONE3_NAME_BLABLAH', "Shortname for the third timezone. (e.g. GMT)");
@define('PLUGIN_TIMEZONES_ZONE3_FORMAT', "Format of the third timezone");
@define('PLUGIN_TIMEZONES_ZONE3_FORMAT_BLABLAH', "Formatstring passed to php");
@define('PLUGIN_TIMEZONES_TIMESHIFT3', "Third Timeshift");
@define('PLUGIN_TIMEZONES_TIMESHIFT3_BLABLAH', "The timeshift in SECONDS from local machine time(only used when PEAR::Date not available).");
@define('PLUGIN_TIMEZONES_ZONE4_TEXT', "Fourth text");
@define('PLUGIN_TIMEZONES_ZONE4_TEXT_BLABLAH', "(Leave empty if you don't need it)One describing line of text for the fourth date.");
@define('PLUGIN_TIMEZONES_ZONE4_NAME', "Fourth zone");
@define('PLUGIN_TIMEZONES_ZONE4_NAME_BLABLAH', "Shortname for the fourth timezone. (e.g. UTC)");
@define('PLUGIN_TIMEZONES_ZONE4_FORMAT', "Format of the fourth timezone");
@define('PLUGIN_TIMEZONES_ZONE4_FORMAT_BLABLAH', "Formatstring passed to php");
@define('PLUGIN_TIMEZONES_TIMESHIFT4', "Fourth Timeshift");
@define('PLUGIN_TIMEZONES_TIMESHIFT4_BLABLAH', "The timeshift in SECONDS from local machine time(only used when PEAR::Date not available).");
?>Code: Select all
serendipity_plugin_timezones.phpCode: Select all
<?php /* serendipity_plugin_timezones.php from Christoph Eunicke <s9y-plugin@eunicke.org> */
if (IN_serendipity !== true) {
die ("Don't hack!");
}
// Probe for a language include with constants. Still include defines later on, if some constants were missing
$probelang = dirname(__FILE__) . '/' . $serendipity['charset'] . 'lang_' . $serendipity['lang'] . '.inc.php';
if (file_exists($probelang)) {
include $probelang;
}
include dirname(__FILE__) . '/lang_en.inc.php';
class serendipity_plugin_timezones extends serendipity_plugin {
var $title = PLUGIN_TIMEZONES_TITLE;
function introspect(&$propbag) {
$propbag->add('name', PLUGIN_TIMEZONES_TITLE);
$propbag->add('description', PLUGIN_TIMEZONES_BLAHBLAH);
$propbag->add('configuration', array('title', 'zone1_text', 'zone1_name', 'zone1_format', 'timeshift1',
'zone2_text', 'zone2_name', 'zone2_format', 'timeshift2',
'zone3_text', 'zone3_name', 'zone3_format', 'timeshift3',
'zone4_text', 'zone4_name', 'zone4_format', 'timeshift4'));
$propbag->add('author', 'Christoph Eunicke <s9y-plugin@eunicke.org>');
$propbag->add('stackable', true);
$propbag->add('version', '0.3');
$propbag->add('requirements', array(
'serendipity' => '0.9',
'smarty' => '2.6.7',
'php' => '4.1.0'
));
$propbag->add('groups', array('FRONTEND_FEATURES'));
}
function introspect_config_item($name, &$propbag) {
switch($name) {
case 'zone1_text':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_TIMEZONES_ZONE1_TEXT);
$propbag->add('description', PLUGIN_TIMEZONES_ZONE1_TEXT_BLABLAH);
$propbag->add('default', 'Cologne:');
break;
case 'zone2_text':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_TIMEZONES_ZONE2_TEXT);
$propbag->add('description', PLUGIN_TIMEZONES_ZONE2_TEXT_BLABLAH);
$propbag->add('default', 'Sacramento:');
break;
case 'zone3_text':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_TIMEZONES_ZONE3_TEXT);
$propbag->add('description', PLUGIN_TIMEZONES_ZONE3_TEXT_BLABLAH);
$propbag->add('default', '');
break;
case 'zone4_text':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_TIMEZONES_ZONE4_TEXT);
$propbag->add('description', PLUGIN_TIMEZONES_ZONE4_TEXT_BLABLAH);
$propbag->add('default', '');
break;
case 'title':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_TIMEZONES_NUGGET_TITLE);
$propbag->add('description', PLUGIN_TIMEZONES_NUGGET_TITLE_BLABLAH);
$propbag->add('default', PLUGIN_TIMEZONES_TITLE);
break;
case 'zone1_name':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_TIMEZONES_ZONE1_NAME);
$propbag->add('description', PLUGIN_TIMEZONES_ZONE1_NAME_BLABLAH);
$propbag->add('default', 'WEST');
break;
case 'zone2_name':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_TIMEZONES_ZONE2_NAME);
$propbag->add('description', PLUGIN_TIMEZONES_ZONE2_NAME_BLABLAH);
$propbag->add('default', 'PST');
break;
case 'zone3_name':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_TIMEZONES_ZONE3_NAME);
$propbag->add('description', PLUGIN_TIMEZONES_ZONE3_NAME_BLABLAH);
$propbag->add('default', '');
break;
case 'zone4_name':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_TIMEZONES_ZONE4_NAME);
$propbag->add('description', PLUGIN_TIMEZONES_ZONE4_NAME_BLABLAH);
$propbag->add('default', '');
break;
case 'zone1_format':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_TIMEZONES_ZONE1_FORMAT);
$propbag->add('description', PLUGIN_TIMEZONES_ZONE1_FORMAT_BLABLAH);
$propbag->add('default', '%T');
break;
case 'zone2_format':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_TIMEZONES_ZONE2_FORMAT);
$propbag->add('description', PLUGIN_TIMEZONES_ZONE2_FORMAT_BLABLAH);
$propbag->add('default', '%T');
break;
case 'zone3_format':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_TIMEZONES_ZONE3_FORMAT);
$propbag->add('description', PLUGIN_TIMEZONES_ZONE3_FORMAT_BLABLAH);
$propbag->add('default', '');
break;
case 'zone4_format':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_TIMEZONES_ZONE4_FORMAT);
$propbag->add('description', PLUGIN_TIMEZONES_ZONE4_FORMAT_BLABLAH);
$propbag->add('default', '');
break;
case 'timeshift1':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_TIMEZONES_TIMESHIFT1);
$propbag->add('description', PLUGIN_TIMEZONES_TIMESHIFT1_BLABLAH);
$propbag->add('default', '');
break;
case 'timeshift2':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_TIMEZONES_TIMESHIFT2);
$propbag->add('description', PLUGIN_TIMEZONES_TIMESHIFT2_BLABLAH);
$propbag->add('default', '');
break;
case 'timeshift3':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_TIMEZONES_TIMESHIFT3);
$propbag->add('description', PLUGIN_TIMEZONES_TIMESHIFT3_BLABLAH);
$propbag->add('default', '');
break;
case 'timeshift4':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_TIMEZONES_TIMESHIFT4);
$propbag->add('description', PLUGIN_TIMEZONES_TIMESHIFT4_BLABLAH);
$propbag->add('default', '');
break;
default:
return false;
}
return true;
}
function generate_content(&$title) {
global $serendipity;
$title = $this->get_config('title');
if (($this->get_config('timeshift1') == "" ||
$this->get_config('timeshift2') == "" ||
$this->get_config('timeshift3') == "" ||
$this->get_config('timeshift4') == "" ) &&
@include_once 'Date.php') {
$date = new Date();
//create the first date
$date->convertTZbyID($this->get_config('zone1_name'));
$date1=$date->format($this->get_config('zone1_format'));
$date->convertTZbyID($this->get_config('zone2_name'));
$date2=$date->format($this->get_config('zone2_format'));
$date->convertTZbyID($this->get_config('zone3_name'));
$date3=$date->format($this->get_config('zone3_format'));
$date->convertTZbyID($this->get_config('zone4_name'));
$date4=$date->format($this->get_config('zone4_format'));
} else {
$date1=date($this->get_config('zone1_format'),time()+$this->get_config('timeshift1'));
$date2=date($this->get_config('zone2_format'),time()+$this->get_config('timeshift2'));
$date3=date($this->get_config('zone3_format'),time()+$this->get_config('timeshift3'));
$date4=date($this->get_config('zone4_format'),time()+$this->get_config('timeshift4'));
}
echo $this->get_config('zone1_text');
echo $date1;
echo '<br />';
echo $this->get_config('zone2_text');
echo $date2;
echo '<br />';
if ($this->get_config('zone3_text') !== ""){ //Third zone required
echo $this->get_config('zone3_text');
echo $date3;
echo '<br />';
if ($this->get_config('zone4_text') !== ""){ //Fourth zone required
echo $this->get_config('zone4_text');
echo $date4;
echo '</div>';
}
}
}
}