📄 v2.php
字号:
<?php/** * PEAR_PackageFile_v2, package.xml version 2.0 * * 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: v2.php,v 1.1.2.2 2006/05/22 10:19:33 cellog Exp $ * @link http://pear.php.net/package/PEAR * @since File available since Release 1.4.0a1 *//** * For error handling */require_once 'PEAR/ErrorStack.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.0a1 */class PEAR_PackageFile_v2{ /** * Parsed package information * @var array * @access private */ var $_packageInfo = array(); /** * path to package .tgz or false if this is a local/extracted package.xml * @var string|false * @access private */ var $_archiveFile; /** * path to package .xml or false if this is an abstract parsed-from-string xml * @var string|false * @access private */ var $_packageFile; /** * This is used by file analysis routines to log progress information * @var PEAR_Common * @access protected */ var $_logger; /** * This is set to the highest validation level that has been validated * * If the package.xml is invalid or unknown, this is set to 0. If * normal validation has occurred, this is set to PEAR_VALIDATE_NORMAL. If * downloading/installation validation has occurred it is set to PEAR_VALIDATE_DOWNLOADING * or INSTALLING, and so on up to PEAR_VALIDATE_PACKAGING. This allows validation * "caching" to occur, which is particularly important for package validation, so * that PHP files are not validated twice * @var int * @access private */ var $_isValid = 0; /** * True if the filelist has been validated * @param bool */ var $_filesValid = false; /** * @var PEAR_Registry * @access protected */ var $_registry; /** * @var PEAR_Config * @access protected */ var $_config; /** * Optional Dependency group requested for installation * @var string * @access private */ var $_requestedGroup = false; /** * @var PEAR_ErrorStack * @access protected */ var $_stack; /** * Namespace prefix used for tasks in this package.xml - use tasks: whenever possible */ var $_tasksNs; /** * Determines whether this packagefile was initialized only with partial package info * * If this package file was constructed via parsing REST, it will only contain * * - package name * - channel name * - dependencies * @var boolean * @access private */ var $_incomplete = true; /** * @var PEAR_PackageFile_v2_Validator */ var $_v2Validator; /** * The constructor merely sets up the private error stack */ function PEAR_PackageFile_v2() { $this->_stack = new PEAR_ErrorStack('PEAR_PackageFile_v2', false, null); $this->_isValid = false; } /** * To make unit-testing easier * @param PEAR_Frontend_* * @param array options * @param PEAR_Config * @return PEAR_Downloader * @access protected */ function &getPEARDownloader(&$i, $o, &$c) { $z = &new PEAR_Downloader($i, $o, $c); return $z; } /** * To make unit-testing easier * @param PEAR_Config * @param array options * @param array package name as returned from {@link PEAR_Registry::parsePackageName()} * @param int PEAR_VALIDATE_* constant * @return PEAR_Dependency2 * @access protected */ function &getPEARDependency2(&$c, $o, $p, $s = PEAR_VALIDATE_INSTALLING) { if (!class_exists('PEAR_Dependency2')) { require_once 'PEAR/Dependency2.php'; } $z = &new PEAR_Dependency2($c, $o, $p, $s); return $z; } function getInstalledBinary() { return isset($this->_packageInfo['#binarypackage']) ? $this->_packageInfo['#binarypackage'] : false; } /** * Installation of source package has failed, attempt to download and install the * binary version of this package. * @param PEAR_Installer * @return array|false */ function installBinary(&$installer) { if (!OS_WINDOWS) { $a = false; return $a; } if ($this->getPackageType() == 'extsrc') { if (!is_array($installer->getInstallPackages())) { $a = false; return $a; } foreach ($installer->getInstallPackages() as $p) { if ($p->isExtension($this->_packageInfo['providesextension'])) { if ($p->getPackageType() != 'extsrc') { $a = false; return $a; // the user probably downloaded it separately } } } if (isset($this->_packageInfo['extsrcrelease']['binarypackage'])) { $installer->log(0, 'Attempting to download binary version of extension "' . $this->_packageInfo['providesextension'] . '"'); $params = $this->_packageInfo['extsrcrelease']['binarypackage']; if (!is_array($params) || !isset($params[0])) { $params = array($params); } if (isset($this->_packageInfo['channel'])) { foreach ($params as $i => $param) { $params[$i] = array('channel' => $this->_packageInfo['channel'], 'package' => $param, 'version' => $this->getVersion()); } } $dl = &$this->getPEARDownloader($installer->ui, $installer->getOptions(), $installer->config); $verbose = $dl->config->get('verbose'); $dl->config->set('verbose', -1); foreach ($params as $param) { PEAR::pushErrorHandling(PEAR_ERROR_RETURN); $ret = $dl->download(array($param)); PEAR::popErrorHandling(); if (is_array($ret) && count($ret)) { break; } } $dl->config->set('verbose', $verbose); if (is_array($ret)) { if (count($ret) == 1) { $pf = $ret[0]->getPackageFile(); PEAR::pushErrorHandling(PEAR_ERROR_RETURN); $err = $installer->install($ret[0]); PEAR::popErrorHandling(); if (is_array($err)) { $this->_packageInfo['#binarypackage'] = $ret[0]->getPackage(); // "install" self, so all dependencies will work transparently $this->_registry->addPackage2($this); $installer->log(0, 'Download and install of binary extension "' . $this->_registry->parsedPackageNameToString( array('channel' => $pf->getChannel(), 'package' => $pf->getPackage()), true) . '" successful'); $a = array($ret[0], $err); return $a; } $installer->log(0, 'Download and install of binary extension "' . $this->_registry->parsedPackageNameToString( array('channel' => $pf->getChannel(), 'package' => $pf->getPackage()), true) . '" failed'); } } } } $a = false; return $a; } /** * @return string|false Extension name */ function getProvidesExtension() { if (in_array($this->getPackageType(), array('extsrc', 'extbin'))) { if (isset($this->_packageInfo['providesextension'])) { return $this->_packageInfo['providesextension']; } } return false; } /** * @param string Extension name * @return bool */ function isExtension($extension) { if (in_array($this->getPackageType(), array('extsrc', 'extbin'))) { return $this->_packageInfo['providesextension'] == $extension; } return false; } /** * Tests whether every part of the package.xml 1.0 is represented in * this package.xml 2.0 * @param PEAR_PackageFile_v1 * @return bool */ function isEquivalent($pf1) { if (!$pf1) { return true; } if ($this->getPackageType() == 'bundle') { return false; } $this->_stack->getErrors(true); if (!$pf1->validate(PEAR_VALIDATE_NORMAL)) { return false; } $pass = true; if ($pf1->getPackage() != $this->getPackage()) { $this->_differentPackage($pf1->getPackage()); $pass = false; } if ($pf1->getVersion() != $this->getVersion()) { $this->_differentVersion($pf1->getVersion()); $pass = false; } if (trim($pf1->getSummary()) != $this->getSummary()) { $this->_differentSummary($pf1->getSummary()); $pass = false; } if (preg_replace('/\s+/', '', $pf1->getDescription()) != preg_replace('/\s+/', '', $this->getDescription())) { $this->_differentDescription($pf1->getDescription()); $pass = false; } if ($pf1->getState() != $this->getState()) { $this->_differentState($pf1->getState()); $pass = false; } if (!strstr(preg_replace('/\s+/', '', $this->getNotes()), preg_replace('/\s+/', '', $pf1->getNotes()))) { $this->_differentNotes($pf1->getNotes()); $pass = false; } $mymaintainers = $this->getMaintainers(); $yourmaintainers = $pf1->getMaintainers(); for ($i1 = 0; $i1 < count($yourmaintainers); $i1++) { $reset = false; for ($i2 = 0; $i2 < count($mymaintainers); $i2++) { if ($mymaintainers[$i2]['handle'] == $yourmaintainers[$i1]['handle']) { if ($mymaintainers[$i2]['role'] != $yourmaintainers[$i1]['role']) { $this->_differentRole($mymaintainers[$i2]['handle'], $yourmaintainers[$i1]['role'], $mymaintainers[$i2]['role']); $pass = false; } if ($mymaintainers[$i2]['email'] != $yourmaintainers[$i1]['email']) { $this->_differentEmail($mymaintainers[$i2]['handle'], $yourmaintainers[$i1]['email'], $mymaintainers[$i2]['email']); $pass = false; } if ($mymaintainers[$i2]['name'] != $yourmaintainers[$i1]['name']) { $this->_differentName($mymaintainers[$i2]['handle'], $yourmaintainers[$i1]['name'], $mymaintainers[$i2]['name']); $pass = false; } unset($mymaintainers[$i2]); $mymaintainers = array_values($mymaintainers); unset($yourmaintainers[$i1]); $yourmaintainers = array_values($yourmaintainers); $reset = true; break; } } if ($reset) { $i1 = -1; } } $this->_unmatchedMaintainers($mymaintainers, $yourmaintainers); $filelist = $this->getFilelist(); foreach ($pf1->getFilelist() as $file => $atts) { if (!isset($filelist[$file])) { $this->_missingFile($file); $pass = false; } } return $pass; } function _differentPackage($package) { $this->_stack->push(__FUNCTION__, 'error', array('package' => $package, 'self' => $this->getPackage()), 'package.xml 1.0 package "%package%" does not match "%self%"'); } function _differentVersion($version) { $this->_stack->push(__FUNCTION__, 'error', array('version' => $version,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -