Go to the documentation of this file.00001 <?php
00002 if(!defined('__PRAGYAN_CMS'))
00003 {
00004 header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden');
00005 echo "<h1>403 Forbidden<h1><h4>You are not authorized to access the page.</h4>";
00006 echo '<hr/>'.$_SERVER['SERVER_SIGNATURE'];
00007 exit(1);
00008 }
00019 global $sourceFolder;
00020 require_once("$sourceFolder/widgetFramework.class.php");
00021
00022 class serverDateTime extends widgetFramework
00023 {
00024 public $configs;
00025 public $includes;
00026 public $timeformat;
00027 public $globaldisable;
00028 public $displaytext;
00029
00030 public function __construct($widgetId,$widgetInstanceId,$pageId)
00031 {
00032 $this->configs = array (
00033 array (
00034 'name' => 'time_format',
00035 'type' => 'select',
00036 'options' => '12 Hour|24 Hour',
00037 'displaytext' => 'Time display format',
00038 'default' => '12 Hour',
00039 'global' => 0
00040 ),
00041 array (
00042 'name' => 'display_text',
00043 'type' => 'text',
00044 'displaytext' => 'Display text with the time ( [%s] will be substituted with time )',
00045 'default' => 'Server time : [%s].',
00046 'global' => 0
00047 ),
00048 array (
00049 'name' => 'global_disable',
00050 'type' => 'bool',
00051 'displaytext' => 'Disable all clocks in the website',
00052 'default' => '0',
00053 'global' => 1
00054 )
00055 );
00056
00057 parent::__construct($widgetId,$widgetInstanceId,$pageId,$this->configs);
00058
00059 }
00060
00061
00062 public function initWidget()
00063 {
00064 $this->timeformat = $this->settings['time_format'];
00065 $this->globaldisable = $this->settings['global_disable'];
00066 $this->displaytext = $this->settings['display_text'];
00067 }
00068
00069 public function getCommonHTML()
00070 {
00071 return $this->includes;
00072 }
00073
00074 public function getHTML()
00075 {
00076 if($this->globaldisable=='1' || $this->globaldisable=='Yes') return "";
00077
00078 $finaltime = "";
00079
00080 if($this->timeformat == "12 Hour")
00081 $finaltime = date("g:i:s a");
00082 else $finaltime = date("H:i:s a");
00083
00084 $finaltext = preg_replace('/(.*)\[\%s\](.*)/','$1 '.$finaltime.'$2',$this->displaytext);
00085 return $finaltext;
00086 }
00087 }
00088
00089 ?>