1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Module: RandomQuote |
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
|
|
|
* |
9
|
|
|
* PHP version 5 |
10
|
|
|
* |
11
|
|
|
* @category Module |
12
|
|
|
* @package Randomquote |
13
|
|
|
* @author XOOPS Development Team, Mamba |
14
|
|
|
* @copyright 2001-2016 XOOPS Project (http://xoops.org) |
15
|
|
|
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
16
|
|
|
* @link http://xoops.org/ |
17
|
|
|
* @since 2.0.0 |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
// defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
|
|
|
|
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Class RandomquoteQuotes |
24
|
|
|
*/ |
25
|
|
|
class RandomquoteQuotes extends XoopsObject |
|
|
|
|
26
|
|
|
{ |
27
|
|
|
//Constructor |
28
|
|
|
/** |
29
|
|
|
* |
30
|
|
|
*/ |
31
|
|
|
public function __construct() |
32
|
|
|
{ |
33
|
|
|
parent::__construct(); |
34
|
|
|
$this->initVar('id', XOBJ_DTYPE_INT, null, false, 11); |
35
|
|
|
$this->initVar('quote', XOBJ_DTYPE_TXTAREA, null, false); |
36
|
|
|
$this->initVar('author', XOBJ_DTYPE_TXTAREA, null, false); |
37
|
|
|
$this->initVar('quote_status', XOBJ_DTYPE_INT, null, false, 10); |
38
|
|
|
$this->initVar('quote_waiting', XOBJ_DTYPE_INT, null, false, 10); |
39
|
|
|
$this->initVar('quote_online', XOBJ_DTYPE_INT, null, false, 1); |
40
|
|
|
|
41
|
|
|
$this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); |
42
|
|
|
$this->initVar('dosmiley', XOBJ_DTYPE_INT, 1, false); |
43
|
|
|
$this->initVar('doxcode', XOBJ_DTYPE_INT, 1, false); |
44
|
|
|
$this->initVar('doimage', XOBJ_DTYPE_INT, 1, false); |
45
|
|
|
$this->initVar('dobr', XOBJ_DTYPE_INT, 1, false); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param bool $action |
50
|
|
|
* |
51
|
|
|
* @return XoopsThemeForm |
52
|
|
|
*/ |
53
|
|
|
public function getForm($action = false) |
|
|
|
|
54
|
|
|
{ |
55
|
|
|
// global $xoopsDB, $xoopsModuleConfig; |
|
|
|
|
56
|
|
|
|
57
|
|
|
if ($action === false) { |
58
|
|
|
$action = $_SERVER['REQUEST_URI']; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
$title = $this->isNew() ? sprintf(_AM_RANDOMQUOTE_QUOTES_ADD) : sprintf(_AM_RANDOMQUOTE_QUOTES_EDIT); |
62
|
|
|
|
63
|
|
|
include_once(XOOPS_ROOT_PATH . '/class/xoopsformloader.php'); |
64
|
|
|
|
65
|
|
|
$form = new XoopsThemeForm($title, 'form', $action, 'post', true); |
66
|
|
|
$form->setExtra('enctype="multipart/form-data"'); |
67
|
|
|
|
68
|
|
|
$author = $this->isNew() ? '' : $this->getVar('author'); |
69
|
|
|
$textAuthor = new XoopsFormText(_AM_RANDOMQUOTE_QUOTES_AUTHOR, 'author', 50, 255, $author); |
70
|
|
|
$form->addElement($textAuthor); |
71
|
|
|
|
72
|
|
|
$editorConfigs = array(); |
73
|
|
|
$editorConfigs['name'] = 'quote'; |
74
|
|
|
$editorConfigs['value'] = $this->getVar('quote', 'e'); |
75
|
|
|
$editorConfigs['rows'] = 10; |
76
|
|
|
$editorConfigs['cols'] = 80; |
77
|
|
|
$editorConfigs['width'] = '100%'; |
78
|
|
|
$editorConfigs['height'] = '400px'; |
79
|
|
|
$editorConfigs['editor'] = $GLOBALS['xoopsModuleConfig']['randomquote_editor']; |
80
|
|
|
$form->addElement(new XoopsFormEditor(_AM_RANDOMQUOTE_QUOTES_QUOTE, 'quote', $editorConfigs), true); |
81
|
|
|
|
82
|
|
|
// $editorConfigs = array(); |
|
|
|
|
83
|
|
|
// $editorConfigs["name"] = "author"; |
|
|
|
|
84
|
|
|
// $editorConfigs["value"] = $this->getVar("author", "e"); |
|
|
|
|
85
|
|
|
// $editorConfigs["rows"] = 10; |
|
|
|
|
86
|
|
|
// $editorConfigs["cols"] = 80; |
|
|
|
|
87
|
|
|
// $editorConfigs["width"] = "100%"; |
|
|
|
|
88
|
|
|
// $editorConfigs["height"] = "400px"; |
|
|
|
|
89
|
|
|
// $editorConfigs["editor"] = $GLOBALS["xoopsModuleConfig"]["randomquote_editor"]; |
|
|
|
|
90
|
|
|
// $form->addElement(new XoopsFormEditor(_AM_RANDOMQUOTE_QUOTES_AUTHOR, "author", $editorConfigs), true); |
|
|
|
|
91
|
|
|
|
92
|
|
|
$quote_status = $this->isNew() ? 0 : $this->getVar('quote_status'); |
93
|
|
|
$check_quote_status = new XoopsFormCheckBox(_AM_RANDOMQUOTE_QUOTES_STATUS, 'quote_status', $quote_status); |
94
|
|
|
$check_quote_status->addOption(1, ' '); |
95
|
|
|
$form->addElement($check_quote_status); |
96
|
|
|
$quote_waiting = $this->isNew() ? 0 : $this->getVar('quote_waiting'); |
97
|
|
|
$check_quote_waiting = new XoopsFormCheckBox(_AM_RANDOMQUOTE_QUOTES_WAITING, 'quote_waiting', $quote_waiting); |
98
|
|
|
$check_quote_waiting->addOption(1, ' '); |
99
|
|
|
$form->addElement($check_quote_waiting); |
100
|
|
|
$quote_online = $this->isNew() ? 0 : $this->getVar('quote_online'); |
101
|
|
|
$check_quote_online = new XoopsFormCheckBox(_AM_RANDOMQUOTE_QUOTES_ONLINE, 'quote_online', $quote_online); |
102
|
|
|
$check_quote_online->addOption(1, ' '); |
103
|
|
|
$form->addElement($check_quote_online); |
104
|
|
|
|
105
|
|
|
$form->addElement(new XoopsFormHidden('op', 'save_quote')); |
106
|
|
|
|
107
|
|
|
//Submit buttons |
108
|
|
|
$button_tray = new XoopsFormElementTray('', ''); |
109
|
|
|
$submit_button = new XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
110
|
|
|
$button_tray->addElement($submit_button); |
111
|
|
|
|
112
|
|
|
$cancel_button = new XoopsFormButton('', '', _CANCEL, 'cancel'); |
113
|
|
|
$cancel_button->setExtra('onclick="history.go(-1)"'); |
114
|
|
|
$button_tray->addElement($cancel_button); |
115
|
|
|
|
116
|
|
|
$form->addElement($button_tray); |
117
|
|
|
|
118
|
|
|
return $form; |
119
|
|
|
} |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* Class RandomquoteQuotesHandler |
124
|
|
|
*/ |
125
|
|
|
class RandomquoteQuotesHandler extends XoopsPersistableObjectHandler |
|
|
|
|
126
|
|
|
{ |
127
|
|
|
/** |
128
|
|
|
* @param null|XoopsDatabase $db |
129
|
|
|
*/ |
130
|
|
|
public function __construct(XoopsDatabase $db) |
131
|
|
|
{ |
132
|
|
|
parent::__construct($db, 'randomquote_quotes', 'RandomquoteQuotes', 'id', 'quote'); |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.