本文整理汇总了PHP中Router::uri方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::uri方法的具体用法?PHP Router::uri怎么用?PHP Router::uri使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Router
的用法示例。
在下文中一共展示了Router::uri方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authenticate
protected function authenticate($username, $password)
{
if (!($config = $this->needsAuthentification(Router::uri()))) {
return true;
}
if (empty($username) || empty($password)) {
return false;
}
// from file .htpasswd
if (is_string($config['logins'])) {
$filename = $config['logins'];
if (!file_exists($filename)) {
die($filename . ' not found');
}
foreach (file($filename) as $line) {
list($user, $pass) = explode(':', $line);
if ($user == $username && $pass == crypt($password, substr($password, 0, 2))) {
return true;
}
}
// from plain config
} else {
foreach ($config['logins'] as $u => $p) {
if ($username == $u && $p == $password) {
return true;
}
}
}
return false;
}
示例2: parseUri
public static function parseUri()
{
self::$default_uri = self::$uri = self::_getUri();
$router = Config::get('*', 'router');
if (is_array($router) && !empty($router)) {
if (isset($router['default']['controller']) && ($controller = $router['default']['controller'])) {
self::setController($controller);
}
if (isset($router['default']['action']) && ($action = $router['default']['action'])) {
self::setAction($action);
}
unset($router['default']);
foreach ($router as $method => $arr) {
if ($method == strtolower($_SERVER['REQUEST_METHOD']) || $method === 'any') {
foreach ($arr as $key => $val) {
$key = str_replace(array('.', '/'), array('\\.', '\\/'), $key);
if (preg_match('#^' . $key . '$#', self::$uri)) {
if (strpos($val, '$') !== FALSE and strpos($key, '(') !== FALSE) {
self::$uri = preg_replace('#^' . $key . '$#', $val, self::$uri);
self::$uri = preg_replace('#//+#', '/', self::$uri);
self::$uri = preg_replace('#\\.[\\s./]*/#', '', self::$uri);
self::$uri = trim(self::$uri, '/');
} else {
self::$uri = trim($val, '/');
}
break;
}
}
}
continue;
}
}
self::_setRouter(self::$uri);
}
示例3: beforeRender
public function beforeRender()
{
$this->attributes->action = Router::uri('blogSearch', array('q' => ''));
if (!empty($this->controller->params['q'])) {
$this->q->value($this->controller->params['q']);
}
return parent::beforeRender();
}
示例4: load_controller
private function load_controller()
{
// Uri format: app/controller/method thus making uri[1] the controller
// If no controller is set through the uri array then set it to default
if (Router::uri(1) === null) {
Router::uri(1, Config::$config[$this->data['app']['name']]['default_controller']);
}
require DOC_ROOT . 'apps/' . $this->app_name . '/controllers/controller.' . Router::uri(1) . '.php';
$controller_name = String::uc_slug(Router::uri(1), '_') . '_Controller';
$controller_obj = new $controller_name($this->data);
}
示例5: __construct
public function __construct($data)
{
$this->data = $data;
$method = Router::uri(2);
$dm = $this->default_method;
// If no method is set go to default
if (is_null($method)) {
$this->{$dm}();
} else {
$this->{$method}();
}
}
示例6: url_to_array
private static function url_to_array($uri)
{
self::$uri = urldecode(trim($uri, '/'));
$uri_parts = explode('?', self::$uri);
$first_part = $uri_parts[0];
$uri_array = explode('/', $first_part);
$uri_elements = array();
// Удаляет все специальные символы и кирилицу из элементов массива (заменяет на "_"), чтоб срабатывало исключение
foreach ($uri_array as $val) {
$uri_element = preg_replace("/[^a-zA-Z0-9]/", "_", $val);
$uri_elements[] = $uri_element;
}
self::$url_array = $uri_elements;
//Debugger::PrintR($uri_elements);
return $uri_elements;
}
示例7: check
public function check($testRoute)
{
foreach ($this->Permissions as $Permission) {
$regexp = '@' . $Permission->rule . '@i';
Log::write(Log::VERBOSE, sprintf('%s: checking "%s" against "%s"', get_class($this), $testRoute, $regexp));
if (preg_match($regexp, $testRoute)) {
return true;
}
}
if ($this->controller instanceof AdminController) {
$this->controller->redirect(Router::uri('admin'));
} else {
$this->controller->redirect(Router::uri('root'));
}
return false;
}
示例8: uri_to_array
public static function uri_to_array($uri = NULL)
{
// Not defaulting to server request uri allows some testing to be done
if (is_null($uri)) {
$uri = $_SERVER['REQUEST_URI'];
}
// Lowercase the entire string then strip http, https and ftp (just for fun) our of uri and then explode by "/"
self::$uri = explode('/', trim(preg_replace('/([.*^?])\\??(.*)/', '$1', trim(str_replace(array('http://', 'https://', 'ftp://'), '', strtolower($uri), $count), '/')), '?/'));
// We want to rebuild the array without the actual domain
if ($count > 0) {
array_shift(self::$uri);
}
$new_uri = array();
foreach (self::$uri as $key => $singleton) {
// Strip the string of all special characters
$new_uri[] = String::clean($singleton, '_');
}
// Replace uri with the new modified version
self::$uri = $new_uri;
return self::$uri;
}
示例9: __
<div class="toolbar">
<?php
echo $HTML->link(Router::uri('root'), __('Frontend'), array('class' => 'back flip'));
echo $HTML->tag('h1', $pageTitle);
echo $HTML->link(Router::uri('adminLogout'), __('Logout'), array('class' => 'button flip'));
?>
</div>
<ul class="rounded">
<li class="arrow"><?php
echo $HTML->link(Router::uri('adminWall'), __('Aktuelles/Wall'));
?>
</li>
</ul>
<ul class="rounded">
<li class="arrow">
<?php
echo $HTML->link(Router::url('adminNode'), __('Seiten'));
?>
<?php
if (!empty($NodeTotalCount)) {
echo $HTML->tag('small', $NodeTotalCount, array('class' => 'counter'));
}
?>
</li>
<li class="arrow">
<?php
echo $HTML->link(Router::url('adminBlogPost'), __('Blogeinträge'));
?>
<?php
if (!empty($BlogPostTotalCount)) {
echo $HTML->tag('small', $BlogPostTotalCount, array('class' => 'counter'));
示例10: __
<h1><?php
echo __('Fehler 404 - Seite nicht gefunden');
?>
</h1>
<p>
Die aufgerufene Seite ist leider nicht mehr auffindbar. Bitte überprüfe die URL
und probier es noch mal wenn du willst.
</p>
<p>
Die beste Möglichkeit schnell weiter zu lesen ist allerdings auf die
<?php
echo $HTML->link(Router::uri('root'), 'Startseite');
?>
zurück zu
gehen.
</p>
<p>
Viel Spass weiterhin!
</p>
示例11: edit
public function edit($id = null)
{
$this->MediaFile = parent::edit($id);
$this->data->set('pageTitle', $this->MediaFile->getText('title', $this->MediaFile->filename));
// language and texts
foreach ($this->Languages as $Language) {
$TextModel = $this->MediaFile->{'Text' . String::ucFirst($Language->id)};
$TextModel->MediaFile = $this->MediaFile;
$TextModel->User = $this->UserLogin->User;
$Form = new AdminMediaTextForm();
$Form->attributes->set('name', 'AdminMediaTextForm' . ucfirst($Language->id));
$Form->attributes->set('id', 'AdminMediaTextForm' . ucfirst($Language->id));
$Form->init($this);
$Form->startup();
$Form->configure();
$Form->fromModel($TextModel);
$Form->attributes->set('action', Router::uri());
$Form->language_id->value($Language->id);
$this->data->set('AdminMediaTextForm' . String::ucFirst($Language->id), $Form);
if ($Form->ok() && $this->request->data['language_id'] == $Language->id) {
$Form->toModel($TextModel);
if (!$TextModel->save()) {
$Form->errors = $TextModel->validationErrors;
} else {
$Form->success = __('Erfolgreich :1 gespeichert', $Language->get('name'), FlashMessageType::SUCCESS);
$this->redirect(Router::url());
}
}
}
// newly uploaded files
$this->AdminMediaFileForm->file->mandatory(false);
if ($this->AdminMediaFileForm->ok()) {
$this->AdminMediaFileForm->toModel($this->MediaFile);
if ($newFile = $this->AdminMediaFileForm->file->value()) {
$this->MediaFile->replace($newFile, $this->AdminMediaFileForm->file->originalFilename());
}
if (!$this->MediaFile->save()) {
$this->AdminMediaFileForm->errors = $this->MediaFile->validationErrors;
} else {
$this->FlashMessage->set(__('Erfolgreich gespeichert'), FlashMessageType::SUCCESS);
}
}
}
示例12: __
<h1><?php
echo __('Gruppen');
?>
</h1>
<ul class="breadcrumb">
<li><?php
echo $HTML->link(Router::getRoute('admin'), __('Home'));
?>
</li>
<li><?php
echo $HTML->link(Router::uri('adminScaffold', array('controller' => $controller)), __('Gruppen & Rechte'));
?>
</li>
<li><?php
echo __('Gruppe erstellen');
?>
</li>
</ul>
<?php
echo $AdminUserGroupForm;
示例13: search
public function search($q = null, $fields = array())
{
if (isset($this->request->data['q'])) {
$this->redirect(Router::uri('blogSearch', array('q' => $this->request->data['q'])));
}
parent::search($q, array('text', 'headline', 'tags'));
$this->action = 'index';
$this->data->set('q', $q);
return true;
}
示例14: init
static function init()
{
$uri = str_replace(Conf::$BASE_URL, '', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
self::$params = $_GET || [];
self::$uri = strtok($uri, '?');
}
示例15: die
<?php
require 'core/master.inc.php';
// Remap URI with routes if needed
Router::new_uri(Config::$config['core']['routes']);
// If no app is set through the uri array then set it to default
if (is_null(Router::uri(0))) {
Router::uri(0, Config::$config['core']['default_app']);
}
// If app doesn't exist then show error
if (!in_array(Router::uri(0), Config::$config['core']['installed_apps'])) {
die('<h1>Opps</h1> <p>The app <strong>"' . Router::uri(0) . '"</strong> does not exist.</p>');
}
$init = new App_Init(Router::uri(0));
// initiate init class