Пример #1
0
 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
0
 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
0
      <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
0
                <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
0
<?php

define('ROOT', dirname(__FILE__) . '/');
define('IDEAL', dirname(__FILE__) . '/ideal/');
define('APP', dirname(__FILE__) . '/application/');
include IDEAL . 'framework.php';
app::gi()->start();