1: <?php
2: /**
3: *
4: * @package Legacy
5: * @version $Id: function.xoops_dhtmltarea.php,v 1.3 2010/02/22 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) Some users and developers want free elements at $params. For example,
13: * $params['script']... This function have not impletented that yet. At
14: * implementing, we will have to define the rule about sanitizing.
15: * 3) Users can't set class element to this function, because XoopsForm is
16: * used. For format xoops_xxxx functions, we may change XoopsForm class
17: * group.
18: *
19: */
20:
21: /*
22: * Smarty plugin
23: * -------------------------------------------------------------
24: * Type: function
25: * Name: xoops_dhtmltarea
26: * Version: 1.0
27: * Date: Jun 6, 2004
28: * Author: minahito
29: * Purpose: cycle through given values
30: * Input: name = form 'name'.
31: * value = preset value. Set raw value without htmlspecialchars().
32: * id = form 'id'. If it's empty, ID is defined automatically by prefix & name.
33: * cols = amount of cols. (default 50)
34: * rows = amount of rows. (default 5)
35: * editor = textarea editor type (default bbcode)
36: *
37: * Examples: {xoops_dhtmltarea name=message cols=40 rows=6 value=$message}
38: * -------------------------------------------------------------
39: */
40:
41: define ("XOOPS_DHTMLTAREA_DEFID_PREFIX", "legacy_xoopsform_");
42: define ("XOOPS_DHTMLTAREA_DEFAULT_COLS", "50");
43: define ("XOOPS_DHTMLTAREA_DEFAULT_ROWS", "5");
44:
45: function smarty_function_xoops_dhtmltarea($params, &$smarty)
46: {
47: if (!XC_CLASS_EXISTS('xoopsformelement')) {
48: require_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
49: }
50: $form = null;
51:
52: $root =& XCube_Root::getSingleton();
53: $textFilter =& $root->getTextFilter();
54: if (isset($params['name'])) {
55: //
56: // Fetch major elements from $params.
57: //
58: $params['name'] = trim($params['name']);
59: $params['class'] = isset($params['class']) ? trim($params['class']) : null;
60: $params['cols'] = isset($params['cols']) ? intval($params['cols']) : XOOPS_DHTMLTAREA_DEFAULT_COLS;
61: $params['rows'] = isset($params['rows']) ? intval($params['rows']) : XOOPS_DHTMLTAREA_DEFAULT_ROWS;
62: $params['value'] = isset($params['value']) ? $textFilter->toEdit($params['value']) : null;
63: $params['id'] = isset($params['id']) ? trim($params['id']) : XOOPS_DHTMLTAREA_DEFID_PREFIX . $params['name'];
64:
65: //
66: // Build the object for output.
67: //
68: $html = "";
69: switch($params['editor']){
70: case 'html':
71: XCube_DelegateUtils::call("Site.TextareaEditor.HTML.Show", new XCube_Ref($html), $params);
72: break;
73:
74: case 'none':
75: XCube_DelegateUtils::call("Site.TextareaEditor.None.Show", new XCube_Ref($html), $params);
76: break;
77: case 'bbcode':
78: default:
79: XCube_DelegateUtils::call("Site.TextareaEditor.BBCode.Show", new XCube_Ref($html), $params);
80: break;
81: }
82: print $html;
83:
84: /*
85: $form =new XoopsFormDhtmlTextArea($name, $name, $value, $rows, $cols);
86: $form->setId($id);
87: if ($class != null) {
88: $form->setClass($class);
89: }
90:
91: print $form->render();
92: */
93: }
94: }
95:
96: ?>
97: