1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
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
|
|
|
|
10
|
|
|
This program is distributed in the hope that it will be useful, |
11
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* wgFileManager module for xoops |
17
|
|
|
* |
18
|
|
|
* @copyright 2021 XOOPS Project (https://xoops.org) |
19
|
|
|
* @license GPL 2.0 or later |
20
|
|
|
* @package wgfilemanager |
21
|
|
|
* @author Goffy - Wedega - Email:[email protected] - Website:https://xoops.wedega.com |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
use Xmf\Request; |
|
|
|
|
25
|
|
|
use XoopsModules\Wgfilemanager; |
26
|
|
|
use XoopsModules\Wgfilemanager\Constants; |
27
|
|
|
use XoopsModules\Wgfilemanager\Common; |
28
|
|
|
|
29
|
|
|
require __DIR__ . '/header.php'; |
30
|
|
|
// Get all request values |
31
|
|
|
$op = Request::getCmd('op', 'list'); |
32
|
|
|
$favId = Request::getInt('id'); |
33
|
|
|
$start = Request::getInt('start'); |
34
|
|
|
$limit = Request::getInt('limit', $helper->getConfig('adminpager')); |
35
|
|
|
$GLOBALS['xoopsTpl']->assign('start', $start); |
36
|
|
|
$GLOBALS['xoopsTpl']->assign('limit', $limit); |
37
|
|
|
|
38
|
|
|
switch ($op) { |
39
|
|
|
case 'list': |
40
|
|
|
default: |
41
|
|
|
// Define Stylesheet |
42
|
|
|
$GLOBALS['xoTheme']->addStylesheet($style, null); |
43
|
|
|
$templateMain = 'wgfilemanager_admin_favorite.tpl'; |
44
|
|
|
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('favorite.php')); |
45
|
|
|
$GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
46
|
|
|
$GLOBALS['xoopsTpl']->assign('wgfilemanager_url', \WGFILEMANAGER_URL); |
47
|
|
|
$GLOBALS['xoopsTpl']->assign('wgfilemanager_upload_url', \WGFILEMANAGER_UPLOAD_URL); |
48
|
|
|
$favoriteCount = $favoriteHandler->getCount(); |
49
|
|
|
$GLOBALS['xoopsTpl']->assign('favorite_count', $favoriteCount); |
50
|
|
|
// Table view favorite |
51
|
|
|
if ($favoriteCount > 0) { |
52
|
|
|
$favoriteAll = $favoriteHandler->getAllFavorite($start, $limit); |
53
|
|
|
foreach (\array_keys($favoriteAll) as $i) { |
54
|
|
|
$favorite = $favoriteAll[$i]->getValuesFavorite(); |
55
|
|
|
$GLOBALS['xoopsTpl']->append('favorite_list', $favorite); |
56
|
|
|
unset($favorite); |
57
|
|
|
} |
58
|
|
|
// Display Navigation |
59
|
|
|
if ($favoriteCount > $limit) { |
60
|
|
|
require_once \XOOPS_ROOT_PATH . '/class/pagenav.php'; |
61
|
|
|
$pagenav = new \XoopsPageNav($favoriteCount, $limit, $start, 'start', 'op=list&limit=' . $limit); |
62
|
|
|
$GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
63
|
|
|
} |
64
|
|
|
} else { |
65
|
|
|
$GLOBALS['xoopsTpl']->assign('error', \_AM_WGFILEMANAGER_THEREARENT_FAVORITE); |
66
|
|
|
} |
67
|
|
|
break; |
68
|
|
|
case 'delete': |
69
|
|
|
$templateMain = 'wgfilemanager_admin_favorite.tpl'; |
70
|
|
|
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('favorite.php')); |
71
|
|
|
$favoriteObj = $favoriteHandler->get($favId); |
72
|
|
|
$dirName = $favoriteObj->getVar('name'); |
73
|
|
|
if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) { |
74
|
|
|
if (!$GLOBALS['xoopsSecurity']->check()) { |
75
|
|
|
\redirect_header('favorite.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
76
|
|
|
} |
77
|
|
|
$dirFullPath = $favoriteObj->getVar('fullpath'); |
78
|
|
|
if ($favoriteHandler->delete($favoriteObj)) { |
79
|
|
|
\redirect_header('favorite.php', 3, \_AM_WGFILEMANAGER_FORM_DELETE_OK); |
80
|
|
|
} else { |
81
|
|
|
$GLOBALS['xoopsTpl']->assign('error', $favoriteObj->getHtmlErrors()); |
82
|
|
|
} |
83
|
|
|
} else { |
84
|
|
|
$confirmText = _AM_WGFILEMANAGER_FORM_SURE_DELETE; |
85
|
|
|
$customConfirm = new Common\Confirm( |
86
|
|
|
['ok' => 1, 'id' => $favId, 'start' => $start, 'limit' => $limit, 'op' => 'delete'], |
87
|
|
|
$_SERVER['REQUEST_URI'], |
88
|
|
|
\sprintf(\_AM_WGFILEMANAGER_FORM_SURE_DELETE, $favId)); |
89
|
|
|
$form = $customConfirm->getFormConfirm(); |
90
|
|
|
$GLOBALS['xoopsTpl']->assign('form', $form->render()); |
91
|
|
|
} |
92
|
|
|
break; |
93
|
|
|
} |
94
|
|
|
require __DIR__ . '/footer.php'; |
95
|
|
|
|
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: