示例#1
0
文件: Php.php 项目: ekowabaka/ntentan
 public function generate($templateData, $view)
 {
     if (file_exists($this->template)) {
         foreach ($templateData as $key => $value) {
             ${$key} = Variable::initialize($value);
         }
         $helpers = $this->helpers;
         $widgets = $this->widgets;
         ob_start();
         include $this->template;
         return ob_get_clean();
     } else {
         echo Ntentan::message("Template file *{$this->template}* not found");
     }
 }
示例#2
0
 public static function error($message, $subTitle = null, $type = null, $showTrace = true, $trace = false)
 {
     Ntentan::$errorDepth++;
     if (isset(Ntentan::$config[Ntentan::$context]['error_handler']) && Ntentan::$debug === false && Ntentan::$errorDepth < Ntentan::MAX_ERROR_DEPTH) {
         controllers\Controller::load(Ntentan::$config[Ntentan::$context]['error_handler']);
     } else {
         ob_clean();
         echo Ntentan::message($message, $subTitle, $type, $showTrace, $trace);
     }
 }
示例#3
0
 public function login()
 {
     Ntentan::addIncludePath(Ntentan::getFilePath('lib/controllers/components/auth/methods'));
     $authenticatorClass = __NAMESPACE__ . '\\methods\\' . Ntentan::camelize($this->authMethod);
     if (class_exists($authenticatorClass)) {
         $this->authMethodInstance = new $authenticatorClass();
         $this->authMethodInstance->usersModel = $this->_usersModel;
     } else {
         print Ntentan::message("Authenticator class *{$authenticatorClass}* not found.");
     }
     if ($this->loggedIn()) {
         $this->performSuccessOperation();
     } else {
         if ($this->authMethodInstance->login()) {
             $this->performSuccessOperation();
         } else {
             switch ($this->onFailure) {
                 case AuthComponent::CALL_FUNCTION:
                     $decomposed = explode("::", $this->failureFunction);
                     $className = $decomposed[0];
                     $methodName = $decomposed[1];
                     $method = new \ReflectionMethod($className, $methodName);
                     $method->invoke(null, $this->controller);
                     break;
                 case AuthComponent::REDIRECT:
                     $this->loginRoute = $this->loginRoute == null ? $this->controller->route . "/login" : $this->loginRoute;
                     $this->logoutRoute = $this->logoutRoute == null ? $this->controller->route . "/logout" : $this->logoutRoute;
                     $this->redirectToLogin();
                     break;
                 default:
                     $this->set('login_status', false);
                     break;
             }
         }
     }
 }