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


PHP Routes类代码示例

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


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

示例1: load_routes

 private function load_routes($file)
 {
     $routes = new Routes();
     include_once SITE_PATH . "config/{$file}.php";
     $routes->dump_to_file("{$file}");
     $this->routing_tree =& $routes->routing_tree;
 }
开发者ID:profes0rul,项目名称:framework,代码行数:7,代码来源:routing.php

示例2: testLoadRoutesNoAnything

 public function testLoadRoutesNoAnything()
 {
     $_SERVER["QUERY_STRING"] = "";
     $routes = new Routes();
     $routes->analizeAndProcessRoutes();
     $this->assertEquals("Application", $routes->controller);
     $this->assertEquals("Index", $routes->action);
 }
开发者ID:giraldomauricio,项目名称:phpXelerator5,代码行数:8,代码来源:routesTest.php

示例3: testNestedRoutes

 function testNestedRoutes()
 {
     $routes = new Routes();
     $nested = $routes->resources("teams");
     $nested->resources("ceva");
     $routes->dump_to_file("nested");
     include_once SITE_PATH . "config/nested.tmp.php";
     $this->assertEqual($routes->routing_tree, $root);
     unlink(SITE_PATH . "config/nested.tmp.php");
 }
开发者ID:hurrycane,项目名称:framework,代码行数:10,代码来源:routing_tests.php

示例4: Run

 public static function Run()
 {
     Logger::debug("Creating server object", "Server", "Run");
     $router = new Routes();
     $router->analizeAndProcessRoutes();
     if ($router->controller && $router->action) {
         Logger::debug("Server controller: [" . $router->controller . "] action: [" . $router->action . "]", "Server", "Run");
         $controller = $router->controller;
         $app = new $controller();
         $app->params = $router->params;
         $app->controller = $router->controller;
         $app->action = $router->action;
         print $app->loadApp();
     }
 }
开发者ID:giraldomauricio,项目名称:phpXelerator5,代码行数:15,代码来源:Server.php

示例5: render

		public function render()
		{
			// Get Template and Page
			if (!file_exists(BASEPATH.'/app/views/'.Routes::getController().'/'.Routes::getMethod().'.php'))
				trigger_error('View file "'.Routes::getController().'/'.Routes::getMethod().'.php" was not found.');
      Template::render($this->vars, true);
		}
开发者ID:nickbarth,项目名称:PHP-Tofu,代码行数:7,代码来源:controller.php

示例6: render

    public static function render($vars, $displayContents = true)
    {
			// Get Templating Vars
			extract($vars, EXTR_SKIP);

      // Include Helper Functions
      require(BASEPATH.'/app/helpers/template.php');

			// Render View File
			ob_start();
			include(BASEPATH.'/app/views/'.Routes::getController().'/'.Routes::getMethod().'.php');
			$contents = ob_get_contents();
			ob_end_clean();

			// Render Layout File
			ob_start();
			include(BASEPATH.'/app/views/layouts/'.Routes::getController().'.php');
			$view = ob_get_contents();
			ob_end_clean();

      foreach($templates as $key => $value)
        $view = str_ireplace($key, $value, $view);
  
      // Render View
      if ($displayContents)
        print $view;
      return $view;
		}
开发者ID:nickbarth,项目名称:PHP-Tofu,代码行数:28,代码来源:template_core.php

示例7: profile_edit

 /**
  * Edit personnal information
  */
 public function profile_edit($params)
 {
     $this->setView('profile_edit.php');
     $this->setTitle(__('USER_EDIT_TITLE'));
     $is_logged = isset(User_Model::$auth_data);
     $is_student = $is_logged && isset(User_Model::$auth_data['student_number']);
     // Authorization
     if (!$is_student) {
         throw new ActionException('Page', 'error404');
     }
     $user = User_Model::$auth_data;
     // Birthday
     $user['birthday'] = date(__('USER_EDIT_FORM_BIRTHDAY_FORMAT'), strtotime($user['birthday']));
     // Saving data
     if (isset($_POST['mail']) && isset($_POST['msn']) && isset($_POST['jabber']) && isset($_POST['address']) && isset($_POST['zipcode']) && isset($_POST['city']) && isset($_POST['cellphone']) && isset($_POST['phone']) && isset($_POST['birthday'])) {
         try {
             // Other info
             $data = array('mail' => $_POST['mail'], 'msn' => $_POST['msn'], 'jabber' => $_POST['jabber'], 'address' => $_POST['address'], 'zipcode' => $_POST['zipcode'], 'city' => $_POST['city'], 'cellphone' => $_POST['cellphone'], 'phone' => $_POST['phone'], 'birthday' => $_POST['birthday']);
             $this->model->save((int) User_Model::$auth_data['id'], $data);
             Routes::redirect('student', array('username' => User_Model::$auth_data['username']));
         } catch (FormException $e) {
             foreach ($data as $key => $value) {
                 $user[$key] = $value;
             }
             $this->set('form_error', $e->getError());
         }
     }
     $this->set('user', $user);
     $this->addJSCode('User.initEdit();');
 }
开发者ID:hugonicolas,项目名称:Site,代码行数:33,代码来源:User.php

示例8: __construct

 function __construct($action = 'index', $recordId = null)
 {
     if (!$this->checkIsUser()) {
         Routes::redirect();
     }
     switch ($action) {
         case 'index':
             $this->setAddressBookModel();
             self::$data['action'] = $action;
             break;
         case 'add':
             self::$data['action'] = $action;
             if ($_SERVER['REQUEST_METHOD'] == 'POST') {
                 $this->addContact();
             }
             break;
         case 'delete':
             self::$data['action'] = $action;
             $this->deleteContact($recordId);
             $this->setAddressBookModel();
             break;
         case 'edit':
             self::$data['action'] = $action;
             if ($_SERVER['REQUEST_METHOD'] == 'POST') {
                 $this->addContact($_POST['id_contact']);
             }
             $this->setAddressBookModel((int) $recordId);
             break;
     }
     new Sidebar($this->sideMenuItems());
 }
开发者ID:masteruser20,项目名称:Blog,代码行数:31,代码来源:AddressBook.php

示例9: __construct

 function __construct()
 {
     if (!$this->checkIsUser()) {
         Routes::redirect();
     }
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $params = array();
         $params['secret'] = '6Lf3ZxMTAAAAANVc5p92ISpeXZp8oTTrOr5WS6iD';
         // Secret key
         if (!empty($_POST) && isset($_POST['g-recaptcha-response'])) {
             $params['response'] = urlencode($_POST['g-recaptcha-response']);
         }
         $params['remoteip'] = $_SERVER['REMOTE_ADDR'];
         $params_string = http_build_query($params);
         $requestURL = 'https://www.google.com/recaptcha/api/siteverify?' . $params_string;
         $curl = curl_init();
         curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $requestURL));
         $response = curl_exec($curl);
         curl_close($curl);
         $response = @json_decode($response, true);
         if ($response["success"] != true && !$this->checkIsUser()) {
             echo '<h3 class="alert alert-danger">Captcha - bład w weryfikacji</h3>';
         } elseif ($response["success"] || self::$isLogged) {
             if ($this->addPost($_POST)) {
                 header('Location: ' . parent::config()['url']);
             }
         }
     } else {
         $this->setPostModel();
     }
 }
开发者ID:masteruser20,项目名称:Blog,代码行数:31,代码来源:AddPost.php

