ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

package_manager.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
26 class package_manager_1_0_0{
27
38 var $Output = false;
39
50 var $CachedMultyFS = false;
51
66 function __construct()
67 {
68 try
69 {
70 $this->CachedMultyFS = get_package( 'cached_multy_fs' , 'last' , __FILE__ );
71 }
72 catch( Exception $e )
73 {
74 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
75 }
76 }
77
96 function install_package( $Options )
97 {
98 try
99 {
100 $Security = get_package( 'security' , 'last' , __FILE__ );
101 $PackageAlgoritms = get_package( 'core::package_algorithms' , 'last' , __FILE__ );
102 $MasterPackage = explode( '#' , $Security->get_gp( 'package_selection' , 'string' ) );
103 $PackageAlgoritms->install_package(
104 $UploadFileAccess->UploadedFilePath , $MasterPackage[ 0 ] , $MasterPackage[ 1 ]
105 );
106 }
107 catch( Exception $e )
108 {
109 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
110 }
111 }
112
131 function delete_package( $Options )
132 {
133 try
134 {
135 $Security = get_package( 'security' , 'last' , __FILE__ );
136 $PackageName = $Security->get_gp( 'package_name' , 'string' );
137 $PackageVersion = $Security->get_gp( 'package_version' , 'string' );
138
139 $ROOT_DIR = _get_root_dir( $PackageName , $PackageVersion , INSTALL_DIR );
140 $PackageDirectory = _get_package_path( $PackageName , $PackageVersion , $ROOT_DIR );
141
142 _delete_package( $PackageName , $PackageVersion );
143 }
144 catch( Exception $e )
145 {
146 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
147 }
148 }
149
168 function controller( $Options )
169 {
170 try
171 {
172 $ContextSet = get_package( 'gui::context_set' , 'last' , __FILE__ );
173
174 $ContextSet->add_context( dirname( __FILE__ ).'/conf/cfcx_delete_package' );
175 $ContextSet->add_context( dirname( __FILE__ ).'/conf/cfcx_install_package' );
176
177 if( $ContextSet->execute( $Options , $this , __FILE__ ) )
178 {
179 return;
180 }
181 }
182 catch( Exception $e )
183 {
184 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
185 }
186 }
187
214 function compile_package_tree_branch( $Branch , $Package )
215 {
216 try
217 {
218 $Title = $Package[ 'package_name' ].'.'.$Package[ 'package_version' ];
219
220 $Branch .= $this->CachedMultyFS->get_template( __FILE__ , 'package_item_start.tpl' );
221
222 $Branch = str_replace( '{title}' , $Title , $Branch );
223
224 $Branch .= $this->show_package_tree_rec( $Package[ 'subpackages' ] );
225
226 $Branch .= $this->CachedMultyFS->get_template( __FILE__ , 'package_item_end.tpl' );
227 }
228 catch( Exception $e )
229 {
230 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
231 }
232 }
233
256 function show_package_tree_rec( $Packages )
257 {
258 try
259 {
260 if( isset( $Packages[ 0 ] ) == false )
261 {
262 return( '' );
263 }
264
265 $Branch = $this->CachedMultyFS->get_template( __FILE__ , 'package_branch_start.tpl' );
266
267 foreach( $Packages as $i => $Package )
268 {
269 $Branch = $this->compile_package_tree_branch( $Branch , $Package );
270 }
271
272 return( $Branch.$this->CachedMultyFS->get_template( __FILE__ , 'package_branch_end.tpl' ) );
273 }
274 catch( Exception $e )
275 {
276 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
277 }
278 }
279
298 function show_package_tree( $Options )
299 {
300 try
301 {
302 $PackageAlgorithms = get_package( 'core::package_algorithms' , 'last' , __FILE__ );
303 $Packages = $PackageAlgorithms->get_packages_tree();
304
305 $this->Output = $this->CachedMultyFS->get_template( __FILE__ , 'package_start.tpl' );
306
307 foreach( $Packages as $i => $Package )
308 {
309 $this->Output = $this->compile_package_tree_branch( $this->Output , $Package );
310 }
311
312 $this->Output .= $this->CachedMultyFS->get_template( __FILE__ , 'package_end.tpl' );
313 }
314 catch( Exception $e )
315 {
316 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
317 }
318 }
319
342 function show_system_tree_meta_rec( $MetaFiles )
343 {
344 try
345 {
346 if( isset( $MetaFiles[ 0 ] ) == false )
347 {
348 return( '' );
349 }
350
351 $Branch = $this->CachedMultyFS->get_template( __FILE__ , 'package_meta_start.tpl' );
352
353 foreach( $MetaFiles as $i => $File )
354 {
355 $Title = basename( $File );
356
357 $Branch .= $this->CachedMultyFS->get_template( __FILE__ , 'package_meta_item.tpl' );
358
359 $Branch = str_replace( '{title}' , $Title , $Branch );
360 }
361
362 return( $Branch.$this->CachedMultyFS->get_template( __FILE__ , 'package_meta_end.tpl' ) );
363 }
364 catch( Exception $e )
365 {
366 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
367 }
368 }
369
392 function show_system_tree_conf_rec( $ConfigFiles )
393 {
394 try
395 {
396 if( isset( $ConfigFiles[ 0 ] ) == false )
397 {
398 return( '' );
399 }
400
401 $Branch = $this->CachedMultyFS->get_template( __FILE__ , 'package_conf_start.tpl' );
402
403 foreach( $ConfigFiles as $i => $File )
404 {
405 $Title = basename( $File );
406
407 $Branch .= $this->CachedMultyFS->get_template( __FILE__ , 'package_conf_item.tpl' );
408
409 $Branch = str_replace( '{title}' , $Title , $Branch );
410 }
411
412 return( $Branch.$this->CachedMultyFS->get_template( __FILE__ , 'package_conf_end.tpl' ) );
413 }
414 catch( Exception $e )
415 {
416 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
417 }
418 }
419
446 function compile_system_tree_branch( $Branch , $Package )
447 {
448 try
449 {
450 $Title = $Package[ 'package_name' ].'.'.$Package[ 'package_version' ];
451
452 $Branch .= $this->CachedMultyFS->get_template( __FILE__ , 'package_system_item_start.tpl' );
453
454 $Branch = str_replace( '{title}' , $Title , $Branch );
455
456 $Branch .= $this->show_system_tree_rec( $Package[ 'subpackages' ] );
457
458 $Branch .= $this->show_system_tree_meta_rec( $Package[ 'meta' ] );
459
460 $Branch .= $this->show_system_tree_conf_rec( $Package[ 'conf' ] );
461
462 $Branch .= $this->CachedMultyFS->get_template( __FILE__ , 'package_system_item_end.tpl' );
463 }
464 catch( Exception $e )
465 {
466 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
467 }
468 }
469
492 function show_system_tree_rec( $Packages )
493 {
494 try
495 {
496 if( isset( $Packages[ 0 ] ) == false )
497 {
498 return( '' );
499 }
500
501 $Branch = $this->CachedMultyFS->get_template( __FILE__ , 'package_system_start.tpl' );
502
503 foreach( $Packages as $i => $Package )
504 {
505 $Branch = $this->compile_system_tree_branch( $Branch , $Package );
506 }
507
508 return( $Branch.$this->CachedMultyFS->get_template( __FILE__ , 'package_system_end.tpl' ) );
509 }
510 catch( Exception $e )
511 {
512 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
513 }
514 }
515
534 function show_system_tree( $Options )
535 {
536 try
537 {
538 $PackageAlgorithms = get_package( 'core::package_algorithms' , 'last' , __FILE__ );
539 $Packages = $PackageAlgorithms->get_packages_tree();
540
541 $this->Output = $this->CachedMultyFS->get_template( __FILE__ , 'system_start.tpl' );
542
543 foreach( $Packages as $i => $Package )
544 {
545 $this->Output = $this->compile_system_tree_branch( $this->Output , $Package );
546 }
547
548 $this->Output .= $this->CachedMultyFS->get_template( __FILE__ , 'system_end.tpl' );
549 }
550 catch( Exception $e )
551 {
552 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
553 }
554 }
555
578 function view( $Options )
579 {
580 try
581 {
582 $ContextSet = get_package( 'gui::context_set' , 'last' , __FILE__ );
583
584 $ContextSet->add_context( dirname( __FILE__ ).'/conf/cfcx_show_package_tree' );
585 $ContextSet->add_context( dirname( __FILE__ ).'/conf/cfcx_show_system_tree' );
586
587 if( $ContextSet->execute( $Options , $this , __FILE__ ) )
588 {
589 return( $this->Output );
590 }
591 }
592 catch( Exception $e )
593 {
594 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
595 }
596 }
597 }
598
599 ?>