commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / packages / ezc / Base / src / metadata.php
1 <?php
2 /**
3 * File containing the ezcBaseMetaData class.
4 *
5 * @package Base
6 * @version 1.7
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. It knows whether to use the PEAR registry or the bundled XML
13 * file, depending on how eZ Components is installed.
14 *
15 * @package Base
16 * @version 1.7
17 * @mainclass
18 */
19 class ezcBaseMetaData
20 {
21 /**
22 * Creates a ezcBaseMetaData object
23 *
24 * The sole parameter $installMethod should only be used if you are really
25 * sure that you need to use it. It is mostly there to make testing at
26 * least slightly possible. Again, do not set it unless instructed.
27 *
28 * @param string $installMethod
29 */
30 public function __construct( $installMethod = NULL )
31 {
32 $installMethod = $installMethod !== NULL ? $installMethod : ezcBase::getInstallMethod();
33
34 // figure out which reader to use
35 switch ( $installMethod )
36 {
37 case 'tarball':
38 $this->reader = new ezcBaseMetaDataTarballReader;
39 break;
40 case 'pear':
41 $this->reader = new ezcBaseMetaDataPearReader;
42 break;
43 default:
44 throw new ezcBaseMetaDataReaderException( "Unknown install method '$installMethod'." );
45 break;
46 }
47 }
48
49 /**
50 * Returns the version string for the installed eZ Components bundle.
51 *
52 * A version string such as "2008.2.2" is returned.
53 *
54 * @return string
55 */
56 public function getBundleVersion()
57 {
58 return $this->reader->getBundleVersion();
59 }
60
61 /**
62 * Returns a PHP version string that describes the required PHP version for
63 * this installed eZ Components bundle.
64 *
65 * @return string
66 */
67 public function getRequiredPhpVersion()
68 {
69 return $this->reader->getRequiredPhpVersion();
70 }
71
72 /**
73 * Returns whether $componentName is installed
74 *
75 * If installed with PEAR, it checks the PEAR registry whether the
76 * component is there. In case the tarball installation method is used, it
77 * will return true for every component that exists (because all of them
78 * are then available).
79 *
80 * @return bool
81 */
82 public function isComponentInstalled( $componentName )
83 {
84 return $this->reader->isComponentInstalled( $componentName );
85 }
86
87 /**
88 * Returns the version string of the available $componentName or false when
89 * the component is not installed.
90 *
91 * @return string
92 */
93 public function getComponentVersion( $componentName )
94 {
95 return $this->reader->getComponentVersion( $componentName );
96 }
97
98 /**
99 * Returns a list of components that $componentName depends on.
100 *
101 * If $componentName is left empty, all installed components are returned.
102 *
103 * The returned array has as keys the component names, and as values the
104 * version of the components.
105 *
106 * @return array(string=>string).
107 */
108 public function getComponentDependencies( $componentName = null )
109 {
110 if ( $componentName === null )
111 {
112 return $this->reader->getComponentDependencies();
113 }
114 else
115 {
116 return $this->reader->getComponentDependencies( $componentName );
117 }
118 }
119 }
120 ?>