| [ Index ] |
PHP Cross Reference of MantisBT |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * File containing the ezcBaseMetaDataTarballReader class. 4 * 5 * @package Base 6 * @version 1.8 7 * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. 8 * @license http://ez.no/licenses/new_bsd New BSD License 9 */ 10 /** 11 * Base class implements ways of fetching information about the installed 12 * eZ Components when installed as tarball. 13 * 14 * @package Base 15 * @version 1.8 16 * @mainclass 17 */ 18 class ezcBaseMetaDataTarballReader 19 { 20 /** 21 * Contains the handler to the XML file containing the release information. 22 * @var SimpleXmlElement 23 */ 24 private $xml; 25 26 /** 27 * Creates the reader object and opens the release-info file. 28 */ 29 public function __construct() 30 { 31 $filename = dirname( __FILE__ ) . '/../../../release-info.xml'; 32 $this->xml = simplexml_load_file( $filename ); 33 } 34 35 /** 36 * Returns the version string for the installed eZ Components bundle. 37 * 38 * A version string such as "2008.2.2" is returned. 39 * 40 * @return string 41 */ 42 public function getBundleVersion() 43 { 44 return (string) $this->xml->version; 45 } 46 47 /** 48 * Returns a PHP version string that describes the required PHP version for 49 * this installed eZ Components bundle. 50 * 51 * @return string 52 */ 53 public function getRequiredPhpVersion() 54 { 55 return (string) $this->xml->deps->php; 56 } 57 58 /** 59 * Returns whether $componentName is installed 60 * 61 * Returns true for every component that exists (because all of them are 62 * then available). 63 * 64 * @return bool 65 */ 66 public function isComponentInstalled( $componentName ) 67 { 68 $root = $this->xml->deps->packages->package; 69 70 foreach ( $root as $package ) 71 { 72 if ( (string) $package['name'] == $componentName ) 73 { 74 return true; 75 } 76 } 77 return false; 78 } 79 80 /** 81 * Returns the version string of the available $componentName or false when 82 * the component is not installed. 83 * 84 * @return string 85 */ 86 public function getComponentVersion( $componentName ) 87 { 88 $root = $this->xml->deps->packages->package; 89 90 foreach ( $root as $package ) 91 { 92 if ( (string) $package['name'] == $componentName ) 93 { 94 return (string) $package['version']; 95 } 96 } 97 return false; 98 } 99 100 /** 101 * Returns a list of components that $componentName depends on. 102 * 103 * If $componentName is left empty, all installed components are returned. 104 * 105 * The returned array has as keys the component names, and as values the 106 * version of the components. It returns null of the $componentName 107 * is not found. 108 * 109 * @return array(string=>string). 110 */ 111 public function getComponentDependencies( $componentName = null ) 112 { 113 $baseVersion = false; 114 $root = $this->xml->deps->packages; 115 $found = $componentName === null ? true : false; 116 117 // in case $componentName != null, we loop through all the components 118 // in the file, and figure out the new root that we can list dependency 119 // packages from. 120 foreach ( $root->package as $package ) 121 { 122 if ( (string) $package['name'] == 'Base' ) 123 { 124 $baseVersion = $package['version']; 125 } 126 if ( !$found && (string) $package['name'] == $componentName ) 127 { 128 $root = $package->deps; 129 $found = true; 130 } 131 } 132 133 if ( !$found ) 134 { 135 return null; 136 } 137 138 // We always add the Base dependency even though it's not in the dependency file. 139 $deps = array(); 140 $deps['Base'] = (string) $baseVersion; 141 142 if ( !isset( $root->package ) ) 143 { 144 return $deps; 145 } 146 foreach ( $root->package as $package ) 147 { 148 $deps[(string) $package['name']] = (string) $package['version']; 149 } 150 return $deps; 151 } 152 } 153 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Jul 28 15:48:31 2011 | Cross-referenced by PHPXref 0.7 |