コード例 #1
0
ファイル: view.php プロジェクト: rcrowe/fuel-pjax
 public function set_filename($file)
 {
     // set find_file's one-time-only search paths
     \Finder::instance()->flash($this->request_paths);
     $is_pjax = Input::server('HTTP_X_PJAX') or Input::get('_pjax');
     // Check if this request is being made by PJAX
     if ($is_pjax) {
         $pjax_file = explode('.', $file);
         $pjax_file = $pjax_file[0] . Config::get('pjax.file', '-pjax');
         // locate the pjax view file
         if (($path = \Finder::search('views', $pjax_file, '.' . $this->extension, false, false)) !== false) {
             $this->pjax_file_loaded = true;
         } else {
             // PJAX file not found, carry on looking for normal view file
             if (($path = \Finder::search('views', $file, '.' . $this->extension, false, false)) === false) {
                 throw new \FuelException('The requested view could not be found: ' . \Fuel::clean_path($file));
             }
         }
         Log::info('Pjax\\View::forge - loaded WITH PJAX: ' . $path);
     } else {
         // locate the view file
         if (($path = \Finder::search('views', $file, '.' . $this->extension, false, false)) === false) {
             throw new \FuelException('The requested view could not be found: ' . \Fuel::clean_path($file));
         }
         Log::info('Pjax\\View::forge - loaded WITHOUT PJAX: ' . $path);
     }
     // Store the file path locally
     $this->file_name = $path;
     return $this;
 }
コード例 #2
0
 private function process_form()
 {
     $domain = Request::getPost('domain');
     if (strlen($domain) < 1) {
         return;
     }
     $this->set_body('form_success', true);
     $url = CrawlerURL::instance($domain);
     $domain = $url->getDomain();
     $link = "{$domain}/";
     $domainObject = Finder::instance('Domain')->setNameFilter($domain)->getDomain();
     if (!$domainObject) {
         $domainObject = Mutator::instance('Domain', 'Create')->setData($domain)->execute();
     }
     $linkObject = Finder::instance('Link')->setNameFilter($link)->getLink();
     if (!$linkObject) {
         $linkObject = Mutator::instance('Link', 'Create')->setData($link)->execute();
     }
     $crawlSiteQueueObject = Finder::instance('CrawlSiteQueue')->setDomainFilter($domainObject->getID())->setStatusFilter(CrawlSiteQueue::$IS_UNCRAWLED)->getCrawlSiteQueue();
     if (!$crawlSiteQueueObject) {
         Mutator::instance('CrawlSiteQueue', 'Create')->setData($domainObject, CrawlSiteQueue::$IS_UNCRAWLED)->execute();
     }
     $crawlPageQueueObject = Finder::instance('CrawlPageQueue')->setDomainFilter($domainObject->getID())->setLinkFilter($linkObject->getID())->setStatusFilter(CrawlPageQueue::$IS_UNCRAWLED)->getCrawlPageQueue();
     if (!$crawlPageQueueObject) {
         Mutator::instance('CrawlPageQueue', 'Create')->setData($domainObject, $linkObject, CrawlPageQueue::$IS_UNCRAWLED)->execute();
     }
 }
コード例 #3
0
 public function getDomain()
 {
     if (!isset($this->domain)) {
         $domain = Finder::instance('Domain')->setNameFilter($this->site)->getDomain();
         if (!$domain) {
             trigger_error("CrawlerSite tried to pull an invalid domain {$this->site}!");
         }
         $this->domain = $domain;
     }
     return $this->domain;
 }
コード例 #4
0
ファイル: view.php プロジェクト: quickpacket/noclayer
 /**
  * Sets the view filename.
  *
  *     $view->set_filename($file);
  *
  * @param   string  view filename
  * @return  View
  * @throws  FuelException
  */
 public function set_filename($file)
 {
     // set find_file's one-time-only search paths
     \Finder::instance()->flash($this->request_paths);
     // locate the view file
     if (($path = \Finder::search('views', $file, '.' . $this->extension, false, false)) === false) {
         throw new \FuelException('The requested view could not be found: ' . \Fuel::clean_path($file));
     }
     // Store the file path locally
     $this->file_name = $path;
     return $this;
 }
コード例 #5
0
ファイル: package.php プロジェクト: vienbk91/fuelphp17
 /**
  * Unloads a package from the stack.
  *
  * @param string $pacakge
  *        	The package name
  * @return void
  */
 public static function unload($package)
 {
     \Finder::instance()->remove_path(static::$packages[$package]);
     unset(static::$packages[$package]);
 }
