@@ -28,20 +28,20 @@ discard block |
||
28 | 28 | */ |
29 | 29 | function xoops_module_pre_install_myiframe(\XoopsModule $module) |
30 | 30 | { |
31 | - require_once \dirname(__DIR__) . '/preloads/autoloader.php'; |
|
32 | - /** @var \Utility $utility */ |
|
33 | - $utility = new Utility(); |
|
34 | - $xoopsSuccess = $utility::checkVerXoops($module); |
|
35 | - $phpSuccess = $utility::checkVerPhp($module); |
|
31 | + require_once \dirname(__DIR__) . '/preloads/autoloader.php'; |
|
32 | + /** @var \Utility $utility */ |
|
33 | + $utility = new Utility(); |
|
34 | + $xoopsSuccess = $utility::checkVerXoops($module); |
|
35 | + $phpSuccess = $utility::checkVerPhp($module); |
|
36 | 36 | |
37 | - if (false !== $xoopsSuccess && false !== $phpSuccess) { |
|
38 | - $moduleTables = &$module->getInfo('tables'); |
|
39 | - foreach ($moduleTables as $table) { |
|
40 | - $GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';'); |
|
41 | - } |
|
42 | - } |
|
37 | + if (false !== $xoopsSuccess && false !== $phpSuccess) { |
|
38 | + $moduleTables = &$module->getInfo('tables'); |
|
39 | + foreach ($moduleTables as $table) { |
|
40 | + $GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';'); |
|
41 | + } |
|
42 | + } |
|
43 | 43 | |
44 | - return $xoopsSuccess && $phpSuccess; |
|
44 | + return $xoopsSuccess && $phpSuccess; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -52,52 +52,52 @@ discard block |
||
52 | 52 | */ |
53 | 53 | function xoops_module_install_myiframe(\XoopsModule $module) |
54 | 54 | { |
55 | - require \dirname(__DIR__, 3) . '/mainfile.php'; |
|
55 | + require \dirname(__DIR__, 3) . '/mainfile.php'; |
|
56 | 56 | |
57 | - $moduleDirName = \basename(\dirname(__DIR__)); |
|
57 | + $moduleDirName = \basename(\dirname(__DIR__)); |
|
58 | 58 | |
59 | - /** @var Myiframe\Helper $helper */ |
|
60 | - $helper = Myiframe\Helper::getInstance(); |
|
61 | - /** @var Myiframe\Utility $helper */ |
|
62 | - $utility = new Utility(); |
|
63 | - /** @var Myiframe\Common\Configurator $helper */ |
|
64 | - $configurator = new Myiframe\Common\Configurator(); |
|
65 | - // Load language files |
|
66 | - $helper->loadLanguage('admin'); |
|
67 | - $helper->loadLanguage('modinfo'); |
|
59 | + /** @var Myiframe\Helper $helper */ |
|
60 | + $helper = Myiframe\Helper::getInstance(); |
|
61 | + /** @var Myiframe\Utility $helper */ |
|
62 | + $utility = new Utility(); |
|
63 | + /** @var Myiframe\Common\Configurator $helper */ |
|
64 | + $configurator = new Myiframe\Common\Configurator(); |
|
65 | + // Load language files |
|
66 | + $helper->loadLanguage('admin'); |
|
67 | + $helper->loadLanguage('modinfo'); |
|
68 | 68 | |
69 | - // default Permission Settings ---------------------- |
|
70 | - global $xoopsModule; |
|
71 | - $moduleId = $xoopsModule->getVar('mid'); |
|
72 | - // $moduleId2 = $helper->getModule()->mid(); |
|
73 | - /** @var \XoopsGroupPermHandler $grouppermHandler */ |
|
74 | - $grouppermHandler = xoops_getHandler('groupperm'); |
|
75 | - // access rights ------------------------------------------ |
|
76 | - $grouppermHandler->addRight($moduleDirName . '_approve', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
77 | - $grouppermHandler->addRight($moduleDirName . '_submit', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
78 | - $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
79 | - $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_USERS, $moduleId); |
|
80 | - $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ANONYMOUS, $moduleId); |
|
69 | + // default Permission Settings ---------------------- |
|
70 | + global $xoopsModule; |
|
71 | + $moduleId = $xoopsModule->getVar('mid'); |
|
72 | + // $moduleId2 = $helper->getModule()->mid(); |
|
73 | + /** @var \XoopsGroupPermHandler $grouppermHandler */ |
|
74 | + $grouppermHandler = xoops_getHandler('groupperm'); |
|
75 | + // access rights ------------------------------------------ |
|
76 | + $grouppermHandler->addRight($moduleDirName . '_approve', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
77 | + $grouppermHandler->addRight($moduleDirName . '_submit', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
78 | + $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
79 | + $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_USERS, $moduleId); |
|
80 | + $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ANONYMOUS, $moduleId); |
|
81 | 81 | |
82 | - // --- CREATE FOLDERS --------------- |
|
83 | - if (count($configurator->uploadFolders) > 0) { |
|
84 | - // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
|
85 | - foreach (array_keys($configurator->uploadFolders) as $i) { |
|
86 | - $utility::createFolder($configurator->uploadFolders[$i]); |
|
87 | - } |
|
88 | - } |
|
82 | + // --- CREATE FOLDERS --------------- |
|
83 | + if (count($configurator->uploadFolders) > 0) { |
|
84 | + // foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
|
85 | + foreach (array_keys($configurator->uploadFolders) as $i) { |
|
86 | + $utility::createFolder($configurator->uploadFolders[$i]); |
|
87 | + } |
|
88 | + } |
|
89 | 89 | |
90 | - // --- COPY blank.png FILES --------------- |
|
91 | - if (count($configurator->copyBlankFiles) > 0) { |
|
92 | - $file = \dirname(__DIR__) . '/assets/images/blank.png'; |
|
93 | - foreach (array_keys($configurator->copyBlankFiles) as $i) { |
|
94 | - $dest = $configurator->copyBlankFiles[$i] . '/blank.png'; |
|
95 | - $utility::copyFile($file, $dest); |
|
96 | - } |
|
97 | - } |
|
98 | - //delete .html entries from the tpl table |
|
99 | - $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $xoopsModule->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'"; |
|
100 | - $GLOBALS['xoopsDB']->queryF($sql); |
|
90 | + // --- COPY blank.png FILES --------------- |
|
91 | + if (count($configurator->copyBlankFiles) > 0) { |
|
92 | + $file = \dirname(__DIR__) . '/assets/images/blank.png'; |
|
93 | + foreach (array_keys($configurator->copyBlankFiles) as $i) { |
|
94 | + $dest = $configurator->copyBlankFiles[$i] . '/blank.png'; |
|
95 | + $utility::copyFile($file, $dest); |
|
96 | + } |
|
97 | + } |
|
98 | + //delete .html entries from the tpl table |
|
99 | + $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $xoopsModule->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'"; |
|
100 | + $GLOBALS['xoopsDB']->queryF($sql); |
|
101 | 101 | |
102 | - return true; |
|
102 | + return true; |
|
103 | 103 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | function xoops_module_pre_install_myiframe(\XoopsModule $module) |
30 | 30 | { |
31 | - require_once \dirname(__DIR__) . '/preloads/autoloader.php'; |
|
31 | + require_once \dirname(__DIR__).'/preloads/autoloader.php'; |
|
32 | 32 | /** @var \Utility $utility */ |
33 | 33 | $utility = new Utility(); |
34 | 34 | $xoopsSuccess = $utility::checkVerXoops($module); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | if (false !== $xoopsSuccess && false !== $phpSuccess) { |
38 | 38 | $moduleTables = &$module->getInfo('tables'); |
39 | 39 | foreach ($moduleTables as $table) { |
40 | - $GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';'); |
|
40 | + $GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS '.$GLOBALS['xoopsDB']->prefix($table).';'); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | function xoops_module_install_myiframe(\XoopsModule $module) |
54 | 54 | { |
55 | - require \dirname(__DIR__, 3) . '/mainfile.php'; |
|
55 | + require \dirname(__DIR__, 3).'/mainfile.php'; |
|
56 | 56 | |
57 | 57 | $moduleDirName = \basename(\dirname(__DIR__)); |
58 | 58 | |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
74 | 74 | $grouppermHandler = xoops_getHandler('groupperm'); |
75 | 75 | // access rights ------------------------------------------ |
76 | - $grouppermHandler->addRight($moduleDirName . '_approve', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
77 | - $grouppermHandler->addRight($moduleDirName . '_submit', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
78 | - $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
79 | - $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_USERS, $moduleId); |
|
80 | - $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ANONYMOUS, $moduleId); |
|
76 | + $grouppermHandler->addRight($moduleDirName.'_approve', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
77 | + $grouppermHandler->addRight($moduleDirName.'_submit', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
78 | + $grouppermHandler->addRight($moduleDirName.'_view', 1, XOOPS_GROUP_ADMIN, $moduleId); |
|
79 | + $grouppermHandler->addRight($moduleDirName.'_view', 1, XOOPS_GROUP_USERS, $moduleId); |
|
80 | + $grouppermHandler->addRight($moduleDirName.'_view', 1, XOOPS_GROUP_ANONYMOUS, $moduleId); |
|
81 | 81 | |
82 | 82 | // --- CREATE FOLDERS --------------- |
83 | 83 | if (count($configurator->uploadFolders) > 0) { |
@@ -89,14 +89,14 @@ discard block |
||
89 | 89 | |
90 | 90 | // --- COPY blank.png FILES --------------- |
91 | 91 | if (count($configurator->copyBlankFiles) > 0) { |
92 | - $file = \dirname(__DIR__) . '/assets/images/blank.png'; |
|
92 | + $file = \dirname(__DIR__).'/assets/images/blank.png'; |
|
93 | 93 | foreach (array_keys($configurator->copyBlankFiles) as $i) { |
94 | - $dest = $configurator->copyBlankFiles[$i] . '/blank.png'; |
|
94 | + $dest = $configurator->copyBlankFiles[$i].'/blank.png'; |
|
95 | 95 | $utility::copyFile($file, $dest); |
96 | 96 | } |
97 | 97 | } |
98 | 98 | //delete .html entries from the tpl table |
99 | - $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $xoopsModule->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'"; |
|
99 | + $sql = 'DELETE FROM '.$GLOBALS['xoopsDB']->prefix('tplfile')." WHERE `tpl_module` = '".$xoopsModule->getVar('dirname', 'n')."' AND `tpl_file` LIKE '%.html%'"; |
|
100 | 100 | $GLOBALS['xoopsDB']->queryF($sql); |
101 | 101 | |
102 | 102 | return true; |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | */ |
21 | 21 | function xoops_module_pre_uninstall_myiframe(\XoopsModule $module) |
22 | 22 | { |
23 | - // Do some synchronization |
|
24 | - return true; |
|
23 | + // Do some synchronization |
|
24 | + return true; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -32,32 +32,32 @@ discard block |
||
32 | 32 | */ |
33 | 33 | function xoops_module_uninstall_myiframe(\XoopsModule $module) |
34 | 34 | { |
35 | - // return true; |
|
35 | + // return true; |
|
36 | 36 | |
37 | - $moduleDirName = \basename(\dirname(__DIR__)); |
|
38 | - $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
39 | - /** @var Myiframe\Helper $helper */ |
|
40 | - $helper = Myiframe\Helper::getInstance(); |
|
37 | + $moduleDirName = \basename(\dirname(__DIR__)); |
|
38 | + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
39 | + /** @var Myiframe\Helper $helper */ |
|
40 | + $helper = Myiframe\Helper::getInstance(); |
|
41 | 41 | |
42 | - /** @var Myiframe\Utility $utility */ |
|
43 | - $utility = new Utility(); |
|
42 | + /** @var Myiframe\Utility $utility */ |
|
43 | + $utility = new Utility(); |
|
44 | 44 | |
45 | - $success = true; |
|
46 | - $helper->loadLanguage('admin'); |
|
45 | + $success = true; |
|
46 | + $helper->loadLanguage('admin'); |
|
47 | 47 | |
48 | - // Rename uploads folder to BAK and add date to name |
|
49 | - $uploadDirectory = $GLOBALS['xoops']->path("uploads/$moduleDirName"); |
|
50 | - $dirInfo = new \SplFileInfo($uploadDirectory); |
|
51 | - if ($dirInfo->isDir()) { |
|
52 | - // The directory exists so rename it |
|
53 | - $date = date('Y-m-d'); |
|
54 | - if (!rename($uploadDirectory, $uploadDirectory . "_bak_$date")) { |
|
55 | - $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH'), $uploadDirectory)); |
|
56 | - $success = false; |
|
57 | - } |
|
58 | - } |
|
59 | - unset($dirInfo); |
|
60 | - /* |
|
48 | + // Rename uploads folder to BAK and add date to name |
|
49 | + $uploadDirectory = $GLOBALS['xoops']->path("uploads/$moduleDirName"); |
|
50 | + $dirInfo = new \SplFileInfo($uploadDirectory); |
|
51 | + if ($dirInfo->isDir()) { |
|
52 | + // The directory exists so rename it |
|
53 | + $date = date('Y-m-d'); |
|
54 | + if (!rename($uploadDirectory, $uploadDirectory . "_bak_$date")) { |
|
55 | + $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH'), $uploadDirectory)); |
|
56 | + $success = false; |
|
57 | + } |
|
58 | + } |
|
59 | + unset($dirInfo); |
|
60 | + /* |
|
61 | 61 | //------------ START ---------------- |
62 | 62 | //------------------------------------------------------------------ |
63 | 63 | // Remove xsitemap.xml from XOOPS root folder if it exists |
@@ -71,6 +71,6 @@ discard block |
||
71 | 71 | // return $success && $delOk; // use this if you're using this routine |
72 | 72 | */ |
73 | 73 | |
74 | - return $success; |
|
75 | - //------------ END ---------------- |
|
74 | + return $success; |
|
75 | + //------------ END ---------------- |
|
76 | 76 | } |
@@ -51,8 +51,8 @@ |
||
51 | 51 | if ($dirInfo->isDir()) { |
52 | 52 | // The directory exists so rename it |
53 | 53 | $date = date('Y-m-d'); |
54 | - if (!rename($uploadDirectory, $uploadDirectory . "_bak_$date")) { |
|
55 | - $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_DEL_PATH'), $uploadDirectory)); |
|
54 | + if (!rename($uploadDirectory, $uploadDirectory."_bak_$date")) { |
|
55 | + $module->setErrors(sprintf(constant('CO_'.$moduleDirNameUpper.'_ERROR_BAD_DEL_PATH'), $uploadDirectory)); |
|
56 | 56 | $success = false; |
57 | 57 | } |
58 | 58 | } |
@@ -30,5 +30,5 @@ |
||
30 | 30 | */ |
31 | 31 | class Utility extends Common\SysUtility |
32 | 32 | { |
33 | - //--------------- Custom module methods ----------------------------- |
|
33 | + //--------------- Custom module methods ----------------------------- |
|
34 | 34 | } |
@@ -67,7 +67,7 @@ |
||
67 | 67 | { |
68 | 68 | $ret = false; |
69 | 69 | |
70 | - $class = __NAMESPACE__ . '\\' . \ucfirst($name) . 'Handler'; |
|
70 | + $class = __NAMESPACE__.'\\'.\ucfirst($name).'Handler'; |
|
71 | 71 | if (!\class_exists($class)) { |
72 | 72 | throw new \RuntimeException("Class '$class' not found"); |
73 | 73 | } |
@@ -23,62 +23,62 @@ |
||
23 | 23 | */ |
24 | 24 | class Helper extends \Xmf\Module\Helper |
25 | 25 | { |
26 | - public $debug; |
|
26 | + public $debug; |
|
27 | 27 | |
28 | - /** |
|
29 | - * @param bool $debug |
|
30 | - */ |
|
31 | - public function __construct($debug = false) |
|
32 | - { |
|
33 | - $this->debug = $debug; |
|
34 | - $moduleDirName = \basename(\dirname(__DIR__)); |
|
35 | - parent::__construct($moduleDirName); |
|
36 | - } |
|
28 | + /** |
|
29 | + * @param bool $debug |
|
30 | + */ |
|
31 | + public function __construct($debug = false) |
|
32 | + { |
|
33 | + $this->debug = $debug; |
|
34 | + $moduleDirName = \basename(\dirname(__DIR__)); |
|
35 | + parent::__construct($moduleDirName); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param bool $debug |
|
40 | - * |
|
41 | - * @return \XoopsModules\Myiframe\Helper |
|
42 | - */ |
|
43 | - public static function getInstance(bool $debug = false): self |
|
44 | - { |
|
45 | - static $instance; |
|
46 | - if (null === $instance) { |
|
47 | - $instance = new static($debug); |
|
48 | - } |
|
38 | + /** |
|
39 | + * @param bool $debug |
|
40 | + * |
|
41 | + * @return \XoopsModules\Myiframe\Helper |
|
42 | + */ |
|
43 | + public static function getInstance(bool $debug = false): self |
|
44 | + { |
|
45 | + static $instance; |
|
46 | + if (null === $instance) { |
|
47 | + $instance = new static($debug); |
|
48 | + } |
|
49 | 49 | |
50 | - return $instance; |
|
51 | - } |
|
50 | + return $instance; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @return string |
|
55 | - */ |
|
56 | - public function getDirname() |
|
57 | - { |
|
58 | - return $this->dirname; |
|
59 | - } |
|
53 | + /** |
|
54 | + * @return string |
|
55 | + */ |
|
56 | + public function getDirname() |
|
57 | + { |
|
58 | + return $this->dirname; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Get an Object Handler |
|
63 | - * |
|
64 | - * @param string $name name of handler to load |
|
65 | - * |
|
66 | - * @return bool|\XoopsObjectHandler|\XoopsPersistableObjectHandler |
|
67 | - */ |
|
68 | - public function getHandler($name) |
|
69 | - { |
|
70 | - $ret = false; |
|
61 | + /** |
|
62 | + * Get an Object Handler |
|
63 | + * |
|
64 | + * @param string $name name of handler to load |
|
65 | + * |
|
66 | + * @return bool|\XoopsObjectHandler|\XoopsPersistableObjectHandler |
|
67 | + */ |
|
68 | + public function getHandler($name) |
|
69 | + { |
|
70 | + $ret = false; |
|
71 | 71 | |
72 | - $class = __NAMESPACE__ . '\\' . \ucfirst($name) . 'Handler'; |
|
73 | - if (!\class_exists($class)) { |
|
74 | - throw new \RuntimeException("Class '$class' not found"); |
|
75 | - } |
|
76 | - /** @var \XoopsMySQLDatabase $db */ |
|
77 | - $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
78 | - $helper = self::getInstance(); |
|
79 | - $ret = new $class($db, $helper); |
|
80 | - $this->addLog("Getting handler '{$name}'"); |
|
72 | + $class = __NAMESPACE__ . '\\' . \ucfirst($name) . 'Handler'; |
|
73 | + if (!\class_exists($class)) { |
|
74 | + throw new \RuntimeException("Class '$class' not found"); |
|
75 | + } |
|
76 | + /** @var \XoopsMySQLDatabase $db */ |
|
77 | + $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
78 | + $helper = self::getInstance(); |
|
79 | + $ret = new $class($db, $helper); |
|
80 | + $this->addLog("Getting handler '{$name}'"); |
|
81 | 81 | |
82 | - return $ret; |
|
83 | - } |
|
82 | + return $ret; |
|
83 | + } |
|
84 | 84 | } |
@@ -25,39 +25,39 @@ discard block |
||
25 | 25 | */ |
26 | 26 | class Breadcrumb |
27 | 27 | { |
28 | - public $dirname; |
|
29 | - private $bread = []; |
|
28 | + public $dirname; |
|
29 | + private $bread = []; |
|
30 | 30 | |
31 | - public function __construct() |
|
32 | - { |
|
33 | - $this->dirname = \basename(\dirname(__DIR__, 2)); |
|
34 | - } |
|
31 | + public function __construct() |
|
32 | + { |
|
33 | + $this->dirname = \basename(\dirname(__DIR__, 2)); |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * Add link to breadcrumb |
|
38 | - * |
|
39 | - * @param string $title |
|
40 | - * @param string $link |
|
41 | - */ |
|
42 | - public function addLink($title = '', $link = ''): void |
|
43 | - { |
|
44 | - $this->bread[] = [ |
|
45 | - 'link' => $link, |
|
46 | - 'title' => $title, |
|
47 | - ]; |
|
48 | - } |
|
36 | + /** |
|
37 | + * Add link to breadcrumb |
|
38 | + * |
|
39 | + * @param string $title |
|
40 | + * @param string $link |
|
41 | + */ |
|
42 | + public function addLink($title = '', $link = ''): void |
|
43 | + { |
|
44 | + $this->bread[] = [ |
|
45 | + 'link' => $link, |
|
46 | + 'title' => $title, |
|
47 | + ]; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * Render BreadCrumb |
|
52 | - */ |
|
53 | - public function render(): void |
|
54 | - { |
|
55 | - /* |
|
50 | + /** |
|
51 | + * Render BreadCrumb |
|
52 | + */ |
|
53 | + public function render(): void |
|
54 | + { |
|
55 | + /* |
|
56 | 56 | TODO if you want to use the render code below, |
57 | 57 | 1) create ./templates/chess_common_breadcrumb.tpl) |
58 | 58 | 2) add declaration to xoops_version.php |
59 | 59 | */ |
60 | - /* |
|
60 | + /* |
|
61 | 61 | if (!isset($GLOBALS['xoTheme']) || !\is_object($GLOBALS['xoTheme'])) { |
62 | 62 | require $GLOBALS['xoops']->path('class/theme.php'); |
63 | 63 | |
@@ -76,5 +76,5 @@ discard block |
||
76 | 76 | |
77 | 77 | return $html; |
78 | 78 | */ |
79 | - } |
|
79 | + } |
|
80 | 80 | } |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | //check for minimum XOOPS version |
41 | 41 | $currentVer = mb_substr(\XOOPS_VERSION, 6); // get the numeric part of string |
42 | 42 | if (null === $requiredVer) { |
43 | - $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string |
|
43 | + $requiredVer = ''.$module->getInfo('min_xoops'); //making sure it's a string |
|
44 | 44 | } |
45 | 45 | $success = true; |
46 | 46 | |
47 | 47 | if (\version_compare($currentVer, $requiredVer, '<')) { |
48 | 48 | $success = false; |
49 | - $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer)); |
|
49 | + $module->setErrors(\sprintf(\constant('CO_'.$moduleDirNameUpper.'_ERROR_BAD_XOOPS'), $requiredVer, $currentVer)); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | return $success; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | if (false !== $reqVer && '' !== $reqVer) { |
79 | 79 | if (\version_compare($verNum, $reqVer, '<')) { |
80 | - $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum)); |
|
80 | + $module->setErrors(\sprintf(\constant('CO_'.$moduleDirNameUpper.'_ERROR_BAD_PHP'), $reqVer, $verNum)); |
|
81 | 81 | $success = false; |
82 | 82 | } |
83 | 83 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $moduleDirName = \basename(\dirname(__DIR__, 2)); |
97 | 97 | $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
98 | 98 | $update = ''; |
99 | - $repository = 'XoopsModules25x/' . $moduleDirName; |
|
99 | + $repository = 'XoopsModules25x/'.$moduleDirName; |
|
100 | 100 | // $repository = 'XoopsModules25x/publisher'; //for testing only |
101 | 101 | $ret = null; |
102 | 102 | $infoReleasesUrl = "https://api.github.com/repos/$repository/releases"; |
@@ -110,14 +110,14 @@ discard block |
||
110 | 110 | if (false === $curlReturn) { |
111 | 111 | \trigger_error(\curl_error($curlHandle)); |
112 | 112 | } elseif (false !== \mb_strpos($curlReturn, 'Not Found')) { |
113 | - \trigger_error('Repository Not Found: ' . $infoReleasesUrl); |
|
113 | + \trigger_error('Repository Not Found: '.$infoReleasesUrl); |
|
114 | 114 | } else { |
115 | 115 | $file = json_decode($curlReturn, false); |
116 | 116 | $latestVersionLink = \sprintf("https://github.com/$repository/archive/%s.zip", $file ? \reset($file)->tag_name : $default); |
117 | 117 | $latestVersion = $file[0]->tag_name; |
118 | 118 | $prerelease = $file[0]->prerelease; |
119 | 119 | if ('master' !== $latestVersionLink) { |
120 | - $update = \constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion; |
|
120 | + $update = \constant('CO_'.$moduleDirNameUpper.'_'.'NEW_VERSION').$latestVersion; |
|
121 | 121 | } |
122 | 122 | //"PHP-standardized" version |
123 | 123 | $latestVersion = \mb_strtolower($latestVersion); |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $latestVersion = \str_replace('_', '', \mb_strtolower($latestVersion)); |
126 | 126 | $latestVersion = \str_replace('final', '', \mb_strtolower($latestVersion)); |
127 | 127 | } |
128 | - $moduleVersion = ($helper->getModule()->getInfo('version') . '_' . $helper->getModule()->getInfo('module_status')); |
|
128 | + $moduleVersion = ($helper->getModule()->getInfo('version').'_'.$helper->getModule()->getInfo('module_status')); |
|
129 | 129 | //"PHP-standardized" version |
130 | 130 | $moduleVersion = \str_replace(' ', '', \mb_strtolower($moduleVersion)); |
131 | 131 | // $moduleVersion = '1.0'; //for testing only |
@@ -19,127 +19,127 @@ |
||
19 | 19 | */ |
20 | 20 | trait VersionChecks |
21 | 21 | { |
22 | - /** |
|
23 | - * Verifies XOOPS version meets minimum requirements for this module |
|
24 | - * @static |
|
25 | - * @param \XoopsModule|null $module |
|
26 | - * |
|
27 | - * @param null|string $requiredVer |
|
28 | - * @return bool true if meets requirements, false if not |
|
29 | - */ |
|
30 | - public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null) |
|
31 | - { |
|
32 | - $moduleDirName = \basename(\dirname(__DIR__, 2)); |
|
33 | - $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
34 | - if (null === $module) { |
|
35 | - $module = \XoopsModule::getByDirname($moduleDirName); |
|
36 | - } |
|
37 | - \xoops_loadLanguage('admin', $moduleDirName); |
|
38 | - \xoops_loadLanguage('common', $moduleDirName); |
|
22 | + /** |
|
23 | + * Verifies XOOPS version meets minimum requirements for this module |
|
24 | + * @static |
|
25 | + * @param \XoopsModule|null $module |
|
26 | + * |
|
27 | + * @param null|string $requiredVer |
|
28 | + * @return bool true if meets requirements, false if not |
|
29 | + */ |
|
30 | + public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null) |
|
31 | + { |
|
32 | + $moduleDirName = \basename(\dirname(__DIR__, 2)); |
|
33 | + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
34 | + if (null === $module) { |
|
35 | + $module = \XoopsModule::getByDirname($moduleDirName); |
|
36 | + } |
|
37 | + \xoops_loadLanguage('admin', $moduleDirName); |
|
38 | + \xoops_loadLanguage('common', $moduleDirName); |
|
39 | 39 | |
40 | - //check for minimum XOOPS version |
|
41 | - $currentVer = mb_substr(\XOOPS_VERSION, 6); // get the numeric part of string |
|
42 | - if (null === $requiredVer) { |
|
43 | - $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string |
|
44 | - } |
|
45 | - $success = true; |
|
40 | + //check for minimum XOOPS version |
|
41 | + $currentVer = mb_substr(\XOOPS_VERSION, 6); // get the numeric part of string |
|
42 | + if (null === $requiredVer) { |
|
43 | + $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string |
|
44 | + } |
|
45 | + $success = true; |
|
46 | 46 | |
47 | - if (\version_compare($currentVer, $requiredVer, '<')) { |
|
48 | - $success = false; |
|
49 | - $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer)); |
|
50 | - } |
|
47 | + if (\version_compare($currentVer, $requiredVer, '<')) { |
|
48 | + $success = false; |
|
49 | + $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer)); |
|
50 | + } |
|
51 | 51 | |
52 | - return $success; |
|
53 | - } |
|
52 | + return $success; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Verifies PHP version meets minimum requirements for this module |
|
57 | - * @static |
|
58 | - * @param \XoopsModule|bool|null $module |
|
59 | - * |
|
60 | - * @return bool true if meets requirements, false if not |
|
61 | - */ |
|
62 | - public static function checkVerPhp(\XoopsModule $module = null) |
|
63 | - { |
|
64 | - $moduleDirName = \basename(\dirname(__DIR__, 2)); |
|
65 | - $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
66 | - if (null === $module) { |
|
67 | - $module = \XoopsModule::getByDirname($moduleDirName); |
|
68 | - } |
|
69 | - \xoops_loadLanguage('admin', $moduleDirName); |
|
70 | - \xoops_loadLanguage('common', $moduleDirName); |
|
55 | + /** |
|
56 | + * Verifies PHP version meets minimum requirements for this module |
|
57 | + * @static |
|
58 | + * @param \XoopsModule|bool|null $module |
|
59 | + * |
|
60 | + * @return bool true if meets requirements, false if not |
|
61 | + */ |
|
62 | + public static function checkVerPhp(\XoopsModule $module = null) |
|
63 | + { |
|
64 | + $moduleDirName = \basename(\dirname(__DIR__, 2)); |
|
65 | + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
66 | + if (null === $module) { |
|
67 | + $module = \XoopsModule::getByDirname($moduleDirName); |
|
68 | + } |
|
69 | + \xoops_loadLanguage('admin', $moduleDirName); |
|
70 | + \xoops_loadLanguage('common', $moduleDirName); |
|
71 | 71 | |
72 | - // check for minimum PHP version |
|
73 | - $success = true; |
|
72 | + // check for minimum PHP version |
|
73 | + $success = true; |
|
74 | 74 | |
75 | - $verNum = \PHP_VERSION; |
|
76 | - $reqVer = &$module->getInfo('min_php'); |
|
75 | + $verNum = \PHP_VERSION; |
|
76 | + $reqVer = &$module->getInfo('min_php'); |
|
77 | 77 | |
78 | - if (false !== $reqVer && '' !== $reqVer) { |
|
79 | - if (\version_compare($verNum, $reqVer, '<')) { |
|
80 | - $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum)); |
|
81 | - $success = false; |
|
82 | - } |
|
83 | - } |
|
78 | + if (false !== $reqVer && '' !== $reqVer) { |
|
79 | + if (\version_compare($verNum, $reqVer, '<')) { |
|
80 | + $module->setErrors(\sprintf(\constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum)); |
|
81 | + $success = false; |
|
82 | + } |
|
83 | + } |
|
84 | 84 | |
85 | - return $success; |
|
86 | - } |
|
85 | + return $success; |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * compares current module version with the latest GitHub release |
|
90 | - * @static |
|
91 | - * |
|
92 | - * @return string|array info about the latest module version, if newer |
|
93 | - */ |
|
94 | - public static function checkVerModule(\Xmf\Module\Helper $helper, ?string $source = 'github', ?string $default = 'master'): ?array |
|
95 | - { |
|
96 | - $moduleDirName = \basename(\dirname(__DIR__, 2)); |
|
97 | - $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
98 | - $update = ''; |
|
99 | - $repository = 'XoopsModules25x/' . $moduleDirName; |
|
100 | - // $repository = 'XoopsModules25x/publisher'; //for testing only |
|
101 | - $ret = null; |
|
102 | - $infoReleasesUrl = "https://api.github.com/repos/$repository/releases"; |
|
103 | - if ('github' === $source) { |
|
104 | - if (\function_exists('curl_init') && false !== ($curlHandle = \curl_init())) { |
|
105 | - \curl_setopt($curlHandle, \CURLOPT_URL, $infoReleasesUrl); |
|
106 | - \curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); |
|
107 | - \curl_setopt($curlHandle, \CURLOPT_SSL_VERIFYPEER, true); //TODO: how to avoid an error when 'Peer's Certificate issuer is not recognized' |
|
108 | - \curl_setopt($curlHandle, \CURLOPT_HTTPHEADER, ["User-Agent:Publisher\r\n"]); |
|
109 | - $curlReturn = \curl_exec($curlHandle); |
|
110 | - if (false === $curlReturn) { |
|
111 | - \trigger_error(\curl_error($curlHandle)); |
|
112 | - } elseif (false !== \mb_strpos($curlReturn, 'Not Found')) { |
|
113 | - \trigger_error('Repository Not Found: ' . $infoReleasesUrl); |
|
114 | - } else { |
|
115 | - $file = json_decode($curlReturn, false); |
|
116 | - $latestVersionLink = \sprintf("https://github.com/$repository/archive/%s.zip", $file ? \reset($file)->tag_name : $default); |
|
117 | - $latestVersion = $file[0]->tag_name; |
|
118 | - $prerelease = $file[0]->prerelease; |
|
119 | - if ('master' !== $latestVersionLink) { |
|
120 | - $update = \constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion; |
|
121 | - } |
|
122 | - //"PHP-standardized" version |
|
123 | - $latestVersion = \mb_strtolower($latestVersion); |
|
124 | - if (false !== mb_strpos($latestVersion, 'final')) { |
|
125 | - $latestVersion = \str_replace('_', '', \mb_strtolower($latestVersion)); |
|
126 | - $latestVersion = \str_replace('final', '', \mb_strtolower($latestVersion)); |
|
127 | - } |
|
128 | - $moduleVersion = ($helper->getModule()->getInfo('version') . '_' . $helper->getModule()->getInfo('module_status')); |
|
129 | - //"PHP-standardized" version |
|
130 | - $moduleVersion = \str_replace(' ', '', \mb_strtolower($moduleVersion)); |
|
131 | - // $moduleVersion = '1.0'; //for testing only |
|
132 | - // $moduleDirName = 'publisher'; //for testing only |
|
133 | - if (!$prerelease && \version_compare($moduleVersion, $latestVersion, '<')) { |
|
134 | - $ret = []; |
|
135 | - $ret[] = $update; |
|
136 | - $ret[] = $latestVersionLink; |
|
137 | - } |
|
138 | - } |
|
139 | - \curl_close($curlHandle); |
|
140 | - } |
|
141 | - } |
|
88 | + /** |
|
89 | + * compares current module version with the latest GitHub release |
|
90 | + * @static |
|
91 | + * |
|
92 | + * @return string|array info about the latest module version, if newer |
|
93 | + */ |
|
94 | + public static function checkVerModule(\Xmf\Module\Helper $helper, ?string $source = 'github', ?string $default = 'master'): ?array |
|
95 | + { |
|
96 | + $moduleDirName = \basename(\dirname(__DIR__, 2)); |
|
97 | + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
98 | + $update = ''; |
|
99 | + $repository = 'XoopsModules25x/' . $moduleDirName; |
|
100 | + // $repository = 'XoopsModules25x/publisher'; //for testing only |
|
101 | + $ret = null; |
|
102 | + $infoReleasesUrl = "https://api.github.com/repos/$repository/releases"; |
|
103 | + if ('github' === $source) { |
|
104 | + if (\function_exists('curl_init') && false !== ($curlHandle = \curl_init())) { |
|
105 | + \curl_setopt($curlHandle, \CURLOPT_URL, $infoReleasesUrl); |
|
106 | + \curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); |
|
107 | + \curl_setopt($curlHandle, \CURLOPT_SSL_VERIFYPEER, true); //TODO: how to avoid an error when 'Peer's Certificate issuer is not recognized' |
|
108 | + \curl_setopt($curlHandle, \CURLOPT_HTTPHEADER, ["User-Agent:Publisher\r\n"]); |
|
109 | + $curlReturn = \curl_exec($curlHandle); |
|
110 | + if (false === $curlReturn) { |
|
111 | + \trigger_error(\curl_error($curlHandle)); |
|
112 | + } elseif (false !== \mb_strpos($curlReturn, 'Not Found')) { |
|
113 | + \trigger_error('Repository Not Found: ' . $infoReleasesUrl); |
|
114 | + } else { |
|
115 | + $file = json_decode($curlReturn, false); |
|
116 | + $latestVersionLink = \sprintf("https://github.com/$repository/archive/%s.zip", $file ? \reset($file)->tag_name : $default); |
|
117 | + $latestVersion = $file[0]->tag_name; |
|
118 | + $prerelease = $file[0]->prerelease; |
|
119 | + if ('master' !== $latestVersionLink) { |
|
120 | + $update = \constant('CO_' . $moduleDirNameUpper . '_' . 'NEW_VERSION') . $latestVersion; |
|
121 | + } |
|
122 | + //"PHP-standardized" version |
|
123 | + $latestVersion = \mb_strtolower($latestVersion); |
|
124 | + if (false !== mb_strpos($latestVersion, 'final')) { |
|
125 | + $latestVersion = \str_replace('_', '', \mb_strtolower($latestVersion)); |
|
126 | + $latestVersion = \str_replace('final', '', \mb_strtolower($latestVersion)); |
|
127 | + } |
|
128 | + $moduleVersion = ($helper->getModule()->getInfo('version') . '_' . $helper->getModule()->getInfo('module_status')); |
|
129 | + //"PHP-standardized" version |
|
130 | + $moduleVersion = \str_replace(' ', '', \mb_strtolower($moduleVersion)); |
|
131 | + // $moduleVersion = '1.0'; //for testing only |
|
132 | + // $moduleDirName = 'publisher'; //for testing only |
|
133 | + if (!$prerelease && \version_compare($moduleVersion, $latestVersion, '<')) { |
|
134 | + $ret = []; |
|
135 | + $ret[] = $update; |
|
136 | + $ret[] = $latestVersionLink; |
|
137 | + } |
|
138 | + } |
|
139 | + \curl_close($curlHandle); |
|
140 | + } |
|
141 | + } |
|
142 | 142 | |
143 | - return $ret; |
|
144 | - } |
|
143 | + return $ret; |
|
144 | + } |
|
145 | 145 | } |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | |
63 | 63 | if (self::SHOW_BUTTONS == $displaySampleButton) { |
64 | 64 | \xoops_loadLanguage('admin/modulesadmin', 'system'); |
65 | - $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA'), $helper->url('testdata/index.php?op=load'), 'add'); |
|
66 | - $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), $helper->url('testdata/index.php?op=save'), 'add'); |
|
67 | - $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA'), $helper->url('testdata/index.php?op=clear'), 'alert'); |
|
65 | + $adminObject->addItemButton(\constant('CO_'.$moduleDirNameUpper.'_'.'LOAD_SAMPLEDATA'), $helper->url('testdata/index.php?op=load'), 'add'); |
|
66 | + $adminObject->addItemButton(\constant('CO_'.$moduleDirNameUpper.'_'.'SAVE_SAMPLEDATA'), $helper->url('testdata/index.php?op=save'), 'add'); |
|
67 | + $adminObject->addItemButton(\constant('CO_'.$moduleDirNameUpper.'_'.'CLEAR_SAMPLEDATA'), $helper->url('testdata/index.php?op=clear'), 'alert'); |
|
68 | 68 | // $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), $helper->url( 'testdata/index.php?op=exportschema'), 'add'); |
69 | - $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete'); |
|
69 | + $adminObject->addItemButton(\constant('CO_'.$moduleDirNameUpper.'_'.'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete'); |
|
70 | 70 | } else { |
71 | - $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add'); |
|
71 | + $adminObject->addItemButton(\constant('CO_'.$moduleDirNameUpper.'_'.'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add'); |
|
72 | 72 | // $displaySampleButton = $config['displaySampleButton']; |
73 | 73 | } |
74 | 74 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public static function hideButtons(): void |
82 | 82 | { |
83 | - $yamlFile = \dirname(__DIR__, 2) . '/config/admin.yml'; |
|
83 | + $yamlFile = \dirname(__DIR__, 2).'/config/admin.yml'; |
|
84 | 84 | $app = []; |
85 | 85 | $app['displaySampleButton'] = 0; |
86 | 86 | Yaml::save($app, $yamlFile); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public static function showButtons(): void |
96 | 96 | { |
97 | - $yamlFile = \dirname(__DIR__, 2) . '/config/admin.yml'; |
|
97 | + $yamlFile = \dirname(__DIR__, 2).'/config/admin.yml'; |
|
98 | 98 | $app = []; |
99 | 99 | $app['displaySampleButton'] = 1; |
100 | 100 | Yaml::save($app, $yamlFile); |
@@ -23,12 +23,12 @@ discard block |
||
23 | 23 | */ |
24 | 24 | |
25 | 25 | use Xmf\{ |
26 | - Module\Admin, |
|
27 | - Request, |
|
28 | - Yaml |
|
26 | + Module\Admin, |
|
27 | + Request, |
|
28 | + Yaml |
|
29 | 29 | }; |
30 | 30 | use XoopsModules\Myiframe\{ |
31 | - Helper |
|
31 | + Helper |
|
32 | 32 | }; |
33 | 33 | |
34 | 34 | /** @var Helper $helper */ |
@@ -40,65 +40,65 @@ discard block |
||
40 | 40 | */ |
41 | 41 | class TestdataButtons |
42 | 42 | { |
43 | - /** Button status constants */ |
|
44 | - private const SHOW_BUTTONS = 1; |
|
45 | - private const HIDE_BUTTONS = 0; |
|
43 | + /** Button status constants */ |
|
44 | + private const SHOW_BUTTONS = 1; |
|
45 | + private const HIDE_BUTTONS = 0; |
|
46 | 46 | |
47 | - /** |
|
48 | - * Load the test button configuration |
|
49 | - * |
|
50 | - * @param \Xmf\Module\Admin $adminObject |
|
51 | - * |
|
52 | - * @return void |
|
53 | - */ |
|
54 | - public static function loadButtonConfig($adminObject): void |
|
55 | - { |
|
56 | - $moduleDirName = \basename(\dirname(__DIR__, 2)); |
|
57 | - $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
58 | - $helper = Helper::getInstance(); |
|
59 | - $yamlFile = $helper->path('/config/admin.yml'); |
|
60 | - /** @var array $config */ |
|
61 | - $config = Yaml::readWrapped($yamlFile); // work with phpmyadmin YAML dumps |
|
62 | - $displaySampleButton = $config['displaySampleButton']; |
|
47 | + /** |
|
48 | + * Load the test button configuration |
|
49 | + * |
|
50 | + * @param \Xmf\Module\Admin $adminObject |
|
51 | + * |
|
52 | + * @return void |
|
53 | + */ |
|
54 | + public static function loadButtonConfig($adminObject): void |
|
55 | + { |
|
56 | + $moduleDirName = \basename(\dirname(__DIR__, 2)); |
|
57 | + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
58 | + $helper = Helper::getInstance(); |
|
59 | + $yamlFile = $helper->path('/config/admin.yml'); |
|
60 | + /** @var array $config */ |
|
61 | + $config = Yaml::readWrapped($yamlFile); // work with phpmyadmin YAML dumps |
|
62 | + $displaySampleButton = $config['displaySampleButton']; |
|
63 | 63 | |
64 | - if (self::SHOW_BUTTONS == $displaySampleButton) { |
|
65 | - \xoops_loadLanguage('admin/modulesadmin', 'system'); |
|
66 | - $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA'), $helper->url('testdata/index.php?op=load'), 'add'); |
|
67 | - $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), $helper->url('testdata/index.php?op=save'), 'add'); |
|
68 | - $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA'), $helper->url('testdata/index.php?op=clear'), 'alert'); |
|
69 | - // $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), $helper->url( 'testdata/index.php?op=exportschema'), 'add'); |
|
70 | - $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete'); |
|
71 | - } else { |
|
72 | - $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add'); |
|
73 | - // $displaySampleButton = $config['displaySampleButton']; |
|
74 | - } |
|
75 | - } |
|
64 | + if (self::SHOW_BUTTONS == $displaySampleButton) { |
|
65 | + \xoops_loadLanguage('admin/modulesadmin', 'system'); |
|
66 | + $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA'), $helper->url('testdata/index.php?op=load'), 'add'); |
|
67 | + $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), $helper->url('testdata/index.php?op=save'), 'add'); |
|
68 | + $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'CLEAR_SAMPLEDATA'), $helper->url('testdata/index.php?op=clear'), 'alert'); |
|
69 | + // $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), $helper->url( 'testdata/index.php?op=exportschema'), 'add'); |
|
70 | + $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete'); |
|
71 | + } else { |
|
72 | + $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add'); |
|
73 | + // $displaySampleButton = $config['displaySampleButton']; |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * Hide the test buttons |
|
79 | - * |
|
80 | - * @return void |
|
81 | - */ |
|
82 | - public static function hideButtons(): void |
|
83 | - { |
|
84 | - $yamlFile = \dirname(__DIR__, 2) . '/config/admin.yml'; |
|
85 | - $app = []; |
|
86 | - $app['displaySampleButton'] = 0; |
|
87 | - Yaml::save($app, $yamlFile); |
|
88 | - \redirect_header('index.php', 0, ''); |
|
89 | - } |
|
77 | + /** |
|
78 | + * Hide the test buttons |
|
79 | + * |
|
80 | + * @return void |
|
81 | + */ |
|
82 | + public static function hideButtons(): void |
|
83 | + { |
|
84 | + $yamlFile = \dirname(__DIR__, 2) . '/config/admin.yml'; |
|
85 | + $app = []; |
|
86 | + $app['displaySampleButton'] = 0; |
|
87 | + Yaml::save($app, $yamlFile); |
|
88 | + \redirect_header('index.php', 0, ''); |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * Show the test buttons |
|
93 | - * |
|
94 | - * @return void |
|
95 | - */ |
|
96 | - public static function showButtons(): void |
|
97 | - { |
|
98 | - $yamlFile = \dirname(__DIR__, 2) . '/config/admin.yml'; |
|
99 | - $app = []; |
|
100 | - $app['displaySampleButton'] = 1; |
|
101 | - Yaml::save($app, $yamlFile); |
|
102 | - \redirect_header('index.php', 0, ''); |
|
103 | - } |
|
91 | + /** |
|
92 | + * Show the test buttons |
|
93 | + * |
|
94 | + * @return void |
|
95 | + */ |
|
96 | + public static function showButtons(): void |
|
97 | + { |
|
98 | + $yamlFile = \dirname(__DIR__, 2) . '/config/admin.yml'; |
|
99 | + $app = []; |
|
100 | + $app['displaySampleButton'] = 1; |
|
101 | + Yaml::save($app, $yamlFile); |
|
102 | + \redirect_header('index.php', 0, ''); |
|
103 | + } |
|
104 | 104 | } |
@@ -19,60 +19,60 @@ |
||
19 | 19 | */ |
20 | 20 | trait ServerStats |
21 | 21 | { |
22 | - /** |
|
23 | - * serverStats() |
|
24 | - * |
|
25 | - * @return string |
|
26 | - */ |
|
27 | - public static function getServerStats() |
|
28 | - { |
|
29 | - //mb $wfdownloads = WfdownloadsWfdownloads::getInstance(); |
|
30 | - $moduleDirName = \basename(\dirname(__DIR__, 2)); |
|
31 | - $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
32 | - \xoops_loadLanguage('common', $moduleDirName); |
|
33 | - $html = ''; |
|
34 | - // $sql = 'SELECT metavalue'; |
|
35 | - // $sql .= ' FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_meta'); |
|
36 | - // $sql .= " WHERE metakey='version' LIMIT 1"; |
|
37 | - // $query = $GLOBALS['xoopsDB']->query($sql); |
|
38 | - // list($meta) = $GLOBALS['xoopsDB']->fetchRow($query); |
|
39 | - $html .= "<fieldset><legend style='font-weight: bold; color: #900;'>" . \constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . "</legend>\n"; |
|
40 | - $html .= "<div style='padding: 8px;'>\n"; |
|
41 | - // $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_METAVERSION') . $meta . "</div>\n"; |
|
42 | - // $html .= "<br>\n"; |
|
43 | - // $html .= "<br>\n"; |
|
44 | - $html .= '<div>' . \constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "</div>\n"; |
|
45 | - $html .= "<ul>\n"; |
|
22 | + /** |
|
23 | + * serverStats() |
|
24 | + * |
|
25 | + * @return string |
|
26 | + */ |
|
27 | + public static function getServerStats() |
|
28 | + { |
|
29 | + //mb $wfdownloads = WfdownloadsWfdownloads::getInstance(); |
|
30 | + $moduleDirName = \basename(\dirname(__DIR__, 2)); |
|
31 | + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
|
32 | + \xoops_loadLanguage('common', $moduleDirName); |
|
33 | + $html = ''; |
|
34 | + // $sql = 'SELECT metavalue'; |
|
35 | + // $sql .= ' FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_meta'); |
|
36 | + // $sql .= " WHERE metakey='version' LIMIT 1"; |
|
37 | + // $query = $GLOBALS['xoopsDB']->query($sql); |
|
38 | + // list($meta) = $GLOBALS['xoopsDB']->fetchRow($query); |
|
39 | + $html .= "<fieldset><legend style='font-weight: bold; color: #900;'>" . \constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . "</legend>\n"; |
|
40 | + $html .= "<div style='padding: 8px;'>\n"; |
|
41 | + // $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_METAVERSION') . $meta . "</div>\n"; |
|
42 | + // $html .= "<br>\n"; |
|
43 | + // $html .= "<br>\n"; |
|
44 | + $html .= '<div>' . \constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "</div>\n"; |
|
45 | + $html .= "<ul>\n"; |
|
46 | 46 | |
47 | - $gdlib = \function_exists('gd_info') ? '<span style="color: green;">' . \constant('CO_' . $moduleDirNameUpper . '_GDON') . '</span>' : '<span style="color: red;">' . \constant('CO_' . $moduleDirNameUpper . '_GDOFF') . '</span>'; |
|
48 | - $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib; |
|
49 | - if (\function_exists('gd_info')) { |
|
50 | - if (true === ($gdlib = gd_info())) { |
|
51 | - $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '<b>' . $gdlib['GD Version'] . '</b>'; |
|
52 | - } |
|
53 | - } |
|
54 | - // |
|
55 | - // $safemode = ini_get('safe_mode') ? constant('CO_' . $moduleDirNameUpper . '_ON') . constant('CO_' . $moduleDirNameUpper . '_SAFEMODEPROBLEMS : constant('CO_' . $moduleDirNameUpper . '_OFF'); |
|
56 | - // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SAFEMODESTATUS . $safemode; |
|
57 | - // |
|
58 | - // $registerglobals = (!ini_get('register_globals')) ? "<span style=\"color: green;\">" . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>' : "<span style=\"color: red;\">" . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>'; |
|
59 | - // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals; |
|
60 | - // |
|
61 | - $downloads = \ini_get('file_uploads') ? '<span style="color: green;">' . \constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>' : '<span style="color: red;">' . \constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>'; |
|
62 | - $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads; |
|
47 | + $gdlib = \function_exists('gd_info') ? '<span style="color: green;">' . \constant('CO_' . $moduleDirNameUpper . '_GDON') . '</span>' : '<span style="color: red;">' . \constant('CO_' . $moduleDirNameUpper . '_GDOFF') . '</span>'; |
|
48 | + $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib; |
|
49 | + if (\function_exists('gd_info')) { |
|
50 | + if (true === ($gdlib = gd_info())) { |
|
51 | + $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '<b>' . $gdlib['GD Version'] . '</b>'; |
|
52 | + } |
|
53 | + } |
|
54 | + // |
|
55 | + // $safemode = ini_get('safe_mode') ? constant('CO_' . $moduleDirNameUpper . '_ON') . constant('CO_' . $moduleDirNameUpper . '_SAFEMODEPROBLEMS : constant('CO_' . $moduleDirNameUpper . '_OFF'); |
|
56 | + // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SAFEMODESTATUS . $safemode; |
|
57 | + // |
|
58 | + // $registerglobals = (!ini_get('register_globals')) ? "<span style=\"color: green;\">" . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>' : "<span style=\"color: red;\">" . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>'; |
|
59 | + // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals; |
|
60 | + // |
|
61 | + $downloads = \ini_get('file_uploads') ? '<span style="color: green;">' . \constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>' : '<span style="color: red;">' . \constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>'; |
|
62 | + $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads; |
|
63 | 63 | |
64 | - $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' <b><span style="color: blue;">' . \ini_get('upload_max_filesize') . "</span></b>\n"; |
|
65 | - $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' <b><span style="color: blue;">' . \ini_get('post_max_size') . "</span></b>\n"; |
|
66 | - $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' <b><span style="color: blue;">' . \ini_get('memory_limit') . "</span></b>\n"; |
|
67 | - $html .= "</ul>\n"; |
|
68 | - $html .= "<ul>\n"; |
|
69 | - $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' <b>' . XOOPS_ROOT_PATH . "</b>\n"; |
|
70 | - $html .= "</ul>\n"; |
|
71 | - $html .= "<br>\n"; |
|
72 | - $html .= \constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n"; |
|
73 | - $html .= '</div>'; |
|
74 | - $html .= '</fieldset><br>'; |
|
64 | + $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' <b><span style="color: blue;">' . \ini_get('upload_max_filesize') . "</span></b>\n"; |
|
65 | + $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' <b><span style="color: blue;">' . \ini_get('post_max_size') . "</span></b>\n"; |
|
66 | + $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' <b><span style="color: blue;">' . \ini_get('memory_limit') . "</span></b>\n"; |
|
67 | + $html .= "</ul>\n"; |
|
68 | + $html .= "<ul>\n"; |
|
69 | + $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' <b>' . XOOPS_ROOT_PATH . "</b>\n"; |
|
70 | + $html .= "</ul>\n"; |
|
71 | + $html .= "<br>\n"; |
|
72 | + $html .= \constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n"; |
|
73 | + $html .= '</div>'; |
|
74 | + $html .= '</fieldset><br>'; |
|
75 | 75 | |
76 | - return $html; |
|
77 | - } |
|
76 | + return $html; |
|
77 | + } |
|
78 | 78 | } |
@@ -36,19 +36,19 @@ discard block |
||
36 | 36 | // $sql .= " WHERE metakey='version' LIMIT 1"; |
37 | 37 | // $query = $GLOBALS['xoopsDB']->query($sql); |
38 | 38 | // list($meta) = $GLOBALS['xoopsDB']->fetchRow($query); |
39 | - $html .= "<fieldset><legend style='font-weight: bold; color: #900;'>" . \constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . "</legend>\n"; |
|
39 | + $html .= "<fieldset><legend style='font-weight: bold; color: #900;'>".\constant('CO_'.$moduleDirNameUpper.'_IMAGEINFO')."</legend>\n"; |
|
40 | 40 | $html .= "<div style='padding: 8px;'>\n"; |
41 | 41 | // $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_METAVERSION') . $meta . "</div>\n"; |
42 | 42 | // $html .= "<br>\n"; |
43 | 43 | // $html .= "<br>\n"; |
44 | - $html .= '<div>' . \constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "</div>\n"; |
|
44 | + $html .= '<div>'.\constant('CO_'.$moduleDirNameUpper.'_SPHPINI')."</div>\n"; |
|
45 | 45 | $html .= "<ul>\n"; |
46 | 46 | |
47 | - $gdlib = \function_exists('gd_info') ? '<span style="color: green;">' . \constant('CO_' . $moduleDirNameUpper . '_GDON') . '</span>' : '<span style="color: red;">' . \constant('CO_' . $moduleDirNameUpper . '_GDOFF') . '</span>'; |
|
48 | - $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib; |
|
47 | + $gdlib = \function_exists('gd_info') ? '<span style="color: green;">'.\constant('CO_'.$moduleDirNameUpper.'_GDON').'</span>' : '<span style="color: red;">'.\constant('CO_'.$moduleDirNameUpper.'_GDOFF').'</span>'; |
|
48 | + $html .= '<li>'.\constant('CO_'.$moduleDirNameUpper.'_GDLIBSTATUS').$gdlib; |
|
49 | 49 | if (\function_exists('gd_info')) { |
50 | 50 | if (true === ($gdlib = gd_info())) { |
51 | - $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '<b>' . $gdlib['GD Version'] . '</b>'; |
|
51 | + $html .= '<li>'.\constant('CO_'.$moduleDirNameUpper.'_GDLIBVERSION').'<b>'.$gdlib['GD Version'].'</b>'; |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | // |
@@ -58,18 +58,18 @@ discard block |
||
58 | 58 | // $registerglobals = (!ini_get('register_globals')) ? "<span style=\"color: green;\">" . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>' : "<span style=\"color: red;\">" . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>'; |
59 | 59 | // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals; |
60 | 60 | // |
61 | - $downloads = \ini_get('file_uploads') ? '<span style="color: green;">' . \constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>' : '<span style="color: red;">' . \constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>'; |
|
62 | - $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads; |
|
61 | + $downloads = \ini_get('file_uploads') ? '<span style="color: green;">'.\constant('CO_'.$moduleDirNameUpper.'_ON').'</span>' : '<span style="color: red;">'.\constant('CO_'.$moduleDirNameUpper.'_OFF').'</span>'; |
|
62 | + $html .= '<li>'.\constant('CO_'.$moduleDirNameUpper.'_SERVERUPLOADSTATUS').$downloads; |
|
63 | 63 | |
64 | - $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' <b><span style="color: blue;">' . \ini_get('upload_max_filesize') . "</span></b>\n"; |
|
65 | - $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' <b><span style="color: blue;">' . \ini_get('post_max_size') . "</span></b>\n"; |
|
66 | - $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' <b><span style="color: blue;">' . \ini_get('memory_limit') . "</span></b>\n"; |
|
64 | + $html .= '<li>'.\constant('CO_'.$moduleDirNameUpper.'_MAXUPLOADSIZE').' <b><span style="color: blue;">'.\ini_get('upload_max_filesize')."</span></b>\n"; |
|
65 | + $html .= '<li>'.\constant('CO_'.$moduleDirNameUpper.'_MAXPOSTSIZE').' <b><span style="color: blue;">'.\ini_get('post_max_size')."</span></b>\n"; |
|
66 | + $html .= '<li>'.\constant('CO_'.$moduleDirNameUpper.'_MEMORYLIMIT').' <b><span style="color: blue;">'.\ini_get('memory_limit')."</span></b>\n"; |
|
67 | 67 | $html .= "</ul>\n"; |
68 | 68 | $html .= "<ul>\n"; |
69 | - $html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' <b>' . XOOPS_ROOT_PATH . "</b>\n"; |
|
69 | + $html .= '<li>'.\constant('CO_'.$moduleDirNameUpper.'_SERVERPATH').' <b>'.XOOPS_ROOT_PATH."</b>\n"; |
|
70 | 70 | $html .= "</ul>\n"; |
71 | 71 | $html .= "<br>\n"; |
72 | - $html .= \constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n"; |
|
72 | + $html .= \constant('CO_'.$moduleDirNameUpper.'_UPLOADPATHDSC')."\n"; |
|
73 | 73 | $html .= '</div>'; |
74 | 74 | $html .= '</fieldset><br>'; |
75 | 75 |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | throw new \RuntimeException(\sprintf('Unable to create the %s directory', $folder)); |
33 | 33 | } |
34 | 34 | |
35 | - file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
35 | + file_put_contents($folder.'/index.html', '<script>history.go(-1);</script>'); |
|
36 | 36 | } |
37 | 37 | } catch (\Throwable $e) { |
38 | 38 | echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
@@ -57,14 +57,14 @@ discard block |
||
57 | 57 | $dir = \opendir($src); |
58 | 58 | // @mkdir($dst); |
59 | 59 | if (!@\mkdir($dst) && !\is_dir($dst)) { |
60 | - throw new \RuntimeException('The directory ' . $dst . ' could not be created.'); |
|
60 | + throw new \RuntimeException('The directory '.$dst.' could not be created.'); |
|
61 | 61 | } |
62 | 62 | while (false !== ($file = \readdir($dir))) { |
63 | 63 | if (('.' !== $file) && ('..' !== $file)) { |
64 | - if (\is_dir($src . '/' . $file)) { |
|
65 | - self::recurseCopy($src . '/' . $file, $dst . '/' . $file); |
|
64 | + if (\is_dir($src.'/'.$file)) { |
|
65 | + self::recurseCopy($src.'/'.$file, $dst.'/'.$file); |
|
66 | 66 | } else { |
67 | - \copy($src . '/' . $file, $dst . '/' . $file); |
|
67 | + \copy($src.'/'.$file, $dst.'/'.$file); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | self::rrmdir($fObj->getPathname()); |
155 | 155 | } |
156 | 156 | } |
157 | - $iterator = null; // clear iterator Obj to close file/directory |
|
157 | + $iterator = null; // clear iterator Obj to close file/directory |
|
158 | 158 | |
159 | 159 | return \rmdir($src); // remove the directory & return results |
160 | 160 | } |
@@ -188,14 +188,14 @@ discard block |
||
188 | 188 | $iterator = new \DirectoryIterator($src); |
189 | 189 | foreach ($iterator as $fObj) { |
190 | 190 | if ($fObj->isFile()) { |
191 | - \rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
191 | + \rename($fObj->getPathname(), "{$dest}/".$fObj->getFilename()); |
|
192 | 192 | } elseif (!$fObj->isDot() && $fObj->isDir()) { |
193 | 193 | // Try recursively on directory |
194 | - self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
194 | + self::rmove($fObj->getPathname(), "{$dest}/".$fObj->getFilename()); |
|
195 | 195 | // rmdir($fObj->getPath()); // now delete the directory |
196 | 196 | } |
197 | 197 | } |
198 | - $iterator = null; // clear iterator Obj to close file/directory |
|
198 | + $iterator = null; // clear iterator Obj to close file/directory |
|
199 | 199 | |
200 | 200 | return \rmdir($src); // remove the directory & return results |
201 | 201 | } |
@@ -232,9 +232,9 @@ discard block |
||
232 | 232 | $iterator = new \DirectoryIterator($src); |
233 | 233 | foreach ($iterator as $fObj) { |
234 | 234 | if ($fObj->isFile()) { |
235 | - \copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
235 | + \copy($fObj->getPathname(), "{$dest}/".$fObj->getFilename()); |
|
236 | 236 | } elseif (!$fObj->isDot() && $fObj->isDir()) { |
237 | - self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
237 | + self::rcopy($fObj->getPathname(), "{$dest}/".$fObj->getFilename()); |
|
238 | 238 | } |
239 | 239 | } |
240 | 240 |
@@ -19,226 +19,226 @@ |
||
19 | 19 | */ |
20 | 20 | trait FilesManagement |
21 | 21 | { |
22 | - /** |
|
23 | - * Function responsible for checking if a directory exists, we can also write in and create an index.html file |
|
24 | - * |
|
25 | - * @param string $folder The full path of the directory to check |
|
26 | - */ |
|
27 | - public static function createFolder($folder): void |
|
28 | - { |
|
29 | - try { |
|
30 | - if (!\is_dir($folder)) { |
|
31 | - if (!\is_dir($folder) && !\mkdir($folder) && !\is_dir($folder)) { |
|
32 | - throw new \RuntimeException(\sprintf('Unable to create the %s directory', $folder)); |
|
33 | - } |
|
34 | - |
|
35 | - file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
36 | - } |
|
37 | - } catch (\Throwable $e) { |
|
38 | - echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
39 | - } |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * @param string $file |
|
44 | - * @param string $folder |
|
45 | - * @return bool |
|
46 | - */ |
|
47 | - public static function copyFile(string $file, string $folder): bool |
|
48 | - { |
|
49 | - return \copy($file, $folder); |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * @param $src |
|
54 | - * @param $dst |
|
55 | - */ |
|
56 | - public static function recurseCopy($src, $dst): void |
|
57 | - { |
|
58 | - $dir = \opendir($src); |
|
59 | - // @mkdir($dst); |
|
60 | - if (!@\mkdir($dst) && !\is_dir($dst)) { |
|
61 | - throw new \RuntimeException('The directory ' . $dst . ' could not be created.'); |
|
62 | - } |
|
63 | - while (false !== ($file = \readdir($dir))) { |
|
64 | - if (('.' !== $file) && ('..' !== $file)) { |
|
65 | - if (\is_dir($src . '/' . $file)) { |
|
66 | - self::recurseCopy($src . '/' . $file, $dst . '/' . $file); |
|
67 | - } else { |
|
68 | - \copy($src . '/' . $file, $dst . '/' . $file); |
|
69 | - } |
|
70 | - } |
|
71 | - } |
|
72 | - \closedir($dir); |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * Remove files and (sub)directories |
|
77 | - * |
|
78 | - * @param string $src source directory to delete |
|
79 | - * |
|
80 | - * @return bool true on success |
|
81 | - * @uses \Xmf\Module\Helper::isUserAdmin() |
|
82 | - * |
|
83 | - * @uses \Xmf\Module\Helper::getHelper() |
|
84 | - */ |
|
85 | - public static function deleteDirectory($src) |
|
86 | - { |
|
87 | - // Only continue if user is a 'global' Admin |
|
88 | - if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
89 | - return false; |
|
90 | - } |
|
91 | - |
|
92 | - $success = true; |
|
93 | - // remove old files |
|
94 | - $dirInfo = new \SplFileInfo($src); |
|
95 | - // validate is a directory |
|
96 | - if ($dirInfo->isDir()) { |
|
97 | - $fileList = \array_diff(\scandir($src, \SCANDIR_SORT_NONE), ['..', '.']); |
|
98 | - foreach ($fileList as $k => $v) { |
|
99 | - $fileInfo = new \SplFileInfo("{$src}/{$v}"); |
|
100 | - if ($fileInfo->isDir()) { |
|
101 | - // recursively handle subdirectories |
|
102 | - if (!$success = self::deleteDirectory($fileInfo->getRealPath())) { |
|
103 | - break; |
|
104 | - } |
|
105 | - } elseif (!($success = \unlink($fileInfo->getRealPath()))) { |
|
106 | - break; |
|
107 | - } |
|
108 | - } |
|
109 | - // now delete this (sub)directory if all the files are gone |
|
110 | - if ($success) { |
|
111 | - $success = \rmdir($dirInfo->getRealPath()); |
|
112 | - } |
|
113 | - } else { |
|
114 | - // input is not a valid directory |
|
115 | - $success = false; |
|
116 | - } |
|
117 | - |
|
118 | - return $success; |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * Recursively remove directory |
|
123 | - * |
|
124 | - * @todo currently won't remove directories with hidden files, should it? |
|
125 | - * |
|
126 | - * @param string $src directory to remove (delete) |
|
127 | - * |
|
128 | - * @return bool true on success |
|
129 | - */ |
|
130 | - public static function rrmdir($src) |
|
131 | - { |
|
132 | - // Only continue if user is a 'global' Admin |
|
133 | - if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
134 | - return false; |
|
135 | - } |
|
136 | - |
|
137 | - // If source is not a directory stop processing |
|
138 | - if (!\is_dir($src)) { |
|
139 | - return false; |
|
140 | - } |
|
141 | - |
|
142 | - $success = true; |
|
143 | - |
|
144 | - // Open the source directory to read in files |
|
145 | - $iterator = new \DirectoryIterator($src); |
|
146 | - foreach ($iterator as $fObj) { |
|
147 | - if ($fObj->isFile()) { |
|
148 | - $filename = $fObj->getPathname(); |
|
149 | - $fObj = null; // clear this iterator object to close the file |
|
150 | - if (!\unlink($filename)) { |
|
151 | - return false; // couldn't delete the file |
|
152 | - } |
|
153 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
154 | - // Try recursively on directory |
|
155 | - self::rrmdir($fObj->getPathname()); |
|
156 | - } |
|
157 | - } |
|
158 | - $iterator = null; // clear iterator Obj to close file/directory |
|
159 | - |
|
160 | - return \rmdir($src); // remove the directory & return results |
|
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * Recursively move files from one directory to another |
|
165 | - * |
|
166 | - * @param string $src - Source of files being moved |
|
167 | - * @param string $dest - Destination of files being moved |
|
168 | - * |
|
169 | - * @return bool true on success |
|
170 | - */ |
|
171 | - public static function rmove($src, $dest) |
|
172 | - { |
|
173 | - // Only continue if user is a 'global' Admin |
|
174 | - if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
175 | - return false; |
|
176 | - } |
|
177 | - |
|
178 | - // If source is not a directory stop processing |
|
179 | - if (!\is_dir($src)) { |
|
180 | - return false; |
|
181 | - } |
|
182 | - |
|
183 | - // If the destination directory does not exist and could not be created stop processing |
|
184 | - if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) { |
|
185 | - return false; |
|
186 | - } |
|
187 | - |
|
188 | - // Open the source directory to read in files |
|
189 | - $iterator = new \DirectoryIterator($src); |
|
190 | - foreach ($iterator as $fObj) { |
|
191 | - if ($fObj->isFile()) { |
|
192 | - \rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
193 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
194 | - // Try recursively on directory |
|
195 | - self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
196 | - // rmdir($fObj->getPath()); // now delete the directory |
|
197 | - } |
|
198 | - } |
|
199 | - $iterator = null; // clear iterator Obj to close file/directory |
|
200 | - |
|
201 | - return \rmdir($src); // remove the directory & return results |
|
202 | - } |
|
203 | - |
|
204 | - /** |
|
205 | - * Recursively copy directories and files from one directory to another |
|
206 | - * |
|
207 | - * @param string $src - Source of files being moved |
|
208 | - * @param string $dest - Destination of files being moved |
|
209 | - * |
|
210 | - * @return bool true on success |
|
211 | - * @uses \Xmf\Module\Helper::isUserAdmin() |
|
212 | - * |
|
213 | - * @uses \Xmf\Module\Helper::getHelper() |
|
214 | - */ |
|
215 | - public static function rcopy($src, $dest) |
|
216 | - { |
|
217 | - // Only continue if user is a 'global' Admin |
|
218 | - if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
219 | - return false; |
|
220 | - } |
|
221 | - |
|
222 | - // If source is not a directory stop processing |
|
223 | - if (!\is_dir($src)) { |
|
224 | - return false; |
|
225 | - } |
|
226 | - |
|
227 | - // If the destination directory does not exist and could not be created stop processing |
|
228 | - if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) { |
|
229 | - return false; |
|
230 | - } |
|
231 | - |
|
232 | - // Open the source directory to read in files |
|
233 | - $iterator = new \DirectoryIterator($src); |
|
234 | - foreach ($iterator as $fObj) { |
|
235 | - if ($fObj->isFile()) { |
|
236 | - \copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
237 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
238 | - self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
239 | - } |
|
240 | - } |
|
241 | - |
|
242 | - return true; |
|
243 | - } |
|
22 | + /** |
|
23 | + * Function responsible for checking if a directory exists, we can also write in and create an index.html file |
|
24 | + * |
|
25 | + * @param string $folder The full path of the directory to check |
|
26 | + */ |
|
27 | + public static function createFolder($folder): void |
|
28 | + { |
|
29 | + try { |
|
30 | + if (!\is_dir($folder)) { |
|
31 | + if (!\is_dir($folder) && !\mkdir($folder) && !\is_dir($folder)) { |
|
32 | + throw new \RuntimeException(\sprintf('Unable to create the %s directory', $folder)); |
|
33 | + } |
|
34 | + |
|
35 | + file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
36 | + } |
|
37 | + } catch (\Throwable $e) { |
|
38 | + echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
39 | + } |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * @param string $file |
|
44 | + * @param string $folder |
|
45 | + * @return bool |
|
46 | + */ |
|
47 | + public static function copyFile(string $file, string $folder): bool |
|
48 | + { |
|
49 | + return \copy($file, $folder); |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * @param $src |
|
54 | + * @param $dst |
|
55 | + */ |
|
56 | + public static function recurseCopy($src, $dst): void |
|
57 | + { |
|
58 | + $dir = \opendir($src); |
|
59 | + // @mkdir($dst); |
|
60 | + if (!@\mkdir($dst) && !\is_dir($dst)) { |
|
61 | + throw new \RuntimeException('The directory ' . $dst . ' could not be created.'); |
|
62 | + } |
|
63 | + while (false !== ($file = \readdir($dir))) { |
|
64 | + if (('.' !== $file) && ('..' !== $file)) { |
|
65 | + if (\is_dir($src . '/' . $file)) { |
|
66 | + self::recurseCopy($src . '/' . $file, $dst . '/' . $file); |
|
67 | + } else { |
|
68 | + \copy($src . '/' . $file, $dst . '/' . $file); |
|
69 | + } |
|
70 | + } |
|
71 | + } |
|
72 | + \closedir($dir); |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * Remove files and (sub)directories |
|
77 | + * |
|
78 | + * @param string $src source directory to delete |
|
79 | + * |
|
80 | + * @return bool true on success |
|
81 | + * @uses \Xmf\Module\Helper::isUserAdmin() |
|
82 | + * |
|
83 | + * @uses \Xmf\Module\Helper::getHelper() |
|
84 | + */ |
|
85 | + public static function deleteDirectory($src) |
|
86 | + { |
|
87 | + // Only continue if user is a 'global' Admin |
|
88 | + if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
89 | + return false; |
|
90 | + } |
|
91 | + |
|
92 | + $success = true; |
|
93 | + // remove old files |
|
94 | + $dirInfo = new \SplFileInfo($src); |
|
95 | + // validate is a directory |
|
96 | + if ($dirInfo->isDir()) { |
|
97 | + $fileList = \array_diff(\scandir($src, \SCANDIR_SORT_NONE), ['..', '.']); |
|
98 | + foreach ($fileList as $k => $v) { |
|
99 | + $fileInfo = new \SplFileInfo("{$src}/{$v}"); |
|
100 | + if ($fileInfo->isDir()) { |
|
101 | + // recursively handle subdirectories |
|
102 | + if (!$success = self::deleteDirectory($fileInfo->getRealPath())) { |
|
103 | + break; |
|
104 | + } |
|
105 | + } elseif (!($success = \unlink($fileInfo->getRealPath()))) { |
|
106 | + break; |
|
107 | + } |
|
108 | + } |
|
109 | + // now delete this (sub)directory if all the files are gone |
|
110 | + if ($success) { |
|
111 | + $success = \rmdir($dirInfo->getRealPath()); |
|
112 | + } |
|
113 | + } else { |
|
114 | + // input is not a valid directory |
|
115 | + $success = false; |
|
116 | + } |
|
117 | + |
|
118 | + return $success; |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * Recursively remove directory |
|
123 | + * |
|
124 | + * @todo currently won't remove directories with hidden files, should it? |
|
125 | + * |
|
126 | + * @param string $src directory to remove (delete) |
|
127 | + * |
|
128 | + * @return bool true on success |
|
129 | + */ |
|
130 | + public static function rrmdir($src) |
|
131 | + { |
|
132 | + // Only continue if user is a 'global' Admin |
|
133 | + if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
134 | + return false; |
|
135 | + } |
|
136 | + |
|
137 | + // If source is not a directory stop processing |
|
138 | + if (!\is_dir($src)) { |
|
139 | + return false; |
|
140 | + } |
|
141 | + |
|
142 | + $success = true; |
|
143 | + |
|
144 | + // Open the source directory to read in files |
|
145 | + $iterator = new \DirectoryIterator($src); |
|
146 | + foreach ($iterator as $fObj) { |
|
147 | + if ($fObj->isFile()) { |
|
148 | + $filename = $fObj->getPathname(); |
|
149 | + $fObj = null; // clear this iterator object to close the file |
|
150 | + if (!\unlink($filename)) { |
|
151 | + return false; // couldn't delete the file |
|
152 | + } |
|
153 | + } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
154 | + // Try recursively on directory |
|
155 | + self::rrmdir($fObj->getPathname()); |
|
156 | + } |
|
157 | + } |
|
158 | + $iterator = null; // clear iterator Obj to close file/directory |
|
159 | + |
|
160 | + return \rmdir($src); // remove the directory & return results |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * Recursively move files from one directory to another |
|
165 | + * |
|
166 | + * @param string $src - Source of files being moved |
|
167 | + * @param string $dest - Destination of files being moved |
|
168 | + * |
|
169 | + * @return bool true on success |
|
170 | + */ |
|
171 | + public static function rmove($src, $dest) |
|
172 | + { |
|
173 | + // Only continue if user is a 'global' Admin |
|
174 | + if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
175 | + return false; |
|
176 | + } |
|
177 | + |
|
178 | + // If source is not a directory stop processing |
|
179 | + if (!\is_dir($src)) { |
|
180 | + return false; |
|
181 | + } |
|
182 | + |
|
183 | + // If the destination directory does not exist and could not be created stop processing |
|
184 | + if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) { |
|
185 | + return false; |
|
186 | + } |
|
187 | + |
|
188 | + // Open the source directory to read in files |
|
189 | + $iterator = new \DirectoryIterator($src); |
|
190 | + foreach ($iterator as $fObj) { |
|
191 | + if ($fObj->isFile()) { |
|
192 | + \rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
193 | + } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
194 | + // Try recursively on directory |
|
195 | + self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
196 | + // rmdir($fObj->getPath()); // now delete the directory |
|
197 | + } |
|
198 | + } |
|
199 | + $iterator = null; // clear iterator Obj to close file/directory |
|
200 | + |
|
201 | + return \rmdir($src); // remove the directory & return results |
|
202 | + } |
|
203 | + |
|
204 | + /** |
|
205 | + * Recursively copy directories and files from one directory to another |
|
206 | + * |
|
207 | + * @param string $src - Source of files being moved |
|
208 | + * @param string $dest - Destination of files being moved |
|
209 | + * |
|
210 | + * @return bool true on success |
|
211 | + * @uses \Xmf\Module\Helper::isUserAdmin() |
|
212 | + * |
|
213 | + * @uses \Xmf\Module\Helper::getHelper() |
|
214 | + */ |
|
215 | + public static function rcopy($src, $dest) |
|
216 | + { |
|
217 | + // Only continue if user is a 'global' Admin |
|
218 | + if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
219 | + return false; |
|
220 | + } |
|
221 | + |
|
222 | + // If source is not a directory stop processing |
|
223 | + if (!\is_dir($src)) { |
|
224 | + return false; |
|
225 | + } |
|
226 | + |
|
227 | + // If the destination directory does not exist and could not be created stop processing |
|
228 | + if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) { |
|
229 | + return false; |
|
230 | + } |
|
231 | + |
|
232 | + // Open the source directory to read in files |
|
233 | + $iterator = new \DirectoryIterator($src); |
|
234 | + foreach ($iterator as $fObj) { |
|
235 | + if ($fObj->isFile()) { |
|
236 | + \copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
237 | + } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
238 | + self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
239 | + } |
|
240 | + } |
|
241 | + |
|
242 | + return true; |
|
243 | + } |
|
244 | 244 | } |