Example #1
0
File: View.php Project: gueff/mymvc
 /**
  * instantiates smarty object and set major smarty configs
  * 
  * @access public
  * @return void
  */
 public function __construct()
 {
     parent::__construct();
     $this->sTemplateDir = \mvc\registry::get('MVC_MODULES') . '/' . \mvc\Request::getInstance()->getModule() . '/templates';
     $this->sTemplate = Registry::get('MVC_SMARTY_TEMPLATE_DEFAULT');
     $this->iSmartyVersion = (int) preg_replace('/[^0-9]+/', '', self::SMARTY_VERSION);
     $this->setAbsolutePathToTemplateDir();
     $this->setCompileDir(\MVC\Registry::get('MVC_SMARTY_TEMPLATE_CACHE_DIR'));
     $this->setCacheDir(\MVC\Registry::get('MVC_SMARTY_CACHE_DIR'));
     $this->caching = \MVC\Registry::get('MVC_SMARTY_CACHE_STATUS');
     $aPlugInDir = array(\MVC\Registry::get('MVC_APPLICATION_PATH') . '/vendor/smarty/smarty/libs/plugins/');
     \MVC\Registry::isRegistered('MVC_SMARTY_PLUGINS_DIR') ? $aPlugInDir = array_merge($aPlugInDir, \MVC\Registry::get('MVC_SMARTY_PLUGINS_DIR')) : false;
     $this->setPluginsDir($aPlugInDir);
     $this->checkDirs();
     \MVC\Event::BIND('mvc.view.echoOut.off', function () {
         MVC_View::$bEchoOut = false;
     });
     \MVC\Event::BIND('mvc.view.echoOut.on', function () {
         MVC_View::$bEchoOut = true;
     });
 }
Example #2
0
 public function __defaultController()
 {
     // Include only the Class needed
     $app = $this->app;
     $bind = $this->bind;
     $action = $this->action;
     $view_display = $this->view_display;
     $classFile = MVC_BASE_PATH . '/apps/greystone/models/' . $bind . '.php';
     $classView = MVC_BASE_PATH . '/apps/greystone/views/' . $view_display . '.php';
     $classAction = MVC_BASE_PATH . '/' . $bind . '.php?action=' . $action;
     // Load and verify Class
     require_once $classFile;
     if (class_exists($bind)) {
         try {
             $instance = new $bind();
             if (!MVC_App::isValid($instance)) {
                 die('Not the object I am looking for.');
             }
         } catch (Exeception $e) {
             echo 'Message: ' . $e->getMessage();
             die("The requested class does not exists!");
         }
     } else {
         echo 'Message: Danger, Danger, Will Robinson!';
         die("The requested class does not exists!");
     }
     $instance->appName = $app;
     $result = array();
     // Execute and verify Class Action
     try {
         $result = $instance->{$action}();
     } catch (Exeception $e) {
         echo 'Message: ' . $e->getMessage();
         die("No action found.");
     }
     //Send the model results to view
     $view = MVC_View::factory($instance->view, $instance);
     $view->app = $app;
     $view->bind = $bind;
     $view->action = $action;
     $view->view_display = $view_display;
     $view->display();
 }