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

📄 channels.php

📁 php-4.4.7学习linux时下载的源代码
💻 PHP
📖 第 1 页 / 共 3 页
字号:
<?php// /* vim: set expandtab tabstop=4 shiftwidth=4: *//** * PEAR_Command_Channels (list-channels, update-channels, channel-delete, channel-add, * channel-update, channel-info, channel-alias, channel-discover commands) * * 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     Stig Bakken <ssb@php.net> * @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: Channels.php,v 1.1.2.1 2005/11/02 16:57:23 cellog Exp $ * @link       http://pear.php.net/package/PEAR * @since      File available since Release 1.4.0a1 *//** * base class */require_once 'PEAR/Command/Common.php';/** * PEAR commands for managing channels. * * @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.0a1 */class PEAR_Command_Channels extends PEAR_Command_Common{    // {{{ properties    var $commands = array(        'list-channels' => array(            'summary' => 'List Available Channels',            'function' => 'doList',            'shortcut' => 'lc',            'options' => array(),            'doc' => 'List all available channels for installation.',            ),        'update-channels' => array(            'summary' => 'Update the Channel List',            'function' => 'doUpdateAll',            'shortcut' => 'uc',            'options' => array(),            'doc' => 'List all installed packages in all channels.'            ),        'channel-delete' => array(            'summary' => 'Remove a Channel From the List',            'function' => 'doDelete',            'shortcut' => 'cde',            'options' => array(),            'doc' => '<channel name>Delete a channel from the registry.  You may notremove any channel that has installed packages.'            ),        'channel-add' => array(            'summary' => 'Add a Channel',            'function' => 'doAdd',            'shortcut' => 'ca',            'options' => array(),            'doc' => '<channel.xml>Add a private channel to the channel list.  Note that allpublic channels should be synced using "update-channels".Parameter may be either a local file or remote URL to achannel.xml.'            ),        'channel-update' => array(            'summary' => 'Update an Existing Channel',            'function' => 'doUpdate',            'shortcut' => 'cu',            'options' => array(                'force' => array(                    'shortopt' => 'f',                    'doc' => 'will force download of new channel.xml if an existing channel name is used',                    ),                'channel' => array(                    'shortopt' => 'c',                    'arg' => 'CHANNEL',                    'doc' => 'will force download of new channel.xml if an existing channel name is used',                    ),),            'doc' => '[<channel.xml>|<channel name>]Update a channel in the channel list directly.  Note that allpublic channels can be synced using "update-channels".Parameter may be a local or remote channel.xml, or the name ofan existing channel.'            ),        'channel-info' => array(            'summary' => 'Retrieve Information on a Channel',            'function' => 'doInfo',            'shortcut' => 'ci',            'options' => array(),            'doc' => '<package>List the files in an installed package.'            ),        'channel-alias' => array(            'summary' => 'Specify an alias to a channel name',            'function' => 'doAlias',            'shortcut' => 'cha',            'options' => array(),            'doc' => '<channel> <alias>Specify a specific alias to use for a channel name.The alias may not be an existing channel name oralias.'            ),        'channel-discover' => array(            'summary' => 'Initialize a Channel from its server',            'function' => 'doDiscover',            'shortcut' => 'di',            'options' => array(),            'doc' => '<package>List the files in an installed package.'            ),        );    // }}}    // {{{ constructor    /**     * PEAR_Command_Registry constructor.     *     * @access public     */    function PEAR_Command_Channels(&$ui, &$config)    {        parent::PEAR_Command_Common($ui, $config);    }    // }}}    // {{{ doList()        function _sortChannels($a, $b)    {        return strnatcasecmp($a->getName(), $b->getName());    }    function doList($command, $options, $params)    {        $reg = &$this->config->getRegistry();        $registered = $reg->getChannels();        usort($registered, array(&$this, '_sortchannels'));        $i = $j = 0;        $data = array(            'caption' => 'Registered Channels:',            'border' => true,            'headline' => array('Channel', 'Summary')            );        foreach ($registered as $channel) {            $data['data'][] = array($channel->getName(),                                      $channel->getSummary());        }        if (count($registered)==0) {            $data = '(no registered channels)';        }        $this->ui->outputData($data, $command);        return true;    }        function doUpdateAll($command, $options, $params)    {        $reg = &$this->config->getRegistry();        $savechannel = $this->config->get('default_channel');        if (isset($options['channel'])) {            if (!$reg->channelExists($options['channel'])) {                return $this->raiseError('Unknown channel "' . $options['channel'] . '"');            }            $this->config->set('default_channel', $options['channel']);        } else {            $this->config->set('default_channel', 'pear.php.net');        }        $remote = &$this->config->getRemote();        $channels = $remote->call('channel.listAll');        if (PEAR::isError($channels)) {            $this->config->set('default_channel', $savechannel);            return $channels;        }        if (!is_array($channels) || isset($channels['faultCode'])) {            $this->config->set('default_channel', $savechannel);            return $this->raiseError("Incorrect channel listing returned from channel '$chan'");        }        if (!count($channels)) {            $data = 'no updates available';        }        $dl = &$this->getDownloader();        if (!class_exists('System')) {            require_once 'System.php';        }        $tmpdir = System::mktemp(array('-d'));        foreach ($channels as $channel) {            $channel = $channel[0];            $save = $channel;            if ($reg->channelExists($channel, true)) {                $this->ui->outputData("Updating channel \"$channel\"", $command);                $test = $reg->getChannel($channel, true);                if (!$test) {                    $this->ui->outputData("Channel '$channel' is corrupt in registry!", $command);                    $lastmodified = false;                } else {                    $lastmodified = $test->lastModified();                                    }                PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);                $contents = $dl->downloadHttp('http://' . $test->getName() . '/channel.xml',                    $this->ui, $tmpdir, null, $lastmodified);                PEAR::staticPopErrorHandling();                if (PEAR::isError($contents)) {                    $this->ui->outputData('ERROR: Cannot retrieve channel.xml for channel "' .                        $test->getName() . '"', $command);                    continue;                }                if (!$contents) {                    $this->ui->outputData("Channel \"$channel\" is up-to-date", $command);                    continue;                }                list($contents, $lastmodified) = $contents;                $info = implode('', file($contents));                if (!$info) {                    $this->ui->outputData("Channel \"$channel\" is up-to-date", $command);                    continue;                }                if (!class_exists('PEAR_ChannelFile')) {                    require_once 'PEAR/ChannelFile.php';                }                $channelinfo = new PEAR_ChannelFile;                $channelinfo->fromXmlString($info);                if ($channelinfo->getErrors()) {                    $this->ui->outputData("Downloaded channel data from channel \"$channel\" " .                         'is corrupt, skipping', $command);                    continue;                }                $channel = $channelinfo;

⌨️ 快捷键说明

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