示例#1
0
 /**
  * Constructor initializes the controller.  This method cannot be overriden.  If you need
  * to do something during construction, add it to Init
  *
  * @param Phreezer $phreezer Object persistance engine
  * @param IRenderEngine $renderEngine rendering engine
  * @param Context (optional) a context object for persisting the state of the current page
  * @param Router (optional) a custom writer for URL formatting
  */
 final function __construct(Phreezer $phreezer, $renderEngine, $context = null, IRouter $router = null)
 {
     $this->Phreezer =& $phreezer;
     $this->RenderEngine =& $renderEngine;
     // for backwards compatibility
     $this->Smarty =& $renderEngine;
     $ra = RequestUtil::GetRemoteHost();
     $this->GUID = $this->Phreezer->DataAdapter->GetDBName() . "_" . str_replace(".", "_", $ra);
     $this->_router = $router ? $router : new GenericRouter();
     if ($context) {
         $this->Context =& $context;
     } else {
         $this->Context = new Context();
         $this->Context->GUID = "CTX_" . $this->GUID;
     }
     if ($this->RenderEngine) {
         // assign some variables globally for the views
         $this->Assign("CURRENT_USER", $this->GetCurrentUser());
         $this->Assign("URL", $this->GetRouter());
         $this->Assign("BROWSER_DEVICE", $this->GetDevice());
         // if feedback was persisted, set it
         $feedback = $this->Context->Get("feedback");
         // print_r($feedback); die('feedback');
         if (is_array($feedback)) {
             foreach ($feedback as $key => $val) {
                 $this->Assign($key, $val);
             }
         } else {
             $this->Assign("feedback", $feedback);
         }
         $this->Context->Set("feedback", null);
     }
     $this->Init();
 }