PageRenderTime 52ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/php/PEAR/PackageFile/v2.php

https://bitbucket.org/adarshj/convenient_website
PHP | 2049 lines | 1579 code | 122 blank | 348 comment | 306 complexity | 76d76e677471159a4bd4595190f849f8 MD5 | raw file
Possible License(s): Apache-2.0, MPL-2.0-no-copyleft-exception, LGPL-2.1, BSD-2-Clause, GPL-2.0, LGPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. * PEAR_PackageFile_v2, package.xml version 2.0
  4. *
  5. * PHP versions 4 and 5
  6. *
  7. * @category pear
  8. * @package PEAR
  9. * @author Greg Beaver <cellog@php.net>
  10. * @copyright 1997-2009 The Authors
  11. * @license http://opensource.org/licenses/bsd-license.php New BSD License
  12. * @version CVS: $Id: v2.php 313023 2011-07-06 19:17:11Z dufuz $
  13. * @link http://pear.php.net/package/PEAR
  14. * @since File available since Release 1.4.0a1
  15. */
  16. /**
  17. * For error handling
  18. */
  19. require_once 'PEAR/ErrorStack.php';
  20. /**
  21. * @category pear
  22. * @package PEAR
  23. * @author Greg Beaver <cellog@php.net>
  24. * @copyright 1997-2009 The Authors
  25. * @license http://opensource.org/licenses/bsd-license.php New BSD License
  26. * @version Release: 1.9.4
  27. * @link http://pear.php.net/package/PEAR
  28. * @since Class available since Release 1.4.0a1
  29. */
  30. class PEAR_PackageFile_v2
  31. {
  32. /**
  33. * Parsed package information
  34. * @var array
  35. * @access private
  36. */
  37. var $_packageInfo = array();
  38. /**
  39. * path to package .tgz or false if this is a local/extracted package.xml
  40. * @var string|false
  41. * @access private
  42. */
  43. var $_archiveFile;
  44. /**
  45. * path to package .xml or false if this is an abstract parsed-from-string xml
  46. * @var string|false
  47. * @access private
  48. */
  49. var $_packageFile;
  50. /**
  51. * This is used by file analysis routines to log progress information
  52. * @var PEAR_Common
  53. * @access protected
  54. */
  55. var $_logger;
  56. /**
  57. * This is set to the highest validation level that has been validated
  58. *
  59. * If the package.xml is invalid or unknown, this is set to 0. If
  60. * normal validation has occurred, this is set to PEAR_VALIDATE_NORMAL. If
  61. * downloading/installation validation has occurred it is set to PEAR_VALIDATE_DOWNLOADING
  62. * or INSTALLING, and so on up to PEAR_VALIDATE_PACKAGING. This allows validation
  63. * "caching" to occur, which is particularly important for package validation, so
  64. * that PHP files are not validated twice
  65. * @var int
  66. * @access private
  67. */
  68. var $_isValid = 0;
  69. /**
  70. * True if the filelist has been validated
  71. * @param bool
  72. */
  73. var $_filesValid = false;
  74. /**
  75. * @var PEAR_Registry
  76. * @access protected
  77. */
  78. var $_registry;
  79. /**
  80. * @var PEAR_Config
  81. * @access protected
  82. */
  83. var $_config;
  84. /**
  85. * Optional Dependency group requested for installation
  86. * @var string
  87. * @access private
  88. */
  89. var $_requestedGroup = false;
  90. /**
  91. * @var PEAR_ErrorStack
  92. * @access protected
  93. */
  94. var $_stack;
  95. /**
  96. * Namespace prefix used for tasks in this package.xml - use tasks: whenever possible
  97. */
  98. var $_tasksNs;
  99. /**
  100. * Determines whether this packagefile was initialized only with partial package info
  101. *
  102. * If this package file was constructed via parsing REST, it will only contain
  103. *
  104. * - package name
  105. * - channel name
  106. * - dependencies
  107. * @var boolean
  108. * @access private
  109. */
  110. var $_incomplete = true;
  111. /**
  112. * @var PEAR_PackageFile_v2_Validator
  113. */
  114. var $_v2Validator;
  115. /**
  116. * The constructor merely sets up the private error stack
  117. */
  118. function PEAR_PackageFile_v2()
  119. {
  120. $this->_stack = new PEAR_ErrorStack('PEAR_PackageFile_v2', false, null);
  121. $this->_isValid = false;
  122. }
  123. /**
  124. * To make unit-testing easier
  125. * @param PEAR_Frontend_*
  126. * @param array options
  127. * @param PEAR_Config
  128. * @return PEAR_Downloader
  129. * @access protected
  130. */
  131. function &getPEARDownloader(&$i, $o, &$c)
  132. {
  133. $z = &new PEAR_Downloader($i, $o, $c);
  134. return $z;
  135. }
  136. /**
  137. * To make unit-testing easier
  138. * @param PEAR_Config
  139. * @param array options
  140. * @param array package name as returned from {@link PEAR_Registry::parsePackageName()}
  141. * @param int PEAR_VALIDATE_* constant
  142. * @return PEAR_Dependency2
  143. * @access protected
  144. */
  145. function &getPEARDependency2(&$c, $o, $p, $s = PEAR_VALIDATE_INSTALLING)
  146. {
  147. if (!class_exists('PEAR_Dependency2')) {
  148. require_once 'PEAR/Dependency2.php';
  149. }
  150. $z = &new PEAR_Dependency2($c, $o, $p, $s);
  151. return $z;
  152. }
  153. function getInstalledBinary()
  154. {
  155. return isset($this->_packageInfo['#binarypackage']) ? $this->_packageInfo['#binarypackage'] :
  156. false;
  157. }
  158. /**
  159. * Installation of source package has failed, attempt to download and install the
  160. * binary version of this package.
  161. * @param PEAR_Installer
  162. * @return array|false
  163. */
  164. function installBinary(&$installer)
  165. {
  166. if (!OS_WINDOWS) {
  167. $a = false;
  168. return $a;
  169. }
  170. if ($this->getPackageType() == 'extsrc' || $this->getPackageType() == 'zendextsrc') {
  171. $releasetype = $this->getPackageType() . 'release';
  172. if (!is_array($installer->getInstallPackages())) {
  173. $a = false;
  174. return $a;
  175. }
  176. foreach ($installer->getInstallPackages() as $p) {
  177. if ($p->isExtension($this->_packageInfo['providesextension'])) {
  178. if ($p->getPackageType() != 'extsrc' && $p->getPackageType() != 'zendextsrc') {
  179. $a = false;
  180. return $a; // the user probably downloaded it separately
  181. }
  182. }
  183. }
  184. if (isset($this->_packageInfo[$releasetype]['binarypackage'])) {
  185. $installer->log(0, 'Attempting to download binary version of extension "' .
  186. $this->_packageInfo['providesextension'] . '"');
  187. $params = $this->_packageInfo[$releasetype]['binarypackage'];
  188. if (!is_array($params) || !isset($params[0])) {
  189. $params = array($params);
  190. }
  191. if (isset($this->_packageInfo['channel'])) {
  192. foreach ($params as $i => $param) {
  193. $params[$i] = array('channel' => $this->_packageInfo['channel'],
  194. 'package' => $param, 'version' => $this->getVersion());
  195. }
  196. }
  197. $dl = &$this->getPEARDownloader($installer->ui, $installer->getOptions(),
  198. $installer->config);
  199. $verbose = $dl->config->get('verbose');
  200. $dl->config->set('verbose', -1);
  201. foreach ($params as $param) {
  202. PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
  203. $ret = $dl->download(array($param));
  204. PEAR::popErrorHandling();
  205. if (is_array($ret) && count($ret)) {
  206. break;
  207. }
  208. }
  209. $dl->config->set('verbose', $verbose);
  210. if (is_array($ret)) {
  211. if (count($ret) == 1) {
  212. $pf = $ret[0]->getPackageFile();
  213. PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
  214. $err = $installer->install($ret[0]);
  215. PEAR::popErrorHandling();
  216. if (is_array($err)) {
  217. $this->_packageInfo['#binarypackage'] = $ret[0]->getPackage();
  218. // "install" self, so all dependencies will work transparently
  219. $this->_registry->addPackage2($this);
  220. $installer->log(0, 'Download and install of binary extension "' .
  221. $this->_registry->parsedPackageNameToString(
  222. array('channel' => $pf->getChannel(),
  223. 'package' => $pf->getPackage()), true) . '" successful');
  224. $a = array($ret[0], $err);
  225. return $a;
  226. }
  227. $installer->log(0, 'Download and install of binary extension "' .
  228. $this->_registry->parsedPackageNameToString(
  229. array('channel' => $pf->getChannel(),
  230. 'package' => $pf->getPackage()), true) . '" failed');
  231. }
  232. }
  233. }
  234. }
  235. $a = false;
  236. return $a;
  237. }
  238. /**
  239. * @return string|false Extension name
  240. */
  241. function getProvidesExtension()
  242. {
  243. if (in_array($this->getPackageType(),
  244. array('extsrc', 'extbin', 'zendextsrc', 'zendextbin'))) {
  245. if (isset($this->_packageInfo['providesextension'])) {
  246. return $this->_packageInfo['providesextension'];
  247. }
  248. }
  249. return false;
  250. }
  251. /**
  252. * @param string Extension name
  253. * @return bool
  254. */
  255. function isExtension($extension)
  256. {
  257. if (in_array($this->getPackageType(),
  258. array('extsrc', 'extbin', 'zendextsrc', 'zendextbin'))) {
  259. return $this->_packageInfo['providesextension'] == $extension;
  260. }
  261. return false;
  262. }
  263. /**
  264. * Tests whether every part of the package.xml 1.0 is represented in
  265. * this package.xml 2.0
  266. * @param PEAR_PackageFile_v1
  267. * @return bool
  268. */
  269. function isEquivalent($pf1)
  270. {
  271. if (!$pf1) {
  272. return true;
  273. }
  274. if ($this->getPackageType() == 'bundle') {
  275. return false;
  276. }
  277. $this->_stack->getErrors(true);
  278. if (!$pf1->validate(PEAR_VALIDATE_NORMAL)) {
  279. return false;
  280. }
  281. $pass = true;
  282. if ($pf1->getPackage() != $this->getPackage()) {
  283. $this->_differentPackage($pf1->getPackage());
  284. $pass = false;
  285. }
  286. if ($pf1->getVersion() != $this->getVersion()) {
  287. $this->_differentVersion($pf1->getVersion());
  288. $pass = false;
  289. }
  290. if (trim($pf1->getSummary()) != $this->getSummary()) {
  291. $this->_differentSummary($pf1->getSummary());
  292. $pass = false;
  293. }
  294. if (preg_replace('/\s+/', '', $pf1->getDescription()) !=
  295. preg_replace('/\s+/', '', $this->getDescription())) {
  296. $this->_differentDescription($pf1->getDescription());
  297. $pass = false;
  298. }
  299. if ($pf1->getState() != $this->getState()) {
  300. $this->_differentState($pf1->getState());
  301. $pass = false;
  302. }
  303. if (!strstr(preg_replace('/\s+/', '', $this->getNotes()),
  304. preg_replace('/\s+/', '', $pf1->getNotes()))) {
  305. $this->_differentNotes($pf1->getNotes());
  306. $pass = false;
  307. }
  308. $mymaintainers = $this->getMaintainers();
  309. $yourmaintainers = $pf1->getMaintainers();
  310. for ($i1 = 0; $i1 < count($yourmaintainers); $i1++) {
  311. $reset = false;
  312. for ($i2 = 0; $i2 < count($mymaintainers); $i2++) {
  313. if ($mymaintainers[$i2]['handle'] == $yourmaintainers[$i1]['handle']) {
  314. if ($mymaintainers[$i2]['role'] != $yourmaintainers[$i1]['role']) {
  315. $this->_differentRole($mymaintainers[$i2]['handle'],
  316. $yourmaintainers[$i1]['role'], $mymaintainers[$i2]['role']);
  317. $pass = false;
  318. }
  319. if ($mymaintainers[$i2]['email'] != $yourmaintainers[$i1]['email']) {
  320. $this->_differentEmail($mymaintainers[$i2]['handle'],
  321. $yourmaintainers[$i1]['email'], $mymaintainers[$i2]['email']);
  322. $pass = false;
  323. }
  324. if ($mymaintainers[$i2]['name'] != $yourmaintainers[$i1]['name']) {
  325. $this->_differentName($mymaintainers[$i2]['handle'],
  326. $yourmaintainers[$i1]['name'], $mymaintainers[$i2]['name']);
  327. $pass = false;
  328. }
  329. unset($mymaintainers[$i2]);
  330. $mymaintainers = array_values($mymaintainers);
  331. unset($yourmaintainers[$i1]);
  332. $yourmaintainers = array_values($yourmaintainers);
  333. $reset = true;
  334. break;
  335. }
  336. }
  337. if ($reset) {
  338. $i1 = -1;
  339. }
  340. }
  341. $this->_unmatchedMaintainers($mymaintainers, $yourmaintainers);
  342. $filelist = $this->getFilelist();
  343. foreach ($pf1->getFilelist() as $file => $atts) {
  344. if (!isset($filelist[$file])) {
  345. $this->_missingFile($file);
  346. $pass = false;
  347. }
  348. }
  349. return $pass;
  350. }
  351. function _differentPackage($package)
  352. {
  353. $this->_stack->push(__FUNCTION__, 'error', array('package' => $package,
  354. 'self' => $this->getPackage()),
  355. 'package.xml 1.0 package "%package%" does not match "%self%"');
  356. }
  357. function _differentVersion($version)
  358. {
  359. $this->_stack->push(__FUNCTION__, 'error', array('version' => $version,
  360. 'self' => $this->getVersion()),
  361. 'package.xml 1.0 version "%version%" does not match "%self%"');
  362. }
  363. function _differentState($state)
  364. {
  365. $this->_stack->push(__FUNCTION__, 'error', array('state' => $state,
  366. 'self' => $this->getState()),
  367. 'package.xml 1.0 state "%state%" does not match "%self%"');
  368. }
  369. function _differentRole($handle, $role, $selfrole)
  370. {
  371. $this->_stack->push(__FUNCTION__, 'error', array('handle' => $handle,
  372. 'role' => $role, 'self' => $selfrole),
  373. 'package.xml 1.0 maintainer "%handle%" role "%role%" does not match "%self%"');
  374. }
  375. function _differentEmail($handle, $email, $selfemail)
  376. {
  377. $this->_stack->push(__FUNCTION__, 'error', array('handle' => $handle,
  378. 'email' => $email, 'self' => $selfemail),
  379. 'package.xml 1.0 maintainer "%handle%" email "%email%" does not match "%self%"');
  380. }
  381. function _differentName($handle, $name, $selfname)
  382. {
  383. $this->_stack->push(__FUNCTION__, 'error', array('handle' => $handle,
  384. 'name' => $name, 'self' => $selfname),
  385. 'package.xml 1.0 maintainer "%handle%" name "%name%" does not match "%self%"');
  386. }
  387. function _unmatchedMaintainers($my, $yours)
  388. {
  389. if ($my) {
  390. array_walk($my, create_function('&$i, $k', '$i = $i["handle"];'));
  391. $this->_stack->push(__FUNCTION__, 'error', array('handles' => $my),
  392. 'package.xml 2.0 has unmatched extra maintainers "%handles%"');
  393. }
  394. if ($yours) {
  395. array_walk($yours, create_function('&$i, $k', '$i = $i["handle"];'));
  396. $this->_stack->push(__FUNCTION__, 'error', array('handles' => $yours),
  397. 'package.xml 1.0 has unmatched extra maintainers "%handles%"');
  398. }
  399. }
  400. function _differentNotes($notes)
  401. {
  402. $truncnotes = strlen($notes) < 25 ? $notes : substr($notes, 0, 24) . '...';
  403. $truncmynotes = strlen($this->getNotes()) < 25 ? $this->getNotes() :
  404. substr($this->getNotes(), 0, 24) . '...';
  405. $this->_stack->push(__FUNCTION__, 'error', array('notes' => $truncnotes,
  406. 'self' => $truncmynotes),
  407. 'package.xml 1.0 release notes "%notes%" do not match "%self%"');
  408. }
  409. function _differentSummary($summary)
  410. {
  411. $truncsummary = strlen($summary) < 25 ? $summary : substr($summary, 0, 24) . '...';
  412. $truncmysummary = strlen($this->getsummary()) < 25 ? $this->getSummary() :
  413. substr($this->getsummary(), 0, 24) . '...';
  414. $this->_stack->push(__FUNCTION__, 'error', array('summary' => $truncsummary,
  415. 'self' => $truncmysummary),
  416. 'package.xml 1.0 summary "%summary%" does not match "%self%"');
  417. }
  418. function _differentDescription($description)
  419. {
  420. $truncdescription = trim(strlen($description) < 25 ? $description : substr($description, 0, 24) . '...');
  421. $truncmydescription = trim(strlen($this->getDescription()) < 25 ? $this->getDescription() :
  422. substr($this->getdescription(), 0, 24) . '...');
  423. $this->_stack->push(__FUNCTION__, 'error', array('description' => $truncdescription,
  424. 'self' => $truncmydescription),
  425. 'package.xml 1.0 description "%description%" does not match "%self%"');
  426. }
  427. function _missingFile($file)
  428. {
  429. $this->_stack->push(__FUNCTION__, 'error', array('file' => $file),
  430. 'package.xml 1.0 file "%file%" is not present in <contents>');
  431. }
  432. /**
  433. * WARNING - do not use this function unless you know what you're doing
  434. */
  435. function setRawState($state)
  436. {
  437. if (!isset($this->_packageInfo['stability'])) {
  438. $this->_packageInfo['stability'] = array();
  439. }
  440. $this->_packageInfo['stability']['release'] = $state;
  441. }
  442. /**
  443. * WARNING - do not use this function unless you know what you're doing
  444. */
  445. function setRawCompatible($compatible)
  446. {
  447. $this->_packageInfo['compatible'] = $compatible;
  448. }
  449. /**
  450. * WARNING - do not use this function unless you know what you're doing
  451. */
  452. function setRawPackage($package)
  453. {
  454. $this->_packageInfo['name'] = $package;
  455. }
  456. /**
  457. * WARNING - do not use this function unless you know what you're doing
  458. */
  459. function setRawChannel($channel)
  460. {
  461. $this->_packageInfo['channel'] = $channel;
  462. }
  463. function setRequestedGroup($group)
  464. {
  465. $this->_requestedGroup = $group;
  466. }
  467. function getRequestedGroup()
  468. {
  469. if (isset($this->_requestedGroup)) {
  470. return $this->_requestedGroup;
  471. }
  472. return false;
  473. }
  474. /**
  475. * For saving in the registry.
  476. *
  477. * Set the last version that was installed
  478. * @param string
  479. */
  480. function setLastInstalledVersion($version)
  481. {
  482. $this->_packageInfo['_lastversion'] = $version;
  483. }
  484. /**
  485. * @return string|false
  486. */
  487. function getLastInstalledVersion()
  488. {
  489. if (isset($this->_packageInfo['_lastversion'])) {
  490. return $this->_packageInfo['_lastversion'];
  491. }
  492. return false;
  493. }
  494. /**
  495. * Determines whether this package.xml has post-install scripts or not
  496. * @return array|false
  497. */
  498. function listPostinstallScripts()
  499. {
  500. $filelist = $this->getFilelist();
  501. $contents = $this->getContents();
  502. $contents = $contents['dir']['file'];
  503. if (!is_array($contents) || !isset($contents[0])) {
  504. $contents = array($contents);
  505. }
  506. $taskfiles = array();
  507. foreach ($contents as $file) {
  508. $atts = $file['attribs'];
  509. unset($file['attribs']);
  510. if (count($file)) {
  511. $taskfiles[$atts['name']] = $file;
  512. }
  513. }
  514. $common = new PEAR_Common;
  515. $common->debug = $this->_config->get('verbose');
  516. $this->_scripts = array();
  517. $ret = array();
  518. foreach ($taskfiles as $name => $tasks) {
  519. if (!isset($filelist[$name])) {
  520. // ignored files will not be in the filelist
  521. continue;
  522. }
  523. $atts = $filelist[$name];
  524. foreach ($tasks as $tag => $raw) {
  525. $task = $this->getTask($tag);
  526. $task = &new $task($this->_config, $common, PEAR_TASK_INSTALL);
  527. if ($task->isScript()) {
  528. $ret[] = $filelist[$name]['installed_as'];
  529. }
  530. }
  531. }
  532. if (count($ret)) {
  533. return $ret;
  534. }
  535. return false;
  536. }
  537. /**
  538. * Initialize post-install scripts for running
  539. *
  540. * This method can be used to detect post-install scripts, as the return value
  541. * indicates whether any exist
  542. * @return bool
  543. */
  544. function initPostinstallScripts()
  545. {
  546. $filelist = $this->getFilelist();
  547. $contents = $this->getContents();
  548. $contents = $contents['dir']['file'];
  549. if (!is_array($contents) || !isset($contents[0])) {
  550. $contents = array($contents);
  551. }
  552. $taskfiles = array();
  553. foreach ($contents as $file) {
  554. $atts = $file['attribs'];
  555. unset($file['attribs']);
  556. if (count($file)) {
  557. $taskfiles[$atts['name']] = $file;
  558. }
  559. }
  560. $common = new PEAR_Common;
  561. $common->debug = $this->_config->get('verbose');
  562. $this->_scripts = array();
  563. foreach ($taskfiles as $name => $tasks) {
  564. if (!isset($filelist[$name])) {
  565. // file was not installed due to installconditions
  566. continue;
  567. }
  568. $atts = $filelist[$name];
  569. foreach ($tasks as $tag => $raw) {
  570. $taskname = $this->getTask($tag);
  571. $task = &new $taskname($this->_config, $common, PEAR_TASK_INSTALL);
  572. if (!$task->isScript()) {
  573. continue; // scripts are only handled after installation
  574. }
  575. $lastversion = isset($this->_packageInfo['_lastversion']) ?
  576. $this->_packageInfo['_lastversion'] : null;
  577. $task->init($raw, $atts, $lastversion);
  578. $res = $task->startSession($this, $atts['installed_as']);
  579. if (!$res) {
  580. continue; // skip this file
  581. }
  582. if (PEAR::isError($res)) {
  583. return $res;
  584. }
  585. $assign = &$task;
  586. $this->_scripts[] = &$assign;
  587. }
  588. }
  589. if (count($this->_scripts)) {
  590. return true;
  591. }
  592. return false;
  593. }
  594. function runPostinstallScripts()
  595. {
  596. if ($this->initPostinstallScripts()) {
  597. $ui = &PEAR_Frontend::singleton();
  598. if ($ui) {
  599. $ui->runPostinstallScripts($this->_scripts, $this);
  600. }
  601. }
  602. }
  603. /**
  604. * Convert a recursive set of <dir> and <file> tags into a single <dir> tag with
  605. * <file> tags.
  606. */
  607. function flattenFilelist()
  608. {
  609. if (isset($this->_packageInfo['bundle'])) {
  610. return;
  611. }
  612. $filelist = array();
  613. if (isset($this->_packageInfo['contents']['dir']['dir'])) {
  614. $this->_getFlattenedFilelist($filelist, $this->_packageInfo['contents']['dir']);
  615. if (!isset($filelist[1])) {
  616. $filelist = $filelist[0];
  617. }
  618. $this->_packageInfo['contents']['dir']['file'] = $filelist;
  619. unset($this->_packageInfo['contents']['dir']['dir']);
  620. } else {
  621. // else already flattened but check for baseinstalldir propagation
  622. if (isset($this->_packageInfo['contents']['dir']['attribs']['baseinstalldir'])) {
  623. if (isset($this->_packageInfo['contents']['dir']['file'][0])) {
  624. foreach ($this->_packageInfo['contents']['dir']['file'] as $i => $file) {
  625. if (isset($file['attribs']['baseinstalldir'])) {
  626. continue;
  627. }
  628. $this->_packageInfo['contents']['dir']['file'][$i]['attribs']['baseinstalldir']
  629. = $this->_packageInfo['contents']['dir']['attribs']['baseinstalldir'];
  630. }
  631. } else {
  632. if (!isset($this->_packageInfo['contents']['dir']['file']['attribs']['baseinstalldir'])) {
  633. $this->_packageInfo['contents']['dir']['file']['attribs']['baseinstalldir']
  634. = $this->_packageInfo['contents']['dir']['attribs']['baseinstalldir'];
  635. }
  636. }
  637. }
  638. }
  639. }
  640. /**
  641. * @param array the final flattened file list
  642. * @param array the current directory being processed
  643. * @param string|false any recursively inherited baeinstalldir attribute
  644. * @param string private recursion variable
  645. * @return array
  646. * @access protected
  647. */
  648. function _getFlattenedFilelist(&$files, $dir, $baseinstall = false, $path = '')
  649. {
  650. if (isset($dir['attribs']) && isset($dir['attribs']['baseinstalldir'])) {
  651. $baseinstall = $dir['attribs']['baseinstalldir'];
  652. }
  653. if (isset($dir['dir'])) {
  654. if (!isset($dir['dir'][0])) {
  655. $dir['dir'] = array($dir['dir']);
  656. }
  657. foreach ($dir['dir'] as $subdir) {
  658. if (!isset($subdir['attribs']) || !isset($subdir['attribs']['name'])) {
  659. $name = '*unknown*';
  660. } else {
  661. $name = $subdir['attribs']['name'];
  662. }
  663. $newpath = empty($path) ? $name :
  664. $path . '/' . $name;
  665. $this->_getFlattenedFilelist($files, $subdir,
  666. $baseinstall, $newpath);
  667. }
  668. }
  669. if (isset($dir['file'])) {
  670. if (!isset($dir['file'][0])) {
  671. $dir['file'] = array($dir['file']);
  672. }
  673. foreach ($dir['file'] as $file) {
  674. $attrs = $file['attribs'];
  675. $name = $attrs['name'];
  676. if ($baseinstall && !isset($attrs['baseinstalldir'])) {
  677. $attrs['baseinstalldir'] = $baseinstall;
  678. }
  679. $attrs['name'] = empty($path) ? $name : $path . '/' . $name;
  680. $attrs['name'] = preg_replace(array('!\\\\+!', '!/+!'), array('/', '/'),
  681. $attrs['name']);
  682. $file['attribs'] = $attrs;
  683. $files[] = $file;
  684. }
  685. }
  686. }
  687. function setConfig(&$config)
  688. {
  689. $this->_config = &$config;
  690. $this->_registry = &$config->getRegistry();
  691. }
  692. function setLogger(&$logger)
  693. {
  694. if (!is_object($logger) || !method_exists($logger, 'log')) {
  695. return PEAR::raiseError('Logger must be compatible with PEAR_Common::log');
  696. }
  697. $this->_logger = &$logger;
  698. }
  699. /**
  700. * WARNING - do not use this function directly unless you know what you're doing
  701. */
  702. function setDeps($deps)
  703. {
  704. $this->_packageInfo['dependencies'] = $deps;
  705. }
  706. /**
  707. * WARNING - do not use this function directly unless you know what you're doing
  708. */
  709. function setCompatible($compat)
  710. {
  711. $this->_packageInfo['compatible'] = $compat;
  712. }
  713. function setPackagefile($file, $archive = false)
  714. {
  715. $this->_packageFile = $file;
  716. $this->_archiveFile = $archive ? $archive : $file;
  717. }
  718. /**
  719. * Wrapper to {@link PEAR_ErrorStack::getErrors()}
  720. * @param boolean determines whether to purge the error stack after retrieving
  721. * @return array
  722. */
  723. function getValidationWarnings($purge = true)
  724. {
  725. return $this->_stack->getErrors($purge);
  726. }
  727. function getPackageFile()
  728. {
  729. return $this->_packageFile;
  730. }
  731. function getArchiveFile()
  732. {
  733. return $this->_archiveFile;
  734. }
  735. /**
  736. * Directly set the array that defines this packagefile
  737. *
  738. * WARNING: no validation. This should only be performed by internal methods
  739. * inside PEAR or by inputting an array saved from an existing PEAR_PackageFile_v2
  740. * @param array
  741. */
  742. function fromArray($pinfo)
  743. {
  744. unset($pinfo['old']);
  745. unset($pinfo['xsdversion']);
  746. // If the changelog isn't an array then it was passed in as an empty tag
  747. if (isset($pinfo['changelog']) && !is_array($pinfo['changelog'])) {
  748. unset($pinfo['changelog']);
  749. }
  750. $this->_incomplete = false;
  751. $this->_packageInfo = $pinfo;
  752. }
  753. function isIncomplete()
  754. {
  755. return $this->_incomplete;
  756. }
  757. /**
  758. * @return array
  759. */
  760. function toArray($forreg = false)
  761. {
  762. if (!$this->validate(PEAR_VALIDATE_NORMAL)) {
  763. return false;
  764. }
  765. return $this->getArray($forreg);
  766. }
  767. function getArray($forReg = false)
  768. {
  769. if ($forReg) {
  770. $arr = $this->_packageInfo;
  771. $arr['old'] = array();
  772. $arr['old']['version'] = $this->getVersion();
  773. $arr['old']['release_date'] = $this->getDate();
  774. $arr['old']['release_state'] = $this->getState();
  775. $arr['old']['release_license'] = $this->getLicense();
  776. $arr['old']['release_notes'] = $this->getNotes();
  777. $arr['old']['release_deps'] = $this->getDeps();
  778. $arr['old']['maintainers'] = $this->getMaintainers();
  779. $arr['xsdversion'] = '2.0';
  780. return $arr;
  781. } else {
  782. $info = $this->_packageInfo;
  783. unset($info['dirtree']);
  784. if (isset($info['_lastversion'])) {
  785. unset($info['_lastversion']);
  786. }
  787. if (isset($info['#binarypackage'])) {
  788. unset($info['#binarypackage']);
  789. }
  790. return $info;
  791. }
  792. }
  793. function packageInfo($field)
  794. {
  795. $arr = $this->getArray(true);
  796. if ($field == 'state') {
  797. return $arr['stability']['release'];
  798. }
  799. if ($field == 'api-version') {
  800. return $arr['version']['api'];
  801. }
  802. if ($field == 'api-state') {
  803. return $arr['stability']['api'];
  804. }
  805. if (isset($arr['old'][$field])) {
  806. if (!is_string($arr['old'][$field])) {
  807. return null;
  808. }
  809. return $arr['old'][$field];
  810. }
  811. if (isset($arr[$field])) {
  812. if (!is_string($arr[$field])) {
  813. return null;
  814. }
  815. return $arr[$field];
  816. }
  817. return null;
  818. }
  819. function getName()
  820. {
  821. return $this->getPackage();
  822. }
  823. function getPackage()
  824. {
  825. if (isset($this->_packageInfo['name'])) {
  826. return $this->_packageInfo['name'];
  827. }
  828. return false;
  829. }
  830. function getChannel()
  831. {
  832. if (isset($this->_packageInfo['uri'])) {
  833. return '__uri';
  834. }
  835. if (isset($this->_packageInfo['channel'])) {
  836. return strtolower($this->_packageInfo['channel']);
  837. }
  838. return false;
  839. }
  840. function getUri()
  841. {
  842. if (isset($this->_packageInfo['uri'])) {
  843. return $this->_packageInfo['uri'];
  844. }
  845. return false;
  846. }
  847. function getExtends()
  848. {
  849. if (isset($this->_packageInfo['extends'])) {
  850. return $this->_packageInfo['extends'];
  851. }
  852. return false;
  853. }
  854. function getSummary()
  855. {
  856. if (isset($this->_packageInfo['summary'])) {
  857. return $this->_packageInfo['summary'];
  858. }
  859. return false;
  860. }
  861. function getDescription()
  862. {
  863. if (isset($this->_packageInfo['description'])) {
  864. return $this->_packageInfo['description'];
  865. }
  866. return false;
  867. }
  868. function getMaintainers($raw = false)
  869. {
  870. if (!isset($this->_packageInfo['lead'])) {
  871. return false;
  872. }
  873. if ($raw) {
  874. $ret = array('lead' => $this->_packageInfo['lead']);
  875. (isset($this->_packageInfo['developer'])) ?
  876. $ret['developer'] = $this->_packageInfo['developer'] :null;
  877. (isset($this->_packageInfo['contributor'])) ?
  878. $ret['contributor'] = $this->_packageInfo['contributor'] :null;
  879. (isset($this->_packageInfo['helper'])) ?
  880. $ret['helper'] = $this->_packageInfo['helper'] :null;
  881. return $ret;
  882. } else {
  883. $ret = array();
  884. $leads = isset($this->_packageInfo['lead'][0]) ? $this->_packageInfo['lead'] :
  885. array($this->_packageInfo['lead']);
  886. foreach ($leads as $lead) {
  887. $s = $lead;
  888. $s['handle'] = $s['user'];
  889. unset($s['user']);
  890. $s['role'] = 'lead';
  891. $ret[] = $s;
  892. }
  893. if (isset($this->_packageInfo['developer'])) {
  894. $leads = isset($this->_packageInfo['developer'][0]) ?
  895. $this->_packageInfo['developer'] :
  896. array($this->_packageInfo['developer']);
  897. foreach ($leads as $maintainer) {
  898. $s = $maintainer;
  899. $s['handle'] = $s['user'];
  900. unset($s['user']);
  901. $s['role'] = 'developer';
  902. $ret[] = $s;
  903. }
  904. }
  905. if (isset($this->_packageInfo['contributor'])) {
  906. $leads = isset($this->_packageInfo['contributor'][0]) ?
  907. $this->_packageInfo['contributor'] :
  908. array($this->_packageInfo['contributor']);
  909. foreach ($leads as $maintainer) {
  910. $s = $maintainer;
  911. $s['handle'] = $s['user'];
  912. unset($s['user']);
  913. $s['role'] = 'contributor';
  914. $ret[] = $s;
  915. }
  916. }
  917. if (isset($this->_packageInfo['helper'])) {
  918. $leads = isset($this->_packageInfo['helper'][0]) ?
  919. $this->_packageInfo['helper'] :
  920. array($this->_packageInfo['helper']);
  921. foreach ($leads as $maintainer) {
  922. $s = $maintainer;
  923. $s['handle'] = $s['user'];
  924. unset($s['user']);
  925. $s['role'] = 'helper';
  926. $ret[] = $s;
  927. }
  928. }
  929. return $ret;
  930. }
  931. return false;
  932. }
  933. function getLeads()
  934. {
  935. if (isset($this->_packageInfo['lead'])) {
  936. return $this->_packageInfo['lead'];
  937. }
  938. return false;
  939. }
  940. function getDevelopers()
  941. {
  942. if (isset($this->_packageInfo['developer'])) {
  943. return $this->_packageInfo['developer'];
  944. }
  945. return false;
  946. }
  947. function getContributors()
  948. {
  949. if (isset($this->_packageInfo['contributor'])) {
  950. return $this->_packageInfo['contributor'];
  951. }
  952. return false;
  953. }
  954. function getHelpers()
  955. {
  956. if (isset($this->_packageInfo['helper'])) {
  957. return $this->_packageInfo['helper'];
  958. }
  959. return false;
  960. }
  961. function setDate($date)
  962. {
  963. if (!isset($this->_packageInfo['date'])) {
  964. // ensure that the extends tag is set up in the right location
  965. $this->_packageInfo = $this->_insertBefore($this->_packageInfo,
  966. array('time', 'version',
  967. 'stability', 'license', 'notes', 'contents', 'compatible',
  968. 'dependencies', 'providesextension', 'srcpackage', 'srcuri',
  969. 'phprelease', 'extsrcrelease', 'extbinrelease', 'zendextsrcrelease',
  970. 'zendextbinrelease', 'bundle', 'changelog'), array(), 'date');
  971. }
  972. $this->_packageInfo['date'] = $date;
  973. $this->_isValid = 0;
  974. }
  975. function setTime($time)
  976. {
  977. $this->_isValid = 0;
  978. if (!isset($this->_packageInfo['time'])) {
  979. // ensure that the time tag is set up in the right location
  980. $this->_packageInfo = $this->_insertBefore($this->_packageInfo,
  981. array('version',
  982. 'stability', 'license', 'notes', 'contents', 'compatible',
  983. 'dependencies', 'providesextension', 'srcpackage', 'srcuri',
  984. 'phprelease', 'extsrcrelease', 'extbinrelease', 'zendextsrcrelease',
  985. 'zendextbinrelease', 'bundle', 'changelog'), $time, 'time');
  986. }
  987. $this->_packageInfo['time'] = $time;
  988. }
  989. function getDate()
  990. {
  991. if (isset($this->_packageInfo['date'])) {
  992. return $this->_packageInfo['date'];
  993. }
  994. return false;
  995. }
  996. function getTime()
  997. {
  998. if (isset($this->_packageInfo['time'])) {
  999. return $this->_packageInfo['time'];
  1000. }
  1001. return false;
  1002. }
  1003. /**
  1004. * @param package|api version category to return
  1005. */
  1006. function getVersion($key = 'release')
  1007. {
  1008. if (isset($this->_packageInfo['version'][$key])) {
  1009. return $this->_packageInfo['version'][$key];
  1010. }
  1011. return false;
  1012. }
  1013. function getStability()
  1014. {
  1015. if (isset($this->_packageInfo['stability'])) {
  1016. return $this->_packageInfo['stability'];
  1017. }
  1018. return false;
  1019. }
  1020. function getState($key = 'release')
  1021. {
  1022. if (isset($this->_packageInfo['stability'][$key])) {
  1023. return $this->_packageInfo['stability'][$key];
  1024. }
  1025. return false;
  1026. }
  1027. function getLicense($raw = false)
  1028. {
  1029. if (isset($this->_packageInfo['license'])) {
  1030. if ($raw) {
  1031. return $this->_packageInfo['license'];
  1032. }
  1033. if (is_array($this->_packageInfo['license'])) {
  1034. return $this->_packageInfo['license']['_content'];
  1035. } else {
  1036. return $this->_packageInfo['license'];
  1037. }
  1038. }
  1039. return false;
  1040. }
  1041. function getLicenseLocation()
  1042. {
  1043. if (!isset($this->_packageInfo['license']) || !is_array($this->_packageInfo['license'])) {
  1044. return false;
  1045. }
  1046. return $this->_packageInfo['license']['attribs'];
  1047. }
  1048. function getNotes()
  1049. {
  1050. if (isset($this->_packageInfo['notes'])) {
  1051. return $this->_packageInfo['notes'];
  1052. }
  1053. return false;
  1054. }
  1055. /**
  1056. * Return the <usesrole> tag contents, if any
  1057. * @return array|false
  1058. */
  1059. function getUsesrole()
  1060. {
  1061. if (isset($this->_packageInfo['usesrole'])) {
  1062. return $this->_packageInfo['usesrole'];
  1063. }
  1064. return false;
  1065. }
  1066. /**
  1067. * Return the <usestask> tag contents, if any
  1068. * @return array|false
  1069. */
  1070. function getUsestask()
  1071. {
  1072. if (isset($this->_packageInfo['usestask'])) {
  1073. return $this->_packageInfo['usestask'];
  1074. }
  1075. return false;
  1076. }
  1077. /**
  1078. * This should only be used to retrieve filenames and install attributes
  1079. */
  1080. function getFilelist($preserve = false)
  1081. {
  1082. if (isset($this->_packageInfo['filelist']) && !$preserve) {
  1083. return $this->_packageInfo['filelist'];
  1084. }
  1085. $this->flattenFilelist();
  1086. if ($contents = $this->getContents()) {
  1087. $ret = array();
  1088. if (!isset($contents['dir'])) {
  1089. return false;
  1090. }
  1091. if (!isset($contents['dir']['file'][0])) {
  1092. $contents['dir']['file'] = array($contents['dir']['file']);
  1093. }
  1094. foreach ($contents['dir']['file'] as $file) {
  1095. $name = $file['attribs']['name'];
  1096. if (!$preserve) {
  1097. $file = $file['attribs'];
  1098. }
  1099. $ret[$name] = $file;
  1100. }
  1101. if (!$preserve) {
  1102. $this->_packageInfo['filelist'] = $ret;
  1103. }
  1104. return $ret;
  1105. }
  1106. return false;
  1107. }
  1108. /**
  1109. * Return configure options array, if any
  1110. *
  1111. * @return array|false
  1112. */
  1113. function getConfigureOptions()
  1114. {
  1115. if ($this->getPackageType() != 'extsrc' && $this->getPackageType() != 'zendextsrc') {
  1116. return false;
  1117. }
  1118. $releases = $this->getReleases();
  1119. if (isset($releases[0])) {
  1120. $releases = $releases[0];
  1121. }
  1122. if (isset($releases['configureoption'])) {
  1123. if (!isset($releases['configureoption'][0])) {
  1124. $releases['configureoption'] = array($releases['configureoption']);
  1125. }
  1126. for ($i = 0; $i < count($releases['configureoption']); $i++) {
  1127. $releases['configureoption'][$i] = $releases['configureoption'][$i]['attribs'];
  1128. }
  1129. return $releases['configureoption'];
  1130. }
  1131. return false;
  1132. }
  1133. /**
  1134. * This is only used at install-time, after all serialization
  1135. * is over.
  1136. */
  1137. function resetFilelist()
  1138. {
  1139. $this->_packageInfo['filelist'] = array();
  1140. }
  1141. /**
  1142. * Retrieve a list of files that should be installed on this computer
  1143. * @return array
  1144. */
  1145. function getInstallationFilelist($forfilecheck = false)
  1146. {
  1147. $contents = $this->getFilelist(true);
  1148. if (isset($contents['dir']['attribs']['baseinstalldir'])) {
  1149. $base = $contents['dir']['attribs']['baseinstalldir'];
  1150. }
  1151. if (isset($this->_packageInfo['bundle'])) {
  1152. return PEAR::raiseError(
  1153. 'Exception: bundles should be handled in download code only');
  1154. }
  1155. $release = $this->getReleases();
  1156. if ($release) {
  1157. if (!isset($release[0])) {
  1158. if (!isset($release['installconditions']) && !isset($release['filelist'])) {
  1159. if ($forfilecheck) {
  1160. return $this->getFilelist();
  1161. }
  1162. return $contents;
  1163. }
  1164. $release = array($release);
  1165. }
  1166. $depchecker = &$this->getPEARDependency2($this->_config, array(),
  1167. array('channel' => $this->getChannel(), 'package' => $this->getPackage()),
  1168. PEAR_VALIDATE_INSTALLING);
  1169. foreach ($release as $instance) {
  1170. if (isset($instance['installconditions'])) {
  1171. $installconditions = $instance['installconditions'];
  1172. if (is_array($installconditions)) {
  1173. PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
  1174. foreach ($installconditions as $type => $conditions) {
  1175. if (!isset($conditions[0])) {
  1176. $conditions = array($conditions);
  1177. }
  1178. foreach ($conditions as $condition) {
  1179. $ret = $depchecker->{"validate{$type}Dependency"}($condition);
  1180. if (PEAR::isError($ret)) {
  1181. PEAR::popErrorHandling();
  1182. continue 3; // skip this release
  1183. }
  1184. }
  1185. }
  1186. PEAR::popErrorHandling();
  1187. }
  1188. }
  1189. // this is the release to use
  1190. if (isset($instance['filelist'])) {
  1191. // ignore files
  1192. if (isset($instance['filelist']['ignore'])) {
  1193. $ignore = isset($instance['filelist']['ignore'][0]) ?
  1194. $instance['filelist']['ignore'] :
  1195. array($instance['filelist']['ignore']);
  1196. foreach ($ignore as $ig) {
  1197. unset ($contents[$ig['attribs']['name']]);
  1198. }
  1199. }
  1200. // install files as this name
  1201. if (isset($instance['filelist']['install'])) {
  1202. $installas = isset($instance['filelist']['install'][0]) ?
  1203. $instance['filelist']['install'] :
  1204. array($instance['filelist']['install']);
  1205. foreach ($installas as $as) {
  1206. $contents[$as['attribs']['name']]['attribs']['install-as'] =
  1207. $as['attribs']['as'];
  1208. }
  1209. }
  1210. }
  1211. if ($forfilecheck) {
  1212. foreach ($contents as $file => $attrs) {
  1213. $contents[$file] = $attrs['attribs'];
  1214. }
  1215. }
  1216. return $contents;
  1217. }
  1218. } else { // simple release - no installconditions or install-as
  1219. if ($forfilecheck) {
  1220. return $this->getFilelist();
  1221. }
  1222. return $contents;
  1223. }
  1224. // no releases matched
  1225. return PEAR::raiseError('No releases in package.xml matched the existing operating ' .
  1226. 'system, extensions installed, or architecture, cannot install');
  1227. }
  1228. /**
  1229. * This is only used at install-time, after all serialization
  1230. * is over.
  1231. * @param string file name
  1232. * @param string installed path
  1233. */
  1234. function setInstalledAs($file, $path)
  1235. {
  1236. if ($path) {
  1237. return $this->_packageInfo['filelist'][$file]['installed_as'] = $path;
  1238. }
  1239. unset($this->_packageInfo['filelist'][$file]['installed_as']);
  1240. }
  1241. function getInstalledLocation($file)
  1242. {
  1243. if (isset($this->_packageInfo['filelist'][$file]['installed_as'])) {
  1244. return $this->_packageInfo['filelist'][$file]['installed_as'];
  1245. }
  1246. return false;
  1247. }
  1248. /**
  1249. * This is only used at install-time, after all serialization
  1250. * is over.
  1251. */
  1252. function installedFile($file, $atts)
  1253. {
  1254. if (isset($this->_packageInfo['filelist'][$file])) {
  1255. $this->_packageInfo['filelist'][$file] =
  1256. array_merge($this->_packageInfo['filelist'][$file], $atts['attribs']);
  1257. } else {
  1258. $this->_packageInfo['filelist'][$file] = $atts['attribs'];
  1259. }
  1260. }
  1261. /**
  1262. * Retrieve the contents tag
  1263. */
  1264. function getContents()
  1265. {
  1266. if (isset($this->_packageInfo['contents'])) {
  1267. return $this->_packageInfo['contents'];
  1268. }
  1269. return false;
  1270. }
  1271. /**
  1272. * @param string full path to file
  1273. * @param string attribute name
  1274. * @param string attribute value
  1275. * @param int risky but fast - use this to choose a file based on its position in the list
  1276. * of files. Index is zero-based like PHP arrays.
  1277. * @return bool success of operation
  1278. */
  1279. function setFileAttribute($filename, $attr, $value, $index = false)
  1280. {
  1281. $this->_isValid = 0;
  1282. if (in_array($attr, array('role', 'name', 'baseinstalldir'))) {
  1283. $this->_filesValid = false;
  1284. }
  1285. if ($index !== false &&
  1286. isset($this->_packageInfo['contents']['dir']['file'][$index]['attribs'])) {
  1287. $this->_packageInfo['contents']['dir']['file'][$index]['attribs'][$attr] = $value;
  1288. return true;
  1289. }
  1290. if (!isset($this->_packageInfo['contents']['dir']['file'])) {
  1291. return false;
  1292. }
  1293. $files = $this->_packageInfo['contents']['dir']['file'];
  1294. if (!isset($files[0])) {
  1295. $files = array($files);
  1296. $ind = false;
  1297. } else {
  1298. $ind = true;
  1299. }
  1300. foreach ($files as $i => $file) {
  1301. if (isset($file['attribs'])) {
  1302. if ($file['attribs']['name'] == $filename) {
  1303. if ($ind) {
  1304. $this->_packageInfo['contents']['dir']['file'][$i]['attribs'][$attr] = $value;
  1305. } else {
  1306. $this->_packageInfo['contents']['dir']['file']['attribs'][$attr] = $value;
  1307. }
  1308. return true;
  1309. }
  1310. }
  1311. }
  1312. return false;
  1313. }
  1314. function setDirtree($path)
  1315. {
  1316. if (!isset($this->_packageInfo['dirtree'])) {
  1317. $this->_packageInfo['dirtree'] = array();
  1318. }
  1319. $this->_packageInfo['dirtree'][$path] = true;
  1320. }
  1321. function getDirtree()
  1322. {
  1323. if (isset($this->_packageInfo['dirtree']) && count($this->_packageInfo['dirtree'])) {
  1324. return $this->_packageInfo['dirtree'];
  1325. }
  1326. return false;
  1327. }
  1328. function resetDirtree()
  1329. {
  1330. unset($this->_packageInfo['dirtree']);
  1331. }
  1332. /**
  1333. * Determines whether this package claims it is compatible with the version of
  1334. * the package that has a recommended version dependency
  1335. * @param PEAR_PackageFile_v2|PEAR_PackageFile_v1|PEAR_Downloader_Package
  1336. * @return boolean
  1337. */
  1338. function isCompatible($pf)
  1339. {
  1340. if (!isset($this->_packageInfo['compatible'])) {
  1341. return false;
  1342. }
  1343. if (!isset($this->_packageInfo['channel'])) {
  1344. return false;
  1345. }
  1346. $me = $pf->getVersion();
  1347. $compatible = $this->_packageInfo['compatible'];
  1348. if (!isset($compatible[0])) {
  1349. $compatible = array($compatible);
  1350. }
  1351. $found = false;
  1352. foreach ($compatible as $info) {
  1353. if (strtolower($info['name']) == strtolower($pf->getPackage())) {
  1354. if (strtolower($info['channel']) == strtolower($pf->getChannel())) {
  1355. $found = true;
  1356. break;
  1357. }
  1358. }
  1359. }
  1360. if (!$found) {
  1361. return false;
  1362. }
  1363. if (isset($info['exclude'])) {
  1364. if (!isset($info['exclude'][0])) {
  1365. $info['exclude'] = array($info['exclude']);
  1366. }
  1367. foreach ($info['exclude'] as $exclude) {
  1368. if (version_compare($me, $exclude, '==')) {
  1369. return false;
  1370. }
  1371. }
  1372. }
  1373. if (version_compare($me, $info['min'], '>=') && version_compare($me, $info['max'], '<=')) {
  1374. return true;
  1375. }
  1376. return false;
  1377. }
  1378. /**
  1379. * @return array|false
  1380. */
  1381. function getCompatible()
  1382. {
  1383. if (isset($this->_packageInfo['compatible'])) {
  1384. return $this->_packageInfo['compatible'];
  1385. }
  1386. return false;
  1387. }
  1388. function getDependencies()
  1389. {
  1390. if (isset($this->_packageInfo['dependencies'])) {
  1391. re

Large files files are truncated, but you can click here to view the full file