]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/CurrentTime.php
timezone argument not implemented
[SourceForge/phpwiki.git] / lib / plugin / CurrentTime.php
1 <?php // -*-php-*-
2 rcs_id('$Id: CurrentTime.php 6185 2008-08-22 11:40:14Z vargenau $');
3 /*
4  * Copyright 2008 Marc-Etienne Vargenau, Alcatel-Lucent
5  *
6  * This file is part of PhpWiki.
7  *
8  * PhpWiki is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * PhpWiki is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with PhpWiki; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 /*
24  * Standard Alcatel-Lucent disclaimer for contributing to open source
25  *
26  * "The CurrentTimePlugin ("Contribution") has not been tested and/or
27  * validated for release as or in products, combinations with products or
28  * other commercial use. Any use of the Contribution is entirely made at
29  * the user's own responsibility and the user can not rely on any features,
30  * functionalities or performances Alcatel-Lucent has attributed to the
31  * Contribution.
32  *
33  * THE CONTRIBUTION BY ALCATEL-LUCENT IS PROVIDED AS IS, WITHOUT WARRANTY
34  * OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
35  * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, COMPLIANCE,
36  * NON-INTERFERENCE AND/OR INTERWORKING WITH THE SOFTWARE TO WHICH THE
37  * CONTRIBUTION HAS BEEN MADE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
38  * ALCATEL-LUCENT BE LIABLE FOR ANY DAMAGES OR OTHER LIABLITY, WHETHER IN
39  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
40  * CONTRIBUTION OR THE USE OR OTHER DEALINGS IN THE CONTRIBUTION, WHETHER
41  * TOGETHER WITH THE SOFTWARE TO WHICH THE CONTRIBUTION RELATES OR ON A STAND
42  * ALONE BASIS."
43  */
44
45 /**
46  * A simple plugin that displays current time and date.
47  *
48  * Usage:
49  * <?plugin CurrentTime?>
50  * <?plugin CurrentTime format=XXX ?>
51  */
52
53 class WikiPlugin_CurrentTime
54 extends WikiPlugin
55 {
56     // Five required functions in a WikiPlugin.
57
58     function getName () {
59         return _("CurrentTime");
60     }
61
62     function getDescription () {
63         return _("A simple plugin that displays current time and date");
64
65     }
66
67     function getVersion() {
68         return preg_replace("/[Revision: $]/", '',
69                             "\$Revision: 6185 $");
70     }
71
72     // Establish default values for each of this plugin's arguments.
73     function getDefaultArguments() {
74         return array('format'  => '%Y-%m-%d %T');
75     }
76
77     function run($dbi, $argstr, &$request, $basepage) {
78         extract($this->getArgs($argstr, $request));
79
80         if ($format == 'date') {
81             $format = '%Y-%m-%d';
82         }
83         if ($format == 'time') {
84             $format = '%T';
85         }
86
87         return HTML::span(strftime($format, time()));
88     }
89 };
90
91 // For emacs users
92 // Local Variables:
93 // mode: php
94 // tab-width: 8
95 // c-basic-offset: 4
96 // c-hanging-comment-ender-p: nil
97 // indent-tabs-mode: nil
98 // End:
99 ?>