Source for file function.eaInput.php
Documentation is available at function.eaInput.php
* smarty function plugin to produce input 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.eaInput.php 109 2007-08-04 22:30:24Z m2mtech $
* @link http://www.ea-geier.at/
* Smarty {eaInput} plugin
* creates <input /> fields from {eaInput} constructs
* - {eaInput name=NAME} -> <input id="NAME" name="NAME" type="text" />
* - {eaInput ... type="TYPE"} -> <input ... type="TYPE" />
* - existing {$data['NAME']} -> <input ... value="{$data['NAME']}" />
* - existing {$error['NAME']} -> <input ... class="error" />
* - existing {#helpNAME#} -> <input ... title="{#helpNAME#}" />
* - existing {#labelNAME#} -> <label for="NAME">{#labelNAME#}</label>...
* - {eaInput ... align="right"} -> <input ... style="text-align: right;" />
* - {eaInput ... onechange="something"} -> <input ... onchange="something" />
* @param array function parameters
* - name function name mandatory
* - type input type (text|password|...) default: text
require_once $smarty->_get_plugin_filepath('shared', 'escape_special_chars');
// ensure name parameter is available
if (!isset ($params['name'])) {
$smarty->trigger_error("eaInput: '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>';
$return .= '<input type="';
if (!isset ($params['type'])) $params['type'] = 'text';
switch ($params['type']) {
case 'text': case 'password':
case 'checkbox': case 'radio':
$return .= $params['type'] . '" ';
$return = substr($return, 0, - 13) . '<textarea ';
$vars = array('name', 'id');
foreach ($vars as $var) $return .= $var . '="' . $name . '" ';
$data = $smarty->get_template_vars('data');
&& (($params['type'] != 'password') && ($params['type'] != 'textarea')))
$return .= 'value="' . smarty_function_escape_special_chars($data[$name]) . '" ';
if ($title = $smarty->get_config_vars('help' . $nameL))
$return .= 'title="' . $title . '" ';
$error = $smarty->get_template_vars('error');
if ($error[$name]) $return .= 'class="error" ';
if (isset ($params['align']) && ($params['align']))
$return .= 'style="text-align: ' . smarty_function_escape_special_chars($params['align']) . '" ';
if (isset ($params['onchange']) && ($params['onchange']))
$return .= 'onchange="' . smarty_function_escape_special_chars($params['onchange']) . '" ';
if ($params['type'] == 'textarea') {
$return .= smarty_function_escape_special_chars($data[$name]);
$return .= '</textarea>';
|