Code Duplication    Length = 87-87 lines in 2 locations

install/cli-install.php 1 location

@@ 690-776 (lines=87) @@
687
// setup modules - array : name, description, type - 0:file or 1:content, file or content,properties, guid,enable_sharedparams
688
$mm = &$moduleModules;
689
$mdp = &$moduleDependencies;
690
if(is_dir($modulePath) && is_readable($modulePath)) {
691
    $d = dir($modulePath);
692
    while (false !== ($tplfile = $d->read())) {
693
        if(substr($tplfile, -4) != '.tpl') {
694
            continue;
695
        }
696
        $params = parse_docblock($modulePath, $tplfile);
697
        if(is_array($params) && count($params) > 0) {
698
            $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
699
            $mm[] = array(
700
                $params['name'],
701
                $description,
702
                "$modulePath/{$params['filename']}",
703
                $params['properties'],
704
                $params['guid'],
705
                (int)$params['shareparams'],
706
                $params['modx_category'],
707
                array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false
708
            );
709
        }
710
        if ((int)$params['shareparams'] || !empty($params['dependencies'])) {
711
            $dependencies = explode(',', $params['dependencies']);
712
            foreach ($dependencies as $dependency) {
713
                $dependency = explode(':', $dependency);
714
                switch (trim($dependency[0])) {
715
                    case 'template':
716
                        $mdp[] = array(
717
                            'module' => $params['name'],
718
                            'table' => 'templates',
719
                            'column' => 'templatename',
720
                            'type' => 50,
721
                            'name' => trim($dependency[1])
722
                        );
723
                        break;
724
                    case 'tv':
725
                    case 'tmplvar':
726
                        $mdp[] = array(
727
                            'module' => $params['name'],
728
                            'table' => 'tmplvars',
729
                            'column' => 'name',
730
                            'type' => 60,
731
                            'name' => trim($dependency[1])
732
                        );
733
                        break;
734
                    case 'chunk':
735
                    case 'htmlsnippet':
736
                        $mdp[] = array(
737
                            'module' => $params['name'],
738
                            'table' => 'htmlsnippets',
739
                            'column' => 'name',
740
                            'type' => 10,
741
                            'name' => trim($dependency[1])
742
                        );
743
                        break;
744
                    case 'snippet':
745
                        $mdp[] = array(
746
                            'module' => $params['name'],
747
                            'table' => 'snippets',
748
                            'column' => 'name',
749
                            'type' => 40,
750
                            'name' => trim($dependency[1])
751
                        );
752
                        break;
753
                    case 'plugin':
754
                        $mdp[] = array(
755
                            'module' => $params['name'],
756
                            'table' => 'plugins',
757
                            'column' => 'name',
758
                            'type' => 30,
759
                            'name' => trim($dependency[1])
760
                        );
761
                        break;
762
                    case 'resource':
763
                        $mdp[] = array(
764
                            'module' => $params['name'],
765
                            'table' => 'content',
766
                            'column' => 'pagetitle',
767
                            'type' => 20,
768
                            'name' => trim($dependency[1])
769
                        );
770
                        break;
771
                }
772
            }
773
        }
774
    }
775
    $d->close();
776
}
777
778
// setup callback function
779
$callBackFnc = "clean_up";

install/setup.info.php 1 location

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