ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

package_version.php
Go to the documentation of this file.
1 <?php
2
3 /*
4 * This source code is a part of the Ultimix Project.
5 * It is distributed under BSD license. All other third side source code (like tinyMCE) is distributed under
6 * it's own license wich could be found from the corresponding files or sources.
7 * This source code is provided "as is" without any warranties or garanties.
8 *
9 * Have a nice day!
10 *
11 * @url http://ultimix.sorceforge.net
12 *
13 * @author Alexey "gdever" Dodonov
14 */
15
16 $FullClassNameCacheChanged = false;
17 $FullClassNameCache = array();
18
19 $PackageRealVersionCacheChanged = false;
20 $PackageRealVersionCache = array();
21
48 function _compare_versions( $TmpVersion , $Sel )
49 {
50 try
51 {
52 return(
53 $TmpVersion[ 0 ] > $Sel[ 0 ] ||
54 ( $TmpVersion[ 0 ] == $Sel[ 0 ] && $TmpVersion[ 1 ] > $Sel[ 1 ] ) ||
55 ( $TmpVersion[ 0 ] == $Sel[ 0 ] && $TmpVersion[ 1 ] == $Sel[ 1 ] &&
56 $TmpVersion[ 2 ] > $Sel[ 2 ] )
57 );
58 }
59 catch( Exception $e )
60 {
61 $Args = func_get_args();throw( _get_exception_object( __FUNCTION__ , $Args , $e ) );
62 }
63 }
64
99 function _check_tmp_version( $Tmp , &$Sel , &$PackageDirectory , &$pi )
100 {
101 try
102 {
103 $TmpVersion = explode( '.' , str_replace( $Tmp , '' , $pi[ 0 ] ) );
104
105 if( _compare_versions( $TmpVersion , $Sel ) )
106 {
107 $Sel = $TmpVersion;
108 $PackageDirectory = $pi[ 1 ];
109 return( true );
110 }
111
112 return( false );
113 }
114 catch( Exception $e )
115 {
116 $Args = func_get_args();throw( _get_exception_object( __FUNCTION__ , $Args , $e ) );
117 }
118 }
119
151 function _get_package_version( $PackageName , $PackageVersion , $ROOT_DIR = INSTALL_DIR )
152 {
153 try
154 {
155 if( $PackageVersion === 'last' )
156 {
157 $PackagesInfo = _load_packages_list( $ROOT_DIR );
158 $Dir = '';
159 $Sel = array( '0' , '0' , '0' );
160 $Tmp = $PackageName.'.';
161 foreach( $PackagesInfo as $pi )
162 {
163 $FastCheck = $pi[ 0 ][ 0 ] === $Tmp[ 0 ] && strpos( $pi[ 0 ] , $Tmp ) === 0;
164 if( $FastCheck && _check_tmp_version( $Tmp , $Sel , $Dir , $pi ) )
165 {
166 break;
167 }
168 }
169 $PackageVersion = implode( '.' , $Sel );
170 if( $Dir === '' )
171 {
172 throw( new Exception( 'Package '.$Tmp.$PackageVersion.' was not found' ) );
173 }
174 }
175 return( $PackageVersion );
176 }
177 catch( Exception $e )
178 {
179 $Args = func_get_args();throw( _get_exception_object( __FUNCTION__ , $Args , $e ) );
180 }
181 }
182
214 function _get_package_real_version( $PackageName , $PackageVersion , $ROOT_DIR = INSTALL_DIR )
215 {
216 try
217 {
218 global $PackageRealVersionCache;
219 $Key = "$PackageName $PackageVersion $ROOT_DIR";
220
221 if( isset( $PackageRealVersionCache[ $Key ] ) === false )
222 {
223 global $PackageRealVersionCacheChanged;
224
225 $PackageRealVersionCacheChanged = true;
226
227 $PackageRealVersionCache[ $Key ] = _get_package_version( $PackageName , $PackageVersion , $ROOT_DIR );
228 }
229
230 return( $PackageRealVersionCache[ $Key ] );
231 }
232 catch( Exception $e )
233 {
234 $Args = func_get_args();throw( _get_exception_object( __FUNCTION__ , $Args , $e ) );
235 }
236 }
237
238 ?>