当前位置: 首页>>代码示例>>PHP>>正文


PHP App::router方法代码示例

本文整理汇总了PHP中App::router方法的典型用法代码示例。如果您正苦于以下问题:PHP App::router方法的具体用法?PHP App::router怎么用?PHP App::router使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在App的用法示例。


在下文中一共展示了App::router方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addKeysToJavascript

 /**
  * Add language keys to Javascript. To add several keys, you can call one time this function, each parameters
  * being a language key that wille be added to JavaScript
  *
  * @param string ...$keys The keys to add
  *
  * @deprecated since version 0.7.0, use Controller::addKeysToJavascript instead
  */
 public static function addKeysToJavascript(...$keys)
 {
     $script = "";
     foreach ($keys as $key) {
         list($plugin, $langKey) = explode(".", $key);
         $script .= "Lang.set('{$key}', '" . addcslashes(self::get($key), "'") . "');";
     }
     App::router()->getCurrentController()->addJavaScriptInline($script);
 }
开发者ID:elvyrra,项目名称:hawk,代码行数:17,代码来源:Lang.php

示例2: run

 public static function run($uri)
 {
     self::$router = new Router($uri);
     # создаем обект базы данных и передаем параметры подключения
     self::$db = new DB(Config::get('db.host'), Config::get('db.user'), Config::get('db.password'), Config::get('db.db_name'));
     Lang::load(self::$router->getLanguage());
     $controller_class = ucfirst(self::$router->getController()) . 'Controller';
     $controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction());
     # при каждом запросе к руту admin выполняется проверка, имеет ли пользователь на это права
     $layout = self::$router->getRoute();
     if ($layout == 'admin' && Session::get('role') != 'admin') {
         if ($controller_method != 'admin_login') {
             Router::redirect('/admin/users/login');
         }
     }
     // Calling controller's method
     $controller_object = new $controller_class();
     if (method_exists($controller_object, $controller_method)) {
         $view_path = $controller_object->{$controller_method}();
         $view_object = new View($controller_object->getData(), $view_path);
         $content = $view_object->render();
     } else {
         throw new Exception('Method ' . $controller_method . ' of class ' . $controller_class . ' does not exist.');
     }
     # код віполняющий рендеринг
     $layout_path = VIEWS_PATH . DS . $layout . '.html';
     $layout_view_object = new View(compact('content'), $layout_path);
     echo $layout_view_object->render();
 }
开发者ID:vovella,项目名称:homeworks,代码行数:29,代码来源:app.class.php

示例3: run

 public static function run($uri)
 {
     self::$router = new Router($uri);
     self::$db = new DB(config::get('db.host'), config::get('db.name'), config::get('db.user'), config::get('db.password'));
     Lang::load(self::$router->getLanguage());
     if ($_POST and (isset($_POST['username_in']) and isset($_POST['password_in'])) or isset($_POST['exit'])) {
         $us = new RegisterController();
         if (isset($_POST['exit'])) {
             $us->LogOut();
         } else {
             $us->Login($_POST);
         }
     }
     if (self::$router->getController() == 'admin' and !Session::getSession('root') or self::$router->getController() == 'myblog' and !Session::getSession('id')) {
         self::$router->setController(Config::get('default_controller'));
         self::$router->setAction(Config::get('default_action'));
         Session::setSession('message', 'Отказ в доступе');
     }
     $controller_class = ucfirst(self::$router->getController()) . 'Controller';
     $controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction());
     $controller_object = new $controller_class();
     if (method_exists($controller_object, $controller_method)) {
         $controller_object->{$controller_method}();
         $view_object = new View($controller_object->getData());
         $content = $view_object->render();
     } else {
         throw new Exception('Method ' . $controller_method . ' of class ' . $controller_class . ' does not exist');
     }
     $layout = self::$router->getRoute();
     $layout_path = VIEWS_PATH . DS . $layout . '.html';
     $layout_view_object = new View(compact('content'), $layout_path);
     echo $layout_view_object->render();
 }
