예제 #1
0
 public function draw()
 {
     $oldPath = CurrentPath::set(dirname(__FILE__));
     $template = new Template('view/view.xml');
     print $template->render(array('payment' => $this));
     CurrentPath::set($oldPath);
 }
예제 #2
0
 public static function resolve(Site $site, $url)
 {
     $matches = array();
     if ($url == 'test') {
         $cms = $site->modules->get('CMS');
         $oldPath = CurrentPath::set($cms->getDir());
         $prefix = $cms->getPrefix();
         try {
             $page = new HTMLPage($site, null, "{$prefix}/cmstest.html", array('cms' => $cms));
         } catch (Exception $e) {
             CurrentPath::set($oldPath);
             throw $e;
         }
         CurrentPath::set($oldPath);
         return $page;
     } elseif (!preg_match('~^(page|node)/(\\w+)(?:/(.+))?$~', $url, $matches)) {
         return null;
     }
     try {
         $what = $matches[1];
         $action = $matches[2];
         if (count($matches) > 3) {
             $extra = $matches[3];
         } else {
             $extra = null;
         }
         return new self($site, $what, $action, $extra);
     } catch (BadMethodCallException $e) {
         return null;
     }
 }
예제 #3
0
 /**
  * Restores the application path after template is rendered.
  */
 protected function renderCleanup()
 {
     parent::renderCleanup();
     if (isset($this->currentPath)) {
         CurrentPath::set($this->oldAppPath);
     }
 }
예제 #4
0
 /**
  * Implements the perform
  *
  * @param ActionDescription $action
  * @param int $stage
  * @return boolean, null on permission denied
  */
 public function perform(ActionDescription &$action, $stage)
 {
     $oldPath = CurrentPath::set($this->getPath());
     $handler = is_string($action->handler) ? array($this, $action->handler) : $action->handler;
     $returnValue = call_user_func($handler, $stage);
     CurrentPath::set($oldPath);
     return $returnValue;
 }
예제 #5
0
 /**
  * Handling process:
  *   dispatch: onParseUrl      }-> caught Exception
  *   dispatch: onAccessCheck     |-> dispatch: onException
  *   dispatch: onRequestStart    |
  *   dispatch: onSendResponse  }---> caught SiteRedirectException
  *   dispatch: onResponseSent    | |-> redirect
  *   cleanup <-------------------/-/
  *
  * At any point in the process, a thrown exception will cause 'onException'
  * to be dispatched, if that generates no output, then the exception is
  * simply printed in a minimal html document. After the onException, normal cleanup is done
  *
  * @return void
  * @see parseUrl
  */
 public final function handle()
 {
     $args = array_slice(func_get_args(), 1);
     try {
         ob_start();
         CurrentPath::set(Loader::$Base);
         $this->parseUrl(Params::server('REQUEST_URI'));
         $this->log->info(sprintf('==> Framework v%s: New Request from %s - %s <==', Loader::$FrameworkVersion, Params::server('REMOTE_ADDR'), $this->requestUrl));
         $this->dispatchCallback('onAccessCheck', $this);
         $this->dispatchCallback('onRequestStart', $this);
         $this->dispatchCallback('onSendResponse', $this);
         $this->dispatchCallback('onResponseSent', $this);
         ob_end_flush();
     } catch (SiteRedirectException $r) {
         ob_end_clean();
         header("Location: {$r->url}");
     }
     $this->cleanup();
 }
예제 #6
0
 /**
  * Constructor
  */
 public function __construct()
 {
     $oldPath = CurrentPath::set($this->getPath());
     $this->onInitialize();
     CurrentPath::set($oldPath);
 }