|
9 | 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
11 | 11 | */ |
| 12 | + |
12 | 13 | /** |
13 | 14 | * tdmcreate module. |
14 | 15 | * |
|
19 | 20 | * |
20 | 21 | * @author Txmod Xoops <support@txmodxoops.org> |
21 | 22 | * |
22 | | - * @version $Id: 1.59 addfiles.php 11297 2013-03-24 10:58:10Z timgno $ |
23 | 23 | */ |
24 | | -include __DIR__.'/header.php'; |
| 24 | +$GLOBALS['xoopsOption']['template_main'] = 'tdmcreate_addfiles.tpl'; |
| 25 | + |
| 26 | +include __DIR__ . '/header.php'; |
25 | 27 | // Recovered value of argument op in the URL $ |
26 | | -$op = XoopsRequest::getString('op', 'list'); |
| 28 | +$op = \Xmf\Request::getString('op', 'list'); |
27 | 29 |
|
28 | | -$fileId = XoopsRequest::getInt('file_id'); |
| 30 | +$fileId = \Xmf\Request::getInt('file_id'); |
29 | 31 |
|
30 | 32 | switch ($op) { |
31 | 33 | case 'list': |
32 | 34 | default: |
33 | | - $start = XoopsRequest::getInt('start', 0); |
34 | | - $limit = XoopsRequest::getInt('limit', $tdmcreate->getConfig('addfiles_adminpager')); |
| 35 | + $start = \Xmf\Request::getInt('start', 0); |
| 36 | + $limit = \Xmf\Request::getInt('limit', $helper->getConfig('addfiles_adminpager')); |
35 | 37 | // Define main template |
36 | | - $templateMain = 'tdmcreate_addfiles.tpl'; |
| 38 | + // $templateMain = 'tdmcreate_addfiles.tpl'; |
37 | 39 | $GLOBALS['xoTheme']->addScript('modules/tdmcreate/assets/js/functions.js'); |
38 | 40 | $GLOBALS['xoTheme']->addStylesheet('modules/tdmcreate/assets/css/admin/style.css'); |
39 | 41 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('addfiles.php')); |
|
43 | 45 | $GLOBALS['xoopsTpl']->assign('tdmc_upload_imgfile_url', TDMC_UPLOAD_IMGMOD_URL); |
44 | 46 | $GLOBALS['xoopsTpl']->assign('modPathIcon16', $modPathIcon16); |
45 | 47 | $GLOBALS['xoopsTpl']->assign('sysPathIcon32', $sysPathIcon32); |
46 | | - $modulesCount = $tdmcreate->getHandler('modules')->getCountModules(); |
| 48 | + $modulesCount = $helper->getHandler('Modules')->getCountModules(); |
47 | 49 | // Redirect if there aren't modules |
48 | 50 | if (0 == $modulesCount) { |
49 | 51 | redirect_header('modules.php?op=new', 2, _AM_TDMCREATE_NOT_MODULES); |
50 | 52 | } |
51 | | - $addfilesCount = $tdmcreate->getHandler('addfiles')->getCountAddFiles(); |
52 | | - $addfilesAll = $tdmcreate->getHandler('addfiles')->getAllAddFiles($start, $limit); |
| 53 | + $addfilesCount = $helper->getHandler('Addfiles')->getCountAddFiles(); |
| 54 | + $addfilesAll = $helper->getHandler('Addfiles')->getAllAddFiles($start, $limit); |
53 | 55 | // Display addfiles list |
54 | 56 | if ($addfilesCount > 0) { |
55 | 57 | foreach (array_keys($addfilesAll) as $i) { |
|
58 | 60 | unset($files); |
59 | 61 | } |
60 | 62 | if ($addfilesCount > $limit) { |
61 | | - include_once XOOPS_ROOT_PATH.'/class/pagenav.php'; |
62 | | - $pagenav = new XoopsPageNav($addfilesCount, $limit, $start, 'start', 'op=list&limit='.$limit); |
| 63 | + include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
| 64 | + $pagenav = new \XoopsPageNav($addfilesCount, $limit, $start, 'start', 'op=list&limit=' . $limit); |
63 | 65 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); |
64 | 66 | } |
65 | 67 | } else { |
66 | 68 | $GLOBALS['xoopsTpl']->assign('error', _AM_TDMCREATE_THEREARENT_MODULES); |
67 | 69 | } |
68 | 70 | break; |
69 | | - |
70 | 71 | case 'new': |
71 | 72 | // Define main template |
72 | | - $templateMain = 'tdmcreate_addfiles.tpl'; |
| 73 | + // $templateMain = 'tdmcreate_addfiles.tpl'; |
73 | 74 | $GLOBALS['xoTheme']->addScript('modules/tdmcreate/assets/js/functions.js'); |
74 | 75 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('addfiles.php')); |
75 | 76 | $adminObject->addItemButton(_AM_TDMCREATE_ADDFILES_LIST, 'addfiles.php', 'list'); |
76 | 77 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
77 | 78 |
|
78 | | - $addfilesObj = &$tdmcreate->getHandler('addfiles')->create(); |
79 | | - $form = $addfilesObj->getFormAddFiles(); |
| 79 | + $addfilesObj = $helper->getHandler('Addfiles')->create(); |
| 80 | + $form = $addfilesObj->getFormAddFiles(); |
80 | 81 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
81 | 82 | break; |
82 | | - |
83 | 83 | case 'save': |
84 | 84 | if (!$GLOBALS['xoopsSecurity']->check()) { |
85 | 85 | redirect_header('addfiles.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
86 | 86 | } |
87 | 87 | if (isset($fileId)) { |
88 | | - $addfilesObj = &$tdmcreate->getHandler('addfiles')->get($fileId); |
| 88 | + $addfilesObj = $helper->getHandler('Addfiles')->get($fileId); |
89 | 89 | } else { |
90 | | - $addfilesObj = &$tdmcreate->getHandler('addfiles')->create(); |
| 90 | + $addfilesObj = $helper->getHandler('Addfiles')->create(); |
91 | 91 | } |
92 | 92 | // Form file save |
93 | | - $addfilesObj->setVars([ |
94 | | - 'file_mid' => $_POST['file_mid'], |
95 | | - 'file_name' => $_POST['file_name'], |
96 | | - 'file_extension' => $_POST['file_extension'], |
97 | | - 'file_infolder' => $_POST['file_infolder'], |
98 | | - ]); |
| 93 | + $addfilesObj->setVars( |
| 94 | + [ |
| 95 | + 'file_mid' => \Xmf\Request::getString('file_mid', '', 'POST'), |
| 96 | + 'file_name' => \Xmf\Request::getString('file_name', '', 'POST'), |
| 97 | + 'file_extension' => \Xmf\Request::getString('file_extension', '', 'POST'), |
| 98 | + 'file_infolder' => \Xmf\Request::getString('file_infolder', '', 'POST'), |
| 99 | + ] |
| 100 | + ); |
99 | 101 |
|
100 | | - if ($tdmcreate->getHandler('addfiles')->insert($addfilesObj)) { |
| 102 | + if ($helper->getHandler('Addfiles')->insert($addfilesObj)) { |
101 | 103 | if ($addfilesObj->isNew()) { |
102 | | - redirect_header('addfiles.php', 5, sprintf(_AM_TDMCREATE_FILE_FORM_CREATED_OK, $_POST['file_name'])); |
| 104 | + redirect_header('addfiles.php', 5, sprintf(_AM_TDMCREATE_FILE_FORM_CREATED_OK, \Xmf\Request::getString('file_name', '', 'POST'))); |
103 | 105 | } else { |
104 | | - redirect_header('addfiles.php', 5, sprintf(_AM_TDMCREATE_FILE_FORM_UPDATED_OK, $_POST['file_name'])); |
| 106 | + redirect_header('addfiles.php', 5, sprintf(_AM_TDMCREATE_FILE_FORM_UPDATED_OK, \Xmf\Request::getString('file_name', '', 'POST'))); |
105 | 107 | } |
106 | 108 | } |
107 | 109 |
|
108 | 110 | $GLOBALS['xoopsTpl']->assign('error', $addfilesObj->getHtmlErrors()); |
109 | | - $form = &$addfilesObj->getFormAddFiles(); |
| 111 | + $form = $addfilesObj->getFormAddFiles(); |
110 | 112 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
111 | 113 | break; |
112 | | - |
113 | 114 | case 'edit': |
114 | 115 | // Define main template |
115 | | - $templateMain = 'tdmcreate_addfiles.tpl'; |
| 116 | + // $templateMain = 'tdmcreate_addfiles.tpl'; |
116 | 117 | $GLOBALS['xoTheme']->addScript('modules/tdmcreate/assets/js/functions.js'); |
117 | 118 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('addfiles.php')); |
118 | 119 | $adminObject->addItemButton(_AM_TDMCREATE_ADD_MODULE, 'addfiles.php?op=new', 'add'); |
119 | 120 | $adminObject->addItemButton(_AM_TDMCREATE_ADDFILES_LIST, 'addfiles.php', 'list'); |
120 | 121 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
121 | 122 |
|
122 | | - $addfilesObj = $tdmcreate->getHandler('addfiles')->get($fileId); |
123 | | - $form = $addfilesObj->getFormAddFiles(); |
| 123 | + $addfilesObj = $helper->getHandler('Addfiles')->get($fileId); |
| 124 | + $form = $addfilesObj->getFormAddFiles(); |
124 | 125 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
125 | 126 | break; |
126 | | - |
127 | 127 | case 'delete': |
128 | | - $addfilesObj = &$tdmcreate->getHandler('addfiles')->get($fileId); |
| 128 | + $addfilesObj = $helper->getHandler('Addfiles')->get($fileId); |
129 | 129 | if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) { |
130 | 130 | if (!$GLOBALS['xoopsSecurity']->check()) { |
131 | 131 | redirect_header('addfiles.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
132 | 132 | } |
133 | | - if ($tdmcreate->getHandler('addfiles')->delete($addfilesObj)) { |
| 133 | + if ($helper->getHandler('Addfiles')->delete($addfilesObj)) { |
134 | 134 | redirect_header('addfiles.php', 3, _AM_TDMCREATE_FORM_DELETED_OK); |
135 | 135 | } else { |
136 | 136 | $GLOBALS['xoopsTpl']->assign('error', $addfilesObj->getHtmlErrors()); |
137 | 137 | } |
138 | 138 | } else { |
139 | | - xoops_confirm(['ok' => 1, 'file_id' => $fileId, 'op' => 'delete'], $_SERVER['REQUEST_URI'], sprintf(_AM_TDMCREATE_FORM_SURE_DELETE, $addfilesObj->getVar('file_name'))); |
| 139 | + xoops_confirm(['ok' => 1, 'file_id' => $fileId, 'op' => 'delete'], \Xmf\Request::getString('REQUEST_URI', '', 'SERVER'), sprintf(_AM_TDMCREATE_FORM_SURE_DELETE, $addfilesObj->getVar('file_name'))); |
140 | 140 | } |
141 | 141 | break; |
142 | 142 | } |
143 | 143 |
|
144 | | -include __DIR__.'/footer.php'; |
| 144 | +include __DIR__ . '/footer.php'; |
0 commit comments