Code Duplication    Length = 87-87 lines in 2 locations

install/cli-install.php 1 location

@@ 745-831 (lines=87) @@
742
// setup modules - array : name, description, type - 0:file or 1:content, file or content,properties, guid,enable_sharedparams
743
$mm = &$moduleModules;
744
$mdp = &$moduleDependencies;
745
if (is_dir($modulePath) && is_readable($modulePath)) {
746
    $d = dir($modulePath);
747
    while (false !== ($tplfile = $d->read())) {
748
        if (substr($tplfile, -4) != '.tpl') {
749
            continue;
750
        }
751
        $params = parse_docblock($modulePath, $tplfile);
752
        if (is_array($params) && count($params) > 0) {
753
            $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
754
            $mm[] = array(
755
                $params['name'],
756
                $description,
757
                "$modulePath/{$params['filename']}",
758
                $params['properties'],
759
                $params['guid'],
760
                (int)$params['shareparams'],
761
                $params['modx_category'],
762
                array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false
763
            );
764
        }
765
        if ((int)$params['shareparams'] || !empty($params['dependencies'])) {
766
            $dependencies = explode(',', $params['dependencies']);
767
            foreach ($dependencies as $dependency) {
768
                $dependency = explode(':', $dependency);
769
                switch (trim($dependency[0])) {
770
                    case 'template':
771
                        $mdp[] = array(
772
                            'module' => $params['name'],
773
                            'table'  => 'templates',
774
                            'column' => 'templatename',
775
                            'type'   => 50,
776
                            'name'   => trim($dependency[1])
777
                        );
778
                        break;
779
                    case 'tv':
780
                    case 'tmplvar':
781
                        $mdp[] = array(
782
                            'module' => $params['name'],
783
                            'table'  => 'tmplvars',
784
                            'column' => 'name',
785
                            'type'   => 60,
786
                            'name'   => trim($dependency[1])
787
                        );
788
                        break;
789
                    case 'chunk':
790
                    case 'htmlsnippet':
791
                        $mdp[] = array(
792
                            'module' => $params['name'],
793
                            'table'  => 'htmlsnippets',
794
                            'column' => 'name',
795
                            'type'   => 10,
796
                            'name'   => trim($dependency[1])
797
                        );
798
                        break;
799
                    case 'snippet':
800
                        $mdp[] = array(
801
                            'module' => $params['name'],
802
                            'table'  => 'snippets',
803
                            'column' => 'name',
804
                            'type'   => 40,
805
                            'name'   => trim($dependency[1])
806
                        );
807
                        break;
808
                    case 'plugin':
809
                        $mdp[] = array(
810
                            'module' => $params['name'],
811
                            'table'  => 'plugins',
812
                            'column' => 'name',
813
                            'type'   => 30,
814
                            'name'   => trim($dependency[1])
815
                        );
816
                        break;
817
                    case 'resource':
818
                        $mdp[] = array(
819
                            'module' => $params['name'],
820
                            'table'  => 'content',
821
                            'column' => 'pagetitle',
822
                            'type'   => 20,
823
                            'name'   => trim($dependency[1])
824
                        );
825
                        break;
826
                }
827
            }
828
        }
829
    }
830
    $d->close();
831
}
832
833
// setup callback function
834
$callBackFnc = "clean_up";

install/src/processor/result.php 1 location

@@ 162-248 (lines=87) @@
159
// setup modules - array : name, description, type - 0:file or 1:content, file or content,properties, guid,enable_sharedparams
160
$mm = &$moduleModules;
161
$mdp = &$moduleDependencies;
162
if (is_dir($modulePath) && is_readable($modulePath)) {
163
    $d = dir($modulePath);
164
    while (false !== ($tplfile = $d->read())) {
165
        if (substr($tplfile, -4) != '.tpl') {
166
            continue;
167
        }
168
        $params = parse_docblock($modulePath, $tplfile);
169
        if (is_array($params) && count($params) > 0) {
170
            $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
171
            $mm[] = array(
172
                $params['name'],
173
                $description,
174
                "$modulePath/{$params['filename']}",
175
                $params['properties'],
176
                $params['guid'],
177
                (int)$params['shareparams'],
178
                $params['modx_category'],
179
                array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false
180
            );
181
        }
182
        if ((int)$params['shareparams'] || !empty($params['dependencies'])) {
183
            $dependencies = explode(',', $params['dependencies']);
184
            foreach ($dependencies as $dependency) {
185
                $dependency = explode(':', $dependency);
186
                switch (trim($dependency[0])) {
187
                    case 'template':
188
                        $mdp[] = array(
189
                            'module' => $params['name'],
190
                            'table'  => 'templates',
191
                            'column' => 'templatename',
192
                            'type'   => 50,
193
                            'name'   => trim($dependency[1])
194
                        );
195
                        break;
196
                    case 'tv':
197
                    case 'tmplvar':
198
                        $mdp[] = array(
199
                            'module' => $params['name'],
200
                            'table'  => 'tmplvars',
201
                            'column' => 'name',
202
                            'type'   => 60,
203
                            'name'   => trim($dependency[1])
204
                        );
205
                        break;
206
                    case 'chunk':
207
                    case 'htmlsnippet':
208
                        $mdp[] = array(
209
                            'module' => $params['name'],
210
                            'table'  => 'htmlsnippets',
211
                            'column' => 'name',
212
                            'type'   => 10,
213
                            'name'   => trim($dependency[1])
214
                        );
215
                        break;
216
                    case 'snippet':
217
                        $mdp[] = array(
218
                            'module' => $params['name'],
219
                            'table'  => 'snippets',
220
                            'column' => 'name',
221
                            'type'   => 40,
222
                            'name'   => trim($dependency[1])
223
                        );
224
                        break;
225
                    case 'plugin':
226
                        $mdp[] = array(
227
                            'module' => $params['name'],
228
                            'table'  => 'plugins',
229
                            'column' => 'name',
230
                            'type'   => 30,
231
                            'name'   => trim($dependency[1])
232
                        );
233
                        break;
234
                    case 'resource':
235
                        $mdp[] = array(
236
                            'module' => $params['name'],
237
                            'table'  => 'content',
238
                            'column' => 'pagetitle',
239
                            'type'   => 20,
240
                            'name'   => trim($dependency[1])
241
                        );
242
                        break;
243
                }
244
            }
245
        }
246
    }
247
    $d->close();
248
}
249
250
// setup callback function
251
$callBackFnc = "clean_up";