コード例 #6
0
ファイル: fuel.php プロジェクト: vienbk91/fuelphp17
 /**
  * Cleans up Fuel execution, ends the output buffering, and outputs the
  * buffer contents.
  *
  * @access public
  * @return void
  */
 public static function finish()
 {
     if (\Config::get('caching', false)) {
         \Finder::instance()->write_cache('FuelFileFinder');
     }
     if (static::$profiling and !static::$is_cli and !\Input::is_ajax()) {
         // Grab the output buffer and flush it, we will rebuffer later
         $output = ob_get_clean();
         $headers = headers_list();
         $show = true;
         foreach ($headers as $header) {
             if (stripos($header, 'content-type') === 0 and stripos($header, 'text/html') === false) {
                 $show = false;
             }
         }
         if ($show) {
             \Profiler::mark('End of Fuel Execution');
             if (preg_match("|</body>.*?</html>|is", $output)) {
                 $output = preg_replace("|</body>.*?</html>|is", '', $output);
                 $output .= \Profiler::output();
                 $output .= '</body></html>';
             } else {
                 $output .= \Profiler::output();
             }
         }
         // Restart the output buffer and send the new output
         ob_start();
         echo $output;
     }
 }
コード例 #7
0
 public function gatherPathData()
 {
     $this->output['paths'] = \Finder::instance()->paths();
     $this->output['pathTotals'] = array('count' => count($this->output['paths']));
 }
コード例 #8
0
ファイル: refine.php プロジェクト: ClixLtd/pccupload
 /**
  * Find all of the task classes in the system and use reflection to discover the
  * commands we can call.
  *
  * @return array $taskname => array($taskmethods)
  **/
 protected static function _discover_tasks()
 {
     $result = array();
     $files = \Finder::instance()->list_files('tasks');
     if (count($files) > 0) {
         foreach ($files as $file) {
             $task_name = str_replace('.php', '', basename($file));
             $class_name = '\\Fuel\\Tasks\\' . $task_name;
             require $file;
             $reflect = new \ReflectionClass($class_name);
             // Ensure we only pull out the public methods
             $methods = $reflect->getMethods(\ReflectionMethod::IS_PUBLIC);
             $result[$task_name] = array();
             if (count($methods) > 0) {
                 foreach ($methods as $method) {
                     strpos($method->name, '_') !== 0 and $result[$task_name][] = $method->name;
                 }
             }
         }
     }
     return $result;
 }