开发者ID:seletskyy,项目名称:blog_mvc,代码行数:33,代码来源:app.class.php

示例4: display

 /**
  * Display the widget
  *
  * @return string The generated HTML
  */
 public function display()
 {
     $plugin = $this->plugin;
     $installer = $plugin->getInstallerInstance();
     $buttons = array(ButtonInput::create(array('icon' => 'share icon-flip-horizontal', 'class' => 'btn-default btn-block', 'href' => App::router()->getUri('manage-plugins'), 'label' => Lang::get('main.back-button'))));
     if (isset($updates[$plugin->getName()])) {
         $buttons[] = ButtonInput::create(array('icon' => 'refresh', 'class' => 'btn-info update-plugin btn-block', 'label' => Lang::get($this->_plugin . '.update-plugin-button'), 'href' => App::router()->getUri('update-plugin', array('plugin' => $plugin->getName()))));
     }
     if (!$plugin->isInstalled()) {
         // the plugin is not installed
         // Install button
         $buttons[] = ButtonInput::create(array('label' => Lang::get($this->_plugin . '.install-plugin-button'), 'icon' => 'upload', 'class' => 'install-plugin btn-block', 'href' => App::router()->getUri('install-plugin', array('plugin' => $plugin->getName()))));
         // Delete button
         $buttons[] = ButtonInput::create(array('label' => Lang::get($this->_plugin . '.delete-plugin-button'), 'icon' => 'trash', 'class' => 'btn-danger delete-plugin btn-block', 'href' => App::router()->getUri('delete-plugin', array('plugin' => $plugin->getName()))));
     } elseif (!$plugin->isActive()) {
         // The plugin is installed but not activated
         // Activate button
         $buttons[] = ButtonInput::create(array('label' => Lang::get($this->_plugin . '.activate-plugin-button'), 'class' => 'btn-success activate-plugin btn-block', 'icon' => 'check', 'href' => App::router()->getUri('activate-plugin', array('plugin' => $plugin->getName()))));
         // Settings button
         if (method_exists($installer, 'settings')) {
             $buttons[] = ButtonInput::create(array('icon' => 'cogs', 'label' => Lang::get($this->_plugin . '.plugin-settings-button'), 'href' => App::router()->getUri('plugin-settings', array('plugin' => $plugin->getName())), 'target' => 'dialog', 'class' => 'btn-info btn-block'));
         }
         // Uninstall button
         $buttons[] = ButtonInput::create(array('label' => Lang::get($this->_plugin . '.uninstall-plugin-button'), 'class' => 'btn-danger uninstall-plugin btn-block', 'icon' => 'chain-broken', 'href' => App::router()->getUri('uninstall-plugin', array('plugin' => $plugin->getName()))));
     } else {
         // The plugin is installed and active
         // Settings button
         if (method_exists($installer, 'settings')) {
             $buttons[] = ButtonInput::create(array('icon' => 'cogs', 'label' => Lang::get($this->_plugin . '.plugin-settings-button'), 'href' => App::router()->getUri('plugin-settings', array('plugin' => $plugin->getName())), 'target' => 'dialog', 'class' => 'btn-info btn-block'));
         }
         $buttons[] = ButtonInput::create(array('label' => Lang::get($this->_plugin . '.deactivate-plugin-button'), 'class' => 'btn-warning deactivate-plugin btn-block', 'icon' => 'ban', 'href' => App::router()->getUri('deactivate-plugin', array('plugin' => $plugin->getName()))));
     }
     return View::make($this->getPlugin()->getView('plugin-details-actions.tpl'), array('buttons' => $buttons));
 }
开发者ID:elvyrra,项目名称:hawk,代码行数:39,代码来源:PluginActionsWidget.php

