本文整理汇总了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();