_get_plugin_filepath('function','html_options'); // This function build a "normal" select or an "option group" select function option_multiple_build($name, $array, $onChange, $extraParams, &$smarty) { if (!is_array($array)) { return false; } $values = array_values($array); // If $array is a matrix, build an option group selectbox if (is_array($values[0])) { $result = "'; } // If $array is NOT a matrix, build a normal selectbox else { // Insert a blank option with value=-1 $array = array(-1 => "") + $array; $result = smarty_function_html_options(array_merge(array( 'name' => $name, 'id' => $name, 'onchange' => "enableButton('" . $name . "');$onChange", 'options' => $array), $extraParams), $smarty); } return $result; } $requiredParams = array( 'nameTop', 'nameBottom' ); $defaultValues = array( 'size' => 8, 'style' => "width:400px", 'sortEnableBottom' => true, 'diffEnable' => true); $extractParams = array( 'nameTop', 'nameBottom', 'arrayTop', 'arrayBottom', 'onChangeTop', 'onChangeBottom', 'size', 'diffEnable', 'sortEnableBottom', 'style'); /* verifica se todos os parâmetros obrigatórios foram passados */ foreach ($requiredParams as $required) if (!array_key_exists($required, $params) || (empty($params[$required]))) $smarty->trigger_error("[wf_select_option_multiple] missing required parameter(s): $required", E_USER_ERROR); /* atribui valores default para os parâmetros não passados */ foreach ($defaultValues as $key => $value) if (!isset($params[$key])) $params[$key] = $value; /* extrai alguns parâmetros da matriz de parâmetros */ foreach ($extractParams as $extract) $$extract = $params[$extract]; /* parâmetros extras são "acumulados" em uma única variável */ $extraParams = array(); foreach ($params as $key => $value_params) if (!in_array($key, $extractParams)) $extraParams[$key] = $value_params; $output = << EOF; $output .= option_multiple_build($nameTop, $arrayTop, $onChangeTop, $extraParams, $smarty); $output .= << -->    EOF; $output .= << EOF; $nameBottomLabel = ucwords( str_replace("_", " ", $nameBottom) ); $output .= $nameBottomLabel; $output .= << EOF; $output .= smarty_function_html_options(array_merge(array( 'multiple' => 'true', 'name' => $nameBottom . "[]", 'id' => $nameBottom, 'size' => $size, 'style' => $style, 'onChange' => "enableButton('" . $nameBottom . "');$onChangeBottom", 'options' => $arrayBottom), $extraParams), $smarty); $output .= << EOF; if($diffEnable) { $output .= <<selectDiffMultiple('$nameBottom','$nameTop'); EOF; } return $output; } ?>