示例5: run

 public static function run($uri)
 {
     self::$router = new Router($uri);
     self::$db = new DB(Config::get('db.host'), Config::get('db.user'), Config::get('db.password'), Config::get('db.db_name'));
     Lang::load(self::$router->getLanguage());
     $controller_class = ucfirst(self::$router->getController()) . "Controller";
     $controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction());
     $layout = self::$router->getRoute();
     if ($layout == "admin" && Session::get("role") != "admin") {
         if ($controller_method != "admin_login") {
             Router::redirect("/admin/users/login");
         }
     }
     //Calling controller's method
     $controller_object = new $controller_class();
     if (method_exists($controller_object, $controller_method)) {
         $view_path = $controller_object->{$controller_method}();
         $view_object = new View($controller_object->getData(), $view_path);
         $content = $view_object->render();
     } else {
         throw new Exception("Method {$controller_method} does not exist in {$controller_class}");
     }
     $layout_path = VIEWS_PATH . DS . $layout . ".html";
     $layout_view_object = new View(compact('content'), $layout_path);
     echo $layout_view_object->render();
 }
开发者ID:Denbora,项目名称:mvc_phpAcademy,代码行数:26,代码来源:app.class.php

示例6: run

 public static function run($uri)
 {
     self::$router = new Router($uri);
     self::$db = DB::getInstance(Config::get('db.host'), Config::get('db.user'), Config::get('db.password'), Config::get('db.db_name'));
     Lang::load(self::$router->getLanguage());
     $controller_class = ucfirst(self::$router->getController()) . 'controller';
     $controller_method = strtolower(self::$router->getMethod_prefix() . self::$router->getAction());
     $controller_parametr = self::$router->getParams();
     $layout = self::$router->getRoute();
     if ($layout == 'admin' && Session::get('role') != 'admin') {
         if ($controller_method != 'admin_login') {
             Router::redirect('/admin/users/login');
         }
     }
     //Calling conrollers method
     $controller_object = new $controller_class();
     if (method_exists($controller_object, $controller_method)) {
         $view_path = $controller_object->{$controller_method}();
         $view_object = new View($controller_object->getData(), $view_path);
         $content = $view_object->render();
     } else {
         throw new Exception('Метод ' . $controller_method . ' в классе ' . $controller_class . 'не найден');
     }
     $layout_path = VIEW_PATH . DS . $layout . '.html';
     $layout_view_object = new View(compact('content'), $layout_path);
     // основной рендер вывода страниц
     echo $layout_view_object->render();
 }
开发者ID:Skynet2004x,项目名称:SkynetPR,代码行数:28,代码来源:app.class.php

示例7: formAction

 protected function formAction()
 {
     $form = new UrlForm();
     if (App::request()->isPost()) {
         $form->setValue('url', App::request()->getPostVar('url'));
         if ($form->isValid()) {
             // if URL is valid
             // find or generate short URL
             $existsUrlRecord = UrlModel::findOneByLongurl($form->getValue('url'));
             if (false !== $existsUrlRecord) {
                 // alredy exists - use it
                 $shortURI = App::alphaid()->toAlpha($existsUrlRecord->id);
             } else {
                 // not exists - create new
                 $urlRecord = new UrlModel();
                 $urlRecord->longurl = $form->getValue('url');
                 $urlRecord->save();
                 $shortURI = App::alphaid()->toAlpha($urlRecord->id);
             }
             $shortURL = App::router()->createUrl('Redirector', 'redirect', array('url' => $shortURI));
             $form->setValue('shortUrl', $shortURL);
         }
     }
     if (App::request()->isAjaxRequest()) {
         $this->setLayout('ajax');
         $this->view->form = $form->getData();
     } else {
         $this->view->form = $form;
         $this->render();
     }
 }
开发者ID:stefangruncharov,项目名称:url-shortening-service,代码行数:31,代码来源:FormController.php

示例8: start

 public static function start()
 {
     $router = new Router();
     self::$db = self::loadDb();
     self::$auth = self::loadAuth();
     self::$access = self::loadAccess();
     self::$router = $router::init();
 }
开发者ID:Tidynar,项目名称:University,代码行数:8,代码来源:App.php

