コード例 #1
0
ファイル: Pages.php プロジェクト: anpone/sitecake
 static function get($full = false)
 {
     $pages = array();
     $pageFiles = pages::page_files();
     $homeHtml = io::file_get_contents($pageFiles['index.html']);
     $homeDoc = phpQuery::newDocument($homeHtml);
     $nav = pages::nav_urls($homeDoc);
     $nav_urls = array_keys($nav);
     foreach ($pageFiles as $rpath => $path) {
         $url = pages::rpath2url($rpath);
         $home = $url == 'index.html';
         $html = $home ? $homeHtml : io::file_get_contents($path);
         $doc = $home ? $homeDoc : phpQuery::newDocument($html);
         $idx = array_search($url, $nav_urls);
         $navtitle = $idx === FALSE ? phpQuery::pq('meta[name="navtitle"]', $doc)->attr('content') : $nav[$url];
         $navtitle = empty($navtitle) ? pages::url2navtitle($url) : $navtitle;
         $page = array('id' => pages::page_id($html), 'idx' => $idx === FALSE ? -1 : $idx, 'title' => phpQuery::pq('title', $doc)->text(), 'navtitle' => $navtitle, 'desc' => phpQuery::pq('meta[name="description"]', $doc)->attr('content'), 'keywords' => phpQuery::pq('meta[name="keywords"]', $doc)->attr('content'), 'home' => $home, 'url' => $url);
         if ($full) {
             $page['path'] = pages::rpath2path($rpath);
             $page['html'] = $html;
             $page['doc'] = $doc;
         }
         array_push($pages, $page);
     }
     return array('status' => 0, 'pages' => $pages);
 }