1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits |
4
|
|
|
of supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
/** |
12
|
|
|
* Module: RandomQuote |
13
|
|
|
* |
14
|
|
|
* @category Module |
15
|
|
|
* @package randomquote |
16
|
|
|
* @author XOOPS Module Development Team |
17
|
|
|
* @author Mamba |
18
|
|
|
* @copyright {@link http://xoops.org The XOOPS Project} |
19
|
|
|
* @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
20
|
|
|
* @link http://xoops.org XOOPS |
21
|
|
|
* @since 2.00 |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
// defined('XOOPS_ROOT_PATH') || exit('Restricted access'); |
|
|
|
|
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Class RandomquoteQuotes |
28
|
|
|
*/ |
29
|
|
|
class RandomquoteQuotes extends XoopsObject |
|
|
|
|
30
|
|
|
{ |
31
|
|
|
//Constructor |
32
|
|
|
/** |
33
|
|
|
* |
34
|
|
|
*/ |
35
|
|
|
public function __construct() |
36
|
|
|
{ |
37
|
|
|
parent::__construct(); |
38
|
|
|
$this->initVar('id', XOBJ_DTYPE_INT, null, false, 11); |
39
|
|
|
$this->initVar('quote', XOBJ_DTYPE_TXTAREA, null, true); |
40
|
|
|
$this->initVar('author', XOBJ_DTYPE_TXTAREA, null, false); |
41
|
|
|
$this->initVar('quote_status', XOBJ_DTYPE_INT, null, false, 10); |
42
|
|
|
$this->initVar('create_date', XOBJ_DTYPE_INT, time(), false, 11); |
43
|
|
|
$this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); |
44
|
|
|
$this->initVar('dosmiley', XOBJ_DTYPE_INT, 1, false); |
45
|
|
|
$this->initVar('doxcode', XOBJ_DTYPE_INT, 1, false); |
46
|
|
|
$this->initVar('doimage', XOBJ_DTYPE_INT, 1, false); |
47
|
|
|
$this->initVar('dobr', XOBJ_DTYPE_INT, 1, false); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* |
52
|
|
|
* Magic function to display obj as string |
53
|
|
|
*/ |
54
|
|
|
public function __toString() |
55
|
|
|
{ |
56
|
|
|
return $this->getVar('quote') . ' - ' . $this->getVar('author'); |
57
|
|
|
} |
58
|
|
|
/** |
59
|
|
|
* Displays the Edit (Create) quote form |
60
|
|
|
* |
61
|
|
|
* @param mixed $action |
62
|
|
|
* |
63
|
|
|
* @return object {@see XoopsThemeForm) |
64
|
|
|
*/ |
65
|
|
|
public function getForm($action = false) |
|
|
|
|
66
|
|
|
{ |
67
|
|
|
if (false === $action) { |
68
|
|
|
$action = XoopsRequest::getString('REQUEST_URI','','SERVER'); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
$title = $this->isNew() ? sprintf(_AM_RANDOMQUOTE_QUOTES_ADD) : sprintf(_AM_RANDOMQUOTE_QUOTES_EDIT); |
72
|
|
|
|
73
|
|
|
xoops_load('constants', 'randomquote'); |
74
|
|
|
include_once $GLOBALS['xoops']->path("/class/xoopsformloader.php"); |
75
|
|
|
|
76
|
|
|
$form = new XoopsThemeForm($title, 'form', $action, 'post', true); |
77
|
|
|
$form->setExtra('enctype="multipart/form-data"'); |
78
|
|
|
|
79
|
|
|
$author = $this->isNew() ? '' : $this->getVar('author'); |
80
|
|
|
$id = ($this->getVar('id')) ? $this->getVar('id') : RandomquoteConstants::DEFAULT_ID; |
81
|
|
|
$textAuthor = new XoopsFormText(_AM_RANDOMQUOTE_QUOTES_AUTHOR, 'author', 50, 255, $author); |
82
|
|
|
$form->addElement($textAuthor); |
83
|
|
|
|
84
|
|
|
$editorConfigs = array('name' => 'quote', |
85
|
|
|
'value' => $this->getVar('quote', 'e'), |
86
|
|
|
'rows' => 10, |
87
|
|
|
'cols' => 50, |
88
|
|
|
'width' => '100%', |
89
|
|
|
'height' => '400px', |
90
|
|
|
'editor' => $GLOBALS['xoopsModuleConfig']['randomquote_editor'] |
91
|
|
|
); |
92
|
|
|
$form->addElement(new XoopsFormEditor(_AM_RANDOMQUOTE_QUOTES_QUOTE, 'quote', $editorConfigs), true); |
93
|
|
|
|
94
|
|
|
/* |
95
|
|
|
* pseudo code |
96
|
|
|
* see if tag module is present & active |
97
|
|
|
* load the formtag class |
98
|
|
|
* display the tag form element to collect the tag item |
99
|
|
|
*/ |
100
|
|
|
$moduleHandler = xoops_gethandler('module'); |
|
|
|
|
101
|
|
|
$tagModule = XoopsModule::getByDirname('tag'); |
102
|
|
|
if (($tagModule instanceof XoopsModule) && ($tagModule->isactive())) { |
|
|
|
|
103
|
|
|
$tagClassExists = XoopsLoad::load('formtag', 'tag'); // get the TagFormTag class |
104
|
|
|
if ($tagClassExists) { |
105
|
|
|
if ($this->isNew()) { |
106
|
|
|
$tag_items = array(); |
107
|
|
|
} else { |
108
|
|
|
$moduleMid = $GLOBALS['xoopsModule']->mid(); |
109
|
|
|
$tagHandler = xoops_getmodulehandler('tag', 'tag'); |
110
|
|
|
$tag_items = $tagHandler->getByItem($id, $moduleMid, 0); |
111
|
|
|
} |
112
|
|
|
$tag_string = implode('|', $tag_items); |
113
|
|
|
$form->addElement(new TagFormTag('item_tag', 60, 255, $tag_string, 0)); |
114
|
|
|
} |
115
|
|
|
} else { |
116
|
|
|
$form->addElement(new XoopsFormHidden('item_tag', '')); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
$quote_status = ($this->isNew()) ? RandomquoteConstants::STATUS_ONLINE : $this->getVar('quote_status'); |
120
|
|
|
$check_quote_status = new XoopsFormRadio(_AM_RANDOMQUOTE_QUOTES_STATUS, 'quote_status', $quote_status); |
121
|
|
|
$check_quote_status->addOption(RandomquoteConstants::STATUS_OFFLINE, _AM_RANDOMQUOTE_QUOTES_OFFLINE_TXT); |
122
|
|
|
$check_quote_status->addOption(RandomquoteConstants::STATUS_ONLINE, _AM_RANDOMQUOTE_QUOTES_ONLINE_TXT); |
123
|
|
|
$check_quote_status->addOption(RandomquoteConstants::STATUS_WAITING, _AM_RANDOMQUOTE_QUOTES_WAITING_TXT); |
124
|
|
|
$form->addElement($check_quote_status); |
125
|
|
|
|
126
|
|
|
$form->addElement(new XoopsFormHidden('op', 'save_quote')); |
127
|
|
|
$form->addElement(new XoopsFormHidden('id', $id)); |
128
|
|
|
|
129
|
|
|
//Submit buttons |
130
|
|
|
$button_tray = new XoopsFormButtonTray('submit', _SUBMIT); |
131
|
|
|
$form->addElement($button_tray); |
132
|
|
|
|
133
|
|
|
return $form; |
134
|
|
|
} |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Class RandomquoteQuotesHandler |
139
|
|
|
*/ |
140
|
|
|
class RandomquoteQuotesHandler extends XoopsPersistableObjectHandler |
|
|
|
|
141
|
|
|
{ |
142
|
|
|
/** |
143
|
|
|
* @param null|object $db |
144
|
|
|
*/ |
145
|
|
|
function __construct(&$db) |
|
|
|
|
146
|
|
|
{ |
147
|
|
|
parent::__construct($db, 'randomquote_quotes', 'RandomquoteQuotes', 'id', 'quote'); |
148
|
|
|
} |
149
|
|
|
} |
150
|
|
|
|
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.