示例9: links

 private function links($file)
 {
     $url = \App::request()->getBaseUrl();
     $skin = \App::user()->get()->config()->skin;
     $type = strtolower(pathinfo($file, PATHINFO_EXTENSION));
     $moduleDir = \App::router()->dir;
     $themeLink = $url . '/themes/';
     $skinLink = $themeLink . $skin . '/';
     $skinPath = THEMES_PATH . $skin . DS;
     return [[$skinPath . 'modules' . DS . $moduleDir . DS . $type . DS . $file, $skinLink . 'modules/' . $moduleDir . '/' . $type . '/' . $file], [ASSETS_PATH . 'modules' . DS . $moduleDir . DS . $type . DS . $file, $url . '/assets/modules/' . $moduleDir . '/' . $type . '/' . $file], [$skinPath . $type . DS . $file, $skinLink . $type . '/' . $file], [ASSETS_PATH . 'template' . DS . $type . DS . $file, $url . '/assets/template/' . $type . '/' . $file]];
 }
开发者ID:professor93,项目名称:mobicms,代码行数:11,代码来源:PathTrait.php

示例10: run

 public static function run($uri)
 {
     self::$router = new Router($uri);
     $controller_class = ucfirst(self::$router->getController()) . 'Controller';
     $controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction());
     // Calling controller's method
     $controller_object = new $controller_class();
     if (method_exists($controller_object, $controller_method)) {
         $result = $controller_object->{$controller_method}();
     } else {
         throw new Exception('Method ' . $controller_method . ' of class ' . $controller_class . ' does not exist.');
     }
 }
开发者ID:YoGurtxo,项目名称:homeworks,代码行数:13,代码来源:app.class.php

示例11: run

 public static function run($uri)
 {
     self::$router = new Router($uri);
     $controller_class = ucfirst(self::$router->getController()) . 'Controller';
     $controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction());
     $controller_object = new $controller_class();
     if (method_exists($controller_object, $controller_method)) {
         $view_path = $controller_object->{$controller_method}();
         $view_object = new View($controller_object->getData(), $view_path);
         $content = $view_object->render();
     } else {
         throw new Exception("Method " . $controller_method . " of class " . $controller_class . " does not exist.");
     }
     $layout = self::$router->getRoute();
     $layout_path = VIEWS_PATH . DS . $layout . ".phtml";
     $layout_view_object = new View(compact('content'), $layout_path);
     echo $layout_view_object->render();
 }
开发者ID:uppermanis,项目名称:steve-j-mvc,代码行数:18,代码来源:app.class.php

示例12: __construct

 /**
  * Constructor
  *
  * @param array $filters The filters
  */
 public function __construct($filters)
 {
     $options = array();
     // active languages
     $languages = array();
     $allLanguages = Language::getAll('tag');
     foreach ($allLanguages as $tag => $language) {
         $options[$tag] = $language->label;
         if ($language->active) {
             $languages[$tag] = $language;
         }
     }
     if (!in_array($filters['tag'], array_keys($allLanguages))) {
         $filters['tag'] = Lang::DEFAULT_LANGUAGE;
     }
     $param = array('id' => 'language-filter-form', 'method' => 'get', 'action' => App::router()->getUri('language-keys-list'), 'fieldsets' => array('filters' => array('nofieldset' => true, new SelectInput(array('name' => 'tag', 'options' => $options, 'default' => $filters['tag'], 'style' => 'width: 80%; margin-right: 5px;', 'label' => Lang::get('language.filter-language-label'), 'after' => Icon::make(array('icon' => 'pencil', 'class' => 'text-primary edit-lang', 'title' => Lang::get('language.filter-language-edit'))) . (count($allLanguages) > 1 && Option::get('main.language') != $filters['tag'] && $filters['tag'] != Lang::DEFAULT_LANGUAGE ? Icon::make(array('icon' => 'close', 'class' => 'text-danger delete-lang', 'title' => Lang::get('language.filter-language-delete'))) : ''))), new RadioInput(array('name' => 'keys', 'options' => array('missing' => Lang::get('language.filter-keys-missing'), 'all' => Lang::get('language.filter-keys-all')), 'default' => isset($filters['keys']) ? $filters['keys'] : 'all', 'label' => Lang::get('language.filter-keys-label'), 'labelWidth' => '100%', 'layout' => 'vertical')))));
     $this->form = new Form($param);
 }
