|
| 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 | + * tdmcreate module |
| 13 | + * |
| 14 | + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ |
| 15 | + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
| 16 | + * @package tdmcreate |
| 17 | + * @since 2.5.5 |
| 18 | + * @author Txmod Xoops <[email protected]> |
| 19 | + * @version $Id: 1.59 morefiles.php 11297 2013-03-24 10:58:10Z timgno $ |
| 20 | + */ |
| 21 | +include __DIR__ . '/header.php'; |
| 22 | +// Recovered value of argument op in the URL $ |
| 23 | +$op = XoopsRequest::getString('op', 'list'); |
| 24 | +// |
| 25 | +$fileId = XoopsRequest::getInt('file_id'); |
| 26 | +// |
| 27 | +switch ($op) { |
| 28 | + case 'list': |
| 29 | + default: |
| 30 | + $start = XoopsRequest::getInt('start', 0); |
| 31 | + $limit = XoopsRequest::getInt('limit', $tdmcreate->getConfig('morefiles_adminpager')); |
| 32 | + // Define main template |
| 33 | + $templateMain = 'tdmcreate_morefiles.tpl'; |
| 34 | + $GLOBALS['xoTheme']->addScript('modules/tdmcreate/assets/js/functions.js'); |
| 35 | + $GLOBALS['xoTheme']->addStylesheet('modules/tdmcreate/assets/css/admin/style.css'); |
| 36 | + $GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation('morefiles.php')); |
| 37 | + $adminMenu->addItemButton(_AM_TDMCREATE_ADD_MORE_FILE, 'morefiles.php?op=new', 'add'); |
| 38 | + $GLOBALS['xoopsTpl']->assign('buttons', $adminMenu->renderButton()); |
| 39 | + $GLOBALS['xoopsTpl']->assign('tdmc_url', TDMC_URL); |
| 40 | + $GLOBALS['xoopsTpl']->assign('tdmc_upload_imgfile_url', TDMC_UPLOAD_IMGMOD_URL); |
| 41 | + $GLOBALS['xoopsTpl']->assign('modPathIcon16', $modPathIcon16); |
| 42 | + $GLOBALS['xoopsTpl']->assign('sysPathIcon32', $sysPathIcon32); |
| 43 | + $modulesCount = $tdmcreate->getHandler('modules')->getCountModules(); |
| 44 | + // Redirect if there aren't modules |
| 45 | + if (0 == $modulesCount) { |
| 46 | + redirect_header('modules.php?op=new', 2, _AM_TDMCREATE_NOT_MODULES); |
| 47 | + } |
| 48 | + $morefilesCount = $tdmcreate->getHandler('morefiles')->getCountMoreFiles(); |
| 49 | + $morefilesAll = $tdmcreate->getHandler('morefiles')->getAllMoreFiles($start, $limit); |
| 50 | + // Display morefiles list |
| 51 | + if ($morefilesCount > 0) { |
| 52 | + foreach (array_keys($morefilesAll) as $i) { |
| 53 | + $files = $morefilesAll[$i]->getValues(); |
| 54 | + $GLOBALS['xoopsTpl']->append('files_list', $files); |
| 55 | + unset($files); |
| 56 | + } |
| 57 | + if ($morefilesCount > $limit) { |
| 58 | + include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
| 59 | + $pagenav = new XoopsPageNav($morefilesCount, $limit, $start, 'start', 'op=list&limit=' . $limit); |
| 60 | + $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); |
| 61 | + } |
| 62 | + } else { |
| 63 | + $GLOBALS['xoopsTpl']->assign('error', _AM_TDMCREATE_THEREARENT_MODULES); |
| 64 | + } |
| 65 | + break; |
| 66 | + |
| 67 | + case 'new': |
| 68 | + // Define main template |
| 69 | + $templateMain = 'tdmcreate_morefiles.tpl'; |
| 70 | + $GLOBALS['xoTheme']->addScript('modules/tdmcreate/assets/js/functions.js'); |
| 71 | + $GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation('morefiles.php')); |
| 72 | + $adminMenu->addItemButton(_AM_TDMCREATE_MORE_FILES_LIST, 'morefiles.php', 'list'); |
| 73 | + $GLOBALS['xoopsTpl']->assign('buttons', $adminMenu->renderButton()); |
| 74 | + |
| 75 | + $morefilesObj =& $tdmcreate->getHandler('morefiles')->create(); |
| 76 | + $form = $morefilesObj->getForm(); |
| 77 | + $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
| 78 | + break; |
| 79 | + |
| 80 | + case 'save': |
| 81 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
| 82 | + redirect_header('morefiles.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
| 83 | + } |
| 84 | + if (isset($fileId)) { |
| 85 | + $morefilesObj =& $tdmcreate->getHandler('morefiles')->get($fileId); |
| 86 | + } else { |
| 87 | + $morefilesObj =& $tdmcreate->getHandler('morefiles')->create(); |
| 88 | + } |
| 89 | + // Form file save |
| 90 | + $morefilesObj->setVars(array( |
| 91 | + 'file_mid' => $_POST['file_mid'], |
| 92 | + 'file_name' => $_POST['file_name'], |
| 93 | + 'file_extension' => $_POST['file_extension'], |
| 94 | + 'file_infolder' => $_POST['file_infolder'])); |
| 95 | + |
| 96 | + if ($tdmcreate->getHandler('morefiles')->insert($morefilesObj)) { |
| 97 | + if ($morefilesObj->isNew()) { |
| 98 | + redirect_header('morefiles.php', 5, sprintf(_AM_TDMCREATE_FILE_FORM_CREATED_OK, $_POST['file_name'])); |
| 99 | + } else { |
| 100 | + redirect_header('morefiles.php', 5, sprintf(_AM_TDMCREATE_FILE_FORM_UPDATED_OK, $_POST['file_name'])); |
| 101 | + } |
| 102 | + } |
| 103 | + |
| 104 | + $GLOBALS['xoopsTpl']->assign('error', $morefilesObj->getHtmlErrors()); |
| 105 | + $form =& $morefilesObj->getForm(); |
| 106 | + $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
| 107 | + break; |
| 108 | + |
| 109 | + case 'edit': |
| 110 | + // Define main template |
| 111 | + $templateMain = 'tdmcreate_morefiles.tpl'; |
| 112 | + $GLOBALS['xoTheme']->addScript('modules/tdmcreate/assets/js/functions.js'); |
| 113 | + $GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation('morefiles.php')); |
| 114 | + $adminMenu->addItemButton(_AM_TDMCREATE_ADD_MODULE, 'morefiles.php?op=new', 'add'); |
| 115 | + $adminMenu->addItemButton(_AM_TDMCREATE_MORE_FILES_LIST, 'morefiles.php', 'list'); |
| 116 | + $GLOBALS['xoopsTpl']->assign('buttons', $adminMenu->renderButton()); |
| 117 | + |
| 118 | + $morefilesObj = $tdmcreate->getHandler('morefiles')->get($fileId); |
| 119 | + $form = $morefilesObj->getForm(); |
| 120 | + $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
| 121 | + break; |
| 122 | + |
| 123 | + case 'delete': |
| 124 | + $morefilesObj =& $tdmcreate->getHandler('morefiles')->get($fileId); |
| 125 | + if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) { |
| 126 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
| 127 | + redirect_header('morefiles.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
| 128 | + } |
| 129 | + if ($tdmcreate->getHandler('morefiles')->delete($morefilesObj)) { |
| 130 | + redirect_header('morefiles.php', 3, _AM_TDMCREATE_FORM_DELETED_OK); |
| 131 | + } else { |
| 132 | + $GLOBALS['xoopsTpl']->assign('error', $morefilesObj->getHtmlErrors()); |
| 133 | + } |
| 134 | + } else { |
| 135 | + xoops_confirm(array('ok' => 1, 'file_id' => $fileId, 'op' => 'delete'), $_SERVER['REQUEST_URI'], sprintf(_AM_TDMCREATE_FORM_SURE_DELETE, $morefilesObj->getVar('file_name'))); |
| 136 | + } |
| 137 | + break; |
| 138 | +} |
| 139 | + |
| 140 | +include __DIR__ . '/footer.php'; |
0 commit comments