📄 v2.php
字号:
'self' => $this->getVersion()), 'package.xml 1.0 version "%version%" does not match "%self%"'); } function _differentState($state) { $this->_stack->push(__FUNCTION__, 'error', array('state' => $state, 'self' => $this->getState()), 'package.xml 1.0 state "%state%" does not match "%self%"'); } function _differentRole($handle, $role, $selfrole) { $this->_stack->push(__FUNCTION__, 'error', array('handle' => $handle, 'role' => $role, 'self' => $selfrole), 'package.xml 1.0 maintainer "%handle%" role "%role%" does not match "%self%"'); } function _differentEmail($handle, $email, $selfemail) { $this->_stack->push(__FUNCTION__, 'error', array('handle' => $handle, 'email' => $email, 'self' => $selfemail), 'package.xml 1.0 maintainer "%handle%" email "%email%" does not match "%self%"'); } function _differentName($handle, $name, $selfname) { $this->_stack->push(__FUNCTION__, 'error', array('handle' => $handle, 'name' => $name, 'self' => $selfname), 'package.xml 1.0 maintainer "%handle%" name "%name%" does not match "%self%"'); } function _unmatchedMaintainers($my, $yours) { if ($my) { array_walk($my, create_function('&$i, $k', '$i = $i["handle"];')); $this->_stack->push(__FUNCTION__, 'error', array('handles' => $my), 'package.xml 2.0 has unmatched extra maintainers "%handles%"'); } if ($yours) { array_walk($yours, create_function('&$i, $k', '$i = $i["handle"];')); $this->_stack->push(__FUNCTION__, 'error', array('handles' => $yours), 'package.xml 1.0 has unmatched extra maintainers "%handles%"'); } } function _differentNotes($notes) { $truncnotes = strlen($notes) < 25 ? $notes : substr($notes, 0, 24) . '...'; $truncmynotes = strlen($this->getNotes()) < 25 ? $this->getNotes() : substr($this->getNotes(), 0, 24) . '...'; $this->_stack->push(__FUNCTION__, 'error', array('notes' => $truncnotes, 'self' => $truncmynotes), 'package.xml 1.0 release notes "%notes%" do not match "%self%"'); } function _differentSummary($summary) { $truncsummary = strlen($summary) < 25 ? $summary : substr($summary, 0, 24) . '...'; $truncmysummary = strlen($this->getsummary()) < 25 ? $this->getSummary() : substr($this->getsummary(), 0, 24) . '...'; $this->_stack->push(__FUNCTION__, 'error', array('summary' => $truncsummary, 'self' => $truncmysummary), 'package.xml 1.0 summary "%summary%" does not match "%self%"'); } function _differentDescription($description) { $truncdescription = trim(strlen($description) < 25 ? $description : substr($description, 0, 24) . '...'); $truncmydescription = trim(strlen($this->getDescription()) < 25 ? $this->getDescription() : substr($this->getdescription(), 0, 24) . '...'); $this->_stack->push(__FUNCTION__, 'error', array('description' => $truncdescription, 'self' => $truncmydescription), 'package.xml 1.0 description "%description%" does not match "%self%"'); } function _missingFile($file) { $this->_stack->push(__FUNCTION__, 'error', array('file' => $file), 'package.xml 1.0 file "%file%" is not present in <contents>'); } /** * WARNING - do not use this function unless you know what you're doing */ function setRawState($state) { $this->_packageInfo['stability']['release'] = $state; } /** * WARNING - do not use this function unless you know what you're doing */ function setRawCompatible($compatible) { $this->_packageInfo['compatible'] = $compatible; } /** * WARNING - do not use this function unless you know what you're doing */ function setRawPackage($package) { $this->_packageInfo['name'] = $package; } /** * WARNING - do not use this function unless you know what you're doing */ function setRawChannel($channel) { $this->_packageInfo['channel'] = $channel; } function setRequestedGroup($group) { $this->_requestedGroup = $group; } function getRequestedGroup() { if (isset($this->_requestedGroup)) { return $this->_requestedGroup; } return false; } /** * For saving in the registry. * * Set the last version that was installed * @param string */ function setLastInstalledVersion($version) { $this->_packageInfo['_lastversion'] = $version; } /** * @return string|false */ function getLastInstalledVersion() { if (isset($this->_packageInfo['_lastversion'])) { return $this->_packageInfo['_lastversion']; } return false; } /** * Determines whether this package.xml has post-install scripts or not * @return array|false */ function listPostinstallScripts() { $filelist = $this->getFilelist(); $contents = $this->getContents(); $contents = $contents['dir']['file']; if (!is_array($contents) || !isset($contents[0])) { $contents = array($contents); } $taskfiles = array(); foreach ($contents as $file) { $atts = $file['attribs']; unset($file['attribs']); if (count($file)) { $taskfiles[$atts['name']] = $file; } } $common = new PEAR_Common; $common->debug = $this->_config->get('verbose'); $this->_scripts = array(); $ret = array(); foreach ($taskfiles as $name => $tasks) { if (!isset($filelist[$name])) { // ignored files will not be in the filelist continue; } $atts = $filelist[$name]; foreach ($tasks as $tag => $raw) { $task = $this->getTask($tag); $task = &new $task($this->_config, $common, PEAR_TASK_INSTALL); if ($task->isScript()) { $ret[] = $filelist[$name]['installed_as']; } } } if (count($ret)) { return $ret; } return false; } /** * Initialize post-install scripts for running * * This method can be used to detect post-install scripts, as the return value * indicates whether any exist * @return bool */ function initPostinstallScripts() { $filelist = $this->getFilelist(); $contents = $this->getContents(); $contents = $contents['dir']['file']; if (!is_array($contents) || !isset($contents[0])) { $contents = array($contents); } $taskfiles = array(); foreach ($contents as $file) { $atts = $file['attribs']; unset($file['attribs']); if (count($file)) { $taskfiles[$atts['name']] = $file; } } $common = new PEAR_Common; $common->debug = $this->_config->get('verbose'); $this->_scripts = array(); foreach ($taskfiles as $name => $tasks) { $atts = $filelist[$name]; foreach ($tasks as $tag => $raw) { $taskname = $this->getTask($tag); $task = &new $taskname($this->_config, $common, PEAR_TASK_INSTALL); if (!$task->isScript()) { continue; // scripts are only handled after installation } $lastversion = isset($this->_packageInfo['_lastversion']) ? $this->_packageInfo['_lastversion'] : null; $task->init($raw, $atts, $lastversion); $res = $task->startSession($this, $atts['installed_as']); if (!$res) { continue; // skip this file } if (PEAR::isError($res)) { return $res; } $assign = &$task; $this->_scripts[] = &$assign; } } if (count($this->_scripts)) { return true; } return false; } function runPostinstallScripts() { if ($this->initPostinstallScripts()) { $ui = &PEAR_Frontend::singleton(); if ($ui) { $ui->runPostinstallScripts($this->_scripts, $this); } } } /** * Convert a recursive set of <dir> and <file> tags into a single <dir> tag with * <file> tags. */ function flattenFilelist() { if (isset($this->_packageInfo['bundle'])) { return; } $filelist = array(); if (isset($this->_packageInfo['contents']['dir']['dir'])) { $this->_getFlattenedFilelist($filelist, $this->_packageInfo['contents']['dir']); if (!isset($filelist[1])) { $filelist = $filelist[0]; } $this->_packageInfo['contents']['dir']['file'] = $filelist; unset($this->_packageInfo['contents']['dir']['dir']); } else { // else already flattened but check for baseinstalldir propagation if (isset($this->_packageInfo['contents']['dir']['attribs']['baseinstalldir'])) { if (isset($this->_packageInfo['contents']['dir']['file'][0])) { foreach ($this->_packageInfo['contents']['dir']['file'] as $i => $file) { if (isset($file['attribs']['baseinstalldir'])) { continue; } $this->_packageInfo['contents']['dir']['file'][$i]['attribs']['baseinstalldir'] = $this->_packageInfo['contents']['dir']['attribs']['baseinstalldir']; } } else { if (!isset($this->_packageInfo['contents']['dir']['file']['attribs']['baseinstalldir'])) { $this->_packageInfo['contents']['dir']['file']['attribs']['baseinstalldir'] = $this->_packageInfo['contents']['dir']['attribs']['baseinstalldir']; } } } } } /** * @param array the final flattened file list * @param array the current directory being processed * @param string|false any recursively inherited baeinstalldir attribute * @param string private recursion variable * @return array * @access protected */ function _getFlattenedFilelist(&$files, $dir, $baseinstall = false, $path = '') { if (isset($dir['attribs']) && isset($dir['attribs']['baseinstalldir'])) { $baseinstall = $dir['attribs']['baseinstalldir']; } if (isset($dir['dir'])) { if (!isset($dir['dir'][0])) { $dir['dir'] = array($dir['dir']); } foreach ($dir['dir'] as $subdir) { if (!isset($subdir['attribs']) || !isset($subdir['attribs']['name'])) { $name = '*unknown*'; } else { $name = $subdir['attribs']['name']; } $newpath = empty($path) ? $name : $path . '/' . $name; $this->_getFlattenedFilelist($files, $subdir, $baseinstall, $newpath); } } if (isset($dir['file'])) { if (!isset($dir['file'][0])) { $dir['file'] = array($dir['file']); } foreach ($dir['file'] as $file) { $attrs = $file['attribs']; $name = $attrs['name']; if ($baseinstall && !isset($attrs['baseinstalldir'])) { $attrs['baseinstalldir'] = $baseinstall; } $attrs['name'] = empty($path) ? $name : $path . '/' . $name; $attrs['name'] = preg_replace(array('!\\\\+!', '!/+!'), array('/', '/'), $attrs['name']); $file['attribs'] = $attrs; $files[] = $file; } } } function setConfig(&$config) { $this->_config = &$config; $this->_registry = &$config->getRegistry(); } function setLogger(&$logger) { if (!is_object($logger) || !method_exists($logger, 'log')) { return PEAR::raiseError('Logger must be compatible with PEAR_Common::log'); } $this->_logger = &$logger; } /** * WARNING - do not use this function directly unless you know what you're doing */ function setDeps($deps) { $this->_packageInfo['dependencies'] = $deps; } function setPackagefile($file, $archive = false) { $this->_packageFile = $file; $this->_archiveFile = $archive ? $archive : $file; } /** * Wrapper to {@link PEAR_ErrorStack::getErrors()} * @param boolean determines whether to purge the error stack after retrieving * @return array */ function getValidationWarnings($purge = true) { return $this->_stack->getErrors($purge); } function getPackageFile() { return $this->_packageFile;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -