/** * Construct this object by extending the base Controller class */ public function __construct() { parent::__construct(); // get project url $this->data['project_url'] = Router::getProjectUrl(); $this->data['current_url'] = Router::getUrl(); }
public function index($search) { $result = Result::convert(parent::index($search)); $result->addData(array('operation_link_list' => array(function (User $item) { return '<a href="' . Router::getUrl('user/updatePassword', array('id' => $item->id)) . '" rel="popup">修改密码</a>'; }))); return $result; }
/** * Calls authorize and prepare in this order. * The ControllerFactory calls initialize when creating a controller, if $skipInitialization == false * * If you skip it, make sure you call all methods yourself! * * * @see authorize() * @see prepare() * @see ErrorMessageException */ public final function initialize() { $this->router->setCurrentRoute($this->getUrlName(), $this->getUrlAction(), $this->getActionParameters()); if (($error = $this->router->getUrlError()) !== null) { $this->addError($error); } if (($success = $this->router->getUrlSuccess()) !== null) { $this->addSuccess($success); } try { $this->authorize(); $this->prepare(); } catch (DatabaseException $e) { Log::error($e->getMessage(), 'Controller', array('siteName' => $this->getSiteName())); throw new ControllerException('Database error.'); } if ($this->keepInHistory()) { $this->container->history->addUrl($this->router->getUrl()); } }
include_once 'controller/arenaController.php'; $arenaController = new arenaController(); if ($action != '') { handleFullUrl($arenaController, $action); } else { $arenaController->arenaAction(); } break; case 'character': include_once 'controller/characterController.php'; $characterController = new CharacterController(); handleFullUrl($characterController, $action); break; } } else { $loginUrl = Router::getUrl('user_login'); redirectTo($loginUrl); } } function redirectTo($url) { //if(!strpos($url, 'http://')) // $url = 'http://' . $url; header('Location:' . $url); } //Automatically choose controller and action basing on url function handleFullUrl($controller, $action) { $fullActionName = $action . 'Action'; if (method_exists($controller, $fullActionName)) { $controller->{$fullActionName}();
public static function render($code, $params) { header("HTTP/1.0 503 Service Unavailable"); switch ($code) { case 1: if (!Kernel::getDebugMode()) { self::redirect(Router::getUrl("error", "http", array(404))); } $message = "Controller not found"; $origin = "class"; break; case 2: if (!Kernel::getDebugMode()) { self::redirect(Router::getUrl("error", "http", array(404))); } $message = "Action not found"; $origin = "function"; break; case 3: if (!Kernel::getDebugMode()) { self::redirect(Router::getUrl("error", "http", array(404))); } $message = "Theme not found"; $origin = "theme :"; break; case 4: if (!Kernel::getDebugMode()) { self::redirect(Router::getUrl("error", "http", array(404))); } $message = "Number of required parameters for action has not been reached"; $origin = "function :"; break; case 5: if (!Kernel::getDebugMode()) { self::redirect(Router::getUrl("error", "http", array(404))); } $message = "Database connection failed"; $origin = "Message :"; break; default: if (!Kernel::getDebugMode()) { self::redirect(Router::getUrl("error", "http", array(404))); } $message = "Fatal Error catched !"; $origin = "Message :"; break; } ?> <!DOCTYPE html> <html> <head> <title><?php echo $message; ?> </title> </head> <body> <div style="font-family: 'lucida grande',tahoma,verdana,arial,sans-serif;padding: 30px;border: 1px solid #E5E5E5;background: #F9F9F9;width: 400px;margin: auto;margin-top: 40px;border-radius: 5px;"> <span style="font-size: 1.2em;font-weight: bold;"><?php echo $message; ?> </span> <pre style="margin-bottom: 0px;white-space : pre-wrap;"><span style="color: grey;"><?php echo $origin; ?> </span> <?php echo $params; ?> </pre> </div> </body> </html> <?php die; }
<a href="<?php echo Router::getUrl("content", "list", array("type" => "comment")); ?> "> <div class="menu-onglet<?php if ($header == "comment") { ?> -active<?php } ?> "> Comments </div> </a> <a href="<?php echo Router::getUrl("parameters", "index"); ?> "> <div class="menu-onglet<?php if ($header == "parameters") { ?> -active<?php } ?> "> Paramêtres </div> </a> </div> </div> <?php
public function generateUrl($route, $parameters = null) { return Router::getUrl($route, $parameters); }
/** * @expectedException InvalidArgumentException */ public function testGetUrlWrongNumberOfArgumentsForNamedRoutes() { $router = new Router(); $route = new MockRoute_GetLink(); $router->addRoute('myroute', $route); $failed_url = $router->getUrl('myroute', array(':class' => 'myclass', ':method' => 'mymethod')); }
public function DisconnectAction($params) { $this->Auth->disconnect(); $this->redirect(Router::getUrl("/")); }
public function bootstrap() { // set urls $this->data['project_url'] = Router::getProjectUrl(); $this->data['current_url'] = Router::getUrl(); // set date format $this->data['date_format'] = App::load()->date_format; // set default includes $this->header = PATH_APP_VIEWS . 'admin/default/assets/inc/_header'; $this->sidebar = PATH_APP_VIEWS . 'admin/default/assets/inc/_sidebar'; $this->footer = PATH_APP_VIEWS . 'admin/default/assets/inc/_footer'; }
var urlDeleteNode = '<?php echo Router::getUrl("content", "deletenodeajax"); ?> '; var urlUpdate = '<?php echo Router::getUrl("content", "updateajax"); ?> '; var urlRemove = '<?php echo Router::getUrl("content", "removeajax"); ?> '; var urlRestore = '<?php echo Router::getUrl("content", "restoreajax"); ?> '; var urlAddChooseBundle= '<?php echo Router::getUrl("content", "addchoosebundleajax"); ?> '; var urlAddForm = '<?php echo Router::getUrl("content", "addformajax"); ?> '; var urlAddSave = '<?php echo Router::getUrl("content", "addsaveajax"); ?> '; </script>