Ignore:
Timestamp:
07/15/10 17:30:07 (14 years ago)
Author:
viani
Message:

Ticket #950 - Merged 2838:3056 /trunk/workflow em /sandbox/workflow/trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/workflow/trunk/inc/smarty/plugins/function.html_options.php

    r795 r3060  
    9696} 
    9797 
     98function smarty_function_html_boxoptions($params, &$smarty) 
     99{ 
     100    require_once $smarty->_get_plugin_filepath('shared','escape_special_chars'); 
     101     
     102    $name = null; 
     103    $values = null; 
     104    $options = null; 
     105    $selected = array(); 
     106    $output = null; 
     107     
     108    $extra = ''; 
     109     
     110    foreach($params as $_key => $_val) { 
     111        switch($_key) { 
     112            case 'name': 
     113                $$_key = (string)$_val; 
     114                break; 
     115             
     116            case 'options': 
     117                $$_key = (array)$_val; 
     118                break; 
     119                 
     120            case 'values': 
     121            case 'output': 
     122                $$_key = array_values((array)$_val); 
     123                break; 
     124 
     125            case 'selected': 
     126                $$_key = array_map('strval', array_values((array)$_val)); 
     127                break; 
     128 
     129            default: 
     130                if(!is_array($_val)) { 
     131                    $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; 
     132                } else { 
     133                    $smarty->trigger_error("html_options: extra attribute '$_key' cannot be an array", E_USER_NOTICE); 
     134                } 
     135                break; 
     136        } 
     137    } 
     138 
     139    if (!isset($options) && !isset($values)) 
     140        return ''; /* raise error here? */ 
     141 
     142    $_html_result = ''; 
     143 
     144    if (isset($options)) { 
     145 
     146        foreach ($options as $_key=>$_val) 
     147            $_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected); 
     148 
     149    } else { 
     150 
     151        foreach ($values as $_i=>$_key) { 
     152            $_val = isset($output[$_i]) ? $output[$_i] : ''; 
     153            $_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected); 
     154        } 
     155 
     156    } 
     157 
     158    if(!empty($name)) { 
     159        $_html_result = '<select name="' . $name . '"' . $extra . ' style="height: 100px;" size="5">' . "\n" . $_html_result . '</select>' . "\n"; 
     160    } 
     161 
     162    return $_html_result; 
     163 
     164} 
    98165function smarty_function_html_options_optoutput($key, $value, $selected) { 
    99166    if(!is_array($value)) { 
Note: See TracChangeset for help on using the changeset viewer.