Example #1
0
Theme::drawWidgets('top');
?>

                </div><!-- banners -->

                <div class="language-select">
                    <select name="language" id="language">

                        <?php 
foreach (Lang\Lang::instance()->getLangs() as $lang) {
    ?>
                            <option lang="<?php 
    echo $lang['iso'];
    ?>
" value="<?php 
    echo Lang\Lang::instance()->isPrimary($lang['iso']) ? Router::getCurrentRoute()->getWhiteUri() : '/' . $lang['iso'] . Router::getCurrentRoute()->getWhiteUri();
    ?>
" <?php 
    echo $lang['iso'] == Lang\Lang::instance()->getCurrentLang()['iso'] ? 'selected' : '';
    ?>
><?php 
    echo $lang['name'];
    ?>
</option>
                        <?php 
}
?>

                    </select>
                </div>
Example #2
0
 /**
  * Returns parameter of current route
  *
  * 		// adding route
  *		Router::add('blog', '/blog/(<post_id:\d+>/)');
  *		
  *		// getting post_id
  *		$post_id = App::routeParam('post_id');
  *
  *
  * @param $name name of the parameter
  * @return parameter value or NULL if this parameter is not defined
  * @static
  */
 public static function routeParam($name)
 {
     if ($route = Router::getCurrentRoute()) {
         return $route->getParam($name);
     }
     return null;
 }
Example #3
0
 /**
  * TODO Comments.
  */
 private static function _getHtml($sorted, $data)
 {
     // Determine count of actual items about to be displayed, this is used to determine
     // the "first" and "last" classes to be added to the current item, but also if we should just return
     $totalCount = 0;
     foreach ($sorted as $route => $routeData) {
         if ($routeData['hidden'] !== true && !is_null($routeData['title'])) {
             $totalCount++;
         }
     }
     // If no items, just return
     if ($totalCount == 0) {
         return null;
     }
     $html = '<ul';
     if (isset($data['attributes'])) {
         foreach ($data['attributes'] as $k => $v) {
             $html .= sprintf(' %s="%s"', $k, $v);
         }
     }
     $html .= '>';
     // The current route is used to determine if the menu item is active or not
     $currentRoute = Router::getCurrentRoute();
     $currentCount = 1;
     foreach ($sorted as $route => $routeData) {
         if ($routeData['hidden'] === true || is_null($routeData['title'])) {
             continue;
         }
         $classes = array();
         if (String::startsWith($currentRoute['route'], $route)) {
             $classes[] = 'active';
         }
         if ($currentCount == 1) {
             $classes[] = 'first';
         }
         if ($currentCount == $totalCount) {
             $classes[] = 'last';
         }
         $html .= '<li';
         if ($classes) {
             $html .= ' class="' . implode(' ', $classes) . '"';
         }
         $html .= '>';
         $html .= '<a';
         if ($classes) {
             $html .= ' class="' . implode(' ', $classes) . '"';
         }
         $html .= ' href="' . Url::to($route) . '">';
         //$html .= '<a href="' . Url::to($route) . '">';
         if (is_callable($routeData['title'])) {
             $html .= call_user_func($routeData['title']);
         } else {
             $html .= $routeData['title'];
         }
         $html .= '</a>';
         if ($routeData['children']) {
             $html .= self::_getHtml($routeData['children'], $data);
         }
         $html .= '</li>';
         $currentCount++;
     }
     $html .= '</ul>';
     return $html;
 }
Example #4
0
 /**
  * Текуший Слуг для УРЛ
  * @return string
  */
 public function getCurrentSlug()
 {
     return $this->_current = Router::getCurrentRoute()->getActionVariable('page') ?: 'home';
 }
 /**
  * @brief is 判断当前访问位置
  *
  * @param $key 路由名
  * @param $params 参数
  *
  * @return bool
  */
 public function is($key, $params = array())
 {
     if (count($params)) {
         $p = Router::getCurrentParams();
         foreach ($params as $k => $v) {
             if (!isset($p[$k]) || $v != $p[$k]) {
                 return FALSE;
             }
         }
     }
     if ($key == Router::getCurrentRoute()) {
         return TRUE;
     } else {
         return FALSE;
     }
 }