本文整理汇总了PHP中Uri::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Uri::get方法的具体用法?PHP Uri::get怎么用?PHP Uri::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Uri
的用法示例。
在下文中一共展示了Uri::get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: find
public static function find($type, $path = false, $keys = null)
{
self::current();
if (!array_key_exists($type, self::$files)) {
return false;
}
// If no keys are specfied, use the page URI
if (empty($keys)) {
$keys = array_keys(Uri::get());
} elseif (is_string($keys)) {
$keys = explode('_', $keys);
}
// Add the first section, if its not listed
if (!array_key_exists($type, $keys)) {
array_unshift($keys, $type);
}
$total = count($keys);
for ($i = 0; $i < $total; $i++) {
$name = implode($keys, '_');
$file = self::exists($type, $name);
// if ($file) return $file;
if ($file) {
if ($path) {
return $file;
} else {
return self::capitalize($name);
}
}
// Remove the last section on each pass
array_pop($keys);
}
}
示例2: start
public function start()
{
$uri = Uri::get();
if (isset($uri['module'])) {
$this->_module = $uri['module'];
}
if (isset($uri['page'])) {
$this->_page = $uri['page'];
}
if (isset($uri['act'])) {
$this->_act = $uri['act'];
}
$this->_params = $uri['params'];
if (!file_exists(BASE_DIR . '/module/' . $this->_module . '.php')) {
$this->_module = 'home';
$this->_page = '404';
}
$this->reqFile();
}
示例3: __construct
public function __construct($archive = null, $option = array())
{
$this->config =& Config::current();
if (isset($option['per_page'])) {
$this->page = (int) $option['per_page'];
} else {
$this->per_page = (int) $this->config->per_page;
}
if (isset($option['page'])) {
$this->page = (int) $option['page'];
} elseif (Uri::get('page')) {
$this->page = (int) Uri::get('page');
}
if (is_object($archive)) {
$this->_posts =& $archive;
} else {
$this->posts($archive);
}
if (empty($this->_posts)) {
return false;
}
// Everything worked!
$this->success = true;
}
示例4: activationComplete
public function activationComplete()
{
// ------------------------------------------------------------------------------
// CONFIG/USER.PHP AYARLARI
// Config/User.php dosyasında belirtilmiş ayarlar alınıyor.
// ------------------------------------------------------------------------------
$userConfig = $this->config;
$tableName = $userConfig['tableName'];
$usernameColumn = $userConfig['usernameColumn'];
$passwordColumn = $userConfig['passwordColumn'];
$activationColumn = $userConfig['activationColumn'];
// ------------------------------------------------------------------------------
// Aktivasyon dönüş linkinde yer alan segmentler -------------------------------
$user = Uri::get('user');
$pass = Uri::get('pass');
// ------------------------------------------------------------------------------
if (!empty($user) && !empty($pass)) {
$db = uselib('DB');
$row = $db->where($usernameColumn . ' =', $user, 'and')->where($passwordColumn . ' =', $pass)->get($tableName)->row();
if (!empty($row)) {
$db->where($usernameColumn . ' =', $user)->update($tableName, array($activationColumn => '1'));
$this->success = lang('User', 'activationComplete');
return true;
} else {
$this->error = lang('User', 'activationCompleteError');
return Error::set($this->error);
}
} else {
$this->error = lang('User', 'activationCompleteError');
return Error::set($this->error);
}
}
示例5: __construct
/**
* Creates the new Request object by getting a new URI object, then parsing
* the uri with the Route class.
*
* Usage:
*
* $request = new Request('foo/bar');
*
* @param string the uri string
* @param bool whether or not to route the URI
* @param string request method
* @return void
*/
public function __construct($uri, $route = true, $method = null)
{
$this->uri = new \Uri($uri);
$this->method = $method;
logger(\Fuel::L_INFO, 'Creating a new Request with URI = "' . $this->uri->get() . '"', __METHOD__);
// check if a module was requested
if (count($this->uri->get_segments()) and $module_path = \Module::exists($this->uri->get_segment(1))) {
// check if the module has routes
if (is_file($module_path .= 'config/routes.php')) {
$module = $this->uri->get_segment(1);
// load and add the module routes
$module_routes = \Fuel::load($module_path);
$prepped_routes = array();
foreach ($module_routes as $name => $_route) {
if ($name === '_root_') {
$name = $module;
} elseif (strpos($name, $module . '/') !== 0 and $name != $module and $name !== '_404_') {
$name = $module . '/' . $name;
}
$prepped_routes[$name] = $_route;
}
// update the loaded list of routes
\Router::add($prepped_routes, null, true);
}
}
$this->route = \Router::process($this, $route);
if (!$this->route) {
return;
}
$this->module = $this->route->module;
$this->controller = $this->route->controller;
$this->action = $this->route->action;
$this->method_params = $this->route->method_params;
$this->named_params = $this->route->named_params;
if ($this->route->module !== null) {
$this->add_path(\Module::exists($this->module));
}
}
示例6: error_reporting
error_reporting(0);
}
// Production
define('APPPATH', realpath(dirname(__FILE__)) . '/');
define('CACHEPATH', realpath(dirname(__FILE__) . '/../cache') . '/');
define('CONTENTPATH', realpath(dirname(__FILE__) . '/../content') . '/');
// Load Helper & Config
require_once APPPATH . 'classes/class_helper.php';
require_once APPPATH . 'classes/class_error.php';
require_once APPPATH . 'classes/class_config.php';
// By setting the include path, templates can simply call include('header.php');
// and it will include the template header file.
set_include_path(CONTENTPATH . 'templates/' . Config::current()->template . '/' . PATH_SEPARATOR . APPPATH);
// Initialize Autoloader
require_once 'classes/class_loader.php';
spl_autoload_register(array('Loader', 'autoload'));
// Search directories:
Loader::scan();
// Load default page, if no page is specified
if (count(Uri::get()) < 1) {
Uri::set(strtolower(Config::current()->default));
}
// Set the default time zone
date_default_timezone_set(Config::current()->timezone);
DB::init(Config::current()->db_type);
// Find and initialize the controller
$controller = Loader::find('controller');
$controller = new $controller();
// Display Page
echo $controller->indexAction(Uri::get());
示例7: execute
/**
* This executes the request and sets the output to be used later.
*
* Usage:
*
* $request = Request::forge('hello/world')->execute();
*
* @param array|null $method_params An array of parameters to pass to the method being executed
* @return Request This request object
*/
public function execute($method_params = null)
{
// fire any request started events
\Event::instance()->has_events('request_started') and \Event::instance()->trigger('request_started', '', 'none');
if (\Fuel::$profiling) {
\Profiler::mark(__METHOD__ . ': Start of ' . $this->uri->get());
}
logger(\Fuel::L_INFO, 'Called', __METHOD__);
// Make the current request active
static::$active = $this;
// First request called is also the main request
if (!static::$main) {
logger(\Fuel::L_INFO, 'Setting main Request', __METHOD__);
static::$main = $this;
}
if (!$this->route) {
static::reset_request();
throw new \HttpNotFoundException();
}
// save the current language so we can restore it after the call
$current_language = \Config::get('language', 'en');
try {
if ($this->route->callable !== null) {
$response = call_fuel_func_array($this->route->callable, array($this));
if (!$response instanceof Response) {
$response = new \Response($response);
}
} else {
$method_prefix = $this->method . '_';
$class = $this->controller;
// Allow override of method params from execute
if (is_array($method_params)) {
$this->method_params = array_merge($this->method_params, $method_params);
}
// If the class doesn't exist then 404
if (!class_exists($class)) {
throw new \HttpNotFoundException();
}
// Load the controller using reflection
$class = new \ReflectionClass($class);
if ($class->isAbstract()) {
throw new \HttpNotFoundException();
}
// Create a new instance of the controller
$this->controller_instance = $class->newInstance($this);
$this->action = $this->action ?: ($class->hasProperty('default_action') ? $class->getProperty('default_action')->getValue($this->controller_instance) : 'index');
$method = $method_prefix . $this->action;
// Allow to do in controller routing if method router(action, params) exists
if ($class->hasMethod('router')) {
$method = 'router';
$this->method_params = array($this->action, $this->method_params);
}
if (!$class->hasMethod($method)) {
// If they call user, go to $this->post_user();
$method = strtolower(\Input::method()) . '_' . $this->action;
// Fall back to action_ if no HTTP request method based method exists
if (!$class->hasMethod($method)) {
$method = 'action_' . $this->action;
}
}
if ($class->hasMethod($method)) {
$action = $class->getMethod($method);
if (!$action->isPublic()) {
throw new \HttpNotFoundException();
}
if (count($this->method_params) < $action->getNumberOfRequiredParameters()) {
throw new \HttpNotFoundException();
}
// fire any controller started events
\Event::instance()->has_events('controller_started') and \Event::instance()->trigger('controller_started', '', 'none');
$class->hasMethod('before') and $class->getMethod('before')->invoke($this->controller_instance);
$response = $action->invokeArgs($this->controller_instance, $this->method_params);
$class->hasMethod('after') and $response = $class->getMethod('after')->invoke($this->controller_instance, $response);
// fire any controller finished events
\Event::instance()->has_events('controller_finished') and \Event::instance()->trigger('controller_finished', '', 'none');
} else {
throw new \HttpNotFoundException();
}
}
// restore the language setting
\Config::set('language', $current_language);
} catch (\Exception $e) {
static::reset_request();
// restore the language setting
\Config::set('language', $current_language);
throw $e;
}
// Get the controller's output
if ($response instanceof Response) {
$this->response = $response;
//.........这里部分代码省略.........