| Conditions | 27 |
| Paths | > 20000 |
| Total Lines | 240 |
| Code Lines | 168 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 43 | function edit($lid = 0) |
||
| 44 | { |
||
| 45 | global $myts, $mytree, $xtubeImageArray; |
||
| 46 | |||
| 47 | $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE lid=' . $lid; |
||
| 48 | if (!$result = $GLOBALS['xoopsDB']->query($sql)) { |
||
|
|
|||
| 49 | $logger = XoopsLogger::getInstance(); |
||
| 50 | $logger->handleError(E_USER_WARNING, $sql, __FILE__, __LINE__); |
||
| 51 | |||
| 52 | return false; |
||
| 53 | } |
||
| 54 | $video_array = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql)); |
||
| 55 | $directory = $GLOBALS['xoopsModuleConfig']['videoimgdir']; |
||
| 56 | $lid = $video_array['lid'] ?? 0; |
||
| 57 | $cid = $video_array['cid'] ?? 0; |
||
| 58 | $title = isset($video_array['title']) ? htmlspecialchars($video_array['title'], ENT_QUOTES | ENT_HTML5) : ''; |
||
| 59 | $vidid = isset($video_array['vidid']) ? htmlspecialchars($video_array['vidid'], ENT_QUOTES | ENT_HTML5) : ''; |
||
| 60 | $picurl = isset($video_array['picurl']) ? htmlspecialchars($video_array['picurl'], ENT_QUOTES | ENT_HTML5) : 'https://'; |
||
| 61 | $publisher = isset($video_array['publisher']) ? htmlspecialchars($video_array['publisher'], ENT_QUOTES | ENT_HTML5) : ''; |
||
| 62 | $screenshot = isset($video_array['screenshot']) ? htmlspecialchars($video_array['screenshot'], ENT_QUOTES | ENT_HTML5) : ''; |
||
| 63 | $descriptionb = isset($video_array['description']) ? htmlspecialchars($video_array['description'], ENT_QUOTES | ENT_HTML5) : ''; |
||
| 64 | $published = $video_array['published'] ?? time(); |
||
| 65 | $expired = $video_array['expired'] ?? 0; |
||
| 66 | $updated = $video_array['updated'] ?? 0; |
||
| 67 | $offline = $video_array['offline'] ?? 0; |
||
| 68 | $vidsource = $video_array['vidsource'] ?? 0; |
||
| 69 | $ipaddress = $video_array['ipaddress'] ?? 0; |
||
| 70 | $notifypub = $video_array['notifypub'] ?? 0; |
||
| 71 | $time = isset($video_array['time']) ? htmlspecialchars($video_array['time'], ENT_QUOTES | ENT_HTML5) : '0:00:00'; |
||
| 72 | $keywords = isset($video_array['keywords']) ? htmlspecialchars($video_array['keywords'], ENT_QUOTES | ENT_HTML5) : ''; |
||
| 73 | $item_tag = isset($video_array['item_tag']) ? htmlspecialchars($video_array['item_tag'], ENT_QUOTES | ENT_HTML5) : ''; |
||
| 74 | |||
| 75 | require_once __DIR__ . '/admin_header.php'; |
||
| 76 | xoops_cp_header(); |
||
| 77 | //renderAdminMenu( _AM_XOOPSTUBE_MVIDEOS ); |
||
| 78 | |||
| 79 | if ($lid) { |
||
| 80 | $_vote_data = Utility::getVoteDetails($lid); |
||
| 81 | $text_info = ' |
||
| 82 | <table width="100%" style="font-size: 90%;"> |
||
| 83 | <tr> |
||
| 84 | <td style="width: 25%; border-right: #E8E8E8 1px solid; vertical-align: top; padding-left: 10px;"> |
||
| 85 | <div><b>' . _AM_XOOPSTUBE_VIDEO_ID . ' </b>' . $lid . '</div> |
||
| 86 | <div><b>' . _AM_XOOPSTUBE_MINDEX_SUBMITTED . ': </b>' . Utility::getTimestamp(formatTimestamp($video_array['date'], $GLOBALS['xoopsModuleConfig']['dateformat'])) . '</div> |
||
| 87 | <div><b>' . _AM_XOOPSTUBE_MOD_MODIFYSUBMITTER . ' </b>' . Utility::getLinkedUserNameFromId($video_array['submitter']) . '</div><div><b>' . _AM_XOOPSTUBE_VIDEO_IP . ' </b>' . $ipaddress . '</div> |
||
| 88 | <div><b>' . _AM_XOOPSTUBE_VIDEO_VIEWS . ' </b>' . $video_array['hits'] . '</div> |
||
| 89 | </td> |
||
| 90 | <td style="width: 25%; border-right: #E8E8E8 1px solid; vertical-align: top; padding-left: 10px;"> |
||
| 91 | <div><b>' . _AM_XOOPSTUBE_VOTE_TOTALRATE . ': </b>' . Request::getInt('rate', 0, 'vote_data') . '</div> |
||
| 92 | <div><b>' . _AM_XOOPSTUBE_VOTE_USERAVG . ': </b>' . (int)round($_vote_data['avg_rate'], 2) . '</div> |
||
| 93 | <div><b>' . _AM_XOOPSTUBE_VOTE_MAXRATE . ': </b>' . Request::getInt('min_rate', 0, 'vote_data') . '</div> |
||
| 94 | <div><b>' . _AM_XOOPSTUBE_VOTE_MINRATE . ': </b>' . Request::getInt('max_rate', 0, 'vote_data') . '</div> |
||
| 95 | </td> |
||
| 96 | <td style="width: 25%; border-right: #E8E8E8 1px solid; vertical-align: top; padding-left: 10px;"> |
||
| 97 | <div><b>' . _AM_XOOPSTUBE_VOTE_MOSTVOTEDTITLE . ': </b>' . Request::getInt('max_title', 0, 'vote_data') . '</div> |
||
| 98 | <div><b>' . _AM_XOOPSTUBE_VOTE_LEASTVOTEDTITLE . ': </b>' . Request::getInt('min_title', 0, 'vote_data') . '</div> |
||
| 99 | <div><b>' . _AM_XOOPSTUBE_VOTE_REGISTERED . ': </b>' . (Request::getInt('rate', 0, 'vote_data') - $_vote_data['null_ratinguser']) . '</div> |
||
| 100 | <div><b>' . _AM_XOOPSTUBE_VOTE_NONREGISTERED . ': </b>' . Request::getInt('null_ratinguser', 0, 'vote_data') . '</div> |
||
| 101 | </td> |
||
| 102 | <td style="width: 25%; vertical-align: top; padding-left: 10px;"> |
||
| 103 | <div>' . xtubeGetVideoThumb($video_array['vidid'], $video_array['title'], $video_array['vidsource'], $video_array['picurl'], $video_array['screenshot']) . '</div> |
||
| 104 | </td> |
||
| 105 | </tr> |
||
| 106 | </table>'; |
||
| 107 | echo ' |
||
| 108 | <fieldset style="border: #E8E8E8 1px solid;"><legend style="display: inline; font-weight: bold; color: #0A3760;">' . _AM_XOOPSTUBE_INFORMATION . '</legend> |
||
| 109 | <div style="padding: 8px;">' . $text_info . '</div> |
||
| 110 | <!-- <div style="padding: 8px;"><li>' . $xtubeImageArray['deleteimg'] . ' ' . _AM_XOOPSTUBE_VOTE_DELETEDSC . '</li></div>\n --> |
||
| 111 | </fieldset> |
||
| 112 | <br>'; |
||
| 113 | } |
||
| 114 | unset($_vote_data); |
||
| 115 | |||
| 116 | $caption = $lid ? _AM_XOOPSTUBE_VIDEO_MODIFYFILE : _AM_XOOPSTUBE_VIDEO_CREATENEWFILE; |
||
| 117 | |||
| 118 | $sform = new \XoopsThemeForm($caption, 'storyform', xoops_getenv('SCRIPT_NAME'), 'post', true); |
||
| 119 | $sform->setExtra('enctype="multipart / form - data"'); |
||
| 120 | |||
| 121 | // Video title |
||
| 122 | $sform->addElement(new \XoopsFormText(_AM_XOOPSTUBE_VIDEO_TITLE, 'title', 70, 255, $title), true); |
||
| 123 | |||
| 124 | // Video source |
||
| 125 | $vidsource_array = [ |
||
| 126 | 0 => _AM_XOOPSTUBE_YOUTUBE, |
||
| 127 | 1 => _AM_XOOPSTUBE_METACAFE, |
||
| 128 | 2 => _AM_XOOPSTUBE_IFILM, |
||
| 129 | 3 => _AM_XOOPSTUBE_PHOTOBUCKET, |
||
| 130 | 4 => _AM_XOOPSTUBE_VIDDLER, |
||
| 131 | 100 => _AM_XOOPSTUBE_GOOGLEVIDEO, |
||
| 132 | 101 => _AM_XOOPSTUBE_MYSPAVETV, |
||
| 133 | 102 => _AM_XOOPSTUBE_DAILYMOTION, |
||
| 134 | 103 => _AM_XOOPSTUBE_BLIPTV, |
||
| 135 | 104 => _AM_XOOPSTUBE_CLIPFISH, |
||
| 136 | 105 => _AM_XOOPSTUBE_LIVELEAK, |
||
| 137 | 106 => _AM_XOOPSTUBE_MAKTOOB, |
||
| 138 | 107 => _AM_XOOPSTUBE_VEOH, |
||
| 139 | 108 => _AM_XOOPSTUBE_VIMEO, |
||
| 140 | 109 => _MD_XOOPSTUBE_MEGAVIDEO, |
||
| 141 | 200 => _MD_XOOPSTUBE_XOOPSTUBE, |
||
| 142 | ]; // #200 is reserved for XoopsTube's internal FLV player |
||
| 143 | $vidsource_select = new \XoopsFormSelect(_AM_XOOPSTUBE_VIDSOURCE, 'vidsource', $vidsource); |
||
| 144 | $vidsource_select->addOptionArray($vidsource_array); |
||
| 145 | $sform->addElement($vidsource_select); |
||
| 146 | |||
| 147 | // Video code |
||
| 148 | $videocode = new \XoopsFormText(_AM_XOOPSTUBE_VIDEO_DLVIDID, 'vidid', 70, 512, $vidid); |
||
| 149 | $videocode->setDescription('<br><span style="font-size: small;">' . _AM_XOOPSTUBE_VIDEO_DLVIDIDDSC . '</span>'); |
||
| 150 | $sform->addElement($videocode, true); |
||
| 151 | $note = _AM_XOOPSTUBE_VIDEO_DLVIDID_NOTE; |
||
| 152 | $sform->addElement(new \XoopsFormLabel('', $note)); |
||
| 153 | |||
| 154 | // Picture url |
||
| 155 | $picurl = new \XoopsFormText(_AM_XOOPSTUBE_VIDEO_PICURL, 'picurl', 70, 255, $picurl); |
||
| 156 | $picurl->setDescription('<br><span style="font-weight: normal;font-size: smaller;">' . _AM_XOOPSTUBE_VIDEO_PICURLNOTE . '</span>'); |
||
| 157 | $sform->addElement($picurl, false); |
||
| 158 | |||
| 159 | // Video publisher |
||
| 160 | $sform->addElement(new \XoopsFormText(_AM_XOOPSTUBE_VIDEO_PUBLISHER, 'publisher', 70, 255, $publisher), true); |
||
| 161 | |||
| 162 | // Time form |
||
| 163 | $timeform = new \XoopsFormText(_AM_XOOPSTUBE_TIME, 'time', 7, 7, $time); |
||
| 164 | $timeform->setDescription('<span style="font-size: small;">(h:mm:ss)</span>'); |
||
| 165 | $sform->addElement($timeform, false); |
||
| 166 | |||
| 167 | // Category menu |
||
| 168 | ob_start(); |
||
| 169 | $mytree->makeMySelBox('title', 'title', $cid, 0); |
||
| 170 | $sform->addElement(new \XoopsFormLabel(_AM_XOOPSTUBE_VIDEO_CATEGORY, ob_get_clean())); |
||
| 171 | |||
| 172 | // Description form |
||
| 173 | // $editor = xtube_getWysiwygForm( _AM_XOOPSTUBE_VIDEO_DESCRIPTION, 'descriptionb', $descriptionb ); |
||
| 174 | // $sform -> addElement( $editor, false ); |
||
| 175 | |||
| 176 | $optionsTrayNote = new \XoopsFormElementTray(_AM_XOOPSTUBE_VIDEO_DESCRIPTION, '<br>'); |
||
| 177 | if (class_exists('XoopsFormEditor')) { |
||
| 178 | $options['name'] = 'descriptionb'; |
||
| 179 | $options['value'] = $descriptionb; |
||
| 180 | $options['rows'] = 5; |
||
| 181 | $options['cols'] = '100%'; |
||
| 182 | $options['width'] = '100%'; |
||
| 183 | $options['height'] = '200px'; |
||
| 184 | $descriptionb = new \XoopsFormEditor('', $GLOBALS['xoopsModuleConfig']['form_options'], $options, $nohtml = false, $onfailure = 'textarea'); |
||
| 185 | $optionsTrayNote->addElement($descriptionb); |
||
| 186 | } else { |
||
| 187 | $descriptionb = new \XoopsFormDhtmlTextArea('', 'descriptionb', $item->getVar('descriptionb', 'e'), '100%', '100%'); |
||
| 188 | $optionsTrayNote->addElement($descriptionb); |
||
| 189 | } |
||
| 190 | |||
| 191 | $sform->addElement($optionsTrayNote, false); |
||
| 192 | |||
| 193 | // Meta keywords form |
||
| 194 | $keywords = new \XoopsFormTextArea(_AM_XOOPSTUBE_KEYWORDS, 'keywords', $keywords, 7, 60, false); |
||
| 195 | $keywords->setDescription("<br><br><br><br><span style='font-size: smaller;'>" . _AM_XOOPSTUBE_KEYWORDS_NOTE . '</span>'); |
||
| 196 | $sform->addElement($keywords); |
||
| 197 | |||
| 198 | // Insert tags if Tag-module is installed |
||
| 199 | if (isset($video_array['item_tag'])) { |
||
| 200 | if (Utility::isModuleTagInstalled()) { |
||
| 201 | require_once XOOPS_ROOT_PATH . '/modules/tag/include/formtag.php'; |
||
| 202 | $text_tags = new FormTag('item_tag', 70, 255, $video_array['item_tag'], 0); |
||
| 203 | $sform->addElement($text_tags); |
||
| 204 | } else { |
||
| 205 | $sform->addElement(new \XoopsFormHidden('item_tag', $video_array['item_tag'])); |
||
| 206 | } |
||
| 207 | } |
||
| 208 | |||
| 209 | // Video Publish Date |
||
| 210 | $sform->addElement(new \XoopsFormDateTime(_AM_XOOPSTUBE_VIDEO_SETPUBLISHDATE, 'published', $size = 15, $published)); |
||
| 211 | |||
| 212 | if ($lid) { |
||
| 213 | $sform->addElement(new \XoopsFormHidden('was_published', $published)); |
||
| 214 | $sform->addElement(new \XoopsFormHidden('was_expired', $expired)); |
||
| 215 | } |
||
| 216 | |||
| 217 | // Video Expire Date |
||
| 218 | $isexpired = ($expired > time()) ? 1 : 0; |
||
| 219 | $expiredates = ($expired > time()) ? _AM_XOOPSTUBE_VIDEO_EXPIREDATESET . Utility::getTimestamp(formatTimestamp($expired, $GLOBALS['xoopsModuleConfig']['dateformat'])) : _AM_XOOPSTUBE_VIDEO_SETDATETIMEEXPIRE; |
||
| 220 | $warning = ($published > $expired && $expired > time()) ? _AM_XOOPSTUBE_VIDEO_EXPIREWARNING : ''; |
||
| 221 | $expiredate_checkbox = new \XoopsFormCheckBox('', 'expiredateactivate', $isexpired); |
||
| 222 | $expiredate_checkbox->addOption(1, $expiredates . ' <br> <br> '); |
||
| 223 | |||
| 224 | $expiredate_tray = new \XoopsFormElementTray(_AM_XOOPSTUBE_VIDEO_EXPIREDATE . $warning, ''); |
||
| 225 | $expiredate_tray->addElement($expiredate_checkbox); |
||
| 226 | $expiredate_tray->addElement(new \XoopsFormDateTime(_AM_XOOPSTUBE_VIDEO_SETEXPIREDATE . ' <br> ', 'expired', 15, $expired)); |
||
| 227 | $expiredate_tray->addElement(new \XoopsFormRadioYN(_AM_XOOPSTUBE_VIDEO_CLEAREXPIREDATE, 'clearexpire', 0, ' ' . _YES . '', ' ' . _NO . '')); |
||
| 228 | $sform->addElement($expiredate_tray); |
||
| 229 | |||
| 230 | // Set video offline yes/no |
||
| 231 | $videostatus_radio = new \XoopsFormRadioYN(_AM_XOOPSTUBE_VIDEO_FILESSTATUS, 'offline', $offline, ' ' . _YES . '', ' ' . _NO . ''); |
||
| 232 | $sform->addElement($videostatus_radio); |
||
| 233 | |||
| 234 | // Set video status as updated yes/no |
||
| 235 | $up_dated = (0 == $updated) ? 0 : 1; |
||
| 236 | $video_updated_radio = new \XoopsFormRadioYN(_AM_XOOPSTUBE_VIDEO_SETASUPDATED, 'up_dated', $up_dated, ' ' . _YES . '', ' ' . _NO . ''); |
||
| 237 | $sform->addElement($video_updated_radio); |
||
| 238 | |||
| 239 | $result = $GLOBALS['xoopsDB']->query('SELECT COUNT( * ) FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_broken') . ' WHERE lid = ' . $lid); |
||
| 240 | [$broken_count] = $GLOBALS['xoopsDB']->fetchRow($result); |
||
| 241 | if ($broken_count > 0) { |
||
| 242 | $video_updated_radio = new \XoopsFormRadioYN(_AM_XOOPSTUBE_VIDEO_DELEDITMESS, 'delbroken', 1, ' ' . _YES . '', ' ' . _NO . ''); |
||
| 243 | $sform->addElement($editmess_radio); |
||
| 244 | } |
||
| 245 | |||
| 246 | if ($lid && 0 == $published) { |
||
| 247 | $approved = (0 == $published) ? 0 : 1; |
||
| 248 | $approve_checkbox = new \XoopsFormCheckBox(_AM_XOOPSTUBE_VIDEO_EDITAPPROVE, 'approved', 1); |
||
| 249 | $approve_checkbox->addOption(1, ' '); |
||
| 250 | $sform->addElement($approve_checkbox); |
||
| 251 | } |
||
| 252 | |||
| 253 | if (!$lid) { |
||
| 254 | $buttonTray = new \XoopsFormElementTray('', ''); |
||
| 255 | $buttonTray->addElement(new \XoopsFormHidden('status', 1)); |
||
| 256 | $buttonTray->addElement(new \XoopsFormHidden('notifypub', $notifypub)); |
||
| 257 | $buttonTray->addElement(new \XoopsFormHidden('op', 'save')); |
||
| 258 | $buttonTray->addElement(new \XoopsFormButton('', '', _AM_XOOPSTUBE_BSAVE, 'submit')); |
||
| 259 | $sform->addElement($buttonTray); |
||
| 260 | } else { |
||
| 261 | $buttonTray = new \XoopsFormElementTray('', ''); |
||
| 262 | $buttonTray->addElement(new \XoopsFormHidden('lid', $lid)); |
||
| 263 | $buttonTray->addElement(new \XoopsFormHidden('status', 2)); |
||
| 264 | $hidden = new \XoopsFormHidden('op', 'save'); |
||
| 265 | $buttonTray->addElement($hidden); |
||
| 266 | |||
| 267 | $butt_dup = new \XoopsFormButton('', '', _AM_XOOPSTUBE_BMODIFY, 'submit'); |
||
| 268 | $butt_dup->setExtra('onclick="this . form . elements . op . value = \'save\'"'); |
||
| 269 | $buttonTray->addElement($butt_dup); |
||
| 270 | $butt_dupct = new \XoopsFormButton('', '', _AM_XOOPSTUBE_BDELETE, 'submit'); |
||
| 271 | $butt_dupct->setExtra('onclick="this.form.elements.op.value=\'delete\'"'); |
||
| 272 | $buttonTray->addElement($butt_dupct); |
||
| 273 | $butt_dupct2 = new \XoopsFormButton('', '', _AM_XOOPSTUBE_BCANCEL, 'submit'); |
||
| 274 | $butt_dupct2->setExtra('onclick="this.form.elements.op.value=\'videosConfigMenu\'"'); |
||
| 275 | $buttonTray->addElement($butt_dupct2); |
||
| 276 | $sform->addElement($buttonTray); |
||
| 277 | } |
||
| 278 | $sform->display(); |
||
| 279 | unset($hidden); |
||
| 280 | require_once __DIR__ . '/admin_footer.php'; |
||
| 281 | |||
| 282 | return null; |
||
| 283 | } |
||
| 665 |