Changeset 1681

Show
Ignore:
Timestamp:
12/12/2007 08:04:09 PM (13 months ago)
Author:
driehle
Message:

updated Stringparser-Class to version 0.3.2

Location:
trunk/scripts
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/scripts/stringparser.class.php

    r1624 r1681  
    77 * upon this class. 
    88 *  
    9  * Version: 0.3.1 
     9 * Version: 0.3.2 
    1010 * 
    1111 * @author Christian Seiler <spam@christian-seiler.de> 
     
    1313 * @package stringparser 
    1414 * 
    15  *  This program is free software; you can redistribute it and/or modify 
    16  *  it under the terms of either: 
     15 * The MIT License 
    1716 * 
    18  *  a) the GNU General Public License as published by the Free 
    19  *  Software Foundation; either version 1, or (at your option) any 
    20  *  later version, or 
     17 * Copyright (c) 2004-2007 Christian Seiler 
    2118 * 
    22  *  b) the Artistic License as published by Larry Wall, either version 2.0, 
    23  *     or (at your option) any later version. 
     19 * Permission is hereby granted, free of charge, to any person obtaining a copy 
     20 * of this software and associated documentation files (the "Software"), to deal 
     21 * in the Software without restriction, including without limitation the rights 
     22 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
     23 * copies of the Software, and to permit persons to whom the Software is 
     24 * furnished to do so, subject to the following conditions: 
    2425 * 
    25  *  This program is distributed in the hope that it will be useful, 
    26  *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
    27  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See either 
    28  *  the GNU General Public License or the Artistic License for more details. 
     26 * The above copyright notice and this permission notice shall be included in 
     27 * all copies or substantial portions of the Software. 
    2928 * 
    30  *  You should have received a copy of the Artistic License with this Kit, 
    31  *  in the file named "Artistic.clarified".  If not, I'll be glad to provide 
    32  *  one. 
    33  * 
    34  *  You should also have received a copy of the GNU General Public License 
    35  *  along with this program in the file named "COPYING"; if not, write to 
    36  *  the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
    37  *  MA 02111-1307, USA. 
     29 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
     30 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
     31 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
     32 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
     33 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
     34 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
     35 * THE SOFTWARE. 
    3836 */ 
    3937 
  • trunk/scripts/stringparser_bbcode.class.php

    r1624 r1681  
    33 * BB code string parsing class 
    44 * 
    5  * Version: 0.3.1 
     5 * Version: 0.3.2 
    66 * 
    77 * @author Christian Seiler <spam@christian-seiler.de> 
     
    99 * @package stringparser 
    1010 * 
    11  *  This program is free software; you can redistribute it and/or modify 
    12  *  it under the terms of either: 
     11 * The MIT License 
    1312 * 
    14  *  a) the GNU General Public License as published by the Free 
    15  *  Software Foundation; either version 1, or (at your option) any 
    16  *  later version, or 
     13 * Copyright (c) 2004-2007 Christian Seiler 
    1714 * 
    18  *  b) the Artistic License as published by Larry Wall, either version 2.0, 
    19  *     or (at your option) any later version. 
     15 * Permission is hereby granted, free of charge, to any person obtaining a copy 
     16 * of this software and associated documentation files (the "Software"), to deal 
     17 * in the Software without restriction, including without limitation the rights 
     18 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
     19 * copies of the Software, and to permit persons to whom the Software is 
     20 * furnished to do so, subject to the following conditions: 
    2021 * 
    21  *  This program is distributed in the hope that it will be useful, 
    22  *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
    23  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See either 
    24  *  the GNU General Public License or the Artistic License for more details. 
     22 * The above copyright notice and this permission notice shall be included in 
     23 * all copies or substantial portions of the Software. 
    2524 * 
    26  *  You should have received a copy of the Artistic License with this Kit, 
    27  *  in the file named "Artistic.clarified".  If not, I'll be glad to provide 
    28  *  one. 
    29  * 
    30  *  You should also have received a copy of the GNU General Public License 
    31  *  along with this program in the file named "COPYING"; if not, write to 
    32  *  the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
    33  *  MA 02111-1307, USA. 
     25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
     26 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
     27 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
     28 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
     29 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
     30 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
     31 * THE SOFTWARE. 
    3432 */ 
    3533  
     
    773771         */ 
    774772        function _openElement ($type = 0) { 
    775                 $name = $this->_topNode ('name'); 
    776                 if (!isset ($this->_codes[$name])) { 
    777                         if (isset ($this->_codes[strtolower ($name)]) && (!$this->getCodeFlag (strtolower ($name), 'case_sensitive', 'boolean', true) || !$this->_caseSensitive)) { 
    778                                 $name = strtolower ($name); 
    779                         } else { 
    780                                 return $this->_reparseAfterCurrentBlock (); 
    781                         } 
     773                $name = $this->_getCanonicalName ($this->_topNode ('name')); 
     774                //var_dump ($name); 
     775                if ($name === false) { 
     776                        return $this->_reparseAfterCurrentBlock (); 
    782777                } 
    783778                $occ_type = $this->getCodeFlag ($name, 'occurrence_type', 'string'); 
     
    926921         */ 
    927922        function _isOpenableWithClose ($name, &$closecount) { 
    928                 $tnname = $this->_topNode ('name'); 
    929                 if (isset ($this->_codes[strtolower($tnname)]) && (!$this->getCodeFlag (strtolower($tnname), 'case_sensitive', 'boolean', true) || !$this->_caseSensitive)) { 
    930                         $tnname = strtolower($tnname); 
    931                 } 
     923                $tnname = $this->_getCanonicalName ($this->_topNode ('name')); 
    932924                if (!in_array ($this->getCodeFlag ($tnname, 'closetag', 'integer', BBCODE_CLOSETAG_IMPLICIT), array (BBCODE_CLOSETAG_FORBIDDEN, BBCODE_CLOSETAG_OPTIONAL))) { 
    933925                        return false; 
     
    991983         */ 
    992984        function &_findNamedNode ($name, $searchdeeper = false) { 
    993                 $lname = strtolower ($name); 
    994                 if (isset ($this->_codes[$lname]) && (!$this->getCodeFlag ($lname, 'case_sensitive', 'boolean', true) || !$this->_caseSensitive)) { 
    995                         $name = $lname; 
    996                         $case_sensitive = false; 
    997                 } else { 
    998                         $case_sensitive = true; 
     985                $lname = $this->_getCanonicalName ($name); 
     986                $case_sensitive = $this->_caseSensitive && $this->getCodeFlag ($lname, 'case_sensitive', 'boolean', true); 
     987                if ($case_sensitive) { 
     988                        $name = strtolower ($name); 
    999989                } 
    1000990                $scount = count ($this->_stack); 
     
    13431333         */ 
    13441334        function _isUseContent (&$node, $check_attrs = false) { 
    1345                 $name = strtolower($node->name ()); 
     1335                $name = $this->_getCanonicalName ($node->name ()); 
     1336                // this should NOT happen 
     1337                if ($name === false) { 
     1338                        return false; 
     1339                } 
    13461340                if ($this->_codes[$name]['callback_type'] == 'usecontent') { 
    13471341                        return true; 
     
    13701364                } 
    13711365                return !$result; 
     1366        } 
     1367 
     1368        /** 
     1369        * Get canonical name of a code 
     1370        * 
     1371        * @access protected 
     1372        * @param string $name 
     1373        * @return string 
     1374        */ 
     1375        function _getCanonicalName ($name) { 
     1376                if (isset ($this->_codes[$name])) { 
     1377                        return $name; 
     1378                } 
     1379                $found = false; 
     1380                // try to find the code in the code list 
     1381                foreach (array_keys ($this->_codes) as $rname) { 
     1382                        // match 
     1383                        if (strtolower ($rname) == strtolower ($name)) { 
     1384                                $found = $rname; 
     1385                                break; 
     1386                        } 
     1387                } 
     1388                if ($found === false || ($this->_caseSensitive && $this->getCodeFlag ($found, 'case_sensitive', 'boolean', true))) { 
     1389                        return false; 
     1390                } 
     1391                return $rname; 
    13721392        } 
    13731393} 
     
    18131833        function &_findPrevAdjentTextNodeHelper () { 
    18141834                $lastnode =& $this->lastChild (); 
    1815                 if ($lastnode->_type == STRINGPARSER_NODE_TEXT) { 
     1835                if ($lastnode === null || $lastnode->_type == STRINGPARSER_NODE_TEXT) { 
    18161836                        return $lastnode; 
    18171837                }