$rootDir = ‘./lib/Controller/Topic‘; $dirScan = scandir($rootDir); $urls = array(); $c = ‘Topic_‘; foreach ($dirScan as $secDir) { if (in_array($secDir, array(‘.‘, ‘..‘, ‘.svn‘))) { continue; } $dir = $rootDir . ‘/‘ . $secDir; $fdir = opendir($dir); while ($path = readdir($fdir)) { if (in_array($path, array(‘.‘, ‘..‘, ‘.svn‘))) { continue; } $filename = $dir . ‘/‘ . $path; // if (is_dir($secdDir)) {exit(‘here‘); // $secfdir = opendir($secdDir); // while ($path2 = readdir($fdir)) { // if (in_array($path2, array(‘.‘, ‘..‘, ‘.svn‘))) { // continue; // } // if (is_dir($secdDir . ‘/‘ . $path2)) { // exit(‘dir‘); // } else { // $control = ‘Topic_‘ . $secDir . ‘_‘ . $path . ‘_‘ . substr($path2, 0, strpos($path2, ‘.‘)); // } // } // } else { $content = file_get_contents($filename); $isMatch = preg_match_all(‘#\$this->tpl = \‘(.*)\‘#‘, $content, $matches); if(!$isMatch) { echo $filename; echo PHP_EOL; continue; // exit(‘not match tempate‘); } $control = ‘Topic_‘ . $secDir . ‘_‘ . substr($path, 0, strpos($path, ‘.‘)); // echo $secdDir; // echo PHP_EOL; // } // echo ‘http://misc.kimiss.com/common/?c=‘ . $control; // echo PHP_EOL; $templates = $matches[1]; foreach($templates as $key => $value) { $templates[$key] = ‘/export/manager/misc-common/template_dir/‘ . $value . ‘.html‘; } $urls[] = array( ‘url‘ => ‘http://misc.kimiss.com/common/?c=‘ . $control, ‘file‘ => ‘/export/manager/misc-common/‘ . $filename, ‘templates‘ => $templates ); } closedir($fdir); // echo PHP_EOL; } var_export($urls);
时间: 2024-10-18 08:11:16