noalyss Version-9
idate.class.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * NOALYSS is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * NOALYSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with NOALYSS; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21// Copyright Author Dany De Bontridder danydb@noalyss.eu
22
23 /**
24 *\file
25 \brief Html Input Date type
26 */
27
28
29/// Html Input : Input a date format dd.mm.yyyy
30/// The property title should be set to indicate what it is expected
31/// @see calendar-setup.js
32
33class IDate extends HtmlInput
34{
35
37 var $title;
39 static $firstDate=0; //<! first day in the calendar : 0 for sunday
40
41 function __construct($name='', $value='', $p_id="")
42 {
43 parent::__construct($name, $value, $p_id);
44 $this->title="";
45 $this->placeholder="dd.mm.yyyy";
46 $this->extra="";
47 $this->style=' class="input_text" ';
48 $this->autofocus=false;
49 }
50 /**
51 * @return string
52 */
53 public function get_placeholder()
54 {
55 return $this->placeholder;
56 return $this;
57 }
58
59 /**
60 * @param string $placeholder
61 */
63 {
65 return $this;
66 }
67
68 /**
69 * @return string
70 */
71 public function get_title()
72 {
73 return $this->title;
74 return $this;
75 }
76
77 /**
78 * @param string $title
79 */
80 public function set_title($title)
81 {
82 $this->title = $title;
83 return $this;
84 }
85
86 /**
87 * @return false
88 */
89 public function get_autofocus()
90 {
91 return $this->autofocus;
92 return $this;
93 }
94
95 /**
96 * @param false $autofocus
97 */
98 public function set_autofocus($autofocus)
99 {
100 $this->autofocus = $autofocus;
101 return $this;
102 }
103
104 /**
105 * @return mixed
106 */
107 public function get_firstDate()
108 {
109 return self::$firstDate;
110 }
111
112 /**
113 * @param mixed $firstDate
114 */
115 static function set_firstDate($firstDate)
116 {
117 if (isNumber($firstDate)==0){
118 throw new Exception("IDATE1: invalide data");
119 }
120 self::$firstDate= $firstDate;
121 }
122
123
124 /*!\brief show the html input of the widget */
125
126 public function input($p_name=null, $p_value=null)
127 {
128 $this->name=($p_name==null)?$this->name:$p_name;
129 $this->value=($p_value==null)?$this->value:$p_value;
130 if ($this->readOnly==true)
131 return $this->display();
132 if ($this->id=="") $this->id=self::generate_id($this->name);
133 $autofocus=($this->autofocus)?" autofocus ":"";
134 $onchange='onchange="format_date(this)"';
135 $r=sprintf('
136 <input type="text" name="%s" id="%s"
137 class="input_text"
138 size="10" style="width:6em"
139 value ="%s"
140 placeholder="%s"
141 title="%s"
142 pattern="[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4}"
143 %s
144 />
145 <span class="smallbutton icon"
146 id="%s_trigger"
147 />
148 &#xe811;
149 </span>
150 ',$this->name,$this->id,$this->value,$this->placeholder,$this->title,
151 $onchange,
152 $this->id
153 );
154 // @see calendar-setup.js
155 $r.=sprintf('<script type="text/javascript">
156 Calendar.setup({'.
157 'inputField : "%s",
158 ifFormat : "%%d.%%m.%%Y",
159 button : "%s_trigger",
160 align : "Bl",
161 singleClick : true,
162 firstDay:%s
163 });
164 </script>'
165 ,$this->id,
166 $this->id,
167 self::$firstDate);
168 return $r;
169 }
170
171 /*!\brief print in html the readonly value of the widget */
172
173 public function display()
174 {
175 $r="<span> ".$this->value;
176 $r.='<input type="hidden" name="'.$this->name.'"'.
177 'id="'.$this->id.'"'.
178 ' value = "'.$this->value.'"></span>';
179 return $r;
180 }
181
182 static public function test_me()
183 {
184
185 }
186
187}
isNumber($p_int)
Definition: ac_common.php:215
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
$opd_description style
$from_poste name
class widget This class is used to create all the HTML INPUT TYPE and some specials which works with ...
static generate_id($p_prefix)
generate an unique id for a widget,
Html Input : Input a date format dd.mm.yyyy The property title should be set to indicate what it is e...
Definition: idate.class.php:34
set_autofocus($autofocus)
Definition: idate.class.php:98
static $firstDate
Definition: idate.class.php:39
get_title()
Definition: idate.class.php:71
get_autofocus()
Definition: idate.class.php:89
set_title($title)
Definition: idate.class.php:80
__construct($name='', $value='', $p_id="")
Definition: idate.class.php:41
display()
print in html the readonly value of the widget
static set_firstDate($firstDate)
input($p_name=null, $p_value=null)
show the html input of the widget
get_placeholder()
Definition: idate.class.php:53
set_placeholder($placeholder)
Definition: idate.class.php:62
$placeholder
Definition: idate.class.php:36
get_firstDate()
static test_me()
$anc_filter placeholder
$anc_filter title
$icard readOnly
$poste extra