XOOPS RMCommon Utilities  2.1.8.91RC
 All Classes Namespaces Files Functions Variables
theme.class.php
Go to the documentation of this file.
1 <?php
2 // $Id: theme.class.php 825 2011-12-09 00:06:11Z 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 = array();
16  private $cols = 2;
17  private $section = '';
18 
30  function __construct($caption, $name, $multi = 0, $type = 0, $selected = null, $cols = 2, $section=''){
31  $this->setName($name);
32  $this->setCaption($caption);
33  $this->multi = $multi;
34  $this->type = $type;
35  $this->cols = $cols;
36  $this->selected = $selected;
37  $this->section = $section;
38  }
39  function multi(){
40  return $this->multi;
41  }
42  function setMulti($value){
43  return $this->multi = $value;
44  }
45  function type(){
46  return $this->type;
47  }
48  function setType($value){
49  return $this->type = $value;
50  }
51  function selected(){
52  return $this->selected;
53  }
54  function setSelected($value){
55  return $this->selected = $value;
56  }
57 
58  function render(){
59  if($this->section=='GUI')
60  $dirs = XoopsLists::getDirListAsArray(XOOPS_ROOT_PATH.'/modules/rmcommon/themes', '');
61  else
62  $dirs = XoopsLists::getDirListAsArray(XOOPS_ROOT_PATH.'/themes', '');
63 
64  $themes = array();
65  foreach($dirs as $dir => $v){
66 
67  if($this->section=='GUI'){
68  if(!file_exists(XOOPS_ROOT_PATH.'/modules/rmcommon/themes/'.$dir.'/admin_gui.php')) die($dir);
69  }else{
70  if(!file_exists(XOOPS_ROOT_PATH.'/themes/'.$dir.'/theme.html')) continue;
71  }
72 
73  $themes[] = $dir;
74 
75  }
76 
77  if ($this->type){
78  $rtn = '<ul class="rmoptions_container">';
79  foreach ($themes as $k){
80  if ($this->multi){
81  $rtn .= "<li><label><input type='checkbox' value='$k' name='".$this->getName()."[]' id='".$this->id()."'".(is_array($this->selected) ? (in_array($k, $this->selected) ? " checked='checked'" : '') : '')." /> $k</label></li>";
82  } else {
83  $rtn .= "<li><label><input type='radio' value='$k' name='".$this->getName()."' id='".$this->id()."'".(!empty($this->selected) ? ($k == $this->selected ? " checked='checked'" : '') : '')." /> $k</label></li>";
84  }
85  }
86  $rtn .= "</ul>";
87  } else {
88  if ($this->multi){
89  $rtn = "<select name='".$this->getName()."[]' id='".$this->id()."' size='6' multiple='multiple'>";
90  foreach ($themes as $k){
91  $rtn .= "<option value='$k'".(is_array($this->selected) ? (in_array($k, $this->selected) ? " selected='selected'" : '') : '').">$k</option>";
92  }
93  $rtn .= "</select>";
94  } else {
95  $rtn = "<select name='".$this->getName()."' id='".$this->id()."'>";
96  foreach ($themes as $k){
97  $rtn .= "<option value='$k'".(!empty($this->selected) ? ($k==$this->selected ? " selected='selected'" : '') : '').">$k</option>";
98  }
99  $rtn .= "</select>";
100  }
101  }
102 
103  return $rtn;
104 
105  }
106 }