• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP router类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: resolve_controller_callback

 /**
  * Given an action, find the controller and method responsible for
  * handling the action.
  *
  * In addition, send some extra variables to the controller
  * and initialize it.
  *
  * @param string $action
  * @return array
  */
 public function resolve_controller_callback($action)
 {
     /** @var $controller controller_abstract */
     list($controller, $method) = $this->router->route_action($action);
     $controller->init($action);
     return array($controller, $method);
 }
开发者ID:pramithkm,项目名称:moodle-theme_snap,代码行数:17,代码来源:kernel.php


示例2: init

 public function init()
 {
     $this->setRequestParams();
     $rout = new router($this->contData);
     $contName = $rout->getController();
     $this->cont = new $contName();
     $this->cont->init($this->contData);
 }
开发者ID:just4jc,项目名称:scraperpy,代码行数:8,代码来源:index.php


示例3: __construct

 public function __construct(router $router, user $user, array $data)
 {
     $this->router = $router;
     $this->route = $router->getRoute();
     $this->user = $user;
     $this->parameters = $router->getParameters();
     $this->data = $data;
     $this->db = new db(HOST, USER, PASSWORD, DATABASE, ENCODING);
 }
开发者ID:stanhelen87,项目名称:OOOO,代码行数:9,代码来源:shoes_model.php


