Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Makra projektu
- */
- class Macros extends LatteMacros implements IRoute
- {
- /**
- * Vraci url adresu stranky podle id
- * {clink 2} <- vraci odkaz na stranku se section_id 2 a lang
- *
- * @param mixed $sectionId
- * @param mixed $langId
- */
- public static function clink($request)
- {
- list($id, $lang) = explode(':',$request);
- return Environment::getApplication()->getPresenter()->clink($id, $lang);
- }
- }
- abstract class BasePresenter extends Presenter implements IRoute
- {
- protected $model = NULL;
- protected $routes;
- function startup()
- {
- if ($this->model === NULL) $this->model = new BaseModel;
- parent::startup();
- LatteMacros::$defaultMacros['clink'] = '%Macros::clink%';
- }
- /**
- * Vraci cestu
- *
- * @param mixed $sectionId
- * @param mixed $langId
- */
- function clink($sectionId, $langId = NULL)
- {
- $this->initRoutes();
- $sectionId = (int)$sectionId;
- if ($langId === NULL) $langId = $this->langId;
- $x = $this->routes[$sectionId][$langId];
- return $this->routes[$sectionId][$langId] === NULL
- ? 'error: Pozadovana stranka v cms neexistuje'
- : htmlSpecialChars($this->template->basePath.'/'.$this->routes[$sectionId][$langId][self::R_PATH],ENT_QUOTES);
- }
- /**
- * Inicializace odkazů - pole vsech odakzu pra kazdy jazyk
- *
- */
- function initRoutes()
- {
- if ($this->routes === NULL)
- $this->routes = $this->model->getRoutes();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement