📄 remote.php
字号:
$base = $chan->getBaseURL('REST1.1', $this->config->get('preferred_mirror'))) { // use faster list-all if available $rest = &$this->config->getREST('1.1', array()); $available = $rest->listAll($base, $list_options); } elseif ($chan->supportsREST($this->config->get('preferred_mirror')) && $base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) { $rest = &$this->config->getREST('1.0', array()); $available = $rest->listAll($base, $list_options); } else { $r = &$this->config->getRemote(); if ($channel == 'pear.php.net') { // hack because of poor pearweb design $available = $r->call('package.listAll', true, $list_options, false); } else { $available = $r->call('package.listAll', true, $list_options); } } if (PEAR::isError($available)) { $this->config->set('default_channel', $savechannel); return $this->raiseError($available); } $i = $j = 0; $data = array( 'caption' => 'Channel ' . $channel . ' Available packages:', 'border' => true, 'headline' => array('Package', 'Version'), 'channel' => $channel ); if (count($available)==0) { $data = '(no packages available yet)'; } else { foreach ($available as $name => $info) { $data['data'][] = array($name, (isset($info['stable']) && $info['stable']) ? $info['stable'] : '-n/a-'); } } $this->ui->outputData($data, $command); $this->config->set('default_channel', $savechannel); return true; } // }}} // {{{ doListAll() function doListAll($command, $options, $params) { $savechannel = $channel = $this->config->get('default_channel'); $reg = &$this->config->getRegistry(); if (isset($options['channel'])) { $channel = $options['channel']; if ($reg->channelExists($channel)) { $this->config->set('default_channel', $channel); } else { return $this->raiseError("Channel \"$channel\" does not exist"); } } $list_options = false; if ($this->config->get('preferred_state') == 'stable') { $list_options = true; } $chan = $reg->getChannel($channel); if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) { return $e; } if ($chan->supportsREST($this->config->get('preferred_mirror')) && $base = $chan->getBaseURL('REST1.1', $this->config->get('preferred_mirror'))) { // use faster list-all if available $rest = &$this->config->getREST('1.1', array()); $available = $rest->listAll($base, $list_options, false); } elseif ($chan->supportsREST($this->config->get('preferred_mirror')) && $base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) { $rest = &$this->config->getREST('1.0', array()); $available = $rest->listAll($base, $list_options, false); } else { $r = &$this->config->getRemote(); if ($channel == 'pear.php.net') { // hack because of poor pearweb design $available = $r->call('package.listAll', true, $list_options, false); } else { $available = $r->call('package.listAll', true, $list_options); } } if (PEAR::isError($available)) { $this->config->set('default_channel', $savechannel); return $this->raiseError('The package list could not be fetched from the remote server. Please try again. (Debug info: "' . $available->getMessage() . '")'); } $data = array( 'caption' => 'All packages [Channel ' . $channel . ']:', 'border' => true, 'headline' => array('Package', 'Latest', 'Local'), 'channel' => $channel, ); if (isset($options['channelinfo'])) { // add full channelinfo $data['caption'] = 'Channel ' . $channel . ' All packages:'; $data['headline'] = array('Channel', 'Package', 'Latest', 'Local', 'Description', 'Dependencies'); } $local_pkgs = $reg->listPackages($channel); foreach ($available as $name => $info) { $installed = $reg->packageInfo($name, null, $channel); if (is_array($installed['version'])) { $installed['version'] = $installed['version']['release']; } $desc = $info['summary']; if (isset($params[$name])) { $desc .= "\n\n".$info['description']; } if (isset($options['mode'])) { if ($options['mode'] == 'installed' && !isset($installed['version'])) { continue; } if ($options['mode'] == 'notinstalled' && isset($installed['version'])) { continue; } if ($options['mode'] == 'upgrades' && (!isset($installed['version']) || version_compare($installed['version'], $info['stable'], '>='))) { continue; } } $pos = array_search(strtolower($name), $local_pkgs); if ($pos !== false) { unset($local_pkgs[$pos]); } if (isset($info['stable']) && !$info['stable']) { $info['stable'] = null; } if (isset($options['channelinfo'])) { // add full channelinfo if ($info['stable'] === $info['unstable']) { $state = $info['state']; } else { $state = 'stable'; } $latest = $info['stable'].' ('.$state.')'; $local = ''; if (isset($installed['version'])) { $inst_state = $reg->packageInfo($name, 'release_state', $channel); $local = $installed['version'].' ('.$inst_state.')'; } $packageinfo = array( $channel, $name, $latest, $local, isset($desc) ? $desc : null, isset($info['deps']) ? $info['deps'] : null, ); } else { $packageinfo = array( $reg->channelAlias($channel) . '/' . $name, isset($info['stable']) ? $info['stable'] : null, isset($installed['version']) ? $installed['version'] : null, isset($desc) ? $desc : null, isset($info['deps']) ? $info['deps'] : null, ); } $data['data'][$info['category']][] = $packageinfo; } if (isset($options['mode']) && in_array($options['mode'], array('notinstalled', 'upgrades'))) { $this->config->set('default_channel', $savechannel); $this->ui->outputData($data, $command); return true; } foreach ($local_pkgs as $name) { $info = &$reg->getPackage($name, $channel); $data['data']['Local'][] = array( $reg->channelAlias($channel) . '/' . $info->getPackage(), '', $info->getVersion(), $info->getSummary(), $info->getDeps() ); } $this->config->set('default_channel', $savechannel); $this->ui->outputData($data, $command); return true; } // }}} // {{{ doSearch() function doSearch($command, $options, $params) { if ((!isset($params[0]) || empty($params[0])) && (!isset($params[1]) || empty($params[1]))) { return $this->raiseError('no valid search string supplied'); }; $channelinfo = isset($options['channelinfo']); $reg = &$this->config->getRegistry(); if (isset($options['allchannels'])) { // search all channels unset($options['allchannels']); $channels = $reg->getChannels(); $errors = array(); PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); foreach ($channels as $channel) { if ($channel->getName() != '__uri') { $options['channel'] = $channel->getName(); $ret = $this->doSearch($command, $options, $params); if (PEAR::isError($ret)) { $errors[] = $ret; } } } PEAR::staticPopErrorHandling(); if (count($errors) !== 0) { // for now, only give first error return PEAR::raiseError($errors[0]); } return true; } $savechannel = $channel = $this->config->get('default_channel'); $package = $params[0]; $summary = isset($params[1]) ? $params[1] : false; if (isset($options['channel'])) { $reg = &$this->config->getRegistry(); $channel = $options['channel']; if ($reg->channelExists($channel)) { $this->config->set('default_channel', $channel); } else { return $this->raiseError('Channel "' . $channel . '" does not exist'); } } $chan = $reg->getChannel($channel); if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) { return $e; } if ($chan->supportsREST($this->config->get('preferred_mirror')) && $base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) { $rest = &$this->config->getREST('1.0', array()); $available = $rest->listAll($base, false, false, $package, $summary); } else { $r = &$this->config->getRemote(); $available = $r->call('package.search', $package, $summary, true, $this->config->get('preferred_state') == 'stable', true); } if (PEAR::isError($available)) { $this->config->set('default_channel', $savechannel); return $this->raiseError($available); } if (!$available && !$channelinfo) { // clean exit when not found, no error ! $data = 'no packages found that match pattern "' . $package . '", for channel '.$channel.'.'; $this->ui->outputData($data); $this->config->set('default_channel', $channel); return true; } if ($channelinfo) { $data = array( 'caption' => 'Matched packages, channel ' . $channel . ':', 'border' => true, 'headline' => array('Channel', 'Package', 'Stable/(Latest)', 'Local'), 'channel' => $channel ); } else { $data = array( 'caption' => 'Matched packages, channel ' . $channel . ':', 'border' => true,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -