示例#1
0
 public function getController()
 {
     $router = new Router();
     $xml = new \DOMDocument();
     $xml->load(__DIR__ . '/../../App/' . $this->name . '/Config/route.xml');
     $routes = $xml->getElementByTagName("route");
     foreach ($routes as $route) {
         $vars = [];
         if ($route->hasAttribute('vars')) {
             $vars = explode(',', $route->getAttribute('vars'));
         }
         $router->addRoute(new Route($route->getAttribute('url'), $route->getAttribute('module'), $route->getAttribute('action'), $vars));
     }
     try {
         $matched_route = $router->getRoute($this->httpRequest->requestURI());
     } catch (\RuntimeException $exception) {
         if ($exception->getCode() == Router::NO_ROUTE) {
             $this->httpResponse->redirect404();
         }
     }
     // Add variables in tab: $_GET
     $_GET = array_merge($_GET, $matched_route->module(), $matched_route->action());
     // Instancie the controller
     $controller_class = 'App\\' . $this->name . '\\Modules\\' . $matched_route->module() . '\\' . $matched_route->module() . 'Controllers';
     return new $controller_class($this, $matched_route->module(), $matched_route->action());
 }
 public function generateResponse($route = null, $params = array(), $internal = false)
 {
     $router = new Router();
     $request = Request::getInstance();
     $request->setInternal($internal);
     if ($route) {
         $route = $router->getRoute($route);
     } else {
         $route = $router->getDefaultRoute();
     }
     $controller = $route->getController();
     $action = $route->getAction();
     $controller = new $controller();
     $r = new ReflectionMethod($controller, $action);
     $paramsOfFunction = $r->getParameters();
     $paramsToPass = array();
     $indexParams = 0;
     foreach ($paramsOfFunction as $param) {
         if ($param->getClass() != NULL && $param->getClass()->getName() == 'Request') {
             $paramsToPass[] = $request;
         } else {
             if (isset($params[$indexParams])) {
                 $paramsToPass[] = $params[$indexParams++];
             } else {
                 $paramsToPass[] = null;
             }
         }
     }
     if (!empty($paramsToPass)) {
         return call_user_func_array(array($controller, $action), $paramsToPass);
     }
     return $controller->{$action}();
 }
示例#3
0
 public function beforeAction()
 {
     // auto find model entry when id passed
     if (isset($this->params['id'])) {
         if (!$this->{$this->name}->fromId($this->params['id'])) {
             return false;
         }
         $this->data->set($this->name, $this->{$this->name});
     }
     // send invalid logins (invalid user group) back to loing page
     if (!$this->UserLogin->loggedin() && empty($this->publicActions)) {
         $this->redirect(Router::getRoute('adminLogin'));
     }
     // change language on users locale
     if (isset($this->I18n) && $this->UserLogin->loggedin() && $this->User->hasField('locale')) {
         $this->I18n->locale($this->UserLogin->User->locale);
     }
     // if mobile layout selected, use other action view files
     if ($this->layout == 'mobile') {
         // and increase number of returned model entries
         if (!empty($this->{$this->name})) {
             $this->{$this->name}->perPage = 50;
             if (!in_array($this->action, array('edit', 'view'))) {
                 $this->{$this->name}->depth = 0;
             }
         }
         $this->action .= '.mobile';
     }
     return parent::beforeAction();
 }
示例#4
0
 public function getController()
 {
     $Router = new Router();
     $this->Router = $Router;
     $xml = new \DOMDocument();
     $xml->load(__DIR__ . '/../../App/' . $this->name . '/Config/routes.xml');
     $routes = $xml->getElementsByTagName('route');
     // On parcourt les routes du fichier XML.
     foreach ($routes as $route) {
         $vars = [];
         // On regarde si des variables sont présentes dans l'URL.
         if ($route->hasAttribute('vars')) {
             $vars = explode(',', $route->getAttribute('vars'));
         }
         // On ajoute la route au routeur.
         $Router->addRoute(new Route($route->getAttribute('url'), $route->getAttribute('module'), $route->getAttribute('action'), $vars));
     }
     try {
         // On récupère la route correspondante à l'URL.
         $matchedRoute = $Router->getRoute($this->httpRequest->requestURI());
     } catch (\RuntimeException $e) {
         if ($e->getCode() == Router::NO_ROUTE) {
             // Si aucune route ne correspond, c'est que la page demandée n'existe pas.
             $this->httpResponse->redirect404();
         }
     }
     // On ajoute les variables de l'URL au tableau $_GET.
     $_GET = array_merge($_GET, $matchedRoute->vars());
     // On instancie le contrôleur.
     $controllerClass = 'App\\' . $this->name . '\\Modules\\' . $matchedRoute->module() . '\\' . $matchedRoute->module() . 'Controller';
     return new $controllerClass($this, $matchedRoute->module(), $matchedRoute->action());
 }
示例#5
0
 public function ajaxSearch()
 {
     $search = $_GET['s'];
     $groups = $this->group->getGroupInfoByName($search);
     $sports = $this->acc->getSportsByName($search);
     $users = $this->acc->getUsersByName($search);
     echo json_encode(["groupe" => array_slice($groups, 0, 5), "urlgroupe" => $_GET['lang'] . "/" . Router::getRoute('groupe'), "sports" => array_slice($sports, 0, 5), "urlsport" => $_GET['lang'] . "/" . Router::getRoute('SportGroupe'), "users" => array_slice($users, 0, 5)]);
 }
示例#6
0
 /**
  *
  */
 public function __construct()
 {
     $this->View = View::getInstance();
     $this->Model = Router::getRoute()['Controller'];
     $this->loadModel($this->Model);
     $this->Request = Request::getInstance();
     $this->Session = Session::getInstance();
     Orm::getInstance();
 }
 /**
  * Delete single {@link UserGroup}
  * 
  * @param integer $id
  * @return boolean
  */
 public function delete($id = null)
 {
     if ($this->UserGroup->delete()) {
         $this->FlashMessage->set(__('Die Benutzergruppe <q>:1</q> wurder erfolgreich gelöscht.', $this->UserGroup->get('name')), FlashMessageType::SUCCESS);
     } else {
         $this->FlashMessage->set(__('Es ist ein Fehler beim Löschen der Benutzergruppe aufgetreten.'), FlashMessageType::ERROR);
     }
     return $this->redirect(Router::getRoute('adminScaffold', array('controller' => $this->name)));
 }
 public function delete($id = null)
 {
     if (parent::delete($id)) {
         $this->FlashMessage->set(__('Blogeintrag erfolgreich gelöscht.'), FlashMessageType::SUCCESS);
     } else {
         $this->FlashMessage->set(__('Fehler beim Löschen des Blogeintrags.'), FlashMessageType::ERROR);
     }
     $this->redirect(Router::getRoute('adminBlogPost'));
 }
 public function delete($id = null)
 {
     if (parent::delete($id)) {
         $this->FlashMessage->set(__('Zugriffsrecht erfolgreich gelöscht.'), FlashMessageType::SUCCESS);
     } else {
         $this->FlashMessage->set(__('Fehler beim Löschen des Zugriffsrecht.'), FlashMessageType::ERROR);
     }
     $this->redirect(Router::getRoute('adminScaffold', array('controller' => $this->name)));
 }
 public function delete($id = null)
 {
     if (parent::delete($id)) {
         $this->MediaFile->updateWhere(array('folder_id' => (int) $id), array('folder_id' => 'NULL'));
         $this->FlashMessage->set(__('Die Kategorie wurde erfolgreich gelöscht. Dateien die in dieser Kategorie waren sind nun nicht mehr zugeordnet'));
     } else {
         $this->FlashMessage->set(__('Fehler beim Löschen der Kategorie'));
     }
     $this->redirect(Router::getRoute('adminMediaFiles'));
 }
示例#11
0
 public function run(Query $config)
 {
     // Set the timezone for the user using the system one
     Utils::defineTimeZone();
     // Retrieve the route from the given parameters
     $route = Router::getRoute($config);
     if ($route !== false) {
         $this->invoke($route);
     }
 }
 public function parseRequest()
 {
     if (isset($_SERVER['REDIRECT_URL']) && !empty($_SERVER['REDIRECT_URL'])) {
         $url = $_SERVER['REDIRECT_URL'];
     } else {
         $url = $_SERVER['REQUEST_URI'];
     }
     list($handler, $args) = Router::getRoute($url);
     return array($handler, $args);
 }
示例#13
0
 /**
  * Return uri-string to a single blog entry
  */
 public function detailPageUri(array $params = array())
 {
     if (!$this->exists()) {
         return false;
     }
     if ($this->isEmpty('uri')) {
         return Router::getRoute('blogEntryId', array('id' => $this->id));
     } else {
         return Router::getRoute('blogEntryUri', array('uri' => $this->uri));
     }
 }
