本文整理汇总了PHP中Routes类的典型用法代码示例。如果您正苦于以下问题:PHP Routes类的具体用法?PHP Routes怎么用?PHP Routes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Routes类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: request_login
/**
* request_login
*
* @author Adrián Méndez <[email protected]>
* @Version 1.0
*/
public function request_login()
{
// Retifica el estatus de Login.
if (!$this->Session->is_logged()) {
// Si la acción actual no está permitida en $allowedUnloggedActions, redirecciona
// a $loginAction
if (!Routes::request_in_list($this->request, self::$allowedUnloggedActions)) {
$this->go_to(self::$loginAction);
}
}
}
开发者ID:Bincat,项目名称:MVC,代码行数:17,代码来源:AppController.php
示例17: init
public static function init()
{
// Carrega as variaveis de confiruracao para toda a aplicacao
Configs::load();
// Define o modulo
self::$moduleName = Routes::get('module');
// Define o controller
self::setController();
// Define o metodo
self::setMethod();
}
开发者ID:elitonluiz1989,项目名称:modelo,代码行数:11,代码来源:Bootstrap.php
示例18: getRoute
public static function getRoute()
{
self::$url = empty($_GET['url']) ? '/' : $_GET['url'];
Routing::setRoutes();
if (empty(self::$controller))
trigger_error('Page Not Found');
elseif (!method_exists(self::$controller, self::$method))
trigger_error('Invalid Page Index');
Security::check(self::$controller, self::$method);
return array(self::$controller, self::$method);
}
开发者ID:nickbarth,项目名称:PHP-Tofu,代码行数:12,代码来源:routes.php
示例19: render
public static function render($path, array $args = array())
{
if (self::$_instance === NULL) {
self::init();
}
$args['request'] = Request::getInstance();
$args['static_url'] = Rivet::getInstance()->config['static_url'];
$template = self::$_instance->twig->loadTemplate($path);
$template->routes = Routes::getInstance();
self::$_instance->body = $template->render($args);
return self::$_instance->body;
}
开发者ID:plasticine,项目名称:rivet,代码行数:12,代码来源:Template.php
示例20: run
function run()
{
$config = parse_ini_file('../.config');
$this->setUpDb();
$showErrors = isset($config['showErrors']) ? $config['showErrors'] : false;
$configuration = ['settings' => ['displayErrorDetails' => $showErrors]];
$c = new \Slim\Container($configuration);
// create new Slim instance
$app = new \Slim\App($c);
// create new Slim instance
//$app = new \Slim\App();
$app->db = $this->database;
$this->flashDB(false);
$app->auth = false;
$app->user = '';
$app->register = $config['registerActive'];
$app->add(function ($request, $response, $next) use(&$app) {
if (isset($_SESSION['userID'])) {
$app->auth = true;
$app->user = $_SESSION['username'];
}
$response = $next($request, $response);
return $response;
});
$container = $app->getContainer();
$container['view'] = function ($c) {
// templates location and a settings array
$view = new \Slim\Views\Twig('../templates', ['cache' => '../cache', 'auto_reload' => true, 'debug' => true]);
// Instantiate and add Slim specific extension
$view->addExtension(new Slim\Views\TwigExtension($c['router'], $c['request']->getUri()));
return $view;
};
$route = new Routes($app);
$app = $route->run($app);
$this->app = $app;
// Run app
$this->app->run();
}
开发者ID:rath3r,项目名称:rath3rapi,代码行数:38,代码来源:bootstrap.php
注:本文中的Routes类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论