Example #1
0
 /**
  * Loads adapters into the current namespace allowing the processing part
  * to call these adapters.	 
  *
  * @param	string		The URL 
  * @return	boolean		True on success, false if no adapters found.
  */
 private function parse($originalUrl, $url)
 {
     // Load available hooks.
     $hooks = JFolder::files(__DIR__ . '/hooks');
     // Load up the html parser
     $parser = SocialSimpleHTML::str_get_html($this->contents);
     if (!$parser) {
         return false;
     }
     $info = parse_url($url);
     $uri = $info['scheme'] . '://' . $info['host'];
     $absoluteUrl = $url;
     foreach ($hooks as $hook) {
         $file = __DIR__ . '/hooks/' . $hook;
         require_once $file;
         $name = str_ireplace('.php', '', $hook);
         $class = 'EasyBlogCrawler' . ucfirst($name);
         // When item doesn't exist set it to false.
         if (!class_exists($class)) {
             continue;
         }
         $obj = new $class();
         $this->hooks[$name] = $obj->process($parser, $this->contents, $uri, $absoluteUrl, $originalUrl, $this->hooks);
     }
     return true;
 }
Example #2
0
 /**
  * Loads adapters into the current namespace allowing the processing part
  * to call these adapters.
  *
  * @param	string		The URL
  * @return	boolean		True on success, false if no adapters found.
  */
 private function parse($originalUrl, $url)
 {
     // Load available hooks.
     // @TODO: Allow 3rd party to add their own custom rules in the future.
     $hooks = JFolder::files(dirname(__FILE__) . '/hooks');
     $parser = SocialSimpleHTML::str_get_html($this->contents);
     if (!$parser) {
         return false;
     }
     $info = parse_url($url);
     $uri = $info['scheme'] . '://' . $info['host'];
     $absoluteUrl = $url;
     foreach ($hooks as $hook) {
         $file = SOCIAL_LIB . '/crawler/hooks/' . $hook;
         require_once $file;
         $name = str_ireplace('.php', '', $hook);
         $class = 'SocialCrawler' . ucfirst($name);
         // When item doesn't exist set it to false.
         if (!class_exists($class)) {
             continue;
         }
         $obj = new $class();
         $result = $obj->process($parser, $this->contents, $uri, $absoluteUrl, $originalUrl, $this->hooks);
         $this->hooks[$name] = $result;
     }
     return true;
 }