Example #1
0
/**
 * Генерирует вывод пэйджинга
 * @param <string> $url
 * @return <string>
 */
function getPagingAsHTML($url)
{
    $_pagesArray = _generatePaging();
    if ($url[mb_strlen($url) - 1] != "/") {
        $url .= "/";
    }
    $pagesHTML = '';
    if (count($_pagesArray) > 0) {
        foreach ($_pagesArray as $v) {
            if ($v['Page'] == 1) {
                $v['URL'] = $url;
            } else {
                $v['URL'] = $url . "page" . $v['Page'];
            }
            if (isset($v['First']) && $v['First'] == 1) {
                if (isset($v['Selected']) && $v['Selected'] == 1) {
                    $pagesHTML .= '<span class="paging-prev">' . $v['Title'] . '</span>';
                } else {
                    $pagesHTML .= '<a href="' . $v['URL'] . '" class="paging-prev">' . $v['Title'];
                    if (!Router::isAdmin()) {
                        //$pagesHTML .= __('Назад');
                        $pagesHTML .= __('<');
                    }
                    $pagesHTML .= '</a>';
                }
            } else {
                if (isset($v['Last']) && $v['Last'] == 1) {
                    if (isset($v['Selected']) && $v['Selected'] == 1) {
                        $pagesHTML .= '<span class="paging-next">' . $v['Title'] . '</span>';
                    } else {
                        $pagesHTML .= '<a href="' . $v['URL'] . '" class="paging-next">' . $v['Title'];
                        if (!Router::isAdmin()) {
                            //						$pagesHTML .= __('Вперед');
                            $pagesHTML .= __('>');
                        }
                        $pagesHTML .= '</a>';
                    }
                } else {
                    if (isset($v['Selected']) && $v['Selected'] == 1) {
                        $pagesHTML .= '<span class="selected">' . $v['Title'] . '</span>';
                    } else {
                        $pagesHTML .= '<a href="' . $v['URL'] . '">' . $v['Title'] . '</a>';
                    }
                }
            }
        }
    }
    return $pagesHTML;
}
Example #2
0
 /**
  * Возвращает сгенерированный URI
  * @return array
  */
 public static function getPath()
 {
     if (self::$aPath === false) {
         self::$aPath = explode("/", substr($_SERVER['REQUEST_URI'], defined('URL_PREFIX') ? strlen(URL_PREFIX) : 1));
         if (self::$aPath[0] == 'admin') {
             self::$isAdmin = true;
             array_shift(self::$aPath);
         }
         if (count(self::$aPath)) {
             $lastChunk = explode("?", self::$aPath[count(self::$aPath) - 1]);
             self::$aPath[count(self::$aPath) - 1] = $lastChunk[0];
             for ($i = 0, $pathCount = count(self::$aPath); $i < $pathCount; $i++) {
                 preg_match("/^page([0-9]+)\$/", self::$aPath[$i], $matches);
                 if (count($matches) > 0 && (int) $matches[1] > 0) {
                     MySQL::setPage((int) $matches[1]);
                     unset(self::$aPath[$i]);
                     break;
                 }
             }
         }
         if (count(self::$aPath) && self::$aPath[count(self::$aPath) - 1] == '') {
             array_pop(self::$aPath);
         }
     }
     //var_dump(self::$aPath); exit;
     return self::$aPath;
 }
Example #3
0
" class="profile-btn" title="<?php 
echo $_SESSION['auth']->prénom . " " . $_SESSION['auth']->nom;
?>
">
    <?php 
echo substr(ucfirst($_SESSION['auth']->prénom), 0, 1);
?>
  </a>
  <?php 
require_once 'model/Group.php';
$group = new Group();
?>
  <nav>
    <ul class="nav-menu">
      <?php 
if (Router::isAdmin()) {
    ?>
        <li><a href="<?php 
    page('backoffice-user');
    ?>
">Admin</a></li>
      <?php 
}
?>
      <li><a href="<?php 
page('liste-groupe');
?>
"><?php 
lang('Groupes');
?>
        <?php 
