Карта сайта
Страница 7 из 13
- return $t;
- /* 统计引用关系,返回候选布局列表(含 body 优先)与选定布局 */
- function zjm_layout($pages, $ptxt, $rootDir)
- $refc = array();
- foreach ($pages as $p) {
- if (!isset($ptxt[$p])) continue;
- foreach (zjm_refs($ptxt[$p], $p, $rootDir) as $r) {
- if (!isset($refc[$r])) $refc[$r] = 0;
- $refc[$r]++;
- $cand = array();
- $okExt = array('php','php3','php5','phtml','asp','aspx','asa','inc','fix','html','htm','shtml','shtm','xhtml','tpl','master','ascx');
- foreach ($refc as $r => $n) {
- if (!in_array(zjm_ext($r), $okExt, true)) continue;
- $e = ''; $b = '';
- $t = zjm_read($r, $e, $b);
- if ($t === null) continue;
- $L = zjm_lit($t);
- $hasBody = (bool)preg_match('/<\/body\s*>/i', $L);
- $hasHtml = (bool)preg_match('/]/i', $L);
- $hasHead = $hasHtml || (bool)preg_match('/].*<\/head\s*>/is', $t);
- if (!$hasBody && !$hasHtml) continue;
- $cand[] = array('p' => $r, 'n' => $n, 'body' => $hasBody, 'head' => $hasHead);
- $pick = '';
- $best = -1;
- foreach ($cand as $c) { if ($c['body'] && $c['n'] > $best) { $best = $c['n']; $pick = $c['p']; } }
- if ($pick === '') { $best = -1; foreach ($cand as $c) { if ($c['n'] > $best) { $best = $c['n']; $pick = $c['p']; } } }
- return array('refc' => $refc, 'cand' => $cand, 'pick' => $pick);
- /* 按文件角色分类:返回 布局 / 静态页 / 入口页 / 跳过数 */
- function zjm_plan($pages, $ptxt, $refc, $pick)
- $statics = array(); $entries = array(); $skip = 0;
- $staticExt = array('html','htm','shtml','shtm','xhtml','stm');
- if (!isset($ptxt[$p])) { $skip++; continue; }
- $t = $ptxt[$p];
- $e = zjm_ext($p);
- if (in_array($e, $staticExt, true) && stripos($t, '
- && stripos($t, '<%') === false && stripos($t, '') === false) {
- $statics[] = $p;
- continue;
- if ($rp !== false && isset($refc[$rp])) { $skip++; continue; } /* 被 include 的片段 */
- if (stripos($t, '
- $entries[] = $p;
- return array('statics' => $statics, 'entries' => $entries, 'skip' => $skip, 'pick' => $pick);
- function zjm_hasjs($txt)
- if (!preg_match_all('/