示例10: StartApp

		public static function StartApp()
		{
			ob_start('ob_gzhandler');
			session_start();
			
			// Defines
			define('BASEURL', substr((empty($_SERVER['HTTPS']) ? 'http://' : 'https://' ) . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'],0,-10));
			define('BASEPATH', substr($_SERVER['SCRIPT_FILENAME'],0,-10));
			
			// Helper Boot Loader
			require(BASEPATH.'/core/bootloader.php');
			
			// Initialize Helpers
			BootLoader::loadHelpers();
			Registry::getInstance();
			
			// Handle Errors
			Registry::setDebugMode(true);
			set_error_handler('Template::handleError');
			set_exception_handler('Template::handleException');
	
			// Initialize Database
			Model::$db = DBO::getInstance('sqlite:example.sqldb');
			
			// Init Autoloads
			spl_autoload_register('Autoload::controllers');
			spl_autoload_register('Autoload::models');
			
			// Determine Controllers and Methods
			Routes::getRoute();
			
			// Run Application
			Routes::run();
		}
开发者ID:nickbarth,项目名称:PHP-Tofu,代码行数:34,代码来源:index.php

示例11: goPage

 public function goPage($page)
 {
     /* テンプレートファイルを取得 */
     $theme = Configure::read('theme');
     $template_path = THEME_DIR . $theme . '/';
     if (!file_exists($template_path . 'Template.php')) {
         $template_path = LIB_DIR;
     }
     $template_class = 'Template';
     if ($template_path == LIB_DIR) {
         $template_class = 'TemplateBase';
     }
     require_once $template_path . $template_class . '.php';
     /* ページを取得し、遷移する */
     $page_routing = Routes::get();
     $template = new $template_class($page_routing[$page]['php']);
     if (isset($page_routing[$page]['js'])) {
         if (is_array($page_routing[$page]['js'])) {
             $template->script_src += $page_routing[$page]['js'];
         } else {
             $template->script_src[] = $page_routing[$page]['js'];
         }
     }
     if (isset($page_routing[$page]['css'])) {
         if (is_array($page_routing[$page]['css'])) {
             $template->style_src += $page_routing[$page]['css'];
         } else {
             $template->style_src[] = $page_routing[$page]['css'];
         }
     }
     $template->render();
 }
开发者ID:nguyennhuanh,项目名称:tjm-mvc,代码行数:32,代码来源:Application.php

示例12: setRoutes

		public static function setRoutes()
		{
			// URL Routes 
			Routes::add('/', 'apples', 'index');
			Routes::add('/view/(:tofuID)/', 'apples', 'view');
			Routes::add('/create/', 'apples', 'create');
			Routes::add('/update/(:tofuID)/', 'apples', 'update');
			Routes::add('/remove/(:tofuID)/', 'apples', 'remove');
		}
开发者ID:nickbarth,项目名称:PHP-Tofu,代码行数:9,代码来源:routing.php

示例13: initiateController

 public function initiateController()
 {
     if ($_SERVER['SCRIPT_FILENAME'] == './scripts/db.php') {
         return false;
     }
     $route = new Routes($this->uriSegment('whole'));
     $controller_class = $route->getController() . '_controller';
     $action = $route->getAction();
     if (class_exists($controller_class) && !empty($action)) {
         $controller = new $controller_class();
         $controller->setParams($route->getParams($controller));
         $controller->setRequest($route->getRequest());
         $controller->{$action}();
     } else {
         echo 'contorller: ' . $controller_class . ' action: ' . $action . '<br/>';
         die("404 - dont know what you're looking for");
     }
 }
开发者ID:qzio,项目名称:tinly,代码行数:18,代码来源:core.php

示例14: SearchFormView

function SearchFormView($arr_search_field, $arr_order_field, $arr_order_select, $url_options)
{
    $form_search = '<form method="get" action="' . Routes::add_get_parameters($url_options, array()) . '">';
    $form_search .= Utils::set_csrf_key();
    $form_search .= I18n::lang('common', 'order_by', 'Order by') . ': ' . SelectForm('order_field', '', $arr_order_field) . ' ' . I18n::lang('common', 'in_order', 'By order') . ': ' . SelectForm('order_desc', '', $arr_order_select);
    $arr_order_field[0] = $_GET['search_field'];
    $form_search .= '<p>' . I18n::lang('common', 'search', 'Search') . ': ' . TextForm('search_word', '', $_GET['search_word']) . ' ' . I18n::lang('common', 'search_by', 'Search by') . ': ' . SelectForm('search_field', '', $arr_search_field) . '</p><p><input type="submit" value="' . I18n::lang('common', 'send', 'Send') . '"/> <input type="button" value="' . I18n::lang('common', 'reset', 'Reset') . '" onclick="javascript:location.href=\'' . $url_options . '\'"/>';
    $form_search .= '</form></p>';
    echo View::load_view(array(I18n::lang('common', 'order_and_search', 'Order and search'), $form_search), 'content');
}
开发者ID:phangoapp,项目名称:admin,代码行数:10,代码来源:searchform.php

示例15: itShouldDrawRoutes

 /**
  *
  * @test
  */
 public function itShouldDrawRoutes()
 {
     Routes::draw(function ($map) {
         $map->addRoute("test", ":controller/:action/:id");
         $map->blog("blog/:action/:id");
     });
     $routes = Routes::getAllRoutes();
     $this->expectsThat(count($routes))->shouldBe(2);
     var_dump($routes['blog'][0]);
     $this->expectsThat($routes['blog'][0])->shouldBe("blog/:action/:id");
 }
开发者ID:amptools-net,项目名称:midori-php,代码行数:15,代码来源:RoutesSpec.php


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