Source for file block.eaSelect.php
Documentation is available at block.eaSelect.php
* smarty block plugin to produce select 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: block.eaSelect.php 78 2007-06-06 21:25:28Z m2mtech $
* @link http://www.ea-geier.at/
* Smarty {eaSelect} plugin
* creates <select></select> tags from {eaSelect} constructs
* - {eaSelect name=NAME} -> <select id="NAME" name="NAME" >...</select>
* - existing {$error['NAME']} -> <select ... class="error">...
* - existing {#helpNAME#} -> <select ... title="{#helpNAME#}"> ...
* - existing {#labelNAME#} -> <label for="NAME">{#labelNAME#}</label>...
* @param array function parameters
* - name function name mandatory
* @param string block content
require_once $smarty->_get_plugin_filepath('shared', 'escape_special_chars');
// ensure name parameter is available
if (!isset ($params['name'])) {
$smarty->trigger_error("eaSelect: '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>';
$vars = array('name', 'id');
foreach ($vars as $var) $return .= $var . '="' . $name . '" ';
if ($title = $smarty->get_config_vars('help' . $nameL))
$return .= 'title="' . $title . '" ';
$error = $smarty->get_template_vars('error');
if ($error[$name]) $return .= 'class="error" ';
$vars = array('onchange');
foreach ($vars as $var) if (isset ($params[$var]))
$return .= $var . '="' . smarty_function_escape_special_chars($params[$var]) . '"';
$return .= '>' . $content . '</select>';
|