コード例 #1
0
ファイル: crawler.php プロジェクト: alex311982/crawler
 /**
  * Run script
  *
  */
 public function run()
 {
     try {
         $content = $this->_factory->getModel('crawlerModel')->crawl($this->_args);
         //array of data to render
         $result = array();
         $sortArr = array();
         foreach ($content as $key => $data) {
             $time = $data['time'];
             Profiler::start($key);
             $renderData = TagCounterHelper::count($data['content'], 'img');
             Profiler::stop($key);
             $time += Profiler::fetch($key);
             array_push($result, array($key, (int) $renderData['img'], $time));
             array_push($sortArr, $renderData['img']);
         }
         array_multisort($sortArr, SORT_DESC, $result);
         if (!empty($result)) {
             array_unshift($result, $this->_tableHeaders);
         }
         ViewHelper::getRenderer()->process(array('grid' => $result));
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
コード例 #2
0
ファイル: Dispatcher.php プロジェクト: rashijani/dragonphp
 private function _executeValidator($module, $controller)
 {
     try {
         if ($module && $controller) {
             // check if the validator class exists for this controller
             $validatorFile = APPLICATION_MODULE_DIR . $module . '/controllers/' . $controller . VALIDATOR_SUFFIX . '.php';
             self::$_logger->debug($validatorFile);
             if (is_file($validatorFile)) {
                 require_once $validatorFile;
                 $validatorClass = $controller . VALIDATOR_SUFFIX;
                 $validator = new $validatorClass();
                 // inject renderer
                 $validator->setRenderer($this->_currentRenderer);
                 if (method_exists($validator, VALIDATE_COMMAND)) {
                     $validator->setRequest(self::$_request);
                     $validator->setModule($module);
                     $validator->setController($controller);
                     $args = array(self::$_request, Session::getInstance());
                     call_user_func_array(array($validator, VALIDATE_COMMAND), $args);
                     $errors = call_user_func_array(array($validator, GET_ERRORS_COMMAND), null);
                     if ($errors && sizeof($errors) > 0) {
                         self::$_logger->info('Validator found errors');
                         self::$_errors = $errors;
                         $model->errors = self::$_errors;
                         $viewClassName = $controller . VIEW_SUFFIX;
                         $viewClassFileName = APPLICATION_MODULE_DIR . $module . '/views/' . $viewClassName . '.php';
                         // get default view renderer
                         $renderer = $this->_currentRenderer;
                         if (!isset($renderer)) {
                             $renderer = ViewHelper::getRenderer($module, DEFAULT_RENDERER);
                         }
                         if (is_file($viewClassFileName)) {
                             require_once $viewClassFileName;
                             $view = new $viewClassName($renderer, $module);
                         } else {
                             require_once FRAMEWORK_VIEW_DIR . 'WebView.php';
                             $errorTemplateSetId = $validator->getErrorTemplateSetId();
                             if (empty($errorTemplateSetId)) {
                                 throw new Exception('Error: you need to set $_errorTemplateSetId in your ' . $controller . 'Validator class!');
                             }
                             $renderer->setAttribute(TEMPLATE_SET_ID, $errorTemplateSetId);
                             $view = new WebView($renderer, $module, $controllerName);
                         }
                         // execute on error method in view
                         $this->_executeOnErrorView($renderer, $view, $controller, $module, $model);
                         exit;
                     }
                 }
             }
         }
     } catch (Exception $ex) {
         throw new Exception($ex->getMessage());
     }
 }