Changeset 328
- Timestamp:
- 12/12/06 23:17:32 (2 years ago)
- Files:
-
- trunk/lib/jelix/core/url/jUrlCompiler.significant.class.php (modified) (1 diff)
- trunk/lib/jelix/core/url/jUrlEngine.significant.class.php (modified) (2 diffs)
- trunk/lib/jelix/dao/jDao.class.php (modified) (6 diffs)
- trunk/lib/jelix/dao/jDaoBase.class.php (modified) (11 diffs)
- trunk/lib/jelix/dao/jDaoConditions.class.php (modified) (3 diffs)
- trunk/lib/jelix/utils/jIniFile.class.php (modified) (5 diffs)
- trunk/testapp/modules/unittest/classes/utcreateurls.class.php (modified) (3 diffs)
- trunk/testapp/modules/unittest/classes/utparseurls.class.php (modified) (3 diffs)
- trunk/testapp/var/config/urls.xml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/jelix/core/url/jUrlCompiler.significant.class.php
r320 r328 205 205 $path=''; 206 206 } 207 if(isset($url['optionalTrailingSlash']) && $url['optionalTrailingSlash'] == 'true'){ 208 if(substr($regexppath, -1) == '/'){ 209 $regexppath.='?'; 210 }else{ 211 $regexppath.='\/?'; 212 } 213 } 214 207 215 $liststatics = array(); 208 216 foreach($url->static as $var){ trunk/lib/jelix/core/url/jUrlEngine.significant.class.php
r320 r328 138 138 global $gJConfig; 139 139 140 if(substr($pathinfo,-1) == '/' && $pathinfo != '/'){140 /*if(substr($pathinfo,-1) == '/' && $pathinfo != '/'){ 141 141 $pathinfo = substr($pathinfo,0,-1); 142 } 142 }*/ 143 143 144 144 $urlact = null; … … 236 236 } 237 237 }else if(!$urlact && $isDefault){ 238 // si on a pas trouver de correspondance, mais que c'est l'entry point238 // si on n'a pas trouv�e correspondance, mais que c'est l'entry point 239 239 // par defaut pour le type de request courant, alors on laisse passer.. 240 240 $urlact = new jUrlAction($params); trunk/lib/jelix/dao/jDao.class.php
r248 r328 3 3 * @package jelix 4 4 * @subpackage dao 5 * @version $Id:$ 6 * @author Croes G�ld, Laurent Jouanneau 7 * @contributor Laurent Jouanneau 8 * @copyright 2001-2005 CopixTeam, 2005-2006 Laurent Jouanneau 5 * @author Laurent Jouanneau 6 * @contributor 7 * @copyright 2005-2006 Laurent Jouanneau 9 8 * @link http://www.jelix.org 10 9 * @licence http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file 11 *12 * Une partie du code est issue de la classe CopixDAOFactory13 * du framework Copix 2.3dev20050901. http://www.copix.org14 * il est sous Copyright 2001-2005 CopixTeam (licence LGPL)15 * Auteurs initiaux : Gerald Croes et Laurent Jouanneau16 * Adapt�et am�or�pour Jelix par Laurent Jouanneau17 10 */ 18 11 … … 24 17 25 18 /** 26 * Factory to create automatic DAO.19 * Factory to create DAO objects 27 20 * @package jelix 28 21 * @subpackage dao … … 31 24 32 25 /** 33 * creates a DAO from its Id. 34 * If no dao is founded, try to compile a DAO from the user definitions. 26 * creates a new instance of a DAO. 27 * If no dao is founded, try to compile a DAO from the dao xml file 28 * @param string|jSelectorDao $Daoid the dao selector 29 * @param string $profil the db profil name to use for the connection. 30 * If empty, use the default profil 31 * @return jDaoFactoryBase the dao object 35 32 */ 36 33 public static function create ($DaoId, $profil=''){ … … 49 46 50 47 /** 51 * Creates a DAO from its ID. Handles a singleton of the DAO. 48 * return a DAO instance. It Handles a singleton of the DAO. 49 * If no dao is founded, try to compile a DAO from the dao xml file 50 * @param string|jSelectorDao $Daoid the dao selector 51 * @param string $profil the db profil name to use for the connection. 52 * If empty, use the default profil 53 * @return jDaoFactoryBase the dao object 52 54 */ 53 55 public static function get ($DaoId, $profil='') { … … 64 66 65 67 /** 66 * creates a record object 68 * creates a record object for the given dao 69 * @param string $Daoid the dao selector 70 * @param string $profil the db profil name to use for the connection. 71 * If empty, use the default profil 72 * @return jDaoRecordBase a dao record object 67 73 */ 68 74 public static function createRecord ($DaoId, $profil=''){ … … 77 83 } 78 84 85 /** 86 * return an instance of a jDaoConditions object, to use with 87 * a findby method of a jDaoFactoryBase object. 88 * @param string $glueOp value should be AND or OR 89 * @return jDaoConditions 90 * @see jDaoFactoryBase::findby 91 */ 79 92 public static function createConditions ($glueOp = 'AND'){ 80 93 $obj = new jDaoConditions ($glueOp); trunk/lib/jelix/dao/jDaoBase.class.php
r287 r328 1 1 <?php 2 2 /** 3 * @package jelix 4 * @subpackage dao 5 * @version $Id:$ 6 * @author Laurent Jouanneau 3 * @package jelix 4 * @subpackage dao 5 * @author Laurent Jouanneau 7 6 * @contributor 8 * @copyright 2005-2006 Laurent Jouanneau7 * @copyright 2005-2006 Laurent Jouanneau 9 8 * @link http://www.jelix.org 10 * @licence http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file9 * @licence http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file 11 10 */ 12 11 … … 25 24 26 25 26 /** 27 * informations on all properties 28 * @var array 29 */ 27 30 protected $_properties=array(); 28 31 32 /** 33 * @return array informations on all properties 34 */ 29 35 public function getProperties(){ return $this->_properties; } 30 36 37 /** 38 * check values in the properties of the record, according on the dao definition 39 * @return array list of errors 40 */ 31 41 public function check(){ 32 42 $errors=array(); … … 78 88 } 79 89 90 /** 91 * set values on the properties which correspond to the primary 92 * key of the record 93 * This method accept a single or many values as parameter 94 */ 80 95 public function setPk(){ 81 96 $args=func_get_args(); … … 105 120 */ 106 121 abstract class jDaoFactoryBase { 107 122 /** 123 * informations on tables 124 * @var array 125 */ 108 126 protected $_tables; 127 /** 128 * the id of the primary table 129 * @var string 130 */ 109 131 protected $_primaryTable; 132 133 /** 134 * the database connector 135 * @var jDbConnection 136 */ 110 137 protected $_conn; 138 /** 139 * the select clause you can reuse for a specific SELECT query 140 * @var string 141 */ 111 142 protected $_selectClause; 143 /** 144 * the from clause you can reuse for a specific SELECT query 145 * @var string 146 */ 112 147 protected $_fromClause; 148 /** 149 * the where clause you can reuse for a specific SELECT query 150 * @var string 151 */ 113 152 protected $_whereClause; 153 /** 154 * the class name of a dao record for this dao factory 155 * @var string 156 */ 114 157 protected $_DaoRecordClassName; 158 /** 159 * list of id of primary properties 160 * @var array 161 */ 115 162 protected $_pkFields; 116 163 117 164 /** 165 * @param jDbConnection $conn the database connection 166 */ 118 167 function __construct($conn){ 119 168 $this->_conn = $conn; 120 169 } 121 170 171 /** 172 * return all records 173 * @return jDbResultSet 174 */ 122 175 public function findAll(){ 123 176 $rs = $this->_conn->query ($this->_selectClause.$this->_fromClause.$this->_whereClause); … … 125 178 return $rs; 126 179 } 127 180 /** 181 * return the number of all records 182 * @return int the count 183 */ 128 184 public function countAll(){ 129 185 $query = 'SELECT COUNT(*) as c '.$this->_fromClause.$this->_whereClause; … … 133 189 } 134 190 191 /** 192 * return the record corresponding to the given key 193 * @param string one or more primary key 194 * @return jDaoRecordBase 195 */ 135 196 public function get(){ 136 197 $args=func_get_args(); … … 153 214 } 154 215 216 /** 217 * delete a record corresponding to the given key 218 * @param string one or more primary key 219 * @return int the number of deleted record 220 */ 155 221 public function delete(){ 156 222 $args=func_get_args(); … … 167 233 } 168 234 235 /** 236 * save a new record into the database 237 * if the dao record has an autoincrement key, its corresponding property is updated 238 * @param jDaoRecordBase $record the record to save 239 */ 169 240 abstract public function insert ($record); 241 242 /** 243 * save a modified record into the database 244 * @param jDaoRecordBase $record the record to save 245 */ 170 246 abstract public function update ($record); 171 247 172 248 173 249 /** 174 * @param jDaoConditions $searchcond 175 */ 250 * return all record corresponding to the conditions stored into the 251 * jDaoConditions object. 252 * you can limit the number of results by given an offset and a count 253 * @param jDaoConditions $searchcond 254 * @param int $limitOffset 255 * @param int $limitCount 256 * @return jDbResultSet 257 */ 176 258 public function findBy ($searchcond, $limitOffset=0, $limitCount=0){ 177 259 $query = $this->_selectClause.$this->_fromClause.$this->_whereClause; … … 194 276 195 277 /** 196 *197 */278 * 279 */ 198 280 protected function _createConditionsClause($daocond){ 199 281 … … 219 301 } 220 302 221 303 /** 304 * @internal 305 */ 222 306 protected function _generateCondition($condition, &$fields, $principal=true){ 223 307 $r = ' '; … … 284 368 } 285 369 /** 286 * prepare the value ready to be used in a dynamic evaluation287 */370 * prepare the value ready to be used in a dynamic evaluation 371 */ 288 372 protected function _prepareValue($value, $fieldType){ 289 373 switch(strtolower($fieldType)){ trunk/lib/jelix/dao/jDaoConditions.class.php
r253 r328 3 3 * @package jelix 4 4 * @subpackage dao 5 * @version $Id:$6 5 * @author Croes G�ld, Laurent Jouanneau 7 6 * @contributor Laurent Jouanneau … … 18 17 19 18 /** 20 * structure stockant les donn� d'une condition 21 * @package jelix19 * content a sub group of conditions 20 * @package jelix 22 21 * @subpackage dao 23 */22 */ 24 23 class jDaoCondition { 25 24 /** … … 50 49 51 50 /** 52 * conteneur d'un ensemble de conditions 53 * @package jelix51 * container for all criteria of a query 52 * @package jelix 54 53 * @subpackage dao 55 54 */ 56 55 class jDaoConditions { 57 56 /** 58 * var jDaoCondition57 * @var jDaoCondition 59 58 */ 60 59 public $condition; trunk/lib/jelix/utils/jIniFile.class.php
r274 r328 3 3 * @package jelix 4 4 * @subpackage utils 5 * @version $Id:$6 5 * @author Loic Mathaud 7 6 * @contributor … … 12 11 13 12 /** 14 * 13 * utility class to read and write an ini file 15 14 * @package jelix 16 15 * @subpackage utils … … 18 17 class jIniFile { 19 18 19 /** 20 * read an ini file 21 * @param string $filename the path and the name of the file to read 22 * @return array the content of the file or false 23 */ 20 24 public static function read($filename) { 21 25 if ( file_exists ($filename) ) { … … 26 30 } 27 31 32 /** 33 * write some datas in an ini file 34 * the datas array should follow the same structure returned by 35 * the read method (or parse_ini_file) 36 * @param array $array the content of an ini file 37 * @param string $filename the path and the name of the file use to store the content 38 */ 28 39 public static function write($array, $filename) { 29 40 $result=''; … … 44 55 fclose($f); 45 56 } else { 46 throw new jException('jelix~errors.inifile.write.error', array ($filename)); 57 // jIniFile est utilis�ar le compilateur des configs 58 // il n'y a alors pas de $gJConfig dans de cas : 59 // il faut g�rer alors une erreur sans passer par jLocale 60 if(isset($GLOBALS['gJConfig'])){ 61 throw new jException('jelix~errors.inifile.write.error', array ($filename)); 62 }else{ 63 throw new Exception('(24)Error while writing ini file '.$filename); 64 } 47 65 } 48 66 } trunk/testapp/modules/unittest/classes/utcreateurls.class.php
r320 r328 230 230 $urlList[]= array('jelix~bar@xmlrpc', array('aaa'=>'bbb')); 231 231 $urlList[]= array('news~bar', array('aaa'=>'bbb')); 232 $urlList[]= array('unittest~urlsig_url8', array('rubrique'=>'vetements', 'id_article'=>'98')); 232 $urlList[]= array('unittest~urlsig_url8', array('mois'=>'23', 'annee'=>'2007', 'id'=>'74')); 233 $urlList[]= array('unittest~urlsig_url11', array('rubrique'=>'vetements', 'id_article'=>'98')); 234 $urlList[]= array('unittest~urlsig_url12', array('rubrique'=>'bricolage', 'id_article'=>'53')); 235 $urlList[]= array('unittest~urlsig_url13', array('rubrique'=>'alimentation', 'id_article'=>'26')); 233 236 234 237 $trueResult=array( … … 243 246 "/xmlrpc.php", 244 247 "/news.php?aaa=bbb&action=default_bar", 245 "/index.php/shop/vetements/98" 246 247 ); 248 249 $trueResult[10]='https://'.$_SERVER['HTTP_HOST'].$trueResult[10]; 248 "/index.php/test/news/2007/23/74?action=urlsig_url8", 249 "/index.php/shop/vetements/98", 250 "/index.php/shop/bricolage/53/", 251 "/index.php/supershop/alimentation?id_article=26", 252 ); 253 254 $trueResult[11]='https://'.$_SERVER['HTTP_HOST'].$trueResult[11]; 250 255 $this->_doCompareUrl("significant, multiview = false", $urlList,$trueResult); 251 256 … … 263 268 "/xmlrpc", 264 269 "/news?aaa=bbb&action=default_bar", 265 "/index/shop/vetements/98" 266 ); 267 $trueResult[10]='https://'.$_SERVER['HTTP_HOST'].$trueResult[10]; 270 "/index/test/news/2007/23/74?action=urlsig_url8", 271 "/index/shop/vetements/98", 272 "/index/shop/bricolage/53/", 273 "/index/supershop/alimentation?id_article=26", 274 ); 275 $trueResult[11]='https://'.$_SERVER['HTTP_HOST'].$trueResult[11]; 268 276 $this->_doCompareUrl("significant, multiview = true", $urlList,$trueResult); 269 277 trunk/testapp/modules/unittest/classes/utparseurls.class.php
r247 r328 68 68 $resultList[]= array(); 69 69 $resultList[]= array('module'=>'news', 'action'=>'main_bar', 'aaa'=>'bbb'); 70 $resultList[]= array('module'=>'unittest', 'action'=>'urlsig_url11', 'rubrique'=>'vetements', 'id_article'=>'65'); 71 $resultList[]= array('module'=>'unittest', 'action'=>'urlsig_url12', 'rubrique'=>'bricolage', 'id_article'=>'34'); 72 $resultList[]= array('module'=>'unittest', 'action'=>'urlsig_url13', 'rubrique'=>'alimentation'); 73 $resultList[]= array('module'=>'unittest', 'action'=>'urlsig_url13', 'rubrique'=>'chaussures'); 70 74 71 75 $request=array( … … 77 81 array("index.php",'',array('module'=>'unittest', 'action'=>'urlsig_url5', 'foo'=>'oof', 'bar'=>'rab')), 78 82 array("xmlrpc.php","",array()), 79 array("news.php","",array('aaa'=>'bbb','action'=>'main_bar')) 83 array("news.php","",array('aaa'=>'bbb','action'=>'main_bar')), 84 array("index.php","/shop/vetements/65",array()), 85 array("index.php","/shop/bricolage/34/",array()), 86 array("index.php","/supershop/alimentation",array()), 87 array("index.php","/supershop/chaussures",array()), 88 80 89 ); 81 90 … … 101 110 array("index",'',array('module'=>'unittest', 'action'=>'urlsig_url5', 'foo'=>'oof', 'bar'=>'rab')), 102 111 array("xmlrpc","",array()), 103 array("news","",array('aaa'=>'bbb','action'=>'main_bar')) 112 array("news","",array('aaa'=>'bbb','action'=>'main_bar')), 113 array("index","/shop/vetements/65",array()), 114 array("index","/shop/bricolage/34/",array()), 115 array("index","/supershop/alimentation",array()), 116 array("index","/supershop/chaussures",array()), 104 117 ); 105 118 foreach($request as $k=>$urldata){ trunk/testapp/var/config/urls.xml
r267 r328 25 25 </url> 26 26 27 <url pathinfo="/shop/:rubrique/:id_article" module="unittest" https="true" action="urlsig_url 8">27 <url pathinfo="/shop/:rubrique/:id_article" module="unittest" https="true" action="urlsig_url11"> 28 28 <param name="rubrique" /> 29 29 <param name="id_article" type="int"/> 30 </url> 31 <url pathinfo="/shop/:rubrique/:id_article/" module="unittest" action="urlsig_url12"> 32 <param name="rubrique" /> 33 <param name="id_article" type="int"/> 34 </url> 35 <url pathinfo="/supershop/:rubrique" module="unittest" action="urlsig_url13" optionalTrailingSlash="true"> 36 <param name="rubrique" /> 30 37 </url> 31 38 </classicentrypoint>
