array( 'addAll' => 'Add all', 'removeAll' => 'Remove all', 'itemsSelected' => 'items selected', ) ); protected function _extractOptions(array &$attribs, array $names, array $defaults = array()) { $options = array(); foreach ($names as $name) { if (array_key_exists($name, $attribs)) { if (array_key_exists($name, $defaults) && is_array($defaults[$name])) { $options[$name] = array_merge($defaults[$name], (array) $attribs[$name]); } else { $options[$name] = $attribs[$name]; } unset($attribs[$name]); } elseif (array_key_exists($name, $defaults)) { $options[$name] = $defaults[$name]; } } return $options; } protected function _extractSpecialOptions(array &$attribs) { $this->_specialOptions = $this->_extractOptions( $attribs, $this->_specialOptionNames, $this->_specialOptionDefaults ); return $this->_specialOptions; } /** * Renders * * @param string $name * @param array|null $value Indexed array with ids of selected options * @param array|null $attribs * @param array|null $options Associative array with all available options (id => title) * @param string $listsep * @return string Html */ public function formMultiDraggableSelect($name, $value = null, $attribs = null, $options = null, $listsep = null) { $info = $this->_getInfo($name, $value, $attribs, $options, $listsep); $id = $disable = $escape = null; extract($info); // name, id, value, attribs, options, listsep, disable, escape $value = (array) $value; $options = (array) $options; $name .= ('[]' === substr($name, -2)) ? '' : '[]'; $this->_name = $name; $attribs['id'] = $this->_id = $id; $this->_extractSpecialOptions($attribs); $separatedOptions = array('available' => array(), 'selected' => array()); $order = 0; foreach ($options as $optValue => $optTitle) { $type = (in_array($optValue, $value)) ? 'selected' : 'available'; $separatedOptions[$type][$order++] = array('value' => $optValue, 'title' => $optTitle); } return $this->_renderElement($attribs, $separatedOptions['available'], $separatedOptions['selected']); } protected function _renderElement(array $attribs, array $available, array $selected) { if (($width = $this->_getWidth())) { $attribs['style'] = 'width: ' . $width; } $xhtml = '