开发者ID:elvyrra,项目名称:hawk,代码行数:23,代码来源:LanguageFilterWidget.php

示例13: run

 public static function run($uri)
 {
     self::$router = new Router($uri);
     Lang::load(self::$router->getLanguage());
     $controller_class = ucfirst(self::$router->getController()) . 'Controller';
     $controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction());
     //calling controller's method
     $controller_object = new $controller_class();
     if (method_exists($controller_object, $controller_method)) {
         $view_path = $controller_object->{$controller_method}();
         $view_object = new View($controller_object->getData(), $view_path);
         $content = $view_object->render();
     } else {
         throw new Exception('Method ' . $controller_method . ' of class ' . $controller_class . ' does not exist.');
     }
     $layout = self::$router->getRoute();
     $layout_paht = VIEWS_PATH . DS . $layout . '.html';
     $layout_view_object = new View(compact('content'), $layout_paht);
     echo $layout_view_object->render();
 }
开发者ID:Eemilow,项目名称:framework_php,代码行数:20,代码来源:app.class.php

示例14: run

 public static function run($uri)
 {
     self::$router = new Router($uri);
     Lang::load(self::$router->getLanguage());
     self::$db = DB::getInstance();
     //        if (self::$router->getRoute() == 'admin' && is_null(Session::get('user'))) {
     //            self::$router->redirect('/admin/');
     //        }
     if (self::$router->getController() == "favicon.ico") {
         die;
     }
     //        $test = self::$router->getController();
     //        echo $test."<br>";
     //        $test = self::renameToSafeCall($test);
     //        echo $test."<br>";
     $controller_class = ucfirst(self::$router->getController()) . 'Controller';
     $controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction());
     if (self::$router->getRoute() == 'admin' && is_null(Session::get('user'))) {
         if (strtolower(self::$router->getAction()) != 'login') {
             Router::redirect('/admin/users/login');
         }
     }
     $controller_object = new $controller_class();
     if (method_exists($controller_object, $controller_method)) {
         $view_path = $controller_object->{$controller_method}();
         $view_object = new View($controller_object->getData(), $view_path);
         $content = $view_object->render();
     } else {
         throw new MethodException('Cannot run method ' . $controller_method . ' on class ' . $controller_class);
     }
     $layout = self::$router->getRoute();
     $layout_path = VIEWS_PATH . DS . $layout . '.php';
     $array_content = array();
     $array_content['content'] = $content;
     // exception from rules for account_count
     if (isset($controller_object->getData()['account_count'])) {
         $array_content['account_count'] = $controller_object->getData()['account_count'];
     }
     $layout_view_object = new View($array_content, $layout_path);
     echo $layout_view_object->render();
 }
开发者ID:qconer,项目名称:php_kamgaz,代码行数:41,代码来源:app.class.php

示例15: run

 public static function run($uri)
 {
     self::$router = new Router($uri);
     self::$db = new DB(Config::get('db.host'), Config::get('db.user'), Config::get('db.password'), Config::get('db.db_name'));
     $class_name = ucfirst(self::$router->getController()) . 'Controller';
     $controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction());
     $controller_object = new $class_name();
     if (method_exists($controller_object, $controller_method)) {
         $view_path = $controller_object->{$controller_method}();
         $view_object = new View($controller_object->getData(), $view_path);
         //content in obb
         $content = $view_object->render();
     } else {
         echo $controller_method . 'in ' . $class_name . 'does not exist';
     }
     $layout = self::$router->getRoute();
     $layout_path = VIEW . DS . $layout . '.html';
     $layout_view_object = new View(compact('content'), $layout_path);
     // content in obb
     echo $layout_view_object->render();
 }
开发者ID:RokoDeveloper,项目名称:summary_site,代码行数:21,代码来源:app.class.php


注:本文中的App::router方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。