示例#14
0
 /**
  *	Uses the router and the name of the model to return a detail page
  *	uri that leads to the detail page of of a model entry
  *	@param array(string) $additionalParams
  *	@return string
  */
 public function adminDetailPageUri($additionalParams = array())
 {
     if (!is_array($additionalParams)) {
         $additionalParams = array('action' => $additionalParams);
     }
     $params = array_merge(array('action' => '', 'id' => $this->id, 'controller' => $this->name), $additionalParams);
     $uri = Router::getRoute('admin' . String::ucFirst($this->name) . 'Id', $params);
     if (empty($uri)) {
         $uri = Router::getRoute('adminScaffoldId', $params);
     }
     return $uri;
 }
 public function create()
 {
     $this->data->set('pageTitle', __('Sprache erstellen'));
     if ($this->AdminLanguageForm->ok()) {
         $this->AdminLanguageForm->toModel($this->Language);
         if (!$this->Language->save()) {
             $this->AdminLanguageForm->errors = $this->Language->validationErrors;
         } else {
             $this->FlashMessage->set(__('Die neue Sprache wurde erfolgreich angelegt.'), FlashMessageType::HINT);
             $this->redirect(Router::getRoute('adminLanguage'));
         }
     }
 }
示例#16
0
 public function __construct(Router $router, $routeName, $action = null)
 {
     $route = $router->getRoute($routeName);
     $modelName = $route->model;
     $controllerName = $route->controller;
     $viewName = $route->view;
     $model = new $modelName();
     $this->controller = new $controllerName($model);
     $this->view = new $viewName($routeName, $model);
     if (!empty($action)) {
         $this->controller->{$action}();
     }
 }
 public function parseRequest()
 {
     if (isset($_SERVER['REDIRECT_URL']) && !empty($_SERVER['REDIRECT_URL'])) {
         $url = $_SERVER['REDIRECT_URL'];
     } else {
         $url = $_SERVER['REQUEST_URI'];
     }
     if (strpos($url, '?') !== FALSE) {
         list($url, $query_string) = explode('?', $url);
     }
     list($handler, $args) = Router::getRoute($url);
     return array($handler, $args);
 }
 public function upload()
 {
     // upload to a folder
     if (!empty($this->params['folder_id'])) {
         if (!$this->Folder->fromId((int) $this->params['folder_id'])) {
             return false;
         }
         $this->data->set('Folder', $this->Folder);
         $this->AdminMediaFileForm->delete('folder_id');
         $this->MediaFile->folder_id = $this->Folder->id;
     } elseif (!empty($this->params['nodeId'])) {
         unset($this->Node->findConditions['Node.status']);
         if (!$this->Node->fromId((int) $this->params['nodeId'])) {
             return false;
         }
         $this->data->set('Node', $this->Node);
         $this->MediaFile->node_id = $this->Node->id;
     }
     // get redirect url after successfull upload
     if ($this->Folder->exists()) {
         $redirectUrl = $this->Folder->adminDetailPageUri();
     } elseif ($this->Node->exists()) {
         $redirectUrl = $this->Node->adminDetailPageUri(array('action' => 'edit'));
     } else {
         $redirectUrl = Router::getRoute('adminMediaFiles');
     }
     $this->data->set('redirectUrl', $redirectUrl);
     // process upload
     $uploadedFile = $this->AdminMediaFileForm->file->value();
     if (!empty($uploadedFile)) {
         $this->AdminMediaFileForm->toModel($this->MediaFile);
         $MediaFile = $this->MediaFile->addFile($this->AdminMediaFileForm->file->value(), $this->AdminMediaFileForm->file->originalFilename());
         $MediaFile->User = $this->UserLogin->User;
         $MediaFile->Folder = $this->Folder;
         if (isset($this->params['nodeId'])) {
             $MediaFile->node_id = $this->params['nodeId'];
         }
         if (!$MediaFile->save()) {
             return $this->AdminMediaFileForm->errors = $MediaFile->validationErrors;
         }
         $this->FlashMessage->set(__('Datei erfolgreich hochgeladen.'), FlashMessageType::HINT);
         if (@$this->request->data['uploadify'] === '1') {
             echo true;
             exit;
         } else {
             $this->redirect($redirectUrl);
         }
     }
 }
示例#19
0
 public static function run()
 {
     session_start();
     /*
      * Array which contains controllerName, controllerAction and arguments.
      *
      * @var array
      * */
     $route = Router::getRoute();
     if (isset($route['controllerName'])) {
         $controllerObj = new $route['controllerName']();
         call_user_func_array(array($controllerObj, $route['controllerAction']), $route['actionArgs']);
     } else {
         $studListControllerObj = new \controllers\StudentsListController();
         $studListControllerObj->studentsListAction();
     }
 }
示例#20
0
 public function getController()
 {
     $router = new Router();
     $router->buildRoutesForApplication($this->name());
     try {
         // On récupère la route correspondante à l'URL.
         $matchedRoute = $router->getRoute($this->httpRequest->requestURI(), $this->name());
     } catch (\RuntimeException $e) {
         if ($e->getCode() == Router::NO_ROUTE) {
             // Si aucune route ne correspond, c'est que la page demandée n'existe pas.
             $this->httpResponse->redirect404();
         }
     }
     // On ajoute les variables de l'URL au tableau $_GET.
     $_GET = array_merge($_GET, $matchedRoute->vars());
     // On instancie le contrôleur.
     $controllerClass = 'App\\' . $this->name . '\\Modules\\' . $matchedRoute->module() . '\\' . $matchedRoute->module() . 'Controller';
     return new $controllerClass($this, $matchedRoute->module(), $matchedRoute->action());
 }
示例#21
0
 public function __construct()
 {
     // parent::__construct();
     config::getInstance();
     config::getConfig();
     $router = new Router();
     $router->explodeUri();
     /*
     apenas para checagem dos caminhos
     //echo '<p>ROUT FILE: '.$routFile.'</p>';
     echo '<pre >';
     echo '<p>ROTA COMPLETA: '.$this->getRoute().'</p>';
     echo '<p>NOME Controller: '.$this->getController().'</p>';
     echo '<p>NOME METODO: '.$this->getAction().'</p>';
     echo '</pre>';
     */
     define('ROUTE', $router->getRoute());
     define('CONTROLLER', $router->getController());
     define('ACTION', $router->getAction());
     $filename = BASEPATH . DIRECTORY_SEPARATOR . APPPATH . DIRECTORY_SEPARATOR . CONTROLLERS . DIRECTORY_SEPARATOR . ROUTE . CONTROLLER . '.controller.php';
     if (file_exists($filename)) {
         require_once $filename;
         $_controllerName = CONTROLLER;
         $_controller = new $_controllerName();
         $action = ACTION;
         if (method_exists($_controller, $action)) {
             $_controller->{$action}();
         } else {
             require_once BASEPATH . DIRECTORY_SEPARATOR . APPPATH . DIRECTORY_SEPARATOR . CONTROLLERS . DIRECTORY_SEPARATOR . 'error404.controller.php';
             $errorController = new error404();
             $errorController->index();
         }
     } else {
         require_once BASEPATH . DIRECTORY_SEPARATOR . APPPATH . DIRECTORY_SEPARATOR . CONTROLLERS . DIRECTORY_SEPARATOR . 'error404.controller.php';
         $errorController = new error404();
         $errorController->index();
     }
 }
示例#22
0
 protected function setProperties()
 {
     $this->_fullRoute = Router::getFullRoute();
     $this->_route = Router::getRoute();
     $this->_domain = Router::getDomain();
     preg_match_all('/\\{\\{((\\w*|\\d))\\}\\}/', $this->content, $matches);
     if (!empty($matches)) {
         foreach ($matches[0] as $match) {
             $matchName = trim(str_replace(array("{{", "}}"), array("", ""), $match));
             if (method_exists($this, $matchName)) {
                 $this->content = str_replace($match, $this->{$matchName}(), $this->content);
             } else {
                 if (property_exists($this, $matchName)) {
                     $this->content = str_replace($match, $this->{$matchName}, $this->content);
                 } else {
                     if (array_key_exists($matchName, $this->data)) {
                         $this->content = str_replace($match, $this->data[$matchName], $this->content);
                     }
                 }
             }
         }
     }
 }
 public function getController()
 {
     $router = new Router();
     $xml = new \DOMDocument();
     $xml->load(__DIR__ . '/../../JVN/' . $this->name . '/Config/routes.xml');
     $routes = $xml->getElementsByTagName('route');
     foreach ($routes as $route) {
         $vars = [];
         if ($route->hasAttribute('vars')) {
             $vars = explode(',', $route->getAttribute('vars'));
         }
         $router->addRoute(new Route($route->getAttribute('url'), $route->getAttribute('module'), $route->getAttribute('action'), $vars));
     }
     try {
         $matchedRoute = $router->getRoute($this->httpRequest->requestURL());
     } catch (\RuntimeException $e) {
         if ($e->getCode() == Router::NO_ROUTE) {
             $this->httpResponse->redirect404();
         }
     }
     $_GET = array_merge($_GET, $matchedRoute->vars());
     $controllerClass = 'JVN\\' . $this->name . '\\Modules\\' . $matchedRoute->module() . '\\' . $matchedRoute->module() . 'Controller';
     return new $controllerClass($this, $matchedRoute->module(), $matchedRoute->action());
 }
示例#24
0
//$_SESSION['logged'] = true;
//$_SESSION['ID'] = 126;
if (!isset($_SESSION['logged'])) {
    $_SESSION['logged'] = false;
}
//initialization of database
include_once "src/util/db_wrap.php";
$connexion = new \db\db_handler();
$connexion->init();
//Routing initialization
include_once "src/Router.php";
$router = new Router();
//URL rewriting
$task = explode('/', $_SERVER["REQUEST_URI"]);
//get the right route from the first parameter
$route = $router->getRoute($task[1]);
//get correct MVC bloc
$model = new $route->model();
$controller = new $route->controller($model);
$view = new $route->view($model);
require_once "src/util/regex.php";
//var_dump($task);
if (count($task) > 2) {
    $options = array_slice($task, 2);
    foreach ($options as $value) {
        if (empty($value) === false) {
            $controller->addOption(strip_all("/[^\\w]/", $value));
        }
    }
}
//let the controller update the model and the view display the model according to itself
示例#25
0
<h1><?php 
echo $pageTitle;
?>
</h1>
<ul class="breadcrumb">
	<li><?php 
echo $HTML->link(Router::getRoute('admin'), __('Home'));
?>
</li>
	<li><?php 
echo $HTML->link(Router::getRoute('adminBlogPost'), __('Blogeinträge'));
?>
</li>
	<li><?php 
echo __('Blogeintrag erstellen');
?>
</li>
</ul>
<?php 
echo $AdminBlogPostForm;
示例#26
0
<div class="toolbar">
	<?php 
echo $HTML->link('#', __('zurück'), array('class' => 'back flip'));
echo $HTML->tag('h1', $pageTitle);
echo $HTML->link(Router::getRoute('adminCommentId', array('id' => $Comment->id, 'action' => 'delete')), __('löschen'), array('class' => 'button confirm', 'title' => __('Wollen Sie diesen Kommentar wirklich löschen?')));
?>
	?>
</div>
<?php 
if ($Comment->BlogPost->exists()) {
    ?>
<ul class="rounded">
	<li class="arrow">
		<?php 
    echo $HTML->link($Comment->BlogPost->adminDetailPageUri('edit'), $Comment->BlogPost->get('headline'));
    ?>
	</li>
</ul>
<?php 
}
echo $this->element('jqtouch/form', array('Form' => $AdminCommentForm));
示例#27
0
<h1><?php 
echo __('Kommentar editieren');
?>
</h1>
<ul class="breadcrumb">
	<li><?php 
echo $HTML->link(Router::getRoute('admin'), __('Home'));
?>
</li>
	<li><?php 
echo $HTML->link(Router::getRoute('adminComment'), __('Kommentare'));
?>
</li>
	<li><?php 
echo __('Kommentar editieren');
?>
</li>
</ul>
<?php 
echo $AdminCommentForm;
示例#28
0
<h1><?php 
echo $User->get('name');
?>
</h1>
<ul class="breadcrumb">
	<li><?php 
echo $HTML->link(Router::getRoute('admin'), __('Home'));
?>
</li>
	<li><?php 
echo $HTML->link(Router::getRoute('adminUser'), __('Benutzer'));
?>
</li>
	<li><?php 
echo $User->get('name');
?>
</li>
</ul>

<?php 
echo $this->element('userMenu');
?>

<?php 
// blocked message
if ($User->hasFlag(UserFlag::BLOCKED)) {
    ?>
<p class="hint">
	<?php 
    echo __('Der Benutzer :1 ist zur Zeit gesperrt und kann sich nicht einloggen.', $User->get('name')) . '<br />';
    echo $HTML->link($User->adminDetailPageUri(array('action' => 'unblock')), __(':1 wieder freischalten', $User->get('name')));
示例#29
0
 public function delete($id = null)
 {
     $this->FlashMessage->set(__('Benutzer <q>:1</q> erfolgreich gelöscht.', (string) $this->User), FlashMessageType::SUCCESS);
     $this->User->delete();
     $this->redirect(Router::getRoute('adminUser'));
 }
示例#30
0
<h1><?php 
echo __('Zugriffsrechte');
?>
</h1>
<ul class="breadcrumb">
	<li><?php 
echo $HTML->link(Router::getRoute('admin'), __('Home'));
?>
</li>
	<li><?php 
echo $HTML->link(Router::getRoute('adminScaffold', array('controller' => $controller)), __('Zugriffsrechte'));
?>
</li>
	<li><?php 
echo __('editieren');
?>
</li>
</ul>