Ejemplo n.º 1
0
 protected function routing($config)
 {
     $request = new Sabel_Request_Object("index/index");
     $config->configure();
     $candidate = $config->getValidCandidate($request->getUri());
     Sabel_Context::getContext()->setCandidate($candidate);
 }
Ejemplo n.º 2
0
 protected function setUri($uri)
 {
     $bus = Sabel_Context::getContext()->getBus();
     if (is_object($bus) && ($request = $bus->get("request"))) {
         $request->setUri($uri);
     }
     $_SERVER["REQUEST_URI"] = $uri;
 }
Ejemplo n.º 3
0
 /**
  * HTTP Redirect to another location with uri.
  *
  * @param string $uriParameter
  * @param array  $parameters
  *
  * @return void
  */
 public function to($uriParameter, $parameters = array())
 {
     $context = Sabel_Context::getContext();
     $uri = $context->getCandidate()->uri($uriParameter);
     if ($this->parameters = $parameters) {
         $uri .= "?" . http_build_query($this->parameters, "", "&");
     }
     return $this->uri($uri);
 }
Ejemplo n.º 4
0
function linkto($file)
{
    if ($bus = Sabel_Context::getContext()->getBus()) {
        if ($bus->get("NO_VIRTUAL_HOST")) {
            return dirname($_SERVER["SCRIPT_NAME"]) . "/" . $file;
        }
    }
    return "/" . $file;
}
Ejemplo n.º 5
0
 public function testCreateDevelopmentCandidate()
 {
     $bus = $this->bus;
     $bus->set("request", new Sabel_Request_Object("devel/main/index/db"));
     $processor = new Processor_Router("router");
     $processor->execute($bus);
     $candidate = Sabel_Context::getContext()->getCandidate();
     $this->assertTrue($candidate instanceof Sabel_Map_Candidate);
     $this->assertEquals("devel", $candidate->getName());
     $this->assertEquals("db", $bus->get("request")->fetchParameterValue("param"));
 }
Ejemplo n.º 6
0
 public function partial($name, $assign = array())
 {
     $bus = Sabel_Context::getContext()->getBus();
     $view = $bus->get("view");
     if (($template = $view->getValidLocation($name)) !== null) {
         $responses = array_merge($bus->get("response")->getResponses(), $assign);
         $contents = $template->getContents();
         return $this->rendering($contents, $responses, $template->getPath());
     } else {
         throw new Sabel_Exception_Runtime("template is not found.");
     }
 }
Ejemplo n.º 7
0
 protected function getRequestUri()
 {
     if (class_exists("Sabel_Context", false)) {
         $bus = Sabel_Context::getContext()->getBus();
         if (is_object($bus) && ($request = $bus->get("request"))) {
             return "/" . $request->getUri();
         }
     }
     if (isset($_SERVER["REQUEST_URI"])) {
         return "/" . normalize_uri($_SERVER["REQUEST_URI"]);
     } else {
         return "/";
     }
 }
Ejemplo n.º 8
0
 public function execute(Sabel_Bus $bus)
 {
     $request = $bus->get("request");
     $config = $bus->getConfig("map");
     $config->configure();
     if ($candidate = $config->getValidCandidate($request->getUri())) {
         $request->setParameterValues(array_map("urldecode", $candidate->getUriParameters()));
         $destination = $candidate->getDestination();
         l("DESTINATION: " . $destination);
         $bus->set("destination", $destination);
         Sabel_Context::getContext()->setCandidate($candidate);
     } else {
         $message = __METHOD__ . "() didn't match to any routing configuration.";
         throw new Sabel_Exception_Runtime($message);
     }
 }
Ejemplo n.º 9
0
 public function afterAction($bus)
 {
     $response = $bus->get("response");
     $response->setResponses(array_merge($response->getResponses(), $bus->get("controller")->getAttributes()));
     if ($response->getStatus()->isServerError()) {
         $exception = Sabel_Context::getContext()->getException();
         if (!is_object($exception)) {
             return;
         }
         $eol = (ENVIRONMENT & DEVELOPMENT) > 0 ? "<br />" : PHP_EOL;
         $msg = get_class($exception) . ": " . $exception->getMessage() . $eol . "At: " . date("r") . $eol . $eol . Sabel_Exception_Printer::printTrace($exception, $eol, true);
         if ((ENVIRONMENT & PRODUCTION) > 0) {
         } else {
             $response->setResponse("exception_message", $msg);
         }
         l(PHP_EOL . str_replace("<br />", PHP_EOL, $msg), SBL_LOG_ERR);
     }
 }
Ejemplo n.º 10
0
 public function execute($bus)
 {
     $response = $bus->get("response");
     $status = $response->getStatus();
     $controller = $bus->get("controller");
     if ($response->isFailure() || $response->isRedirected()) {
         return;
     }
     $action = $bus->get("destination")->getAction();
     $controller->setAction($action);
     if ($isAjax = $bus->get("AJAX_REQUEST")) {
         $controller->setAttribute("ajax", new AjaxResult());
     }
     $controller->setAttribute("submenu", new Views_Submenu());
     try {
         $controller->initialize();
         if ($response->isSuccess() && !$response->isRedirected()) {
             $controller->execute();
         }
         $controller->finalize();
         if ($isAjax && $response->isFailure()) {
             $status->setCode(Sabel_Response::OK);
             $controller->ajax->code = $status->getCode();
         }
     } catch (Exception_UserNotFound $unf) {
         if ($isAjax) {
             $controller->ajax->code = Sabel_Response::NOT_FOUND;
         } else {
             $status->setCode(Sabel_Response::NOT_FOUND);
         }
         Sabel_Context::getContext()->setException($e);
     } catch (Exception $e) {
         if ($isAjax) {
             $controller->ajax->code = Sabel_Response::INTERNAL_SERVER_ERROR;
         } else {
             $status->setCode(Sabel_Response::INTERNAL_SERVER_ERROR);
         }
         Sabel_Context::getContext()->setException($e);
     }
     if ($controller->getAttribute("layout") === false) {
         $bus->set("NO_LAYOUT", true);
     }
 }
Ejemplo n.º 11
0
 public function execute(Sabel_Bus $bus)
 {
     $response = $bus->get("response");
     $controller = $bus->get("controller");
     if ($response->isFailure() || $response->isRedirected()) {
         return;
     }
     $action = $bus->get("destination")->getAction();
     $controller->setAction($action);
     try {
         $controller->initialize();
         if ($response->isSuccess() && !$response->isRedirected()) {
             $controller->execute();
         }
         $controller->finalize();
     } catch (Exception $e) {
         $response->getStatus()->setCode(Sabel_Response::INTERNAL_SERVER_ERROR);
         Sabel_Context::getContext()->setException($e);
     }
     if ($controller->getAttribute("layout") === false) {
         $bus->set("NO_LAYOUT", true);
     }
 }
Ejemplo n.º 12
0
/**
 * create uri
 */
function uri($param, $secure = false, $absolute = false)
{
    $context = Sabel_Context::getContext();
    $prefix = get_uri_prefix($secure, $absolute);
    return $prefix . "/" . $context->getCandidate()->uri($param);
}
Ejemplo n.º 13
0
/**
 * create uri
 */
function uri($uri, $secure = false, $absolute = false)
{
    $context = Sabel_Context::getContext();
    return get_uri_prefix($secure, $absolute) . "/" . $context->getCandidate()->uri($uri);
}
Ejemplo n.º 14
0
 public function __construct()
 {
     $this->processorList = new Sabel_Util_HashList();
     Sabel_Context::getContext()->setBus($this);
 }
Ejemplo n.º 15
0
 /**
  * HTTP Redirect to another location with uri.
  *
  * @param string $uri
  * @param array  $parameters
  * @param string $flagment
  *
  * @return string
  */
 public function to($uri, $parameters = array(), $flagment = "")
 {
     $context = Sabel_Context::getContext();
     return $this->uri($context->getCandidate()->uri($uri), $parameters, $flagment);
 }
Ejemplo n.º 16
0
//require ("Sabel"  . DIRECTORY_SEPARATOR . "Sabel.php");
require RUN_BASE . DIRECTORY_SEPARATOR . "Sabel" . DIRECTORY_SEPARATOR . "Sabel.php";
require RUN_BASE . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "INIT.php";
require RUN_BASE . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "environment.php";
if (!defined("ENVIRONMENT")) {
    echo "SABEL FATAL ERROR: must define ENVIRONMENT in config/environment.php";
    exit;
}
if ((ENVIRONMENT & PRODUCTION) > 0) {
    Sabel::init();
    $out = Sabel_Bus::create()->run(new Config_Bus());
    Sabel::shutdown();
} else {
    $out = Sabel_Bus::create()->run(new Config_Bus());
}
if (Sabel_Context::getContext()->getBus()->get("AJAX_REQUEST")) {
    echo $out;
    exit;
}
$root =& XCube_Root::getSingleton();
$target =& $root->mContext->mModule->getRenderTarget();
$target->setResult($out);
$target->setAttribute('legacy_buffertype', null);
$theme =& $root->mController->_mStrategy->getMainThemeObject();
$renderSystem =& $root->getRenderSystem($theme->get('render_system'));
$renderSystem->_commonPrepareRender();
if (isset($GLOBALS['xoopsUserIsAdmin'])) {
    $renderSystem->mXoopsTpl->assign('xoops_isadmin', $GLOBALS['xoopsUserIsAdmin']);
}
$renderSystem->mXoopsTpl->assign('xoops_block_header', '');
$renderSystem->mXoopsTpl->assign('xoops_module_header', '');
Ejemplo n.º 17
0
 public function __construct()
 {
     $this->imanage = Sabel_Context::getContext()->getBus()->get("imanage");
 }
Ejemplo n.º 18
0
 protected function getBus()
 {
     return Sabel_Context::getContext()->getBus();
 }