Changeset 51
- Timestamp:
- 01/25/06 01:16:35 (3 years ago)
- Files:
-
- trunk/lib/jelix-scripts/templates/config.classic.ini.php.tpl (modified) (2 diffs)
- trunk/lib/jelix/core/jConfig.class.php (modified) (1 diff)
- trunk/lib/jelix/core/jCoordinator.class.php (modified) (3 diffs)
- trunk/lib/jelix/core/jDefaultConfig.lib.php (modified) (1 diff)
- trunk/lib/jelix/core/jIncluder.class.php (modified) (1 diff)
- trunk/lib/jelix/core/jSelector.class.php (modified) (20 diffs)
- trunk/lib/jelix/core/request/jCmdLineRequest.class.php (added)
- trunk/lib/jelix/core/url/jUrl.class.php (modified) (3 diffs)
- trunk/lib/jelix/core/url/jUrlCompiler.significant.class.php (modified) (8 diffs)
- trunk/lib/jelix/core/url/jUrlEngine.significant.class.php (modified) (1 diff)
- trunk/lib/jelix/core/url/jUrlEngine.simple.class.php (moved) (moved from trunk/lib/jelix/core/url/jUrlEngine.default.class.php) (3 diffs)
- trunk/lib/jelix/init.php (modified) (1 diff)
- trunk/lib/jelix/VERSION (modified) (1 diff)
- trunk/myapp/var/config/config.classic.ini.php.dist (modified) (2 diffs)
- trunk/testapp/var/config/config.classic.ini.php.dist (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/jelix-scripts/templates/config.classic.ini.php.tpl
r44 r51 50 50 51 51 [urlengine] 52 ; nom du moteur d'url : simple ou significant 53 engine = simple 52 54 53 ;indique si vous utiliser IIS comme serveur 55 ; active l'analyse d'url (mettre �ff si vous utilisez le mod_rewrite d'apache) 56 enable_parser = on 57 58 multiview_on = off 59 60 default_entrypoint= index 61 62 entrypoint_extension= .php 63 64 notfound_act = "jelix~notfound" 65 66 ;indique si vous utilisez IIS comme serveur 54 67 use_IIS = off 55 68 56 ;indique le param�e dans $_GET o u estindiqu�e path_info69 ;indique le param�e dans $_GET o� indiqu�e path_info 57 70 IIS_path_key = __JELIX_URL__ 58 71 … … 60 73 IIS_stripslashes_path_key = on 61 74 62 default_entrypoint= index63 entrypoint_extension= .php64 75 65 engine = default 66 enable_parser = on 67 multiview_on = off 68 notfound_dest = "jelix~notfound" 76 [simple_urlengine_entrypoints] 77 ; param�es pour le moteur d'url simple : liste des points d'entr� avec les actions 78 ; qui y sont rattach� 69 79 70 [urlengine_specific_entrypoints] 80 71 81 ; nom_script_sans_suffix = "liste de selecteur d'action s�r�ar un espace" 72 82 ; selecteurs : trunk/lib/jelix/core/jConfig.class.php
r41 r51 55 55 $config->trustedModules = array_keys($config->modulesPathList); 56 56 } 57 //$config->urlengine_specific_entrypoints = array_flip($config->urlengine_specific_entrypoints); 57 58 58 return $config; 59 59 } trunk/lib/jelix/core/jCoordinator.class.php
r44 r51 62 62 $this->configFile = $configFile; 63 63 $gJConfig = jConfig::load($configFile); 64 //$this->_initConfig();65 64 66 65 // set Error and exception handler 67 set_error_handler('jErrorHandler');68 set_exception_handler('JExceptionHandler');66 //set_error_handler('jErrorHandler'); 67 //set_exception_handler('JExceptionHandler'); 69 68 70 69 $this->_loadPlugins(); … … 102 101 103 102 $this->request = $request; 104 session_start();103 session_start(); 105 104 106 105 $this->moduleName = $this->request->getParam('module', $gJConfig->defaultModule,true); … … 204 203 * gets a given plugin if registered 205 204 * @param string $plugin_name nom du plugin 206 * @param boolean $required if the plugin is required or not. If true, will trigger a fatal_error if the plugin is not registered.205 * @param boolean $required if the plugin is required or not. If true, will trigger a fatal_error if the plugin is not registered. 207 206 */ 208 207 function getPlugin ($pluginName, $required = true){ trunk/lib/jelix/core/jDefaultConfig.lib.php
r41 r51 69 69 'default_entrypoint' => 'index', 70 70 'entrypoint_extension' => '.php', 71 'engine' => ' default',71 'engine' => 'simple', 72 72 'enable_parser' => '1', 73 73 'multiview_on' => '', 74 'notfound_ dest' => 'jelix~notfound'74 'notfound_act' => 'jelix~notfound' 75 75 ), 76 76 'urlengine_specific_entrypoints' => trunk/lib/jelix/core/jIncluder.class.php
r36 r51 40 40 ); 41 41 } 42 43 public static function URL(){44 return array('jUrlCompiler',45 'core/url/jUrlCompiler.class.php',46 'actions.xml',47 'urls.php'48 );49 }50 51 42 52 43 /** trunk/lib/jelix/core/jSelector.class.php
r44 r51 17 17 */ 18 18 class jSelectorFactory { 19 function create ($id){19 function create ($id){ 20 20 if(preg_match("/^([a-z]{3,5})\:([\w~\/\.]+)$/", $id, $m)){ 21 21 $cname='jSelector'.$m[1]; … … 24 24 if($sel->isValid()) 25 25 return $sel; 26 }26 } 27 27 } 28 28 trigger_error (jLocale::get ('jelix~errors.selector.unknown', $id)); 29 29 $ret = null; 30 30 return $ret; 31 }31 } 32 32 } 33 33 … … 36 36 */ 37 37 interface jISelector { 38 public function getPath ();38 public function getPath (); 39 39 public function isValid(); 40 public function getCompiledFilePath ();40 public function getCompiledFilePath (); 41 41 public function getCompiler(); 42 42 public function useMultiSourceCompiler(); 43 public function toString($full=false);43 public function toString($full=false); 44 44 } 45 45 … … 48 48 */ 49 49 abstract class jSelectorModule implements jISelector { 50 public $type = '_module';51 public $module = null;52 public $resource = null;50 public $type = '_module'; 51 public $module = null; 52 public $resource = null; 53 53 54 54 private $_valid; … … 62 62 protected $_useMultiSourceCompiler=false; 63 63 64 function __construct($sel){64 function __construct($sel){ 65 65 66 66 if(preg_match("/^(([\w\.]+)~)?([\w\.]+)$/", $sel, $m)){ … … 78 78 } 79 79 80 }81 82 public function getPath (){80 } 81 82 public function getPath (){ 83 83 $this->_createPath(); 84 84 return $this->_path; 85 }85 } 86 86 87 87 public function isValid(){ … … 90 90 91 91 92 public function getCompiledFilePath (){92 public function getCompiledFilePath (){ 93 93 $this->_createCachePath(); 94 94 return $this->_cachePath; 95 }95 } 96 96 97 97 public function getCompiler(){ … … 106 106 } 107 107 108 public function toString($full=false){108 public function toString($full=false){ 109 109 if($full) 110 110 return $this->type.':'.$this->module.'~'.$this->resource; 111 111 else 112 112 return $this->module.'~'.$this->resource; 113 }113 } 114 114 115 115 protected function _createPath(){ … … 186 186 } 187 187 188 public function toString($full=false){ 189 if($full) 190 return $this->type.':'.$this->module.'~'.$this->resource.'@'.$this->request; 191 else 192 return $this->module.'~'.$this->resource.'@'.$this->request; 193 } 188 194 } 189 195 … … 372 378 */ 373 379 class jSelectorPlugin implements jISelector { 374 public $type = 'plug';380 public $type = 'plug'; 375 381 public $plugin=''; 376 382 public $file = ''; … … 378 384 private $_path; 379 385 380 function __construct($sel){386 function __construct($sel){ 381 387 global $gJConfig; 382 388 if(preg_match("/^([\w\.]+)~([\w\.]+)$/", $sel, $m)){ … … 391 397 $this->_valid=false; 392 398 } 393 }394 395 public function getPath (){399 } 400 401 public function getPath (){ 396 402 global $gJConfig; 397 403 if(isset($gJConfig->pluginsPathList[$this->plugin])){ … … 400 406 return ''; 401 407 } 402 }408 } 403 409 404 410 public function isValid(){ … … 406 412 } 407 413 408 public function toString($full=false){414 public function toString($full=false){ 409 415 if($full) 410 416 return $this->type.':'.$this->plugin.'~'.$this->file; 411 417 else 412 418 return $this->plugin.'~'.$this->file; 413 }419 } 414 420 415 421 public function getCompiler(){ return null;} 416 422 public function useMultiSourceCompiler() { return false;} 417 public function getCompiledFilePath (){ return '';}423 public function getCompiledFilePath (){ return '';} 418 424 419 425 } … … 427 433 */ 428 434 class jSelectorSimpleFile implements jISelector { 429 public $type = 'simplefile';435 public $type = 'simplefile'; 430 436 public $file = ''; 431 437 protected $_valid; … … 433 439 protected $_basePath=''; 434 440 435 function __construct($sel){441 function __construct($sel){ 436 442 if(preg_match("/^([\w\.\/]+)$/", $sel, $m)){ 437 443 $this->file = $m[1]; … … 441 447 $this->_valid = false; 442 448 } 443 }444 445 public function getPath (){449 } 450 451 public function getPath (){ 446 452 return $this->_path; 447 }453 } 448 454 449 455 public function isValid(){ … … 451 457 } 452 458 453 public function toString($full=false){459 public function toString($full=false){ 454 460 if($full) 455 461 return $this->type.':'.$this->file; 456 462 else 457 463 return $this->file; 458 }464 } 459 465 public function getCompiler(){ return null;} 460 466 public function useMultiSourceCompiler() { return false;} 461 public function getCompiledFilePath (){ return '';}467 public function getCompiledFilePath (){ return '';} 462 468 } 463 469 … … 467 473 function __construct($sel){ 468 474 $this->_basePath = JELIX_APP_VAR_PATH; 469 parent::_ construct($sel);475 parent::__construct($sel); 470 476 } 471 477 } … … 475 481 function __construct($sel){ 476 482 $this->_basePath = JELIX_APP_CONFIG_PATH; 477 parent::_ construct($sel);483 parent::__construct($sel); 478 484 } 479 485 } trunk/lib/jelix/core/url/jUrl.class.php
r50 r51 25 25 */ 26 26 public function parse($scriptNamePath, $params, $pathinfo ); 27 27 28 28 /** 29 29 * Modifie les donn� de l'url selon le type d'url propos�ar le moteur d'url … … 125 125 $urlobj->requestType = $gJCoord->request->type; 126 126 } 127 127 128 128 $engine = & self::getEngine(); 129 129 $engine->create($urlobj); // set path info … … 288 288 $file = JELIX_LIB_CORE_PATH.'url/jUrlEngine.'.$GLOBALS['gJConfig']->urlengine['engine'].'.class.php'; 289 289 if(!file_exists($file)){ 290 trigger_error("Url engine doesn't exist ",E_USER_ERROR);290 trigger_error("Url engine doesn't exist (".$GLOBALS['gJConfig']->urlengine['engine'].')',E_USER_ERROR); 291 291 return null; 292 292 } 293 293 include_once($file); 294 294 $cl='jUrlEngine'.$GLOBALS['gJConfig']->urlengine['engine']; 295 $engine = new $cl(); 295 $engine = new $cl(); 296 296 } 297 297 return $engine; trunk/lib/jelix/core/url/jUrlCompiler.significant.class.php
r50 r51 22 22 * Compilateur pour le moteur d'url significatifs 23 23 */ 24 class jUrlCompiler implements jISimpleCompiler{24 class jUrlCompilerSignificant implements jISimpleCompiler{ 25 25 26 26 public function compile($aSelector){ 27 27 global $gJCoord; 28 28 29 $sourceFile = $ selector->getPath();30 $cachefile = $ selector->getCompiledFilePath();29 $sourceFile = $aSelector->getPath(); 30 $cachefile = $aSelector->getCompiledFilePath(); 31 31 32 32 … … 81 81 $createUrlContent="<?php \n"; 82 82 $defaultEntrypoints=array(); 83 $file = new jFile(); 83 84 foreach($xml->children() as $name=>$tag){ 84 85 if(!preg_match("/^(.*)EntryPoint$/", $name,$m)){ … … 89 90 $entryPoint = (string)$tag['name']; 90 91 $isDefault = (isset($tag['default']) ? (((string)$tag['default']) == 'true'):false); 91 $parseInfos = array($isDefault); 92 92 $parseInfos = array($isDefault); 93 93 94 if($isDefault){ 94 $createUrlInfos['@'.$requestType]=array(2,$entryPoint); 95 $createUrlInfos['@'.$requestType]=array(2,$entryPoint); 95 96 } 96 97 97 98 98 99 $parseContent = "<?php \n"; 99 100 foreach($tag->url as $url){ 100 101 $module = (string)$url['module']; 101 102 // dans le cas d'un point d'entr�qui est celui par defaut pour le type de requete indiqu� // si il y a juste un module indiqu�lors on sait que toutes les actions 102 103 // dans le cas d'un point d'entr�qui est celui par defaut pour le type de requete indiqu� // si il y a juste un module indiqu�lors on sait que toutes les actions 103 104 // concernant ce module passeront par ce point d'entr� 104 if($isDefault && !isset($url['action']) && !isset($url['handler'])){ 105 if($isDefault && !isset($url['action']) && !isset($url['handler'])){ 105 106 $parseInfos[]=array($module, '', '.*', array(), array(), array() ); 106 107 $createUrlInfos[$module.'~@'.$requestType] = array(2,$entryPoint); 107 108 continue; 108 109 } 109 110 110 111 $action = (string)$url['action']; 111 112 112 113 // si il y a un handler indiqu�on sait alors que pour le module et action indiqu� // il faut passer par cette classe handler pour le parsing et la creation de l'url 113 114 if(isset($url['handler'])){ 114 115 $class = (string)$url['handler']; 115 116 $parseInfos[]=array($module, $action, $class ); 116 $s= new jSelectorUrlHandler($module.'~'.$action) 117 $s= new jSelectorUrlHandler($module.'~'.$action); 117 118 $createUrlContent.="include_once('".$s->getPath()."');\n"; 118 119 $createUrlInfos[$module.'~'.$action.'@'.$requestType] = array(0,$entryPoint, $class); 119 120 continue; 120 121 } 121 122 122 123 $listparam=array(); 123 124 $escapes = array(); … … 125 126 $path = (string)$url['path']; 126 127 $regexppath = $path; 127 128 128 129 if(preg_match_all("/\:([a-zA-Z]+)/",$path,$m, PREG_PATTERN_ORDER)){ 129 130 $listparam=$m[1]; 130 131 131 132 foreach($url->var as $var){ 132 133 133 134 $nom = (string) $var['name']; 134 135 $k = array_search($nom, $listparam); … … 137 138 continue; 138 139 } 139 140 140 141 if (isset ($var['escape'])){ 141 142 $escapes[$k] = (((string)$var['escape']) == 'true'); … … 143 144 $escapes[$k] = false; 144 145 } 145 146 146 147 if (isset ($var['regexp'])){ 147 148 $regexp = '('.(string)$var['regexp'].')'; … … 149 150 $regexp = '([^\/]+)'; 150 151 } 151 152 152 153 $regexppath = str_replace(':'.$name, $regexp, $regexppath); 153 154 } … … 164 165 $createUrlInfos[$module.'~'.$action.'@'.$requestType] = array(1,$entryPoint, $listparam, $escapes,$path); 165 166 } 166 167 $parseContent.='$PARSE_URL_INFOS = '.var_export($parseInfos, true).";\n?>"; 168 file_put_contents(JELIX_APP_CONFIG_PATH.'urls/'.$entryPoint.'.entrypoint.php',$parseContent); 167 168 $parseContent.='$GLOBALS[\'SIGNIFICANT_PARSEURL\'] = '.var_export($parseInfos, true).";\n?>"; 169 170 $file->write(JELIX_APP_TEMP_PATH.'compiled/urlsig/'.rawurlencode($entryPoint).'.entrypoint.php',$parseContent); 169 171 } 170 $createUrlContent .='$ CREATE_URL_INFOS='.var_export($createUrlInfos, true).";\n?>";171 file_put_contents(JELIX_APP_CONFIG_PATH.'urls/creationinfos.php',$createUrlContent);172 $createUrlContent .='$GLOBALS[\'SIGNIFICANT_CREATEURL\'] ='.var_export($createUrlInfos, true).";\n?>"; 173 $file->write(JELIX_APP_TEMP_PATH.'compiled/urlsig/creationinfos.php',$createUrlContent); 172 174 } 173 175 trunk/lib/jelix/core/url/jUrlEngine.significant.class.php
r50 r51 1 1 <?php 2 2 /** 3 * @package copix 4 * @subpackage plugins 5 * @version $Id: CopixUrlEngine.significant.class.php,v 1.1.2.1 2005/08/17 22:12:50 laurentj Exp $ 6 * @author Laurent Jouanneau 7 * @copyright 2001-2005 CopixTeam 8 * @link http://copix.aston.fr 9 * @link http://copix.org 10 * @licence http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file 3 * @package jelix 4 * @subpackage core 5 * @version $Id$ 6 * @author Jouanneau Laurent 7 * @contributor 8 * @copyright 2005-2006 Jouanneau laurent 9 * @link http://www.jelix.org 10 * @licence GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 11 * 12 * Some parts of this file are took from an experimental version of Copix Framework v2.3dev20050901, 13 * CopixUrlEngine.significant.class.php, 14 * copyrighted by CopixTeam and released under GNU Lesser General Public Licence 15 * author : Laurent Jouanneau 16 * http://www.copix.org 11 17 */ 12 18 13 19 14 class CopixUrlEngineSignificant extends CopixUrlEngine { 15 16 /** 17 * liste des donn� pour la cr�ion des urls (voir structure plus loin) 18 */ 19 var $dataCreateUrl = array(); 20 21 /** 22 * liste des donn� pour l'analyse des urls 23 */ 24 var $dataParseUrl = array(); 25 26 function CopixUrlEngineSignificant(){ 27 28 $this->coordination = & $GLOBALS['COPIX']['COORD']; 29 $this->config = & $GLOBALS['COPIX']['CONFIG']; 30 $cplCfg = CopixInclude::SIGNIFICANTURL(); 31 32 // on change le nom de fichier de compil car on n'a pas moyen de savoir si 33 // la config copix a � chang�(disons que CopixInclude n'est pour le moment 34 // pas pr� pour v�fier �a fois le fichier de conf, et �a fois les fichiers 35 // de chaque module 36 // @todo am�orer CopixInclude sur ce point ? 37 $cplCfg[2]='significant.'.md5($this->config->url_default_entrypoint.serialize($this->config->url_specific_entrypoints)).'.php'; 38 // charger ici les donn� sur les urls 39 $rv = CopixInclude::includeCacheFile($cplCfg); 40 41 $this->dataParseUrl = & $GLOBALS['SIGNIFICANT_PARSEURL']; 42 $this->dataCreateUrl = & $GLOBALS['SIGNIFICANT_CREATEURL']; 43 } 44 45 /** 46 * 47 */ 48 function parse($scriptNamePath, $params, $pathinfo ){ 49 $url = new CopixUrl($scriptNamePath, $params, $pathinfo); 50 51 if ($this->config->url_enable_parser){ 52 $urloriginal = new CopixUrl($scriptNamePath, $params, $pathinfo); 53 if(!$this->_parse(&$url)){ 54 $url=$urloriginal; 55 } 56 } 57 return $url; 58 } 59 60 function _parse(&$url){ 61 62 $script = $url->scriptName; 63 64 if(strpos($script, $this->config->url_entrypoint_extension) !== false){ 65 $script=substr($script,0,- (strlen($this->config->url_entrypoint_extension))); 66 } 67 if(substr($url->pathInfo,-1) == '/' && $url->pathInfo != '/'){ 68 $pathinfo = substr($url->pathInfo,0,-1); 69 }else{ 70 $pathinfo = $url->pathInfo; 71 } 72 $foundurl = false; 73 74 if(isset($this->dataParseUrl[$script])){ 75 foreach($this->dataParseUrl[$script] as $mod=>$moduleinfoparsing){ 76 foreach($moduleinfoparsing as $infoparsing){ 77 78 $url->params['module']=$infoparsing[0]; 79 $url->params['desc']=$infoparsing[1]; 80 $url->params['action']=$infoparsing[2]; 81 82 if($infoparsing[3]=== false){ 83 // on a un tableau du style 84 // array( 0=> 'module', 1=>'desc', 2=>'action', 3=>false,4=>'handler') 85 $cl = $infoparsing[4]; 86 $handler = new $cl(); 87 if($handler->parse($url)){ 88 $foundurl=true; 89 break; 90 } 91 }else{ 92 // on a un tableau du style 93 /* 94 array( 0=> 'module', 1=>'desc', 2=>'action', 3=>'pathinfo', 95 4=>array('annee','mois'), // tableau des valeurs dynamiques, class� par ordre croissant 96 5=>array(true, false), 97 6=>array('bla'=>'cequejeveux' ) // tableau des valeurs statiques 98 ) 99 */ 100 if(preg_match ($infoparsing[3], $pathinfo, $matches)){ 101 102 // on fusionne les parametres statiques 103 if ($infoparsing[6]){ 104 $url->params = array_merge ($url->params, $infoparsing[6]); 105 } 106 107 if(count($matches)){ 108 foreach($infoparsing[4] as $k=>$name){ 109 if(isset($matches[$k+1])){ 110 if($infoparsing[5][$k]){ 111 $url->params[$name] = CopixUrl::unescape($matches[$k+1]); 112 }else{ 113 $url->params[$name] = $matches[$k+1]; 114 } 115 } 116 } 117 } 118 $foundurl = true; 119 break; 120 } 20 class jSelectorUrlCfgSig extends jSelectorCfg { 21 public $type = 'urlcfgsig'; 22 23 public function getCompiler(){ 24 require_once(JELIX_LIB_CORE_PATH.'url/jUrlCompiler.significant.class.php'); 25 $o = new jUrlCompilerSignificant(); 26 return $o; 27 } 28 public function getCompiledFilePath (){ return JELIX_APP_TEMP_PATH.'compiled/urlsig/creationinfos.php';} 29 } 30 31 class jUrlEngineSignificant implements jIUrlEngine { 32 33 /** 34 * liste des donn� pour la cr�ion des urls (voir structure plus loin) 35 */ 36 var $dataCreateUrl = null; 37 38 /** 39 * liste des donn� pour l'analyse des urls 40 */ 41 var $dataParseUrl = null; 42 43 /** 44 * 45 */ 46 public function parse($scriptNamePath, $params, $pathinfo ){ 47 48 $url = new jUrl($scriptNamePath, $params, $pathinfo); 49 50 if ($GLOBALS['gJConfig']->urlengine['enable_parser']){ 51 $sel = new jSelectorUrlCfgSig('urls.xml'); 52 jIncluder::inc($sel); 53 require_once(JELIX_APP_TEMP_PATH.'compiled/urlsig/'.rawurlencode($scriptNamePath).'.entrypoint.php'); 54 $this->dataCreateUrl = & $GLOBALS['SIGNIFICANT_CREATEURL']; 55 $this->dataParseUrl = & $GLOBALS['SIGNIFICANT_PARSEURL']; 56 57 if(!$this->_parse($url)){ 58 $url= new jUrl($scriptNamePath, $params, $pathinfo); 59 } 60 } 61 return $url; 62 } 63 64 protected function _parse($url){ 65 global $gJConfig; 66 /*$script = $url->scriptName; 67 if(strpos($script, $gJConfig->urlengine['entrypoint_extension']) !== false){ 68 $script=substr($script,0,- (strlen($gJConfig->urlengine['entrypoint_extension']))); 69 }*/ 70 if(substr($url->pathInfo,-1) == '/' && $url->pathInfo != '/'){ 71 $pathinfo = substr($url->pathInfo,0,-1); 72 }else{ 73 $pathinfo = $url->pathInfo; 74 } 75 76 $foundurl = false; 77 $isDefault = false; 78 foreach($this->dataParseUrl as $k=>$infoparsing){ 79 if($k==0){ 80 $isDefault = $infoparsing; 81 continue; 82 } 83 84 $url->params['module']=$infoparsing[0]; 85 $url->params['action']=$infoparsing[1]; 86 87 if(count($infoparsing < 4)){ 88 // on a un tableau du style 89 // array( 0=> 'module', 1=>'action', 2=>'handler') 90 $cl = $infoparsing[2]; 91 $handler = new $cl(); 92 if($handler->parse($url)){ 93 $foundurl=true; 94 break; 95 } 96 }else{ 97 /* on a un tableau du style 98 array( 0=>'module', 1=>'action', 2=>'regexp_pathinfo', 99 3=>array('annee','mois'), // tableau des valeurs dynamiques, class� par ordre croissant 100 4=>array(true, false), // tableau des valeurs escapes 101 5=>array('bla'=>'cequejeveux' ) // tableau des valeurs statiques 102 */ 103 if(preg_match ($infoparsing[2], $pathinfo, $matches)){ 104 105 // on fusionne les parametres statiques 106 if ($infoparsing[5]){ 107 $url->params = array_merge ($url->params, $infoparsing[5]); 108 } 109 110 if(count($matches)){ 111 array_shift($matches); 112 foreach($infoparsing[3] as $k=>$name){ 113 if(isset($matches[$k])){ 114 if($infoparsing[4][$k]){ 115 $url->params[$name] = jUrl::unescape($matches[$k]); 116 }else{ 117 $url->params[$name] = $matches[$k]; 118 } 119 } 121 120 } 122 121 } 123 if($foundurl) 124 break; 125 } 126 } 127 128 if(!$foundurl){ 129 $url->pathInfo=''; 130 $url->params = $url->getDest($this->config->url_404notfound_dest); 131 $foundurl = true; 132 } 133 134 return $foundurl; 135 } 136 137 138 /** 139 * @param CopixUrl $url url �odifier 140 */ 141 function create( &$url){ 142 143 /* 144 a) recupere module|desc|action -> obtient les infos pour la creation de l'url 145 b) r�p� un �n les parametres indiqu�dans params �artir de CopixUrl 146 c) remplace la valeur r�p�e dans le result et supprime le param�e de l'url 147 d) remplace scriptname de CopixUrl par le resultat 148 */ 149 150 $module = $url->getParam ('module'); 151 if($module === null) 152 $module = CopixContext::get(); 153 if($module == '') 154 $module='_'; 155 156 $desc= $url->getParam('desc',COPIX_DEFAULT_VALUE_DESC); 157 $action = $url->getParam('action',COPIX_DEFAULT_VALUE_ACTION); 158 159 $id = $module.'|'.$desc.'|'.$action; 160 161 $urlinfo = null; 162 if (isset ($this->dataCreateUrl [$id])){ 163 122 $foundurl = true; 123 break; 124 } 125 } 126 } 127 if(!$foundurl && !$isDefault){ 128 $url->pathInfo=''; 129 $url->params = $url->getAction($gJConfig->urlengine['notfound_act']); 130 $foundurl = true; 131 } 132 133 return ($isDefault?true:$foundurl); 134 } 135 136 137 /** 138 * @param jUrl $url url �odifier 139 */ 140 public function create( &$url){ 141 if($this->dataCreateUrl == null){ 142 $sel = new jSelectorUrlCfgSig('urls.xml'); 143 jIncluder::inc($sel); 144 $this->dataCreateUrl = & $GLOBALS['SIGNIFICANT_CREATEURL']; 145 } 146 /* 147 a) recupere module~action@request -> obtient les infos pour la creation de l'url 148 b) r�p� un �n les parametres indiqu�dans params �artir de jUrl 149 c) remplace la valeur r�p�e dans le result et supprime le param�e de l'url 150 d) remplace scriptname de jUrl par le resultat 151 */ 152 153 $module = $url->getParam ('module', jContext::get()); 154 $action = $url->getParam('action'); 155 156 $id = $module.'~'.$action.'@'.$url->requestType; 157 $urlinfo = null; 158 if (isset ($this->dataCreateUrl [$id])){ 159 $urlinfo = &$this->dataCreateUrl[$id]; 160 $url->delParam('module'); 161 $url->delParam('action'); 162 }else{ 163 $id = $module.'~@'.$url->requestType; 164 if (isset ($this->dataCreateUrl [$id])){ 165 $urlinfo = &$this->dataCreateUrl[$id]; 164 166 $url->delParam('module'); 165 $url->delParam('desc'); 166 $url->delParam('action'); 167 $urlinfo = &$this->dataCreateUrl[$id]; 168 169 if($urlinfo[0]===false){ 170 $cl = $urlinfo[1]; 171 $handler = new $cl(); 172 $handler->create($url); 173 }else{ 174 $dturl = & $urlinfo[0]; 175 $result = $urlinfo[2]; 176 foreach ($dturl as $k=>$param){ 177 if($urlinfo[1][$k]){ 178 $result=str_replace('%'.($k+1), CopixUrl::escape($url->getParam($param,''),true), $result); 179 }else{ 180 $result=str_replace('%'.($k+1), $url->getParam($param,''), $result); 181 } 182 $url->delParam($param); 183 } 184 185 $url->pathInfo = $result; 186 } 187 } 188 189 } 167 }else{ 168 $id = '@'.$url->requestType; 169 if (isset ($this->dataCreateUrl [$id])){ 170 $urlinfo = &$this->dataCreateUrl[$id]; 171 } 172 } 173 } 174 175 if($urlinfo != null){ 176 /*array( 177 'news~show@classic' => 178 array(0,'entrypoint','handler') 179 ou 180 array(1,'entrypoint', 181 array('annee','mois','jour','id','titre'), // liste des param�es de l'url �rendre en compte 182 array(true, false..), // valeur des escapes 183 "/news/%1/%2/%3/%4-%5", // forme de l'url 184 ) 185 ou 186 array(2,'entrypoint'); pour les cl�du type "@request" ou "module~@request" 187 */ 188 189 $url->scriptName = $urlinfo[1]; 190 191 if($urlinfo[0]==0){ 192 $cl = $urlinfo[1]; 193 $handler = new $cl(); 194 $handler->create($url); 195 }elseif($urlinfo[0]==1){ 196 $result = $urlinfo[4]; 197 foreach ($urlinfo[2] as $k=>$param){ 198 if($urlinfo[3][$k]){ 199 $result=str_replace('%'.($k+1), jUrl::escape($url->getParam($param,''),true), $result); 200 }else{ 201 $result=str_replace('%'.($k+1), $url->getParam($param,''), $result); 202 } 203 $url->delParam($param); 204 } 205 206 $url->pathInfo = $result; 207 } 208 } 209 } 190 210 } 191 211 ?> trunk/lib/jelix/core/url/jUrlEngine.simple.class.php
r50 r51 9 9 * @link http://www.jelix.org 10 10 * @licence GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 11 *12 11 */ 13 12 … … 25 24 $url->scriptName = $this->getScript($url->requestType, $url->getParam('module'),$url->getParam('action')); 26 25 } 27 26 28 27 protected function getScript($requestType, $module=null, $action=null, $nosuffix=false){ 29 28 static $urlspe = null; … … 32 31 $script = $gJConfig->urlengine['default_entrypoint']; 33 32 34 if(count($gJConfig-> urlengine_specific_entrypoints)){33 if(count($gJConfig->simple_urlengine_entrypoints)){ 35 34 if($urlspe == null){ 36 35 $urlspe = array(); 37 foreach($gJConfig-> urlengine_specific_entrypoints as $entrypoint=>$sel){36 foreach($gJConfig->simple_urlengine_entrypoints as $entrypoint=>$sel){ 38 37 $selectors = preg_split("/[\s,]+/", $sel); 39 38 foreach($selectors as $sel){ trunk/lib/jelix/init.php
r45 r51 11 11
