Changeset 328

Show
Ignore:
Timestamp:
12/12/06 23:17:32 (2 years ago)
Author:
laurentj
Message:

- fix ticket #62 : avec le moteur d'url significant, il n'y avait pas de différence entre une url avec un slash de fin et une sans slash
- fix bug dans jIniFile : ne doit pas générer un jException quand gJConfig n'existe pas
- documentation dans les classes de jDao

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/jelix/core/url/jUrlCompiler.significant.class.php

    r320 r328  
    205205                 $path=''; 
    206206               } 
     207               if(isset($url['optionalTrailingSlash']) && $url['optionalTrailingSlash'] == 'true'){ 
     208                    if(substr($regexppath, -1) == '/'){ 
     209                        $regexppath.='?'; 
     210                    }else{ 
     211                        $regexppath.='\/?'; 
     212                    } 
     213               } 
     214 
    207215               $liststatics = array(); 
    208216               foreach($url->static as $var){ 
  • trunk/lib/jelix/core/url/jUrlEngine.significant.class.php

    r320 r328  
    138138        global $gJConfig; 
    139139 
    140         if(substr($pathinfo,-1) == '/' && $pathinfo != '/'){ 
     140        /*if(substr($pathinfo,-1) == '/' && $pathinfo != '/'){ 
    141141                $pathinfo = substr($pathinfo,0,-1); 
    142         } 
     142        }*/ 
    143143 
    144144        $urlact = null; 
     
    236236            } 
    237237        }else if(!$urlact && $isDefault){ 
    238             // si on a pas trouver de correspondance, mais que c'est l'entry point 
     238            // si on n'a pas trouv�e correspondance, mais que c'est l'entry point 
    239239            // par defaut pour le type de request courant, alors on laisse passer.. 
    240240            $urlact = new jUrlAction($params); 
  • trunk/lib/jelix/dao/jDao.class.php

    r248 r328  
    33* @package    jelix 
    44* @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 
    98* @link        http://www.jelix.org 
    109* @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 CopixDAOFactory 
    13 * du framework Copix 2.3dev20050901. http://www.copix.org 
    14 * il est sous Copyright 2001-2005 CopixTeam (licence LGPL) 
    15 * Auteurs initiaux : Gerald Croes et Laurent Jouanneau 
    16 * Adapt�et am�or�pour Jelix par Laurent Jouanneau 
    1710*/ 
    1811 
     
    2417 
    2518/** 
    26  * Factory to create automatic DAO. 
     19 * Factory to create DAO objects 
    2720 * @package  jelix 
    2821 * @subpackage dao 
     
    3124 
    3225    /** 
    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 
    3532    */ 
    3633    public static function create ($DaoId, $profil=''){ 
     
    4946 
    5047    /** 
    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 
    5254    */ 
    5355    public static function get ($DaoId, $profil='') { 
     
    6466 
    6567    /** 
    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 
    6773    */ 
    6874    public static function createRecord ($DaoId, $profil=''){ 
     
    7783    } 
    7884 
     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     */ 
    7992    public static function createConditions ($glueOp = 'AND'){ 
    8093        $obj = new jDaoConditions ($glueOp); 
  • trunk/lib/jelix/dao/jDaoBase.class.php

    r287 r328  
    11<?php 
    22/** 
    3  * @package    jelix 
    4  * @subpackage dao 
    5  * @version    $Id:$ 
    6  * @author     Laurent Jouanneau 
     3 * @package     jelix 
     4 * @subpackage  dao 
     5 * @author      Laurent Jouanneau 
    76 * @contributor 
    8  * @copyright  2005-2006 Laurent Jouanneau 
     7 * @copyright  2005-2006 Laurent Jouanneau 
    98 * @link        http://www.jelix.org 
    10  * @licence  http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file 
     9 * @licence     http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file 
    1110 */ 
    1211 
     
    2524 
    2625 
     26    /** 
     27     * informations on all properties 
     28     * @var array  
     29     */ 
    2730    protected $_properties=array(); 
    2831 
     32    /** 
     33     * @return array informations on all properties 
     34     */ 
    2935    public function getProperties(){ return $this->_properties; } 
    3036 
     37    /** 
     38     * check values in the properties of the record, according on the dao definition 
     39     * @return array list of errors 
     40     */ 
    3141    public function check(){ 
    3242        $errors=array(); 
     
    7888    } 
    7989 
     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     */ 
    8095    public function setPk(){ 
    8196        $args=func_get_args(); 
     
    105120 */ 
    106121abstract class jDaoFactoryBase  { 
    107  
     122    /** 
     123     * informations on tables 
     124     * @var array 
     125     */ 
    108126    protected $_tables; 
     127    /** 
     128     * the id of the primary table 
     129     * @var string 
     130     */ 
    109131    protected $_primaryTable; 
     132 
     133    /** 
     134     * the database connector 
     135     * @var jDbConnection 
     136     */ 
    110137    protected $_conn; 
     138    /** 
     139     * the select clause you can reuse for a specific SELECT query 
     140     * @var string 
     141     */ 
    111142    protected $_selectClause; 
     143    /** 
     144     * the from clause you can reuse for a specific SELECT query 
     145     * @var string 
     146     */ 
    112147    protected $_fromClause; 
     148    /** 
     149     * the where clause you can reuse for a specific SELECT query 
     150     * @var string 
     151     */ 
    113152    protected $_whereClause; 
     153    /** 
     154     * the class name of a dao record for this dao factory 
     155     * @var string 
     156     */ 
    114157    protected $_DaoRecordClassName; 
     158    /** 
     159     * list of id of primary properties 
     160     * @var array 
     161     */ 
    115162    protected $_pkFields; 
    116163 
    117  
     164    /** 
     165     * @param jDbConnection $conn the database connection 
     166     */ 
    118167    function  __construct($conn){ 
    119168        $this->_conn = $conn; 
    120169    } 
    121170 
     171    /** 
     172     * return all records 
     173     * @return jDbResultSet 
     174     */ 
    122175    public function findAll(){ 
    123176        $rs =  $this->_conn->query ($this->_selectClause.$this->_fromClause.$this->_whereClause); 
     
    125178        return $rs; 
    126179    } 
    127  
     180    /** 
     181     * return the number of all records 
     182     * @return int the count 
     183     */ 
    128184    public function countAll(){ 
    129185        $query = 'SELECT COUNT(*) as c '.$this->_fromClause.$this->_whereClause; 
     
    133189    } 
    134190 
     191    /** 
     192     * return the record corresponding to the given key 
     193     * @param string  one or more primary key 
     194     * @return jDaoRecordBase 
     195     */ 
    135196    public function get(){ 
    136197        $args=func_get_args(); 
     
    153214    } 
    154215 
     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     */ 
    155221    public function delete(){ 
    156222        $args=func_get_args(); 
     
    167233    } 
    168234 
     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     */ 
    169240    abstract public function insert ($record); 
     241 
     242    /** 
     243     * save a modified record into the database 
     244     * @param jDaoRecordBase $record the record to save 
     245     */ 
    170246    abstract public function update ($record); 
    171247 
    172248 
    173249    /** 
    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     */ 
    176258    public function findBy ($searchcond, $limitOffset=0, $limitCount=0){ 
    177259        $query = $this->_selectClause.$this->_fromClause.$this->_whereClause; 
     
    194276 
    195277    /** 
    196         * 
    197         */ 
     278    *  
     279    */ 
    198280    protected function _createConditionsClause($daocond){ 
    199281 
     
    219301    } 
    220302 
    221  
     303    /** 
     304     * @internal 
     305     */ 
    222306    protected function _generateCondition($condition, &$fields, $principal=true){ 
    223307        $r = ' '; 
     
    284368    } 
    285369    /** 
    286         * prepare the value ready to be used in a dynamic evaluation 
    287         */ 
     370     * prepare the value ready to be used in a dynamic evaluation 
     371     */ 
    288372    protected function _prepareValue($value, $fieldType){ 
    289373        switch(strtolower($fieldType)){ 
  • trunk/lib/jelix/dao/jDaoConditions.class.php

    r253 r328  
    33* @package    jelix 
    44* @subpackage dao 
    5 * @version    $Id:$ 
    65* @author     Croes G�ld, Laurent Jouanneau 
    76* @contributor Laurent Jouanneau 
     
    1817 
    1918/** 
    20 * structure stockant les donn� d'une condition 
    21 * @package  jelix 
     19 * content a sub group of conditions 
     20 * @package  jelix 
    2221 * @subpackage dao 
    23 */ 
     22 */ 
    2423class jDaoCondition { 
    2524    /** 
     
    5049 
    5150/** 
    52 * conteneur d'un ensemble de conditions 
    53 * @package  jelix 
     51 * container for all criteria of a query 
     52 * @package  jelix 
    5453 * @subpackage dao 
    5554*/ 
    5655class jDaoConditions { 
    5756    /** 
    58     * var jDaoCondition 
     57    * @var jDaoCondition 
    5958    */ 
    6059    public $condition; 
  • trunk/lib/jelix/utils/jIniFile.class.php

    r274 r328  
    33* @package    jelix 
    44* @subpackage utils 
    5 * @version    $Id:$ 
    65* @author     Loic Mathaud 
    76* @contributor 
     
    1211 
    1312/** 
    14 * 
     13* utility class to read and write an ini file 
    1514* @package    jelix 
    1615* @subpackage utils 
     
    1817class jIniFile { 
    1918 
     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     */ 
    2024    public static function read($filename) { 
    2125        if ( file_exists ($filename) ) { 
     
    2630    } 
    2731     
     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     */ 
    2839    public static function write($array, $filename) { 
    2940        $result=''; 
     
    4455            fclose($f); 
    4556        } 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            } 
    4765        } 
    4866    } 
  • trunk/testapp/modules/unittest/classes/utcreateurls.class.php

    r320 r328  
    230230      $urlList[]= array('jelix~bar@xmlrpc', array('aaa'=>'bbb')); 
    231231      $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')); 
    233236 
    234237      $trueResult=array( 
     
    243246          "/xmlrpc.php", 
    244247          "/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]; 
    250255      $this->_doCompareUrl("significant, multiview = false", $urlList,$trueResult); 
    251256 
     
    263268          "/xmlrpc", 
    264269          "/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]; 
    268276      $this->_doCompareUrl("significant, multiview = true", $urlList,$trueResult); 
    269277 
  • trunk/testapp/modules/unittest/classes/utparseurls.class.php

    r247 r328  
    6868      $resultList[]= array(); 
    6969      $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'); 
    7074 
    7175      $request=array( 
     
    7781          array("index.php",'',array('module'=>'unittest', 'action'=>'urlsig_url5', 'foo'=>'oof',  'bar'=>'rab')), 
    7882          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 
    8089       ); 
    8190 
     
    101110          array("index",'',array('module'=>'unittest', 'action'=>'urlsig_url5', 'foo'=>'oof',  'bar'=>'rab')), 
    102111          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()), 
    104117       ); 
    105118      foreach($request as $k=>$urldata){ 
  • trunk/testapp/var/config/urls.xml

    r267 r328  
    2525        </url> 
    2626 
    27         <url pathinfo="/shop/:rubrique/:id_article" module="unittest" https="true" action="urlsig_url8"> 
     27        <url pathinfo="/shop/:rubrique/:id_article" module="unittest" https="true" action="urlsig_url11"> 
    2828           <param name="rubrique" /> 
    2929           <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" /> 
    3037        </url> 
    3138    </classicentrypoint> 
Download in other formats: Unified Diff Zip Archive