Example #4
0
 /**
  * Производит анализ и выполнение действий, переданных в URI
  */
 public function run()
 {
     if (Router::isAdmin() && !Auth::getInstance()->hasAccess(1)) {
         throw new Exception(lang('access_denied', __CLASS__));
     }
     MySQL::setOnPage(Config::get('OnPage'));
     $this->route = Router::getPath();
     if (count($this->route) == 0) {
         $this->index = true;
     }
     $this->folder = Router::isAdmin() ? '/admin/' : '/public/';
     if (!Router::isAdmin() && Router::getDefaultModule() == 'Page') {
         Page_Handler::findPage($this);
     }
     foreach ($this->route as $key => $path) {
         $path = ucfirst(mb_strtolower($path));
         if (is_dir(CORE_ROOT . 'controller' . $this->folder . $this->pathToController . $path) && $path != '') {
             $this->pathToController .= $path . '/';
         }
         if (is_file(CORE_ROOT . 'controller' . $this->folder . $this->pathToController . $path . '.php')) {
             $this->controller = $path;
             $this->pathToView .= $path . '/';
             unset($this->route[$key]);
         }
         if (is_file(CORE_ROOT . 'view' . $this->folder . $this->pathToView . '_footer.phtml') && is_file(CORE_ROOT . 'view' . $this->folder . $this->pathToView . '_header.phtml')) {
             $this->pathToTemplate = $this->pathToView;
         }
         if (is_file(CORE_ROOT . 'view' . $this->folder . $this->pathToView . mb_strtolower($path) . '.phtml')) {
             $this->action = mb_strtolower($path);
             unset($this->route[$key]);
         }
     }
     if ($this->controller == '') {
         $this->controller = Router::isAdmin() ? 'Page' : Router::getDefaultModule();
         $this->pathToView = $this->controller . '/';
     }
     if ($this->action == '') {
         if ($this->controller == 'Page' && !$this->index && !Router::isAdmin() && Page_Handler::getPageID() == 0) {
             $this->action = 'page404';
         } else {
             $this->action = 'index';
         }
     }
     $this->route = array_values($this->route);
     if (!is_file(CORE_ROOT . 'controller' . $this->folder . $this->pathToController . $this->controller . '.php')) {
         throw new Exception(lang('error_controller_not_found', __CLASS__));
     }
     include CORE_ROOT . 'class/Controller/AbstractController.php';
     if (Router::isAdmin()) {
         include CORE_ROOT . 'class/Controller/AdminController.php';
     } else {
         include CORE_ROOT . 'class/Controller/PublicController.php';
     }
     include CORE_ROOT . 'controller' . $this->folder . $this->pathToController . $this->controller . '.php';
     $this->controller .= 'Controller';
     $oController = new $this->controller($this);
     $oController->{$this->action}();
     if (!is_file(CORE_ROOT . 'view' . $this->folder . $this->pathToView . $this->action . '.phtml')) {
         throw new Exception(lang('error_view_not_found', __CLASS__) . ':<br />' . 'view' . $this->folder . $this->pathToView . $this->action . '.phtml');
     }
     $oTemplate = new Template($this);
     $oTemplate->load($oController);
     $oTemplate->show();
 }
