XOOPS RMCommon Utilities  2.1.8.91RC
 All Classes Namespaces Files Functions Variables
timezone.class.php
Go to the documentation of this file.
1 <?php
2 // $Id: timezone.class.php 870 2011-12-22 08:51:07Z i.bitcero $
3 // --------------------------------------------------------------
4 // Red México Common Utilities
5 // A framework for Red México Modules
6 // Author: Eduardo Cortés <i.bitcero@gmail.com>
7 // Email: i.bitcero@gmail.com
8 // License: GPL 2.0
9 // --------------------------------------------------------------
10 
12 {
13  private $multi = 0;
14  private $type = 0;
15  private $selected = null;
16  private $size = 5;
17 
18  public function __construct($caption, $name, $type = 0, $multi = 0, $selected = null, $size=5){
19  $this->setName($name);
20  $this->setCaption($caption);
21  $this->multi = $multi;
22  $this->type = $type;
23  $this->selected = $selected;
24  }
25  public function multi(){
26  return $this->multi;
27  }
28  public function setMulti($value){
29  return $this->multi = $value;
30  }
31  public function type(){
32  return $this->type;
33  }
34  public function setType($value){
35  return $this->type = $value;
36  }
37  public function selected(){
38  return $this->selected;
39  }
40  public function setSelected($value){
41  return $this->selected = $value;
42  }
43  public function size(){
44  return $this->size;
45  }
46  public function setSize($value){
47  return $this->size = $value;
48  }
49 
50  public function render(){
51  include_once XOOPS_ROOT_PATH."/class/xoopslists.php";
52  $zonas = XoopsLists::getTimeZoneList();
53 
54  if ($this->type){
55  $rtn = "<table cellpadding='2' cellspacing='1' border='0'>";
56  foreach ($zonas as $k => $v){
57  $rtn .= "<tr><td>";
58  if ($this->multi){
59  if (!is_array($this->selected)) $this->selected=array($this->selected);
60  $rtn .= "<label><input type='checkbox' value='$k' name='".$this->getName()."[]' id='".$this->id()."[]'".(is_array($this->selected) ? (in_array($k, $this->selected) ? " checked='checked'" : '') : '')." /> $v</label>";
61  } else {
62  $rtn .= "<label><input type='radio' value='$k' name='".$this->getName()."' id='".$this->id()."'".($k == $this->selected ? " checked='checked'" : '')." /> $v</label>";
63  }
64  $rtn .= "</td></tr>";
65  $i++;
66  }
67  $rtn .= "</table>";
68  } else {
69  if ($this->multi){
70  if (!is_array($this->selected)) $this->selected=array($this->selected);
71  $rtn = "<select name='".$this->getName()."[]' id='".$this->id()."[]' size='$this->size' multiple='multiple'>";
72  foreach ($zonas as $k => $v){
73  $rtn .= "<option value='$k'".(is_array($this->selected) ? (in_array($k, $this->selected) ? " selected='selected'" : '') : '').">$v</option>";
74  }
75  $rtn .= "</select>";
76  } else {
77  $rtn = "<select name='".$this->getName()."' id='".$this->id()."'>";
78  foreach ($zonas as $k => $v){
79  $rtn .= "<option value='$k'".($k==$this->selected ? " selected='selected'" : '').">$v</option>";
80  }
81  $rtn .= "</select>";
82  }
83  }
84 
85  return $rtn;
86 
87  }
88 
89 }
90 
91 ?>