Changeset 1064
- Timestamp:
- 08/26/08 12:42:46 (3 months ago)
- Files:
-
- trunk/build/manifests/jelix-lib.mn (modified) (1 diff)
- trunk/lib/jelix-scripts/templates/var/config/defaultconfig.ini.php.tpl (modified) (2 diffs)
- trunk/lib/jelix/core/defaultconfig.ini.php (modified) (3 diffs)
- trunk/lib/jelix/plugins/urls/basic_significant (added)
- trunk/lib/jelix/plugins/urls/basic_significant/basic_significant.urls.php (added)
- trunk/lib/jelix/plugins/urls/simple/simple.urls.php (modified) (3 diffs)
- trunk/testapp/modules/jelix_tests/tests/core.urls_generation.html.php (modified) (1 diff)
- trunk/testapp/modules/jelix_tests/tests/core.urls_parsing.html_cli.php (modified) (1 diff)
- trunk/testapp/var/config/defaultconfig.ini.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/build/manifests/jelix-lib.mn
r1053 r1064 484 484 * jSignificantUrlsCompiler.class.php 485 485 * significant.urls.php 486 486 487 cd lib/jelix/plugins/urls/simple 487 488 simple.urls.php 489 490 cd lib/jelix/plugins/urls/basic_significant 491 basic_significant.urls.php 492 488 493 489 494 cd lib/jelix-www/design trunk/lib/jelix-scripts/templates/var/config/defaultconfig.ini.php.tpl
r886 r1064 88 88 ;notfoundAct = "jelix~error:notfound" 89 89 90 ; liste des actions requerant https (syntaxe expliquée dessous), pour le moteur d'url simple 90 ; list of actions which require https protocol for the simple url engine 91 ; syntax of the list is the same as explained in the simple_urlengine_entrypoints 91 92 simple_urlengine_https = 92 93 94 [simple_urlengine_entrypoints] 95 ; parameters for the simple url engine. This is the list of entry points 96 ; with list of actions attached to each entry points 93 97 94 [simple_urlengine_entrypoints] 95 ; paramètres pour le moteur d'url simple : liste des points d'entrées avec les actions 96 ; qui y sont rattachées 97 98 99 ; nom_script_sans_suffix = "liste de selecteur d'action séparé par un espace" 100 ; selecteurs : 101 ; m~a@r -> pour action "a" du module "m" répondant au type de requete "r" 102 ; m~*@r -> pour toute action du module "m" répondant au type de requete "r" 103 ; @r -> toute action de tout module répondant au type de requete "r" 98 ; script_name_without_suffix = "list of action selectors separated by a space" 99 ; selector syntax : 100 ; m~a@r -> for the action "a" of the module "m" and for the request of type "r" 101 ; m~*@r -> for all actions of the module "m" and for the request of type "r" 102 ; @r -> for all actions for the request of type "r" 104 103 105 104 index = "@classic" … … 109 108 110 109 110 [basic_significant_urlengine_entrypoints] 111 ; for each entry point, it indicates if the entry point name 112 ; should be include in the url or not 113 index = on 114 xmlrpc = on 115 jsonrpc = on 116 rdf = on 117 111 118 [logfiles] 112 119 default=messages.log 113 114 120 115 121 [mailer] trunk/lib/jelix/core/defaultconfig.ini.php
r1058 r1064 154 154 ;notfoundAct = "jelix~error:notfound" 155 155 156 ; liste des actions requerant https (syntaxe expliquée dessous), pour le moteur d'url simple 156 ; list of actions which require https protocol for the simple url engine 157 ; syntax of the list is the same as explained in the simple_urlengine_entrypoints 157 158 simple_urlengine_https = 158 159 … … 160 161 161 162 [simple_urlengine_entrypoints] 162 ; paramètres pour le moteur d'url simple : liste des points d'entrées avec les actions 163 ; qui y sont rattachées 164 165 166 ; nom_script_sans_suffix = "liste de selecteur d'action séparé par un espace" 167 ; selecteurs : 168 ; m~a@r -> pour action "a" du module "m" répondant au type de requete "r" 169 ; m~*@r -> pour toute action du module "m" répondant au type de requete "r" 170 ; @r -> toute action de tout module répondant au type de requete "r" 163 ; parameters for the simple url engine. This is the list of entry points 164 ; with list of actions attached to each entry points 165 166 ; script_name_without_suffix = "list of action selectors separated by a space" 167 ; selector syntax : 168 ; m~a@r -> for the action "a" of the module "m" and for the request of type "r" 169 ; m~*@r -> for all actions of the module "m" and for the request of type "r" 170 ; @r -> for all actions for the request of type "r" 171 171 172 172 index = "@classic" … … 175 175 rdf = "@rdf" 176 176 177 [basic_significant_urlengine_entrypoints] 178 ; for each entry point, it indicates if the entry point name 179 ; should be include in the url or not 180 index = on 181 xmlrpc = on 182 jsonrpc = on 183 rdf = on 177 184 178 185 [logfiles] trunk/lib/jelix/plugins/urls/simple/simple.urls.php
r1026 r1064 43 43 */ 44 44 public function create($urlact){ 45 global $gJConfig; 46 $m = $urlact->getParam('module'); 47 $a = $urlact->getParam('action'); 45 48 46 $scriptName = $this->getScript($urlact->requestType, $urlact->getParam('module'),$urlact->getParam('action')); 47 $url = new jUrl($scriptName, $urlact->params, ''); 48 // pour certains types de requete, les paramètres ne sont pas dans l'url 49 // donc on les supprime 50 // c'est un peu crade de faire ça en dur ici, mais ce serait lourdingue 51 // de charger la classe request pour savoir si on peut supprimer ou pas 52 if(in_array($urlact->requestType ,array('xmlrpc','jsonrpc','soap'))) 53 $url->clearParam(); 49 $scriptName = $this->getBasePath($urlact->requestType, $m, $a); 50 $scriptName .= $this->getScript($urlact->requestType, $m, $a); 54 51 55 return $url; 52 if(!$gJConfig->urlengine['multiview']){ 53 $scriptName.=$gJConfig->urlengine['entrypointExtension']; 54 } 55 56 $url = new jUrl($scriptName, $urlact->params, ''); 57 // pour certains types de requete, les paramètres ne sont pas dans l'url 58 // donc on les supprime 59 // c'est un peu crade de faire ça en dur ici, mais ce serait lourdingue 60 // de charger la classe request pour savoir si on peut supprimer ou pas 61 if(in_array($urlact->requestType ,array('xmlrpc','jsonrpc','soap'))) 62 $url->clearParam(); 63 64 return $url; 56 65 } 66 67 /** 68 * read the configuration and return an url part according of the 69 * of the https configuration 70 * @param string $requestType 71 * @param string $module 72 * @param string $action 73 */ 74 protected function getBasePath($requestType, $module=null, $action=null) { 75 global $gJConfig; 76 if($this->urlhttps == null){ 77 $this->urlhttps=array(); 78 $selectors = preg_split("/[\s,]+/", $gJConfig->urlengine['simple_urlengine_https']); 79 foreach($selectors as $sel2){ 80 $this->urlhttps[$sel2]= true; 81 } 82 } 83 84 $usehttps= false; 85 if (count($this->urlhttps)) { 86 if($action && isset($this->urlhttps[$module.'~'.$action.'@'.$requestType])){ 87 $usehttps = true; 88 }elseif($module && isset($this->urlhttps[$module.'~*@'.$requestType])){ 89 $usehttps = true; 90 }elseif(isset($this->urlhttps['@'.$requestType])){ 91 $usehttps = true; 92 } 93 } 94 95 if ($usehttps) 96 return 'https://'.$_SERVER['HTTP_HOST'].$gJConfig->urlengine['basePath']; 97 else 98 return $gJConfig->urlengine['basePath']; 99 } 100 57 101 58 102 /** … … 66 110 67 111 $script = $gJConfig->urlengine['defaultEntrypoint']; 68 69 if($this->urlhttps == null){70 $this->urlhttps=array();71 $selectors = preg_split("/[\s,]+/", $gJConfig->urlengine['simple_urlengine_https']);72 foreach($selectors as $sel2){73 $this->urlhttps[$sel2]= true;74 }75 }76 77 $usehttps= false;78 if($action && isset($this->urlhttps[$module.'~'.$action.'@'.$requestType])){79 $usehttps = true;80 }elseif($module && isset($this->urlhttps[$module.'~*@'.$requestType])){81 $usehttps = true;82 }elseif(isset($this->urlhttps['@'.$requestType])){83 $usehttps = true;84 }85 112 86 113 if(count($gJConfig->simple_urlengine_entrypoints)){ … … 103 130 } 104 131 } 105 if(!$gJConfig->urlengine['multiview']){106 $script.=$gJConfig->urlengine['entrypointExtension'];107 }108 132 109 if($usehttps){ 110 return 'https://'.$_SERVER['HTTP_HOST'].$gJConfig->urlengine['basePath'].$script; 111 }else{ 112 return $gJConfig->urlengine['basePath'].$script; 113 } 133 return $script; 114 134 } 115 135 } trunk/testapp/modules/jelix_tests/tests/core.urls_generation.html.php
r960 r1064 349 349 } 350 350 351 function testBasicSignificantEngine() { 352 global $gJConfig, $gJCoord; 353 354 $gJCoord->request->urlScriptPath='/'; 355 $gJCoord->request->params=array(); 356 //$gJCoord->request->type=; 357 $gJConfig->urlengine = array( 358 'engine'=>'basic_significant', 359 'enableParser'=>true, 360 'multiview'=>false, 361 'basePath'=>'/', 362 'defaultEntrypoint'=>'index', 363 'entrypointExtension'=>'.php', 364 'notfoundAct'=>'jelix~error:notfound', 365 'simple_urlengine_https'=>'jelix_tests~urlsig:url8@classic @xmlrpc', 366 'significantFile'=>'urls.xml', 367 ); 368 369 jUrl::getEngine(true); // on recharge le nouveau moteur d'url 370 371 $urlList=array(); 372 $urlList[]= array('urlsig:url1', array('mois'=>'10', 'annee'=>'2005', 'id'=>'35')); 373 $urlList[]= array('urlsig:url2', array('mois'=>'05', 'annee'=>'2004')); 374 $urlList[]= array('jelix_tests~urlsig:url3', array('rubrique'=>'actualite', 'id_art'=>'65', 'article'=>'c\'est la fête au village')); 375 $urlList[]= array('jelix_tests~urlsig:url4', array('first'=>'premier', 'second'=>'deuxieme')); 376 // celle ci n'a pas de définition dans urls.xml *exprés* 377 $urlList[]= array('urlsig:url5', array('foo'=>'oof', 'bar'=>'rab')); 378 $urlList[]= array('jelix~bar@xmlrpc', array('aaa'=>'bbb')); 379 $urlList[]= array('jelix_tests~urlsig:url8', array('rubrique'=>'vetements', 'id_article'=>'98')); 380 $urlList[]= array('jelix_tests~default:index', array('rubrique'=>'vetements', 'id_article'=>'98')); 381 $urlList[]= array('jelix_tests~urlsig:index', array('rubrique'=>'vetements', 'id_article'=>'98')); 382 383 $trueResult=array( 384 "/index.php/jelix_tests/urlsig/url1?mois=10&annee=2005&id=35", 385 "/jelix_tests/urlsig/url2?mois=05&annee=2004", 386 "/jelix_tests/urlsig/url3?rubrique=actualite&id_art=65&article=c%27est+la+f%C3%AAte+au+village", 387 "/foo/bar.php/jelix_tests/urlsig/url4?first=premier&second=deuxieme", 388 "/index.php/jelix_tests/urlsig/url5?foo=oof&bar=rab", 389 "/xmlrpc.php", 390 "/index.php/jelix_tests/urlsig/url8?rubrique=vetements&id_article=98", 391 "/index.php/jelix_tests/?rubrique=vetements&id_article=98", 392 "/index.php/jelix_tests/urlsig/?rubrique=vetements&id_article=98", 393 ); 394 395 396 $trueResult[5]='https://'.$_SERVER['HTTP_HOST'].$trueResult[5]; 397 $trueResult[6]='https://'.$_SERVER['HTTP_HOST'].$trueResult[6]; 398 $this->_doCompareUrl("simple, multiview = false", $urlList,$trueResult); 399 400 $gJConfig->urlengine['multiview']=true; 401 jUrl::getEngine(true); // on recharge le nouveau moteur d'url 402 $trueResult=array( 403 "/index/jelix_tests/urlsig/url1?mois=10&annee=2005&id=35", 404 "/jelix_tests/urlsig/url2?mois=05&annee=2004", 405 "/jelix_tests/urlsig/url3?rubrique=actualite&id_art=65&article=c%27est+la+f%C3%AAte+au+village", 406 "/foo/bar/jelix_tests/urlsig/url4?first=premier&second=deuxieme", 407 "/index/jelix_tests/urlsig/url5?foo=oof&bar=rab", 408 "/xmlrpc", 409 "/index/jelix_tests/urlsig/url8?rubrique=vetements&id_article=98", 410 "/index/jelix_tests/?rubrique=vetements&id_article=98", 411 "/index/jelix_tests/urlsig/?rubrique=vetements&id_article=98", 412 ); 413 $trueResult[5]='https://'.$_SERVER['HTTP_HOST'].$trueResult[5]; 414 $trueResult[6]='https://'.$_SERVER['HTTP_HOST'].$trueResult[6]; 415 $this->_doCompareUrl("simple, multiview = true", $urlList,$trueResult); 416 } 417 418 419 420 function testBasciSignificantEngineError(){ 421 global $gJConfig, $gJCoord; 422 423 $gJCoord->request->urlScriptPath='/'; 424 $gJCoord->request->params=array(); 425 //$gJCoord->request->type=; 426 $gJConfig->urlengine = array( 427 'engine'=>'basic_significant', 428 'enableParser'=>true, 429 'multiview'=>false, 430 'basePath'=>'/', 431 'defaultEntrypoint'=>'index', 432 'entrypointExtension'=>'.php', 433 'notfoundAct'=>'jelix~notfound', 434 'simple_urlengine_https'=>'jelix_tests~urlsig:url8@classic @xmlrpc', 435 'significantFile'=>'urls.xml', 436 ); 437 438 $urlList=array(); 439 $urlList[]= array('foo~bar@xmlrpc', array('aaa'=>'bbb')); 440 441 $trueResult=array( 442 // type exception : 0 Exception, 1 jException, 2 jExceptionSelector 443 // code 444 // local key 445 array(2,11,'jelix~errors.selector.invalid.target'), 446 ); 447 448 $this->_doCompareError("simple, errors, multiview = false", $urlList,$trueResult); 449 450 $gJConfig->urlengine['multiview']=true; 451 $trueResult=array( 452 array(2,11,'jelix~errors.selector.invalid.target'), 453 ); 454 $this->_doCompareError("simple, errors multiview = true", $urlList,$trueResult); 455 } 456 457 458 459 351 460 } 352 461 ?> trunk/testapp/modules/jelix_tests/tests/core.urls_parsing.html_cli.php
r960 r1064 158 158 159 159 } 160 161 162 function testBasicSignificantEngine() { 163 global $gJConfig, $gJCoord; 164 165 $gJCoord->request->urlScriptPath='/'; 166 $gJCoord->request->params=array(); 167 //$gJCoord->request->type=; 168 $gJConfig->urlengine = array( 169 'engine'=>'basic_significant', 170 'enableParser'=>true, 171 'multiview'=>false, 172 'basePath'=>'/', 173 'defaultEntrypoint'=>'index', 174 'entrypointExtension'=>'.php', 175 'notfoundAct'=>'jelix~notfound', 176 'significantFile'=>'urls.xml', 177 ); 178 179 jUrl::getEngine(true); // on recharge le nouveau moteur d'url 180 181 $resultList=array(); 182 $resultList[]= array('module'=>'jelix_tests', 'action'=>'urlsig:url1', 'mois'=>'10', 'annee'=>'2005', 'id'=>'35'); 183 $resultList[]= array('module'=>'jelix_tests', 'action'=>'urlsig:url2', 'mois'=>'05', 'annee'=>'2004'); 184 $resultList[]= array('module'=>'jelix_tests', 'action'=>'urlsig:url3', 'rubrique'=>'actualite', 'id_art'=>'65', 'article'=>'c\'est la fete au village'); 185 $resultList[]= array('module'=>'jelix_tests', 'action'=>'urlsig:url4', 'first'=>'premier', 'second'=>'deuxieme'); 186 $resultList[]= array(); 187 $resultList[]= array('module'=>'news', 'action'=>'main:bar', 'aaa'=>'bbb'); 188 $resultList[]= array('module'=>'jelix_tests', 'action'=>'urlsig:url5', 'foo'=>'oof', 'bar'=>'rab'); 189 190 $resultList[]= array('module'=>'jelix_tests', 'action'=>'urlsig:url8', 'rubrique'=>'vetements', 'id_article'=>'98'); 191 $resultList[]= array('module'=>'jelix_tests', 'action'=>'default:index', 'rubrique'=>'vetements', 'id_article'=>'98'); 192 $resultList[]= array('module'=>'jelix_tests', 'action'=>'urlsig:index', 'rubrique'=>'vetements', 'id_article'=>'98'); 193 194 $request=array( 195 array("index.php","/jelix_tests/urlsig/url1",array('mois'=>'10', 'annee'=>'2005', 'id'=>'35')), 196 array("testnews.php","/jelix_tests/urlsig/url2",array('mois'=>'05', 'annee'=>'2004')), 197 array("testnews.php","/jelix_tests/urlsig/url3",array('rubrique'=>'actualite', 'id_art'=>'65', 'article'=>'c\'est la fete au village')), 198 array("foo/bar.php","/jelix_tests/urlsig/url4",array('first'=>'premier', 'second'=>'deuxieme')), 199 array("xmlrpc.php","",array()), 200 array("news.php","/news/main/bar",array('aaa'=>'bbb')), 201 array("index.php","/jelix_tests/urlsig/url5",array('foo'=>'oof', 'bar'=>'rab')), 202 array("index.php","/jelix_tests/urlsig/url8",array('rubrique'=>'vetements', 'id_article'=>'98')), 203 array("index.php","/jelix_tests/",array('rubrique'=>'vetements', 'id_article'=>'98')), 204 array("index.php","/jelix_tests/urlsig/",array('rubrique'=>'vetements', 'id_article'=>'98')), 205 ); 206 207 //$this->sendMessage("significant, multiview = false"); 208 foreach($request as $k=>$urldata){ 209 $url = jUrl::parse ($urldata[0], $urldata[1], $urldata[2]); 210 $p = $url->params; 211 ksort($p); 212 ksort($resultList[$k]); 213 214 $this->assertTrue( ($p == $resultList[$k]), 'created:'.var_export($p,true).' expected:'.var_export($resultList[$k],true)); 215 } 216 217 $gJConfig->urlengine['multiview']=true; 218 $request=array( 219 array("index","/jelix_tests/urlsig/url1",array('mois'=>'10', 'annee'=>'2005', 'id'=>'35')), 220 array("testnews","/jelix_tests/urlsig/url2",array('mois'=>'05', 'annee'=>'2004')), 221 array("testnews","/jelix_tests/urlsig/url3",array('rubrique'=>'actualite', 'id_art'=>'65', 'article'=>'c\'est la fete au village')), 222 array("foo/bar","/jelix_tests/urlsig/url4",array('first'=>'premier', 'second'=>'deuxieme')), 223 array("xmlrpc","",array()), 224 array("news","/news/main/bar",array('aaa'=>'bbb')), 225 array("index","/jelix_tests/urlsig/url5",array('foo'=>'oof', 'bar'=>'rab')), 226 array("index","/jelix_tests/urlsig/url8",array('rubrique'=>'vetements', 'id_article'=>'98')), 227 array("index","/jelix_tests/",array('rubrique'=>'vetements', 'id_article'=>'98')), 228 array("index","/jelix_tests/urlsig/",array('rubrique'=>'vetements', 'id_article'=>'98')), 229 ); 230 foreach($request as $k=>$urldata){ 231 $url = jUrl::parse ($urldata[0], $urldata[1], $urldata[2]); 232 $p = $url->params; 233 ksort($p); 234 ksort($resultList[$k]); 235 236 $this->assertTrue( ($p == $resultList[$k]), 'created:'.var_export($p,true).' expected:'.var_export($resultList[$k],true)); 237 } 238 239 } 240 160 241 } 161 242 trunk/testapp/var/config/defaultconfig.ini.php
r1058 r1064 99 99 __https= 100 100 101 [basic_significant_urlengine_entrypoints] 102 ; for each entry point, it indicates if the entry point name 103 ; should be include in the url or not 104 index = on 105 xmlrpc = on 106 jsonrpc = on 107 testnews = off 108 foo/bar = on 109 news = on 110 111 101 112 [logfiles] 102 113 default=messages.log
