Ignore:
Timestamp:
2014/08/22 18:31:39 (12 years ago)
Author:
kimoto
Message:

#2609 モジュールのバグfix

XML_Util 1.2.3
Mobile_Detect 2.8.3
Cache_Lite 1.7.16
Archive_Tar 1.3.12

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_13-dev/data/module/XML/Util.php

    r21713 r23600  
    77 * 
    88 * XML Utilities package 
    9  *  
     9 * 
    1010 * PHP versions 4 and 5 
    1111 * 
     
    4444 * @copyright 2003-2008 Stephan Schmidt <[email protected]> 
    4545 * @license   http://opensource.org/licenses/bsd-license New BSD License 
    46  * @version   CVS: $Id: Util.php,v 1.38 2008/11/13 00:03:38 ashnazg Exp $ 
     46 * @version   CVS: $Id$ 
    4747 * @link      http://pear.php.net/package/XML_Util 
    4848 */ 
     
    120120 * @copyright 2003-2008 Stephan Schmidt <[email protected]> 
    121121 * @license   http://opensource.org/licenses/bsd-license New BSD License 
    122  * @version   Release: 1.2.1 
     122 * @version   Release: 1.2.3 
    123123 * @link      http://pear.php.net/package/XML_Util 
    124124 */ 
     
    162162     * </code> 
    163163     * 
    164      * @param string $string          string where XML special chars  
     164     * @param string $string          string where XML special chars 
    165165     *                                should be replaced 
    166      * @param int    $replaceEntities setting for entities in attribute values  
    167      *                                (one of XML_UTIL_ENTITIES_XML,  
    168      *                                XML_UTIL_ENTITIES_XML_REQUIRED,  
     166     * @param int    $replaceEntities setting for entities in attribute values 
     167     *                                (one of XML_UTIL_ENTITIES_XML, 
     168     *                                XML_UTIL_ENTITIES_XML_REQUIRED, 
    169169     *                                XML_UTIL_ENTITIES_HTML) 
    170170     * @param string $encoding        encoding value (if any)... 
     
    228228     * </code> 
    229229     * 
    230      * @param string $string          string where XML special chars  
     230     * @param string $string          string where XML special chars 
    231231     *                                should be replaced 
    232      * @param int    $replaceEntities setting for entities in attribute values  
    233      *                                (one of XML_UTIL_ENTITIES_XML,  
    234      *                                XML_UTIL_ENTITIES_XML_REQUIRED,  
     232     * @param int    $replaceEntities setting for entities in attribute values 
     233     *                                (one of XML_UTIL_ENTITIES_XML, 
     234     *                                XML_UTIL_ENTITIES_XML_REQUIRED, 
    235235     *                                XML_UTIL_ENTITIES_HTML) 
    236236     * @param string $encoding        encoding value (if any)... 
     
    287287     * @uses attributesToString() to serialize the attributes of the XML declaration 
    288288     */ 
    289     function getXMLDeclaration($version = '1.0', $encoding = null,  
     289    function getXMLDeclaration($version = '1.0', $encoding = null, 
    290290        $standalone = null) 
    291291    { 
     
    302302        } 
    303303 
    304         return sprintf('<?xml%s?>',  
     304        return sprintf('<?xml%s?>', 
    305305            XML_Util::attributesToString($attributes, false)); 
    306306    } 
     
    317317     * 
    318318     * @param string $root        name of the root tag 
    319      * @param string $uri         uri of the doctype definition  
     319     * @param string $uri         uri of the doctype definition 
    320320     *                            (or array with uri and public id) 
    321321     * @param string $internalDtd internal dtd entries 
     
    359359     * 
    360360     * @param array      $attributes attribute array 
    361      * @param bool|array $sort       sort attribute list alphabetically,  
    362      *                               may also be an assoc array containing  
    363      *                               the keys 'sort', 'multiline', 'indent',  
     361     * @param bool|array $sort       sort attribute list alphabetically, 
     362     *                               may also be an assoc array containing 
     363     *                               the keys 'sort', 'multiline', 'indent', 
    364364     *                               'linebreak' and 'entities' 
    365      * @param bool       $multiline  use linebreaks, if more than  
     365     * @param bool       $multiline  use linebreaks, if more than 
    366366     *                               one attribute is given 
    367      * @param string     $indent     string used for indentation of  
     367     * @param string     $indent     string used for indentation of 
    368368     *                               multiline attributes 
    369      * @param string     $linebreak  string used for linebreaks of  
     369     * @param string     $linebreak  string used for linebreaks of 
    370370     *                               multiline attributes 
    371      * @param int        $entities   setting for entities in attribute values  
    372      *                               (one of XML_UTIL_ENTITIES_NONE,  
    373      *                               XML_UTIL_ENTITIES_XML,  
    374      *                               XML_UTIL_ENTITIES_XML_REQUIRED,  
     371     * @param int        $entities   setting for entities in attribute values 
     372     *                               (one of XML_UTIL_ENTITIES_NONE, 
     373     *                               XML_UTIL_ENTITIES_XML, 
     374     *                               XML_UTIL_ENTITIES_XML_REQUIRED, 
    375375     *                               XML_UTIL_ENTITIES_HTML) 
    376376     * 
     
    381381     * @todo allow sort also to be an options array 
    382382     */ 
    383     function attributesToString($attributes, $sort = true, $multiline = false,  
     383    function attributesToString($attributes, $sort = true, $multiline = false, 
    384384        $indent = '    ', $linebreak = "\n", $entities = XML_UTIL_ENTITIES_XML) 
    385385    { 
     
    452452     *       in the IF branch 
    453453     */ 
    454     function collapseEmptyTags($xml, $mode = XML_UTIL_COLLAPSE_ALL)  
     454    function collapseEmptyTags($xml, $mode = XML_UTIL_COLLAPSE_ALL) 
    455455    { 
    456456        if ($mode == XML_UTIL_COLLAPSE_XHTML_ONLY) { 
     
    475475     * 
    476476     * // create an XML tag: 
    477      * $tag = XML_Util::createTag('myNs:myTag',  
    478      *     array('foo' => 'bar'),  
    479      *     'This is inside the tag',  
     477     * $tag = XML_Util::createTag('myNs:myTag', 
     478     *     array('foo' => 'bar'), 
     479     *     'This is inside the tag', 
    480480     *     'http://www.w3c.org/myNs#'); 
    481481     * </code> 
     
    485485     * @param mixed  $content         the content 
    486486     * @param string $namespaceUri    URI of the namespace 
    487      * @param int    $replaceEntities whether to replace XML special chars in  
    488      *                                content, embedd it in a CData section  
     487     * @param int    $replaceEntities whether to replace XML special chars in 
     488     *                                content, embedd it in a CData section 
    489489     *                                or none of both 
    490      * @param bool   $multiline       whether to create a multiline tag where  
     490     * @param bool   $multiline       whether to create a multiline tag where 
    491491     *                                each attribute gets written to a single line 
    492      * @param string $indent          string used to indent attributes  
    493      *                                (_auto indents attributes so they start  
     492     * @param string $indent          string used to indent attributes 
     493     *                                (_auto indents attributes so they start 
    494494     *                                at the same column) 
    495495     * @param string $linebreak       string used for linebreaks 
     
    502502     * @uses createTagFromArray() to create the tag 
    503503     */ 
    504     function createTag($qname, $attributes = array(), $content = null,  
    505         $namespaceUri = null, $replaceEntities = XML_UTIL_REPLACE_ENTITIES,  
    506         $multiline = false, $indent = '_auto', $linebreak = "\n",  
     504    function createTag($qname, $attributes = array(), $content = null, 
     505        $namespaceUri = null, $replaceEntities = XML_UTIL_REPLACE_ENTITIES, 
     506        $multiline = false, $indent = '_auto', $linebreak = "\n", 
    507507        $sortAttributes = true) 
    508508    { 
     
    522522        } 
    523523 
    524         return XML_Util::createTagFromArray($tag, $replaceEntities, $multiline,  
     524        return XML_Util::createTagFromArray($tag, $replaceEntities, $multiline, 
    525525            $indent, $linebreak, $sortAttributes); 
    526526    } 
     
    532532     * array( 
    533533     *     // qualified name of the tag 
    534      *     'qname' => $qname         
     534     *     'qname' => $qname 
    535535     * 
    536536     *     // namespace prefix (optional, if qname is specified or no namespace) 
    537      *     'namespace' => $namespace     
     537     *     'namespace' => $namespace 
    538538     * 
    539539     *     // local part of the tagname (optional, if qname is specified) 
    540      *     'localpart' => $localpart,    
     540     *     'localpart' => $localpart, 
    541541     * 
    542542     *     // array containing all attributes (optional) 
    543      *     'attributes' => array(),       
     543     *     'attributes' => array(), 
    544544     * 
    545545     *     // tag content (optional) 
    546      *     'content' => $content,      
     546     *     'content' => $content, 
    547547     * 
    548548     *     // namespaceUri for the given namespace (optional) 
    549      *     'namespaceUri' => $namespaceUri  
     549     *     'namespaceUri' => $namespaceUri 
    550550     * ) 
    551551     * </pre> 
     
    565565     * 
    566566     * @param array  $tag             tag definition 
    567      * @param int    $replaceEntities whether to replace XML special chars in  
    568      *                                content, embedd it in a CData section  
     567     * @param int    $replaceEntities whether to replace XML special chars in 
     568     *                                content, embedd it in a CData section 
    569569     *                                or none of both 
    570      * @param bool   $multiline       whether to create a multiline tag where each  
     570     * @param bool   $multiline       whether to create a multiline tag where each 
    571571     *                                attribute gets written to a single line 
    572      * @param string $indent          string used to indent attributes  
    573      *                                (_auto indents attributes so they start  
     572     * @param string $indent          string used to indent attributes 
     573     *                                (_auto indents attributes so they start 
    574574     *                                at the same column) 
    575575     * @param string $linebreak       string used for linebreaks 
     
    586586     */ 
    587587    function createTagFromArray($tag, $replaceEntities = XML_UTIL_REPLACE_ENTITIES, 
    588         $multiline = false, $indent = '_auto', $linebreak = "\n",  
     588        $multiline = false, $indent = '_auto', $linebreak = "\n", 
    589589        $sortAttributes = true) 
    590590    { 
     
    596596        if (!isset($tag['qname']) && !isset($tag['localPart'])) { 
    597597            return XML_Util::raiseError('You must either supply a qualified name ' 
    598                 . '(qname) or local tag name (localPart).',  
     598                . '(qname) or local tag name (localPart).', 
    599599                XML_UTIL_ERROR_NO_TAG_NAME); 
    600600        } 
     
    650650 
    651651        // create attribute list 
    652         $attList = XML_Util::attributesToString($tag['attributes'],  
    653             $sortAttributes, $multiline, $indent, $linebreak, $replaceEntities); 
     652        $attList = XML_Util::attributesToString($tag['attributes'], 
     653            $sortAttributes, $multiline, $indent, $linebreak); 
    654654        if (!isset($tag['content']) || (string)$tag['content'] == '') { 
    655655            $tag = sprintf('<%s%s />', $tag['qname'], $attList); 
     
    662662                break; 
    663663            default: 
    664                 $tag['content'] = XML_Util::replaceEntities($tag['content'],  
     664                $tag['content'] = XML_Util::replaceEntities($tag['content'], 
    665665                    $replaceEntities); 
    666666                break; 
     
    679679     * 
    680680     * // create an XML start element: 
    681      * $tag = XML_Util::createStartElement('myNs:myTag',  
     681     * $tag = XML_Util::createStartElement('myNs:myTag', 
    682682     *     array('foo' => 'bar') ,'http://www.w3c.org/myNs#'); 
    683683     * </code> 
     
    686686     * @param array  $attributes     array containg attributes 
    687687     * @param string $namespaceUri   URI of the namespace 
    688      * @param bool   $multiline      whether to create a multiline tag where each  
     688     * @param bool   $multiline      whether to create a multiline tag where each 
    689689     *                               attribute gets written to a single line 
    690690     * @param string $indent         string used to indent attributes (_auto indents 
     
    699699     */ 
    700700    function createStartElement($qname, $attributes = array(), $namespaceUri = null, 
    701         $multiline = false, $indent = '_auto', $linebreak = "\n",  
     701        $multiline = false, $indent = '_auto', $linebreak = "\n", 
    702702        $sortAttributes = true) 
    703703    { 
     
    729729 
    730730        // create attribute list 
    731         $attList = XML_Util::attributesToString($attributes, $sortAttributes,  
     731        $attList = XML_Util::attributesToString($attributes, $sortAttributes, 
    732732            $multiline, $indent, $linebreak); 
    733733        $element = sprintf('<%s%s>', $qname, $attList); 
     
    798798    function createCDataSection($data) 
    799799    { 
    800         return sprintf('<![CDATA[%s]]>',  
     800        return sprintf('<![CDATA[%s]]>', 
    801801            preg_replace('/\]\]>/', ']]]]><![CDATA[>', strval($data))); 
    802802 
     
    872872    { 
    873873        // check for invalid chars 
    874         if (!preg_match('/^[[:alpha:]_]$/', $string{0})) { 
     874        if (!preg_match('/^[[:alpha:]_]\\z/', $string{0})) { 
    875875            return XML_Util::raiseError('XML names may only start with letter ' 
    876876                . 'or underscore', XML_UTIL_ERROR_INVALID_START); 
     
    878878 
    879879        // check for invalid chars 
    880         if (!preg_match('/^([[:alpha:]_]([[:alnum:]\-\.]*)?:)?[[:alpha:]_]([[:alnum:]\_\-\.]+)?$/', 
     880        if (!preg_match('/^([[:alpha:]_]([[:alnum:]\-\.]*)?:)?[[:alpha:]_]([[:alnum:]\_\-\.]+)?\\z/', 
    881881            $string) 
    882882        ) { 
    883883            return XML_Util::raiseError('XML names may only contain alphanumeric ' 
    884                 . 'chars, period, hyphen, colon and underscores',  
     884                . 'chars, period, hyphen, colon and underscores', 
    885885                XML_UTIL_ERROR_INVALID_CHARS); 
    886886        } 
Note: See TracChangeset for help on using the changeset viewer.