*
*
*
*
*Your setup may vary...
*/
class HTML_QuickForm_Sorter extends HTML_QuickForm_input
{
var $_html = '';
/**
* Class constructor
*
* @param string $elementName (optional)Input field name attribute
* @param string $elementLabel (optional)Input field label
* @param mixed $attributes (optional) array
* @return void
*/
function HTML_QuickForm_Sorter($elementName=null, $elementLabel=null, $attributes=null)
{
HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes);
$this->_persistantFreeze = true;
}
function getJsIncludes($dir = '')
{
if(empty($dir))
$dir = BLUECMS_WEBROOT . 'bluecms/jsapps/scriptaculous/';
$js='
';
return($js);
}
function toHTML()
{
return($this->_html);
}
/**
*Function called by quickform.
*$values is array of form (key1=>value1, key2=>value2...) where keyX is integer and array reflects current order
*/
function setValue($values)
{
if(is_array($values))
{
if(! defined('HTML_QUICKFORM_SORTER_JS'))
{
define('HTML_QUICKFORM_SORTER_JS', true);
$js =<<
function getOrder(id)
{
var ul = document.getElementById('sorter_' + id);
var order = '';
var ar;
for(var i=0;i0)
order = order + "," + ar[ar.length-1];
else
order = ar[ar.length-1];
}
document.forms[0].elements[id].value = order;
}
JS;
$this->_html .= $js;
}
$html = &$this->_html;
$name = $this->_attributes['name'];
$this->_html .= '';
$this->_html .= '\n";
$this->_html .= '';
}
}
}
?>