コード例 #9
0
 public function save()
 {
     $domain = Finder::instance('Domain')->setNameFilter($this->crawlerURL->getDomain())->getDomain();
     if (!isset($domain)) {
         $domain = Mutator::instance('Domain', 'Create')->setData($this->crawlerURL->getDomain())->execute();
     }
     $link = Finder::instance('Link')->setNameFilter($this->crawlerURL->getAbsoluteURL())->getLink();
     if (!isset($link)) {
         $link = Mutator::instance('Link', 'Create')->setData($this->crawlerURL->getAbsoluteURL())->execute();
     }
     $metaTitle = Finder::instance('MetaTitle')->setNameFilter($this->getMetaTitle())->getMetaTitle();
     if (!isset($metaTitle)) {
         $metaTitle = Mutator::instance('MetaTitle', 'Create')->setData($this->getMetaTitle())->execute();
     }
     $metaDescription = Finder::instance('MetaDescription')->setNameFilter($this->getMetaDescription())->getMetaDescription();
     if (!isset($metaDescription)) {
         $metaDescription = Mutator::instance('MetaDescription', 'Create')->setData($this->getMetaDescription())->execute();
     }
     $contentPage = Finder::instance('ContentPage')->setNameFilter($this->getContentPage())->getContentPage();
     if (!isset($contentPage)) {
         $contentPage = Mutator::instance('ContentPage', 'Create')->setData($this->getContentPage())->execute();
     }
     $page = Finder::instance('Page')->setDomainFilter($domain->getID())->setLinkFilter($link->getID())->setMetaTitleFilter($metaTitle->getID())->setMetaDescriptionFilter($metaDescription->getID())->setMetaRedirectFilter($this->hasMetaRedirect())->setContentPageFilter($contentPage->getID())->setHTTPCodeFilter($this->getHTTPCode())->getPage();
     if (!isset($page)) {
         $page = Mutator::instance('Page', 'Create')->setData($domain, $link, $metaTitle, $metaDescription, $this->hasMetaRedirect(), $contentPage, $this->getHTTPCode(), $this->getDateAccessed())->execute();
     }
     $this->page = $page;
     foreach ($this->getContentH1s() as $contentH1) {
         $contentH1Object = Finder::instance('ContentH1')->setNameFilter($contentH1)->getContentH1();
         if (!isset($contentH1Object)) {
             $contentH1Object = Mutator::instance('ContentH1', 'Create')->setData($contentH1)->execute();
         }
         $pageContentH1Map = Mutator::instance('PageContentH1Map', 'Create')->setData($page, $contentH1Object)->execute();
     }
     foreach ($this->getContentImages() as $image) {
         $contentImageSource = Finder::instance('ContentImageSource')->setNameFilter($image->source)->getContentImageSource();
         if (!isset($contentImageSource)) {
             $contentImageSource = Mutator::instance('ContentImageSource', 'Create')->setData($image->source)->execute();
         }
         $pageContentImageSourceMap = Finder::instance('PageContentImageSourceMap')->setPageFilter($page->getID())->setContentImageSourceFilter($contentImageSource->getID())->getPageContentImageSourceMap();
         if (!$pageContentImageSourceMap) {
             $pageContentImageSourceMap = Mutator::instance('PageContentImageSourceMap', 'Create')->setData($page, $contentImageSource)->execute();
         }
         if (strlen($image->alternate_text) > 0) {
             $contentImageAlternateText = Finder::instance('ContentImageAlternateText')->setNameFilter($image->alternate_text)->getContentImageAlternateText();
             if (!isset($contentImageAlternateText)) {
                 $contentImageAlternateText = Mutator::instance('ContentImageAlternateText', 'Create')->setData($image->alternate_text)->execute();
             }
             $contentImageSourceContentImageAlternateTextMap = Finder::instance('ContentImageSourceContentImageAlternateTextMap')->setContentImageSourceFilter($contentImageSource->getID())->setContentImageAlternateTextFilter($contentImageAlternateText->getID())->getContentImageSourceContentImageAlternateTextMap();
             if (!isset($contentImageSourceContentImageAlternateTextMap)) {
                 $contentImageSourceContentImageAlternateTextMap = Mutator::instance('ContentImageSourceContentImageAlternateTextMap', 'Create')->setData($contentImageSource, $contentImageAlternateText)->execute();
             }
         }
     }
     foreach ($this->get_links() as $crawlerLink) {
         if (!$crawlerLink->isContentLink()) {
             continue;
         }
         $link = Finder::instance('Link')->setNameFilter($crawlerLink->getAbsoluteURL())->getLink();
         if (!isset($link)) {
             $link = Mutator::instance('Link', 'Create')->setData($crawlerLink->getAbsoluteURL())->execute();
         }
         $host = $domain->getName();
         $host = str_replace('http://', '', $host);
         $pageLinkMap = Finder::instance('PageLinkMap')->setPageFilter($page->getID())->setLinkFilter($link->getID())->setInternalLinkFilter($crawlerLink->isInternalLink($host))->getPageLinkMap();
         if (!$pageLinkMap) {
             $pageLinkMap = Mutator::instance('PageLinkMap', 'Create')->setData($page, $link, $crawlerLink->isInternalLink($host))->execute();
         }
     }
     foreach ($this->getMetaKeywords() as $metaKeyword) {
         $keyword = Finder::instance('MetaKeyword')->setNameFilter($metaKeyword)->getMetaKeyword();
         if (!isset($keyword)) {
             $keyword = Mutator::instance('MetaKeyword', 'Create')->setData($metaKeyword)->execute();
         }
         $pageKeywordMap = Finder::instance('PageMetaKeywordMap')->setPageFilter($page->getID())->setMetaKeywordFilter($keyword->getID())->getPageMetaKeywordMap();
         if (!$pageKeywordMap) {
             $pageKeywordMap = Mutator::instance('PageMetaKeywordMap', 'Create')->setData($page, $keyword)->execute();
         }
     }
 }
コード例 #10
0
ファイル: view.php プロジェクト: socialskeptic/sainsburys
 /**
  * Sets the view filename.
  *
  *     $view->set_filename($file);
  *
  * @param   string  view filename
  * @return  View
  * @throws  FuelException
  */
 public function set_filename($file)
 {
     // strip the extension from it
     $pathinfo = pathinfo($file);
     if (!empty($pathinfo['extension'])) {
         $this->extension = $pathinfo['extension'];
         $file = substr($file, 0, strlen($this->extension) * -1 - 1);
     }
     // set find_file's one-time-only search paths
     \Finder::instance()->flash($this->request_paths);
     // locate the view file
     if (($path = \Finder::search('views', $file, '.' . $this->extension, false, false)) === false) {
         throw new \FuelException('The requested view could not be found: ' . \Fuel::clean_path($file) . '.' . $this->extension);
     }
     // Store the file path locally
     $this->file_name = $path;
     return $this;
 }
コード例 #11
0
ファイル: fuel.php プロジェクト: phabos/fuel-core
 /**
  * Returns the array of currently loaded search paths.
  *
  * @return  array  the array of paths
  */
 public static function get_paths()
 {
     logger(\Fuel::L_WARNING, 'This method is deprecated.  Please use a Finder::instance()->paths() instead.', __METHOD__);
     return \Finder::instance()->paths();
 }