Code Duplication    Length = 87-87 lines in 2 locations

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";

install/cli-install.php 1 location

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