|
|
|
@ -274,14 +274,21 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
* @return void |
|
|
|
* @return void |
|
|
|
* @since version 0.4.0 (2005-06-25) |
|
|
|
* @since version 0.4.0 (2005-06-25) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function HTML_QuickForm_advmultiselect($elementName = null, $elementLabel = null, |
|
|
|
function HTML_QuickForm_advmultiselect( |
|
|
|
$options = null, $attributes = null, |
|
|
|
$elementName = null, |
|
|
|
$sort = null) |
|
|
|
$elementLabel = null, |
|
|
|
{ |
|
|
|
$options = null, |
|
|
|
|
|
|
|
$attributes = null, |
|
|
|
|
|
|
|
$sort = null |
|
|
|
|
|
|
|
) { |
|
|
|
$opts = $options; |
|
|
|
$opts = $options; |
|
|
|
$options = null; // prevent to use the default select element load options |
|
|
|
$options = null; // prevent to use the default select element load options |
|
|
|
$this->HTML_QuickForm_select($elementName, $elementLabel, |
|
|
|
$this->HTML_QuickForm_select( |
|
|
|
$options, $attributes); |
|
|
|
$elementName, |
|
|
|
|
|
|
|
$elementLabel, |
|
|
|
|
|
|
|
$options, |
|
|
|
|
|
|
|
$attributes |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// allow to load options at once and take care of fancy attributes |
|
|
|
// allow to load options at once and take care of fancy attributes |
|
|
|
$this->load($opts); |
|
|
|
$this->load($opts); |
|
|
|
@ -295,17 +302,17 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
} |
|
|
|
} |
|
|
|
if (is_null($this->getAttribute('style'))) { |
|
|
|
if (is_null($this->getAttribute('style'))) { |
|
|
|
// default width of each select box |
|
|
|
// default width of each select box |
|
|
|
$this->updateAttributes(array('style' => 'width:100px;')); |
|
|
|
//$this->updateAttributes(array('style' => 'min-width:100px;')); |
|
|
|
} |
|
|
|
} |
|
|
|
$this->_tableAttributes = $this->getAttribute('class'); |
|
|
|
$this->_tableAttributes = $this->getAttribute('class'); |
|
|
|
|
|
|
|
|
|
|
|
if (is_null($this->_tableAttributes)) { |
|
|
|
if (is_null($this->_tableAttributes)) { |
|
|
|
// default table layout |
|
|
|
$this->updateAttributes(array('class' => 'span4')); |
|
|
|
$attr = array('border' => '0', |
|
|
|
|
|
|
|
'cellpadding' => '10', 'cellspacing' => '0'); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$attr = array('class' => $this->_tableAttributes); |
|
|
|
$attr = array('class' => $this->_tableAttributes); |
|
|
|
$this->_removeAttr('class', $this->_attributes); |
|
|
|
$this->_removeAttr('class', $this->_attributes); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$this->_tableAttributes = $this->_getAttrString($attr); |
|
|
|
$this->_tableAttributes = $this->_getAttrString($attr); |
|
|
|
|
|
|
|
|
|
|
|
// set default add button attributes |
|
|
|
// set default add button attributes |
|
|
|
@ -395,117 +402,158 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
function setButtonAttributes($button, $attributes = null) |
|
|
|
function setButtonAttributes($button, $attributes = null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!is_string($button)) { |
|
|
|
if (!is_string($button)) { |
|
|
|
return PEAR::throwError('Argument 1 of HTML_QuickForm_advmultiselect::' . |
|
|
|
return PEAR::throwError( |
|
|
|
|
|
|
|
'Argument 1 of HTML_QuickForm_advmultiselect::'. |
|
|
|
'setButtonAttributes is not a string', |
|
|
|
'setButtonAttributes is not a string', |
|
|
|
HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT, |
|
|
|
HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT, |
|
|
|
array('level' => 'exception')); |
|
|
|
array('level' => 'exception') |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch ($button) { |
|
|
|
switch ($button) { |
|
|
|
case 'add': |
|
|
|
case 'add': |
|
|
|
if (is_null($attributes)) { |
|
|
|
if (is_null($attributes)) { |
|
|
|
$this->_addButtonAttributes |
|
|
|
$this->_addButtonAttributes |
|
|
|
= array('name' => 'add', |
|
|
|
= array( |
|
|
|
'value' => ' ', |
|
|
|
'name' => 'add', |
|
|
|
'type' => 'button'); |
|
|
|
'value' => '', |
|
|
|
|
|
|
|
'type' => 'button' |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
$this->setValue('<i class="icon-shopping-cart icon-large"></i>'); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$this->_updateAttrArray($this->_addButtonAttributes, |
|
|
|
$this->_updateAttrArray( |
|
|
|
$this->_parseAttributes($attributes)); |
|
|
|
$this->_addButtonAttributes, |
|
|
|
|
|
|
|
$this->_parseAttributes($attributes) |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'remove': |
|
|
|
case 'remove': |
|
|
|
if (is_null($attributes)) { |
|
|
|
if (is_null($attributes)) { |
|
|
|
$this->_removeButtonAttributes |
|
|
|
$this->_removeButtonAttributes |
|
|
|
= array('name' => 'remove', |
|
|
|
= array( |
|
|
|
|
|
|
|
'name' => 'remove', |
|
|
|
'value' => ' ', |
|
|
|
'value' => ' ', |
|
|
|
'type' => 'button'); |
|
|
|
'type' => 'button' |
|
|
|
|
|
|
|
); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$this->_updateAttrArray($this->_removeButtonAttributes, |
|
|
|
$this->_updateAttrArray( |
|
|
|
$this->_parseAttributes($attributes)); |
|
|
|
$this->_removeButtonAttributes, |
|
|
|
|
|
|
|
$this->_parseAttributes($attributes) |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'all': |
|
|
|
case 'all': |
|
|
|
if (is_null($attributes)) { |
|
|
|
if (is_null($attributes)) { |
|
|
|
$this->_allButtonAttributes |
|
|
|
$this->_allButtonAttributes |
|
|
|
= array('name' => 'all', |
|
|
|
= array( |
|
|
|
|
|
|
|
'name' => 'all', |
|
|
|
'value' => ' Select All ', |
|
|
|
'value' => ' Select All ', |
|
|
|
'type' => 'button'); |
|
|
|
'type' => 'button' |
|
|
|
|
|
|
|
); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$this->_updateAttrArray($this->_allButtonAttributes, |
|
|
|
$this->_updateAttrArray( |
|
|
|
$this->_parseAttributes($attributes)); |
|
|
|
$this->_allButtonAttributes, |
|
|
|
|
|
|
|
$this->_parseAttributes($attributes) |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'none': |
|
|
|
case 'none': |
|
|
|
if (is_null($attributes)) { |
|
|
|
if (is_null($attributes)) { |
|
|
|
$this->_noneButtonAttributes |
|
|
|
$this->_noneButtonAttributes |
|
|
|
= array('name' => 'none', |
|
|
|
= array( |
|
|
|
|
|
|
|
'name' => 'none', |
|
|
|
'value' => ' Select None ', |
|
|
|
'value' => ' Select None ', |
|
|
|
'type' => 'button'); |
|
|
|
'type' => 'button' |
|
|
|
|
|
|
|
); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$this->_updateAttrArray($this->_noneButtonAttributes, |
|
|
|
$this->_updateAttrArray( |
|
|
|
$this->_parseAttributes($attributes)); |
|
|
|
$this->_noneButtonAttributes, |
|
|
|
|
|
|
|
$this->_parseAttributes($attributes) |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'toggle': |
|
|
|
case 'toggle': |
|
|
|
if (is_null($attributes)) { |
|
|
|
if (is_null($attributes)) { |
|
|
|
$this->_toggleButtonAttributes |
|
|
|
$this->_toggleButtonAttributes |
|
|
|
= array('name' => 'toggle', |
|
|
|
= array( |
|
|
|
|
|
|
|
'name' => 'toggle', |
|
|
|
'value' => ' Toggle Selection ', |
|
|
|
'value' => ' Toggle Selection ', |
|
|
|
'type' => 'button'); |
|
|
|
'type' => 'button' |
|
|
|
|
|
|
|
); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$this->_updateAttrArray($this->_toggleButtonAttributes, |
|
|
|
$this->_updateAttrArray( |
|
|
|
$this->_parseAttributes($attributes)); |
|
|
|
$this->_toggleButtonAttributes, |
|
|
|
|
|
|
|
$this->_parseAttributes($attributes) |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'moveup': |
|
|
|
case 'moveup': |
|
|
|
if (is_null($attributes)) { |
|
|
|
if (is_null($attributes)) { |
|
|
|
$this->_upButtonAttributes |
|
|
|
$this->_upButtonAttributes |
|
|
|
= array('name' => 'up', |
|
|
|
= array( |
|
|
|
|
|
|
|
'name' => 'up', |
|
|
|
'value' => ' Up ', |
|
|
|
'value' => ' Up ', |
|
|
|
'type' => 'button'); |
|
|
|
'type' => 'button' |
|
|
|
|
|
|
|
); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$this->_updateAttrArray($this->_upButtonAttributes, |
|
|
|
$this->_updateAttrArray( |
|
|
|
$this->_parseAttributes($attributes)); |
|
|
|
$this->_upButtonAttributes, |
|
|
|
|
|
|
|
$this->_parseAttributes($attributes) |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'movedown': |
|
|
|
case 'movedown': |
|
|
|
if (is_null($attributes)) { |
|
|
|
if (is_null($attributes)) { |
|
|
|
$this->_downButtonAttributes |
|
|
|
$this->_downButtonAttributes |
|
|
|
= array('name' => 'down', |
|
|
|
= array( |
|
|
|
|
|
|
|
'name' => 'down', |
|
|
|
'value' => ' Down ', |
|
|
|
'value' => ' Down ', |
|
|
|
'type' => 'button'); |
|
|
|
'type' => 'button' |
|
|
|
|
|
|
|
); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$this->_updateAttrArray($this->_downButtonAttributes, |
|
|
|
$this->_updateAttrArray( |
|
|
|
$this->_parseAttributes($attributes)); |
|
|
|
$this->_downButtonAttributes, |
|
|
|
|
|
|
|
$this->_parseAttributes($attributes) |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'movetop': |
|
|
|
case 'movetop': |
|
|
|
if (is_null($attributes)) { |
|
|
|
if (is_null($attributes)) { |
|
|
|
$this->_topButtonAttributes |
|
|
|
$this->_topButtonAttributes |
|
|
|
= array('name' => 'top', |
|
|
|
= array( |
|
|
|
|
|
|
|
'name' => 'top', |
|
|
|
'value' => ' Top ', |
|
|
|
'value' => ' Top ', |
|
|
|
'type' => 'button'); |
|
|
|
'type' => 'button' |
|
|
|
|
|
|
|
); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$this->_updateAttrArray($this->_topButtonAttributes, |
|
|
|
$this->_updateAttrArray( |
|
|
|
$this->_parseAttributes($attributes)); |
|
|
|
$this->_topButtonAttributes, |
|
|
|
|
|
|
|
$this->_parseAttributes($attributes) |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'movebottom': |
|
|
|
case 'movebottom': |
|
|
|
if (is_null($attributes)) { |
|
|
|
if (is_null($attributes)) { |
|
|
|
$this->_bottomButtonAttributes |
|
|
|
$this->_bottomButtonAttributes |
|
|
|
= array('name' => 'bottom', |
|
|
|
= array( |
|
|
|
|
|
|
|
'name' => 'bottom', |
|
|
|
'value' => ' Bottom ', |
|
|
|
'value' => ' Bottom ', |
|
|
|
'type' => 'button'); |
|
|
|
'type' => 'button' |
|
|
|
|
|
|
|
); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$this->_updateAttrArray($this->_bottomButtonAttributes, |
|
|
|
$this->_updateAttrArray( |
|
|
|
$this->_parseAttributes($attributes)); |
|
|
|
$this->_bottomButtonAttributes, |
|
|
|
|
|
|
|
$this->_parseAttributes($attributes) |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
default; |
|
|
|
default; |
|
|
|
return PEAR::throwError('Argument 1 of HTML_QuickForm_advmultiselect::' . |
|
|
|
return PEAR::throwError( |
|
|
|
|
|
|
|
'Argument 1 of HTML_QuickForm_advmultiselect::'. |
|
|
|
'setButtonAttributes has unexpected value', |
|
|
|
'setButtonAttributes has unexpected value', |
|
|
|
HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT, |
|
|
|
HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT, |
|
|
|
array('level' => 'error')); |
|
|
|
array('level' => 'error') |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -524,26 +572,24 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
$oldTemplate = $this->_elementTemplate; |
|
|
|
$oldTemplate = $this->_elementTemplate; |
|
|
|
|
|
|
|
|
|
|
|
if (isset($html) && is_string($html)) { |
|
|
|
if (isset($html) && is_string($html)) { |
|
|
|
$this->_elementTemplate = $html; |
|
|
|
// $this->_elementTemplate = $html; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
/*<!-- BEGIN label_2 --><tr><th>{label_2}</th><!-- END label_2 --> |
|
|
|
|
|
|
|
<!-- BEGIN label_3 --><th> </th><th>{label_3}</th></tr><!-- END label_3 -->*/ |
|
|
|
|
|
|
|
|
|
|
|
$this->_elementTemplate = ' |
|
|
|
$this->_elementTemplate = ' |
|
|
|
{javascript} |
|
|
|
{javascript} |
|
|
|
<table{class}> |
|
|
|
<div class="advmultiselect row"> |
|
|
|
<!-- BEGIN label_2 --><tr><th>{label_2}</th><!-- END label_2 --> |
|
|
|
<div class="span4">{unselected}</div> |
|
|
|
<!-- BEGIN label_3 --><th> </th><th>{label_3}</th></tr><!-- END label_3 --> |
|
|
|
<div class="span1">{add} <br /><br />{remove}</div> |
|
|
|
<tr> |
|
|
|
<div class="span4">{selected}</div> |
|
|
|
<td valign="top">{unselected}</td> |
|
|
|
</div> |
|
|
|
<td align="center">{add}{remove}</td> |
|
|
|
'; |
|
|
|
<td valign="top">{selected}</td> |
|
|
|
|
|
|
|
</tr> |
|
|
|
|
|
|
|
</table> |
|
|
|
|
|
|
|
'; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if ($js == false) { |
|
|
|
if ($js == false) { |
|
|
|
$this->_elementTemplate = str_replace('{javascript}', '', |
|
|
|
$this->_elementTemplate = str_replace('{javascript}', '', $this->_elementTemplate); |
|
|
|
$this->_elementTemplate); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return $oldTemplate; |
|
|
|
//return $oldTemplate; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -571,14 +617,14 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
$css = str_replace('{id}', $id, $this->_elementCSS); |
|
|
|
$css = str_replace('{id}', $id, $this->_elementCSS); |
|
|
|
|
|
|
|
|
|
|
|
if ($raw !== true) { |
|
|
|
if ($raw !== true) { |
|
|
|
$css = '<style type="text/css">' . PHP_EOL |
|
|
|
$css = '<style type="text/css">'.PHP_EOL |
|
|
|
// Modified by Chamilo team, 16-MAR-2010. |
|
|
|
// Modified by Chamilo team, 16-MAR-2010. |
|
|
|
//. '<!--' . $css . '// -->' . PHP_EOL |
|
|
|
//. '<!--' . $css . '// -->' . PHP_EOL |
|
|
|
. '/*<![CDATA[*/' . PHP_EOL |
|
|
|
.'/*<![CDATA[*/'.PHP_EOL |
|
|
|
. $css . PHP_EOL |
|
|
|
.$css.PHP_EOL |
|
|
|
. '/*]]>*/' . PHP_EOL |
|
|
|
.'/*]]>*/'.PHP_EOL |
|
|
|
// |
|
|
|
// |
|
|
|
. '</style>'; |
|
|
|
.'</style>'; |
|
|
|
} |
|
|
|
} |
|
|
|
return $css; |
|
|
|
return $css; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -599,10 +645,11 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
$tabs = $this->_getTabs(); |
|
|
|
$tabs = $this->_getTabs(); |
|
|
|
$tab = $this->_getTab(); |
|
|
|
$tab = $this->_getTab(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$selectId = $this->getName(); |
|
|
|
$selectId = $this->getName(); |
|
|
|
$selectName = $this->getName() . '[]'; |
|
|
|
$selectName = $this->getName().'[]'; |
|
|
|
$selectNameFrom = $this->getName() . '-f[]'; |
|
|
|
$selectNameFrom = $this->getName().'-f[]'; |
|
|
|
$selectNameTo = $this->getName() . '-t[]'; |
|
|
|
$selectNameTo = $this->getName().'-t[]'; |
|
|
|
$selected_count = 0; |
|
|
|
$selected_count = 0; |
|
|
|
|
|
|
|
|
|
|
|
// placeholder {unselected} existence determines if we will render |
|
|
|
// placeholder {unselected} existence determines if we will render |
|
|
|
@ -612,14 +659,13 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
|
|
|
|
|
|
|
|
$id = $this->getAttribute('name'); |
|
|
|
$id = $this->getAttribute('name'); |
|
|
|
|
|
|
|
|
|
|
|
$strHtmlSelected = $tab . '<div id="qfams_'.$id.'">' . PHP_EOL; |
|
|
|
$strHtmlSelected = $tab.'<div id="qfams_'.$id.'">'.PHP_EOL; |
|
|
|
$unselected_count = count($this->_options); |
|
|
|
$unselected_count = count($this->_options); |
|
|
|
|
|
|
|
|
|
|
|
$checkbox_id_suffix = 0; |
|
|
|
$checkbox_id_suffix = 0; |
|
|
|
|
|
|
|
|
|
|
|
foreach ($this->_options as $option) { |
|
|
|
foreach ($this->_options as $option) { |
|
|
|
$_labelAttributes |
|
|
|
$_labelAttributes = array('style', 'class', 'onmouseover', 'onmouseout'); |
|
|
|
= array('style', 'class', 'onmouseover', 'onmouseout'); |
|
|
|
|
|
|
|
$labelAttributes = array(); |
|
|
|
$labelAttributes = array(); |
|
|
|
foreach ($_labelAttributes as $attr) { |
|
|
|
foreach ($_labelAttributes as $attr) { |
|
|
|
if (isset($option['attr'][$attr])) { |
|
|
|
if (isset($option['attr'][$attr])) { |
|
|
|
@ -629,7 +675,8 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (is_array($this->_values) |
|
|
|
if (is_array($this->_values) |
|
|
|
&& in_array((string)$option['attr']['value'], $this->_values)) { |
|
|
|
&& in_array((string)$option['attr']['value'], $this->_values) |
|
|
|
|
|
|
|
) { |
|
|
|
// The items is *selected* |
|
|
|
// The items is *selected* |
|
|
|
$checked = ' checked="checked"'; |
|
|
|
$checked = ' checked="checked"'; |
|
|
|
$selected_count++; |
|
|
|
$selected_count++; |
|
|
|
@ -639,17 +686,17 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
} |
|
|
|
} |
|
|
|
$checkbox_id_suffix++; |
|
|
|
$checkbox_id_suffix++; |
|
|
|
$strHtmlSelected .= $tab |
|
|
|
$strHtmlSelected .= $tab |
|
|
|
. '<label' |
|
|
|
.'<label' |
|
|
|
. $this->_getAttrString($labelAttributes) .'>' |
|
|
|
.$this->_getAttrString($labelAttributes).'>' |
|
|
|
. '<input type="checkbox"' |
|
|
|
.'<input type="checkbox"' |
|
|
|
. ' id="'.$selectId . $checkbox_id_suffix.'"' |
|
|
|
.' id="'.$selectId.$checkbox_id_suffix.'"' |
|
|
|
. ' name="'.$selectName.'"' |
|
|
|
.' name="'.$selectName.'"' |
|
|
|
. $checked |
|
|
|
.$checked |
|
|
|
. $this->_getAttrString($option['attr']) |
|
|
|
.$this->_getAttrString($option['attr']) |
|
|
|
. ' />' . $option['text'] . '</label>' |
|
|
|
.' />'.$option['text'].'</label>' |
|
|
|
. PHP_EOL; |
|
|
|
.PHP_EOL; |
|
|
|
} |
|
|
|
} |
|
|
|
$strHtmlSelected .= $tab . '</div>'. PHP_EOL; |
|
|
|
$strHtmlSelected .= $tab.'</div>'.PHP_EOL; |
|
|
|
|
|
|
|
|
|
|
|
$strHtmlHidden = ''; |
|
|
|
$strHtmlHidden = ''; |
|
|
|
$strHtmlUnselected = ''; |
|
|
|
$strHtmlUnselected = ''; |
|
|
|
@ -657,30 +704,38 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
$strHtmlRemove = ''; |
|
|
|
$strHtmlRemove = ''; |
|
|
|
|
|
|
|
|
|
|
|
// build the select all button with all its attributes |
|
|
|
// build the select all button with all its attributes |
|
|
|
$jsName = $this->_jsPrefix . $this->_jsPostfix; |
|
|
|
$jsName = $this->_jsPrefix.$this->_jsPostfix; |
|
|
|
$attributes = array('onclick' => $jsName . |
|
|
|
$attributes = array( |
|
|
|
"('". $selectId ."', 1);"); |
|
|
|
'onclick' => $jsName. |
|
|
|
|
|
|
|
"('".$selectId."', 1);" |
|
|
|
|
|
|
|
); |
|
|
|
$this->_allButtonAttributes |
|
|
|
$this->_allButtonAttributes |
|
|
|
= array_merge($this->_allButtonAttributes, $attributes); |
|
|
|
= array_merge($this->_allButtonAttributes, $attributes); |
|
|
|
$attrStrAll = $this->_getAttrString($this->_allButtonAttributes); |
|
|
|
$attrStrAll = $this->_getAttrString($this->_allButtonAttributes); |
|
|
|
$strHtmlAll = "<input$attrStrAll />". PHP_EOL; |
|
|
|
$strHtmlAll = "<input$attrStrAll />".PHP_EOL; |
|
|
|
|
|
|
|
|
|
|
|
// build the select none button with all its attributes |
|
|
|
// build the select none button with all its attributes |
|
|
|
$attributes = array('onclick' => $jsName . |
|
|
|
$attributes = array( |
|
|
|
"('". $selectId ."', 0);"); |
|
|
|
'onclick' => $jsName. |
|
|
|
|
|
|
|
"('".$selectId."', 0);" |
|
|
|
|
|
|
|
); |
|
|
|
$this->_noneButtonAttributes |
|
|
|
$this->_noneButtonAttributes |
|
|
|
= array_merge($this->_noneButtonAttributes, $attributes); |
|
|
|
= array_merge($this->_noneButtonAttributes, $attributes); |
|
|
|
$attrStrNone = $this->_getAttrString($this->_noneButtonAttributes); |
|
|
|
$attrStrNone = $this->_getAttrString($this->_noneButtonAttributes); |
|
|
|
$strHtmlNone = "<input$attrStrNone />". PHP_EOL; |
|
|
|
$strHtmlNone = "<input$attrStrNone />".PHP_EOL; |
|
|
|
|
|
|
|
|
|
|
|
// build the toggle selection button with all its attributes |
|
|
|
// build the toggle selection button with all its attributes |
|
|
|
$attributes = array('onclick' => $jsName . |
|
|
|
$attributes = array( |
|
|
|
"('". $selectId ."', 2);"); |
|
|
|
'onclick' => $jsName. |
|
|
|
|
|
|
|
"('".$selectId."', 2);" |
|
|
|
|
|
|
|
); |
|
|
|
$this->_toggleButtonAttributes |
|
|
|
$this->_toggleButtonAttributes |
|
|
|
= array_merge($this->_toggleButtonAttributes, |
|
|
|
= array_merge( |
|
|
|
$attributes); |
|
|
|
$this->_toggleButtonAttributes, |
|
|
|
|
|
|
|
$attributes |
|
|
|
|
|
|
|
); |
|
|
|
$attrStrToggle = $this->_getAttrString($this->_toggleButtonAttributes); |
|
|
|
$attrStrToggle = $this->_getAttrString($this->_toggleButtonAttributes); |
|
|
|
$strHtmlToggle = "<input$attrStrToggle />". PHP_EOL; |
|
|
|
$strHtmlToggle = "<input$attrStrToggle />".PHP_EOL; |
|
|
|
|
|
|
|
|
|
|
|
$strHtmlMoveUp = ''; |
|
|
|
$strHtmlMoveUp = ''; |
|
|
|
$strHtmlMoveDown = ''; |
|
|
|
$strHtmlMoveDown = ''; |
|
|
|
@ -688,45 +743,51 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
$strHtmlMoveBottom = ''; |
|
|
|
$strHtmlMoveBottom = ''; |
|
|
|
|
|
|
|
|
|
|
|
// default selection counters |
|
|
|
// default selection counters |
|
|
|
$strHtmlSelectedCount = $selected_count . '/' . $unselected_count; |
|
|
|
$strHtmlSelectedCount = $selected_count.'/'.$unselected_count; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// ... or a dual multi-select |
|
|
|
// ... or a dual multi-select |
|
|
|
$this->_jsPostfix = 'moveSelection'; |
|
|
|
$this->_jsPostfix = 'moveSelection'; |
|
|
|
$jsName = $this->_jsPrefix . $this->_jsPostfix; |
|
|
|
$jsName = $this->_jsPrefix.$this->_jsPostfix; |
|
|
|
|
|
|
|
|
|
|
|
// set name of Select From Box |
|
|
|
// set name of Select From Box |
|
|
|
$this->_attributesUnselected |
|
|
|
$this->_attributesUnselected |
|
|
|
= array('id' => $selectId . '-f', |
|
|
|
= array( |
|
|
|
|
|
|
|
'id' => $selectId.'-f', |
|
|
|
'name' => $selectNameFrom, |
|
|
|
'name' => $selectNameFrom, |
|
|
|
'ondblclick' => $jsName . |
|
|
|
'ondblclick' => $jsName. |
|
|
|
"('{$selectId}', ". |
|
|
|
"('{$selectId}', ". |
|
|
|
"this.form.elements['" . $selectNameFrom . "'], " . |
|
|
|
"this.form.elements['".$selectNameFrom."'], ". |
|
|
|
"this.form.elements['" . $selectNameTo . "'], " . |
|
|
|
"this.form.elements['".$selectNameTo."'], ". |
|
|
|
"this.form.elements['" . $selectName . "'], " . |
|
|
|
"this.form.elements['".$selectName."'], ". |
|
|
|
"'add', '{$this->_sort}')"); |
|
|
|
"'add', '{$this->_sort}')" |
|
|
|
|
|
|
|
); |
|
|
|
$this->_attributesUnselected |
|
|
|
$this->_attributesUnselected |
|
|
|
= array_merge($this->_attributes, $this->_attributesUnselected); |
|
|
|
= array_merge($this->_attributes, $this->_attributesUnselected); |
|
|
|
$attrUnselected = $this->_getAttrString($this->_attributesUnselected); |
|
|
|
$attrUnselected = $this->_getAttrString($this->_attributesUnselected); |
|
|
|
|
|
|
|
|
|
|
|
// set name of Select To Box |
|
|
|
// set name of Select To Box |
|
|
|
$this->_attributesSelected |
|
|
|
$this->_attributesSelected |
|
|
|
= array('id' => $selectId . '-t', |
|
|
|
= array( |
|
|
|
|
|
|
|
'id' => $selectId.'-t', |
|
|
|
'name' => $selectNameTo, |
|
|
|
'name' => $selectNameTo, |
|
|
|
'ondblclick' => $jsName . |
|
|
|
'ondblclick' => $jsName. |
|
|
|
"('{$selectId}', " . |
|
|
|
"('{$selectId}', ". |
|
|
|
"this.form.elements['" . $selectNameFrom . "'], " . |
|
|
|
"this.form.elements['".$selectNameFrom."'], ". |
|
|
|
"this.form.elements['" . $selectNameTo . "'], ". |
|
|
|
"this.form.elements['".$selectNameTo."'], ". |
|
|
|
"this.form.elements['" . $selectName . "'], " . |
|
|
|
"this.form.elements['".$selectName."'], ". |
|
|
|
"'remove', '{$this->_sort}')"); |
|
|
|
"'remove', '{$this->_sort}')" |
|
|
|
|
|
|
|
); |
|
|
|
$this->_attributesSelected |
|
|
|
$this->_attributesSelected |
|
|
|
= array_merge($this->_attributes, $this->_attributesSelected); |
|
|
|
= array_merge($this->_attributes, $this->_attributesSelected); |
|
|
|
$attrSelected = $this->_getAttrString($this->_attributesSelected); |
|
|
|
$attrSelected = $this->_getAttrString($this->_attributesSelected); |
|
|
|
|
|
|
|
|
|
|
|
// set name of Select hidden Box |
|
|
|
// set name of Select hidden Box |
|
|
|
$this->_attributesHidden |
|
|
|
$this->_attributesHidden |
|
|
|
= array('name' => $selectName, |
|
|
|
= array( |
|
|
|
'style' => 'overflow: hidden; visibility: hidden; ' . |
|
|
|
'name' => $selectName, |
|
|
|
'width: 1px; height: 0;'); |
|
|
|
'style' => 'overflow: hidden; visibility: hidden; '. |
|
|
|
|
|
|
|
'width: 1px; height: 0;' |
|
|
|
|
|
|
|
); |
|
|
|
$this->_attributesHidden |
|
|
|
$this->_attributesHidden |
|
|
|
= array_merge($this->_attributes, $this->_attributesHidden); |
|
|
|
= array_merge($this->_attributes, $this->_attributesHidden); |
|
|
|
$attrHidden = $this->_getAttrString($this->_attributesHidden); |
|
|
|
$attrHidden = $this->_getAttrString($this->_attributesHidden); |
|
|
|
@ -746,11 +807,16 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
|
|
|
|
|
|
|
|
foreach ($this->_options as $option) { |
|
|
|
foreach ($this->_options as $option) { |
|
|
|
if (is_array($this->_values) |
|
|
|
if (is_array($this->_values) |
|
|
|
&& in_array((string)$option['attr']['value'], |
|
|
|
&& in_array( |
|
|
|
$this->_values)) { |
|
|
|
(string)$option['attr']['value'], |
|
|
|
|
|
|
|
$this->_values |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) { |
|
|
|
// Get the post order |
|
|
|
// Get the post order |
|
|
|
$key = array_search($option['attr']['value'], |
|
|
|
$key = array_search( |
|
|
|
$this->_values); |
|
|
|
$option['attr']['value'], |
|
|
|
|
|
|
|
$this->_values |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
/** The items is *selected* so we want to put it |
|
|
|
/** The items is *selected* so we want to put it |
|
|
|
in the 'selected' multi-select */ |
|
|
|
in the 'selected' multi-select */ |
|
|
|
@ -784,13 +850,13 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
= array_merge($this->_attributes, $this->_attributesUnselected); |
|
|
|
= array_merge($this->_attributes, $this->_attributesUnselected); |
|
|
|
$attrUnselected = $this->_getAttrString($this->_attributesUnselected); |
|
|
|
$attrUnselected = $this->_getAttrString($this->_attributesUnselected); |
|
|
|
} |
|
|
|
} |
|
|
|
$strHtmlUnselected = "<select$attrUnselected>". PHP_EOL; |
|
|
|
$strHtmlUnselected = "<select$attrUnselected>".PHP_EOL; |
|
|
|
if ($unselected_count > 0) { |
|
|
|
if ($unselected_count > 0) { |
|
|
|
foreach ($arrHtmlUnselected as $data) { |
|
|
|
foreach ($arrHtmlUnselected as $data) { |
|
|
|
$strHtmlUnselected |
|
|
|
$strHtmlUnselected |
|
|
|
.= $tabs . $tab |
|
|
|
.= $tabs.$tab |
|
|
|
. '<option' . $this->_getAttrString($data['attr']) . '>' |
|
|
|
.'<option'.$this->_getAttrString($data['attr']).'>' |
|
|
|
. $data['text'] . '</option>' . PHP_EOL; |
|
|
|
.$data['text'].'</option>'.PHP_EOL; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$strHtmlUnselected .= '<option value=""> </option>'; |
|
|
|
$strHtmlUnselected .= '<option value=""> </option>'; |
|
|
|
@ -806,13 +872,13 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
= array_merge($this->_attributes, $this->_attributesSelected); |
|
|
|
= array_merge($this->_attributes, $this->_attributesSelected); |
|
|
|
$attrSelected = $this->_getAttrString($this->_attributesSelected); |
|
|
|
$attrSelected = $this->_getAttrString($this->_attributesSelected); |
|
|
|
} |
|
|
|
} |
|
|
|
$strHtmlSelected = "<select$attrSelected>". PHP_EOL; |
|
|
|
$strHtmlSelected = "<select$attrSelected>".PHP_EOL; |
|
|
|
if ($selected_count > 0) { |
|
|
|
if ($selected_count > 0) { |
|
|
|
foreach ($arrHtmlSelected as $data) { |
|
|
|
foreach ($arrHtmlSelected as $data) { |
|
|
|
$strHtmlSelected |
|
|
|
$strHtmlSelected |
|
|
|
.= $tabs . $tab |
|
|
|
.= $tabs.$tab |
|
|
|
. '<option' . $this->_getAttrString($data['attr']) . '>' |
|
|
|
.'<option'.$this->_getAttrString($data['attr']).'>' |
|
|
|
. $data['text'] . '</option>' . PHP_EOL; |
|
|
|
.$data['text'].'</option>'.PHP_EOL; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$strHtmlSelected .= '<option value=""> </option>'; |
|
|
|
$strHtmlSelected .= '<option value=""> </option>'; |
|
|
|
@ -820,133 +886,154 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
$strHtmlSelected .= '</select>'; |
|
|
|
$strHtmlSelected .= '</select>'; |
|
|
|
|
|
|
|
|
|
|
|
// The 'hidden' multi-select |
|
|
|
// The 'hidden' multi-select |
|
|
|
$strHtmlHidden = "<select$attrHidden>". PHP_EOL; |
|
|
|
$strHtmlHidden = "<select$attrHidden>".PHP_EOL; |
|
|
|
if (count($arrHtmlHidden) > 0) { |
|
|
|
if (count($arrHtmlHidden) > 0) { |
|
|
|
foreach ($arrHtmlHidden as $data) { |
|
|
|
foreach ($arrHtmlHidden as $data) { |
|
|
|
$strHtmlHidden |
|
|
|
$strHtmlHidden |
|
|
|
.= $tabs . $tab |
|
|
|
.= $tabs.$tab |
|
|
|
. '<option' . $this->_getAttrString($data['attr']) . '>' |
|
|
|
.'<option'.$this->_getAttrString($data['attr']).'>' |
|
|
|
. $data['text'] . '</option>' . PHP_EOL; |
|
|
|
.$data['text'].'</option>'.PHP_EOL; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
$strHtmlHidden .= '</select>'; |
|
|
|
$strHtmlHidden .= '</select>'; |
|
|
|
|
|
|
|
|
|
|
|
// build the remove button with all its attributes |
|
|
|
// build the remove button with all its attributes |
|
|
|
$attributes |
|
|
|
$attributes = array( |
|
|
|
= array('onclick' => $jsName . |
|
|
|
'class' => 'btn btn-block ', |
|
|
|
"('{$selectId}', " . |
|
|
|
'onclick' => $jsName. |
|
|
|
"this.form.elements['" . $selectNameFrom . "'], " . |
|
|
|
"('{$selectId}', ". |
|
|
|
"this.form.elements['" . $selectNameTo . "'], " . |
|
|
|
"this.form.elements['".$selectNameFrom."'], ". |
|
|
|
"this.form.elements['" . $selectName . "'], " . |
|
|
|
"this.form.elements['".$selectNameTo."'], ". |
|
|
|
"'remove', '{$this->_sort}'); return false;"); |
|
|
|
"this.form.elements['".$selectName."'], ". |
|
|
|
|
|
|
|
"'remove', '{$this->_sort}'); return false;" |
|
|
|
|
|
|
|
); |
|
|
|
$this->_removeButtonAttributes |
|
|
|
$this->_removeButtonAttributes |
|
|
|
= array_merge($this->_removeButtonAttributes, $attributes); |
|
|
|
= array_merge($this->_removeButtonAttributes, $attributes); |
|
|
|
$attrStrRemove = $this->_getAttrString($this->_removeButtonAttributes); |
|
|
|
$attrStrRemove = $this->_getAttrString($this->_removeButtonAttributes); |
|
|
|
$strHtmlRemove = "<input$attrStrRemove />". PHP_EOL; |
|
|
|
//$strHtmlRemove = "<input$attrStrRemove />". PHP_EOL; |
|
|
|
|
|
|
|
$strHtmlRemove = "<button$attrStrRemove /><i class='icon-arrow-left icon-large'></i></button>".PHP_EOL; |
|
|
|
|
|
|
|
|
|
|
|
// build the add button with all its attributes |
|
|
|
// build the add button with all its attributes |
|
|
|
$attributes |
|
|
|
$attributes |
|
|
|
= array('onclick' => $jsName . |
|
|
|
= array( |
|
|
|
"('{$selectId}', " . |
|
|
|
'class' => 'btn btn-block ', |
|
|
|
"this.form.elements['" . $selectNameFrom . "'], " . |
|
|
|
'onclick' => $jsName. |
|
|
|
"this.form.elements['" . $selectNameTo . "'], " . |
|
|
|
"('{$selectId}', ". |
|
|
|
"this.form.elements['" . $selectName . "'], " . |
|
|
|
"this.form.elements['".$selectNameFrom."'], ". |
|
|
|
"'add', '{$this->_sort}'); return false;"); |
|
|
|
"this.form.elements['".$selectNameTo."'], ". |
|
|
|
|
|
|
|
"this.form.elements['".$selectName."'], ". |
|
|
|
|
|
|
|
"'add', '{$this->_sort}'); return false;" |
|
|
|
|
|
|
|
); |
|
|
|
$this->_addButtonAttributes |
|
|
|
$this->_addButtonAttributes |
|
|
|
= array_merge($this->_addButtonAttributes, $attributes); |
|
|
|
= array_merge($this->_addButtonAttributes, $attributes); |
|
|
|
$attrStrAdd = $this->_getAttrString($this->_addButtonAttributes); |
|
|
|
$attrStrAdd = $this->_getAttrString($this->_addButtonAttributes); |
|
|
|
$strHtmlAdd = "<input$attrStrAdd />". PHP_EOL; |
|
|
|
$strHtmlAdd = "<button$attrStrAdd /><i class='icon-arrow-right icon-large'></i></button>".PHP_EOL; |
|
|
|
|
|
|
|
|
|
|
|
// build the select all button with all its attributes |
|
|
|
// build the select all button with all its attributes |
|
|
|
$attributes |
|
|
|
$attributes |
|
|
|
= array('onclick' => $jsName . |
|
|
|
= array( |
|
|
|
"('{$selectId}', " . |
|
|
|
'onclick' => $jsName. |
|
|
|
"this.form.elements['" . $selectNameFrom . "'], " . |
|
|
|
"('{$selectId}', ". |
|
|
|
"this.form.elements['" . $selectNameTo . "'], " . |
|
|
|
"this.form.elements['".$selectNameFrom."'], ". |
|
|
|
"this.form.elements['" . $selectName . "'], " . |
|
|
|
"this.form.elements['".$selectNameTo."'], ". |
|
|
|
"'all', '{$this->_sort}'); return false;"); |
|
|
|
"this.form.elements['".$selectName."'], ". |
|
|
|
|
|
|
|
"'all', '{$this->_sort}'); return false;" |
|
|
|
|
|
|
|
); |
|
|
|
$this->_allButtonAttributes |
|
|
|
$this->_allButtonAttributes |
|
|
|
= array_merge($this->_allButtonAttributes, $attributes); |
|
|
|
= array_merge($this->_allButtonAttributes, $attributes); |
|
|
|
$attrStrAll = $this->_getAttrString($this->_allButtonAttributes); |
|
|
|
$attrStrAll = $this->_getAttrString($this->_allButtonAttributes); |
|
|
|
$strHtmlAll = "<input$attrStrAll />". PHP_EOL; |
|
|
|
$strHtmlAll = "<input$attrStrAll />".PHP_EOL; |
|
|
|
|
|
|
|
|
|
|
|
// build the select none button with all its attributes |
|
|
|
// build the select none button with all its attributes |
|
|
|
$attributes |
|
|
|
$attributes |
|
|
|
= array('onclick' => $jsName . |
|
|
|
= array( |
|
|
|
"('{$selectId}', " . |
|
|
|
'onclick' => $jsName. |
|
|
|
"this.form.elements['" . $selectNameFrom . "'], " . |
|
|
|
"('{$selectId}', ". |
|
|
|
"this.form.elements['" . $selectNameTo . "'], " . |
|
|
|
"this.form.elements['".$selectNameFrom."'], ". |
|
|
|
"this.form.elements['" . $selectName . "'], " . |
|
|
|
"this.form.elements['".$selectNameTo."'], ". |
|
|
|
"'none', '{$this->_sort}'); return false;"); |
|
|
|
"this.form.elements['".$selectName."'], ". |
|
|
|
|
|
|
|
"'none', '{$this->_sort}'); return false;" |
|
|
|
|
|
|
|
); |
|
|
|
$this->_noneButtonAttributes |
|
|
|
$this->_noneButtonAttributes |
|
|
|
= array_merge($this->_noneButtonAttributes, $attributes); |
|
|
|
= array_merge($this->_noneButtonAttributes, $attributes); |
|
|
|
$attrStrNone = $this->_getAttrString($this->_noneButtonAttributes); |
|
|
|
$attrStrNone = $this->_getAttrString($this->_noneButtonAttributes); |
|
|
|
$strHtmlNone = "<input$attrStrNone />". PHP_EOL; |
|
|
|
$strHtmlNone = "<input$attrStrNone />".PHP_EOL; |
|
|
|
|
|
|
|
|
|
|
|
// build the toggle button with all its attributes |
|
|
|
// build the toggle button with all its attributes |
|
|
|
$attributes |
|
|
|
$attributes |
|
|
|
= array('onclick' => $jsName . |
|
|
|
= array( |
|
|
|
"('{$selectId}', " . |
|
|
|
'onclick' => $jsName. |
|
|
|
"this.form.elements['" . $selectNameFrom . "'], " . |
|
|
|
"('{$selectId}', ". |
|
|
|
"this.form.elements['" . $selectNameTo . "'], " . |
|
|
|
"this.form.elements['".$selectNameFrom."'], ". |
|
|
|
"this.form.elements['" . $selectName . "'], " . |
|
|
|
"this.form.elements['".$selectNameTo."'], ". |
|
|
|
"'toggle', '{$this->_sort}'); return false;"); |
|
|
|
"this.form.elements['".$selectName."'], ". |
|
|
|
|
|
|
|
"'toggle', '{$this->_sort}'); return false;" |
|
|
|
|
|
|
|
); |
|
|
|
$this->_toggleButtonAttributes |
|
|
|
$this->_toggleButtonAttributes |
|
|
|
= array_merge($this->_toggleButtonAttributes, $attributes); |
|
|
|
= array_merge($this->_toggleButtonAttributes, $attributes); |
|
|
|
$attrStrToggle = $this->_getAttrString($this->_toggleButtonAttributes); |
|
|
|
$attrStrToggle = $this->_getAttrString($this->_toggleButtonAttributes); |
|
|
|
$strHtmlToggle = "<input$attrStrToggle />". PHP_EOL; |
|
|
|
$strHtmlToggle = "<input$attrStrToggle />".PHP_EOL; |
|
|
|
|
|
|
|
|
|
|
|
// build the move up button with all its attributes |
|
|
|
// build the move up button with all its attributes |
|
|
|
$attributes |
|
|
|
$attributes |
|
|
|
= array('onclick' => "{$this->_jsPrefix}moveUp" . |
|
|
|
= array( |
|
|
|
"(this.form.elements['" . $selectNameTo . "'], " . |
|
|
|
'onclick' => "{$this->_jsPrefix}moveUp". |
|
|
|
"this.form.elements['" . $selectName . "']); " . |
|
|
|
"(this.form.elements['".$selectNameTo."'], ". |
|
|
|
"return false;"); |
|
|
|
"this.form.elements['".$selectName."']); ". |
|
|
|
|
|
|
|
"return false;" |
|
|
|
|
|
|
|
); |
|
|
|
$this->_upButtonAttributes |
|
|
|
$this->_upButtonAttributes |
|
|
|
= array_merge($this->_upButtonAttributes, $attributes); |
|
|
|
= array_merge($this->_upButtonAttributes, $attributes); |
|
|
|
$attrStrUp = $this->_getAttrString($this->_upButtonAttributes); |
|
|
|
$attrStrUp = $this->_getAttrString($this->_upButtonAttributes); |
|
|
|
$strHtmlMoveUp = "<input$attrStrUp />". PHP_EOL; |
|
|
|
$strHtmlMoveUp = "<input$attrStrUp />".PHP_EOL; |
|
|
|
|
|
|
|
|
|
|
|
// build the move down button with all its attributes |
|
|
|
// build the move down button with all its attributes |
|
|
|
$attributes |
|
|
|
$attributes |
|
|
|
= array('onclick' => "{$this->_jsPrefix}moveDown" . |
|
|
|
= array( |
|
|
|
"(this.form.elements['" . $selectNameTo . "'], " . |
|
|
|
'onclick' => "{$this->_jsPrefix}moveDown". |
|
|
|
"this.form.elements['" . $selectName . "']); " . |
|
|
|
"(this.form.elements['".$selectNameTo."'], ". |
|
|
|
"return false;"); |
|
|
|
"this.form.elements['".$selectName."']); ". |
|
|
|
|
|
|
|
"return false;" |
|
|
|
|
|
|
|
); |
|
|
|
$this->_downButtonAttributes |
|
|
|
$this->_downButtonAttributes |
|
|
|
= array_merge($this->_downButtonAttributes, $attributes); |
|
|
|
= array_merge($this->_downButtonAttributes, $attributes); |
|
|
|
$attrStrDown = $this->_getAttrString($this->_downButtonAttributes); |
|
|
|
$attrStrDown = $this->_getAttrString($this->_downButtonAttributes); |
|
|
|
$strHtmlMoveDown = "<input$attrStrDown />". PHP_EOL; |
|
|
|
$strHtmlMoveDown = "<input$attrStrDown />".PHP_EOL; |
|
|
|
|
|
|
|
|
|
|
|
// build the move top button with all its attributes |
|
|
|
// build the move top button with all its attributes |
|
|
|
$attributes |
|
|
|
$attributes |
|
|
|
= array('onclick' => "{$this->_jsPrefix}moveTop" . |
|
|
|
= array( |
|
|
|
"(this.form.elements['" . $selectNameTo . "'], " . |
|
|
|
'onclick' => "{$this->_jsPrefix}moveTop". |
|
|
|
"this.form.elements['" . $selectName . "']); " . |
|
|
|
"(this.form.elements['".$selectNameTo."'], ". |
|
|
|
"return false;"); |
|
|
|
"this.form.elements['".$selectName."']); ". |
|
|
|
|
|
|
|
"return false;" |
|
|
|
|
|
|
|
); |
|
|
|
$this->_topButtonAttributes |
|
|
|
$this->_topButtonAttributes |
|
|
|
= array_merge($this->_topButtonAttributes, $attributes); |
|
|
|
= array_merge($this->_topButtonAttributes, $attributes); |
|
|
|
$attrStrTop = $this->_getAttrString($this->_topButtonAttributes); |
|
|
|
$attrStrTop = $this->_getAttrString($this->_topButtonAttributes); |
|
|
|
$strHtmlMoveTop = "<input$attrStrTop />". PHP_EOL; |
|
|
|
$strHtmlMoveTop = "<input$attrStrTop />".PHP_EOL; |
|
|
|
|
|
|
|
|
|
|
|
// build the move bottom button with all its attributes |
|
|
|
// build the move bottom button with all its attributes |
|
|
|
$attributes |
|
|
|
$attributes |
|
|
|
= array('onclick' => "{$this->_jsPrefix}moveBottom" . |
|
|
|
= array( |
|
|
|
"(this.form.elements['" . $selectNameTo . "'], " . |
|
|
|
'onclick' => "{$this->_jsPrefix}moveBottom". |
|
|
|
"this.form.elements['" . $selectName . "']); " . |
|
|
|
"(this.form.elements['".$selectNameTo."'], ". |
|
|
|
"return false;"); |
|
|
|
"this.form.elements['".$selectName."']); ". |
|
|
|
|
|
|
|
"return false;" |
|
|
|
|
|
|
|
); |
|
|
|
$this->_bottomButtonAttributes |
|
|
|
$this->_bottomButtonAttributes |
|
|
|
= array_merge($this->_bottomButtonAttributes, $attributes); |
|
|
|
= array_merge($this->_bottomButtonAttributes, $attributes); |
|
|
|
$attrStrBottom = $this->_getAttrString($this->_bottomButtonAttributes); |
|
|
|
$attrStrBottom = $this->_getAttrString($this->_bottomButtonAttributes); |
|
|
|
$strHtmlMoveBottom = "<input$attrStrBottom />". PHP_EOL; |
|
|
|
$strHtmlMoveBottom = "<input$attrStrBottom />".PHP_EOL; |
|
|
|
|
|
|
|
|
|
|
|
// default selection counters |
|
|
|
// default selection counters |
|
|
|
$strHtmlSelectedCount = $selected_count; |
|
|
|
$strHtmlSelectedCount = $selected_count; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$strHtmlUnselectedCount = $unselected_count; |
|
|
|
$strHtmlUnselectedCount = $unselected_count; |
|
|
|
|
|
|
|
|
|
|
|
$strHtmlSelectedCountId = $selectId .'_selected'; |
|
|
|
$strHtmlSelectedCountId = $selectId.'_selected'; |
|
|
|
$strHtmlUnselectedCountId = $selectId .'_unselected'; |
|
|
|
$strHtmlUnselectedCountId = $selectId.'_unselected'; |
|
|
|
|
|
|
|
|
|
|
|
// render all part of the multi select component with the template |
|
|
|
// render all part of the multi select component with the template |
|
|
|
$strHtml = $this->_elementTemplate; |
|
|
|
$strHtml = $this->_elementTemplate; |
|
|
|
@ -959,7 +1046,7 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
// render extra labels, if any |
|
|
|
// render extra labels, if any |
|
|
|
if (is_array($labels)) { |
|
|
|
if (is_array($labels)) { |
|
|
|
foreach ($labels as $key => $text) { |
|
|
|
foreach ($labels as $key => $text) { |
|
|
|
$key = is_int($key)? $key + 2: $key; |
|
|
|
$key = is_int($key) ? $key + 2 : $key; |
|
|
|
$strHtml = str_replace("{label_{$key}}", $text, $strHtml); |
|
|
|
$strHtml = str_replace("{label_{$key}}", $text, $strHtml); |
|
|
|
$strHtml = str_replace("<!-- BEGIN label_{$key} -->", '', $strHtml); |
|
|
|
$strHtml = str_replace("<!-- BEGIN label_{$key} -->", '', $strHtml); |
|
|
|
$strHtml = str_replace("<!-- END label_{$key} -->", '', $strHtml); |
|
|
|
$strHtml = str_replace("<!-- END label_{$key} -->", '', $strHtml); |
|
|
|
@ -967,31 +1054,53 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
} |
|
|
|
} |
|
|
|
// clean up useless label tags |
|
|
|
// clean up useless label tags |
|
|
|
if (strpos($strHtml, '{label_')) { |
|
|
|
if (strpos($strHtml, '{label_')) { |
|
|
|
$strHtml = preg_replace('/\s*<!-- BEGIN label_(\S+) -->'. |
|
|
|
$strHtml = preg_replace( |
|
|
|
'.*<!-- END label_\1 -->\s*/i', '', $strHtml); |
|
|
|
'/\s*<!-- BEGIN label_(\S+) -->'. |
|
|
|
|
|
|
|
'.*<!-- END label_\1 -->\s*/i', |
|
|
|
|
|
|
|
'', |
|
|
|
|
|
|
|
$strHtml |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$placeHolders = array( |
|
|
|
$placeHolders = array( |
|
|
|
'{stylesheet}', '{javascript}', |
|
|
|
'{stylesheet}', |
|
|
|
|
|
|
|
'{javascript}', |
|
|
|
'{class}', |
|
|
|
'{class}', |
|
|
|
'{unselected_count_id}', '{selected_count_id}', |
|
|
|
'{unselected_count_id}', |
|
|
|
'{unselected_count}', '{selected_count}', |
|
|
|
'{selected_count_id}', |
|
|
|
'{unselected}', '{selected}', |
|
|
|
'{unselected_count}', |
|
|
|
'{add}', '{remove}', |
|
|
|
'{selected_count}', |
|
|
|
'{all}', '{none}', '{toggle}', |
|
|
|
'{unselected}', |
|
|
|
'{moveup}', '{movedown}', |
|
|
|
'{selected}', |
|
|
|
'{movetop}', '{movebottom}' |
|
|
|
'{add}', |
|
|
|
|
|
|
|
'{remove}', |
|
|
|
|
|
|
|
'{all}', |
|
|
|
|
|
|
|
'{none}', |
|
|
|
|
|
|
|
'{toggle}', |
|
|
|
|
|
|
|
'{moveup}', |
|
|
|
|
|
|
|
'{movedown}', |
|
|
|
|
|
|
|
'{movetop}', |
|
|
|
|
|
|
|
'{movebottom}' |
|
|
|
); |
|
|
|
); |
|
|
|
$htmlElements = array( |
|
|
|
$htmlElements = array( |
|
|
|
$this->getElementCss(false), $this->getElementJs(false), |
|
|
|
$this->getElementCss(false), |
|
|
|
|
|
|
|
$this->getElementJs(false), |
|
|
|
$this->_tableAttributes, |
|
|
|
$this->_tableAttributes, |
|
|
|
$strHtmlUnselectedCountId, $strHtmlSelectedCountId, |
|
|
|
$strHtmlUnselectedCountId, |
|
|
|
$strHtmlUnselectedCount, $strHtmlSelectedCount, |
|
|
|
$strHtmlSelectedCountId, |
|
|
|
$strHtmlUnselected, $strHtmlSelected . $strHtmlHidden, |
|
|
|
$strHtmlUnselectedCount, |
|
|
|
$strHtmlAdd, $strHtmlRemove, |
|
|
|
$strHtmlSelectedCount, |
|
|
|
$strHtmlAll, $strHtmlNone, $strHtmlToggle, |
|
|
|
$strHtmlUnselected, |
|
|
|
$strHtmlMoveUp, $strHtmlMoveDown, |
|
|
|
$strHtmlSelected.$strHtmlHidden, |
|
|
|
$strHtmlMoveTop, $strHtmlMoveBottom |
|
|
|
$strHtmlAdd, |
|
|
|
|
|
|
|
$strHtmlRemove, |
|
|
|
|
|
|
|
$strHtmlAll, |
|
|
|
|
|
|
|
$strHtmlNone, |
|
|
|
|
|
|
|
$strHtmlToggle, |
|
|
|
|
|
|
|
$strHtmlMoveUp, |
|
|
|
|
|
|
|
$strHtmlMoveDown, |
|
|
|
|
|
|
|
$strHtmlMoveTop, |
|
|
|
|
|
|
|
$strHtmlMoveBottom |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
$strHtml = str_replace($placeHolders, $htmlElements, $strHtml); |
|
|
|
$strHtml = str_replace($placeHolders, $htmlElements, $strHtml); |
|
|
|
@ -999,7 +1108,7 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
$comment = $this->getComment(); |
|
|
|
$comment = $this->getComment(); |
|
|
|
|
|
|
|
|
|
|
|
if (!empty($comment)) { |
|
|
|
if (!empty($comment)) { |
|
|
|
$strHtml = $tabs . '<!-- ' . $comment . " //-->" . PHP_EOL . $strHtml; |
|
|
|
$strHtml = $tabs.'<!-- '.$comment." //-->".PHP_EOL.$strHtml; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $strHtml; |
|
|
|
return $strHtml; |
|
|
|
@ -1017,8 +1126,8 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function getElementJs($raw = true, $min = true) |
|
|
|
function getElementJs($raw = true, $min = true) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$js = '@data_dir@' . DIRECTORY_SEPARATOR |
|
|
|
$js = '@data_dir@'.DIRECTORY_SEPARATOR |
|
|
|
. '@package_name@' . DIRECTORY_SEPARATOR; |
|
|
|
.'@package_name@'.DIRECTORY_SEPARATOR; |
|
|
|
|
|
|
|
|
|
|
|
$js = api_get_path(LIBRARY_PATH).'javascript'.DIRECTORY_SEPARATOR.'pear'.DIRECTORY_SEPARATOR; |
|
|
|
$js = api_get_path(LIBRARY_PATH).'javascript'.DIRECTORY_SEPARATOR.'pear'.DIRECTORY_SEPARATOR; |
|
|
|
|
|
|
|
|
|
|
|
@ -1036,11 +1145,11 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
|
|
|
|
|
|
|
|
if ($raw !== true) { |
|
|
|
if ($raw !== true) { |
|
|
|
$js = '<script type="text/javascript">' |
|
|
|
$js = '<script type="text/javascript">' |
|
|
|
. PHP_EOL . '//<![CDATA[' |
|
|
|
.PHP_EOL.'//<![CDATA[' |
|
|
|
. PHP_EOL . $js |
|
|
|
.PHP_EOL.$js |
|
|
|
. PHP_EOL . '//]]>' |
|
|
|
.PHP_EOL.'//]]>' |
|
|
|
. PHP_EOL . '</script>' |
|
|
|
.PHP_EOL.'</script>' |
|
|
|
. PHP_EOL; |
|
|
|
.PHP_EOL; |
|
|
|
} |
|
|
|
} |
|
|
|
return $js; |
|
|
|
return $js; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -1063,9 +1172,13 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
* @throws PEAR_Error |
|
|
|
* @throws PEAR_Error |
|
|
|
* @see loadArray() |
|
|
|
* @see loadArray() |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function load(&$options, |
|
|
|
function load( |
|
|
|
$param1 = null, $param2 = null, $param3 = null, $param4 = null) |
|
|
|
&$options, |
|
|
|
{ |
|
|
|
$param1 = null, |
|
|
|
|
|
|
|
$param2 = null, |
|
|
|
|
|
|
|
$param3 = null, |
|
|
|
|
|
|
|
$param4 = null |
|
|
|
|
|
|
|
) { |
|
|
|
if (is_array($options)) { |
|
|
|
if (is_array($options)) { |
|
|
|
$ret = $this->loadArray($options, $param1); |
|
|
|
$ret = $this->loadArray($options, $param1); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
@ -1092,10 +1205,12 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
function loadArray($arr, $values = null) |
|
|
|
function loadArray($arr, $values = null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!is_array($arr)) { |
|
|
|
if (!is_array($arr)) { |
|
|
|
return PEAR::throwError('Argument 1 of HTML_QuickForm_advmultiselect::' . |
|
|
|
return PEAR::throwError( |
|
|
|
|
|
|
|
'Argument 1 of HTML_QuickForm_advmultiselect::'. |
|
|
|
'loadArray is not a valid array', |
|
|
|
'loadArray is not a valid array', |
|
|
|
HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT, |
|
|
|
HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT, |
|
|
|
array('level' => 'exception')); |
|
|
|
array('level' => 'exception') |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
if (isset($values)) { |
|
|
|
if (isset($values)) { |
|
|
|
$this->setSelected($values); |
|
|
|
$this->setSelected($values); |
|
|
|
@ -1129,19 +1244,23 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
function setPersistantOptions($optionValues, $persistant = true) |
|
|
|
function setPersistantOptions($optionValues, $persistant = true) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!is_bool($persistant)) { |
|
|
|
if (!is_bool($persistant)) { |
|
|
|
return PEAR::throwError('Argument 2 of HTML_QuickForm_advmultiselect::' . |
|
|
|
return PEAR::throwError( |
|
|
|
|
|
|
|
'Argument 2 of HTML_QuickForm_advmultiselect::'. |
|
|
|
'setPersistantOptions is not a boolean', |
|
|
|
'setPersistantOptions is not a boolean', |
|
|
|
HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT, |
|
|
|
HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT, |
|
|
|
array('level' => 'exception')); |
|
|
|
array('level' => 'exception') |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
if (is_string($optionValues)) { |
|
|
|
if (is_string($optionValues)) { |
|
|
|
$optionValues = array($optionValues); |
|
|
|
$optionValues = array($optionValues); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!is_array($optionValues)) { |
|
|
|
if (!is_array($optionValues)) { |
|
|
|
return PEAR::throwError('Argument 1 of HTML_QuickForm_advmultiselect::' . |
|
|
|
return PEAR::throwError( |
|
|
|
|
|
|
|
'Argument 1 of HTML_QuickForm_advmultiselect::'. |
|
|
|
'setPersistantOptions is not a valid array', |
|
|
|
'setPersistantOptions is not a valid array', |
|
|
|
HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT, |
|
|
|
HTML_QUICKFORM_ADVMULTISELECT_ERROR_INVALID_INPUT, |
|
|
|
array('level' => 'exception')); |
|
|
|
array('level' => 'exception') |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
foreach ($this->_options as $k => $v) { |
|
|
|
foreach ($this->_options as $k => $v) { |
|
|
|
@ -1182,5 +1301,9 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select |
|
|
|
|
|
|
|
|
|
|
|
// @todo this fires an PHP notice, needed in order to parse the advmultiselect test it in main/group/group_edit.php |
|
|
|
// @todo this fires an PHP notice, needed in order to parse the advmultiselect test it in main/group/group_edit.php |
|
|
|
if (class_exists('HTML_QuickForm')) { |
|
|
|
if (class_exists('HTML_QuickForm')) { |
|
|
|
@HTML_QuickForm::registerElementType('advmultiselect','HTML/QuickForm/advmultiselect.php', 'HTML_QuickForm_advmultiselect'); |
|
|
|
@HTML_QuickForm::registerElementType( |
|
|
|
|
|
|
|
'advmultiselect', |
|
|
|
|
|
|
|
'HTML/QuickForm/advmultiselect.php', |
|
|
|
|
|
|
|
'HTML_QuickForm_advmultiselect' |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|