| 1: | <?php | 
| 2: | /** | 
| 3: | * XOOPS form element | 
| 4: | * | 
| 5: | * You may not change or alter any portion of this comment or credits | 
| 6: | * of supporting developers from this source code or any supporting source code | 
| 7: | * which is considered copyrighted (c) material of the original comment or credit authors. | 
| 8: | * This program is distributed in the hope that it will be useful, | 
| 9: | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 10: | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 
| 11: | * | 
| 12: | * @copyright (c) 2000-2017 XOOPS Project (www.xoops.org) | 
| 13: | * @license GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html) | 
| 14: | * @package kernel | 
| 15: | * @subpackage form | 
| 16: | * @since 2.0.0 | 
| 17: | * @author Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/ | 
| 18: | */ | 
| 19: | |
| 20: | defined('XOOPS_ROOT_PATH') || exit('Restricted access'); | 
| 21: | |
| 22: | xoops_load('XoopsFormElement'); | 
| 23: | |
| 24: | /** | 
| 25: | * A textarea | 
| 26: | */ | 
| 27: | class XoopsFormTextArea extends XoopsFormElement | 
| 28: | { | 
| 29: | /** | 
| 30: | * number of columns | 
| 31: | * | 
| 32: | * @var int | 
| 33: | * @access private | 
| 34: | */ | 
| 35: | public $_cols; | 
| 36: | |
| 37: | /** | 
| 38: | * number of rows | 
| 39: | * | 
| 40: | * @var int | 
| 41: | * @access private | 
| 42: | */ | 
| 43: | public $_rows; | 
| 44: | |
| 45: | /** | 
| 46: | * initial content | 
| 47: | * | 
| 48: | * @var string | 
| 49: | * @access private | 
| 50: | */ | 
| 51: | public $_value; | 
| 52: | |
| 53: | /** | 
| 54: | * Constuctor | 
| 55: | * | 
| 56: | * @param string $caption caption | 
| 57: | * @param string $name name | 
| 58: | * @param string $value initial content | 
| 59: | * @param int $rows number of rows | 
| 60: | * @param int $cols number of columns | 
| 61: | */ | 
| 62: | public function __construct($caption, $name, $value = '', $rows = 5, $cols = 50) | 
| 63: | { | 
| 64: | $this->setCaption($caption); | 
| 65: | $this->setName($name); | 
| 66: | $this->_rows = (int)$rows; | 
| 67: | $this->_cols = (int)$cols; | 
| 68: | $this->setValue($value); | 
| 69: | } | 
| 70: | |
| 71: | /** | 
| 72: | * get number of rows | 
| 73: | * | 
| 74: | * @return int | 
| 75: | */ | 
| 76: | public function getRows() | 
| 77: | { | 
| 78: | return $this->_rows; | 
| 79: | } | 
| 80: | |
| 81: | /** | 
| 82: | * Get number of columns | 
| 83: | * | 
| 84: | * @return int | 
| 85: | */ | 
| 86: | public function getCols() | 
| 87: | { | 
| 88: | return $this->_cols; | 
| 89: | } | 
| 90: | |
| 91: | /** | 
| 92: | * Get initial content | 
| 93: | * | 
| 94: | * @param bool $encode To sanitizer the text? Default value should be "true"; however we have to set "false" for backward compatibility | 
| 95: | * @return string | 
| 96: | */ | 
| 97: | public function getValue($encode = false) | 
| 98: | { | 
| 99: | return $encode ? htmlspecialchars($this->_value, ENT_QUOTES) : $this->_value; | 
| 100: | } | 
| 101: | |
| 102: | /** | 
| 103: | * Set initial content | 
| 104: | * | 
| 105: | * @param string $value | 
| 106: | */ | 
| 107: | public function setValue($value) | 
| 108: | { | 
| 109: | $this->_value = $value; | 
| 110: | } | 
| 111: | |
| 112: | /** | 
| 113: | * prepare HTML for output | 
| 114: | * | 
| 115: | * @return string HTML | 
| 116: | */ | 
| 117: | public function render() | 
| 118: | { | 
| 119: | return XoopsFormRenderer::getInstance()->get()->renderFormTextArea($this); | 
| 120: | } | 
| 121: | } | 
| 122: |