Example #1
0
 public function getFullUrl($params)
 {
     return Application::getBaseUrl() . '/' . Application::getRouter()->getUrl($params);
 }
Example #2
0
 /**
  *
  */
 protected function rendarParamSet()
 {
     // set template
     $this->template->assign_vars(array("PATH" => Application::getBaseUrl(), "PPATH" => Application::getBaseUrl("/" . $this->project), "ROOT" => Application::getWebUrl(), "PROOT" => Application::getWebUrl("/" . $this->project), "HOST" => Application::getHostname(), "URL" => Application::getHostUrl(), "PROJECT_NAME" => $this->project, "CLASS_NAME" => get_class($this), "SELF" => Application::getBaseUrl() . Request::getUri(), "SERVER" => Request::getServer()->getVars(), "REQUEST" => Request::getRequest()->getVars(), "POST" => Request::post()->getVars(), "GET" => Request::getQuery()->getVars(), "FLASH" => Session::getFlashData()));
     Session::clearFlash();
 }
Example #3
0
 /**
  * request to load controller
  */
 static function action()
 {
     // benchmark
     $benchmark = new Benchmark();
     $benchmark->start();
     $request = new Request();
     $request->setBaseUri(Application::getBaseUrl());
     // auth checkc
     if (self::$auth) {
         foreach (self::$auth as $auth) {
             $auth->check($request->getUri());
         }
     }
     $routing = new Routing();
     if (!($data = $routing::getRouleClass($request->getUri()))) {
         if ($data = $routing::getRouleClass($request->getUri() . '/')) {
             Server::redirect(Application::getBaseUrl() . $request->getUri() . '/');
         }
     }
     if (empty($data)) {
         $data = array('class' => 'core:default:error_404');
     } else {
         if ($data['class'] == '') {
             $data = array('class' => 'core:default:index');
         }
     }
     // pearse class method
     if (preg_match("/^([0-9a-zA-Z\\-_]+):([0-9a-zA-Z\\-_]+):?([0-9a-zA-Z\\-_]*)\$/", $data['class'], $matchs)) {
         $project = $matchs[1];
         $class = $matchs[2];
         $method = $matchs[3];
         $method = !empty($method) ? $method : "index";
     } else {
         throw new PMPException('Error Class Method or Class Name(`' . $data['class'] . '` is not routing find).');
     }
     $benchmark->setMark("routing");
     try {
         $path = self::$source_dir . '/' . $project;
         $filename = $path . '/conf';
         dir_include_all($filename);
         $filename = $path . '/class';
         dir_include_all($filename);
         $filename = $path . '/controller/' . $class . '.php';
         if (file_exists($filename)) {
             include_once $filename;
         } else {
             $path = dirname(__FILE__) . '/../../component';
             $filename = $path . '/controller/' . $class . '.php';
             if (file_exists($filename)) {
                 include_once $filename;
             }
         }
         $classname = $class . 'Controller';
         $controller = new $classname($path, $class, $method, $project);
         $controller->addDefaultTemplatefiles(dirname(__FILE__) . '/../../component/view/form.tpl');
         $benchmark->setMark('included');
         if (isset($data['param'])) {
             $reflection = new \ReflectionClass($controller);
             $reflection_method = $reflection->getMethod($method);
             $params = array();
             foreach ($reflection_method->getParameters() as $key => $p) {
                 if (array_key_exists($p->getName(), $data['param'])) {
                     $params[$key] = $data['param'][$p->getName()];
                 } else {
                     if ($p->isDefaultValueAvailable()) {
                         $params[$key] = $p->getDefaultValue();
                     } else {
                         throw new PMPException(sprintf('Not Found Controller Paramater %s In %s', get_class($controller) . ':' . $method, $p->getName()));
                     }
                 }
             }
             call_user_func_array(array($controller, $method), $params);
         } else {
             $controller->{$method}();
         }
         $benchmark->setMark("action");
         $benchmark->stop();
         //$benchmark->display(false);
     } catch (\Exception $e) {
         throw new PMPException($e);
     }
 }
Example #4
0
 /**
  * @return mixed
  */
 public function getUrl()
 {
     $url = call_user_func_array(array(__CLASS__, 'generateUrl'), func_get_args());
     return Application::getBaseUrl($url);
 }