XOOPS RMCommon Utilities  2.1.8.91RC
 All Classes Namespaces Files Functions Variables
date.class.php
Go to the documentation of this file.
1 <?php
2 // $Id: date.class.php 870 2011-12-22 08:51:07Z i.bitcero $
3 // --------------------------------------------------------------
4 // EXM System
5 // Content Management System
6 // Author: Eduardo Cortés (aka BitC3R0)
7 // Email: bitc3r0@gmail.com
8 // License: GPL 2.0
9 // --------------------------------------------------------------
10 
11 global $rmc_config;
12 
14 {
15 
16  private $_date = 0;
17  private $options = 0;
18  private $year_range = '';
19  private $time;
20 
29  function __construct($caption, $name, $date='', $year_range='', $time=0){
30  $this->setCaption($caption);
31  $this->setName($name);
32  $this->_date = $date;
33  $this->year_range = $year_range=='' ? (date('Y',time()) - 15).':'.(date('Y',time()) + 15) : $year_range;
34 
35  if ($time==0) $this->options = "showHour: false, showMinute: false, showSecond: false";
36  $this->time = $time;
37 
38  RMTemplate::get()->add_local_script('jquery-ui-timepicker-addon.js', 'rmcommon', 'include');
39  RMTemplate::get()->add_local_script('dates.js', 'rmcommon', 'include');
40 
41  }
42 
48  public function options($options){
49 
50  $this->options = $options;
51 
52  }
53 
54  public function render(){
55  global $exmConfig;
56  /*$rtn = '';
57  $rtn .= '<div class="exmDateField">
58  <div id="txt_'.$this->getName().'" class="exmTextDate">'.($this->_date===null ? _RMS_CFD_SDTXT : date($this->_showtime ? $exmConfig['datestring'] : $exmConfig['dateshort'], $this->_date)).'</div>';
59  $rtn .= '<img title="'._RMS_CFD_CLICKTOSEL.'" src="'.ABSURL.'/rmcommon/images/calendar.png" alt="" class="exmfield_date_show_date" onclick="showEXMDates(\''.$this->getName().'\','.$this->_showtime.','.($this->_date===null ? "'time'" : $this->_date).');" style="cursor: pointer;" />';
60  $rtn .= '<img title="'._RMS_CFD_CLICKTOCLEAR.'" src="'.ABSURL.'/rmcommon/images/calendardel.png" alt="" onclick="clearEXMDates(\''.$this->getName().'\');" style="cursor: pointer;" />';
61  $rtn .= '<input type="hidden" name="'.$this->getName().'" id="'.$this->getName().'" value="'.($this->_date===null ? '' : $this->_date).'" /></div>';
62  if (!defined('RM_FRAME_DATETIME_DIVOK')){
63  $rtn .= "<div id='exmDatesContainer' class='exmDates'></div>";
64  define('RM_FRAME_DATETIME_DIVOK', 1);
65  }*/
66 
67  if ($this->time==1){
68  RMTemplate::get()->add_head("\n<script type='text/javascript'>
69  \nvar ".$this->id()."_time = 1;
70  \n$(function(){
71  \n$(\"#exmdate-".$this->getName()."\").datetimepicker({changeMonth: true,changeYear: true, yearRange: '".$this->year_range."'".($this->options!=''?",".$this->options:"")."});
72  \n});\n</script>
73  \n");
74 
75  $date = '';
76  if($this->_date>0) $date = date('m/d/Y H:i:s', $this->_date);
77 
78  } elseif($this->time==0) {
79  RMTemplate::get()->add_head("\n<script type='text/javascript'>
80  \nvar ".$this->getName()."_time = 0;
81  \n$(function(){
82  \n$(\"#exmdate-".$this->id()."\").datepicker({changeMonth: true,changeYear: true, yearRange: '".$this->year_range."'".($this->options!=''?",".$this->options:"")."});
83  \n});\n</script>
84  \n");
85 
86  $date = '';
87  if($this->_date>0) $date = date('m/d/Y', $this->_date);
88 
89  } elseif($this->time==2){
90  RMTemplate::get()->add_head("\n<script type='text/javascript'>
91  \nvar ".$this->getName()."_time = 2;
92  \n$(function(){
93  \n$(\"#exmdate-".$this->id()."\").timepicker({changeMonth: true,changeYear: true, yearRange: '".$this->year_range."'".($this->options!=''?",".$this->options:"").", timeOnlyTitle: '".__('Choose Time','rmcommon')."'});
94  \n});\n</script>
95  \n");
96 
97  $date = '';
98  if($this->_date!='') $date = $this->_date;
99 
100  }
101 
102 
103 
104  $rtn = "<input type='text' class='exmdates_field' name='text_".$this->getName()."' id=\"exmdate-".$this->id()."\"' size='20' maxlength='19' value='".$date."' />
105  <input type='hidden' name='".$this->getName()."' id='".$this->id()."' value='".$this->_date."' />";
106  return $rtn;
107  }
108 
109 }