@@ -5,149 +5,149 @@ |
||
5 | 5 | */ |
6 | 6 | class SmartObjectUtility extends XoopsObject |
7 | 7 | { |
8 | - /** |
|
9 | - * Function responsible for checking if a directory exists, we can also write in and create an index.html file |
|
10 | - * |
|
11 | - * @param string $folder The full path of the directory to check |
|
12 | - * |
|
13 | - * @return void |
|
14 | - */ |
|
15 | - public static function createFolder($folder) |
|
16 | - { |
|
17 | - // try { |
|
18 | - // if (!mkdir($folder) && !is_dir($folder)) { |
|
19 | - // throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); |
|
20 | - // } else { |
|
21 | - // file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
22 | - // } |
|
23 | - // } |
|
24 | - // catch (Exception $e) { |
|
25 | - // echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
26 | - // } |
|
27 | - try { |
|
28 | - if (!file_exists($folder)) { |
|
29 | - if (!mkdir($folder) && !is_dir($folder)) { |
|
30 | - throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); |
|
31 | - } else { |
|
32 | - file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
33 | - } |
|
34 | - } |
|
35 | - } catch (Exception $e) { |
|
36 | - echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
37 | - } |
|
38 | - } |
|
8 | + /** |
|
9 | + * Function responsible for checking if a directory exists, we can also write in and create an index.html file |
|
10 | + * |
|
11 | + * @param string $folder The full path of the directory to check |
|
12 | + * |
|
13 | + * @return void |
|
14 | + */ |
|
15 | + public static function createFolder($folder) |
|
16 | + { |
|
17 | + // try { |
|
18 | + // if (!mkdir($folder) && !is_dir($folder)) { |
|
19 | + // throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); |
|
20 | + // } else { |
|
21 | + // file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
22 | + // } |
|
23 | + // } |
|
24 | + // catch (Exception $e) { |
|
25 | + // echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
26 | + // } |
|
27 | + try { |
|
28 | + if (!file_exists($folder)) { |
|
29 | + if (!mkdir($folder) && !is_dir($folder)) { |
|
30 | + throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); |
|
31 | + } else { |
|
32 | + file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
33 | + } |
|
34 | + } |
|
35 | + } catch (Exception $e) { |
|
36 | + echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
37 | + } |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @param $file |
|
42 | - * @param $folder |
|
43 | - * @return bool |
|
44 | - */ |
|
45 | - public static function copyFile($file, $folder) |
|
46 | - { |
|
47 | - return copy($file, $folder); |
|
48 | - // try { |
|
49 | - // if (!is_dir($folder)) { |
|
50 | - // throw new \RuntimeException(sprintf('Unable to copy file as: %s ', $folder)); |
|
51 | - // } else { |
|
52 | - // return copy($file, $folder); |
|
53 | - // } |
|
54 | - // } catch (Exception $e) { |
|
55 | - // echo 'Caught exception: ', $e->getMessage(), "\n", "<br>"; |
|
56 | - // } |
|
57 | - // return false; |
|
58 | - } |
|
40 | + /** |
|
41 | + * @param $file |
|
42 | + * @param $folder |
|
43 | + * @return bool |
|
44 | + */ |
|
45 | + public static function copyFile($file, $folder) |
|
46 | + { |
|
47 | + return copy($file, $folder); |
|
48 | + // try { |
|
49 | + // if (!is_dir($folder)) { |
|
50 | + // throw new \RuntimeException(sprintf('Unable to copy file as: %s ', $folder)); |
|
51 | + // } else { |
|
52 | + // return copy($file, $folder); |
|
53 | + // } |
|
54 | + // } catch (Exception $e) { |
|
55 | + // echo 'Caught exception: ', $e->getMessage(), "\n", "<br>"; |
|
56 | + // } |
|
57 | + // return false; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @param $src |
|
62 | - * @param $dst |
|
63 | - */ |
|
64 | - public static function recurseCopy($src, $dst) |
|
65 | - { |
|
66 | - $dir = opendir($src); |
|
67 | - // @mkdir($dst); |
|
68 | - while (false !== ($file = readdir($dir))) { |
|
69 | - if (($file !== '.') && ($file !== '..')) { |
|
70 | - if (is_dir($src . '/' . $file)) { |
|
71 | - self::recurseCopy($src . '/' . $file, $dst . '/' . $file); |
|
72 | - } else { |
|
73 | - copy($src . '/' . $file, $dst . '/' . $file); |
|
74 | - } |
|
75 | - } |
|
76 | - } |
|
77 | - closedir($dir); |
|
78 | - } |
|
60 | + /** |
|
61 | + * @param $src |
|
62 | + * @param $dst |
|
63 | + */ |
|
64 | + public static function recurseCopy($src, $dst) |
|
65 | + { |
|
66 | + $dir = opendir($src); |
|
67 | + // @mkdir($dst); |
|
68 | + while (false !== ($file = readdir($dir))) { |
|
69 | + if (($file !== '.') && ($file !== '..')) { |
|
70 | + if (is_dir($src . '/' . $file)) { |
|
71 | + self::recurseCopy($src . '/' . $file, $dst . '/' . $file); |
|
72 | + } else { |
|
73 | + copy($src . '/' . $file, $dst . '/' . $file); |
|
74 | + } |
|
75 | + } |
|
76 | + } |
|
77 | + closedir($dir); |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * |
|
82 | - * Verifies XOOPS version meets minimum requirements for this module |
|
83 | - * @static |
|
84 | - * @param XoopsModule $module |
|
85 | - * |
|
86 | - * @param null|string $requiredVer |
|
87 | - * @return bool true if meets requirements, false if not |
|
88 | - */ |
|
89 | - public static function checkVerXoops(XoopsModule $module = null, $requiredVer = null) |
|
90 | - { |
|
91 | - $moduleDirName = basename(dirname(__DIR__)); |
|
92 | - if (null === $module) { |
|
93 | - $module = XoopsModule::getByDirname($moduleDirName); |
|
94 | - } |
|
95 | - xoops_loadLanguage('admin', $moduleDirName); |
|
96 | - //check for minimum XOOPS version |
|
97 | - $currentVer = substr(XOOPS_VERSION, 6); // get the numeric part of string |
|
98 | - $currArray = explode('.', $currentVer); |
|
99 | - if (null === $requiredVer) { |
|
100 | - $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string |
|
101 | - } |
|
102 | - $reqArray = explode('.', $requiredVer); |
|
103 | - $success = true; |
|
104 | - foreach ($reqArray as $k => $v) { |
|
105 | - if (isset($currArray[$k])) { |
|
106 | - if ($currArray[$k] > $v) { |
|
107 | - break; |
|
108 | - } elseif ($currArray[$k] == $v) { |
|
109 | - continue; |
|
110 | - } else { |
|
111 | - $success = false; |
|
112 | - break; |
|
113 | - } |
|
114 | - } else { |
|
115 | - if ((int)$v > 0) { // handles versions like x.x.x.0_RC2 |
|
116 | - $success = false; |
|
117 | - break; |
|
118 | - } |
|
119 | - } |
|
120 | - } |
|
80 | + /** |
|
81 | + * |
|
82 | + * Verifies XOOPS version meets minimum requirements for this module |
|
83 | + * @static |
|
84 | + * @param XoopsModule $module |
|
85 | + * |
|
86 | + * @param null|string $requiredVer |
|
87 | + * @return bool true if meets requirements, false if not |
|
88 | + */ |
|
89 | + public static function checkVerXoops(XoopsModule $module = null, $requiredVer = null) |
|
90 | + { |
|
91 | + $moduleDirName = basename(dirname(__DIR__)); |
|
92 | + if (null === $module) { |
|
93 | + $module = XoopsModule::getByDirname($moduleDirName); |
|
94 | + } |
|
95 | + xoops_loadLanguage('admin', $moduleDirName); |
|
96 | + //check for minimum XOOPS version |
|
97 | + $currentVer = substr(XOOPS_VERSION, 6); // get the numeric part of string |
|
98 | + $currArray = explode('.', $currentVer); |
|
99 | + if (null === $requiredVer) { |
|
100 | + $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string |
|
101 | + } |
|
102 | + $reqArray = explode('.', $requiredVer); |
|
103 | + $success = true; |
|
104 | + foreach ($reqArray as $k => $v) { |
|
105 | + if (isset($currArray[$k])) { |
|
106 | + if ($currArray[$k] > $v) { |
|
107 | + break; |
|
108 | + } elseif ($currArray[$k] == $v) { |
|
109 | + continue; |
|
110 | + } else { |
|
111 | + $success = false; |
|
112 | + break; |
|
113 | + } |
|
114 | + } else { |
|
115 | + if ((int)$v > 0) { // handles versions like x.x.x.0_RC2 |
|
116 | + $success = false; |
|
117 | + break; |
|
118 | + } |
|
119 | + } |
|
120 | + } |
|
121 | 121 | |
122 | - if (!$success) { |
|
123 | - $module->setErrors(sprintf(_AM_SOBJECT_ERROR_BAD_XOOPS, $requiredVer, $currentVer)); |
|
124 | - } |
|
122 | + if (!$success) { |
|
123 | + $module->setErrors(sprintf(_AM_SOBJECT_ERROR_BAD_XOOPS, $requiredVer, $currentVer)); |
|
124 | + } |
|
125 | 125 | |
126 | - return $success; |
|
127 | - } |
|
126 | + return $success; |
|
127 | + } |
|
128 | 128 | |
129 | - /** |
|
130 | - * |
|
131 | - * Verifies PHP version meets minimum requirements for this module |
|
132 | - * @static |
|
133 | - * @param XoopsModule $module |
|
134 | - * |
|
135 | - * @return bool true if meets requirements, false if not |
|
136 | - */ |
|
137 | - public static function checkVerPhp(XoopsModule $module) |
|
138 | - { |
|
139 | - xoops_loadLanguage('admin', $module->dirname()); |
|
140 | - // check for minimum PHP version |
|
141 | - $success = true; |
|
142 | - $verNum = PHP_VERSION; |
|
143 | - $reqVer = $module->getInfo('min_php'); |
|
144 | - if (false !== $reqVer && '' !== $reqVer) { |
|
145 | - if (version_compare($verNum, $reqVer, '<')) { |
|
146 | - $module->setErrors(sprintf(_AM_SOBJECT_ERROR_BAD_PHP, $reqVer, $verNum)); |
|
147 | - $success = false; |
|
148 | - } |
|
149 | - } |
|
129 | + /** |
|
130 | + * |
|
131 | + * Verifies PHP version meets minimum requirements for this module |
|
132 | + * @static |
|
133 | + * @param XoopsModule $module |
|
134 | + * |
|
135 | + * @return bool true if meets requirements, false if not |
|
136 | + */ |
|
137 | + public static function checkVerPhp(XoopsModule $module) |
|
138 | + { |
|
139 | + xoops_loadLanguage('admin', $module->dirname()); |
|
140 | + // check for minimum PHP version |
|
141 | + $success = true; |
|
142 | + $verNum = PHP_VERSION; |
|
143 | + $reqVer = $module->getInfo('min_php'); |
|
144 | + if (false !== $reqVer && '' !== $reqVer) { |
|
145 | + if (version_compare($verNum, $reqVer, '<')) { |
|
146 | + $module->setErrors(sprintf(_AM_SOBJECT_ERROR_BAD_PHP, $reqVer, $verNum)); |
|
147 | + $success = false; |
|
148 | + } |
|
149 | + } |
|
150 | 150 | |
151 | - return $success; |
|
152 | - } |
|
151 | + return $success; |
|
152 | + } |
|
153 | 153 | } |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | global $xoopsConfig; |
67 | 67 | $common_file = XOOPS_ROOT_PATH . '/modules/smartobject/language/' . $xoopsConfig['language'] . '/common.php'; |
68 | 68 | if (file_exists($common_file)) { |
69 | - $flag_common = true; |
|
70 | - require_once $common_file; |
|
69 | + $flag_common = true; |
|
70 | + require_once $common_file; |
|
71 | 71 | } else { |
72 | - require_once XOOPS_ROOT_PATH . '/modules/smartobject/language/english/common.php'; |
|
72 | + require_once XOOPS_ROOT_PATH . '/modules/smartobject/language/english/common.php'; |
|
73 | 73 | } |
74 | 74 | // ----- |
75 | 75 | |
@@ -105,10 +105,10 @@ discard block |
||
105 | 105 | |
106 | 106 | // ------------------- Help files ------------------- // |
107 | 107 | $modversion['helpsection'] = array( |
108 | - ['name' => _MI_SOBJECT_OVERVIEW, 'link' => 'page=help'], |
|
109 | - ['name' => _MI_SOBJECT_DISCLAIMER, 'link' => 'page=disclaimer'], |
|
110 | - ['name' => _MI_SOBJECT_LICENSE, 'link' => 'page=license'], |
|
111 | - ['name' => _MI_SOBJECT_SUPPORT, 'link' => 'page=support'], |
|
108 | + ['name' => _MI_SOBJECT_OVERVIEW, 'link' => 'page=help'], |
|
109 | + ['name' => _MI_SOBJECT_DISCLAIMER, 'link' => 'page=disclaimer'], |
|
110 | + ['name' => _MI_SOBJECT_LICENSE, 'link' => 'page=license'], |
|
111 | + ['name' => _MI_SOBJECT_SUPPORT, 'link' => 'page=support'], |
|
112 | 112 | ); |
113 | 113 | |
114 | 114 |