Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.64 KB | None | 0 0
  1. <?php
  2. /**
  3. * Makra projektu
  4. */
  5. class Macros extends LatteMacros implements IRoute
  6. {  
  7.     /**
  8.     * Vraci url adresu stranky podle id
  9.     * {clink 2} <- vraci odkaz na stranku se section_id 2 a lang
  10.     *
  11.     * @param mixed $sectionId
  12.     * @param mixed $langId
  13.     */
  14.     public static function clink($request)
  15.     {
  16.         list($id, $lang) = explode(':',$request);
  17.         return Environment::getApplication()->getPresenter()->clink($id, $lang);        
  18.     }
  19.    
  20. }
  21.  
  22. abstract class BasePresenter extends Presenter implements IRoute
  23. {
  24.     protected $model = NULL;
  25.     protected $routes;
  26.  
  27.     function startup()
  28.     {
  29.         if ($this->model === NULL) $this->model = new BaseModel;
  30.         parent::startup();                    
  31.         LatteMacros::$defaultMacros['clink'] = '%Macros::clink%';
  32.     }
  33.  
  34.     /**
  35.     * Vraci cestu
  36.     *
  37.     * @param mixed $sectionId
  38.     * @param mixed $langId
  39.     */
  40.     function clink($sectionId, $langId = NULL)
  41.     {
  42.         $this->initRoutes();
  43.         $sectionId = (int)$sectionId;
  44.         if ($langId === NULL) $langId = $this->langId;            
  45.         $x = $this->routes[$sectionId][$langId];
  46.         return $this->routes[$sectionId][$langId] === NULL
  47.                 ? 'error: Pozadovana stranka v cms neexistuje'
  48.                 : htmlSpecialChars($this->template->basePath.'/'.$this->routes[$sectionId][$langId][self::R_PATH],ENT_QUOTES);
  49.     }
  50.  
  51.     /**
  52.     * Inicializace odkazů - pole vsech odakzu pra kazdy jazyk
  53.     *
  54.     */
  55.     function initRoutes()
  56.     {
  57.         if ($this->routes === NULL)
  58.             $this->routes = $this->model->getRoutes();
  59.     }
  60.    
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement