PluginProbe
CSS & JavaScript Toolbox / 6.1.4
CSS & JavaScript Toolbox v6.1.4
trunk 0.3 0.8 10 10.1 11 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 11.9.1 12 12.0 12.0.1 12.0.3 12.0.4 12.0.5 12.0.6 12.0.7 6.0 6.0.11 All 60 releases
css-javascript-toolbox / framework / html / components / checkbox-list / checkbox-list.class.php

checkbox-list.class.php in CSS & JavaScript Toolbox 6.1.4, at framework/html/components/checkbox-list/checkbox-list.class.php

186 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 *
4 */
5
6 // No direct access allowed.
7 defined('ABSPATH') or die("Access denied");
8
9 // HTML Component base class.
10 require CJTOOLBOX_FRAMEWORK . '/html/component.class.php';
11
12 /**
13 *
14 * @author Ahmed Said
15 */
16 class HTMLCheckboxList extends HTMLComponent {
17
18 /**
19 *
20 */
21 const ITEM_CLASS_NAME = 'checkbox-list-item';
22
23 /**
24 *
25 */
26 const LIST_CLASS_NAME = 'checkbox-list';
27
28 /**
29 *
30 */
31 const ITEM_SELECTED_CLASS_NAME = 'checkbox-list-selected-item';
32
33 /**
34 * put your comment there...
35 *
36 * @var mixed
37 */
38 protected $className = null;
39
40 /**
41 * put your comment there...
42 *
43 * @var mixed
44 */
45 protected $id = null;
46
47 /**
48 * put your comment there...
49 *
50 * @var mixed
51 */
52 protected $list = array();
53
54 /**
55 * put your comment there...
56 *
57 * @var mixed
58 */
59 protected $itemDefaults = null;
60
61 /**
62 * put your comment there...
63 *
64 * @var mixed
65 */
66 protected $title = null;
67
68 /**
69 * put your comment there...
70 *
71 * @param mixed $id
72 * @param mixed $name
73 * @param mixed $className
74 * @return HTMLCheckboxList
75 */
76 public function __construct($id, $name, $title = '', $className = self::LIST_CLASS_NAME) {
77 // Identify component file.
78 parent::__construct(__FILE__);
79 // Initialize class properties.
80 $this->id = $id;
81 $this->className = $className;
82 $this->title = $title;
83 // Initialize default values.
84 $this->itemDefaults = (object) array(
85 'name' => $name,
86 'className' => self::ITEM_CLASS_NAME,
87 'selectedClassName' => self::ITEM_SELECTED_CLASS_NAME,
88 );
89 }
90
91 /**
92 * put your comment there...
93 *
94 */
95 public function __toString() {
96 return $this->getTemplate('checkbox-list');
97 }
98
99 /**
100 * put your comment there...
101 *
102 * @param mixed $text
103 * @param mixed $value
104 * @param mixed $checked
105 * @param mixed $name
106 * @param mixed $className
107 * @param mixed $selectedClassName
108 */
109 public function add($text, $value, $checked, $name, $className = null, $selectedClassName = null) {
110 // Create new item.
111 $item = (object) array();
112 // Fill item with data.
113 $item->text = $text;
114 $item->value = $value;
115 $item->checked = $checked;
116 $item->name = "{$this->itemDefaults->name}{$name}";
117 $item->className = $className ? $className : $this->itemDefaults->className;
118 $item->selectedClassName = $selectedClassName ? $selectedClassName : $this->itemDefaults->selectedClassName;
119 // Add item to the list.
120 $this->list[$value] = $item;
121 }
122
123 /**
124 * put your comment there...
125 *
126 */
127 public function clear() {
128 $this->list = array();
129 }
130
131 /**
132 * put your comment there...
133 *
134 * @param mixed $value
135 */
136 public function delete($value) {
137 unset($this->list[$value]);
138 }
139
140 /**
141 *
142 */
143 public function getClassName() {
144 return $this->className;
145 }
146
147 /**
148 * put your comment there...
149 *
150 */
151 public function getId() {
152 return $this->id;
153 }
154
155 /**
156 * put your comment there...
157 *
158 * @param mixed $id
159 * @param mixed $className
160 */
161 public static function getInstance($id, $name, $title = '', $className = self::LIST_CLASS_NAME) {
162 return new HTMLCheckboxList($id, $name, $title, $className);
163 }
164
165 /**
166 * put your comment there...
167 *
168 */
169 public function getTitle() {
170 return $this->title;
171 }
172
173 /**
174 * put your comment there...
175 *
176 * @param mixed $name
177 * @param mixed $className
178 * @param mixed $selectedClassName
179 */
180 public function setItemDefault($name, $className = self::ITEM_CLASS_NAME, $selectedClassName = self::ITEM_SELECTED_CLASS_NAME) {
181 $this->itemDefaults->name = $name;
182 $this->itemDefaults->className = $className;
183 $this->itemDefaults->selectedClassName = $selectedClassName;
184 }
185
186 } // End class.