示例4: __construct

 public function __construct()
 {
     parent::__construct();
     if (!users_helper::isLoggedin() || !session::permission('site_access_cp', 'system')) {
         router::redirect('cp/users/login');
     }
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:7,代码来源:home.php


示例5: getJson

 public function getJson($addWhere = '', $addSql = '', $showMax = 12)
 {
     $sort = input::getInput("mix.sort") ? input::getInput("mix.sort") : 'id';
     $order = input::getInput("mix.order") ? input::getInput("mix.order") : "asc";
     $page = input::getInput("mix.page") ? input::getInput("mix.page") : 1;
     $rows = input::getInput("mix.rows") ? input::getInput("mix.rows") : 10;
     $db = sf::getLib("db");
     if ($select) {
         $sql = $select . " ";
     } else {
         $sql = "SELECT * FROM `" . $this->table . "` ";
     }
     $addWhere && ($sql .= "WHERE " . $addWhere . " ");
     if ($addSql) {
         $sql .= $addSql . " ";
     } else {
         $sql .= " ORDER BY {$sort} {$order} ";
     }
     if (!router::get("totalnum" . $key)) {
         $query = $db->query($sql);
         $total = $db->num_rows($query);
     } else {
         $total = router::get("totalnum" . $key);
     }
     $sql .= "LIMIT " . $rows * ($page - 1) . "," . $rows;
     $query = $db->query($sql);
     while ($row = $db->fetch_array($query)) {
         $result[] = $this->fillObject($row)->toArray();
     }
     return '{"total":' . $total . ',"rows":' . json_encode($result) . '}';
 }
开发者ID:meetcd,项目名称:sofast,代码行数:31,代码来源:Model.php


示例6: __construct

 public function __construct()
 {
     parent::__construct();
     if (!config::item('news_blog', 'news') && uri::segment(1) != 'news') {
         router::redirect('news/' . utf8::substr(uri::getURI(), 5));
     }
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:7,代码来源:blog.php


示例7: dispatch

 public static function dispatch()
 {
     $uri = visitor::uri();
     $target = router::parse_pps_uri($uri);
     if (config::get_module('view.default_skeleton', false) !== false) {
         if (config::get_module('view.cache_pps_in_server', false)) {
             $use_cache = false;
             if (defined('kern\\data_dir')) {
                 $version_key = config::get_kern('version_key', router::default_version_key);
                 $cache_dir = data_dir . '/cache/' . $serve_mode . '/' . $target->get_param($version_key, '0');
                 $cache_file = $cache_dir . '/' . sha1($uri) . '.cache';
                 if (is_readable($cache_file)) {
                     $use_cache = true;
                 }
             }
             if ($use_cache) {
                 $content = file_get_contents($cache_file);
             } else {
                 $content = pps_rendor::render_for($target);
                 if (!is_dir($cache_dir)) {
                     @mkdir($cache_dir, 0777, true);
                 }
                 @file_put_contents($cache_file, $content);
             }
         } else {
             $content = pps_rendor::render_for($target);
         }
     } else {
         $content = '';
     }
     visitor::set_content($content);
 }
开发者ID:xpd1437,项目名称:swap,代码行数:32,代码来源:pps.php


示例8: signUP

 public function signUP($username, $pass, $passControl)
 {
     if ($pass !== $passControl) {
         return 'The passwords do not match.';
     }
     if (!ctype_alnum(str_replace(array('-', '_'), '', $username))) {
         return 'This username contains forbidden characters. Please stick to alphanumerics, hyphens, and underscores.';
     }
     if (strlen(trim($username)) < 4 || strlen(trim($username)) > 32) {
         return 'Your username is either too short or too long. It has to consist of 4-32 characters.';
     }
     if (strlen(trim($pass)) < 4 || strlen(trim($pass)) > 32) {
         return 'This is not a valid password (too short or too long).';
     }
     $userRows = database::fetchRows('users', 'id', 'name', $username);
     if ($userRows->num_rows != 1) {
         $user['name'] = trim($username);
         $user['password'] = trim($pass);
         database::addRow('users', $user);
         $_SESSION['user'] = $username;
         $_SESSION['loggedIn'] = true;
         router::redirect('u/' . $username);
     } else {
         return 'This username has already been taken.';
     }
 }
开发者ID:kaniis,项目名称:htdocs,代码行数:26,代码来源:user.php


示例9: confirm

 public function confirm($action = '')
 {
     // Do we have necessary data?
     if (input::get('oauth_token') && input::get('oauth_verifier')) {
         // Get temporary access token
         $this->initialize(session::item('twitter', 'remote_connect', 'token'), session::item('twitter', 'remote_connect', 'secret'));
         $access = $this->twitter->getAccessToken(input::get('oauth_verifier'));
         // Do we have temporary token?
         if ($access) {
             // Get saved token
             $token = $this->getToken(0, $access['user_id']);
             // Do we have saved token or are we logging in?
             if ($token || $action == 'login' && $token) {
                 $this->users_model->login($token['user_id']);
                 router::redirect(session::item('slug') . '#home');
             } elseif (!$token || $action == 'signup') {
                 // Get user data
                 $this->initialize($access['oauth_token'], $access['oauth_token_secret']);
                 $user = $this->getUser($access['user_id']);
                 // Do we have user data?
                 if ($user && isset($user->id)) {
                     $connection = array('name' => 'twitter', 'twitter_id' => $user->id, 'token' => $access['oauth_token'], 'secret' => $access['oauth_token_secret']);
                     session::set(array('connection' => $connection), '', 'remote_connect');
                     $account = array('username' => isset($user->name) ? $user->name : '');
                     session::set(array('account' => $account), '', 'signup');
                     router::redirect('users/signup#account');
                 }
             }
         }
     }
     router::redirect('users/login');
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:32,代码来源:twitter.php


示例10: _sendFeedback

 protected function _sendFeedback()
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Extra rules
     $rules = array('name' => array('rules' => array('required', 'is_string', 'trim', 'min_length' => 2, 'max_length' => 255)), 'email' => array('rules' => array('required', 'is_string', 'trim', 'valid_email', 'min_length' => 4, 'max_length' => 255)), 'subject' => array('rules' => array('required', 'is_string', 'trim', 'min_length' => 5, 'max_length' => 255)), 'message' => array('rules' => array('required', 'is_string', 'trim', 'min_length' => 10, 'max_length' => 10000)));
     if (config::item('feedback_captcha', 'feedback') == 1 || config::item('feedback_captcha', 'feedback') == 2 && !users_helper::isLoggedin()) {
         $rules['captcha'] = array('rules' => array('is_captcha'));
     }
     validate::setRules($rules);
     // Validate form values
     if (!validate::run($rules)) {
         return false;
     }
     // Get values
     $email = input::post('email');
     $subject = input::post('subject');
     $message = input::post('message') . "\n\n--\n" . input::post('name') . ' <' . input::post('email') . '>' . "\n" . input::ipaddress();
     // Send feedback
     if (!$this->feedback_model->sendFeedback($email, $subject, $message)) {
         if (!validate::getTotalErrors()) {
             view::setError(__('send_error', 'system'));
         }
         return false;
     }
     // Success
     view::setInfo(__('message_sent', 'feedback'));
     router::redirect('feedback');
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:31,代码来源:feedback.php


示例11: processInput

 public function processInput()
 {
     if (isset($_GET['push'])) {
         $this->model->pushSettings();
         router::redirectMessage('index.php?view=device', 'Push Successful');
     }
 }
开发者ID:MichaelCStevens,项目名称:Android-web-portal-JSON-API,代码行数:7,代码来源:device.controller.php


示例12: __construct

 public function __construct()
 {
     parent::__construct();
     // Is this control panel?
     if (strtolower(uri::segment(1)) == 'cp' && !$this->isLoggedin() && (uri::segment(2) != 'users' || uri::segment(3) != 'login')) {
         router::redirect('cp/users/login');
     }
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:8,代码来源:users.php


示例13: getInstance

 /**
  * 创建唯一router实例
  * @access public
  * @static
  * @return Object routerObject
  * @example $router = router::getInstance()
  */
 public static function getInstance()
 {
     if (!self::$_instance instanceof router) {
         self::$_instance = new self();
         log::accessLog("Create router instance success");
     }
     log::returnLog(self::$_instance);
     return self::$_instance;
 }
开发者ID:sajawa,项目名称:lib,代码行数:16,代码来源:router.php


示例14: run

 public static function run()
 {
     spl_autoload_register(__CLASS__ . "::" . 'autoload');
     if (app_config::$use_db == true) {
         db::set_db_config(app_config::$db);
     }
     url::init(app_config::$url);
     router::route(app_config::$router, app_config::$re_route);
 }
开发者ID:rajuthapa8086,项目名称:SimpleMVC,代码行数:9,代码来源:main.php


示例15: __construct

 public function __construct()
 {
     /**
      * Get the database and set the config
      */
     $db = new database();
     $db->setup($a = array('hostname' => 'localhost', 'username' => 'govhack', 'password' => 'govhack', 'database' => 'govhack_ip'))->connect();
     /**
      * Load the page controllers
      */
     $search = new search($db);
     $index = new index();
     $about = new about();
     /**
      * Get the application router
      */
     $router = new router();
     $router->add('/', $index)->add('/index', $index)->add('/about', $about)->add('/search', $search)->add('/*', $search);
     $router->route();
 }
开发者ID:JWeiry,项目名称:govhack2015,代码行数:20,代码来源:app.php


示例16: confirm

 public function confirm()
 {
     $class = uri::segment(4);
     $action = uri::segment(5) == 'signup' ? 'signup' : 'login';
     $service = $this->users_authentication_model->getService($class);
     if ($service) {
         loader::library('authentication/' . uri::segment(4), $service['settings'], 'users_authentication_' . $class . '_model');
         $this->{'users_authentication_' . $class . '_model'}->confirm($action);
     }
     router::redirect('users/login');
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:11,代码来源:connect.php


示例17: __construct

 public function __construct()
 {
     parent::__construct();
     // Is user loggedin ?
     if (!users_helper::isLoggedin()) {
         router::redirect('users/login');
     } elseif (!config::item('visitors_active', 'users')) {
         error::show404();
     }
     loader::model('users/visitors', array(), 'users_visitors_model');
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:11,代码来源:visitors.php


示例18: getColumnStr

function getColumnStr($subject = '', $orderfield = '')
{
    $result = router::get();
    $result['ordermode'] = $result['ordermode'] == 'DESC' ? 'ASC' : 'DESC';
    $result['orderfield'] = $orderfield;
    $str = array_shift($result);
    $str .= '/' . array_shift($result);
    foreach ($result as $key => $val) {
        $str .= '/' . $key . '/' . $val;
    }
    return link_to($str, $subject, array('class' => $result['ordermode']));
}
开发者ID:GitBeBest,项目名称:sf-framwork,代码行数:12,代码来源:Url.helper.php


示例19: __construct

 public function __construct()
 {
     parent::__construct(true);
     // Is user loggedin ?
     if (!users_helper::isLoggedin()) {
         router::redirect('users/login');
     } elseif (!config::item('invoices_active', 'billing')) {
         router::redirect('users/settings');
     }
     loader::model('billing/gateways');
     loader::model('billing/transactions');
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:12,代码来源:invoices.php


示例20: startController

 private function startController()
 {
     $router = new router();
     $controller = "controllers\\" . $router->getController();
     $this->controller = $controller;
     $this->controllerstring = "controllers_" . $router->getController();
     $obj = new $controller();
     $method = $router->getAction();
     $this->action = $method;
     try {
         $obj->{$method}();
         $this->view = $obj;
         if (!empty($obj->view)) {
             $this->viewfile = $obj->view;
         } else {
             $this->viewfile = $method;
         }
     } catch (\Exception $e) {
         $this->render = '<p class="errorMessage">' . $e->getMessage() . '</p>';
     }
 }
开发者ID:KremlinCardinal,项目名称:phpmvc,代码行数:21,代码来源:mvc.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP rrd类代码示例发布时间:2022-05-23
下一篇:
PHP route类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap