|
1
|
|
|
<?php |
|
|
|
|
|
|
2
|
|
|
/** |
|
3
|
|
|
* XOOPS theme form |
|
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-2016 XOOPS Project (www.xoops.org) |
|
13
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/gpl-2.0.html) |
|
14
|
|
|
* @package kernel |
|
15
|
|
|
* @subpackage form |
|
16
|
|
|
* @since 2.0.0 |
|
17
|
|
|
*/ |
|
18
|
|
|
|
|
19
|
|
|
defined('XOOPS_ROOT_PATH') || exit('Restricted access'); |
|
20
|
|
|
|
|
21
|
|
|
xoops_load('XoopsForm'); |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Form that will output as a theme-enabled HTML table |
|
25
|
|
|
* |
|
26
|
|
|
* Also adds JavaScript to validate required fields |
|
27
|
|
|
*/ |
|
28
|
|
|
class XoopsThemeForm extends XoopsForm |
|
29
|
|
|
{ |
|
30
|
|
|
/** |
|
31
|
|
|
* Insert an empty row in the table to serve as a separator. |
|
32
|
|
|
* |
|
33
|
|
|
* @param string $extra HTML to be displayed in the empty row. |
|
34
|
|
|
* @param string $class CSS class name for <td> tag |
|
35
|
|
|
*/ |
|
36
|
|
|
public function insertBreak($extra = '', $class = '') |
|
37
|
|
|
{ |
|
38
|
|
|
XoopsFormRenderer::getInstance()->get()->addThemeFormBreak($this, $extra, $class); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* create HTML to output the form as a theme-enabled table with validation. |
|
43
|
|
|
* |
|
44
|
|
|
* YOU SHOULD AVOID TO USE THE FOLLOWING Nocolspan METHOD, IT WILL BE REMOVED |
|
45
|
|
|
* |
|
46
|
|
|
* To use the noColspan simply use the following example: |
|
47
|
|
|
* |
|
48
|
|
|
* $colspan = new XoopsFormDhtmlTextArea( '', 'key', $value, '100%', '100%' ); |
|
49
|
|
|
* $colspan->setNocolspan(); |
|
50
|
|
|
* $form->addElement( $colspan ); |
|
51
|
|
|
* |
|
52
|
|
|
* @return string |
|
53
|
|
|
*/ |
|
54
|
|
|
public function render() |
|
55
|
|
|
{ |
|
56
|
|
|
return XoopsFormRenderer::getInstance()->get()->renderThemeForm($this); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.