public static function baseHref() { $baseHref = ''; $app =& SA_Registry::get('__SA_APPLICATION__'); $baseHref .= $app->getServerSecure() ? 'https' : 'http'; $baseHref .= '://'; $baseHref .= $app->getServerName(); $baseHref .= $app->getServerPort() == 80 ? '' : ":{$port}"; $baseHref .= $app->getScriptPath(); return $baseHref; }
public function __construct($name) { parent::Smarty(); $this->app =& SA_Registry::get('__SA_APPLICATION__'); $this->assign_by_ref('app', $this->app); $this->setName($name); $this->setTemplate("{$name}.tpl"); $appHome = $this->app->getApplicationDirectory(); $this->plugins_dir = array('plugins', SA_CORE_DIR . 'sa_smarty_plugins'); $this->setLayoutDir("{$appHome}/layouts"); $this->setTemplateDir("{$appHome}/templates"); $this->setCompileDir("{$appHome}/templates_c"); $this->use_sub_dirs = true; $this->headers = array('Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT', 'Last-Modified' => gmdate('D, d M Y H:i:s') . ' GMT', 'Cache-Control' => 'no-store, no-cache, must-revalidate', 'Pragma' => 'no-cache'); }
public function dispatch($appDirectory = null) { $appDirectory = is_null($appDirectory) ? SA_HOME_DIR . '/app/' : $appDirectory; $appFile = $appDirectory . '/Application.php'; $app = null; if (file_exists($appFile)) { require_once $appFile; $app = new Application(); SA_Registry::set('__SA_APPLICATION__', $app); $app->setApplicationDirectory($appDirectory); $app->init(); } else { throw new SA_ApplicationNotFoundException('Application not found in <b>' . $appDirectory . '</b>.'); } return $app; }
public static function &factory($name) { $page = null; $pageFile = SA_Registry::get('__SA_APPLICATION__')->getApplicationDirectory() . "/pages/{$name}.php"; $className = 'Page_' . basename($name); if (file_exists($pageFile)) { require_once $pageFile; if (class_exists($className)) { $page = new $className($name); if (!is_a($page, 'SA_IPage')) { throw new SA_DoesNotImplementSAIPageException("{$className} does not implement <b>SA_IPage</b>"); } } else { throw new Exception("The class <b>{$className}</b> was not found."); } } else { throw new Exception("The file <b>{$pageFile}</b> was not found."); } return $page; }