Mage_Pear_Helpers - Version 1.0.18800

Version Notes

First stable release

Download this release

Release Info

Developer Magento Core Team
Extension Mage_Pear_Helpers
Version 1.0.18800
Comparing to
See all releases


Version 1.0.18800

PEAR/Command/Mage.php ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * base class
5
+ */
6
+ require_once 'PEAR/Command/Common.php';
7
+ require_once 'Archive/Tar.php';
8
+
9
+ class PEAR_Command_Mage extends PEAR_Command_Common
10
+ {
11
+ var $commands = array(
12
+ 'mage-package' => array(
13
+ 'summary' => 'Build Magento Package',
14
+ 'function' => 'doPackage',
15
+ 'shortcut' => 'mp',
16
+ 'options' => array(
17
+ 'targetdir' => array(
18
+ 'shortopt' => 'T',
19
+ 'doc' => 'Target directory for package file.',
20
+ 'arg' => 'TARGETDIR',
21
+ ),
22
+ ),
23
+ 'doc' => '[descfile]
24
+ Creates a Magento specific PEAR package from its description file.
25
+ '
26
+ ),
27
+ );
28
+
29
+ var $pkginfofile;
30
+
31
+ var $roles;
32
+
33
+ var $xml;
34
+
35
+ var $options;
36
+
37
+ var $output;
38
+
39
+ var $files = array();
40
+
41
+ /**
42
+ * PEAR_Command_Package constructor.
43
+ *
44
+ * @access public
45
+ */
46
+ function PEAR_Command_Mage(&$ui, &$config)
47
+ {
48
+ parent::PEAR_Command_Common($ui, $config);
49
+ }
50
+
51
+ function doPackage($command, $options, $params)
52
+ {
53
+ $this->output = '';
54
+ $this->options = $options;
55
+ $this->pkginfofile = isset($params[0]) ? $params[0] : 'package.xml';
56
+
57
+ $this->xml = simplexml_load_file($this->pkginfofile);
58
+
59
+ $result = $this->_collectFiles();
60
+ if ($result instanceof PEAR_Error) {
61
+ return $result;
62
+ }
63
+
64
+ $result = $this->_generateTarFile();
65
+ if ($result instanceof PEAR_Error) {
66
+ return $result;
67
+ }
68
+
69
+ if ($this->output) {
70
+ $this->ui->outputData($this->output, $command);
71
+ }
72
+
73
+ return true;
74
+ }
75
+
76
+ function _collectFiles($node=null, $path='')
77
+ {
78
+ if (is_null($node)) {
79
+ $node = $this->xml->contents->dir;
80
+ }
81
+
82
+ if ($node->getName()=='file') {
83
+ $roles = $this->getRoles();
84
+ $roleDir = $this->config->get($roles[(string)$node['role']]['dir_config']);
85
+ $filePath = $roleDir.$path;
86
+ if (!is_file($filePath)) {
87
+ $result = new PEAR_Error('Could not find file: '.$filePath);
88
+ return $result;
89
+ }
90
+ $this->files[$roleDir][] = $filePath;
91
+ }
92
+ elseif ($children = $node->children()) {
93
+ foreach ($children as $child) {
94
+ $result = $this->_collectFiles($child, $path.DIRECTORY_SEPARATOR.(string)$child['name']);
95
+ if ($result instanceof PEAR_Error) {
96
+ return $result;
97
+ }
98
+ }
99
+ }
100
+ return true;
101
+ }
102
+
103
+ function _generateTarFile($compress=true)
104
+ {
105
+ $pkgver = (string)$this->xml->name.'-'.(string)$this->xml->version->release;
106
+ $targetdir = !empty($this->options['targetdir']) ? $this->options['targetdir'].DIRECTORY_SEPARATOR : '';
107
+ $tarname = $targetdir.$pkgver.($compress ? '.tgz' : '.tar');
108
+
109
+ $tar = new Archive_Tar($tarname, $compress);
110
+ $tar->setErrorHandling(PEAR_ERROR_RETURN);
111
+
112
+ $result = $tar->create(array($this->pkginfofile));
113
+ if (PEAR::isError($result)) {
114
+ return $this->raiseError($result);
115
+ }
116
+
117
+ foreach ($this->files as $roleDir=>$files) {
118
+ $result = $tar->addModify($files, $pkgver, $roleDir);
119
+ }
120
+ if (PEAR::isError($result)) {
121
+ return $this->raiseError($result);
122
+ }
123
+
124
+ $this->output .= 'Successfully created '.$tarname."\n";
125
+
126
+ return true;
127
+ }
128
+
129
+ function getRoles()
130
+ {
131
+ if (!$this->roles) {
132
+ $this->roles = array(
133
+ 'magelocal' => array('name'=>'Magento Local module file', 'dir_config'=>'mage_local_dir'),
134
+ 'magecommunity' => array('name'=>'Magento Community module file', 'dir_config'=>'mage_community_dir'),
135
+ 'magecore' => array('name'=>'Magento Core team module file', 'dir_config'=>'mage_core_dir'),
136
+ 'magedesign' => array('name'=>'Magento User Interface (layouts, templates)', 'dir_config'=>'mage_design_dir'),
137
+ 'mageetc' => array('name'=>'Magento Global Configuration', 'dir_config'=>'mage_etc_dir'),
138
+ 'magelib' => array('name'=>'Magento PHP Library file', 'dir_config'=>'mage_lib_dir'),
139
+ 'magelocale' => array('name'=>'Magento Locale language file', 'dir_config'=>'mage_locale_dir'),
140
+ 'magemedia' => array('name'=>'Magento Media library', 'dir_config'=>'mage_media_dir'),
141
+ 'mageskin' => array('name'=>'Magento Theme Skin (Images, CSS, JS)', 'dir_config'=>'mage_skin_dir'),
142
+ 'mageweb' => array('name'=>'Magento Other web accessible file', 'dir_config'=>'mage_web_dir'),
143
+ 'magetest' => array('name'=>'Magento PHPUnit test', 'dir_config'=>'mage_test_dir'),
144
+ 'mage' => array('name'=>'Magento other', 'dir_config'=>'mage_dir'),
145
+ 'php' => array('dir_config'=>'php_dir'),
146
+ 'data' => array('dir_config'=>'data_dir'),
147
+ 'doc' => array('dir_config'=>'doc_dir'),
148
+ 'test' => array('dir_config'=>'test_dir'),
149
+ 'temp' => array('dir_config'=>'temp_dir'),
150
+ );
151
+ }
152
+
153
+ return $this->roles;
154
+ }
155
+ }
PEAR/Command/Mage.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <commands version="1.0">
2
+ <mage-package>
3
+ <summary>Build Magento Package</summary>
4
+ <function>doPackage</function>
5
+ <shortcut>mp</shortcut>
6
+ <options>
7
+ <targetdir>
8
+ <shortopt>T</shortopt>
9
+ <doc>Target directory for package file.</doc>
10
+ <arg>TARGETDIR</arg>
11
+ </targetdir>
12
+ </options>
13
+ <doc>[descfile]
14
+ Creates a Magento specific PEAR package from its description file.
15
+ </doc>
16
+ </mage-package>
17
+ </commands>
PEAR/Installer/Role/Mage.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Varien
16
+ * @package Varien_Pear
17
+ * @copyright Copyright (c) 2004-2007 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+
22
+ /**
23
+ * @category Varien
24
+ * @package Varien_Object
25
+ */
26
+ class PEAR_Installer_Role_Mage extends PEAR_Installer_Role_Common {}
PEAR/Installer/Role/Mage.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <role version="1.0">
2
+ <releasetypes>php</releasetypes>
3
+ <installable>1</installable>
4
+ <locationconfig>mage_dir</locationconfig>
5
+ <honorsbaseinstall>1</honorsbaseinstall>
6
+ <unusualbaseinstall />
7
+ <phpfile />
8
+ <executable />
9
+ <phpextension />
10
+ <config_vars>
11
+ <mage_dir>
12
+ <type>directory</type>
13
+ <default>.</default>
14
+ <doc>Magento root directory</doc>
15
+ <prompt>Magento root directory</prompt>
16
+ <group>File Locations</group>
17
+ </mage_dir>
18
+ </config_vars>
19
+ </role>
PEAR/Installer/Role/Magecommunity.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Varien
16
+ * @package Varien_Pear
17
+ * @copyright Copyright (c) 2004-2007 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+
22
+ /**
23
+ * @category Varien
24
+ * @package Varien_Object
25
+ */
26
+ class PEAR_Installer_Role_Magecommunity extends PEAR_Installer_Role_Common {}
PEAR/Installer/Role/Magecommunity.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <role version="1.0">
2
+ <releasetypes>php</releasetypes>
3
+ <installable>1</installable>
4
+ <locationconfig>mage_community_dir</locationconfig>
5
+ <honorsbaseinstall>1</honorsbaseinstall>
6
+ <unusualbaseinstall />
7
+ <phpfile>1</phpfile>
8
+ <executable />
9
+ <phpextension />
10
+ <config_vars>
11
+ <mage_community_dir>
12
+ <type>directory</type>
13
+ <default>./app/code/community</default>
14
+ <doc>Magento Community Code pool repository directory</doc>
15
+ <prompt>Magento Community Code pool repository directory</prompt>
16
+ <group>File Locations</group>
17
+ </mage_community_dir>
18
+ </config_vars>
19
+ </role>
PEAR/Installer/Role/Magecore.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Varien
16
+ * @package Varien_Pear
17
+ * @copyright Copyright (c) 2004-2007 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+
22
+ /**
23
+ * @category Varien
24
+ * @package Varien_Object
25
+ */
26
+ class PEAR_Installer_Role_Magecore extends PEAR_Installer_Role_Common {}
PEAR/Installer/Role/Magecore.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <role version="1.0">
2
+ <releasetypes>php</releasetypes>
3
+ <installable>1</installable>
4
+ <locationconfig>mage_core_dir</locationconfig>
5
+ <honorsbaseinstall>1</honorsbaseinstall>
6
+ <unusualbaseinstall />
7
+ <phpfile>1</phpfile>
8
+ <executable />
9
+ <phpextension />
10
+ <config_vars>
11
+ <mage_core_dir>
12
+ <type>directory</type>
13
+ <default>./app/code/core</default>
14
+ <doc>Magento root directory</doc>
15
+ <prompt>Magento root directory</prompt>
16
+ <group>File Locations</group>
17
+ </mage_core_dir>
18
+ </config_vars>
19
+ </role>
PEAR/Installer/Role/Magedesign.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Varien
16
+ * @package Varien_Pear
17
+ * @copyright Copyright (c) 2004-2007 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+
22
+ /**
23
+ * @category Varien
24
+ * @package Varien_Object
25
+ */
26
+ class PEAR_Installer_Role_Magedesign extends PEAR_Installer_Role_Common {}
PEAR/Installer/Role/Magedesign.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <role version="1.0">
2
+ <releasetypes>php</releasetypes>
3
+ <installable>1</installable>
4
+ <locationconfig>mage_design_dir</locationconfig>
5
+ <honorsbaseinstall>1</honorsbaseinstall>
6
+ <unusualbaseinstall />
7
+ <phpfile>1</phpfile>
8
+ <executable />
9
+ <phpextension />
10
+ <config_vars>
11
+ <mage_design_dir>
12
+ <type>directory</type>
13
+ <default>./app/design</default>
14
+ <doc>Magento design packages directory</doc>
15
+ <prompt>Magento design packages directory</prompt>
16
+ <group>File Locations</group>
17
+ </mage_design_dir>
18
+ </config_vars>
19
+ </role>
PEAR/Installer/Role/Mageetc.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Varien
16
+ * @package Varien_Pear
17
+ * @copyright Copyright (c) 2004-2007 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+
22
+ /**
23
+ * @category Varien
24
+ * @package Varien_Object
25
+ */
26
+ class PEAR_Installer_Role_Mageetc extends PEAR_Installer_Role_Common {}
PEAR/Installer/Role/Mageetc.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <role version="1.0">
2
+ <releasetypes>php</releasetypes>
3
+ <installable>1</installable>
4
+ <locationconfig>mage_etc_dir</locationconfig>
5
+ <honorsbaseinstall>1</honorsbaseinstall>
6
+ <unusualbaseinstall />
7
+ <phpfile />
8
+ <executable />
9
+ <phpextension />
10
+ <config_vars>
11
+ <mage_etc_dir>
12
+ <type>directory</type>
13
+ <default>./app/etc</default>
14
+ <doc>Magento global configuration directory</doc>
15
+ <prompt>Magento global configuration directory</prompt>
16
+ <group>File Locations</group>
17
+ </mage_etc_dir>
18
+ </config_vars>
19
+ </role>
PEAR/Installer/Role/Magelib.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Varien
16
+ * @package Varien_Pear
17
+ * @copyright Copyright (c) 2004-2007 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+
22
+ /**
23
+ * @category Varien
24
+ * @package Varien_Object
25
+ */
26
+ class PEAR_Installer_Role_Magelib extends PEAR_Installer_Role_Common {}
PEAR/Installer/Role/Magelib.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <role version="1.0">
2
+ <releasetypes>php</releasetypes>
3
+ <installable>1</installable>
4
+ <locationconfig>mage_lib_dir</locationconfig>
5
+ <honorsbaseinstall>1</honorsbaseinstall>
6
+ <unusualbaseinstall />
7
+ <phpfile>1</phpfile>
8
+ <executable />
9
+ <phpextension />
10
+ <config_vars>
11
+ <mage_lib_dir>
12
+ <type>directory</type>
13
+ <default>./lib</default>
14
+ <doc>Magento libraries directory</doc>
15
+ <prompt>Magento libraries directory</prompt>
16
+ <group>File Locations</group>
17
+ </mage_lib_dir>
18
+ </config_vars>
19
+ </role>
PEAR/Installer/Role/Magelocal.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Varien
16
+ * @package Varien_Pear
17
+ * @copyright Copyright (c) 2004-2007 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+
22
+ /**
23
+ * @category Varien
24
+ * @package Varien_Object
25
+ */
26
+ class PEAR_Installer_Role_Magelocal extends PEAR_Installer_Role_Common {}
PEAR/Installer/Role/Magelocal.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <role version="1.0">
2
+ <releasetypes>php</releasetypes>
3
+ <installable>1</installable>
4
+ <locationconfig>mage_local_dir</locationconfig>
5
+ <honorsbaseinstall>1</honorsbaseinstall>
6
+ <unusualbaseinstall />
7
+ <phpfile>1</phpfile>
8
+ <executable />
9
+ <phpextension />
10
+ <config_vars>
11
+ <mage_local_dir>
12
+ <type>directory</type>
13
+ <default>./app/code/local</default>
14
+ <doc>Magento Local Code pool repository directory</doc>
15
+ <prompt>Magento Local Code pool repository directory</prompt>
16
+ <group>File Locations</group>
17
+ </mage_local_dir>
18
+ </config_vars>
19
+ </role>
PEAR/Installer/Role/Magelocale.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Varien
16
+ * @package Varien_Pear
17
+ * @copyright Copyright (c) 2004-2007 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+
22
+ /**
23
+ * @category Varien
24
+ * @package Varien_Object
25
+ */
26
+ class PEAR_Installer_Role_Magelocale extends PEAR_Installer_Role_Common {}
PEAR/Installer/Role/Magelocale.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <role version="1.0">
2
+ <releasetypes>php</releasetypes>
3
+ <installable>1</installable>
4
+ <locationconfig>mage_locale_dir</locationconfig>
5
+ <honorsbaseinstall>1</honorsbaseinstall>
6
+ <unusualbaseinstall />
7
+ <phpfile>1</phpfile>
8
+ <executable />
9
+ <phpextension />
10
+ <config_vars>
11
+ <mage_locale_dir>
12
+ <type>directory</type>
13
+ <default>./app/locale</default>
14
+ <doc>Magento Locale i18n directory</doc>
15
+ <prompt>Magento Locale i18n directory</prompt>
16
+ <group>File Locations</group>
17
+ </mage_locale_dir>
18
+ </config_vars>
19
+ </role>
PEAR/Installer/Role/Magemedia.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Varien
16
+ * @package Varien_Pear
17
+ * @copyright Copyright (c) 2004-2007 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+
22
+ /**
23
+ * @category Varien
24
+ * @package Varien_Object
25
+ */
26
+ class PEAR_Installer_Role_Magemedia extends PEAR_Installer_Role_Common {}
PEAR/Installer/Role/Magemedia.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <role version="1.0">
2
+ <releasetypes>php</releasetypes>
3
+ <installable>1</installable>
4
+ <locationconfig>mage_media_dir</locationconfig>
5
+ <honorsbaseinstall>1</honorsbaseinstall>
6
+ <unusualbaseinstall />
7
+ <phpfile />
8
+ <executable />
9
+ <phpextension />
10
+ <config_vars>
11
+ <mage_media_dir>
12
+ <type>directory</type>
13
+ <default>./media</default>
14
+ <doc>Magento media directory</doc>
15
+ <prompt>Magento media directory</prompt>
16
+ <group>File Locations</group>
17
+ </mage_media_dir>
18
+ </config_vars>
19
+ </role>
PEAR/Installer/Role/Mageskin.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Varien
16
+ * @package Varien_Pear
17
+ * @copyright Copyright (c) 2004-2007 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+
22
+ /**
23
+ * @category Varien
24
+ * @package Varien_Object
25
+ */
26
+ class PEAR_Installer_Role_Mageskin extends PEAR_Installer_Role_Common {}
PEAR/Installer/Role/Mageskin.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <role version="1.0">
2
+ <releasetypes>php</releasetypes>
3
+ <installable>1</installable>
4
+ <locationconfig>mage_skin_dir</locationconfig>
5
+ <honorsbaseinstall>1</honorsbaseinstall>
6
+ <unusualbaseinstall />
7
+ <phpfile />
8
+ <executable />
9
+ <phpextension />
10
+ <config_vars>
11
+ <mage_skin_dir>
12
+ <type>directory</type>
13
+ <default>./skin</default>
14
+ <doc>Magento CSS/Images/Javascript skin directory</doc>
15
+ <prompt>Magento skin directory</prompt>
16
+ <group>File Locations</group>
17
+ </mage_skin_dir>
18
+ </config_vars>
19
+ </role>
PEAR/Installer/Role/Magetest.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Varien
16
+ * @package Varien_Pear
17
+ * @copyright Copyright (c) 2004-2007 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+
22
+ /**
23
+ * @category Varien
24
+ * @package Varien_Object
25
+ */
26
+ class PEAR_Installer_Role_Magetest extends PEAR_Installer_Role_Common {}
PEAR/Installer/Role/Magetest.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <role version="1.0">
2
+ <releasetypes>php</releasetypes>
3
+ <installable>1</installable>
4
+ <locationconfig>mage_test_dir</locationconfig>
5
+ <honorsbaseinstall>1</honorsbaseinstall>
6
+ <unusualbaseinstall />
7
+ <phpfile>1</phpfile>
8
+ <executable />
9
+ <phpextension />
10
+ <config_vars>
11
+ <mage_test_dir>
12
+ <type>directory</type>
13
+ <default>./tests</default>
14
+ <doc>Magento tests directory</doc>
15
+ <prompt>Magento tests directory</prompt>
16
+ <group>File Locations</group>
17
+ </mage_test_dir>
18
+ </config_vars>
19
+ </role>
PEAR/Installer/Role/Mageweb.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Varien
16
+ * @package Varien_Pear
17
+ * @copyright Copyright (c) 2004-2007 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+
22
+ /**
23
+ * @category Varien
24
+ * @package Varien_Object
25
+ */
26
+ class PEAR_Installer_Role_Mageweb extends PEAR_Installer_Role_Common {}
PEAR/Installer/Role/Mageweb.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <role version="1.0">
2
+ <releasetypes>php</releasetypes>
3
+ <installable>1</installable>
4
+ <locationconfig>mage_web_dir</locationconfig>
5
+ <honorsbaseinstall>1</honorsbaseinstall>
6
+ <unusualbaseinstall />
7
+ <phpfile />
8
+ <executable />
9
+ <phpextension />
10
+ <config_vars>
11
+ <mage_web_dir>
12
+ <type>directory</type>
13
+ <default>.</default>
14
+ <doc>Magento web accessible root directory</doc>
15
+ <prompt>Magento web accessible root directory</prompt>
16
+ <group>File Locations</group>
17
+ </mage_web_dir>
18
+ </config_vars>
19
+ </role>
package.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Mage_Pear_Helpers</name>
4
+ <version>1.0.18800</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Files that needs to be in PEAR library such as roles, tasks and commands</summary>
10
+ <description>Includes:
11
+ ./pear
12
+ ./lib/pear/php/pearmage.php
13
+ ./lib/pear/php/PEAR/Command/Mage*
14
+ ./lib/pear/php/PEAR/Installer/Role//Mage*</description>
15
+ <notes>First stable release</notes>
16
+ <authors><author><name>Moshe Gurvich</name><user>auto-converted</user><email>moshe@varien.com</email></author></authors>
17
+ <date>2008-03-31</date>
18
+ <time>09:30:32</time>
19
+ <contents><target name="mage"><dir name="PEAR"><dir name="Command"><file name="Mage.php" hash="78e50bbd748f18bd2e41d4fcb75bebc4"/><file name="Mage.xml" hash="6be7dfbe25f59bf8ab43d167acea5c1d"/></dir><dir name="Installer"><dir name="Role"><file name="Mage.php" hash="3cd6ca46e3c817e69c93191339fbd1b3"/><file name="Mage.xml" hash="aa0481ad26bd06335bdd2c33e0d05e4c"/><file name="Magecommunity.php" hash="6883659b6769d4f2377e89fd0cc8c567"/><file name="Magecommunity.xml" hash="a4af396f7ce3cf766692a43ad19999e0"/><file name="Magecore.php" hash="6d8294715141bcf0426707bf396fdc9e"/><file name="Magecore.xml" hash="e594dbddd25a2b19d78e344b738f985f"/><file name="Magedesign.php" hash="bb9ad3e0c38a7431e490f297f57a009f"/><file name="Magedesign.xml" hash="1b457a4b589ce60a9369c5b32f26439b"/><file name="Mageetc.php" hash="6c724a468da6a3eef7fc50712f9b72d7"/><file name="Mageetc.xml" hash="d5eb7a8a335131052ae5426cf3c32526"/><file name="Magelib.php" hash="01a2ac0481e6e4cc612257175bebaa8f"/><file name="Magelib.xml" hash="d62e1e596596993582d4459884ded0b0"/><file name="Magelocal.php" hash="83bfcab888941705c5015dec4de3ef8d"/><file name="Magelocal.xml" hash="f6891c4c6701301fd5e6a44079d53c6b"/><file name="Magelocale.php" hash="07c0de4909c44066a532b2e1e0d3e826"/><file name="Magelocale.xml" hash="7b4eac70932914f0c917a7d0ade58aed"/><file name="Magemedia.php" hash="e2d9705fc30062c9256b123dae93047b"/><file name="Magemedia.xml" hash="d13eb312b33a02a8ad5052a21158a58e"/><file name="Mageskin.php" hash="5ba871968ce0aa8c67a211a96211a4e3"/><file name="Mageskin.xml" hash="e7dbd60378b10243ab67be148d782494"/><file name="Magetest.php" hash="206239d35a13c576dcf454c3cee9f852"/><file name="Magetest.xml" hash="9ae0894a07764794022553dccc64e8c2"/><file name="Mageweb.php" hash="5c782192d6f599b6f5a0522b28498187"/><file name="Mageweb.xml" hash="ad84936dd30548ce972c1bbc04c4e944"/></dir></dir></dir><dir name="."><file name="pearmage.php" hash="e6bdff850af0cdcc99e679991efb867e"/></dir></target></contents>
20
+ <compatible/>
21
+ <dependencies><required><package><name>PEAR</name><channel>magento-pear.php.net</channel><min>1.6.2</min><max></max></package></required></dependencies>
22
+ </package>
pearmage.php ADDED
@@ -0,0 +1,446 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //
3
+ // +----------------------------------------------------------------------+
4
+ // | PHP Version 5 |
5
+ // +----------------------------------------------------------------------+
6
+ // | Copyright (c) 1997-2004 The PHP Group |
7
+ // +----------------------------------------------------------------------+
8
+ // | This source file is subject to version 3.0 of the PHP license, |
9
+ // | that is bundled with this package in the file LICENSE, and is |
10
+ // | available through the world-wide-web at the following url: |
11
+ // | http://www.php.net/license/3_0.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
+ // | Authors: Stig Bakken <ssb@php.net> |
17
+ // | Tomas V.V.Cox <cox@idecnet.com> |
18
+ // | |
19
+ // +----------------------------------------------------------------------+
20
+ //
21
+ // $Id: pearcmd.php,v 1.37 2007/01/08 05:14:01 cellog Exp $
22
+
23
+ ob_end_clean();
24
+ if (!defined('PEAR_RUNTYPE')) {
25
+ // this is defined in peclcmd.php as 'pecl'
26
+ define('PEAR_RUNTYPE', 'pear');
27
+ }
28
+ define('PEAR_IGNORE_BACKTRACE', 1);
29
+ /**
30
+ * @nodep Gtk
31
+ */
32
+ #if ('/home/moshe/dev/magento_pear/lib/pear/php' != '@'.'include_path'.'@') {
33
+ # ini_set('include_path', '/home/moshe/dev/magento_pear/lib/pear/php');
34
+ # $raw = false;
35
+ #} else {
36
+ // this is a raw, uninstalled pear, either a cvs checkout, or php distro
37
+ $raw = true;
38
+ #}
39
+ @ini_set('allow_url_fopen', true);
40
+ if (!ini_get('safe_mode')) {
41
+ @set_time_limit(0);
42
+ }
43
+ ob_implicit_flush(true);
44
+ @ini_set('track_errors', true);
45
+ @ini_set('html_errors', false);
46
+ @ini_set('magic_quotes_runtime', false);
47
+ $_PEAR_PHPDIR = '#$%^&*';
48
+ set_error_handler('error_handler');
49
+
50
+ $pear_package_version = "1.6.2";
51
+
52
+ require_once 'PEAR.php';
53
+ require_once 'PEAR/Frontend.php';
54
+ require_once 'PEAR/Config.php';
55
+ require_once 'PEAR/Command.php';
56
+ require_once 'Console/Getopt.php';
57
+
58
+
59
+ PEAR_Command::setFrontendType('CLI');
60
+ $all_commands = PEAR_Command::getCommands();
61
+
62
+ // remove this next part when we stop supporting that crap-ass PHP 4.2
63
+ if (!isset($_SERVER['argv']) && !isset($argv) && !isset($HTTP_SERVER_VARS['argv'])) {
64
+ echo 'ERROR: either use the CLI php executable, or set register_argc_argv=On in php.ini';
65
+ exit(1);
66
+ }
67
+ $argv = Console_Getopt::readPHPArgv();
68
+ // fix CGI sapi oddity - the -- in pear.bat/pear is not removed
69
+ if (php_sapi_name() != 'cli' && isset($argv[1]) && $argv[1] == '--') {
70
+ unset($argv[1]);
71
+ $argv = array_values($argv);
72
+ }
73
+ $progname = PEAR_RUNTYPE;
74
+ if (in_array('getopt2', get_class_methods('Console_Getopt'))) {
75
+ array_shift($argv);
76
+ $options = Console_Getopt::getopt2($argv, "c:C:d:D:Gh?sSqu:vV");
77
+ } else {
78
+ $options = Console_Getopt::getopt($argv, "c:C:d:D:Gh?sSqu:vV");
79
+ }
80
+ if (PEAR::isError($options)) {
81
+ usage($options);
82
+ }
83
+
84
+ $opts = $options[0];
85
+
86
+ $fetype = 'CLI';
87
+ if ($progname == 'gpear' || $progname == 'pear-gtk') {
88
+ $fetype = 'Gtk';
89
+ } else {
90
+ foreach ($opts as $opt) {
91
+ if ($opt[0] == 'G') {
92
+ $fetype = 'Gtk';
93
+ }
94
+ }
95
+ }
96
+ //Check if Gtk and PHP >= 5.1.0
97
+ if ($fetype == 'Gtk' && version_compare(phpversion(), '5.1.0', '>=')) {
98
+ $fetype = 'Gtk2';
99
+ }
100
+
101
+ $pear_user_config = '';
102
+ $pear_system_config = '';
103
+ $store_user_config = false;
104
+ $store_system_config = false;
105
+ $verbose = 1;
106
+
107
+ foreach ($opts as $opt) {
108
+ switch ($opt[0]) {
109
+ case 'c':
110
+ $pear_user_config = $opt[1];
111
+ break;
112
+ case 'C':
113
+ $pear_system_config = $opt[1];
114
+ break;
115
+ }
116
+ }
117
+
118
+ PEAR_Command::setFrontendType($fetype);
119
+ $ui = &PEAR_Command::getFrontendObject();
120
+ $config = &PEAR_Config::singleton($pear_user_config, $pear_system_config);
121
+
122
+ if (PEAR::isError($config)) {
123
+ $_file = '';
124
+ if ($pear_user_config !== false) {
125
+ $_file .= $pear_user_config;
126
+ }
127
+ if ($pear_system_config !== false) {
128
+ $_file .= '/' . $pear_system_config;
129
+ }
130
+ if ($_file == '/') {
131
+ $_file = 'The default config file';
132
+ }
133
+ $config->getMessage();
134
+ $ui->outputData("ERROR: $_file is not a valid config file or is corrupted.");
135
+ // We stop, we have no idea where we are :)
136
+ exit(1);
137
+ }
138
+
139
+ // this is used in the error handler to retrieve a relative path
140
+ $_PEAR_PHPDIR = $config->get('php_dir');
141
+ $ui->setConfig($config);
142
+ PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ui, "displayFatalError"));
143
+ if (ini_get('safe_mode')) {
144
+ $ui->outputData('WARNING: running in safe mode requires that all files created ' .
145
+ 'be the same uid as the current script. PHP reports this script is uid: ' .
146
+ @getmyuid() . ', and current user is: ' . @get_current_user());
147
+ }
148
+
149
+ $verbose = $config->get("verbose");
150
+ $cmdopts = array();
151
+
152
+ if ($raw) {
153
+ if (!$config->isDefinedLayer('user') && !$config->isDefinedLayer('system')) {
154
+ $found = false;
155
+ foreach ($opts as $opt) {
156
+ if ($opt[0] == 'd' || $opt[0] == 'D') {
157
+ $found = true; // the user knows what they are doing, and are setting config values
158
+ }
159
+ }
160
+ if (!$found) {
161
+ // no prior runs, try to install PEAR
162
+ if (strpos(dirname(__FILE__), 'scripts')) {
163
+ $packagexml = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'package2.xml';
164
+ $pearbase = dirname(dirname(__FILE__));
165
+ } else {
166
+ $packagexml = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'package2.xml';
167
+ $pearbase = dirname(__FILE__);
168
+ }
169
+ if (file_exists($packagexml)) {
170
+ $options[1] = array(
171
+ 'install',
172
+ $packagexml
173
+ );
174
+ $config->set('php_dir', $pearbase . DIRECTORY_SEPARATOR . 'php');
175
+ $config->set('data_dir', $pearbase . DIRECTORY_SEPARATOR . 'data');
176
+ $config->set('doc_dir', $pearbase . DIRECTORY_SEPARATOR . 'docs');
177
+ $config->set('test_dir', $pearbase . DIRECTORY_SEPARATOR . 'tests');
178
+ $config->set('ext_dir', $pearbase . DIRECTORY_SEPARATOR . 'extensions');
179
+ $config->set('bin_dir', $pearbase);
180
+ $config->mergeConfigFile($pearbase . 'pear.ini', false);
181
+ $config->store();
182
+ $config->set('auto_discover', 1);
183
+ }
184
+ }
185
+ }
186
+ }
187
+ foreach ($opts as $opt) {
188
+ $param = !empty($opt[1]) ? $opt[1] : true;
189
+ switch ($opt[0]) {
190
+ case 'd':
191
+ if ($param === true) {
192
+ die('Invalid usage of "-d" option, expected -d config_value=value, ' .
193
+ 'received "-d"' . "\n");
194
+ }
195
+ $possible = explode('=', $param);
196
+ if (count($possible) != 2) {
197
+ die('Invalid usage of "-d" option, expected -d config_value=value, received "' .
198
+ $param . '"' . "\n");
199
+ }
200
+ list($key, $value) = explode('=', $param);
201
+ $config->set($key, $value, 'user');
202
+ break;
203
+ case 'D':
204
+ if ($param === true) {
205
+ die('Invalid usage of "-d" option, expected -d config_value=value, ' .
206
+ 'received "-d"' . "\n");
207
+ }
208
+ $possible = explode('=', $param);
209
+ if (count($possible) != 2) {
210
+ die('Invalid usage of "-d" option, expected -d config_value=value, received "' .
211
+ $param . '"' . "\n");
212
+ }
213
+ list($key, $value) = explode('=', $param);
214
+ $config->set($key, $value, 'system');
215
+ break;
216
+ case 's':
217
+ $store_user_config = true;
218
+ break;
219
+ case 'S':
220
+ $store_system_config = true;
221
+ break;
222
+ case 'u':
223
+ $config->remove($param, 'user');
224
+ break;
225
+ case 'v':
226
+ $config->set('verbose', $config->get('verbose') + 1);
227
+ break;
228
+ case 'q':
229
+ $config->set('verbose', $config->get('verbose') - 1);
230
+ break;
231
+ case 'V':
232
+ usage(null, 'version');
233
+ case 'c':
234
+ case 'C':
235
+ break;
236
+ default:
237
+ // all non pear params goes to the command
238
+ $cmdopts[$opt[0]] = $param;
239
+ break;
240
+ }
241
+ }
242
+
243
+ if ($store_system_config) {
244
+ $config->store('system');
245
+ }
246
+
247
+ if ($store_user_config) {
248
+ $config->store('user');
249
+ }
250
+
251
+ $command = (isset($options[1][0])) ? $options[1][0] : null;
252
+
253
+ if (empty($command) && ($store_user_config || $store_system_config)) {
254
+ exit;
255
+ }
256
+
257
+ if ($fetype == 'Gtk' || $fetype == 'Gtk2') {
258
+ if (!$config->validConfiguration()) {
259
+ PEAR::raiseError('CRITICAL ERROR: no existing valid configuration files found in files ' .
260
+ "'$pear_user_config' or '$pear_system_config', please copy an existing configuration" .
261
+ 'file to one of these locations, or use the -c and -s options to create one');
262
+ }
263
+ Gtk::main();
264
+ } else do {
265
+ if ($command == 'help') {
266
+ usage(null, @$options[1][1]);
267
+ }
268
+ if (!$config->validConfiguration()) {
269
+ PEAR::raiseError('CRITICAL ERROR: no existing valid configuration files found in files ' .
270
+ "'$pear_user_config' or '$pear_system_config', please copy an existing configuration" .
271
+ 'file to one of these locations, or use the -c and -s options to create one');
272
+ }
273
+
274
+ PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
275
+ $cmd = PEAR_Command::factory($command, $config);
276
+ PEAR::popErrorHandling();
277
+ if (PEAR::isError($cmd)) {
278
+ usage(null, @$options[1][0]);
279
+ }
280
+
281
+ $short_args = $long_args = null;
282
+ PEAR_Command::getGetoptArgs($command, $short_args, $long_args);
283
+ if (in_array('getopt2', get_class_methods('Console_Getopt'))) {
284
+ array_shift($options[1]);
285
+ $tmp = Console_Getopt::getopt2($options[1], $short_args, $long_args);
286
+ } else {
287
+ $tmp = Console_Getopt::getopt($options[1], $short_args, $long_args);
288
+ }
289
+ if (PEAR::isError($tmp)) {
290
+ break;
291
+ }
292
+ list($tmpopt, $params) = $tmp;
293
+ $opts = array();
294
+ foreach ($tmpopt as $foo => $tmp2) {
295
+ list($opt, $value) = $tmp2;
296
+ if ($value === null) {
297
+ $value = true; // options without args
298
+ }
299
+ if (strlen($opt) == 1) {
300
+ $cmdoptions = $cmd->getOptions($command);
301
+ foreach ($cmdoptions as $o => $d) {
302
+ if (@$d['shortopt'] == $opt) {
303
+ $opts[$o] = $value;
304
+ }
305
+ }
306
+ } else {
307
+ if (substr($opt, 0, 2) == '--') {
308
+ $opts[substr($opt, 2)] = $value;
309
+ }
310
+ }
311
+ }
312
+ $ok = $cmd->run($command, $opts, $params);
313
+ if ($ok === false) {
314
+ PEAR::raiseError("unknown command `$command'");
315
+ }
316
+ if (PEAR::isError($ok)) {
317
+ PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ui, "displayFatalError"));
318
+ PEAR::raiseError($ok);
319
+ }
320
+ } while (false);
321
+
322
+ // {{{ usage()
323
+
324
+ function usage($error = null, $helpsubject = null)
325
+ {
326
+ global $progname, $all_commands;
327
+ $stderr = fopen('php://stderr', 'w');
328
+ if (PEAR::isError($error)) {
329
+ fputs($stderr, $error->getMessage() . "\n");
330
+ } elseif ($error !== null) {
331
+ fputs($stderr, "$error\n");
332
+ }
333
+ if ($helpsubject != null) {
334
+ $put = cmdHelp($helpsubject);
335
+ } else {
336
+ $put =
337
+ "Commands:\n";
338
+ $maxlen = max(array_map("strlen", $all_commands));
339
+ $formatstr = "%-{$maxlen}s %s\n";
340
+ ksort($all_commands);
341
+ foreach ($all_commands as $cmd => $class) {
342
+ $put .= sprintf($formatstr, $cmd, PEAR_Command::getDescription($cmd));
343
+ }
344
+ $put .=
345
+ "Usage: $progname [options] command [command-options] <parameters>\n".
346
+ "Type \"$progname help options\" to list all options.\n".
347
+ "Type \"$progname help shortcuts\" to list all command shortcuts.\n".
348
+ "Type \"$progname help <command>\" to get the help for the specified command.";
349
+ }
350
+ fputs($stderr, "$put\n");
351
+ fclose($stderr);
352
+ exit(1);
353
+ }
354
+
355
+ function cmdHelp($command)
356
+ {
357
+ global $progname, $all_commands, $config;
358
+ if ($command == "options") {
359
+ return
360
+ "Options:\n".
361
+ " -v increase verbosity level (default 1)\n".
362
+ " -q be quiet, decrease verbosity level\n".
363
+ " -c file find user configuration in `file'\n".
364
+ " -C file find system configuration in `file'\n".
365
+ " -d foo=bar set user config variable `foo' to `bar'\n".
366
+ " -D foo=bar set system config variable `foo' to `bar'\n".
367
+ " -G start in graphical (Gtk) mode\n".
368
+ " -s store user configuration\n".
369
+ " -S store system configuration\n".
370
+ " -u foo unset `foo' in the user configuration\n".
371
+ " -h, -? display help/usage (this message)\n".
372
+ " -V version information\n";
373
+ } elseif ($command == "shortcuts") {
374
+ $sc = PEAR_Command::getShortcuts();
375
+ $ret = "Shortcuts:\n";
376
+ foreach ($sc as $s => $c) {
377
+ $ret .= sprintf(" %-8s %s\n", $s, $c);
378
+ }
379
+ return $ret;
380
+
381
+ } elseif ($command == "version") {
382
+ return "PEAR Version: ".$GLOBALS['pear_package_version'].
383
+ "\nPHP Version: ".phpversion().
384
+ "\nZend Engine Version: ".zend_version().
385
+ "\nRunning on: ".php_uname();
386
+
387
+ } elseif ($help = PEAR_Command::getHelp($command)) {
388
+ if (is_string($help)) {
389
+ return "$progname $command [options] $help\n";
390
+ }
391
+ if ($help[1] === null) {
392
+ return "$progname $command $help[0]";
393
+ } else {
394
+ return "$progname $command [options] $help[0]\n$help[1]";
395
+ }
396
+ }
397
+ return "Command '$command' is not valid, try 'pear help'";
398
+ }
399
+
400
+ // }}}
401
+
402
+ function error_handler($errno, $errmsg, $file, $line, $vars) {
403
+ if ((defined('E_STRICT') && $errno & E_STRICT) || !error_reporting()) {
404
+ if (defined('E_STRICT') && $errno & E_STRICT) {
405
+ return; // E_STRICT
406
+ }
407
+ if ($GLOBALS['config']->get('verbose') < 4) {
408
+ return false; // @silenced error, show all if debug is high enough
409
+ }
410
+ }
411
+ $errortype = array (
412
+ E_ERROR => "Error",
413
+ E_WARNING => "Warning",
414
+ E_PARSE => "Parsing Error",
415
+ E_NOTICE => "Notice",
416
+ E_CORE_ERROR => "Core Error",
417
+ E_CORE_WARNING => "Core Warning",
418
+ E_COMPILE_ERROR => "Compile Error",
419
+ E_COMPILE_WARNING => "Compile Warning",
420
+ E_USER_ERROR => "User Error",
421
+ E_USER_WARNING => "User Warning",
422
+ E_USER_NOTICE => "User Notice"
423
+ );
424
+ $prefix = $errortype[$errno];
425
+ global $_PEAR_PHPDIR;
426
+ if (stristr($file, $_PEAR_PHPDIR)) {
427
+ $file = substr($file, strlen($_PEAR_PHPDIR) + 1);
428
+ } else {
429
+ $file = basename($file);
430
+ }
431
+ print "\n$prefix: $errmsg in $file on line $line\n";
432
+ return false;
433
+ }
434
+
435
+
436
+ /*
437
+ * Local variables:
438
+ * tab-width: 4
439
+ * c-basic-offset: 4
440
+ * indent-tabs-mode: nil
441
+ * mode: php
442
+ * End:
443
+ */
444
+ // vim600:syn=php
445
+
446
+ ?>