function __construct($sel) { if ($this->_scan_sel($sel)) { if ($this->module == '') { $this->module = App::getCurrentModule(); } $this->_createPath(); $this->_createCachePath(); } else { throw new Exception('jelix~errors.selector.invalid.syntax', array($sel, $this->type)); } }
function __construct($sel, $locale = null, $charset = null) { if ($locale === null) { $locale = App::config()->locale; } if ($charset === null) { $charset = App::config()->charset; } if (strpos($locale, '_') === false) { $locale = Locale::langToLocale($locale); } $this->locale = $locale; $this->charset = $charset; $this->_suffix = '.' . $charset . '.properties'; if ($this->_scan_sel($sel)) { if ($this->module == '') { $this->module = App::getCurrentModule(); } $this->_createPath(); $this->_createCachePath(); } else { throw new \Jelix\Core\Selector\Exception('jelix~errors.selector.invalid.syntax', array($sel, $this->type)); } }
static function getCurrentModule() { return \Jelix\Core\App::getCurrentModule(); }
/** * search informations allowing to build the url corresponding to the * given module/action. * * @return array the informations. It may be: * - array(0,'entrypoint', https true/false, 'handler selector', 'basepathinfo') * - array(1,'entrypoint', https true/false, * array('year','month',), // list of dynamic values included in the url * array(true, false..), // list of integers which indicates for each * // dynamic value: 0: urlencode, 1:urlencode except '/', 2:escape * "/news/%1/%2/", // the url * true/false, // false : this is a secondary action * array('bla'=>'whatIWant' ) // list of static values * ) * - array(2,'entrypoint', https true/false), // for the patterns "@request" * - array(3,'entrypoint', https true/false, $defaultmodule true/false, 'pathinfobase'), // for the patterns "module~@request" * - array(4, array(1,...), array(1,...)...) * - array(5, 'entrypoint', https true/false,) */ protected function getUrlBuilderInfo(\jUrlAction $urlact, \jUrl $url) { $module = $url->getParam('module', App::getCurrentModule()); $urlinfo = null; // let's try to retrieve informations corresponding // to the given action. this informations will allow us to build // the url $id = $module . '~' . $url->getParam('action') . '@' . $urlact->requestType; if (isset($this->dataCreateUrl[$id])) { $urlinfo = $this->dataCreateUrl[$id]; $url->delParam('module'); $url->delParam('action'); } else { list($ctrl, $method) = explode(':', $url->getParam('action')); $id = $module . '~' . $ctrl . ':*@' . $urlact->requestType; if (isset($this->dataCreateUrl[$id])) { $urlinfo = $this->dataCreateUrl[$id]; $url->delParam('module'); } else { $id = $module . '~*@' . $urlact->requestType; if (isset($this->dataCreateUrl[$id])) { $urlinfo = $this->dataCreateUrl[$id]; if ($urlinfo[0] != 3 || $urlinfo[3] === true) { $url->delParam('module'); } } else { $id = '@' . $urlact->requestType; if (isset($this->dataCreateUrl[$id])) { $urlinfo = $this->dataCreateUrl[$id]; } else { throw new \Exception("URL engine doesn't find corresponding url to this action: " . $module . '~' . $action . '@' . $urlact->requestType); } } } } if ($urlinfo[0] == 4) { // an action is mapped to several urls // so it isn't finished. Let's find building information // into the array $l = count($urlinfo); $urlinfofound = null; for ($i = 1; $i < $l; ++$i) { $ok = true; // verify that given static parameters of the action correspond // to those defined for this url foreach ($urlinfo[$i][7] as $n => $v) { // specialStatic are static values for which the url engine // can compare not only with a given url parameter value, but // also with a value stored some where (typically, a configuration value) $specialStatic = !empty($v) && $v[0] == '$'; $paramStatic = $url->getParam($n, null); if ($specialStatic) { // special statique value $typePS = $v[1]; $v = substr($v, 2); if ($typePS == 'l') { if ($paramStatic === null) { $paramStatic = Locale::getCurrentLang(); } elseif (preg_match('/^(\\w{2,3})_\\w{2,3}$/', $paramStatic, $m)) { // if the value is a locale instead of lang, translate it $paramStatic = $m[1]; } } elseif ($typePS == 'L') { if ($paramStatic === null) { $paramStatic = App::config()->locale; } elseif (preg_match('/^\\w{2,3}$/', $paramStatic, $m)) { // if the value is a lang instead of locale, translate it $paramStatic = Locale::langToLocale($paramStatic); } } } if ($paramStatic != $v) { $ok = false; break; } } if ($ok) { // static parameters correspond: we found our informations $urlinfofound = $urlinfo[$i]; break; } } if ($urlinfofound !== null) { $urlinfo = $urlinfofound; } else { $urlinfo = $urlinfo[1]; } } return $urlinfo; }