本文整理匯總了PHP中app::gi方法的典型用法代碼示例。如果您正苦於以下問題:PHP app::gi方法的具體用法?PHP app::gi怎麽用?PHP app::gi使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app
的用法示例。
在下文中一共展示了app::gi方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: parse
function parse($path)
{
$request = $_REQUEST;
$request['controller'] = app::gi()->config->default_controller;
$request['action'] = app::gi()->config->default_action;
$request['id'] = 0;
$parts = parse_url($path);
if (isset($parts['query']) and !empty($parts['query'])) {
$path = str_replace('?' . $parts['query'], '', $path);
parse_str($parts['query'], $req);
$request = array_merge($request, $req);
}
foreach (app::gi()->config->router as $rule => $keypath) {
if (preg_match('#' . $rule . '#sui', $path, $list)) {
for ($i = 1; $i < count($list); $i = $i + 1) {
$keypath = preg_replace('#\\$[a-z0-9]+#', $list[$i], $keypath, 1);
}
$keypath = explode('/', $keypath);
foreach ($keypath as $i => $key) {
$request[$this->path_elements[$i]] = $key;
}
}
}
return $request;
}
示例2: start
function start()
{
$this->uri = new Registry(Router::gi()->parse($_SERVER['REQUEST_URI']));
$controller = app::gi($this->uri->controller . 'Controller');
ob_start();
$controller->__call('action' . $this->uri->action, array($this->uri->id));
$content = ob_get_clean();
if ($this->config->scripts and is_array($this->config->scripts)) {
foreach ($this->config->scripts as $script) {
$controller->addScript($script);
}
}
if ($this->config->styles and is_array($this->config->styles)) {
foreach ($this->config->styles as $style) {
$controller->addStyleSheet($style);
}
}
$controller->renderPage($content);
}
示例3: dirname
<div class="container">
<nav class="blog-nav">
<a class="blog-nav-item <?php
echo app::gi()->uri->controller == 'index' ? 'active' : '';
?>
" href="/">Главная</a>
<a class="blog-nav-item <?php
echo app::gi()->uri->controller == 'user' ? 'active' : '';
?>
" href="/user/">Войти</a>
<a class="blog-nav-item <?php
echo app::gi()->uri->controller == 'page' ? 'active' : '';
?>
" href="/about.html">О фреймворке</a>
<a class="blog-nav-item <?php
echo app::gi()->uri->controller == 'post' ? 'active' : '';
?>
" href="/post">Материалы</a>
</nav>
</div>
</div>
<div class="container">
<?php
include dirname(__FILE__) . '/layouts/' . $this->layout . '.php';
?>
</div><!-- /.container -->
<footer class="blog-footer">
<p><a href="#">Наверх</a></p>
</footer>
<?php
示例4: dirname
<a class="blog-nav-item <?php
echo app::gi()->uri->controller == 'feedback' ? 'active' : '';
?>
" href="/questions/">Вопросы</a>
<a class="blog-nav-item <?php
echo app::gi()->uri->controller == 'user' ? 'active' : '';
?>
" href="/user/"><?php
echo $_SESSION['login'];
?>
</a>
<?php
} else {
?>
<a class="blog-nav-item <?php
echo app::gi()->uri->controller == 'user' ? 'active' : '';
?>
" href="/user/login/">Вход</a>
<?php
}
?>
</nav>
</div>
</div>
<div class="container">
<?php
include dirname(__FILE__) . '/layouts/' . $this->layout . '.php';
?>
</div><!-- /.container -->
<footer class="blog-footer">
示例5: define
<?php
define('ROOT', dirname(__FILE__) . '/');
define('IDEAL', dirname(__FILE__) . '/ideal/');
define('APP', dirname(__FILE__) . '/application/');
include IDEAL . 'framework.php';
app::gi()->start();