XoopsModules25x /
tdmdownloads
| 1 | <?php declare(strict_types=1); |
||
| 2 | |||
| 3 | /** |
||
| 4 | * TDMDownload |
||
| 5 | * |
||
| 6 | * You may not change or alter any portion of this comment or credits |
||
| 7 | * of supporting developers from this source code or any supporting source code |
||
| 8 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 9 | * This program is distributed in the hope that it will be useful, |
||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 12 | * |
||
| 13 | * @copyright Gregory Mage (Aka Mage) |
||
| 14 | * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
||
| 15 | * @author Gregory Mage (Aka Mage) |
||
| 16 | */ |
||
| 17 | |||
| 18 | use Xmf\Database\TableLoad; |
||
| 19 | use Xmf\Database\Tables; |
||
| 20 | use Xmf\Module\Admin; |
||
| 21 | |||
| 22 | require __DIR__ . '/admin_header.php'; |
||
| 23 | xoops_cp_header(); |
||
| 24 | |||
| 25 | // Template |
||
| 26 | $templateMain = 'tdmdownloads_admin_import.tpl'; |
||
| 27 | |||
| 28 | $adminObject = Admin::getInstance(); |
||
| 29 | |||
| 30 | //Action dans switch |
||
| 31 | $op = 'index'; |
||
| 32 | if (\Xmf\Request::hasVar('op', 'REQUEST')) { |
||
| 33 | $op = \Xmf\Request::getCmd('op', '', 'REQUEST'); |
||
| 34 | } |
||
| 35 | |||
| 36 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); |
||
| 37 | |||
| 38 | // import depuis mydownloads |
||
| 39 | /** |
||
| 40 | * @param string $path |
||
| 41 | * @param string $imgurl |
||
| 42 | */ |
||
| 43 | function importMydownloads($path = '', $imgurl = '') |
||
| 44 | { |
||
| 45 | $moduleDirName = basename(dirname(__DIR__)); |
||
| 46 | |||
| 47 | $ok = \Xmf\Request::getInt('ok', 0, 'POST'); |
||
| 48 | |||
| 49 | global $xoopsDB; |
||
| 50 | |||
| 51 | if (1 === $ok) { |
||
| 52 | //Vider les tables |
||
| 53 | |||
| 54 | $myTables = ['tdmdownloads_broken', 'tdmdownloads_cat', 'tdmdownloads_downloads', 'tdmdownloads_fielddata', 'tdmdownloads_modfielddata', 'tdmdownloads_votedata']; |
||
| 55 | |||
| 56 | $table = new TableLoad(); |
||
| 57 | |||
| 58 | $tables = new Tables(); |
||
| 59 | |||
| 60 | foreach ($myTables as $myTable) { |
||
| 61 | if ($tables->useTable($myTable)) { // if this returns false, there is no table |
||
| 62 | $table::truncateTable($myTable); |
||
| 63 | } |
||
| 64 | } |
||
| 65 | |||
| 66 | //Inserer les données des catégories |
||
| 67 | |||
| 68 | $query_topic = $xoopsDB->query('SELECT cid, pid, title, imgurl FROM ' . $xoopsDB->prefix('mydownloads_cat')); |
||
| 69 | |||
| 70 | while (false !== ($donnees = $xoopsDB->fetchArray($query_topic))) { |
||
| 71 | if ('' === $donnees['imgurl']) { |
||
| 72 | $img = 'blank.gif'; |
||
| 73 | } else { |
||
| 74 | $img = substr_replace($donnees['imgurl'], '', 0, mb_strlen($imgurl)); |
||
| 75 | |||
| 76 | @copy($path . $img, XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/cats/' . $img); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 77 | } |
||
| 78 | |||
| 79 | $title = $donnees['title']; |
||
| 80 | |||
| 81 | $insert = $xoopsDB->queryF('INSERT INTO ' . $xoopsDB->prefix('tdmdownloads_cat') . " (cat_cid, cat_pid, cat_title, cat_imgurl, cat_description_main, cat_weight ) VALUES ('" . $donnees['cid'] . "', '" . $donnees['pid'] . "', '" . $title . "', '" . $img . "', '', '0')"); |
||
| 82 | |||
| 83 | if (!$insert) { |
||
| 84 | $errors[] = ['title' => _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA, 'info' => $donnees['title']]; |
||
| 85 | } |
||
| 86 | |||
| 87 | $successes[] = sprintf(_AM_TDMDOWNLOADS_IMPORT_CAT_IMP, $donnees['title']); |
||
| 88 | } |
||
| 89 | |||
| 90 | echo '<br>'; |
||
| 91 | |||
| 92 | //Inserer les données des téléchargemnts |
||
| 93 | |||
| 94 | $query_links = $xoopsDB->query('SELECT lid, cid, title, url, homepage, version, size, platform, logourl, submitter, status, date, hits, rating, votes, comments FROM ' . $xoopsDB->prefix('mydownloads_downloads')); |
||
| 95 | |||
| 96 | while (false !== ($donnees = $xoopsDB->fetchArray($query_links))) { |
||
| 97 | //On recupere la description |
||
| 98 | |||
| 99 | $requete = $xoopsDB->queryF('SELECT description FROM ' . $xoopsDB->prefix('mydownloads_text') . " WHERE lid = '" . $donnees['lid'] . "'"); |
||
| 100 | |||
| 101 | [$description] = $xoopsDB->fetchRow($requete); |
||
| 102 | |||
| 103 | $insert = $xoopsDB->queryF( |
||
| 104 | 'INSERT INTO ' |
||
| 105 | . $xoopsDB->prefix('tdmdownloads_downloads') |
||
| 106 | . " ( |
||
| 107 | lid, cid, title, url, homepage, version, size, platform, description, logourl, submitter, status, date, hits, rating, votes, comments, top) VALUES |
||
| 108 | ('" |
||
| 109 | . $donnees['lid'] |
||
| 110 | . "', '" |
||
| 111 | . $donnees['cid'] |
||
| 112 | . "', '" |
||
| 113 | . $donnees['title'] |
||
| 114 | . "', '" |
||
| 115 | . $donnees['url'] |
||
| 116 | . "', '" |
||
| 117 | . $donnees['homepage'] |
||
| 118 | . "', '" |
||
| 119 | . $donnees['version'] |
||
| 120 | . "', '" |
||
| 121 | . $donnees['size'] |
||
| 122 | . "', '" |
||
| 123 | . $donnees['platform'] |
||
| 124 | . "', '" |
||
| 125 | . $description |
||
| 126 | . "', '" |
||
| 127 | . $donnees['logourl'] |
||
| 128 | . "', '" |
||
| 129 | . $donnees['submitter'] |
||
| 130 | . "', '" |
||
| 131 | . $donnees['status'] |
||
| 132 | . "', '" |
||
| 133 | . $donnees['date'] |
||
| 134 | . "', '" |
||
| 135 | . $donnees['hits'] |
||
| 136 | . "', '" |
||
| 137 | . $donnees['rating'] |
||
| 138 | . "', '" |
||
| 139 | . $donnees['votes'] |
||
| 140 | . "', '0', '0' )" |
||
| 141 | ); |
||
| 142 | |||
| 143 | if (!$insert) { |
||
| 144 | $errors[] = ['title' => _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA, 'info' => $donnees['title']]; |
||
| 145 | } |
||
| 146 | |||
| 147 | $successes[] = sprintf(_AM_TDMDOWNLOADS_IMPORT_DOWNLOADS_IMP, $donnees['title']); |
||
| 148 | |||
| 149 | @copy($path . $donnees['logourl'], XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/shots/' . $donnees['logourl']); |
||
| 150 | } |
||
| 151 | |||
| 152 | echo '<br>'; |
||
| 153 | |||
| 154 | //Inserer les données des votes |
||
| 155 | |||
| 156 | $query_vote = $xoopsDB->query('SELECT ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp FROM ' . $xoopsDB->prefix('mydownloads_votedata')); |
||
| 157 | |||
| 158 | while (false !== ($donnees = $xoopsDB->fetchArray($query_vote))) { |
||
| 159 | $insert = $xoopsDB->queryF( |
||
| 160 | 'INSERT INTO ' |
||
| 161 | . $xoopsDB->prefix('tdmdownloads_votedata') |
||
| 162 | . " (ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp ) VALUES ('" |
||
| 163 | . $donnees['ratingid'] |
||
| 164 | . "', '" |
||
| 165 | . $donnees['lid'] |
||
| 166 | . "', '" |
||
| 167 | . $donnees['ratinguser'] |
||
| 168 | . "', '" |
||
| 169 | . $donnees['rating'] |
||
| 170 | . "', '" |
||
| 171 | . $donnees['ratinghostname'] |
||
| 172 | . "', '" |
||
| 173 | . $donnees['ratingtimestamp'] |
||
| 174 | . "')" |
||
| 175 | ); |
||
| 176 | |||
| 177 | if (!$insert) { |
||
| 178 | $errors[] = ['title' => _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA, 'info' => $donnees['ratingid']]; |
||
| 179 | } |
||
| 180 | |||
| 181 | $successes[] = sprintf(_AM_TDMDOWNLOADS_IMPORT_VOTE_IMP, $donnees['ratingid']); |
||
| 182 | } |
||
| 183 | |||
| 184 | echo '<br><br>'; |
||
| 185 | |||
| 186 | echo "<div class='errorMsg'>"; |
||
| 187 | |||
| 188 | echo _AM_TDMDOWNLOADS_IMPORT_OK; |
||
| 189 | |||
| 190 | echo '</div>'; |
||
| 191 | } else { |
||
| 192 | xoops_confirm(['op' => 'importMydownloads', 'ok' => 1, 'path' => $path, 'imgurl' => $imgurl], 'import.php', _AM_TDMDOWNLOADS_IMPORT_CONF_MYDOWNLOADS . '<br>'); |
||
| 193 | } |
||
| 194 | } |
||
| 195 | |||
| 196 | // import depuis WF-Downloads |
||
| 197 | /** |
||
| 198 | * @param string $shots |
||
| 199 | * @param string $catimg |
||
| 200 | */ |
||
| 201 | function importWfdownloads($shots = '', $catimg = '') |
||
| 202 | { |
||
| 203 | $moduleDirName = basename(dirname(__DIR__)); |
||
| 204 | |||
| 205 | $ok = \Xmf\Request::getInt('ok', 0, 'POST'); |
||
| 206 | |||
| 207 | global $xoopsDB; |
||
| 208 | |||
| 209 | if (1 === $ok) { |
||
| 210 | //Vider les tables |
||
| 211 | |||
| 212 | $myTables = ['tdmdownloads_broken', 'tdmdownloads_cat', 'tdmdownloads_downloads', 'tdmdownloads_fielddata', 'tdmdownloads_modfielddata', 'tdmdownloads_votedata']; |
||
| 213 | |||
| 214 | $table = new TableLoad(); |
||
| 215 | |||
| 216 | $tables = new Tables(); |
||
| 217 | |||
| 218 | foreach ($myTables as $myTable) { |
||
| 219 | if ($tables->useTable($myTable)) { // if this returns false, there is no table |
||
| 220 | $table::truncateTable($myTable); |
||
| 221 | } |
||
| 222 | } |
||
| 223 | |||
| 224 | //Inserer les données des catégories |
||
| 225 | |||
| 226 | $query_topic = $xoopsDB->query('SELECT cid, pid, title, imgurl, description, total, summary, spotlighttop, spotlighthis, dohtml, dosmiley, doxcode, doimage, dobr, weight, formulize_fid FROM ' . $xoopsDB->prefix('wfdownloads_cat')); |
||
| 227 | |||
| 228 | while (false !== ($donnees = $xoopsDB->fetchArray($query_topic))) { |
||
| 229 | if ('' === $donnees['imgurl']) { |
||
| 230 | $img = 'blank.gif'; |
||
| 231 | } else { |
||
| 232 | $img = $donnees['imgurl']; |
||
| 233 | |||
| 234 | @copy($catimg . $img, XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/cats/' . $img); |
||
| 235 | } |
||
| 236 | |||
| 237 | $insert = $xoopsDB->queryF( |
||
| 238 | 'INSERT INTO ' . $xoopsDB->prefix('tdmdownloads_cat') . " (cat_cid, cat_pid, cat_title, cat_imgurl, cat_description_main, cat_weight ) VALUES ('" . $donnees['cid'] . "', '" . $donnees['pid'] . "', '" . addcslashes($donnees['title'], "'") . "', '" . $img . "', '" . addcslashes( |
||
| 239 | $donnees['description'], |
||
| 240 | "'" |
||
| 241 | ) . "', '" . $donnees['weight'] . "')" |
||
| 242 | ); |
||
| 243 | |||
| 244 | if (!$insert) { |
||
| 245 | $errors[] = ['title' => _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA, 'info' => $donnees['title']]; |
||
| 246 | } |
||
| 247 | |||
| 248 | $successes[] = sprintf(_AM_TDMDOWNLOADS_IMPORT_CAT_IMP, $donnees['title']); |
||
| 249 | } |
||
| 250 | |||
| 251 | echo '<br>'; |
||
| 252 | |||
| 253 | //Inserer les données des téléchargemnts |
||
| 254 | |||
| 255 | $query_links = $xoopsDB->query( |
||
| 256 | 'SELECT lid, cid, title, url, filename, filetype, homepage, version, size, platform, screenshot, screenshot2, screenshot3, screenshot4, submitter, publisher, status, date, hits, rating, votes, comments, license, mirror, price, paypalemail, features, requirements, homepagetitle, forumid, limitations, versiontypes, dhistory, published, expired, updated, offline, summary, description, ipaddress, notifypub, formulize_idreq FROM ' |
||
| 257 | . $xoopsDB->prefix('wfdownloads_downloads') |
||
| 258 | ); |
||
| 259 | |||
| 260 | while (false !== ($donnees = $xoopsDB->fetchArray($query_links))) { |
||
| 261 | if ('' === $donnees['url']) { |
||
| 262 | $newurl = XOOPS_URL . '/uploads/' . $donnees['filename']; |
||
| 263 | } else { |
||
| 264 | $newurl = $donnees['url']; |
||
| 265 | } |
||
| 266 | |||
| 267 | $insert = $xoopsDB->queryF( |
||
| 268 | 'INSERT INTO ' . $xoopsDB->prefix('tdmdownloads_downloads') . " ( |
||
| 269 | lid, cid, title, url, homepage, version, size, platform, description, logourl, submitter, status, date, hits, rating, votes, comments, top) VALUES |
||
| 270 | ('" . $donnees['lid'] . "', '" . $donnees['cid'] . "', '" . addcslashes($donnees['title'], "'") . "', '" . $newurl . "', '" . $donnees['homepage'] . "', '" . $donnees['version'] . "', '" . $donnees['size'] . "', '" . $donnees['platform'] . "', '" . addcslashes( |
||
| 271 | $donnees['description'], |
||
| 272 | "'" |
||
| 273 | ) . "', '" . $donnees['screenshot'] . "', '" . $donnees['submitter'] . "', '" . $donnees['status'] . "', '" . $donnees['date'] . "', '" . $donnees['hits'] . "', '" . $donnees['rating'] . "', '" . $donnees['votes'] . "', '0', '0' )" |
||
| 274 | ); |
||
| 275 | |||
| 276 | if (!$insert) { |
||
| 277 | $errors[] = ['title' => _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA, 'info' => $donnees['title']]; |
||
| 278 | } |
||
| 279 | |||
| 280 | $successes[] = sprintf(_AM_TDMDOWNLOADS_IMPORT_DOWNLOADS_IMP, $donnees['title']); |
||
| 281 | |||
| 282 | @copy($shots . $donnees['screenshot'], XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/shots/' . $donnees['screenshot']); |
||
| 283 | } |
||
| 284 | |||
| 285 | echo '<br>'; |
||
| 286 | |||
| 287 | //Inserer les données des votes |
||
| 288 | |||
| 289 | $query_vote = $xoopsDB->query('SELECT ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp FROM ' . $xoopsDB->prefix('wfdownloads_votedata')); |
||
| 290 | |||
| 291 | while (false !== ($donnees = $xoopsDB->fetchArray($query_vote))) { |
||
| 292 | $insert = $xoopsDB->queryF( |
||
| 293 | 'INSERT INTO ' |
||
| 294 | . $xoopsDB->prefix('tdmdownloads_votedata') |
||
| 295 | . " (ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp ) VALUES ('" |
||
| 296 | . $donnees['ratingid'] |
||
| 297 | . "', '" |
||
| 298 | . $donnees['lid'] |
||
| 299 | . "', '" |
||
| 300 | . $donnees['ratinguser'] |
||
| 301 | . "', '" |
||
| 302 | . $donnees['rating'] |
||
| 303 | . "', '" |
||
| 304 | . $donnees['ratinghostname'] |
||
| 305 | . "', '" |
||
| 306 | . $donnees['ratingtimestamp'] |
||
| 307 | . "')" |
||
| 308 | ); |
||
| 309 | |||
| 310 | if (!$insert) { |
||
| 311 | echo '<span style="color: #ff0000; ">' . _AM_TDMDOWNLOADS_IMPORT_ERROR_DATA . ': </span> ' . $donnees['ratingid'] . '<br>'; |
||
| 312 | } |
||
| 313 | |||
| 314 | echo sprintf(_AM_TDMDOWNLOADS_IMPORT_VOTE_IMP . '<br>', $donnees['ratingid']); |
||
| 315 | } |
||
| 316 | |||
| 317 | $successes[] = _AM_TDMDOWNLOADS_IMPORT_OK; |
||
| 318 | |||
| 319 | $GLOBALS['xoopsTpl']->assign('successes', $successes); |
||
| 320 | |||
| 321 | $GLOBALS['xoopsTpl']->assign('errors', $errors); |
||
| 322 | } else { |
||
| 323 | xoops_confirm(['op' => 'importWfdownloads', 'ok' => 1, 'shots' => $shots, 'catimg' => $catimg], 'import.php', _AM_TDMDOWNLOADS_IMPORT_CONF_WFDOWNLOADS . '<br>'); |
||
| 324 | } |
||
| 325 | } |
||
| 326 | |||
| 327 | switch ($op) { |
||
| 328 | case 'index': |
||
| 329 | default: |
||
| 330 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_IMPORT_MYDOWNLOADS, 'import.php?op=form_mydownloads', 'add'); |
||
| 331 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_IMPORT_WFDOWNLOADS, 'import.php?op=form_wfdownloads', 'add'); |
||
| 332 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('center')); |
||
| 333 | $GLOBALS['xoopsTpl']->assign('intro', true); |
||
| 334 | break; |
||
| 335 | // import Mydownloads |
||
| 336 | case 'importMydownloads': |
||
| 337 | if ('' == \Xmf\Request::getString('path', '', 'REQUEST') || '' == \Xmf\Request::getString('imgurl', '', 'REQUEST')) { |
||
| 338 | redirect_header('import.php?op=form_mydownloads', 3, _AM_TDMDOWNLOADS_IMPORT_ERREUR); |
||
| 339 | } else { |
||
| 340 | importMydownloads(\Xmf\Request::getString('path', '', 'REQUEST'), \Xmf\Request::getString('imgurl', '', 'REQUEST')); |
||
| 341 | } |
||
| 342 | break; |
||
| 343 | case 'form_mydownloads': |
||
| 344 | // Get Theme Form |
||
| 345 | xoops_load('XoopsFormLoader'); |
||
| 346 | $form = new \XoopsThemeForm(_AM_TDMDOWNLOADS_IMPORT_MYDOWNLOADS, 'form_mydownloads', 'import.php', 'post', true); |
||
| 347 | $form->setExtra('enctype="multipart/form-data"'); |
||
| 348 | // Form number |
||
| 349 | $counter = 0; |
||
| 350 | $check = '<ul>'; |
||
| 351 | |||
| 352 | global $xoopsDB; |
||
| 353 | $sql = $xoopsDB->query('SELECT COUNT(lid) AS count FROM ' . $xoopsDB->prefix('mydownloads_downloads')); |
||
| 354 | [$count_downloads] = $xoopsDB->fetchRow($sql); |
||
| 355 | if ($count_downloads < 1) { |
||
| 356 | $check .= '<li>' . _AM_TDMDOWNLOADS_IMPORT_DONT_DOWNLOADS . '</li>'; |
||
| 357 | } else { |
||
| 358 | $check .= '<li>' . sprintf(_AM_TDMDOWNLOADS_IMPORT_NB_DOWNLOADS, $count_downloads) . '</li>'; |
||
| 359 | |||
| 360 | $counter++; |
||
| 361 | } |
||
| 362 | $sql = $xoopsDB->query('SELECT COUNT(cid) AS count FROM ' . $xoopsDB->prefix('mydownloads_cat')); |
||
| 363 | [$count_topic] = $xoopsDB->fetchRow($sql); |
||
| 364 | |||
| 365 | if ($count_topic < 1) { |
||
| 366 | $check .= '<li>' . _AM_TDMDOWNLOADS_IMPORT_DONT_TOPIC . '</li>'; |
||
| 367 | } else { |
||
| 368 | $check .= '<li>' . sprintf('<br>' . _AM_TDMDOWNLOADS_IMPORT_NB_CAT, $count_topic) . '</li>'; |
||
| 369 | |||
| 370 | $counter++; |
||
| 371 | } |
||
| 372 | $check .= '</ul>'; |
||
| 373 | $form->addElement(new \XoopsFormLabel(_AM_TDMDOWNLOADS_IMPORT_NUMBER, $check)); |
||
| 374 | // Form path |
||
| 375 | $form->addElement(new \XoopsFormText(_AM_TDMDOWNLOADS_IMPORT_MYDOWNLOADS_PATH, 'path', 100, 255, XOOPS_ROOT_PATH . '/modules/mydownloads/images/shots/')); |
||
| 376 | // Form url |
||
| 377 | $form->addElement(new \XoopsFormText(_AM_TDMDOWNLOADS_IMPORT_MYDOWNLOADS_URL, 'path', 100, 255, XOOPS_URL . '/modules/mydownloads/images/shots/')); |
||
| 378 | // To execute |
||
| 379 | if ($counter > 0) { |
||
| 380 | $form->addElement(new \XoopsFormHidden('op', 'import_mydownloads')); |
||
| 381 | |||
| 382 | $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); |
||
| 383 | } else { |
||
| 384 | $form->addElement(new \XoopsFormHidden('op', 'cancel')); |
||
| 385 | |||
| 386 | $form->addElement(new \XoopsFormButton('', 'submit', _CANCEL, 'submit')); |
||
| 387 | } |
||
| 388 | $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); |
||
| 389 | |||
| 390 | break; |
||
| 391 | // import WF-Downloads |
||
| 392 | case 'importWfdownloads': |
||
| 393 | if ('' === \Xmf\Request::getString('shots') || '' === \Xmf\Request::getString('catimg')) { |
||
| 394 | redirect_header('import.php?op=form_wfdownloads', 3, _AM_TDMDOWNLOADS_IMPORT_ERREUR); |
||
| 395 | } else { |
||
| 396 | importWfdownloads(\Xmf\Request::getString('shots'), \Xmf\Request::getString('catimg')); |
||
| 397 | } |
||
| 398 | break; |
||
| 399 | case 'form_wfdownloads': |
||
| 400 | global $xoopsDB; |
||
| 401 | // Get Theme Form |
||
| 402 | xoops_load('XoopsFormLoader'); |
||
| 403 | $form = new \XoopsThemeForm(_AM_TDMDOWNLOADS_IMPORT_MYDOWNLOADS, 'form_mydownloads', 'import.php', 'post', true); |
||
| 404 | $form->setExtra('enctype="multipart/form-data"'); |
||
| 405 | // Form number |
||
| 406 | $counter = 0; |
||
| 407 | $check = '<ul>'; |
||
| 408 | |||
| 409 | $sql = $xoopsDB->query('SELECT COUNT(lid) AS count FROM ' . $xoopsDB->prefix('wfdownloads_downloads')); |
||
| 410 | [$count_downloads] = $xoopsDB->fetchRow($sql); |
||
| 411 | if ($count_downloads < 1) { |
||
| 412 | $check .= '<li>' . _AM_TDMDOWNLOADS_IMPORT_DONT_DOWNLOADS . '</li>'; |
||
| 413 | } else { |
||
| 414 | $check .= '<li>' . sprintf(_AM_TDMDOWNLOADS_IMPORT_NB_DOWNLOADS, $count_downloads) . '</li>'; |
||
| 415 | |||
| 416 | $counter++; |
||
| 417 | } |
||
| 418 | $sql = $xoopsDB->query('SELECT COUNT(cid) AS count FROM ' . $xoopsDB->prefix('wfdownloads_cat')); |
||
| 419 | [$count_topic] = $xoopsDB->fetchRow($sql); |
||
| 420 | if ($count_topic < 1) { |
||
| 421 | $check .= '<li>' . _AM_TDMDOWNLOADS_IMPORT_DONT_TOPIC . '</li>'; |
||
| 422 | } else { |
||
| 423 | $check .= '<li>' . sprintf('<br>' . _AM_TDMDOWNLOADS_IMPORT_NB_CAT, $count_topic) . '</li>'; |
||
| 424 | |||
| 425 | $counter++; |
||
| 426 | } |
||
| 427 | $check .= '</ul>'; |
||
| 428 | $form->addElement(new \XoopsFormLabel(_AM_TDMDOWNLOADS_IMPORT_NUMBER, $check)); |
||
| 429 | // Form path |
||
| 430 | $form->addElement(new \XoopsFormText(_AM_TDMDOWNLOADS_IMPORT_WFDOWNLOADS_SHOTS, 'path', 100, 255, XOOPS_ROOT_PATH . '/modules/wfdownloads/assets/images/screenshots/')); |
||
| 431 | // Form url |
||
| 432 | $form->addElement(new \XoopsFormText(_AM_TDMDOWNLOADS_IMPORT_WFDOWNLOADS_CATIMG, 'catimg', 100, 255, XOOPS_ROOT_PATH . '/modules/wfdownloads/assets/images/category/')); |
||
| 433 | // To execute |
||
| 434 | if ($counter > 0) { |
||
| 435 | $form->addElement(new \XoopsFormHidden('op', 'import_mydownloads')); |
||
| 436 | |||
| 437 | $form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); |
||
| 438 | } else { |
||
| 439 | $form->addElement(new \XoopsFormHidden('op', 'cancel')); |
||
| 440 | |||
| 441 | $form->addElement(new \XoopsFormButton('', 'submit', _CANCEL, 'submit')); |
||
| 442 | } |
||
| 443 | $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); |
||
| 444 | |||
| 445 | break; |
||
| 446 | } |
||
| 447 | |||
| 448 | require __DIR__ . '/admin_footer.php'; |
||
| 449 |