|
|
|
@ -216,6 +216,8 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
|
*/ |
|
|
|
|
var $_attributesHidden; |
|
|
|
|
|
|
|
|
|
public $selectAllCheckBox = false; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Default Element template string |
|
|
|
|
* |
|
|
|
@ -270,14 +272,19 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
|
* @return void |
|
|
|
|
* @since version 0.4.0 (2005-06-25) |
|
|
|
|
*/ |
|
|
|
|
function HTML_QuickForm_advmultiselect($elementName = null, $elementLabel = null, |
|
|
|
|
$options = null, $attributes = null, |
|
|
|
|
$sort = null) |
|
|
|
|
{ |
|
|
|
|
public function HTML_QuickForm_advmultiselect( |
|
|
|
|
$elementName = null, |
|
|
|
|
$elementLabel = null, |
|
|
|
|
$options = null, |
|
|
|
|
$attributes = null, |
|
|
|
|
$sort = null |
|
|
|
|
) { |
|
|
|
|
$opts = $options; |
|
|
|
|
$options = null; // prevent to use the default select element load options |
|
|
|
|
$this->HTML_QuickForm_select($elementName, $elementLabel, |
|
|
|
|
$options, $attributes); |
|
|
|
|
|
|
|
|
|
$this->HTML_QuickForm_select($elementName, $elementLabel, $options, $attributes); |
|
|
|
|
|
|
|
|
|
$this->selectAllCheckBox = isset($attributes['select_all_checkbox']) ? $attributes['select_all_checkbox'] : false; |
|
|
|
|
|
|
|
|
|
// allow to load options at once and take care of fancy attributes |
|
|
|
|
$this->load($opts); |
|
|
|
@ -291,13 +298,12 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
|
} |
|
|
|
|
if (is_null($this->getAttribute('style'))) { |
|
|
|
|
// default width of each select box |
|
|
|
|
$this->updateAttributes(array('style' => 'width:100px;')); |
|
|
|
|
$this->updateAttributes(array('style' => 'min-width:180px;')); |
|
|
|
|
} |
|
|
|
|
$this->_tableAttributes = $this->getAttribute('class'); |
|
|
|
|
if (is_null($this->_tableAttributes)) { |
|
|
|
|
// default table layout |
|
|
|
|
$attr = array('border' => '0', |
|
|
|
|
'cellpadding' => '10', 'cellspacing' => '0'); |
|
|
|
|
$attr = array('border' => '0', 'cellpadding' => '10', 'cellspacing' => '0'); |
|
|
|
|
} else { |
|
|
|
|
$attr = array('class' => $this->_tableAttributes); |
|
|
|
|
$this->_removeAttr('class', $this->_attributes); |
|
|
|
@ -400,13 +406,16 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
|
switch ($button) { |
|
|
|
|
case 'add': |
|
|
|
|
if (is_null($attributes)) { |
|
|
|
|
$this->_addButtonAttributes |
|
|
|
|
= array('name' => 'add', |
|
|
|
|
$this->_addButtonAttributes = array( |
|
|
|
|
'name' => 'add', |
|
|
|
|
'value' => ' ', |
|
|
|
|
'type' => 'button'); |
|
|
|
|
'type' => 'button' |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
|
$this->_updateAttrArray($this->_addButtonAttributes, |
|
|
|
|
$this->_parseAttributes($attributes)); |
|
|
|
|
$this->_updateAttrArray( |
|
|
|
|
$this->_addButtonAttributes, |
|
|
|
|
$this->_parseAttributes($attributes) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 'remove': |
|
|
|
@ -586,7 +595,7 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
|
* @return string |
|
|
|
|
* @since version 0.4.0 (2005-06-25) |
|
|
|
|
*/ |
|
|
|
|
function toHtml() |
|
|
|
|
public function toHtml() |
|
|
|
|
{ |
|
|
|
|
if ($this->_flagFrozen) { |
|
|
|
|
return $this->getFrozenHtml(); |
|
|
|
@ -610,7 +619,6 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
|
|
|
|
|
|
$strHtmlSelected = $tab . '<div id="qfams_'.$id.'">' . PHP_EOL; |
|
|
|
|
$unselected_count = count($this->_options); |
|
|
|
|
|
|
|
|
|
$checkbox_id_suffix = 0; |
|
|
|
|
|
|
|
|
|
foreach ($this->_options as $option) { |
|
|
|
@ -654,16 +662,13 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
|
|
|
|
|
|
// build the select all button with all its attributes |
|
|
|
|
$jsName = $this->_jsPrefix . $this->_jsPostfix; |
|
|
|
|
$attributes = array('onclick' => $jsName . |
|
|
|
|
"('". $selectId ."', 1);"); |
|
|
|
|
$this->_allButtonAttributes |
|
|
|
|
= array_merge($this->_allButtonAttributes, $attributes); |
|
|
|
|
$attributes = array('onclick' => $jsName ."('". $selectId ."', 1);"); |
|
|
|
|
$this->_allButtonAttributes = array_merge($this->_allButtonAttributes, $attributes); |
|
|
|
|
$attrStrAll = $this->_getAttrString($this->_allButtonAttributes); |
|
|
|
|
$strHtmlAll = "<input$attrStrAll />". PHP_EOL; |
|
|
|
|
|
|
|
|
|
// build the select none button with all its attributes |
|
|
|
|
$attributes = array('onclick' => $jsName . |
|
|
|
|
"('". $selectId ."', 0);"); |
|
|
|
|
$attributes = array('onclick' => $jsName ."('". $selectId ."', 0);"); |
|
|
|
|
$this->_noneButtonAttributes |
|
|
|
|
= array_merge($this->_noneButtonAttributes, $attributes); |
|
|
|
|
$attrStrNone = $this->_getAttrString($this->_noneButtonAttributes); |
|
|
|
@ -672,9 +677,7 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
|
// build the toggle selection button with all its attributes |
|
|
|
|
$attributes = array('onclick' => $jsName . |
|
|
|
|
"('". $selectId ."', 2);"); |
|
|
|
|
$this->_toggleButtonAttributes |
|
|
|
|
= array_merge($this->_toggleButtonAttributes, |
|
|
|
|
$attributes); |
|
|
|
|
$this->_toggleButtonAttributes = array_merge($this->_toggleButtonAttributes, $attributes); |
|
|
|
|
$attrStrToggle = $this->_getAttrString($this->_toggleButtonAttributes); |
|
|
|
|
$strHtmlToggle = "<input$attrStrToggle />". PHP_EOL; |
|
|
|
|
|
|
|
|
@ -802,13 +805,22 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
|
= array_merge($this->_attributes, $this->_attributesSelected); |
|
|
|
|
$attrSelected = $this->_getAttrString($this->_attributesSelected); |
|
|
|
|
} |
|
|
|
|
$strHtmlSelected = "<select$attrSelected>". PHP_EOL; |
|
|
|
|
$strHtmlSelected = "<select$attrSelected>"; |
|
|
|
|
if ($selected_count > 0) { |
|
|
|
|
foreach ($arrHtmlSelected as $data) { |
|
|
|
|
$attribute = null; |
|
|
|
|
if (isset($data['attr'])) { |
|
|
|
|
$attribute = $this->_getAttrString($data['attr']); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$text = null; |
|
|
|
|
if (isset($data['text'])) { |
|
|
|
|
$text = $data['text']; |
|
|
|
|
} |
|
|
|
|
$strHtmlSelected |
|
|
|
|
.= $tabs . $tab |
|
|
|
|
. '<option' . $this->_getAttrString($data['attr']) . '>' |
|
|
|
|
. $data['text'] . '</option>' . PHP_EOL; |
|
|
|
|
. '<option' . $attribute. '>' |
|
|
|
|
. $text . '</option>'; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
$strHtmlSelected .= '<option value=""> </option>'; |
|
|
|
@ -819,10 +831,18 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
|
$strHtmlHidden = "<select$attrHidden>". PHP_EOL; |
|
|
|
|
if (count($arrHtmlHidden) > 0) { |
|
|
|
|
foreach ($arrHtmlHidden as $data) { |
|
|
|
|
$attribute = null; |
|
|
|
|
if (isset($data['attr'])) { |
|
|
|
|
$attribute = $this->_getAttrString($data['attr']); |
|
|
|
|
} |
|
|
|
|
$text = null; |
|
|
|
|
if (isset($data['text'])) { |
|
|
|
|
$text = $data['text']; |
|
|
|
|
} |
|
|
|
|
$strHtmlHidden |
|
|
|
|
.= $tabs . $tab |
|
|
|
|
. '<option' . $this->_getAttrString($data['attr']) . '>' |
|
|
|
|
. $data['text'] . '</option>' . PHP_EOL; |
|
|
|
|
. '<option' . $attribute . '>' |
|
|
|
|
. $text . '</option>' . PHP_EOL; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$strHtmlHidden .= '</select>'; |
|
|
|
@ -838,7 +858,7 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
|
$this->_removeButtonAttributes |
|
|
|
|
= array_merge($this->_removeButtonAttributes, $attributes); |
|
|
|
|
$attrStrRemove = $this->_getAttrString($this->_removeButtonAttributes); |
|
|
|
|
$strHtmlRemove = "<input$attrStrRemove />". PHP_EOL; |
|
|
|
|
$strHtmlRemove = "<button $attrStrRemove /> <i class='fa fa-arrow-left'></i></button>"; |
|
|
|
|
|
|
|
|
|
// build the add button with all its attributes |
|
|
|
|
$attributes |
|
|
|
@ -848,10 +868,9 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
|
"this.form.elements['" . $selectNameTo . "'], " . |
|
|
|
|
"this.form.elements['" . $selectName . "'], " . |
|
|
|
|
"'add', '{$this->_sort}'); return false;"); |
|
|
|
|
$this->_addButtonAttributes |
|
|
|
|
= array_merge($this->_addButtonAttributes, $attributes); |
|
|
|
|
$this->_addButtonAttributes = array_merge($this->_addButtonAttributes, $attributes); |
|
|
|
|
$attrStrAdd = $this->_getAttrString($this->_addButtonAttributes); |
|
|
|
|
$strHtmlAdd = "<input$attrStrAdd />". PHP_EOL; |
|
|
|
|
$strHtmlAdd = "<button $attrStrAdd /> <i class='fa fa-arrow-right'></i></button><br /><br />"; |
|
|
|
|
|
|
|
|
|
// build the select all button with all its attributes |
|
|
|
|
$attributes |
|
|
|
@ -861,8 +880,7 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
|
"this.form.elements['" . $selectNameTo . "'], " . |
|
|
|
|
"this.form.elements['" . $selectName . "'], " . |
|
|
|
|
"'all', '{$this->_sort}'); return false;"); |
|
|
|
|
$this->_allButtonAttributes |
|
|
|
|
= array_merge($this->_allButtonAttributes, $attributes); |
|
|
|
|
$this->_allButtonAttributes = array_merge($this->_allButtonAttributes, $attributes); |
|
|
|
|
$attrStrAll = $this->_getAttrString($this->_allButtonAttributes); |
|
|
|
|
$strHtmlAll = "<input$attrStrAll />". PHP_EOL; |
|
|
|
|
|
|
|
|
@ -990,6 +1008,14 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
|
$strHtmlMoveTop, $strHtmlMoveBottom |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if ($this->selectAllCheckBox) { |
|
|
|
|
$strHtml .= ' |
|
|
|
|
<label class="checkbox" >'.get_lang('SelectAll').' |
|
|
|
|
<input type="checkbox" class="advmultiselect_checkbox" id="'.$selectId.'_select_all'.'"> |
|
|
|
|
</label> |
|
|
|
|
'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$strHtml = str_replace($placeHolders, $htmlElements, $strHtml); |
|
|
|
|
|
|
|
|
|
$comment = $this->getComment(); |
|
|
|
@ -998,6 +1024,7 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
|
$strHtml = $tabs . '<!-- ' . $comment . " //-->" . PHP_EOL . $strHtml; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $strHtml; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1013,16 +1040,14 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
|
*/ |
|
|
|
|
function getElementJs($raw = true, $min = true) |
|
|
|
|
{ |
|
|
|
|
$js = '@data_dir@' . DIRECTORY_SEPARATOR |
|
|
|
|
. '@package_name@' . DIRECTORY_SEPARATOR; |
|
|
|
|
|
|
|
|
|
$js = api_get_path(LIBRARY_PATH).'javascript'.DIRECTORY_SEPARATOR.'pear'.DIRECTORY_SEPARATOR; |
|
|
|
|
|
|
|
|
|
if ($min) { |
|
|
|
|
/*if ($min) { |
|
|
|
|
$js .= 'qfamsHandler-min.js'; |
|
|
|
|
} else { |
|
|
|
|
$js .= 'qfamsHandler.js'; |
|
|
|
|
} |
|
|
|
|
}*/ |
|
|
|
|
$js .= 'qfamsHandler.js'; |
|
|
|
|
|
|
|
|
|
if (file_exists($js)) { |
|
|
|
|
$js = file_get_contents($js); |
|
|
|
@ -1038,6 +1063,7 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
|
. PHP_EOL . '</script>' |
|
|
|
|
. PHP_EOL; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $js; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|