From eba717f95f586d2538007bd18da6e9b32b076c30 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 31 Oct 2008 22:12:14 +0000 Subject: Merge over vendor code. git-svn-id: http://gallery.svn.sourceforge.net/svnroot/gallery/trunk/eval/gx/gallery3/trunk@18408 57fcd75e-5312-0410-8df3-f5eb6fbb1595 --- modules/forge/libraries/Form_Checklist.php | 92 ++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 modules/forge/libraries/Form_Checklist.php (limited to 'modules/forge/libraries/Form_Checklist.php') diff --git a/modules/forge/libraries/Form_Checklist.php b/modules/forge/libraries/Form_Checklist.php new file mode 100644 index 00000000..6b1df490 --- /dev/null +++ b/modules/forge/libraries/Form_Checklist.php @@ -0,0 +1,92 @@ + '', + 'type' => 'checkbox', + 'class' => 'checklist', + 'options' => array(), + ); + + protected $protect = array('name', 'type'); + + public function __construct($name) + { + $this->data['name'] = $name; + } + + public function __get($key) + { + if ($key == 'value') + { + // Return the currently checked values + $array = array(); + foreach ($this->data['options'] as $id => $opt) + { + // Return the options that are checked + ($opt[1] === TRUE) and $array[] = $id; + } + return $array; + } + + return parent::__get($key); + } + + public function render() + { + // Import base data + $base_data = $this->data; + + // Make it an array + $base_data['name'] .= '[]'; + + // Newline + $nl = "\n"; + + $checklist = ''; + + return $checklist; + } + + protected function load_value() + { + foreach ($this->data['options'] as $val => $checked) + { + if ($input = $this->input_value($this->data['name'])) + { + $this->data['options'][$val][1] = in_array($val, $input); + } + else + { + $this->data['options'][$val][1] = FALSE; + } + } + } + +} // End Form Checklist \ No newline at end of file -- cgit v1.2.3