Minahito
minah****@users*****
2006年 7月 1日 (土) 13:20:24 JST
Index: xoops2jp/html/class/smarty/plugins/function.xoops_dhtmltarea.php diff -u xoops2jp/html/class/smarty/plugins/function.xoops_dhtmltarea.php:1.1.2.2 xoops2jp/html/class/smarty/plugins/function.xoops_dhtmltarea.php:1.1.2.3 --- xoops2jp/html/class/smarty/plugins/function.xoops_dhtmltarea.php:1.1.2.2 Fri Nov 25 00:28:43 2005 +++ xoops2jp/html/class/smarty/plugins/function.xoops_dhtmltarea.php Sat Jul 1 13:20:24 2006 @@ -1,4 +1,17 @@ <?php +/** + * [ToDo] + * 1) We may have to move this file to other module with following namespace or + * package. + * 2) Some users and developers want free elements at $params. For example, + * $params['script']... This function have not impletented that yet. At + * implementing, we will have to define the rule about sanitizing. + * 3) Users can't set class element to this function, because XoopsForm is + * used. For format xoops_xxxx functions, we may change XoopsForm class + * group. + * + * @version $Id: function.xoops_dhtmltarea.php,v 1.1.2.3 2006/07/01 04:20:24 minahito Exp $ + */ /* * Smarty plugin @@ -9,27 +22,47 @@ * Date: Jun 6, 2004 * Author: minahito * Purpose: cycle through given values - * Input: name = name of form 'name' - * values = preset value - * cols = default 50 - * rows = default 5 + * Input: name = form 'name'. + * value = preset value. Set raw value without htmlspecialchars(). + * id = form 'id'. If it's empty, ID is defined automatically by prefix & name. + * cols = amount of cols. (default 50) + * rows = amount of rows. (default 5) * * Examples: {xoopsdhtmltarea name=message cols=40 rows=6 value=$message} * ------------------------------------------------------------- */ + +define ("XOOPS_DHTMLTAREA_DEFID_PREFIX", "legacy_xoopsform_"); +define ("XOOPS_DHTMLTAREA_DEFAULT_COLS", "50"); +define ("XOOPS_DHTMLTAREA_DEFAULT_ROWS", "5"); + function smarty_function_xoops_dhtmltarea($params, &$smarty) { if (!class_exists('xoopsformelement')) { - require_once XOOPS_ROOT_PATH."/class/xoopsformloader.php"; + require_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; } - $form=null; + $form = null; - if(isset($params['name'])) { + if (isset($params['name'])) { + // + // Fetch major elements from $params. + // $name = trim($params['name']); - $rows = isset($params['rows']) ? intval($params['rows']) : 5; - $cols = isset($params['cols']) ? intval($params['cols']) : 50; - $value = isset($params['value']) ? trim($params['value']) : ""; - $form= new XoopsFormDhtmlTextArea($name,$name,htmlspecialchars($value),$rows,$cols); + $class = isset($params['class']) ? trim($params['class']) : null; + $cols = isset($params['cols']) ? intval($params['cols']) : XOOPS_TEXTAREA_DEFAULT_COLS; + $rows = isset($params['rows']) ? intval($params['rows']) : XOOPS_DHTMLTAREA_DEFAULT_ROWS; + $value = isset($params['value']) ? trim($params['value']) : null; + $id = isset($params['id']) ? trim($params['id']) : XOOPS_DHTMLTAREA_DEFID_PREFIX . $name; + + // + // Build the object for output. + // + $form =& new XoopsFormDhtmlTextArea($name, $name, htmlspecialchars($value), $rows, $cols); + $form->setId($id); + if ($class != null) { + $form->setClass($class); + } + print $form->render(); } } Index: xoops2jp/html/class/smarty/plugins/function.xoops_textarea.php diff -u xoops2jp/html/class/smarty/plugins/function.xoops_textarea.php:1.1.2.3 xoops2jp/html/class/smarty/plugins/function.xoops_textarea.php:1.1.2.4 --- xoops2jp/html/class/smarty/plugins/function.xoops_textarea.php:1.1.2.3 Fri Nov 25 00:28:21 2005 +++ xoops2jp/html/class/smarty/plugins/function.xoops_textarea.php Sat Jul 1 13:20:24 2006 @@ -1,4 +1,14 @@ <?php +/** + * [ToDo] + * 1) We may have to move this file to other module with following namespace or + * package. + * 2) Some users and developers want free elements at $params. For example, + * $params['script']... This function have not impletented that yet. At + * implementing, we will have to define the rule about sanitizing. + * + * @version $Id: function.xoops_textarea.php,v 1.1.2.4 2006/07/01 04:20:24 minahito Exp $ + */ /* * Smarty plugin @@ -9,41 +19,56 @@ * Date: Nov 2, 2005 * Author: minahito * Purpose: textarea tag with sanitize. - * Input: name = name of form 'name' - * value = preset value - * class = - * cols = - * rows = + * Input: name = form 'name'. + * value = preset value. Set raw value without htmlspecialchars(). + * class = form 'class'. + * id = form 'id'. If it's empty, ID is defined automatically by prefix & name. + * cols = amount of cols. (default 50) + * rows = amount of rows. (default 5) + * readonly = if it's true, textarea becomes readonly. * * Examples: {xoopsdhtmltarea name=message cols=40 rows=6 value=$message} * ------------------------------------------------------------- */ + +define ("XOOPS_TEXTAREA_DEFID_PREFIX", "legacy_xoopsform_"); +define ("XOOPS_TEXTAREA_DEFAULT_COLS", "50"); +define ("XOOPS_TEXTAREA_DEFAULT_ROWS", "5"); + function smarty_function_xoops_textarea($params, &$smarty) { - if(isset($params['name'])) { + if (isset($params['name'])) { + // + // Fetch major elements from $params. + // $name = trim($params['name']); $class = isset($params['class']) ? trim($params['class']) : null; - $cols = isset($params['cols']) ? intval($params['cols']) : null; - $rows = isset($params['rows']) ? intval($params['rows']) : null; - $value = isset($params['value']) ? htmlspecialchars($params['value'],ENT_QUOTES) : null; - $id = isset($params['id']) ? trim($params['id']) : null; + $cols = isset($params['cols']) ? intval($params['cols']) : XOOPS_TEXTAREA_DEFAULT_COLS; + $rows = isset($params['rows']) ? intval($params['rows']) : XOOPS_TEXTAREA_DEFAULT_ROWS; + $value = isset($params['value']) ? htmlspecialchars($params['value'], ENT_QUOTES) : null; + $id = isset($params['id']) ? trim($params['id']) : XOOPS_TEXTAREA_DEFID_PREFIX . $name; $readonly = isset($params['readonly']) ? trim($params['readonly']) : null; - $string="<textarea name=\"$name\""; - if($class) - $string.=" class=\"$class\""; - if($cols) - $string.=" cols=\"$cols\""; - if($rows) - $string.=" rows=\"$rows\""; - if($id) - $string.=" id=\"$id\""; - if($readonly==1) { - $string.=" readonly=\"readonly\""; + // + // Build string. + // + $string = "<textarea name=\"${name}\" cols=\"${cols}\" rows=\"${rows}\""; + + if ($class) { + $string .= " class=\"${class}\""; + } + + $string .= " id=\"$id\""; + + if($readonly == 1) { + $string .= " readonly=\"readonly\""; } - $string.=" />".$value."</textarea>"; + $string .= " />" . $value . "</textarea>"; + // + // Output. + // print $string; } } Index: xoops2jp/html/class/smarty/plugins/function.xoops_input.php diff -u xoops2jp/html/class/smarty/plugins/function.xoops_input.php:1.1.2.7 xoops2jp/html/class/smarty/plugins/function.xoops_input.php:1.1.2.8 --- xoops2jp/html/class/smarty/plugins/function.xoops_input.php:1.1.2.7 Wed Mar 29 18:43:47 2006 +++ xoops2jp/html/class/smarty/plugins/function.xoops_input.php Sat Jul 1 13:20:24 2006 @@ -1,4 +1,15 @@ <?php +/** + * [ToDo] + * 1) We may have to move this file to other module with following namespace or + * package. + * 2) This function accepts all of <input> pattern. We may have to divide it. + * 3) Some users and developers want free elements at $params. For example, + * $params['script']... This function have not impletented that yet. At + * implementing, we will have to define the rule about sanitizing. + * + * @version $Id: function.xoops_input.php,v 1.1.2.8 2006/07/01 04:20:24 minahito Exp $ + */ /* * Smarty plugin @@ -13,55 +24,73 @@ * key = key of the name. If this parameter is array, set it. * type = "text" or other * value = preset value - * class = html class - * size = - * maxlength = - * default ~ + * class = form 'class'. + * id = form 'id'. If it's empty, ID is defined automatically by prefix & name. + * size = size element. + * maxlength = maxlength element. + * default = If it equals 'value', add "checked" element in the case of "select" or "radio". + * disabled = disabled element. * * Examples: {xoops_input name=text value=$message} * {xoops_input name=checkbox value=1 default=$value } * ------------------------------------------------------------- */ + +define ("XOOPS_INPUT_DEFID_PREFIX", "legacy_xoopsform_"); + function smarty_function_xoops_input($params, &$smarty) { - if(isset($params['name'])) { + if (isset($params['name'])) { + // + // Fetch major elements from $params. + // $name = trim($params['name']); $key = isset($params['key']) ? trim($params['key']) : null; $type = isset($params['type']) ? strtolower(trim($params['type'])) : "text"; + $value = isset($params['value']) ? htmlspecialchars($params['value'], ENT_QUOTES) : null; $class = isset($params['class']) ? trim($params['class']) : null; + $id = isset($params['id']) ? trim($params['id']) : XOOPS_INPUT_DEFID_PREFIX . $name; $size = isset($params['size']) ? intval($params['size']) : null; $maxlength = isset($params['maxlength']) ? intval($params['maxlength']) : null; - $value = isset($params['value']) ? htmlspecialchars($params['value'],ENT_QUOTES) : null; - $id = isset($params['id']) ? trim($params['id']) : null; $default = isset($params['default']) ? trim($params['default']) : null; $disabled = (isset($params['disabled']) && $params['disabled'] != false) ? true : false; - if ($key != null) - { - $string="<input name=\"${name}[${key}]\""; - } - else - { - $string="<input name=\"${name}\""; - } - - if($class) - $string.=" class=\"${class}\""; - if($type) - $string.=" type=\"${type}\""; - if($size) - $string.=" size=\"${size}\""; - if($maxlength) - $string.=" maxlength=\"${maxlength}\""; - if($value!==null) - $string.=" value=\"${value}\""; - if($id) - $string.=" id=\"${id}\""; - + // + // Build string. + // + if ($key != null) { + $string = "<input name=\"${name}[${key}]\""; + } + else { + $string = "<input name=\"${name}\""; + } + + if ($class) { + $string .= " class=\"${class}\""; + } + + $string .= " id=\"{$id}\""; + + if ($type) { + $string .= " type=\"${type}\""; + } + + if ($size) { + $string .= " size=\"${size}\""; + } + + if($maxlength) { + $string .= " maxlength=\"${maxlength}\""; + } + + if($value !== null) { + $string .= " value=\"${value}\""; + } + if (isset($params['default'])) { $default = trim($params['default']); - if ($value==$default) { + if ($value == $default) { if ($type = "checkbox" || $type == "radio") { $string .= " checked"; } @@ -69,11 +98,14 @@ } if ($disabled) { - $string .=" disabled"; + $string .= " disabled"; } - $string.=" />"; + $string .= " />"; + // + // Output. + // print $string; } }