Example #5
0
 public function routerRequete()
 {
     try {
         switch ($this->page) {
             // Accueil
             case 'accueil':
                 if (Router::isLoggedIn()) {
                     $this->ctr['Accueil']->accueil_logged();
                 } else {
                     $this->ctr['Accueil']->accueil();
                 }
                 break;
             case 'recherche':
                 $this->ctr['Accueil']->recherche();
                 break;
             case 'search-ajax':
                 $this->ctr['Accueil']->ajaxSearch();
                 break;
             case 'langue':
                 $this->ctr['Accueil']->langue();
                 break;
             case 'aide':
                 $this->ctr['Accueil']->aide();
                 break;
                 // Forum
             // Forum
             case 'forum':
                 $this->ctr['Forum']->forum();
                 break;
             case 'forumDiscussion':
                 $this->ctr['Forum']->forumDiscussion($this->params['id']);
                 break;
             case 'forumNewDiscussion':
                 if (Router::isLoggedIn()) {
                     $this->ctr['Forum']->forumNewDiscussion($this->params['id']);
                 } else {
                     $this->redirect();
                 }
                 break;
             case 'topic':
                 $this->ctr['Forum']->Topic($this->params['id']);
                 break;
                 // Groupe
             // Groupe
             case 'liste-groupe':
                 if (Router::isLoggedIn()) {
                     $this->ctr['Group']->liste();
                 } else {
                     $this->redirect();
                 }
                 break;
             case 'creation-groupe':
                 if (Router::isLoggedIn()) {
                     $this->ctr['Group']->creation();
                 } else {
                     $this->redirect();
                 }
                 break;
             case 'groupe':
                 if (Router::isLoggedIn()) {
                     $this->ctr['Group']->modificationEnTete($this->params['id']);
                     $this->ctr['Group']->informations($this->params['id']);
                 } else {
                     $this->redirect();
                 }
                 break;
             case 'discussion-groupe':
                 if (Router::isLoggedIn()) {
                     $this->ctr['Group']->discussion($this->params['id']);
                 } else {
                     $this->redirect();
                 }
                 break;
             case 'groupe-message':
                 if (Router::isLoggedIn()) {
                     $this->ctr['Group']->message($this->params);
                 } else {
                     $this->redirect();
                 }
                 break;
             case 'membres-groupe':
                 if (Router::isLoggedIn()) {
                     $this->ctr['Group']->membres($this->params['id']);
                 } else {
                     $this->redirect();
                 }
                 break;
             case 'planning-groupe':
                 if (Router::isLoggedIn()) {
                     $this->ctr['Group']->planning($this->params['id']);
                 } else {
                     $this->redirect();
                 }
                 break;
             case 'reglage-groupe':
                 if (Router::isLoggedIn()) {
                     $this->ctr['Group']->reglage($this->params['id']);
                 } else {
                     Router::redirect();
                 }
                 break;
                 // Sport
             // Sport
             case 'SportClub':
                 $this->ctr['Sport']->SportClub($this->params['id']);
                 break;
             case 'SportGroupe':
                 $this->ctr['Sport']->SportGroupe($this->params['id']);
                 break;
             case 'typeSport':
                 $this->ctr['Sport']->TypeSport($this->params['id']);
                 break;
                 // Club
             // Club
             case 'club':
                 $this->ctr['Sport']->club($this->params['id']);
                 break;
                 // Profile
             // Profile
             case 'profile':
                 if (Router::isLoggedIn()) {
                     $this->ctr['User']->profile();
                 } else {
                     Router::redirect();
                 }
                 break;
             case 'profile-planning':
                 if (Router::isLoggedIn()) {
                     $this->ctr['User']->profilePlanning();
                 } else {
                     Router::redirect();
                 }
                 break;
             case 'profile-reglage':
                 if (Router::isLoggedIn()) {
                     $this->ctr['User']->profileReglage();
                 } else {
                     Router::redirect();
                 }
                 break;
                 // Inscription
             // Inscription
             case 'inscription':
                 $this->ctr['User']->inscription();
                 break;
             case 'inscription-verif':
                 $this->ctr['User']->verifinscription($this->params['token']);
                 break;
                 // Login
             // Login
             case 'login':
                 $this->ctr['User']->login();
                 break;
             case 'forgot':
                 $this->ctr['User']->forgot();
                 break;
             case 'forgot-verif':
                 $this->ctr['User']->resetPwd($this->params['token']);
                 break;
             case 'logout':
                 $this->ctr['User']->logout();
                 break;
             case 'backoffice-user':
                 if (Router::isAdmin()) {
                     $this->ctr['Backoffice']->user();
                 } else {
                     Router::redirect();
                 }
                 break;
             case 'backoffice-group':
                 if (Router::isAdmin()) {
                     $this->ctr['Backoffice']->group();
                 } else {
                     Router::redirect();
                 }
                 break;
             case 'backoffice-sport':
                 if (Router::isAdmin()) {
                     $this->ctr['Backoffice']->sport();
                 } else {
                     Router::redirect();
                 }
                 break;
             case 'backoffice-forum':
                 if (Router::isAdmin()) {
                     $this->ctr['Backoffice']->forum();
                 } else {
                     Router::redirect();
                 }
                 break;
             case 'backoffice-help':
                 if (Router::isAdmin()) {
                     $this->ctr['Backoffice']->help();
                 } else {
                     Router::redirect();
                 }
                 break;
             default:
                 throw new Exception("Page non valide");
                 break;
         }
     } catch (PDOException $e) {
         Router::erreur($e->getMessage());
     } catch (Exception $e) {
         Router::erreur($e->getMessage());
     }
 }