Overview

Packages

  • Archive
    • Zip
  • class
    • mail
  • kernel
    • block
    • comment
    • config
    • core
    • database
    • form
    • member
    • notification
    • util
  • Legacy
  • None
  • PHP
  • PHPMailer
  • ShadePlus
  • ShadeSoap
  • Smarty
    • plugins
  • XCube
  • XOOPS
  • XOOPS2

Functions

  • _smarty_regex_replace_check
  • smarty_block_textformat
  • smarty_compiler_assign
  • smarty_core_assemble_plugin_filepath
  • smarty_core_assign_smarty_interface
  • smarty_core_create_dir_structure
  • smarty_core_display_debug_console
  • smarty_core_get_include_path
  • smarty_core_get_microtime
  • smarty_core_get_php_resource
  • smarty_core_is_secure
  • smarty_core_is_trusted
  • smarty_core_load_plugins
  • smarty_core_load_resource_plugin
  • smarty_core_process_cached_inserts
  • smarty_core_process_compiled_include
  • smarty_core_read_cache_file
  • smarty_core_rm_auto
  • smarty_core_rmdir
  • smarty_core_run_insert_handler
  • smarty_core_smarty_include_php
  • smarty_core_write_cache_file
  • smarty_core_write_compiled_include
  • smarty_core_write_compiled_resource
  • smarty_core_write_file
  • smarty_function_assign_debug_info
  • smarty_function_config_load
  • smarty_function_counter
  • smarty_function_cycle
  • smarty_function_debug
  • smarty_function_escape_special_chars
  • smarty_function_eval
  • smarty_function_fetch
  • smarty_function_html_checkboxes
  • smarty_function_html_checkboxes_output
  • smarty_function_html_image
  • smarty_function_html_options
  • smarty_function_html_options_optgroup
  • smarty_function_html_options_optoutput
  • smarty_function_html_radios
  • smarty_function_html_radios_output
  • smarty_function_html_select_date
  • smarty_function_html_select_time
  • smarty_function_html_table
  • smarty_function_html_table_cycle
  • smarty_function_mailto
  • smarty_function_math
  • smarty_function_popup
  • smarty_function_popup_init
  • smarty_make_timestamp
  • smarty_modifier_capitalize
  • smarty_modifier_capitalize_ucfirst
  • smarty_modifier_cat
  • smarty_modifier_count_characters
  • smarty_modifier_count_paragraphs
  • smarty_modifier_count_sentences
  • smarty_modifier_count_words
  • smarty_modifier_date_format
  • smarty_modifier_debug_print_var
  • smarty_modifier_default
  • smarty_modifier_escape
  • smarty_modifier_indent
  • smarty_modifier_lower
  • smarty_modifier_nl2br
  • smarty_modifier_regex_replace
  • smarty_modifier_replace
  • smarty_modifier_spacify
  • smarty_modifier_string_format
  • smarty_modifier_strip
  • smarty_modifier_strip_tags
  • smarty_modifier_truncate
  • smarty_modifier_upper
  • smarty_modifier_wordwrap
  • smarty_modifier_xoops_debug_print_var
  • smarty_outputfilter_trimwhitespace
  • smarty_outputfilter_trimwhitespace_replace
  • Overview
  • Package
  • Function
  • Tree
  1: <?php
  2: /**
  3:  * Smarty plugin
  4:  * @package Smarty
  5:  * @subpackage plugins
  6:  */
  7: 
  8: 
  9: /**
 10:  * Smarty {html_radios} function plugin
 11:  *
 12:  * File:       function.html_radios.php<br>
 13:  * Type:       function<br>
 14:  * Name:       html_radios<br>
 15:  * Date:       24.Feb.2003<br>
 16:  * Purpose:    Prints out a list of radio input types<br>
 17:  * Input:<br>
 18:  *           - name       (optional) - string default "radio"
 19:  *           - values     (required) - array
 20:  *           - options    (optional) - associative array
 21:  *           - checked    (optional) - array default not set
 22:  *           - separator  (optional) - ie <br> or &nbsp;
 23:  *           - output     (optional) - the output next to each radio button
 24:  *           - assign     (optional) - assign the output as an array to this variable
 25:  * Examples:
 26:  * <pre>
 27:  * {html_radios values=$ids output=$names}
 28:  * {html_radios values=$ids name='box' separator='<br>' output=$names}
 29:  * {html_radios values=$ids checked=$checked separator='<br>' output=$names}
 30:  * </pre>
 31:  * @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios}
 32:  *      (Smarty online manual)
 33:  * @author     Christopher Kvarme <christopher.kvarme@flashjab.com>
 34:  * @author credits to Monte Ohrt <monte at ohrt dot com>
 35:  * @version    1.0
 36:  * @param array
 37:  * @param Smarty
 38:  * @return string
 39:  * @uses smarty_function_escape_special_chars()
 40:  */
 41: function smarty_function_html_radios($params, &$smarty)
 42: {
 43:     require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
 44:    
 45:     $name = 'radio';
 46:     $values = null;
 47:     $options = null;
 48:     $selected = null;
 49:     $separator = '';
 50:     $labels = true;
 51:     $label_ids = false;
 52:     $output = null;
 53:     $extra = '';
 54: 
 55:     foreach($params as $_key => $_val) {
 56:         switch($_key) {
 57:             case 'name':
 58:             case 'separator':
 59:                 $$_key = (string)$_val;
 60:                 break;
 61: 
 62:             case 'checked':
 63:             case 'selected':
 64:                 if(is_array($_val)) {
 65:                     $smarty->trigger_error('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING);
 66:                 } else {
 67:                     $selected = (string)$_val;
 68:                 }
 69:                 break;
 70: 
 71:             case 'labels':
 72:             case 'label_ids':
 73:                 $$_key = (bool)$_val;
 74:                 break;
 75: 
 76:             case 'options':
 77:                 $$_key = (array)$_val;
 78:                 break;
 79: 
 80:             case 'values':
 81:             case 'output':
 82:                 $$_key = array_values((array)$_val);
 83:                 break;
 84: 
 85:             case 'radios':
 86:                 $smarty->trigger_error('html_radios: the use of the "radios" attribute is deprecated, use "options" instead', E_USER_WARNING);
 87:                 $options = (array)$_val;
 88:                 break;
 89: 
 90:             case 'assign':
 91:                 break;
 92: 
 93:             default:
 94:                 if(!is_array($_val)) {
 95:                     $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
 96:                 } else {
 97:                     $smarty->trigger_error("html_radios: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
 98:                 }
 99:                 break;
100:         }
101:     }
102: 
103:     if (!isset($options) && !isset($values))
104:         return ''; /* raise error here? */
105: 
106:     $_html_result = array();
107: 
108:     if (isset($options)) {
109: 
110:         foreach ($options as $_key=>$_val)
111:             $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids);
112: 
113:     } else {
114: 
115:         foreach ($values as $_i=>$_key) {
116:             $_val = isset($output[$_i]) ? $output[$_i] : '';
117:             $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids);
118:         }
119: 
120:     }
121: 
122:     if(!empty($params['assign'])) {
123:         $smarty->assign($params['assign'], $_html_result);
124:     } else {
125:         return implode("\n",$_html_result);
126:     }
127: 
128: }
129: 
130: function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids) {
131:     $_output = '';
132:     if ($labels) {
133:       if($label_ids) {
134:           $_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!', '_', $name . '_' . $value));
135:           $_output .= '<label for="' . $_id . '">';
136:       } else {
137:           $_output .= '<label>';           
138:       }
139:    }
140:    $_output .= '<input type="radio" name="'
141:         . smarty_function_escape_special_chars($name) . '" value="'
142:         . smarty_function_escape_special_chars($value) . '"';
143: 
144:    if ($labels && $label_ids) $_output .= ' id="' . $_id . '"';
145: 
146:     if ((string)$value==$selected) {
147:         $_output .= ' checked="checked"';
148:     }
149:     $_output .= $extra . ' />' . $output;
150:     if ($labels) $_output .= '</label>';
151:     $_output .=  $separator;
152: 
153:     return $_output;
154: }
155: 
156: ?>
157: 
XOOPS Cube Legacy :: API documentation generated by ApiGen 2.7.0