⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rw.php

📁 php-4.4.7学习linux时下载的源代码
💻 PHP
📖 第 1 页 / 共 4 页
字号:
<?php/** * PEAR_PackageFile_v2, package.xml version 2.0, read/write version * * PHP versions 4 and 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt.  If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category   pear * @package    PEAR * @author     Greg Beaver <cellog@php.net> * @copyright  1997-2005 The PHP Group * @license    http://www.php.net/license/3_0.txt  PHP License 3.0 * @version    CVS: $Id: rw.php,v 1.1.2.2 2006/05/22 10:19:34 cellog Exp $ * @link       http://pear.php.net/package/PEAR * @since      File available since Release 1.4.0a8 *//** * For base class */require_once 'PEAR/PackageFile/v2.php';/** * @category   pear * @package    PEAR * @author     Greg Beaver <cellog@php.net> * @copyright  1997-2005 The PHP Group * @license    http://www.php.net/license/3_0.txt  PHP License 3.0 * @version    Release: @package_version@ * @link       http://pear.php.net/package/PEAR * @since      Class available since Release 1.4.0a8 */class PEAR_PackageFile_v2_rw extends PEAR_PackageFile_v2{    /**     * @param string Extension name     * @return bool success of operation     */    function setProvidesExtension($extension)    {        if (in_array($this->getPackageType(), array('extsrc', 'extbin'))) {            if (!isset($this->_packageInfo['providesextension'])) {                // ensure that the channel tag is set up in the right location                $this->_packageInfo = $this->_insertBefore($this->_packageInfo,                    array('usesrole', 'usestask', 'srcpackage', 'srcuri', 'phprelease',                    'extsrcrelease', 'extbinrelease', 'bundle', 'changelog'),                    $extension, 'providesextension');            }            $this->_packageInfo['providesextension'] = $extension;            return true;        }        return false;    }    function setPackage($package)    {        $this->_isValid = 0;        if (!isset($this->_packageInfo['attribs'])) {            $this->_packageInfo = array_merge(array('attribs' => array(                                 'version' => '2.0',                                 'xmlns' => 'http://pear.php.net/dtd/package-2.0',                                 'xmlns:tasks' => 'http://pear.php.net/dtd/tasks-1.0',                                 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',                                 'xsi:schemaLocation' => 'http://pear.php.net/dtd/tasks-1.0    http://pear.php.net/dtd/tasks-1.0.xsd    http://pear.php.net/dtd/package-2.0    http://pear.php.net/dtd/package-2.0.xsd',                             )), $this->_packageInfo);        }        if (!isset($this->_packageInfo['name'])) {            return $this->_packageInfo = array_merge(array('name' => $package),                $this->_packageInfo);        }        $this->_packageInfo['name'] = $package;    }    function setUri($uri)    {        unset($this->_packageInfo['channel']);        $this->_isValid = 0;        if (!isset($this->_packageInfo['uri'])) {            // ensure that the uri tag is set up in the right location            $this->_packageInfo = $this->_insertBefore($this->_packageInfo,                 array('extends', 'summary', 'description', 'lead',                'developer', 'contributor', 'helper', 'date', 'time', 'version',                'stability', 'license', 'notes', 'contents', 'compatible',                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',                'phprelease', 'extsrcrelease',                'extbinrelease', 'bundle', 'changelog'), $uri, 'uri');        }        $this->_packageInfo['uri'] = $uri;    }    function setChannel($channel)    {        unset($this->_packageInfo['uri']);        $this->_isValid = 0;        if (!isset($this->_packageInfo['channel'])) {            // ensure that the channel tag is set up in the right location            $this->_packageInfo = $this->_insertBefore($this->_packageInfo,                array('extends', 'summary', 'description', 'lead',                'developer', 'contributor', 'helper', 'date', 'time', 'version',                'stability', 'license', 'notes', 'contents', 'compatible',                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',                'phprelease', 'extsrcrelease',                'extbinrelease', 'bundle', 'changelog'), $channel, 'channel');        }        $this->_packageInfo['channel'] = $channel;    }    function setExtends($extends)    {        $this->_isValid = 0;        if (!isset($this->_packageInfo['extends'])) {            // ensure that the extends tag is set up in the right location            $this->_packageInfo = $this->_insertBefore($this->_packageInfo,                array('summary', 'description', 'lead',                'developer', 'contributor', 'helper', 'date', 'time', 'version',                'stability', 'license', 'notes', 'contents', 'compatible',                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',                'phprelease', 'extsrcrelease',                'extbinrelease', 'bundle', 'changelog'), $extends, 'extends');        }        $this->_packageInfo['extends'] = $extends;    }    function setSummary($summary)    {        $this->_isValid = 0;        if (!isset($this->_packageInfo['summary'])) {            // ensure that the summary tag is set up in the right location            $this->_packageInfo = $this->_insertBefore($this->_packageInfo,                array('description', 'lead',                'developer', 'contributor', 'helper', 'date', 'time', 'version',                'stability', 'license', 'notes', 'contents', 'compatible',                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',                'phprelease', 'extsrcrelease',                'extbinrelease', 'bundle', 'changelog'), $summary, 'summary');        }        $this->_packageInfo['summary'] = $summary;    }    function setDescription($desc)    {        $this->_isValid = 0;        if (!isset($this->_packageInfo['description'])) {            // ensure that the description tag is set up in the right location            $this->_packageInfo = $this->_insertBefore($this->_packageInfo,                array('lead',                'developer', 'contributor', 'helper', 'date', 'time', 'version',                'stability', 'license', 'notes', 'contents', 'compatible',                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',                'phprelease', 'extsrcrelease',                'extbinrelease', 'bundle', 'changelog'), $desc, 'description');        }        $this->_packageInfo['description'] = $desc;    }    /**     * Adds a new maintainer - no checking of duplicates is performed, use     * updatemaintainer for that purpose.     */    function addMaintainer($role, $handle, $name, $email, $active = 'yes')    {        if (!in_array($role, array('lead', 'developer', 'contributor', 'helper'))) {            return false;        }        if (isset($this->_packageInfo[$role])) {            if (!isset($this->_packageInfo[$role][0])) {                $this->_packageInfo[$role] = array($this->_packageInfo[$role]);            }            $this->_packageInfo[$role][] =                array(                    'name' => $name,                    'user' => $handle,                    'email' => $email,                    'active' => $active,                );        } else {            $testarr = array('lead',                    'developer', 'contributor', 'helper', 'date', 'time', 'version',                    'stability', 'license', 'notes', 'contents', 'compatible',                    'dependencies', 'providesextension', 'usesrole', 'usestask',                    'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease',                    'extbinrelease', 'bundle', 'changelog');            foreach (array('lead', 'developer', 'contributor', 'helper') as $testrole) {                array_shift($testarr);                if ($role == $testrole) {                    break;                }            }            if (!isset($this->_packageInfo[$role])) {                // ensure that the extends tag is set up in the right location                $this->_packageInfo = $this->_insertBefore($this->_packageInfo, $testarr,                    array(), $role);            }            $this->_packageInfo[$role] =                array(                    'name' => $name,                    'user' => $handle,                    'email' => $email,                    'active' => $active,                );        }        $this->_isValid = 0;    }    function updateMaintainer($newrole, $handle, $name, $email, $active = 'yes')    {        $found = false;        foreach (array('lead', 'developer', 'contributor', 'helper') as $role) {            if (!isset($this->_packageInfo[$role])) {                continue;            }            $info = $this->_packageInfo[$role];            if (!isset($info[0])) {                if ($info['user'] == $handle) {                    $found = true;                    break;                }            }            foreach ($info as $i => $maintainer) {                if ($maintainer['user'] == $handle) {                    $found = $i;                    break 2;                }            }        }        if ($found === false) {            return $this->addMaintainer($newrole, $handle, $name, $email, $active);        }        if ($found !== false) {            if ($found === true) {                unset($this->_packageInfo[$role]);            } else {                unset($this->_packageInfo[$role][$found]);                $this->_packageInfo[$role] = array_values($this->_packageInfo[$role]);            }        }        $this->addMaintainer($newrole, $handle, $name, $email, $active);        $this->_isValid = 0;    }    function deleteMaintainer($handle)    {        $found = false;        foreach (array('lead', 'developer', 'contributor', 'helper') as $role) {            if (!isset($this->_packageInfo[$role])) {                continue;            }            if (!isset($this->_packageInfo[$role][0])) {                $this->_packageInfo[$role] = array($this->_packageInfo[$role]);            }            foreach ($this->_packageInfo[$role] as $i => $maintainer) {                if ($maintainer['user'] == $handle) {                    $found = $i;                    break;                }            }            if ($found !== false) {                unset($this->_packageInfo[$role][$found]);                if (!count($this->_packageInfo[$role]) && $role == 'lead') {                    $this->_isValid = 0;                }                if (!count($this->_packageInfo[$role])) {                    unset($this->_packageInfo[$role]);                    return true;                }                $this->_packageInfo[$role] =                    array_values($this->_packageInfo[$role]);                if (count($this->_packageInfo[$role]) == 1) {                    $this->_packageInfo[$role] = $this->_packageInfo[$role][0];                }                return true;            }            if (count($this->_packageInfo[$role]) == 1) {                $this->_packageInfo[$role] = $this->_packageInfo[$role][0];            }        }        return false;    }    function setReleaseVersion($version)    {        if (isset($this->_packageInfo['version']) &&              isset($this->_packageInfo['version']['release'])) {            unset($this->_packageInfo['version']['release']);        }        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $version, array(            'version' => array('stability', 'license', 'notes', 'contents', 'compatible',                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',                'phprelease', 'extsrcrelease',                'extbinrelease', 'bundle', 'changelog'),            'release' => array('api')));        $this->_isValid = 0;    }    function setAPIVersion($version)    {        if (isset($this->_packageInfo['version']) &&              isset($this->_packageInfo['version']['api'])) {            unset($this->_packageInfo['version']['api']);        }        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $version, array(            'version' => array('stability', 'license', 'notes', 'contents', 'compatible',                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',                'phprelease', 'extsrcrelease',                'extbinrelease', 'bundle', 'changelog'),            'api' => array()));        $this->_isValid = 0;    }    /**     * snapshot|devel|alpha|beta|stable     */    function setReleaseStability($state)    {        if (isset($this->_packageInfo['stability']) &&              isset($this->_packageInfo['stability']['release'])) {            unset($this->_packageInfo['stability']['release']);        }        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $state, array(            'stability' => array('license', 'notes', 'contents', 'compatible',                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',                'phprelease', 'extsrcrelease',                'extbinrelease', 'bundle', 'changelog'),            'release' => array('api')));        $this->_isValid = 0;    }    /**     * @param devel|alpha|beta|stable     */    function setAPIStability($state)    {        if (isset($this->_packageInfo['stability']) &&              isset($this->_packageInfo['stability']['api'])) {            unset($this->_packageInfo['stability']['api']);        }        $this->_packageInfo = $this->_mergeTag($this->_packageInfo, $state, array(            'stability' => array('license', 'notes', 'contents', 'compatible',                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',                'phprelease', 'extsrcrelease',                'extbinrelease', 'bundle', 'changelog'),            'api' => array()));        $this->_isValid = 0;    }    function setLicense($license, $uri = false, $filesource = false)    {        if (!isset($this->_packageInfo['license'])) {            // ensure that the license tag is set up in the right location            $this->_packageInfo = $this->_insertBefore($this->_packageInfo,                array('notes', 'contents', 'compatible',                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',                'phprelease', 'extsrcrelease',                'extbinrelease', 'bundle', 'changelog'), 0, 'license');        }        if ($uri || $filesource) {            $attribs = array();            if ($uri) {                $attribs['uri'] = $uri;            }            $uri = true; // for test below            if ($filesource) {                $attribs['filesource'] = $filesource;            }        }        $license = $uri ? array('attribs' => $attribs, '_content' => $license) : $license;        $this->_packageInfo['license'] = $license;        $this->_isValid = 0;    }    function setNotes($notes)    {        $this->_isValid = 0;        if (!isset($this->_packageInfo['notes'])) {            // ensure that the notes tag is set up in the right location            $this->_packageInfo = $this->_insertBefore($this->_packageInfo,                array('contents', 'compatible',                'dependencies', 'providesextension', 'usesrole', 'usestask', 'srcpackage', 'srcuri',                'phprelease', 'extsrcrelease',                'extbinrelease', 'bundle', 'changelog'), $notes, 'notes');        }        $this->_packageInfo['notes'] = $notes;    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -