1
+ <?php
2
+ //
3
+ // +----------------------------------------------------------------------+
4
+ // | PHP Version 4 |
5
+ // +----------------------------------------------------------------------+
6
+ // | Copyright (c) 1997-2002 The PHP Group |
7
+ // +----------------------------------------------------------------------+
8
+ // | This source file is subject to version 2.02 of the PHP license, |
9
+ // | that is bundled with this package in the file LICENSE, and is |
10
+ // | available at through the world-wide-web at |
11
+ // | http://www.php.net/license/2_02.txt. |
12
+ // | If you did not receive a copy of the PHP license and are unable to |
13
+ // | obtain it through the world-wide-web, please send a note to |
14
+ // | license@php.net so we can mail you a copy immediately. |
15
+ // +----------------------------------------------------------------------+
16
+ // | Author: Stig Bakken <ssb@fast.no> |
17
+ // +----------------------------------------------------------------------+
18
+ //
19
+ // $Id$
20
+
21
+ require_once "PEAR/Command/Common.php " ;
22
+ require_once "PEAR/Registry.php " ;
23
+
24
+ /**
25
+ * PEAR commands for managing configuration data.
26
+ *
27
+ */
28
+ class PEAR_Command_List extends PEAR_Command_Common
29
+ {
30
+ // {{{ properties
31
+ // }}}
32
+
33
+ // {{{ constructor
34
+
35
+ /**
36
+ * PEAR_Command_Config constructor.
37
+ *
38
+ * @access public
39
+ */
40
+ function PEAR_Command_List (&$ ui , &$ config )
41
+ {
42
+ parent ::PEAR_Command_Common ($ ui , $ config );
43
+ }
44
+
45
+ // }}}
46
+
47
+ // {{{ getCommands()
48
+
49
+ /**
50
+ * Return a list of all the commands defined by this class.
51
+ * @return array list of commands
52
+ * @access public
53
+ */
54
+ function getCommands ()
55
+ {
56
+ return array ('list ' );
57
+ }
58
+
59
+ // }}}
60
+ // {{{ run()
61
+
62
+ function run ($ command , $ params )
63
+ {
64
+ $ reg = new PEAR_Registry (); // XXX Use config here
65
+ $ installed = $ reg ->packageInfo ();
66
+ $ i = $ j = 0 ;
67
+ ob_start ();
68
+ heading ("Installed packages: " );
69
+ foreach ($ installed as $ package ) {
70
+ if ($ i ++ % 20 == 0 ) {
71
+ if ($ j ++ > 0 ) {
72
+ print "\n" ;
73
+ }
74
+ printf ("%-20s %-10s %s \n" ,
75
+ "Package " , "Version " , "State " );
76
+ print str_repeat ("- " , 75 )."\n" ;
77
+ }
78
+ printf ("%-20s %-10s %s \n" , $ package ['package ' ],
79
+ $ package ['version ' ], $ package ['release_state ' ]);
80
+ }
81
+ $ output = ob_get_contents ();
82
+ ob_end_clean ();
83
+ $ lines = explode ("\n" , $ output );
84
+ foreach ($ lines as $ line ) {
85
+ $ this ->ui ->displayLine ($ line );
86
+ }
87
+ }
88
+ }
89
+ ?>
0 commit comments