📄 v2.php
字号:
$ret = array(); if (!isset($contents['dir']['file'][0])) { $contents['dir']['file'] = array($contents['dir']['file']); } foreach ($contents['dir']['file'] as $file) { $name = $file['attribs']['name']; if (!$preserve) { $file = $file['attribs']; } $ret[$name] = $file; } if (!$preserve) { $this->_packageInfo['filelist'] = $ret; } return $ret; } return false; } /** * Return configure options array, if any * * @return array|false */ function getConfigureOptions() { if ($this->getPackageType() != 'extsrc') { return false; } $releases = $this->getReleases(); if (isset($releases[0])) { $releases = $release[0]; } if (isset($releases['configureoption'])) { if (!isset($releases['configureoption'][0])) { $releases['configureoption'] = array($releases['configureoption']); } for ($i = 0; $i < count($releases['configureoption']); $i++) { $releases['configureoption'][$i] = $releases['configureoption'][$i]['attribs']; } return $releases['configureoption']; } return false; } /** * This is only used at install-time, after all serialization * is over. */ function resetFilelist() { $this->_packageInfo['filelist'] = array(); } /** * Retrieve a list of files that should be installed on this computer * @return array */ function getInstallationFilelist($forfilecheck = false) { $contents = $this->getFilelist(true); if (isset($contents['dir']['attribs']['baseinstalldir'])) { $base = $contents['dir']['attribs']['baseinstalldir']; } if (isset($this->_packageInfo['bundle'])) { return PEAR::raiseError( 'Exception: bundles should be handled in download code only'); } $release = $this->getReleases(); if ($release) { if (!isset($release[0])) { if (!isset($release['installconditions']) && !isset($release['filelist'])) { if ($forfilecheck) { return $this->getFilelist(); } return $contents; } $release = array($release); } $depchecker = &$this->getPEARDependency2($this->_config, array(), array('channel' => $this->getChannel(), 'package' => $this->getPackage()), PEAR_VALIDATE_INSTALLING); foreach ($release as $instance) { if (isset($instance['installconditions'])) { $installconditions = $instance['installconditions']; if (is_array($installconditions)) { PEAR::pushErrorHandling(PEAR_ERROR_RETURN); foreach ($installconditions as $type => $conditions) { if (!isset($conditions[0])) { $conditions = array($conditions); } foreach ($conditions as $condition) { $ret = $depchecker->{"validate{$type}Dependency"}($condition); if (PEAR::isError($ret)) { PEAR::popErrorHandling(); continue 3; // skip this release } } } PEAR::popErrorHandling(); } } // this is the release to use if (isset($instance['filelist'])) { // ignore files if (isset($instance['filelist']['ignore'])) { $ignore = isset($instance['filelist']['ignore'][0]) ? $instance['filelist']['ignore'] : array($instance['filelist']['ignore']); foreach ($ignore as $ig) { unset ($contents[$ig['attribs']['name']]); } } // install files as this name if (isset($instance['filelist']['install'])) { $installas = isset($instance['filelist']['install'][0]) ? $instance['filelist']['install'] : array($instance['filelist']['install']); foreach ($installas as $as) { $contents[$as['attribs']['name']]['attribs']['install-as'] = $as['attribs']['as']; } } } if ($forfilecheck) { foreach ($contents as $file => $attrs) { $contents[$file] = $attrs['attribs']; } } return $contents; } } else { // simple release - no installconditions or install-as if ($forfilecheck) { return $this->getFilelist(); } return $contents; } // no releases matched return PEAR::raiseError('No releases in package.xml matched the existing operating ' . 'system, extensions installed, or architecture, cannot install'); } /** * This is only used at install-time, after all serialization * is over. * @param string file name * @param string installed path */ function setInstalledAs($file, $path) { if ($path) { return $this->_packageInfo['filelist'][$file]['installed_as'] = $path; } unset($this->_packageInfo['filelist'][$file]['installed_as']); } function getInstalledLocation($file) { if (isset($this->_packageInfo['filelist'][$file]['installed_as'])) { return $this->_packageInfo['filelist'][$file]['installed_as']; } return false; } /** * This is only used at install-time, after all serialization * is over. */ function installedFile($file, $atts) { if (isset($this->_packageInfo['filelist'][$file])) { $this->_packageInfo['filelist'][$file] = array_merge($this->_packageInfo['filelist'][$file], $atts['attribs']); } else { $this->_packageInfo['filelist'][$file] = $atts['attribs']; } } /** * Retrieve the contents tag */ function getContents() { if (isset($this->_packageInfo['contents'])) { return $this->_packageInfo['contents']; } return false; } /** * @param string full path to file * @param string attribute name * @param string attribute value * @param int risky but fast - use this to choose a file based on its position in the list * of files. Index is zero-based like PHP arrays. * @return bool success of operation */ function setFileAttribute($filename, $attr, $value, $index = false) { $this->_isValid = 0; if (in_array($attr, array('role', 'name', 'baseinstalldir'))) { $this->_filesValid = false; } if ($index !== false && isset($this->_packageInfo['contents']['dir']['file'][$index]['attribs'])) { $this->_packageInfo['contents']['dir']['file'][$index]['attribs'][$attr] = $value; return true; } if (!isset($this->_packageInfo['contents']['dir']['file'])) { return false; } $files = $this->_packageInfo['contents']['dir']['file']; if (!isset($files[0])) { $files = array($files); $ind = false; } else { $ind = true; } foreach ($files as $i => $file) { if (isset($file['attribs'])) { if ($file['attribs']['name'] == $filename) { if ($ind) { $this->_packageInfo['contents']['dir']['file'][$i]['attribs'][$attr] = $value; } else { $this->_packageInfo['contents']['dir']['file']['attribs'][$attr] = $value; } return true; } } } return false; } function setDirtree($path) { $this->_packageInfo['dirtree'][$path] = true; } function getDirtree() { if (isset($this->_packageInfo['dirtree']) && count($this->_packageInfo['dirtree'])) { return $this->_packageInfo['dirtree']; } return false; } function resetDirtree() { unset($this->_packageInfo['dirtree']); } /** * Determines whether this package claims it is compatible with the version of * the package that has a recommended version dependency * @param PEAR_PackageFile_v2|PEAR_PackageFile_v1|PEAR_Downloader_Package * @return boolean */ function isCompatible($pf) { if (!isset($this->_packageInfo['compatible'])) { return false; } if (!isset($this->_packageInfo['channel'])) { return false; } $me = $pf->getVersion(); $compatible = $this->_packageInfo['compatible']; if (!isset($compatible[0])) { $compatible = array($compatible); } $found = false; foreach ($compatible as $info) { if (strtolower($info['name']) == strtolower($pf->getPackage())) { if (strtolower($info['channel']) == strtolower($pf->getChannel())) { $found = true; break; } } } if (!$found) { return false; } if (isset($info['exclude'])) { if (!isset($info['exclude'][0])) { $info['exclude'] = array($info['exclude']); } foreach ($info['exclude'] as $exclude) { if (version_compare($me, $exclude, '==')) { return false; } } } if (version_compare($me, $info['min'], '>=') && version_compare($me, $info['max'], '<=')) { return true; } return false; } /** * @return array|false */ function getCompatible() { if (isset($this->_packageInfo['compatible'])) { return $this->_packageInfo['compatible']; } return false; } function getDependencies() { if (isset($this->_packageInfo['dependencies'])) { return $this->_packageInfo['dependencies']; } return false; } function isSubpackageOf($p) { return $p->isSubpackage($this); } /** * Determines whether the passed in package is a subpackage of this package. * * No version checking is done, only name verification. * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2 * @return bool */ function isSubpackage($p) { $sub = array(); if (isset($this->_packageInfo['dependencies']['required']['subpackage'])) { $sub = $this->_packageInfo['dependencies']['required']['subpackage']; if (!isset($sub[0])) { $sub = array($sub); } } if (isset($this->_packageInfo['dependencies']['optional']['subpackage'])) { $sub1 = $this->_packageInfo['dependencies']['optional']['subpackage']; if (!isset($sub1[0])) { $sub1 = array($sub1); } $sub = array_merge($sub, $sub1); } if (isset($this->_packageInfo['dependencies']['group'])) { $group = $this->_packageInfo['dependencies']['group']; if (!isset($group[0])) { $group = array($group); } foreach ($group as $deps) { if (isset($deps['subpackage'])) { $sub2 = $deps['subpackage']; if (!isset($sub2[0])) { $sub2 = array($sub2); } $sub = array_merge($sub, $sub2); } } } foreach ($sub as $dep) { if (strtolower($dep['name']) == strtolower($p->getPackage())) { if (isset($dep['channel'])) { if (strtolower($dep['channel']) == strtolower($p->getChannel())) { return true; } } else { if ($dep['uri'] == $p->getURI()) { return true; } } } } return false; } function dependsOn($package, $channel) { if (!($deps = $this->getDependencies())) { return false; } foreach (array('package', 'subpackage') as $type) { foreach (array('required', 'optional') as $needed) { if (isset($deps[$needed][$type])) { if (!isset($deps[$needed][$type][0])) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -