public static function loadClass($class) { if (strpos($class, 'jelix\\') === 0) { $f = LIB_PATH . 'jelix-legacy/' . str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 6)) . '.php'; } elseif (preg_match('/^j(Dao|Tpl|Event|Db|Controller|Forms|Auth|Installer|KV).*/i', $class, $m)) { $f = self::$libPath[$m[1]] . $class . '.class.php'; } elseif (preg_match('/^cDao(?:Record)?_(.+)_Jx_(.+)_Jx_(.+)$/', $class, $m)) { // for DAO which are stored in sessions for example if (!isset(jApp::config()->_modulesPathList[$m[1]])) { //this may happen if we have several entry points, but the current one does not have this module accessible return; } $s = new jSelectorDaoDb($m[1] . '~' . $m[2], '', $m[3]); if (jApp::config()->compilation['checkCacheFiletime']) { // if it is needed to check the filetime, then we use jIncluder // because perhaps we will have to recompile the dao before the include jIncluder::inc($s); } else { $f = $s->getCompiledFilePath(); // we should verify that the file is here and if not, we recompile // (case where the temp has been cleaned, see bug #6062 on berlios.de) if (!file_exists($f)) { jIncluder::inc($s); } else { require $f; } } return; } else { $f = JELIX_LIB_UTILS_PATH . $class . '.class.php'; } if (file_exists($f)) { require $f; } }
public static function createRecord($DaoId, $profile = '') { $sel = new jSelectorDao($DaoId, $profile); $c = $sel->getDaoClass(); if (!class_exists($c, false)) { jIncluder::inc($sel); } $c = $sel->getDaoRecordClass(); $obj = new $c(); return $obj; }
/** * get an existing instance of a form * * In your controller, call it before to re-display a form with existing data. * * @param string $formSel the selector of the xml jform file * @param string $formId the id of the form (if you use multiple instance of a form) * @return jFormBase the object representing the form. Return null if there isn't an existing form */ public static function get($formSel, $formId = null) { $session = self::getSession(); list($container, $sel) = $session->getContainer($formSel, $formId, false); if (!$container) { return null; } jIncluder::inc($sel); $c = $sel->getClass(); $form = new $c($container->formSelector, $container, false); return $form; }
/** * get an existing instance of a form * * In your controller, call it before to re-display a form with existing data. * * @param string $formSel the selector of the xml jform file * @param string $formId the id of the form (if you use multiple instance of a form) * @return jFormBase the object representing the form. Return null if there isn't an existing form */ public static function get($formSel, $formId = null) { global $gJCoord; if ($formId === null) { $formId = self::DEFAULT_ID; } $fid = is_array($formId) ? serialize($formId) : $formId; if (!isset($_SESSION['JFORMS'][$formSel][$fid])) { return null; } $sel = new jSelectorForm($formSel); jIncluder::inc($sel); $c = $sel->getClass(); $form = new $c($sel->toString(), $_SESSION['JFORMS'][$formSel][$fid], false); return $form; }
/** * function used by php to try to load an unknown class */ function jelix_autoload($class) { if (preg_match('/^j(Dao|Tpl|Acl|Event|Db|Controller|Forms|Auth|Installer).*/i', $class, $m)) { $f = $GLOBALS['gLibPath'][$m[1]] . $class . '.class.php'; } elseif (preg_match('/^cDao(?:Record)?_(.+)_Jx_(.+)_Jx_(.+)$/', $class, $m)) { // for DAO which are stored in sessions for example $s = new jSelectorDao($m[1] . '~' . $m[2], $m[3], false); if ($GLOBALS['gJConfig']->compilation['checkCacheFiletime']) { // if it is needed to check the filetime, then we use jIncluder // because perhaps we will have to recompile the dao before the include jIncluder::inc($s); } else { $f = $s->getCompiledFilePath(); // we should verify that the file is here and if not, we recompile // (case where the temp has been cleaned, see bug #6062 on berlios.de) if (!file_exists($f)) { jIncluder::inc($s); } else { require $f; } } return; } else { $f = JELIX_LIB_UTILS_PATH . $class . '.class.php'; } if (file_exists($f)) { require $f; } }
/** * include the compiled template file and call one of the generated function * @param string|jSelectorTpl $tpl template selector * @param string $outputtype the type of output (html, text etc..) * @param boolean $trusted says if the template file is trusted or not * @return string the suffix name of the function to call */ protected function getTemplate($tpl, $outputtype = '', $trusted = true) { $tpl->userModifiers = $this->userModifiers; $tpl->userFunctions = $this->userFunctions; jIncluder::inc($tpl); return md5($tpl->module . '_' . $tpl->resource . '_' . $tpl->outputType . ($trusted ? '_t' : '')); }
/** * return the generated content from the given template * @param string $tpl template selector * @param string $outputtype the type of output (html, text etc..) * @param boolean $trusted says if the template file is trusted or not * @param boolean $callMeta false if meta should not be called * @return string the generated content */ public function fetch($tpl, $outputtype = '', $trusted = true, $callMeta = true) { $content = ''; ob_start(); try { $sel = new jSelectorTpl($tpl, $outputtype, $trusted); $sel->userModifiers = $this->userModifiers; $sel->userFunctions = $this->userFunctions; jIncluder::inc($sel); $md = md5($sel->module . '_' . $sel->resource . '_' . $sel->outputType . ($trusted ? '_t' : '')); $this->_templateName = $sel->toString(); if ($callMeta) { $fct = 'template_meta_' . $md; $fct($this); } $fct = 'template_' . $md; $fct($this); $content = ob_get_clean(); } catch (Exception $e) { ob_end_clean(); throw $e; } return $content; }
/** * Create a jurl object with the given action data * @param jUrlAction $url information about the action * @return jUrl the url correspondant to the action * @author Laurent Jouanneau * @copyright 2005 CopixTeam, 2005-2006 Laurent Jouanneau * very few lines of code are copyrighted by CopixTeam, written by Laurent Jouanneau * and released under GNU Lesser General Public Licence, * in an experimental version of Copix Framework v2.3dev20050901, * http://www.copix.org. */ public function create($urlact) { if ($this->dataCreateUrl == null) { $sel = new jSelectorUrlCfgSig(jApp::config()->urlengine['significantFile']); jIncluder::inc($sel); $this->dataCreateUrl =& $GLOBALS['SIGNIFICANT_CREATEURL']; } $url = new jUrl('', $urlact->params, ''); $module = $url->getParam('module', jApp::getCurrentModule()); $action = $url->getParam('action'); // let's try to retrieve informations corresponding // to the given action. this informations will allow us to build // the url $id = $module . '~' . $action . '@' . $urlact->requestType; $urlinfo = null; if (isset($this->dataCreateUrl[$id])) { $urlinfo = $this->dataCreateUrl[$id]; $url->delParam('module'); $url->delParam('action'); } 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("Significant url engine doesn't find corresponding url to this action :" . $module . '~' . $action . '@' . $urlact->requestType); } } } /* urlinfo = or array(0,'entrypoint', https true/false, 'handler selector', 'basepathinfo') or 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 ) or array(2,'entrypoint', https true/false), // for the patterns "@request" or array(3,'entrypoint', https true/false), // for the patterns "module~@request" or array(4, array(1,...), array(1,...)...) */ 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 = jLocale::getCurrentLang(); } else { if (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 = jApp::config()->locale; } else { if (preg_match('/^\\w{2,3}$/', $paramStatic, $m)) { // if the value is a lang instead of locale, translate it $paramStatic = jLocale::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]; } } // at this step, we have informations to build the url $url->scriptName = jApp::config()->urlengine['basePath'] . $urlinfo[1]; if ($urlinfo[2]) { $url->scriptName = jApp::coord()->request->getServerURI(true) . $url->scriptName; } if ($urlinfo[1] && !jApp::config()->urlengine['multiview']) { $url->scriptName .= '.php'; } // for some request types, parameters aren't in the url // so we remove them // it's a bit dirty to do that hardcoded here, but it would be a pain // to load the request class to check whether we can remove or not if (in_array($urlact->requestType, array('xmlrpc', 'jsonrpc', 'soap'))) { $url->clearParam(); return $url; } if ($urlinfo[0] == 0) { $s = new jSelectorUrlHandler($urlinfo[3]); $c = $s->resource . 'UrlsHandler'; $handler = new $c(); $handler->create($urlact, $url); if ($urlinfo[4] != '') { $url->pathInfo = $urlinfo[4] . $url->pathInfo; } } elseif ($urlinfo[0] == 1) { $pi = $urlinfo[5]; foreach ($urlinfo[3] as $k => $param) { $typeParam = $urlinfo[4][$k]; $value = $url->getParam($param, ''); if ($typeParam & 2) { $value = jUrl::escape($value, true); } else { if ($typeParam & 1) { $value = str_replace('%2F', '/', urlencode($value)); } else { if ($typeParam & 4) { if ($value == '') { $value = jLocale::getCurrentLang(); } else { if (preg_match('/^(\\w{2,3})_\\w{2,3}$/', $value, $m)) { $value = $m[1]; } } } else { if ($typeParam & 8) { if ($value == '') { $value = jApp::config()->locale; } else { if (preg_match('/^\\w{2,3}$/', $value, $m)) { $value = jLocale::langToLocale($value); } } } else { $value = urlencode($value); } } } } $pi = str_replace(':' . $param, $value, $pi); $url->delParam($param); } $url->pathInfo = $pi; if ($urlinfo[6]) { $url->setParam('action', $action); } // removed parameters corresponding to static values foreach ($urlinfo[7] as $name => $value) { $url->delParam($name); } } elseif ($urlinfo[0] == 3) { if ($urlinfo[3]) { $url->delParam('module'); } } return $url; }
/** * return the list of all listener corresponding to an event * @param string $eventName the event name we wants the listeners for. * @return array of objects */ protected static function loadListenersFor($eventName) { if (!isset($GLOBALS['JELIX_EVENTS'])) { self::$compilerData[3] = jApp::config()->urlengine['urlScriptId'] . '.' . self::$compilerData[3]; jIncluder::incAll(self::$compilerData); } $inf =& $GLOBALS['JELIX_EVENTS']; self::$hashListened[$eventName] = array(); if (isset($inf[$eventName])) { $modules =& jApp::config()->_modulesPathList; foreach ($inf[$eventName] as $listener) { list($module, $listenerName) = $listener; if (!isset($modules[$module])) { // some modules could be unused continue; } if (!isset(self::$listenersSingleton[$module][$listenerName])) { require_once $modules[$module] . 'classes/' . $listenerName . '.listener.php'; $className = $listenerName . 'Listener'; self::$listenersSingleton[$module][$listenerName] = new $className(); } self::$hashListened[$eventName][] = self::$listenersSingleton[$module][$listenerName]; } } }
/** * get an existing instance of a form * * In your controller, call it before to re-display a form with existing data. * * @param string $formSel the selector of the xml jform file * @param string $formId the id of the form (if you use multiple instance of a form) * @return jFormBase the object representing the form. Return null if there isn't an existing form */ public static function get($formSel, $formId = null) { if ($formId === null || $formId === '') { $formId = self::DEFAULT_ID; } $fid = is_array($formId) ? serialize($formId) : $formId; $sel = new jSelectorForm($formSel); // normalize the selector to avoid conflict in session $formSel = $sel->toString(); if (!isset($_SESSION['JFORMS'][$formSel][$fid])) { return null; } jIncluder::inc($sel); $c = $sel->getClass(); $form = new $c($formSel, $_SESSION['JFORMS'][$formSel][$fid], false); return $form; }
/** * Create a jurl object with the given action data * @param jUrlAction $url information about the action * @return jUrl the url correspondant to the action * @author Laurent Jouanneau * @copyright 2005 CopixTeam, 2005-2006 Laurent Jouanneau * very few lines of code are copyrighted by CopixTeam, written by Laurent Jouanneau * and released under GNU Lesser General Public Licence, * in an experimental version of Copix Framework v2.3dev20050901, * http://www.copix.org. */ public function create($urlact) { if ($this->dataCreateUrl == null) { $sel = new jSelectorUrlCfgSig($GLOBALS['gJConfig']->urlengine['significantFile']); jIncluder::inc($sel); $this->dataCreateUrl =& $GLOBALS['SIGNIFICANT_CREATEURL']; } $url = new jUrl('', $urlact->params, ''); $module = $url->getParam('module', jContext::get()); $action = $url->getParam('action'); // let's try to retrieve informations corresponding // to the given action. this informations will allow us to build // the url $id = $module . '~' . $action . '@' . $urlact->requestType; $urlinfo = null; if (isset($this->dataCreateUrl[$id])) { $urlinfo = $this->dataCreateUrl[$id]; $url->delParam('module'); $url->delParam('action'); } 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("Significant url engine doesn't find corresponding url to this action :" . $module . '~' . $action . '@' . $urlact->requestType); } } } /* urlinfo = or array(0,'entrypoint', https true/false, 'handler selector', 'basepathinfo') or 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 ) or array(2,'entrypoint', https true/false), // for the patterns "@request" or array(3,'entrypoint', https true/false), // for the patterns "module~@request" or array(4, array(1,...), array(1,...)...) */ 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) { if ($url->getParam($n, '') != $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]; } } // at this step, we have informations to build the url $url->scriptName = $GLOBALS['gJConfig']->urlengine['basePath'] . $urlinfo[1]; if ($urlinfo[2]) { $url->scriptName = $GLOBALS['gJCoord']->request->getServerURI(true) . $url->scriptName; } if ($urlinfo[1] && !$GLOBALS['gJConfig']->urlengine['multiview']) { $url->scriptName .= $GLOBALS['gJConfig']->urlengine['entrypointExtension']; } // pour certains types de requete, les paramètres ne sont pas dans l'url // donc on les supprime // c'est un peu crade de faire ça en dur ici, mais ce serait lourdingue // de charger la classe request pour savoir si on peut supprimer ou pas if (in_array($urlact->requestType, array('xmlrpc', 'jsonrpc', 'soap'))) { $url->clearParam(); return $url; } if ($urlinfo[0] == 0) { $s = new jSelectorUrlHandler($urlinfo[3]); $c = $s->resource . 'UrlsHandler'; $handler = new $c(); $handler->create($urlact, $url); if ($urlinfo[4] != '') { $url->pathInfo = $urlinfo[4] . $url->pathInfo; } } elseif ($urlinfo[0] == 1) { $pi = $urlinfo[5]; foreach ($urlinfo[3] as $k => $param) { switch ($urlinfo[4][$k]) { case 2: $value = jUrl::escape($url->getParam($param, ''), true); break; case 1: $value = str_replace('%2F', '/', urlencode($url->getParam($param, ''))); break; default: $value = urlencode($url->getParam($param, '')); break; } $pi = str_replace(':' . $param, $value, $pi); $url->delParam($param); } $url->pathInfo = $pi; if ($urlinfo[6]) { $url->setParam('action', $action); } // removed parameters corresponding to static values foreach ($urlinfo[7] as $name => $value) { $url->delParam($name); } } elseif ($urlinfo[0] == 3) { if ($urlinfo[3]) { $url->delParam('module'); } } return $url; }
function jelix_autoload($class) { if (preg_match('/^j(Dao|Tpl|Event|Db|Controller|Forms|Auth|Installer|KV|Pref).*/i', $class, $m)) { $f = $GLOBALS['gLibPath'][$m[1]] . $class . '.class.php'; } elseif ($class == 'jAcl2') { $f = JELIX_LIB_PATH . 'acl/jAcl2.class.php'; } elseif (preg_match('/^cDao(?:Record)?_(.+)_Jx_(.+)_Jx_(.+)$/', $class, $m)) { $s = new jSelectorDao($m[1] . '~' . $m[2], $m[3], false); if (jApp::config()->compilation['checkCacheFiletime']) { jIncluder::inc($s); } else { $f = $s->getCompiledFilePath(); if (!file_exists($f)) { jIncluder::inc($s); } else { require $f; } } return; } else { $f = JELIX_LIB_UTILS_PATH . $class . '.class.php'; } if (file_exists($f)) { require $f; } }
/** * return the list of all listener corresponding to an event * @param string $eventName the event name we wants the listeners for. * @return array of objects */ protected static function loadListenersFor($eventName) { if (!isset($GLOBALS['JELIX_EVENTS'])) { jIncluder::incAll(self::$compilerData); } $inf =& $GLOBALS['JELIX_EVENTS']; self::$hashListened[$eventName] = array(); if (isset($inf[$eventName])) { foreach ($inf[$eventName] as $listener) { list($module, $listenerName) = $listener; if (!isset(self::$listenersSingleton[$module][$listenerName])) { require_once $GLOBALS['gJConfig']->_modulesPathList[$module] . 'classes/' . $listenerName . '.listener.php'; $className = $listenerName . 'Listener'; #if ENABLE_OLD_CLASS_NAMING if (!class_exists($className, false)) { $className = 'Listener' . $listenerName; } #endif self::$listenersSingleton[$module][$listenerName] = new $className(); } self::$hashListened[$eventName][] = self::$listenersSingleton[$module][$listenerName]; } } }
/** * Create a jurl object with the given action data * @param jUrlAction $url information about the action * @return jUrl the url correspondant to the action * @author Laurent Jouanneau * @copyright 2005 CopixTeam, 2005-2006 Laurent Jouanneau * very few lines of code are copyrighted by CopixTeam, written by Laurent Jouanneau * and released under GNU Lesser General Public Licence, * in an experimental version of Copix Framework v2.3dev20050901, * http://www.copix.org. */ public function create($urlact) { if ($this->dataCreateUrl == null) { $sel = new jSelectorUrlCfgSig($GLOBALS['gJConfig']->urlengine['significantFile']); jIncluder::inc($sel); $this->dataCreateUrl =& $GLOBALS['SIGNIFICANT_CREATEURL']; } /* a) recupere module~action@request -> obtient les infos pour la creation de l'url b) récupère un à un les parametres indiqués dans params à partir de jUrl c) remplace la valeur récupérée dans le result et supprime le paramètre de l'url d) remplace scriptname de jUrl par le resultat */ $url = new jUrl('', $urlact->params, ''); $module = $url->getParam('module', jContext::get()); $action = $url->getParam('action'); $id = $module . '~' . $action . '@' . $urlact->requestType; $urlinfo = null; if (isset($this->dataCreateUrl[$id])) { $urlinfo = $this->dataCreateUrl[$id]; $url->delParam('module'); $url->delParam('action'); } else { $id = $module . '~*@' . $urlact->requestType; if (isset($this->dataCreateUrl[$id])) { $urlinfo = $this->dataCreateUrl[$id]; $url->delParam('module'); } else { $id = '@' . $urlact->requestType; if (isset($this->dataCreateUrl[$id])) { $urlinfo = $this->dataCreateUrl[$id]; } else { throw new Exception("Significant url engine doesn't find corresponding url to this action :" . $module . '~' . $action . '@' . $urlact->requestType); } } } /* urlinfo = array(0,'entrypoint', https true/false,'selecteur handler') ou array(1,'entrypoint', https true/false, array('annee','mois','jour','id','titre'), // liste des paramètres de l'url à prendre en compte array(true, false..), // valeur des escapes "/news/%1/%2/%3/%4-%5", // forme de l'url false, //indique si c'est une action surchargeante ) ou array(2,'entrypoint', https true/false,); pour les clés du type "@request" array(3,'entrypoint', https true/false); pour les clés du type "module~@request" array(4, array(1,..), array(1,..)...); */ if ($urlinfo[0] == 4) { $l = count($urlinfo); $urlinfofound = null; for ($i = 1; $i < $l; $i++) { $ok = true; foreach ($urlinfo[$i][7] as $n => $v) { if ($url->getParam($n, '') != $v) { $ok = false; break; } } if ($ok) { $urlinfofound = $urlinfo[$i]; break; } } if ($urlinfofound !== null) { $urlinfo = $urlinfofound; } else { $urlinfo = $urlinfo[1]; } } $url->scriptName = $GLOBALS['gJConfig']->urlengine['basePath'] . $urlinfo[1]; if ($urlinfo[2]) { $url->scriptName = 'https://' . $_SERVER['HTTP_HOST'] . $url->scriptName; } if ($urlinfo[1] && !$GLOBALS['gJConfig']->urlengine['multiview']) { $url->scriptName .= $GLOBALS['gJConfig']->urlengine['entrypointExtension']; } // pour certains types de requete, les paramètres ne sont pas dans l'url // donc on les supprime // c'est un peu crade de faire ça en dur ici, mais ce serait lourdingue // de charger la classe request pour savoir si on peut supprimer ou pas if (in_array($urlact->requestType, array('xmlrpc', 'jsonrpc', 'soap'))) { $url->clearParam(); return $url; } if ($urlinfo[0] == 0) { $s = new jSelectorUrlHandler($urlinfo[3]); $c = $s->resource . 'UrlsHandler'; $handler = new $c(); $handler->create($urlact, $url); } elseif ($urlinfo[0] == 1) { $pi = $urlinfo[5]; foreach ($urlinfo[3] as $k => $param) { if ($urlinfo[4][$k]) { $pi = str_replace(':' . $param, jUrl::escape($url->getParam($param, ''), true), $pi); } else { $pi = str_replace(':' . $param, $url->getParam($param, ''), $pi); } $url->delParam($param); } $url->pathInfo = $pi; if ($urlinfo[6]) { $url->setParam('action', $action); } // removed parameters corresponding to static values foreach ($urlinfo[7] as $name => $value) { $url->delParam($name); } } elseif ($urlinfo[0] == 3) { $url->delParam('module'); } return $url; }
public function create($urlact) { if ($this->dataCreateUrl == null) { $sel = new jSelectorUrlCfgSig(jApp::config()->urlengine['significantFile']); jIncluder::inc($sel); $this->dataCreateUrl =& $GLOBALS['SIGNIFICANT_CREATEURL']; } $url = new jUrl('', $urlact->params, ''); $module = $url->getParam('module', jContext::get()); $action = $url->getParam('action'); $id = $module . '~' . $action . '@' . $urlact->requestType; $urlinfo = null; if (isset($this->dataCreateUrl[$id])) { $urlinfo = $this->dataCreateUrl[$id]; $url->delParam('module'); $url->delParam('action'); } 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("Significant url engine doesn't find corresponding url to this action :" . $module . '~' . $action . '@' . $urlact->requestType); } } } if ($urlinfo[0] == 4) { $l = count($urlinfo); $urlinfofound = null; for ($i = 1; $i < $l; $i++) { $ok = true; foreach ($urlinfo[$i][7] as $n => $v) { $specialStatic = $v[0] == '$'; $paramStatic = $url->getParam($n, null); if ($specialStatic) { $typePS = $v[1]; $v = substr($v, 2); if ($typePS == 'l') { if ($paramStatic === null) { $paramStatic = jLocale::getCurrentLang(); } else { if (preg_match('/^(\\w{2,3})_\\w{2,3}$/', $paramStatic, $m)) { $paramStatic = $m[1]; } } } elseif ($typePS == 'L') { if ($paramStatic === null) { $paramStatic = jApp::config()->locale; } else { if (preg_match('/^\\w{2,3}$/', $paramStatic, $m)) { $paramStatic = jLocale::langToLocale($paramStatic); } } } } if ($paramStatic != $v) { $ok = false; break; } } if ($ok) { $urlinfofound = $urlinfo[$i]; break; } } if ($urlinfofound !== null) { $urlinfo = $urlinfofound; } else { $urlinfo = $urlinfo[1]; } } $url->scriptName = jApp::config()->urlengine['basePath'] . $urlinfo[1]; if ($urlinfo[2]) { $url->scriptName = jApp::coord()->request->getServerURI(true) . $url->scriptName; } if ($urlinfo[1] && !jApp::config()->urlengine['multiview']) { $url->scriptName .= jApp::config()->urlengine['entrypointExtension']; } if (in_array($urlact->requestType, array('xmlrpc', 'jsonrpc', 'soap'))) { $url->clearParam(); return $url; } if ($urlinfo[0] == 0) { $s = new jSelectorUrlHandler($urlinfo[3]); $c = $s->resource . 'UrlsHandler'; $handler = new $c(); $handler->create($urlact, $url); if ($urlinfo[4] != '') { $url->pathInfo = $urlinfo[4] . $url->pathInfo; } } elseif ($urlinfo[0] == 1) { $pi = $urlinfo[5]; foreach ($urlinfo[3] as $k => $param) { $typeParam = $urlinfo[4][$k]; $value = $url->getParam($param, ''); if ($typeParam & 2) { $value = jUrl::escape($value, true); } else { if ($typeParam & 1) { $value = str_replace('%2F', '/', urlencode($value)); } else { if ($typeParam & 4) { if ($value == '') { $value = jLocale::getCurrentLang(); } else { if (preg_match('/^(\\w{2,3})_\\w{2,3}$/', $value, $m)) { $value = $m[1]; } } } else { if ($typeParam & 8) { if ($value == '') { $value = jApp::config()->locale; } else { if (preg_match('/^\\w{2,3}$/', $value, $m)) { $value = jLocale::langToLocale($value); } } } else { $value = urlencode($value); } } } } $pi = str_replace(':' . $param, $value, $pi); $url->delParam($param); } $url->pathInfo = $pi; if ($urlinfo[6]) { $url->setParam('action', $action); } foreach ($urlinfo[7] as $name => $value) { $url->delParam($name); } } elseif ($urlinfo[0] == 3) { if ($urlinfo[3]) { $url->delParam('module'); } } return $url; }
/** * include the compiled template file and call one of the generated function * @param string|jSelectorTpl $tpl template selector * @param string $outputtype the type of output (html, text etc..) * @param boolean $trusted says if the template file is trusted or not * @return string the suffix name of the function to call */ protected function getTemplate($tpl, $outputtype = '', $trusted = true) { #ifnot JTPL_STANDALONE $tpl->userModifiers = $this->userModifiers; $tpl->userFunctions = $this->userFunctions; jIncluder::inc($tpl); return md5($tpl->module . '_' . $tpl->resource . '_' . $tpl->outputType . ($trusted ? '_t' : '')); #else $tpl = jTplConfig::$templatePath . $tpl; if ($outputtype == '') { $outputtype = 'html'; } $cachefile = dirname($this->_templateName) . '/'; if ($cachefile == './') { $cachefile = ''; } if (jTplConfig::$cachePath == '/' || jTplConfig::$cachePath == '') { throw new Exception('cache path is invalid ! its value is: "' . jTplConfig::$cachePath . '".'); } $cachefile = jTplConfig::$cachePath . $cachefile . $outputtype . ($trusted ? '_t' : '') . '_' . basename($tpl); $mustCompile = jTplConfig::$compilationForce || !file_exists($cachefile); if (!$mustCompile) { if (filemtime($tpl) > filemtime($cachefile)) { $mustCompile = true; } } if ($mustCompile) { include_once JTPL_PATH . 'jTplCompiler.class.php'; $compiler = new jTplCompiler(); $compiler->compile($this->_templateName, $tpl, $outputtype, $trusted, $this->userModifiers, $this->userFunctions); } require_once $cachefile; return md5($tpl . '_' . $outputtype . ($trusted ? '_t' : '')); #endif }