|
1 | | -<?php |
| 1 | +<?php declare(strict_types=1); |
2 | 2 |
|
3 | 3 | /* |
4 | 4 | You may not change or alter any portion of this comment or credits |
|
19 | 19 | * @since 2.5.5 |
20 | 20 | * |
21 | 21 | * @author Goffy https://myxoops.org |
22 | | - * |
23 | 22 | */ |
24 | 23 |
|
25 | 24 | use Xmf\Request; |
|
33 | 32 |
|
34 | 33 | require __DIR__ . '/header.php'; |
35 | 34 | // Recovered value of argument op in the URL $ |
36 | | -$op = Request::getString('op', 'list'); |
| 35 | +$op = Request::getString('op', 'list'); |
37 | 36 |
|
38 | 37 | switch ($op) { |
39 | 38 | case 'fq': |
40 | 39 | $fqModule = Request::getString('fq_module'); |
41 | 40 | $src_path = \XOOPS_ROOT_PATH . '/modules/' . $fqModule; |
42 | 41 | $dst_path = TDMC_UPLOAD_PATH . '/devtools/fq/' . $fqModule; |
43 | 42 |
|
44 | | - $patKeys = []; |
| 43 | + $patKeys = []; |
45 | 44 | $patValues = []; |
46 | 45 | //Devtools::cloneFileFolder($src_path, $dst_path, $patKeys, $patValues); |
47 | 46 | Devtools::function_qualifier($src_path, $dst_path, $fqModule); |
48 | 47 | \redirect_header('devtools.php', 3, \_AM_MODULEBUILDER_DEVTOOLS_FQ_SUCCESS); |
49 | 48 | break; |
50 | 49 | case 'check_lang': |
51 | 50 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('devtools.php')); |
52 | | - $clModuleName = Request::getString('cl_module'); |
| 51 | + $clModuleName = Request::getString('cl_module'); |
53 | 52 | $clModuleNameUpper = \mb_strtoupper($clModuleName); |
54 | 53 |
|
55 | 54 | //scan language files |
56 | | - $src_path = \XOOPS_ROOT_PATH . '/modules/' . $clModuleName . '/language/english/'; |
| 55 | + $src_path = \XOOPS_ROOT_PATH . '/modules/' . $clModuleName . '/language/english/'; |
57 | 56 | $langfiles = []; |
58 | 57 | foreach (scandir($src_path) as $scan) { |
59 | 58 | if (is_file($src_path . $scan) && 'index.html' !== $scan) { |
|
69 | 68 | } |
70 | 69 | $constantsAfterInclude = getUserDefinedConstants(); |
71 | 70 | foreach ($constantsAfterInclude as $constKey => $constValue) { |
72 | | - if (strpos($constKey, '_' . $clModuleNameUpper . '_') > 0) { |
| 71 | + if (mb_strpos($constKey, '_' . $clModuleNameUpper . '_') > 0) { |
73 | 72 | $moduleConstants[$constKey] = $constKey; |
74 | 73 | } |
75 | 74 | } |
76 | 75 |
|
77 | 76 | //get all php and tpl files from module |
78 | 77 | $check_path = \XOOPS_ROOT_PATH . '/modules/' . $clModuleName; |
79 | | - $Directory = new RecursiveDirectoryIterator($check_path); |
80 | | - $Iterator = new RecursiveIteratorIterator($Directory); |
| 78 | + $Directory = new RecursiveDirectoryIterator($check_path); |
| 79 | + $Iterator = new RecursiveIteratorIterator($Directory); |
81 | 80 | $regexFiles = new RegexIterator($Iterator, '/^.+\.(php|tpl)$/i', RecursiveRegexIterator::GET_MATCH); |
82 | 81 | //$files = new RegexIterator($flattened, '#^(?:[A-Z]:)?(?:/(?!\.Trash)[^/]+)+/[^/]+\.(?:php|html)$#Di'); |
83 | 82 | $modfiles = []; |
84 | | - foreach($regexFiles as $regexFiles) { |
| 83 | + foreach ($regexFiles as $regexFiles) { |
85 | 84 | $file = str_replace('\\', '/', $regexFiles[0]); |
86 | 85 | if (!\in_array($file, $langfiles)) { |
87 | 86 | $modfiles[] = $file; |
|
91 | 90 | //check all constants in all files |
92 | 91 | $resultCheck = []; |
93 | 92 | foreach ($moduleConstants as $constKey) { |
94 | | - $foundMod = 0; |
95 | | - $first = ''; |
| 93 | + $foundMod = 0; |
| 94 | + $first = ''; |
96 | 95 | $foundLang = 'not defined'; |
97 | 96 | //search for complete string |
98 | | - foreach($modfiles as $modfile) { |
99 | | - if( strpos(file_get_contents($modfile),$constKey) !== false) { |
| 97 | + foreach ($modfiles as $modfile) { |
| 98 | + if (mb_strpos(file_get_contents($modfile), $constKey) !== false) { |
100 | 99 | $foundMod = 1; |
101 | | - $first = $modfile; |
| 100 | + $first = $modfile; |
102 | 101 | break; |
103 | 102 | } |
104 | 103 | } |
105 | 104 | if (0 == $foundMod) { |
106 | 105 | //search for concatenated string |
107 | 106 | $needle = str_replace('_' . $clModuleNameUpper . '_', "_' . \$moduleDirNameUpper . '_", $constKey); |
108 | | - foreach($modfiles as $modfile) { |
109 | | - if( strpos(file_get_contents($modfile),$needle) !== false) { |
| 107 | + foreach ($modfiles as $modfile) { |
| 108 | + if (mb_strpos(file_get_contents($modfile), $needle) !== false) { |
110 | 109 | $foundMod = 1; |
111 | | - $first = $modfile; |
| 110 | + $first = $modfile; |
112 | 111 | break; |
113 | 112 | } |
114 | 113 | } |
115 | 114 | } |
116 | 115 | if (0 == $foundMod) { |
117 | 116 | //search for concatenated string |
118 | 117 | $needle = str_replace('_' . $clModuleNameUpper . '_', "_' . \$moduleDirNameUpper . '_' . '", $constKey); |
119 | | - foreach($modfiles as $modfile) { |
120 | | - if( strpos(file_get_contents($modfile),$needle) !== false) { |
| 118 | + foreach ($modfiles as $modfile) { |
| 119 | + if (mb_strpos(file_get_contents($modfile), $needle) !== false) { |
121 | 120 | $foundMod = 1; |
122 | | - $first = $modfile; |
| 121 | + $first = $modfile; |
123 | 122 | break; |
124 | 123 | } |
125 | 124 | } |
126 | 125 | } |
127 | | - foreach($langfiles as $langfile) { |
128 | | - if( strpos(file_get_contents($langfile),$constKey) !== false) { |
| 126 | + foreach ($langfiles as $langfile) { |
| 127 | + if (mb_strpos(file_get_contents($langfile), $constKey) !== false) { |
129 | 128 | $foundLang = $langfile; |
130 | 129 | break; |
131 | 130 | } |
132 | 131 | } |
133 | 132 | if ('' == $foundLang) { |
134 | 133 | //search for concatenated string |
135 | 134 | $needle = str_replace('_' . $clModuleNameUpper . '_', "_' . \$moduleDirNameUpper . '_", $constKey); |
136 | | - foreach($langfiles as $langfile) { |
137 | | - if( strpos(file_get_contents($langfile),$needle) !== false) { |
| 135 | + foreach ($langfiles as $langfile) { |
| 136 | + if (mb_strpos(file_get_contents($langfile), $needle) !== false) { |
138 | 137 | $foundLang = $langfile; |
139 | 138 | break; |
140 | 139 | } |
|
143 | 142 | if ('' == $foundLang) { |
144 | 143 | //search for concatenated string |
145 | 144 | $needle = str_replace('_' . $clModuleNameUpper . '_', "_' . \$moduleDirNameUpper . '_' . '", $constKey); |
146 | | - foreach($langfiles as $langfile) { |
147 | | - if( strpos(file_get_contents($langfile),$needle) !== false) { |
| 145 | + foreach ($langfiles as $langfile) { |
| 146 | + if (mb_strpos(file_get_contents($langfile), $needle) !== false) { |
148 | 147 | $foundLang = $langfile; |
149 | 148 | break; |
150 | 149 | } |
|
158 | 157 | break; |
159 | 158 | case 'tab_replacer': |
160 | 159 | $tabModule = Request::getString('tab_module'); |
161 | | - $src_path = \XOOPS_ROOT_PATH . '/modules/' . $tabModule; |
162 | | - $dst_path = TDMC_UPLOAD_PATH . '/devtools/tab/'; |
| 160 | + $src_path = \XOOPS_ROOT_PATH . '/modules/' . $tabModule; |
| 161 | + $dst_path = TDMC_UPLOAD_PATH . '/devtools/tab/'; |
163 | 162 | @\mkdir($dst_path); |
164 | 163 | $dst_path = TDMC_UPLOAD_PATH . '/devtools/tab/' . $tabModule; |
165 | 164 | @\mkdir($dst_path); |
|
171 | 170 | default: |
172 | 171 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('devtools.php')); |
173 | 172 | $dst_path = TDMC_UPLOAD_PATH . '/devtools/fq/'; |
174 | | - $GLOBALS['xoopsTpl']->assign('fq_desc',\str_replace('%s', $dst_path, \_AM_MODULEBUILDER_DEVTOOLS_FQ_DESC)); |
| 173 | + $GLOBALS['xoopsTpl']->assign('fq_desc', \str_replace('%s', $dst_path, \_AM_MODULEBUILDER_DEVTOOLS_FQ_DESC)); |
175 | 174 | $fq_form = Devtools::getFormModulesFq(); |
176 | 175 | $GLOBALS['xoopsTpl']->assign('fq_form', $fq_form->render()); |
177 | 176 | $cl_form = Devtools::getFormModulesCl(); |
178 | 177 | $GLOBALS['xoopsTpl']->assign('cl_form', $cl_form->render()); |
179 | 178 | $tab_form = Devtools::getFormModulesTab(); |
180 | 179 | $GLOBALS['xoopsTpl']->assign('tab_form', $tab_form->render()); |
181 | 180 | $dst_path = TDMC_UPLOAD_PATH . '/devtools/tab/'; |
182 | | - $GLOBALS['xoopsTpl']->assign('tab_desc',\str_replace('%s', $dst_path, \_AM_MODULEBUILDER_DEVTOOLS_TAB_DESC)); |
183 | | - $GLOBALS['xoopsTpl']->assign('devtools_list',true); |
| 181 | + $GLOBALS['xoopsTpl']->assign('tab_desc', \str_replace('%s', $dst_path, \_AM_MODULEBUILDER_DEVTOOLS_TAB_DESC)); |
| 182 | + $GLOBALS['xoopsTpl']->assign('devtools_list', true); |
184 | 183 |
|
185 | 184 | break; |
186 | 185 | } |
187 | 186 |
|
188 | | -function getUserDefinedConstants() { |
| 187 | +function getUserDefinedConstants() |
| 188 | +{ |
189 | 189 | $constants = get_defined_constants(true); |
190 | | - return (isset($constants['user']) ? $constants['user'] : []); |
| 190 | + |
| 191 | + return ($constants['user'] ?? []); |
191 | 192 | } |
192 | 193 |
|
193 | 194 | require __DIR__ . '/footer.php'; |
194 | | - |
195 | | - |
196 | | - |
197 | | - |
0 commit comments