Code Duplication    Length = 87-87 lines in 2 locations

install/cli-install.php 1 location

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

install/src/processor/result.php 1 location

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