Changeset 289

Show
Ignore:
Timestamp:
11/01/06 19:13:41 (2 years ago)
Author:
laurentj
Message:

- ajout d'une nouvelle classe jFilter (non terminée) pour la verification de chaine
- corrections dans simpletest pour eviter des notices/strict
- petite optimisation dans jUrl

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/build/manifests/jelix-lib.mn

    r288 r289  
    187187  jMailer.class.php 
    188188  jSmtp.class.php 
     189* jFilter.class.php 
    189190 
    190191cd lib/json 
  • trunk/build/manifests/testapp.mn

    r276 r289  
    6464  utdao2.class.php 
    6565  utdao_conditions.class.php 
     66  utfilter.class.php 
    6667cd testapp/modules/unittest/locales/fr_FR 
    6768  testunit.ISO-8859-1.properties 
  • trunk/lib/jelix/core/url/jUrl.class.php

    r283 r289  
    196196        $url = $this->scriptName.$this->pathInfo; 
    197197        if (count ($this->params)>0){ 
    198             $url .='?'.self::_collapseParams($this->params, $forxml); 
     198            $url .='?'.http_build_query($this->params, '', ($forxml?'&':'&')); 
    199199        } 
    200200        return $url; 
     
    208208    */ 
    209209    public function collapseParams ($forxml = false) { 
    210         return self::_collapseParams($this->params, $forxml); 
     210        return http_build_query($this->params, '', ($forxml?'&':'&')); 
    211211    } 
    212212 
     
    223223        if ($url === false){ 
    224224           $url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'].$GLOBALS['gJCoord']->request->url_path_info.'?'; 
    225            $url.= self::_collapseParams($_GET,$forxml); 
     225           $url.= http_build_query($_GET, '', ($forxml?'&':'&')); 
    226226        } 
    227227        return $url; 
     
    235235    static function appendToUrlString ($url, $params = array (), $forxml = false){ 
    236236        if ((($pos = strpos ( $url, '?')) !== false) && ($pos !== (strlen ($url)-1))){ 
    237             return $url . ($forxml ? '&' : '&').jUrl::_collapseParams ($params, $forxml); 
     237            return $url . ($forxml ? '&' : '&').http_build_query($params, '', ($forxml?'&':'&')); 
    238238        }else{ 
    239             return $url . '?'.jUrl::_collapseParams ($params, $forxml); 
     239            return $url . '?'.http_build_query($params, '', ($forxml?'&':'&')); 
    240240        } 
    241241    } 
     
    273273    static function parse($scriptNamePath, $pathinfo, $params ){ 
    274274         return jUrl::getEngine()->parse($scriptNamePath,$pathinfo, $params); 
    275     } 
    276  
    277  
    278     /** 
    279     * collapse parameters to generate an url parameters string 
    280     * @param array $params array of parameters 
    281     * @param boolean $forxml if the string has to be html compliant (& for &) 
    282     * @return string the url 
    283     */ 
    284     static private function _collapseParams ($params, $forxml = false) { 
    285         $url = ''; 
    286         $amp = ($forxml ? '&' : '&'); 
    287         foreach ($params as $k=>$v){ 
    288             if ($url == ''){ 
    289                 $url = $k.'='.urlencode($v); 
    290             }else{ 
    291                 $url .= $amp.$k.'='.urlencode($v); 
    292             } 
    293         } 
    294         return $url; 
    295275    } 
    296276 
  • trunk/lib/simpletest/authentication.php

    r276 r289  
    229229         *    @static 
    230230         */ 
    231         function addBasicHeaders(&$request, $username, $password) { 
     231        static function addBasicHeaders(&$request, $username, $password) { 
    232232            if ($username && $password) { 
    233233                $request->addHeaderLine( 
  • trunk/lib/simpletest/compatibility.php

    r275 r289  
    2020         *        @static 
    2121         */ 
    22         function copy($object) { 
     22        static function copy($object) { 
    2323            if (version_compare(phpversion(), '5') >= 0) { 
    2424                eval('$copy = clone $object;'); 
     
    3838         *    @static 
    3939         */ 
    40         function isIdentical($first, $second) { 
     40        static function isIdentical($first, $second) { 
    4141            if ($first != $second) { 
    4242                return false; 
     
    5656         *    @static 
    5757         */ 
    58         function _isIdenticalType($first, $second) { 
     58        static function _isIdenticalType($first, $second) { 
    5959            if (gettype($first) != gettype($second)) { 
    6060                return false; 
     
    8282         *    @static 
    8383         */ 
    84         function _isArrayOfIdenticalTypes($first, $second) { 
     84        static function _isArrayOfIdenticalTypes($first, $second) { 
    8585            if (array_keys($first) != array_keys($second)) { 
    8686                return false; 
     
    105105         *    @static 
    106106         */ 
    107         function isReference(&$first, &$second) { 
     107        static function isReference(&$first, &$second) { 
    108108            if (version_compare(phpversion(), '5', '>=') 
    109109                    && is_object($first)) { 
     
    133133         *    @static 
    134134         */ 
    135         function isA($object, $class) { 
     135        static function isA($object, $class) { 
    136136            if (version_compare(phpversion(), '5') >= 0) { 
    137137                if (! class_exists($class, false)) { 
     
    159159         *    @static 
    160160         */ 
    161         function setTimeout($handle, $timeout) { 
     161        static function setTimeout($handle, $timeout) { 
    162162            if (function_exists('stream_set_timeout')) { 
    163163                stream_set_timeout($handle, $timeout, 0); 
  • trunk/lib/simpletest/dumper.php

    r275 r289  
    1212        define('TYPE_MATTERS', true); 
    1313    } 
    14      
     14 
    1515    /** 
    1616     *    Displays variables as text and does diffs. 
     
    1919     */ 
    2020    class SimpleDumper { 
    21          
     21 
    2222        /** 
    2323         *    Renders a variable in a shorter form than print_r(). 
     
    4444            return "Unknown"; 
    4545        } 
    46          
     46 
    4747        /** 
    4848         *    Gets the string representation of a type. 
     
    9696            return $this->$method($first, $second, $identical); 
    9797        } 
    98          
     98 
    9999        /** 
    100100         *    Tests to see if types match. 
     
    129129            return ($start > 0 ? "..." : "") . $value . ($start + $size < $length ? "..." : ""); 
    130130        } 
    131          
     131 
    132132        /** 
    133133         *    Creates a human readable description of the 
     
    144144                    $this->describeValue($second) . "]"; 
    145145        } 
    146          
     146 
    147147        /** 
    148148         *    Creates a human readable description of the 
     
    157157            return $this->_describeGenericDifference($first, $second); 
    158158        } 
    159          
     159 
    160160        /** 
    161161         *    Creates a human readable description of the 
     
    170170            return $this->_describeGenericDifference($first, $second); 
    171171        } 
    172          
     172 
    173173        /** 
    174174         *    Creates a human readable description of the 
     
    191191            return $message; 
    192192        } 
    193          
     193 
    194194        /** 
    195195         *    Creates a human readable description of the 
     
    210210                    abs($first - $second); 
    211211        } 
    212          
     212 
    213213        /** 
    214214         *    Creates a human readable description of the 
     
    229229                    abs($first - $second); 
    230230        } 
    231          
     231 
    232232        /** 
    233233         *    Creates a human readable description of the 
     
    262262            return ""; 
    263263        } 
    264          
     264 
    265265        /** 
    266266         *    Compares two arrays to see if their key lists match. 
     
    283283            return ($first_keys == $second_keys); 
    284284        } 
    285          
     285 
    286286        /** 
    287287         *    Creates a human readable description of the 
     
    296296            return $this->_describeGenericDifference($first, $second); 
    297297        } 
    298          
     298 
    299299        /** 
    300300         *    Creates a human readable description of the 
     
    315315                    $identical); 
    316316        } 
    317          
     317 
    318318        /** 
    319319         *    Find the first character position that differs 
     
    342342            return $position; 
    343343        } 
    344          
     344 
    345345        /** 
    346346         *    Sends a formatted dump of a variable to a string. 
     
    350350         *    @static 
    351351         */ 
    352         function dump($variable) { 
     352        static function dump($variable) { 
    353353            ob_start(); 
    354354            print_r($variable); 
     
    365365         *    @static 
    366366         */ 
    367         function getFormattedAssertionLine($stack) { 
     367        static function getFormattedAssertionLine($stack) { 
    368368            foreach ($stack as $frame) { 
    369369                if (isset($frame['file'])) { 
     
    380380            return ''; 
    381381        } 
    382          
     382 
    383383        /** 
    384384         *    Tries to determine if the method call is an assertion. 
     
    387387         *    @static 
    388388         */ 
    389         function _stackFrameIsAnAssertion($frame) { 
     389        static function _stackFrameIsAnAssertion($frame) { 
    390390            if (($frame['function'] == 'fail') || ($frame['function'] == 'pass')) { 
    391391                return true; 
  • trunk/lib/simpletest/expectation.php

    r276 r289  
    8787         *    @static 
    8888         */ 
    89         function isExpectation($expectation) { 
     89        static function isExpectation($expectation) { 
    9090            return is_object($expectation) && 
    9191                    SimpleTestCompatibility::isA($expectation, 'SimpleExpectation'); 
  • trunk/lib/simpletest/parser.php

    r276 r289  
    587587         *    @static 
    588588         */ 
    589         function &createLexer(&$parser) { 
     589        static function &createLexer(&$parser) { 
    590590            $lexer = &new SimpleHtmlLexer($parser); 
    591591            return $lexer; 
     
    697697         *    @static 
    698698         */ 
    699         function decodeHtml($html) { 
     699        static function decodeHtml($html) { 
    700700            static $translations; 
    701701            if (! isset($translations)) { 
     
    714714         *    @static 
    715715         */ 
    716         function normalise($html) { 
     716        static function normalise($html) { 
    717717            $text = preg_replace('|<!--.*?-->|', '', $html); 
    718718            $text = preg_replace('|<img.*?alt\s*=\s*"(.*?)".*?>|', ' \1 ', $text); 
  • trunk/lib/simpletest/reporter.php

    r276 r289  
    5959         *    @static 
    6060         */ 
    61         function sendNoCacheHeaders() { 
     61        static function sendNoCacheHeaders() { 
    6262            if (! headers_sent()) { 
    6363                header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 
  • trunk/lib/simpletest/scorer.php

    r276 r289  
    380380         *    @static 
    381381         */ 
    382         function inCli() { 
     382        static function inCli() { 
    383383            return php_sapi_name() == 'cli'; 
    384384        } 
  • trunk/lib/simpletest/simpletest.php

    r275 r289  
    3232         *    @access public 
    3333         */ 
    34         function getVersion() { 
     34        static function getVersion() { 
    3535            $content = file(dirname(__FILE__) . '/VERSION'); 
    3636            return trim($content[0]); 
     
    4646         *    @access public 
    4747         */ 
    48         function ignore($class) { 
     48        static function ignore($class) { 
    4949            $registry = &SimpleTest::_getRegistry(); 
    5050            $registry['IgnoreList'][strtolower($class)] = true; 
     
    6666         *    @access public 
    6767         */ 
    68         function ignoreParentsIfIgnored($classes) { 
     68        static function ignoreParentsIfIgnored($classes) { 
    6969            $registry = &SimpleTest::_getRegistry(); 
    7070            foreach ($classes as $class) { 
     
    8989         *    @static 
    9090         */ 
    91         function isIgnored($class) { 
     91        static function isIgnored($class) { 
    9292            $registry = &SimpleTest::_getRegistry(); 
    9393            return isset($registry['IgnoreList'][strtolower($class)]); 
     
    165165         *    @static 
    166166         */ 
    167         function setCurrent(&$test) { 
     167        static function setCurrent(&$test) { 
    168168            $registry = &SimpleTest::_getRegistry(); 
    169169            $registry['CurrentTestCase'] = &$test; 
     
    176176         *    @static 
    177177         */ 
    178         function &getCurrent() { 
     178        static function &getCurrent() { 
    179179            $registry = &SimpleTest::_getRegistry(); 
    180180            return $registry['CurrentTestCase']; 
     
    187187         *    @static 
    188188         */ 
    189         function &_getRegistry() { 
     189        static function &_getRegistry() { 
    190190            static $registry = false; 
    191191            if (! $registry) { 
     
    201201         *    @static 
    202202         */ 
    203         function _getDefaults() { 
     203        static function _getDefaults() { 
    204204            return array( 
    205205                    'StubBaseClass' => 'SimpleStub', 
     
    212212    } 
    213213 
    214     /** 
    215      *    @deprecated 
    216      */ 
    217     class SimpleTestOptions extends SimpleTest { 
    218  
    219         /** 
    220          *    @deprecated 
    221          */ 
    222         function getVersion() { 
    223             return Simpletest::getVersion(); 
    224         } 
    225  
    226         /** 
    227          *    @deprecated 
    228          */ 
    229         function ignore($class) { 
    230             return Simpletest::ignore($class); 
    231         } 
    232  
    233         /** 
    234          *    @deprecated 
    235          */ 
    236         function isIgnored($class) { 
    237             return Simpletest::isIgnored($class); 
    238         } 
    239  
    240         /** 
    241          *    @deprecated 
    242          */ 
    243         function setMockBaseClass($mock_base) { 
    244             return Simpletest::setMockBaseClass($mock_base); 
    245         } 
    246  
    247         /** 
    248          *    @deprecated 
    249          */ 
    250         function getMockBaseClass() { 
    251             return Simpletest::getMockBaseClass(); 
    252         } 
    253  
    254         /** 
    255          *    @deprecated 
    256          */ 
    257         function useProxy($proxy, $username = false, $password = false) { 
    258             return Simpletest::useProxy($proxy, $username, $password); 
    259         } 
    260  
    261         /** 
    262          *    @deprecated 
    263          */ 
    264         function getDefaultProxy() { 
    265             return Simpletest::getDefaultProxy(); 
    266         } 
    267  
    268         /** 
    269          *    @deprecated 
    270          */ 
    271         function getDefaultProxyUsername() { 
    272             return Simpletest::getDefaultProxyUsername(); 
    273         } 
    274  
    275         /** 
    276          *    @deprecated 
    277          */ 
    278         function getDefaultProxyPassword() { 
    279             return Simpletest::getDefaultProxyPassword(); 
    280         } 
    281     } 
    282214?> 
  • trunk/lib/simpletest/test_case.php

    r276 r289  
    379379         *    @static 
    380380         */ 
    381         function getSize() { 
     381        static function getSize() { 
    382382            return 1; 
    383383        } 
  • trunk/lib/simpletest/url.php

    r275 r289  
    3636        var $_target; 
    3737        var $_raw = false; 
    38          
     38 
    3939        /** 
    4040         *    Constructor. Parses URL into sections. 
     
    5858            $this->_target = false; 
    5959        } 
    60          
     60 
    6161        /** 
    6262         *    Extracts the X, Y coordinate pair from an image map. 
     
    7373            return array(false, false); 
    7474        } 
    75          
     75 
    7676        /** 
    7777         *    Extracts the scheme part of an incoming URL. 
     
    8888            return false; 
    8989        } 
    90          
     90 
    9191        /** 
    9292         *    Extracts the username and password from the 
     
    115115            return array(false, false); 
    116116        } 
    117          
     117 
    118118        /** 
    119119         *    Extracts the host part of an incoming URL. 
     
    144144            return false; 
    145145        } 
    146          
     146 
    147147        /** 
    148148         *    Extracts the path information from the incoming 
     
    160160            return ''; 
    161161        } 
    162          
     162 
    163163        /** 
    164164         *    Strips off the request data. 
     
    175175            return ''; 
    176176        } 
    177           
     177 
    178178        /** 
    179179         *    Breaks the request down into an object. 
     
    194194            return $request; 
    195195        } 
    196          
     196 
    197197        /** 
    198198         *    Accessor for protocol part. 
     
    204204            return $this->_scheme ? $this->_scheme : $default; 
    205205        } 
    206          
     206 
    207207        /** 
    208208         *    Accessor for user name. 
     
    213213            return $this->_username; 
    214214        } 
    215          
     215 
    216216        /** 
    217217         *    Accessor for password. 
     
    222222            return $this->_password; 
    223223        } 
    224          
     224 
    225225        /** 
    226226         *    Accessor for hostname and port. 
     
    232232            return $this->_host ? $this->_host : $default; 
    233233        } 
    234          
     234 
    235235        /** 
    236236         *    Accessor for top level domain. 
     
    242242            return (isset($path_parts['extension']) ? $path_parts['extension'] : false); 
    243243        } 
    244          
     244 
    245245        /** 
    246246         *    Accessor for port number. 
     
    250250        function getPort() { 
    251251            return $this->_port; 
    252         }         
    253                  
     252        } 
     253 
    254254       /** 
    255255         *    Accessor for path. 
     
    263263            return $this->_path; 
    264264        } 
    265          
     265 
    266266        /** 
    267267         *    Accessor for page if any. This may be a 
     
    276276            return $matches[1]; 
    277277        } 
    278          
     278 
    279279        /** 
    280280         *    Gets the path to the page. 
     
    288288            return $matches[1]; 
    289289        } 
    290          
     290 
    291291        /** 
    292292         *    Accessor for fragment at end of URL after the "#". 
     
    297297            return $this->_fragment; 
    298298        } 
    299          
     299 
    300300        /** 
    301301         *    Sets image coordinates. Set to false to clear 
     
    313313            $this->_y = (integer)$y; 
    314314        } 
    315          
     315 
    316316        /** 
    317317         *    Accessor for horizontal image coordinate. 
     
    322322            return $this->_x; 
    323323        } 
    324           
     324 
    325325        /** 
    326326         *    Accessor for vertical image coordinate. 
     
    331331            return $this->_y; 
    332332        } 
    333         
     333 
    334334        /** 
    335335         *    Accessor for current request parameters 
     
    351351            return ''; 
    352352        } 
    353          
     353 
    354354        /** 
    355355         *    Adds an additional parameter to the request. 
     
    362362            $this->_request->add($key, $value); 
    363363        } 
    364          
     364 
    365365        /** 
    366366         *    Adds additional parameters to the request. 
     
    373373            $this->_request->merge($parameters); 
    374374        } 
    375          
     375 
    376376        /** 
    377377         *    Clears down all parameters. 
     
    382382            $this->_request = &new SimpleGetEncoding(); 
    383383        } 
    384          
     384 
    385385        /** 
    386386         *    Gets the frame target if present. Although 
     
    393393            return $this->_target; 
    394394        } 
    395          
     395 
    396396        /** 
    397397         *    Attaches a frame target. 
     
    403403            $this->_target = $frame; 
    404404        } 
    405          
     405 
    406406        /** 
    407407         *    Renders the URL back into a string. 
     
    426426            return "$scheme://$identity$host$path$encoded$fragment$coords"; 
    427427        } 
    428          
     428 
    429429        /** 
    430430         *    Replaces unknown sections to turn a relative 
     
    457457            return new SimpleUrl("$scheme://$identity$host$port$path$encoded$fragment$coords"); 
    458458        } 
    459          
     459 
    460460        /** 
    461461         *    Replaces unknown sections of the path with base parts 
     
    477477            return $base->getPath(); 
    478478        } 
    479          
     479 
    480480        /** 
    481481         *    Simple test to see if a path part is relative. 
     
    487487            return (substr($path, 0, 1) != '/'); 
    488488        } 
    489          
     489 
    490490        /** 
    491491         *    Extracts the username and password for use in rendering 
     
    500500            return false; 
    501501        } 
    502          
     502 
    503503        /** 
    504504         *    Replaces . and .. sections of the path. 
     
    511511            return preg_replace('|/\./|', '/', $path); 
    512512        } 
    513          
     513 
    514514        /** 
    515515         *    A pipe seperated list of all TLDs that result in two part 
     
    519519         *    @static 
    520520         */ 
    521         function getAllTopLevelDomains() { 
     521        static function getAllTopLevelDomains() { 
    522522            return 'com|edu|net|org|gov|mil|int|biz|info|name|pro|aero|coop|museum'; 
    523523        } 
  • trunk/lib/simpletest/VERSION

    r275 r289  
    1 1.0.1alpha3 
     11.0.1alpha3-jelix 
  • trunk/testapp/modules/unittest/classes/unittestservice.class.php

    r276 r289  
    6868   } 
    6969 
     70   function filterTest(){ 
     71      $test = jClasses::create("utfilter"); 
     72      $test->run(new jHtmlRespReporter($this->_rep)); 
     73   } 
     74 
    7075} 
    7176?> 
  • trunk/testapp/modules/unittest/controllers/default.classic.php

    r250 r289  
    7777   } 
    7878 
     79   function testfilter(){ 
     80      $rep = $this->getResponse('unittest'); 
     81      $rep->title = 'test unitaires sur jfilter'; 
     82 
     83      $ut = jClasses::create("unittestservice"); 
     84      $ut->init($rep); 
     85      $ut->filterTest(); 
     86 
     87      return $rep; 
     88   } 
    7989} 
    8090?> 
  • trunk/testapp/modules/unittest/templates/menu.tpl

    r276 r289  
    55<ul> 
    66    <li><a href="?module=unittest&amp;action=testselectoract">selecteurs d'action</a></li> 
    7  
    87</ul> 
    98<h3>jEvent</h3> 
    109<ul> 
    1110    <li><a href="?module=unittest&amp;action=testevent">lancer deux �nements</a></li> 
    12  
    1311</ul> 
    1412 
     
    2422    <li><a href="?module=unittest&amp;action=dao_parser2">Parser (2)</a></li> 
    2523    <li><a href="?module=unittest&amp;action=dao_conditions">jDaoConditions</a></li> 
     24</ul> 
    2625 
     26<h3>Utilitaires</h3> 
     27<ul> 
     28    <li><a href="?module=unittest&amp;action=testfilter">jFilter</a></li> 
    2729</ul> 
    2830 
    2931 
    30  
    3132<p><a href="?">Retour �'accueil</a></p> 
Download in other formats: Unified Diff Zip Archive