1: <?php
2: /**
3: *
4: * @package Legacy
5: * @version $Id: function.legacy_button.php,v 1.3 2008/09/25 15:12:36 kilica Exp $
6: * @copyright Copyright 2005-2007 XOOPS Cube Project <https://github.com/xoopscube/legacy>
7: * @license https://github.com/xoopscube/legacy/blob/master/docs/GPL_V2.txt GNU GENERAL PUBLIC LICENSE Version 2
8: *
9: * [ToDo]
10: * 1) We may have to move this file to other module with following namespace or
11: * package.
12: * 2) This function accepts all of <input> pattern. We may have to divide it.
13: * 3) Some users and developers want free elements at $params. For example,
14: * $params['script']... This function have not impletented that yet. At
15: * implementing, we will have to define the rule about sanitizing.
16: *
17: */
18:
19: /*
20: * Smarty plugin
21: * -------------------------------------------------------------
22: * Type: function
23: * Name: legacy_button
24: * Version: 1.0
25: * Date: Oct 14, 2005
26: * Author: minahito
27: * Purpose: Display a button with the control
28: * Input: id = ID of form 'name'
29: * Text = The displayed text of the button
30: * class = The class name of the form
31: * Examples: <{legacy_button id=commentpost Text='POST'}>
32: * -------------------------------------------------------------
33: */
34:
35: function smarty_function_legacy_button($params, &$smarty)
36: {
37: if (isset($params['id'])) {
38: //
39: // Fetch major elements from $params.
40: //
41: $id = trim($params['id']);
42: $name = "Legacy.Event.User.${id}";
43: $text = isset($params['Text']) ? htmlspecialchars(trim($params['Text']), ENT_QUOTES) : null;
44: $class = isset($params['class']) ? htmlspecialchars(trim($params['class']), ENT_QUOTES) : null;
45:
46: //
47: // Build string.
48: //
49: $string = "<input type='submit' id='${id}' name='${name}'";
50:
51: if ($text != null) {
52: $string .= " value='${text}'";
53: }
54:
55: if ($class != null) {
56: $string .= " class='${class}'";
57: }
58:
59: $string .= " />";
60:
61: //
62: // Output.
63: //
64: print $string;
65: }
66: }
67:
68: ?>
69: