Source for file function.eaCheckBox.php
Documentation is available at function.eaCheckBox.php
* smarty function plugin to produce checkbox tags
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* @subpackage code/base/smarty
* @author m2mtech <tech@m2m.at>
* @copyright 2007 m2m server software gmbh
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License Version 2
* @version $Id: function.eaCheckBox.php 99 2007-07-29 14:10:07Z m2mtech $
* @link http://www.ea-geier.at/
* Smarty {eaCheckBox} plugin
* creates <input type="checkbox" /> fields from {eaCheckBox} constructs
* extends html_checkboxes
* - existing {$data['NAME']} -> used for selection
* - existing {$error['NAME']} -> <... class="error" />
* - existing {#helpNAME#} -> <... title="{#helpNAME#}" />
* - existing {#labelNAME#} -> <label for="NAME">{#labelNAME#}</label>...
* - values are created from $opt['NAME'] & config files
* @param array function parameters
* - name function name mandatory
require_once $smarty->_get_plugin_filepath('shared', 'escape_special_chars');
// load checkboxes function
require_once $smarty->_get_plugin_filepath('function', 'html_checkboxes');
// ensure name parameter is available
if (!isset ($params['name'])) {
$smarty->trigger_error("eaCheckBox: 'name' missing", E_USER_NOTICE);
$name = smarty_function_escape_special_chars($params['name']);
if ($label = $smarty->get_config_vars('label' . $nameL))
$return .= '<label for="' . $name . '">' . $label . '</label>';
$opt = $smarty->get_template_vars('opt');
if (isset ($opt[$name])) foreach ($opt[$name] as $key => $val) {
$params['values'][$key] = $key;
if ($vName = $smarty->get_config_vars('opt' . $nameL . $key))
$params['output'][$key] = $vName;
$data = $smarty->get_template_vars('data');
if (isset ($data[$name])) $params['selected'] = $data[$name];
if ($title = $smarty->get_config_vars('help' . $nameL))
$params['title'] = $title;
$error = $smarty->get_template_vars('error');
if ($error[$name]) $params['class'] = 'error';
return $return . smarty_function_html_checkboxes($params, $smarty);
|