These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * |
||
4 | * Module: WF-Links |
||
5 | * Version: v1.0.3 |
||
6 | * Release Date: 21 June 2005 |
||
7 | * Developer: John N |
||
8 | * Team: WF-Projects |
||
9 | * Licence: GNU |
||
10 | */ |
||
11 | |||
12 | require_once __DIR__ . '/header.php'; |
||
13 | |||
14 | include XOOPS_ROOT_PATH . '/header.php'; |
||
15 | include XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
16 | |||
17 | $mytree = new WflinksXoopsTree($xoopsDB->prefix('wflinks_cat'), 'cid', 'pid'); |
||
18 | global $wfmyts, $xoopsModuleConfig; |
||
19 | |||
20 | $cid = WfLinksUtility::cleanRequestVars($_REQUEST, 'cid', 0); |
||
21 | $lid = WfLinksUtility::cleanRequestVars($_REQUEST, 'lid', 0); |
||
22 | $cid = (int)$cid; |
||
23 | $lid = (int)$lid; |
||
24 | |||
25 | if (false === WfLinksUtility::checkGroups($cid, 'WFLinkSubPerm')) { |
||
26 | redirect_header('index.php', 1, _MD_WFL_NOPERMISSIONTOPOST); |
||
27 | } |
||
28 | |||
29 | if (true === WfLinksUtility::checkGroups($cid, 'WFLinkSubPerm')) { |
||
30 | if (WfLinksUtility::cleanRequestVars($_REQUEST, 'submit', 0)) { |
||
31 | if (false === WfLinksUtility::checkGroups($cid, 'WFLinkSubPerm')) { |
||
32 | redirect_header('index.php', 1, _MD_WFL_NOPERMISSIONTOPOST); |
||
33 | } |
||
34 | |||
35 | $submitter = (is_object($xoopsUser) && !empty($xoopsUser)) ? $xoopsUser->getVar('uid') : 0; |
||
36 | $forumid = WfLinksUtility::cleanRequestVars($_REQUEST, 'forumid', 0); |
||
37 | $offline = WfLinksUtility::cleanRequestVars($_REQUEST, 'offline', 0); |
||
38 | $notifypub = WfLinksUtility::cleanRequestVars($_REQUEST, 'notifypub', 0); |
||
39 | $approve = WfLinksUtility::cleanRequestVars($_REQUEST, 'approve', 0); |
||
40 | $url = $wfmyts->addSlashes(ltrim($_POST['url'])); |
||
41 | $title = $wfmyts->addSlashes(ltrim($_REQUEST['title'])); |
||
42 | $descriptionb = $wfmyts->addSlashes(ltrim($_REQUEST['descriptionb'])); |
||
43 | $keywords = $wfmyts->addSlashes(trim(substr($_POST['keywords'], 0, $xoopsModuleConfig['keywordlength']))); |
||
44 | |||
45 | $item_tag = ''; |
||
46 | if ($xoopsModuleConfig['usercantag']) { |
||
47 | $item_tag = $wfmyts->addSlashes(ltrim($_REQUEST['item_tag'])); |
||
48 | } |
||
49 | |||
50 | View Code Duplication | if ($xoopsModuleConfig['useaddress']) { |
|
0 ignored issues
–
show
|
|||
51 | $googlemap = ($_POST['googlemap'] !== 'http://maps.google.com') ? $wfmyts->addSlashes($_POST['googlemap']) : ''; |
||
52 | $yahoomap = ($_POST['yahoomap'] !== 'http://maps.yahoo.com') ? $wfmyts->addSlashes($_POST['yahoomap']) : ''; |
||
53 | $multimap = ($_POST['multimap'] !== 'http://www.multimap.com') ? $wfmyts->addSlashes($_POST['multimap']) : ''; |
||
54 | $street1 = $wfmyts->addSlashes(ltrim($_REQUEST['street1'])); |
||
55 | $street2 = $wfmyts->addSlashes(ltrim($_REQUEST['street2'])); |
||
56 | $town = $wfmyts->addSlashes(ltrim($_REQUEST['town'])); |
||
57 | $state = $wfmyts->addSlashes(ltrim($_REQUEST['state'])); |
||
58 | $zip = $wfmyts->addSlashes(ltrim($_REQUEST['zip'])); |
||
59 | $tel = $wfmyts->addSlashes(ltrim($_REQUEST['tel'])); |
||
60 | $fax = $wfmyts->addSlashes(ltrim($_REQUEST['fax'])); |
||
61 | $voip = $wfmyts->addSlashes(ltrim($_REQUEST['voip'])); |
||
62 | $mobile = $wfmyts->addSlashes(ltrim($_REQUEST['mobile'])); |
||
63 | $email = WfLinksUtility::convertEmail($wfmyts->addSlashes(ltrim($_REQUEST['email']))); |
||
64 | $vat = $wfmyts->addSlashes(ltrim($_REQUEST['vat'])); |
||
65 | } else { |
||
66 | $googlemap = $yahoomap = $multimap = $street1 = $street2 = $town = $state = $zip = $tel = $fax = $voip = $mobile = $email = $vat = ''; |
||
67 | } |
||
68 | |||
69 | $country = $wfmyts->addSlashes(ltrim($_REQUEST['country'])); |
||
70 | |||
71 | $date = time(); |
||
72 | $publishdate = 0; |
||
73 | $ipaddress = $_SERVER['REMOTE_ADDR']; |
||
74 | |||
75 | if ($lid == 0) { |
||
76 | $status = 0; |
||
77 | $publishdate = 0; |
||
78 | $message = _MD_WFL_THANKSFORINFO; |
||
79 | if (true === WfLinksUtility::checkGroups($cid, 'WFLinkAutoApp')) { |
||
80 | $publishdate = time(); |
||
81 | $status = 1; |
||
82 | $message = _MD_WFL_ISAPPROVED; |
||
83 | } |
||
84 | |||
85 | $sql = 'INSERT INTO ' |
||
86 | . $xoopsDB->prefix('wflinks_links') |
||
87 | . ' (lid, cid, title, url, submitter, status, date, hits, rating, votes, comments, forumid, published, expired, offline, description, ipaddress, notifypub, country, keywords, item_tag, googlemap, yahoomap, multimap, street1, street2, town, state, zip, tel, fax, voip, mobile, email, vat ) '; |
||
88 | |||
89 | $sql .= " VALUES (0, $cid, '$title', '$url', '$submitter', '$status', '$date', 0, 0, 0, 0, '$forumid', '$publishdate', 0, '$offline', '$descriptionb', '$ipaddress', '$notifypub', '$country', '$keywords', '$item_tag', '$googlemap', '$yahoomap', '$multimap', '$street1', '$street2', '$town', '$state', '$zip', '$tel', '$fax', '$voip', '$mobile', '$email', '$vat' )"; |
||
90 | |||
91 | if (!$result = $xoopsDB->query($sql)) { |
||
92 | $_error = $xoopsDB->error() . ' : ' . $xoopsDB->errno(); |
||
93 | XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__); |
||
94 | } |
||
95 | // $newid = $xoopsDB -> getInsertId(); |
||
96 | $newid = $GLOBALS['xoopsDB']->getInsertId(); |
||
97 | |||
98 | // Add item_tag to Tag-module |
||
99 | View Code Duplication | if ($lid == 0) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
100 | $tagupdate = WfLinksUtility::updateTag($newid, $item_tag); |
||
0 ignored issues
–
show
Are you sure the assignment to
$tagupdate is correct as \WfLinksUtility::updateTag($newid, $item_tag) (which targets WfLinksUtility::updateTag() ) seems to always return null.
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
101 | } else { |
||
102 | $tagupdate = WfLinksUtility::updateTag($lid, $item_tag); |
||
0 ignored issues
–
show
Are you sure the assignment to
$tagupdate is correct as \WfLinksUtility::updateTag($lid, $item_tag) (which targets WfLinksUtility::updateTag() ) seems to always return null.
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
103 | } |
||
104 | |||
105 | // Notify of new link (anywhere) and new link in category |
||
106 | $notificationHandler = xoops_getHandler('notification'); |
||
107 | |||
108 | $tags = array(); |
||
109 | $tags['LINK_NAME'] = $title; |
||
110 | $tags['LINK_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/singlelink.php?cid=' . $cid . '&lid=' . (int)$newid; |
||
111 | |||
112 | $sql = 'SELECT title FROM ' . $xoopsDB->prefix('wflinks_cat') . ' WHERE cid=' . $cid; |
||
113 | $result = $xoopsDB->query($sql); |
||
114 | $row = $xoopsDB->fetchArray($result); |
||
115 | |||
116 | $tags['CATEGORY_NAME'] = $row['title']; |
||
117 | $tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' . $cid; |
||
118 | if (true === WfLinksUtility::checkGroups($cid, 'WFLinkAutoApp')) { |
||
119 | $notificationHandler->triggerEvent('global', 0, 'new_link', $tags); |
||
120 | $notificationHandler->triggerEvent('category', $cid, 'new_link', $tags); |
||
121 | redirect_header('index.php', 2, _MD_WFL_ISAPPROVED); |
||
122 | } else { |
||
123 | $tags['WAITINGFILES_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/newlinks.php'; |
||
124 | $notificationHandler->triggerEvent('global', 0, 'link_submit', $tags); |
||
125 | $notificationHandler->triggerEvent('category', $cid, 'link_submit', $tags); |
||
126 | if ($notifypub) { |
||
127 | require_once XOOPS_ROOT_PATH . '/include/notification_constants.php'; |
||
128 | $notificationHandler->subscribe('link', $newid, 'approve', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE); |
||
129 | } |
||
130 | redirect_header('index.php', 2, _MD_WFL_THANKSFORINFO); |
||
131 | } |
||
132 | } else { |
||
133 | if (1 == $approve || true === WfLinksUtility::checkGroups($cid, 'WFLinkAutoApp')) { |
||
134 | $updated = time(); |
||
135 | $sql = 'UPDATE ' |
||
136 | . $xoopsDB->prefix('wflinks_links') |
||
137 | . " SET cid=$cid, title='$title', url='$url', updated='$updated', offline='$offline', description='$descriptionb', ipaddress='$ipaddress', notifypub='$notifypub', country='$country', keywords='$keywords', item_tag='$item_tag', googlemap='$googlemap', yahoomap='$yahoomap', multimap='$multimap', street1='$street1', street2='$street2', town='$town', state='$state', zip='$zip', tel='$tel', fax='$fax', voip='$voip', mobile='$mobile', email='$email', vat='$vat' WHERE lid=" |
||
138 | . $lid; |
||
139 | if (!$result = $xoopsDB->query($sql)) { |
||
140 | $_error = $xoopsDB->error() . ' : ' . $xoopsDB->errno(); |
||
141 | XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__); |
||
142 | } |
||
143 | |||
144 | $notificationHandler = xoops_getHandler('notification'); |
||
145 | $tags = array(); |
||
146 | $tags['LINK_NAME'] = $title; |
||
147 | $tags['LINK_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/singlelink.php?cid=' . $cid . '&lid=' . $lid; |
||
148 | $sql = 'SELECT title FROM ' . $xoopsDB->prefix('wflinks_cat') . ' WHERE cid=' . $cid; |
||
149 | $result = $xoopsDB->query($sql); |
||
150 | $row = $xoopsDB->fetchArray($result); |
||
151 | $tags['CATEGORY_NAME'] = $row['title']; |
||
152 | $tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' . $lid; |
||
153 | |||
154 | $notificationHandler->triggerEvent('global', 0, 'new_link', $tags); |
||
155 | $notificationHandler->triggerEvent('category', $cid, 'new_link', $tags); |
||
156 | $_message = _MD_WFL_ISAPPROVED; |
||
157 | } else { |
||
158 | $modifysubmitter = $xoopsUser->uid(); |
||
159 | $requestid = $modifysubmitter; |
||
160 | $requestdate = time(); |
||
161 | $updated = WfLinksUtility::cleanRequestVars($_REQUEST, 'up_dated', time()); |
||
162 | $sql = 'INSERT INTO ' |
||
163 | . $xoopsDB->prefix('wflinks_mod') |
||
164 | . ' (requestid, lid, cid, title, url, forumid, description, modifysubmitter, requestdate, country, keywords, item_tag, googlemap, yahoomap, multimap, street1, street2, town, state, zip, tel, fax, voip, mobile, email, vat)'; |
||
165 | $sql .= " VALUES (0, $lid, $cid, '$title', '$url', '$forumid', '$descriptionb', '$modifysubmitter', '$requestdate', '$country', '$keywords', '$item_tag', '$googlemap', '$yahoomap', '$multimap', '$street1', '$street2', '$town', '$state', '$zip', '$tel', '$fax', '$voip', '$mobile', '$email', '$vat')"; |
||
166 | if (!$result = $xoopsDB->query($sql)) { |
||
167 | $_error = $xoopsDB->error() . ' : ' . $xoopsDB->errno(); |
||
168 | XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__); |
||
169 | } |
||
170 | |||
171 | $tags = array(); |
||
172 | $tags['MODIFYREPORTS_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/main.php?op=listModReq'; |
||
173 | $notificationHandler = xoops_getHandler('notification'); |
||
174 | $notificationHandler->triggerEvent('global', 0, 'link_modify', $tags); |
||
175 | |||
176 | $tags['WAITINGFILES_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/main.php?op=listNewlinks'; |
||
177 | $notificationHandler->triggerEvent('global', 0, 'link_submit', $tags); |
||
178 | $notificationHandler->triggerEvent('category', $cid, 'link_submit', $tags); |
||
179 | if ($notifypub) { |
||
180 | require_once XOOPS_ROOT_PATH . '/include/notification_constants.php'; |
||
181 | $notificationHandler->subscribe('link', $newid, 'approve', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE); |
||
182 | } |
||
183 | $_message = _MD_WFL_THANKSFORINFO; |
||
184 | } |
||
185 | redirect_header('index.php', 2, $_message); |
||
186 | } |
||
187 | } else { |
||
188 | global $xoopsModuleConfig; |
||
189 | |||
190 | $approve = WfLinksUtility::cleanRequestVars($_REQUEST, 'approve', 0); |
||
191 | |||
192 | //Show disclaimer |
||
193 | if (!isset($_GET['agree']) && $xoopsModuleConfig['showdisclaimer'] && $approve == 0) { |
||
194 | $GLOBALS['xoopsOption']['template_main'] = 'wflinks_disclaimer.tpl'; |
||
195 | include XOOPS_ROOT_PATH . '/header.php'; |
||
196 | |||
197 | $xoopsTpl->assign('image_header', WfLinksUtility::getImageHeader()); |
||
198 | $xoopsTpl->assign('disclaimer', $wfmyts->displayTarea($xoopsModuleConfig['disclaimer'], 1, 1, 1, 1, 1)); |
||
199 | $xoopsTpl->assign('cancel_location', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/index.php'); |
||
200 | $xoopsTpl->assign('link_disclaimer', false); |
||
201 | if (!isset($_REQUEST['lid'])) { |
||
202 | $xoopsTpl->assign('agree_location', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/submit.php?agree=1'); |
||
203 | } elseif (isset($_REQUEST['lid'])) { |
||
204 | $lid = (int)$_REQUEST['lid']; |
||
205 | $xoopsTpl->assign('agree_location', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/submit.php?agree=1&lid=' . $lid); |
||
206 | } |
||
207 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
208 | exit(); |
||
209 | } |
||
210 | |||
211 | echo "<br><div class='txtcenter;'>" . WfLinksUtility::getImageHeader() . "</div><br>\n"; |
||
212 | echo '<div>' . _MD_WFL_SUB_SNEWMNAMEDESC . "</div>\n<br>\n"; |
||
213 | |||
214 | $sql = 'SELECT * FROM ' . $xoopsDB->prefix('wflinks_links') . ' WHERE lid=' . $lid; |
||
215 | $link_array = $xoopsDB->fetchArray($xoopsDB->query($sql)); |
||
216 | |||
217 | $lid = $link_array['lid'] ?: 0; |
||
218 | $cid = $link_array['cid'] ?: 0; |
||
219 | $title = $link_array['title'] ? $wfmyts->htmlSpecialCharsStrip($link_array['title']) : ''; |
||
220 | $url = $link_array['url'] ? $wfmyts->htmlSpecialCharsStrip($link_array['url']) : 'http://'; |
||
221 | $publisher = $link_array['publisher'] ? $wfmyts->htmlSpecialCharsStrip($link_array['publisher']) : ''; |
||
222 | $screenshot = $link_array['screenshot'] ? $wfmyts->htmlSpecialCharsStrip($link_array['screenshot']) : ''; |
||
223 | $descriptionb = $link_array['description'] ? $wfmyts->htmlSpecialCharsStrip($link_array['description']) : ''; |
||
224 | $published = $link_array['published'] ?: 0; |
||
225 | $expired = $link_array['expired'] ?: 0; |
||
226 | $updated = $link_array['updated'] ?: 0; |
||
227 | $offline = $link_array['offline'] ?: 0; |
||
228 | $forumid = $link_array['forumid'] ?: 0; |
||
229 | $ipaddress = $link_array['ipaddress'] ?: 0; |
||
230 | $notifypub = $link_array['notifypub'] ?: 0; |
||
231 | $country = $link_array['country'] ? $wfmyts->htmlSpecialCharsStrip($link_array['country']) : '-'; |
||
232 | $keywords = $link_array['keywords'] ? $wfmyts->htmlSpecialCharsStrip($link_array['keywords']) : ''; |
||
233 | $item_tag = $link_array['item_tag'] ? $wfmyts->htmlSpecialCharsStrip($link_array['item_tag']) : ''; |
||
234 | |||
235 | $googlemap = $link_array['googlemap'] ? $wfmyts->htmlSpecialCharsStrip($link_array['googlemap']) : 'http://maps.google.com'; |
||
236 | $yahoomap = $link_array['yahoomap'] ? $wfmyts->htmlSpecialCharsStrip($link_array['yahoomap']) : 'http://maps.yahoo.com'; |
||
237 | $multimap = $link_array['multimap'] ? $wfmyts->htmlSpecialCharsStrip($link_array['multimap']) : 'http://www.multimap.com'; |
||
238 | |||
239 | $street1 = $link_array['street1'] ? $wfmyts->htmlSpecialCharsStrip($link_array['street1']) : ''; |
||
240 | $street2 = $link_array['street2'] ? $wfmyts->htmlSpecialCharsStrip($link_array['street2']) : ''; |
||
241 | $town = $link_array['town'] ? $wfmyts->htmlSpecialCharsStrip($link_array['town']) : ''; |
||
242 | $state = $link_array['state'] ? $wfmyts->htmlSpecialCharsStrip($link_array['state']) : ''; |
||
243 | $zip = $link_array['zip'] ? $wfmyts->htmlSpecialCharsStrip($link_array['zip']) : ''; |
||
244 | $tel = $link_array['tel'] ? $wfmyts->htmlSpecialCharsStrip($link_array['tel']) : ''; |
||
245 | $mobile = $link_array['mobile'] ? $wfmyts->htmlSpecialCharsStrip($link_array['mobile']) : ''; |
||
246 | $voip = $link_array['voip'] ? $wfmyts->htmlSpecialCharsStrip($link_array['voip']) : ''; |
||
247 | $fax = $link_array['fax'] ? $wfmyts->htmlSpecialCharsStrip($link_array['fax']) : ''; |
||
248 | $email = $link_array['email'] ? $wfmyts->htmlSpecialCharsStrip($link_array['email']) : ''; |
||
249 | $vat = $link_array['vat'] ? $wfmyts->htmlSpecialCharsStrip($link_array['vat']) : ''; |
||
250 | |||
251 | $sform = new XoopsThemeForm(_MD_WFL_SUBMITCATHEAD, 'storyform', xoops_getenv('PHP_SELF'), 'post', true); |
||
252 | $sform->setExtra('enctype="multipart/form-data"'); |
||
253 | |||
254 | // Title form |
||
255 | $sform->addElement(new XoopsFormText(_MD_WFL_FILETITLE, 'title', 70, 255, $title), true); |
||
256 | |||
257 | // Link url form |
||
258 | $url_text = new XoopsFormText('', 'url', 70, 255, $url); |
||
259 | $url_tray = new XoopsFormElementTray(_MD_WFL_DLURL, ''); |
||
260 | $url_tray->addElement($url_text, true); |
||
261 | $url_tray->addElement(new XoopsFormLabel(" <img src='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/assets/images/icon/world.png' onClick=\"window.open(document.storyform.url.value,'','');return(false);\" alt='Check URL'>")); |
||
262 | $sform->addElement($url_tray); |
||
263 | |||
264 | // Category selection menu |
||
265 | $mytree = new WflinksXoopsTree($xoopsDB->prefix('wflinks_cat'), 'cid', 'pid'); |
||
266 | $submitcats = array(); |
||
267 | $sql = 'SELECT * FROM ' . $xoopsDB->prefix('wflinks_cat') . ' ORDER BY title'; |
||
268 | $result = $xoopsDB->query($sql); |
||
269 | while ($myrow = $xoopsDB->fetchArray($result)) { |
||
270 | if (true === WfLinksUtility::checkGroups($myrow['cid'], 'WFLinkSubPerm')) { |
||
271 | $submitcats[$myrow['cid']] = $myrow['title']; |
||
272 | } |
||
273 | } |
||
274 | ob_start(); |
||
275 | $mytree->makeMySelBox('title', 'title', $cid, 0); |
||
276 | $sform->addElement(new XoopsFormLabel(_MD_WFL_CATEGORYC, ob_get_contents())); |
||
277 | ob_end_clean(); |
||
278 | |||
279 | // Link description form |
||
280 | // $editor = WfLinksUtility::getWysiwygForm( _MD_WFL_DESCRIPTIONC, 'descriptionb', $descriptionb, 15, 60 ); |
||
281 | // $sform -> addElement($editor,false); |
||
282 | |||
283 | $optionsTrayNote = new XoopsFormElementTray(_MD_WFL_DESCRIPTIONC, '<br>'); |
||
284 | if (class_exists('XoopsFormEditor')) { |
||
285 | $options['name'] = 'descriptionb'; |
||
286 | $options['value'] = $descriptionb; |
||
287 | $options['rows'] = 5; |
||
288 | $options['cols'] = '100%'; |
||
289 | $options['width'] = '100%'; |
||
290 | $options['height'] = '200px'; |
||
291 | $editor = new XoopsFormEditor('', $xoopsModuleConfig['form_optionsuser'], $options, $nohtml = false, $onfailure = 'textarea'); |
||
292 | $optionsTrayNote->addElement($editor); |
||
293 | } else { |
||
294 | $editor = new XoopsFormDhtmlTextArea('', 'descriptionb', $item->getVar('descriptionb', 'e'), '100%', '100%'); |
||
295 | $optionsTrayNote->addElement($editor); |
||
296 | } |
||
297 | |||
298 | $sform->addElement($optionsTrayNote, false); |
||
299 | |||
300 | // Keywords form |
||
301 | $keywords = new XoopsFormTextArea(_MD_WFL_KEYWORDS, 'keywords', $keywords, 7, 60, false); |
||
302 | $keywords->setDescription('<small>' . _MD_WFL_KEYWORDS_NOTE . '</small>'); |
||
303 | $sform->addElement($keywords); |
||
304 | |||
305 | // Insert tags if Tag-module is installed and if user is allowed |
||
306 | View Code Duplication | if ($xoopsModuleConfig['usercantag']) { |
|
307 | if (WfLinksUtility::isTagModuleIncluded()) { |
||
308 | require_once XOOPS_ROOT_PATH . '/modules/tag/include/formtag.php'; |
||
309 | $text_tags = new TagFormTag('item_tag', 70, 255, $link_array['item_tag'], 0); |
||
310 | $sform->addElement($text_tags); |
||
311 | } else { |
||
312 | $sform->addElement(new XoopsFormHidden('item_tag', $link_array['item_tag'])); |
||
313 | } |
||
314 | } |
||
315 | if ($xoopsModuleConfig['useaddress']) { |
||
316 | $sform->insertBreak(_MD_WFL_LINK_CREATEADDRESS, 'even'); |
||
317 | // Google Maps |
||
318 | $googlemap_text = new XoopsFormText('', 'googlemap', 70, 1024, $googlemap); |
||
319 | $googlemap_tray = new XoopsFormElementTray(_MD_WFL_LINK_GOOGLEMAP, ''); |
||
320 | $googlemap_tray->addElement($googlemap_text, false); |
||
321 | $googlemap_tray->addElement(new XoopsFormLabel(" <img src='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/assets/images/icon/google_map.png' onClick=\"window.open(document.storyform.googlemap.value,'','');return(false);\" alt='" . _MD_WFL_LINK_CHECKMAP . "'>")); |
||
322 | $sform->addElement($googlemap_tray); |
||
323 | |||
324 | // Yahoo Maps |
||
325 | $yahoomap_text = new XoopsFormText('', 'yahoomap', 70, 1024, $yahoomap); |
||
326 | $yahoomap_tray = new XoopsFormElementTray(_MD_WFL_LINK_YAHOOMAP, ''); |
||
327 | $yahoomap_tray->addElement($yahoomap_text, false); |
||
328 | $yahoomap_tray->addElement(new XoopsFormLabel(" <img src='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/assets/images/icon/yahoo_map.png' onClick=\"window.open(document.storyform.yahoomap.value,'','');return(false);\" alt='" . _MD_WFL_LINK_CHECKMAP . "'>")); |
||
329 | $sform->addElement($yahoomap_tray); |
||
330 | |||
331 | // Multimap |
||
332 | $multimap_text = new XoopsFormText('', 'multimap', 70, 1024, $multimap); |
||
333 | $multimap_tray = new XoopsFormElementTray(_MD_WFL_LINK_MULTIMAP, ''); |
||
334 | $multimap_tray->addElement($multimap_text, false); |
||
335 | $multimap_tray->addElement(new XoopsFormLabel(" <img src='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/assets/images/icon/multimap.png' onClick=\"window.open(document.storyform.multimap.value,'','');return(false);\" alt='" . _MD_WFL_LINK_CHECKMAP . "'>")); |
||
336 | $sform->addElement($multimap_tray); |
||
337 | |||
338 | // Address forms |
||
339 | $street1 = new XoopsFormText(_MD_WFL_STREET1, 'street1', 70, 255, $street1); |
||
340 | $sform->addElement($street1, false); |
||
341 | $street2 = new XoopsFormText(_MD_WFL_STREET2, 'street2', 70, 255, $street2); |
||
342 | $sform->addElement($street2, false); |
||
343 | $town = new XoopsFormText(_MD_WFL_TOWN, 'town', 70, 255, $town); |
||
344 | $sform->addElement($town, false); |
||
345 | $state = new XoopsFormText(_MD_WFL_STATE, 'state', 70, 255, $state); |
||
346 | $sform->addElement($state, false); |
||
347 | $zip = new XoopsFormText(_MD_WFL_ZIPCODE, 'zip', 25, 25, $zip); |
||
348 | $sform->addElement($zip, false); |
||
349 | $tel = new XoopsFormText(_MD_WFL_TELEPHONE, 'tel', 25, 25, $tel); |
||
350 | $sform->addElement($tel, false); |
||
351 | $mobile = new XoopsFormText(_MD_WFL_MOBILE, 'mobile', 25, 25, $mobile); |
||
352 | $sform->addElement($mobile, false); |
||
353 | $voip = new XoopsFormText(_MD_WFL_VOIP, 'voip', 25, 25, $voip); |
||
354 | $sform->addElement($voip, false); |
||
355 | $fax = new XoopsFormText(_MD_WFL_FAX, 'fax', 25, 25, $fax); |
||
356 | $sform->addElement($fax, false); |
||
357 | $email = new XoopsFormText(_MD_WFL_EMAIL, 'email', 25, 25, $email); |
||
358 | $sform->addElement($email, false); |
||
359 | $vat = new XoopsFormText(_MD_WFL_VAT, 'vat', 25, 25, $vat); |
||
360 | $vat->setDescription(_MD_WFL_VATWIKI); |
||
361 | $sform->addElement($vat, false); |
||
362 | // $sform -> addElement( new XoopsFormHidden( 'vat', $link_array['vat'] ) ); /* If you don't want to use the VAT form, */ |
||
363 | /* use this line and comment-out the 3 lines above */ |
||
364 | } |
||
365 | |||
366 | // Country form |
||
367 | $sform->addElement(new XoopsFormSelectCountry(_MD_WFL_COUNTRY, 'country', $country), false); |
||
368 | |||
369 | $option_tray = new XoopsFormElementTray(_MD_WFL_OPTIONS, '<br>'); |
||
370 | if (!$approve) { |
||
371 | $notify_checkbox = new XoopsFormCheckBox('', 'notifypub'); |
||
372 | $notify_checkbox->addOption(1, _MD_WFL_NOTIFYAPPROVE); |
||
373 | $option_tray->addElement($notify_checkbox); |
||
374 | } else { |
||
375 | $sform->addElement(new XoopsFormHidden('notifypub', 0)); |
||
376 | } |
||
377 | if ($lid > 0 && true === WfLinksUtility::checkGroups($cid, 'WFLinkAppPerm')) { |
||
378 | $approve_checkbox = new XoopsFormCheckBox('', 'approve', $approve); |
||
379 | $approve_checkbox->addOption(1, _MD_WFL_APPROVE); |
||
380 | $option_tray->addElement($approve_checkbox); |
||
381 | } elseif (true === WfLinksUtility::checkGroups($cid, 'WFLinkAutoApp')) { |
||
382 | $sform->addElement(new XoopsFormHidden('approve', 1)); |
||
383 | } else { |
||
384 | $sform->addElement(new XoopsFormHidden('approve', 0)); |
||
385 | } |
||
386 | $sform->addElement($option_tray); |
||
387 | $button_tray = new XoopsFormElementTray('', ''); |
||
388 | $button_tray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
||
389 | $button_tray->addElement(new XoopsFormHidden('lid', $lid)); |
||
390 | $sform->addElement($button_tray); |
||
391 | $sform->display(); |
||
392 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
393 | } |
||
394 | } else { |
||
395 | redirect_header('index.php', 2, _MD_WFL_NOPERMISSIONTOPOST); |
||
396 | } |
||
397 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.