[ Index ] |
|
Code source de PHP PEAR 1.4.5 |
1 <?php 2 /** 3 * PEAR_Command_Registry (list, list-files, shell-test, info commands) 4 * 5 * PHP versions 4 and 5 6 * 7 * LICENSE: This source file is subject to version 3.0 of the PHP license 8 * that is available through the world-wide-web at the following URI: 9 * http://www.php.net/license/3_0.txt. If you did not receive a copy of 10 * the PHP License and are unable to obtain it through the web, please 11 * send a note to license@php.net so we can mail you a copy immediately. 12 * 13 * @category pear 14 * @package PEAR 15 * @author Stig Bakken <ssb@php.net> 16 * @author Greg Beaver <cellog@php.net> 17 * @copyright 1997-2006 The PHP Group 18 * @license http://www.php.net/license/3_0.txt PHP License 3.0 19 * @version CVS: $Id: Registry.php,v 1.75 2006/11/19 23:50:09 cellog Exp $ 20 * @link http://pear.php.net/package/PEAR 21 * @since File available since Release 0.1 22 */ 23 24 /** 25 * base class 26 */ 27 require_once 'PEAR/Command/Common.php'; 28 29 /** 30 * PEAR commands for registry manipulation 31 * 32 * @category pear 33 * @package PEAR 34 * @author Stig Bakken <ssb@php.net> 35 * @author Greg Beaver <cellog@php.net> 36 * @copyright 1997-2006 The PHP Group 37 * @license http://www.php.net/license/3_0.txt PHP License 3.0 38 * @version Release: 1.5.0 39 * @link http://pear.php.net/package/PEAR 40 * @since Class available since Release 0.1 41 */ 42 class PEAR_Command_Registry extends PEAR_Command_Common 43 { 44 // {{{ properties 45 46 var $commands = array( 47 'list' => array( 48 'summary' => 'List Installed Packages In The Default Channel', 49 'function' => 'doList', 50 'shortcut' => 'l', 51 'options' => array( 52 'channel' => array( 53 'shortopt' => 'c', 54 'doc' => 'list installed packages from this channel', 55 'arg' => 'CHAN', 56 ), 57 'allchannels' => array( 58 'shortopt' => 'a', 59 'doc' => 'list installed packages from all channels', 60 ), 61 ), 62 'doc' => '<package> 63 If invoked without parameters, this command lists the PEAR packages 64 installed in your php_dir ({config php_dir}). With a parameter, it 65 lists the files in a package. 66 ', 67 ), 68 'list-files' => array( 69 'summary' => 'List Files In Installed Package', 70 'function' => 'doFileList', 71 'shortcut' => 'fl', 72 'options' => array(), 73 'doc' => '<package> 74 List the files in an installed package. 75 ' 76 ), 77 'shell-test' => array( 78 'summary' => 'Shell Script Test', 79 'function' => 'doShellTest', 80 'shortcut' => 'st', 81 'options' => array(), 82 'doc' => '<package> [[relation] version] 83 Tests if a package is installed in the system. Will exit(1) if it is not. 84 <relation> The version comparison operator. One of: 85 <, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne 86 <version> The version to compare with 87 '), 88 'info' => array( 89 'summary' => 'Display information about a package', 90 'function' => 'doInfo', 91 'shortcut' => 'in', 92 'options' => array(), 93 'doc' => '<package> 94 Displays information about a package. The package argument may be a 95 local package file, an URL to a package file, or the name of an 96 installed package.' 97 ) 98 ); 99 100 // }}} 101 // {{{ constructor 102 103 /** 104 * PEAR_Command_Registry constructor. 105 * 106 * @access public 107 */ 108 function PEAR_Command_Registry(&$ui, &$config) 109 { 110 parent::PEAR_Command_Common($ui, $config); 111 } 112 113 // }}} 114 115 // {{{ doList() 116 117 function _sortinfo($a, $b) 118 { 119 $apackage = isset($a['package']) ? $a['package'] : $a['name']; 120 $bpackage = isset($b['package']) ? $b['package'] : $b['name']; 121 return strcmp($apackage, $bpackage); 122 } 123 124 function doList($command, $options, $params) 125 { 126 if (isset($options['allchannels'])) { 127 return $this->doListAll($command, array(), $params); 128 } 129 $reg = &$this->config->getRegistry(); 130 if (count($params) == 1) { 131 return $this->doFileList($command, $options, $params); 132 } 133 if (isset($options['channel'])) { 134 if ($reg->channelExists($options['channel'])) { 135 $channel = $reg->channelName($options['channel']); 136 } else { 137 return $this->raiseError('Channel "' . $options['channel'] .'" does not exist'); 138 } 139 } else { 140 $channel = $this->config->get('default_channel'); 141 } 142 $installed = $reg->packageInfo(null, null, $channel); 143 usort($installed, array(&$this, '_sortinfo')); 144 $i = $j = 0; 145 $data = array( 146 'caption' => 'Installed packages, channel ' . 147 $channel . ':', 148 'border' => true, 149 'headline' => array('Package', 'Version', 'State') 150 ); 151 foreach ($installed as $package) { 152 $pobj = $reg->getPackage(isset($package['package']) ? 153 $package['package'] : $package['name'], $channel); 154 $data['data'][] = array($pobj->getPackage(), $pobj->getVersion(), 155 $pobj->getState() ? $pobj->getState() : null); 156 } 157 if (count($installed)==0) { 158 $data = '(no packages installed from channel ' . $channel . ')'; 159 } 160 $this->ui->outputData($data, $command); 161 return true; 162 } 163 164 function doListAll($command, $options, $params) 165 { 166 $reg = &$this->config->getRegistry(); 167 $installed = $reg->packageInfo(null, null, null); 168 foreach ($installed as $channel => $packages) { 169 usort($packages, array($this, '_sortinfo')); 170 $i = $j = 0; 171 $data = array( 172 'caption' => 'Installed packages, channel ' . $channel . ':', 173 'border' => true, 174 'headline' => array('Package', 'Version', 'State') 175 ); 176 foreach ($packages as $package) { 177 $pobj = $reg->getPackage(isset($package['package']) ? 178 $package['package'] : $package['name'], $channel); 179 $data['data'][] = array($pobj->getPackage(), $pobj->getVersion(), 180 $pobj->getState() ? $pobj->getState() : null); 181 } 182 if (count($packages)==0) { 183 $data = array( 184 'caption' => 'Installed packages, channel ' . $channel . ':', 185 'border' => true, 186 'data' => array(array('(no packages installed)')), 187 ); 188 } 189 $this->ui->outputData($data, $command); 190 } 191 return true; 192 } 193 194 function doFileList($command, $options, $params) 195 { 196 if (count($params) != 1) { 197 return $this->raiseError('list-files expects 1 parameter'); 198 } 199 $reg = &$this->config->getRegistry(); 200 $fp = false; 201 if (!is_dir($params[0]) && (file_exists($params[0]) || $fp = @fopen($params[0], 202 'r'))) { 203 if ($fp) { 204 fclose($fp); 205 } 206 if (!class_exists('PEAR_PackageFile')) { 207 require_once 'PEAR/PackageFile.php'; 208 } 209 $pkg = &new PEAR_PackageFile($this->config, $this->_debug); 210 PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); 211 $info = &$pkg->fromAnyFile($params[0], PEAR_VALIDATE_NORMAL); 212 PEAR::staticPopErrorHandling(); 213 $headings = array('Package File', 'Install Path'); 214 $installed = false; 215 } else { 216 PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); 217 $parsed = $reg->parsePackageName($params[0], $this->config->get('default_channel')); 218 PEAR::staticPopErrorHandling(); 219 if (PEAR::isError($parsed)) { 220 return $this->raiseError($parsed); 221 } 222 $info = &$reg->getPackage($parsed['package'], $parsed['channel']); 223 $headings = array('Type', 'Install Path'); 224 $installed = true; 225 } 226 if (PEAR::isError($info)) { 227 return $this->raiseError($info); 228 } 229 if ($info === null) { 230 return $this->raiseError("`$params[0]' not installed"); 231 } 232 $list = ($info->getPackagexmlVersion() == '1.0' || $installed) ? 233 $info->getFilelist() : $info->getContents(); 234 if ($installed) { 235 $caption = 'Installed Files For ' . $params[0]; 236 } else { 237 $caption = 'Contents of ' . basename($params[0]); 238 } 239 $data = array( 240 'caption' => $caption, 241 'border' => true, 242 'headline' => $headings); 243 if ($info->getPackagexmlVersion() == '1.0' || $installed) { 244 foreach ($list as $file => $att) { 245 if ($installed) { 246 if (empty($att['installed_as'])) { 247 continue; 248 } 249 $data['data'][] = array($att['role'], $att['installed_as']); 250 } else { 251 if (isset($att['baseinstalldir']) && !in_array($att['role'], 252 array('test', 'data', 'doc'))) { 253 $dest = $att['baseinstalldir'] . DIRECTORY_SEPARATOR . 254 $file; 255 } else { 256 $dest = $file; 257 } 258 switch ($att['role']) { 259 case 'test': 260 case 'data': 261 case 'doc': 262 $role = $att['role']; 263 if ($role == 'test') { 264 $role .= 's'; 265 } 266 $dest = $this->config->get($role . '_dir') . DIRECTORY_SEPARATOR . 267 $info->getPackage() . DIRECTORY_SEPARATOR . $dest; 268 break; 269 case 'php': 270 default: 271 $dest = $this->config->get('php_dir') . DIRECTORY_SEPARATOR . 272 $dest; 273 } 274 $ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR; 275 $dest = preg_replace(array('!\\\\+!', '!/!', "!$ds2+!"), 276 array(DIRECTORY_SEPARATOR, 277 DIRECTORY_SEPARATOR, 278 DIRECTORY_SEPARATOR), 279 $dest); 280 $file = preg_replace('!/+!', '/', $file); 281 $data['data'][] = array($file, $dest); 282 } 283 } 284 } else { // package.xml 2.0, not installed 285 if (!isset($list['dir']['file'][0])) { 286 $list['dir']['file'] = array($list['dir']['file']); 287 } 288 foreach ($list['dir']['file'] as $att) { 289 $att = $att['attribs']; 290 $file = $att['name']; 291 $role = &PEAR_Installer_Role::factory($info, $att['role'], $this->config); 292 $role->setup($this, $info, $att, $file); 293 if (!$role->isInstallable()) { 294 $dest = '(not installable)'; 295 } else { 296 $dest = $role->processInstallation($info, $att, $file, ''); 297 if (PEAR::isError($dest)) { 298 $dest = '(Unknown role "' . $att['role'] . ')'; 299 } else { 300 list(,, $dest) = $dest; 301 } 302 } 303 $data['data'][] = array($file, $dest); 304 } 305 } 306 $this->ui->outputData($data, $command); 307 return true; 308 } 309 310 // }}} 311 // {{{ doShellTest() 312 313 function doShellTest($command, $options, $params) 314 { 315 if (count($params) < 1) { 316 return PEAR::raiseError('ERROR, usage: pear shell-test packagename [[relation] version]'); 317 } 318 PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); 319 $reg = &$this->config->getRegistry(); 320 $info = $reg->parsePackageName($params[0], $this->config->get('default_channel')); 321 if (PEAR::isError($info)) { 322 exit(1); // invalid package name 323 } 324 $package = $info['package']; 325 $channel = $info['channel']; 326 // "pear shell-test Foo" 327 if (!$reg->packageExists($package, $channel)) { 328 if ($channel == 'pecl.php.net') { 329 if ($reg->packageExists($package, 'pear.php.net')) { 330 $channel = 'pear.php.net'; // magically change channels for extensions 331 } 332 } 333 } 334 if (sizeof($params) == 1) { 335 if (!$reg->packageExists($package, $channel)) { 336 exit(1); 337 } 338 // "pear shell-test Foo 1.0" 339 } elseif (sizeof($params) == 2) { 340 $v = $reg->packageInfo($package, 'version', $channel); 341 if (!$v || !version_compare("$v", "{$params[1]}", "ge")) { 342 exit(1); 343 } 344 // "pear shell-test Foo ge 1.0" 345 } elseif (sizeof($params) == 3) { 346 $v = $reg->packageInfo($package, 'version', $channel); 347 if (!$v || !version_compare("$v", "{$params[2]}", $params[1])) { 348 exit(1); 349 } 350 } else { 351 PEAR::staticPopErrorHandling(); 352 $this->raiseError("$command: expects 1 to 3 parameters"); 353 exit(1); 354 } 355 } 356 357 // }}} 358 // {{{ doInfo 359 360 function doInfo($command, $options, $params) 361 { 362 if (count($params) != 1) { 363 return $this->raiseError('pear info expects 1 parameter'); 364 } 365 $info = $fp = false; 366 $reg = &$this->config->getRegistry(); 367 if ((file_exists($params[0]) && is_file($params[0]) && !is_dir($params[0])) || $fp = @fopen($params[0], 'r')) { 368 if ($fp) { 369 fclose($fp); 370 } 371 if (!class_exists('PEAR_PackageFile')) { 372 require_once 'PEAR/PackageFile.php'; 373 } 374 $pkg = &new PEAR_PackageFile($this->config, $this->_debug); 375 PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); 376 $obj = &$pkg->fromAnyFile($params[0], PEAR_VALIDATE_NORMAL); 377 PEAR::staticPopErrorHandling(); 378 if (PEAR::isError($obj)) { 379 $uinfo = $obj->getUserInfo(); 380 if (is_array($uinfo)) { 381 foreach ($uinfo as $message) { 382 if (is_array($message)) { 383 $message = $message['message']; 384 } 385 $this->ui->outputData($message); 386 } 387 } 388 return $this->raiseError($obj); 389 } 390 if ($obj->getPackagexmlVersion() == '1.0') { 391 $info = $obj->toArray(); 392 } else { 393 return $this->_doInfo2($command, $options, $params, $obj, false); 394 } 395 } else { 396 $parsed = $reg->parsePackageName($params[0], $this->config->get('default_channel')); 397 if (PEAR::isError($parsed)) { 398 return $this->raiseError($parsed); 399 } 400 $package = $parsed['package']; 401 $channel = $parsed['channel']; 402 $info = $reg->packageInfo($package, null, $channel); 403 if (isset($info['old'])) { 404 $obj = $reg->getPackage($package, $channel); 405 return $this->_doInfo2($command, $options, $params, $obj, true); 406 } 407 } 408 if (PEAR::isError($info)) { 409 return $info; 410 } 411 if (empty($info)) { 412 $this->raiseError("No information found for `$params[0]'"); 413 return; 414 } 415 unset($info['filelist']); 416 unset($info['dirtree']); 417 unset($info['changelog']); 418 if (isset($info['xsdversion'])) { 419 $info['package.xml version'] = $info['xsdversion']; 420 unset($info['xsdversion']); 421 } 422 if (isset($info['packagerversion'])) { 423 $info['packaged with PEAR version'] = $info['packagerversion']; 424 unset($info['packagerversion']); 425 } 426 $keys = array_keys($info); 427 $longtext = array('description', 'summary'); 428 foreach ($keys as $key) { 429 if (is_array($info[$key])) { 430 switch ($key) { 431 case 'maintainers': { 432 $i = 0; 433 $mstr = ''; 434 foreach ($info[$key] as $m) { 435 if ($i++ > 0) { 436 $mstr .= "\n"; 437 } 438 $mstr .= $m['name'] . " <"; 439 if (isset($m['email'])) { 440 $mstr .= $m['email']; 441 } else { 442 $mstr .= $m['handle'] . '@php.net'; 443 } 444 $mstr .= "> ($m[role])"; 445 } 446 $info[$key] = $mstr; 447 break; 448 } 449 case 'release_deps': { 450 $i = 0; 451 $dstr = ''; 452 foreach ($info[$key] as $d) { 453 if (isset($this->_deps_rel_trans[$d['rel']])) { 454 $rel = $this->_deps_rel_trans[$d['rel']]; 455 } else { 456 $rel = $d['rel']; 457 } 458 if (isset($this->_deps_type_trans[$d['type']])) { 459 $type = ucfirst($this->_deps_type_trans[$d['type']]); 460 } else { 461 $type = $d['type']; 462 } 463 if (isset($d['name'])) { 464 $name = $d['name'] . ' '; 465 } else { 466 $name = ''; 467 } 468 if (isset($d['version'])) { 469 $version = $d['version'] . ' '; 470 } else { 471 $version = ''; 472 } 473 if (isset($d['optional']) && $d['optional'] == 'yes') { 474 $optional = ' (optional)'; 475 } else { 476 $optional = ''; 477 } 478 $dstr .= "$type $name$rel $version$optional\n"; 479 } 480 $info[$key] = $dstr; 481 break; 482 } 483 case 'provides' : { 484 $debug = $this->config->get('verbose'); 485 if ($debug < 2) { 486 $pstr = 'Classes: '; 487 } else { 488 $pstr = ''; 489 } 490 $i = 0; 491 foreach ($info[$key] as $p) { 492 if ($debug < 2 && $p['type'] != "class") { 493 continue; 494 } 495 // Only print classes when verbosity mode is < 2 496 if ($debug < 2) { 497 if ($i++ > 0) { 498 $pstr .= ", "; 499 } 500 $pstr .= $p['name']; 501 } else { 502 if ($i++ > 0) { 503 $pstr .= "\n"; 504 } 505 $pstr .= ucfirst($p['type']) . " " . $p['name']; 506 if (isset($p['explicit']) && $p['explicit'] == 1) { 507 $pstr .= " (explicit)"; 508 } 509 } 510 } 511 $info[$key] = $pstr; 512 break; 513 } 514 case 'configure_options' : { 515 foreach ($info[$key] as $i => $p) { 516 $info[$key][$i] = array_map(null, array_keys($p), array_values($p)); 517 $info[$key][$i] = array_map(create_function('$a', 518 'return join(" = ",$a);'), $info[$key][$i]); 519 $info[$key][$i] = implode(', ', $info[$key][$i]); 520 } 521 $info[$key] = implode("\n", $info[$key]); 522 break; 523 } 524 default: { 525 $info[$key] = implode(", ", $info[$key]); 526 break; 527 } 528 } 529 } 530 if ($key == '_lastmodified') { 531 $hdate = date('Y-m-d', $info[$key]); 532 unset($info[$key]); 533 $info['Last Modified'] = $hdate; 534 } elseif ($key == '_lastversion') { 535 $info['Previous Installed Version'] = $info[$key] ? $info[$key] : '- None -'; 536 unset($info[$key]); 537 } else { 538 $info[$key] = trim($info[$key]); 539 if (in_array($key, $longtext)) { 540 $info[$key] = preg_replace('/ +/', ' ', $info[$key]); 541 } 542 } 543 } 544 $caption = 'About ' . $info['package'] . '-' . $info['version']; 545 $data = array( 546 'caption' => $caption, 547 'border' => true); 548 foreach ($info as $key => $value) { 549 $key = ucwords(trim(str_replace('_', ' ', $key))); 550 $data['data'][] = array($key, $value); 551 } 552 $data['raw'] = $info; 553 554 $this->ui->outputData($data, 'package-info'); 555 } 556 557 // }}} 558 559 /** 560 * @access private 561 */ 562 function _doInfo2($command, $options, $params, &$obj, $installed) 563 { 564 $reg = &$this->config->getRegistry(); 565 $caption = 'About ' . $obj->getChannel() . '/' .$obj->getPackage() . '-' . 566 $obj->getVersion(); 567 $data = array( 568 'caption' => $caption, 569 'border' => true); 570 switch ($obj->getPackageType()) { 571 case 'php' : 572 $release = 'PEAR-style PHP-based Package'; 573 break; 574 case 'extsrc' : 575 $release = 'PECL-style PHP extension (source code)'; 576 break; 577 case 'zendextsrc' : 578 $release = 'PECL-style Zend extension (source code)'; 579 break; 580 case 'extbin' : 581 $release = 'PECL-style PHP extension (binary)'; 582 break; 583 case 'zendextbin' : 584 $release = 'PECL-style Zend extension (binary)'; 585 break; 586 case 'bundle' : 587 $release = 'Package bundle (collection of packages)'; 588 break; 589 } 590 $extends = $obj->getExtends(); 591 $extends = $extends ? 592 $obj->getPackage() . ' (extends ' . $extends . ')' : $obj->getPackage(); 593 if ($src = $obj->getSourcePackage()) { 594 $extends .= ' (source package ' . $src['channel'] . '/' . $src['package'] . ')'; 595 } 596 $info = array( 597 'Release Type' => $release, 598 'Name' => $extends, 599 'Channel' => $obj->getChannel(), 600 'Summary' => preg_replace('/ +/', ' ', $obj->getSummary()), 601 'Description' => preg_replace('/ +/', ' ', $obj->getDescription()), 602 ); 603 $info['Maintainers'] = ''; 604 foreach (array('lead', 'developer', 'contributor', 'helper') as $role) { 605 $leads = $obj->{"get{$role}s"}(); 606 if (!$leads) { 607 continue; 608 } 609 if (isset($leads['active'])) { 610 $leads = array($leads); 611 } 612 foreach ($leads as $lead) { 613 if (!empty($info['Maintainers'])) { 614 $info['Maintainers'] .= "\n"; 615 } 616 $info['Maintainers'] .= $lead['name'] . ' <'; 617 $info['Maintainers'] .= $lead['email'] . "> ($role)"; 618 } 619 } 620 $info['Release Date'] = $obj->getDate(); 621 if ($time = $obj->getTime()) { 622 $info['Release Date'] .= ' ' . $time; 623 } 624 $info['Release Version'] = $obj->getVersion() . ' (' . $obj->getState() . ')'; 625 $info['API Version'] = $obj->getVersion('api') . ' (' . $obj->getState('api') . ')'; 626 $info['License'] = $obj->getLicense(); 627 $uri = $obj->getLicenseLocation(); 628 if ($uri) { 629 if (isset($uri['uri'])) { 630 $info['License'] .= ' (' . $uri['uri'] . ')'; 631 } else { 632 $extra = $obj->getInstalledLocation($info['filesource']); 633 if ($extra) { 634 $info['License'] .= ' (' . $uri['filesource'] . ')'; 635 } 636 } 637 } 638 $info['Release Notes'] = $obj->getNotes(); 639 if ($compat = $obj->getCompatible()) { 640 $info['Compatible with'] = ''; 641 foreach ($compat as $package) { 642 $info['Compatible with'] .= $package['channel'] . '/' . $package['package'] . 643 "\nVersions >= " . $package['min'] . ', <= ' . $package['max']; 644 if (isset($package['exclude'])) { 645 if (is_array($package['exclude'])) { 646 $package['exclude'] = implode(', ', $package['exclude']); 647 } 648 if (!isset($info['Not Compatible with'])) { 649 $info['Not Compatible with'] = ''; 650 } else { 651 $info['Not Compatible with'] .= "\n"; 652 } 653 $info['Not Compatible with'] .= $package['channel'] . '/' . 654 $package['package'] . "\nVersions " . $package['exclude']; 655 } 656 } 657 } 658 $usesrole = $obj->getUsesrole(); 659 if ($usesrole) { 660 if (!isset($usesrole[0])) { 661 $usesrole = array($usesrole); 662 } 663 foreach ($usesrole as $roledata) { 664 if (isset($info['Uses Custom Roles'])) { 665 $info['Uses Custom Roles'] .= "\n"; 666 } else { 667 $info['Uses Custom Roles'] = ''; 668 } 669 if (isset($roledata['package'])) { 670 $rolepackage = $reg->parsedPackageNameToString($roledata, true); 671 } else { 672 $rolepackage = $roledata['uri']; 673 } 674 $info['Uses Custom Roles'] .= $roledata['role'] . ' (' . $rolepackage . ')'; 675 } 676 } 677 $usestask = $obj->getUsestask(); 678 if ($usestask) { 679 if (!isset($usestask[0])) { 680 $usestask = array($usestask); 681 } 682 foreach ($usestask as $taskdata) { 683 if (isset($info['Uses Custom Tasks'])) { 684 $info['Uses Custom Tasks'] .= "\n"; 685 } else { 686 $info['Uses Custom Tasks'] = ''; 687 } 688 if (isset($taskdata['package'])) { 689 $taskpackage = $reg->parsedPackageNameToString($taskdata, true); 690 } else { 691 $taskpackage = $taskdata['uri']; 692 } 693 $info['Uses Custom Tasks'] .= $taskdata['task'] . ' (' . $taskpackage . ')'; 694 } 695 } 696 $deps = $obj->getDependencies(); 697 $info['Required Dependencies'] = 'PHP version ' . $deps['required']['php']['min']; 698 if (isset($deps['required']['php']['max'])) { 699 $info['Required Dependencies'] .= '-' . $deps['required']['php']['max'] . "\n"; 700 } else { 701 $info['Required Dependencies'] .= "\n"; 702 } 703 if (isset($deps['required']['php']['exclude'])) { 704 if (!isset($info['Not Compatible with'])) { 705 $info['Not Compatible with'] = ''; 706 } else { 707 $info['Not Compatible with'] .= "\n"; 708 } 709 if (is_array($deps['required']['php']['exclude'])) { 710 $deps['required']['php']['exclude'] = 711 implode(', ', $deps['required']['php']['exclude']); 712 } 713 $info['Not Compatible with'] .= "PHP versions\n " . 714 $deps['required']['php']['exclude']; 715 } 716 $info['Required Dependencies'] .= 'PEAR installer version'; 717 if (isset($deps['required']['pearinstaller']['max'])) { 718 $info['Required Dependencies'] .= 's ' . 719 $deps['required']['pearinstaller']['min'] . '-' . 720 $deps['required']['pearinstaller']['max']; 721 } else { 722 $info['Required Dependencies'] .= ' ' . 723 $deps['required']['pearinstaller']['min'] . ' or newer'; 724 } 725 if (isset($deps['required']['pearinstaller']['exclude'])) { 726 if (!isset($info['Not Compatible with'])) { 727 $info['Not Compatible with'] = ''; 728 } else { 729 $info['Not Compatible with'] .= "\n"; 730 } 731 if (is_array($deps['required']['pearinstaller']['exclude'])) { 732 $deps['required']['pearinstaller']['exclude'] = 733 implode(', ', $deps['required']['pearinstaller']['exclude']); 734 } 735 $info['Not Compatible with'] .= "PEAR installer\n Versions " . 736 $deps['required']['pearinstaller']['exclude']; 737 } 738 foreach (array('Package', 'Extension') as $type) { 739 $index = strtolower($type); 740 if (isset($deps['required'][$index])) { 741 if (isset($deps['required'][$index]['name'])) { 742 $deps['required'][$index] = array($deps['required'][$index]); 743 } 744 foreach ($deps['required'][$index] as $package) { 745 if (isset($package['conflicts'])) { 746 $infoindex = 'Not Compatible with'; 747 if (!isset($info['Not Compatible with'])) { 748 $info['Not Compatible with'] = ''; 749 } else { 750 $info['Not Compatible with'] .= "\n"; 751 } 752 } else { 753 $infoindex = 'Required Dependencies'; 754 $info[$infoindex] .= "\n"; 755 } 756 if ($index == 'extension') { 757 $name = $package['name']; 758 } else { 759 if (isset($package['channel'])) { 760 $name = $package['channel'] . '/' . $package['name']; 761 } else { 762 $name = '__uri/' . $package['name'] . ' (static URI)'; 763 } 764 } 765 $info[$infoindex] .= "$type $name"; 766 if (isset($package['uri'])) { 767 $info[$infoindex] .= "\n Download URI: $package[uri]"; 768 continue; 769 } 770 if (isset($package['max']) && isset($package['min'])) { 771 $info[$infoindex] .= " \n Versions " . 772 $package['min'] . '-' . $package['max']; 773 } elseif (isset($package['min'])) { 774 $info[$infoindex] .= " \n Version " . 775 $package['min'] . ' or newer'; 776 } elseif (isset($package['max'])) { 777 $info[$infoindex] .= " \n Version " . 778 $package['max'] . ' or older'; 779 } 780 if (isset($package['recommended'])) { 781 $info[$infoindex] .= "\n Recommended version: $package[recommended]"; 782 } 783 if (isset($package['exclude'])) { 784 if (!isset($info['Not Compatible with'])) { 785 $info['Not Compatible with'] = ''; 786 } else { 787 $info['Not Compatible with'] .= "\n"; 788 } 789 if (is_array($package['exclude'])) { 790 $package['exclude'] = implode(', ', $package['exclude']); 791 } 792 $package['package'] = $package['name']; // for parsedPackageNameToString 793 if (isset($package['conflicts'])) { 794 $info['Not Compatible with'] .= '=> except '; 795 } 796 $info['Not Compatible with'] .= 'Package ' . 797 $reg->parsedPackageNameToString($package, true); 798 $info['Not Compatible with'] .= "\n Versions " . $package['exclude']; 799 } 800 } 801 } 802 } 803 if (isset($deps['required']['os'])) { 804 if (isset($deps['required']['os']['name'])) { 805 $dep['required']['os']['name'] = array($dep['required']['os']['name']); 806 } 807 foreach ($dep['required']['os'] as $os) { 808 if (isset($os['conflicts']) && $os['conflicts'] == 'yes') { 809 if (!isset($info['Not Compatible with'])) { 810 $info['Not Compatible with'] = ''; 811 } else { 812 $info['Not Compatible with'] .= "\n"; 813 } 814 $info['Not Compatible with'] .= "$os[name] Operating System"; 815 } else { 816 $info['Required Dependencies'] .= "\n"; 817 $info['Required Dependencies'] .= "$os[name] Operating System"; 818 } 819 } 820 } 821 if (isset($deps['required']['arch'])) { 822 if (isset($deps['required']['arch']['pattern'])) { 823 $dep['required']['arch']['pattern'] = array($dep['required']['os']['pattern']); 824 } 825 foreach ($dep['required']['arch'] as $os) { 826 if (isset($os['conflicts']) && $os['conflicts'] == 'yes') { 827 if (!isset($info['Not Compatible with'])) { 828 $info['Not Compatible with'] = ''; 829 } else { 830 $info['Not Compatible with'] .= "\n"; 831 } 832 $info['Not Compatible with'] .= "OS/Arch matching pattern '/$os[pattern]/'"; 833 } else { 834 $info['Required Dependencies'] .= "\n"; 835 $info['Required Dependencies'] .= "OS/Arch matching pattern '/$os[pattern]/'"; 836 } 837 } 838 } 839 if (isset($deps['optional'])) { 840 foreach (array('Package', 'Extension') as $type) { 841 $index = strtolower($type); 842 if (isset($deps['optional'][$index])) { 843 if (isset($deps['optional'][$index]['name'])) { 844 $deps['optional'][$index] = array($deps['optional'][$index]); 845 } 846 foreach ($deps['optional'][$index] as $package) { 847 if (isset($package['conflicts']) && $package['conflicts'] == 'yes') { 848 $infoindex = 'Not Compatible with'; 849 if (!isset($info['Not Compatible with'])) { 850 $info['Not Compatible with'] = ''; 851 } else { 852 $info['Not Compatible with'] .= "\n"; 853 } 854 } else { 855 $infoindex = 'Optional Dependencies'; 856 if (!isset($info['Optional Dependencies'])) { 857 $info['Optional Dependencies'] = ''; 858 } else { 859 $info['Optional Dependencies'] .= "\n"; 860 } 861 } 862 if ($index == 'extension') { 863 $name = $package['name']; 864 } else { 865 if (isset($package['channel'])) { 866 $name = $package['channel'] . '/' . $package['name']; 867 } else { 868 $name = '__uri/' . $package['name'] . ' (static URI)'; 869 } 870 } 871 $info[$infoindex] .= "$type $name"; 872 if (isset($package['uri'])) { 873 $info[$infoindex] .= "\n Download URI: $package[uri]"; 874 continue; 875 } 876 if ($infoindex == 'Not Compatible with') { 877 // conflicts is only used to say that all versions conflict 878 continue; 879 } 880 if (isset($package['max']) && isset($package['min'])) { 881 $info[$infoindex] .= " \n Versions " . 882 $package['min'] . '-' . $package['max']; 883 } elseif (isset($package['min'])) { 884 $info[$infoindex] .= " \n Version " . 885 $package['min'] . ' or newer'; 886 } elseif (isset($package['max'])) { 887 $info[$infoindex] .= " \n Version " . 888 $package['min'] . ' or older'; 889 } 890 if (isset($package['recommended'])) { 891 $info[$infoindex] .= "\n Recommended version: $package[recommended]"; 892 } 893 if (isset($package['exclude'])) { 894 if (!isset($info['Not Compatible with'])) { 895 $info['Not Compatible with'] = ''; 896 } else { 897 $info['Not Compatible with'] .= "\n"; 898 } 899 if (is_array($package['exclude'])) { 900 $package['exclude'] = implode(', ', $package['exclude']); 901 } 902 $info['Not Compatible with'] .= "Package $package\n Versions " . 903 $package['exclude']; 904 } 905 } 906 } 907 } 908 } 909 if (isset($deps['group'])) { 910 if (!isset($deps['group'][0])) { 911 $deps['group'] = array($deps['group']); 912 } 913 foreach ($deps['group'] as $group) { 914 $info['Dependency Group ' . $group['attribs']['name']] = $group['attribs']['hint']; 915 $groupindex = $group['attribs']['name'] . ' Contents'; 916 $info[$groupindex] = ''; 917 foreach (array('Package', 'Extension') as $type) { 918 $index = strtolower($type); 919 if (isset($group[$index])) { 920 if (isset($group[$index]['name'])) { 921 $group[$index] = array($group[$index]); 922 } 923 foreach ($group[$index] as $package) { 924 if (!empty($info[$groupindex])) { 925 $info[$groupindex] .= "\n"; 926 } 927 if ($index == 'extension') { 928 $name = $package['name']; 929 } else { 930 if (isset($package['channel'])) { 931 $name = $package['channel'] . '/' . $package['name']; 932 } else { 933 $name = '__uri/' . $package['name'] . ' (static URI)'; 934 } 935 } 936 if (isset($package['uri'])) { 937 if (isset($package['conflicts']) && $package['conflicts'] == 'yes') { 938 $info[$groupindex] .= "Not Compatible with $type $name"; 939 } else { 940 $info[$groupindex] .= "$type $name"; 941 } 942 $info[$groupindex] .= "\n Download URI: $package[uri]"; 943 continue; 944 } 945 if (isset($package['conflicts']) && $package['conflicts'] == 'yes') { 946 $info[$groupindex] .= "Not Compatible with $type $name"; 947 continue; 948 } 949 $info[$groupindex] .= "$type $name"; 950 if (isset($package['max']) && isset($package['min'])) { 951 $info[$groupindex] .= " \n Versions " . 952 $package['min'] . '-' . $package['max']; 953 } elseif (isset($package['min'])) { 954 $info[$groupindex] .= " \n Version " . 955 $package['min'] . ' or newer'; 956 } elseif (isset($package['max'])) { 957 $info[$groupindex] .= " \n Version " . 958 $package['min'] . ' or older'; 959 } 960 if (isset($package['recommended'])) { 961 $info[$groupindex] .= "\n Recommended version: $package[recommended]"; 962 } 963 if (isset($package['exclude'])) { 964 if (!isset($info['Not Compatible with'])) { 965 $info['Not Compatible with'] = ''; 966 } else { 967 $info[$groupindex] .= "Not Compatible with\n"; 968 } 969 if (is_array($package['exclude'])) { 970 $package['exclude'] = implode(', ', $package['exclude']); 971 } 972 $info[$groupindex] .= " Package $package\n Versions " . 973 $package['exclude']; 974 } 975 } 976 } 977 } 978 } 979 } 980 if ($obj->getPackageType() == 'bundle') { 981 $info['Bundled Packages'] = ''; 982 foreach ($obj->getBundledPackages() as $package) { 983 if (!empty($info['Bundled Packages'])) { 984 $info['Bundled Packages'] .= "\n"; 985 } 986 if (isset($package['uri'])) { 987 $info['Bundled Packages'] .= '__uri/' . $package['name']; 988 $info['Bundled Packages'] .= "\n (URI: $package[uri]"; 989 } else { 990 $info['Bundled Packages'] .= $package['channel'] . '/' . $package['name']; 991 } 992 } 993 } 994 $info['package.xml version'] = '2.0'; 995 if ($installed) { 996 if ($obj->getLastModified()) { 997 $info['Last Modified'] = date('Y-m-d H:i', $obj->getLastModified()); 998 } 999 $v = $obj->getLastInstalledVersion(); 1000 $info['Previous Installed Version'] = $v ? $v : '- None -'; 1001 } 1002 foreach ($info as $key => $value) { 1003 $data['data'][] = array($key, $value); 1004 } 1005 $data['raw'] = $obj->getArray(); // no validation needed 1006 1007 $this->ui->outputData($data, 'package-info'); 1008 } 1009 } 1010 1011 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 14:08:00 2007 | par Balluche grâce à PHPXref 0.7 |