Ejemplo n.º 1
0
 /**
  * Discover internal links
  * 
  */
 public function _discoverInteralLinks()
 {
     $tmpLinks = array('print' => array(), 'pages' => array());
     foreach ($this->_links['menu'] as $link) {
         $dom = new DomDocument();
         $dom->loadHTML($link->content);
         $aElements = $dom->getElementsByTagName('a');
         foreach ($aElements as $aElement) {
             $href = $aElement->getAttribute('href');
             $full_link = StaticContentHelperUrl::getFullLink($href);
             if (!StaticContentHelperMenu::isSatisfatoryLink($full_link)) {
                 continue;
             }
             $pageName = StaticContentHelperUrl::createPageName($full_link);
             if (StaticContentHelperUrl::isPrintLink($full_link)) {
                 $tmpLinks['print'][$href] = $pageName;
             }
             if (StaticContentHelperUrl::isFeedLink($full_link)) {
                 $relative_link = $pageName;
             } else {
                 $relative_link = StaticContentHelperUrl::getRelativeLink($href);
             }
             if (!$this->existsLink($full_link)) {
                 $cache_id = md5($full_link);
                 $content = $this->_cachePage->get($cache_id);
                 if (empty($content)) {
                     $content = file_get_contents($full_link);
                     $this->_cachePage->store($content, $cache_id);
                 }
                 $link = new stdClass();
                 $link->file = $pageName;
                 $link->full = $full_link;
                 $link->relative = ltrim($relative_link, '/');
                 $link->content = $content;
                 array_push($tmpLinks['pages'], $link);
             }
         }
         unset($dom);
     }
     return $tmpLinks;
 }
Ejemplo n.º 2
0
 /**
  * Register menu links links
  * 
  * @param array $links
  */
 public static function setLinks($links)
 {
     self::$links = $links;
 }