Lib_Mage - Version 1.6.0.0

Version Notes

1.6.0.0

Download this release

Release Info

Developer Magento Core Team
Extension Lib_Mage
Version 1.6.0.0
Comparing to
See all releases


Version 1.6.0.0

Files changed (64) hide show
  1. lib/Mage/Archive.php +222 -0
  2. lib/Mage/Archive/Abstract.php +84 -0
  3. lib/Mage/Archive/Bz.php +79 -0
  4. lib/Mage/Archive/Gz.php +77 -0
  5. lib/Mage/Archive/Interface.php +53 -0
  6. lib/Mage/Archive/Tar.php +372 -0
  7. lib/Mage/Autoload/Simple.php +52 -0
  8. lib/Mage/Connect/Channel/Generator.php +63 -0
  9. lib/Mage/Connect/Channel/Parser.php +25 -0
  10. lib/Mage/Connect/Channel/VO.php +113 -0
  11. lib/Mage/Connect/Command.php +390 -0
  12. lib/Mage/Connect/Command/Channels.php +189 -0
  13. lib/Mage/Connect/Command/Channels_Header.php +105 -0
  14. lib/Mage/Connect/Command/Config.php +211 -0
  15. lib/Mage/Connect/Command/Config_Header.php +100 -0
  16. lib/Mage/Connect/Command/Install.php +448 -0
  17. lib/Mage/Connect/Command/Install_Header.php +237 -0
  18. lib/Mage/Connect/Command/Package.php +134 -0
  19. lib/Mage/Connect/Command/Package_Header.php +67 -0
  20. lib/Mage/Connect/Command/Registry.php +175 -0
  21. lib/Mage/Connect/Command/Registry_Header.php +68 -0
  22. lib/Mage/Connect/Command/Remote.php +226 -0
  23. lib/Mage/Connect/Command/Remote_Header.php +88 -0
  24. lib/Mage/Connect/Config.php +265 -0
  25. lib/Mage/Connect/Converter.php +337 -0
  26. lib/Mage/Connect/Frontend.php +251 -0
  27. lib/Mage/Connect/Frontend/CLI.php +441 -0
  28. lib/Mage/Connect/Ftp.php +494 -0
  29. lib/Mage/Connect/Loader.php +51 -0
  30. lib/Mage/Connect/Loader/Ftp.php +121 -0
  31. lib/Mage/Connect/Package.php +1486 -0
  32. lib/Mage/Connect/Package/Extension.php +1 -0
  33. lib/Mage/Connect/Package/Hotfix.php +137 -0
  34. lib/Mage/Connect/Package/Maintainer.php +0 -0
  35. lib/Mage/Connect/Package/Reader.php +150 -0
  36. lib/Mage/Connect/Package/Target.php +126 -0
  37. lib/Mage/Connect/Package/VO.php +96 -0
  38. lib/Mage/Connect/Package/Writer.php +209 -0
  39. lib/Mage/Connect/Packager.php +662 -0
  40. lib/Mage/Connect/Repository.php +0 -0
  41. lib/Mage/Connect/Repository/Abstract.php +0 -0
  42. lib/Mage/Connect/Repository/Channel.php +0 -0
  43. lib/Mage/Connect/Repository/Channel/Abstract.php +0 -0
  44. lib/Mage/Connect/Repository/Channel/Commercial.php +0 -0
  45. lib/Mage/Connect/Repository/Channel/Community.php +0 -0
  46. lib/Mage/Connect/Repository/Channel/Core.php +0 -0
  47. lib/Mage/Connect/Repository/Local.php +0 -0
  48. lib/Mage/Connect/Rest.php +364 -0
  49. lib/Mage/Connect/Singleconfig.php +865 -0
  50. lib/Mage/Connect/Structures/Graph.php +248 -0
  51. lib/Mage/Connect/Structures/Node.php +257 -0
  52. lib/Mage/Connect/Validator.php +417 -0
  53. lib/Mage/DB/Exception.php +36 -0
  54. lib/Mage/DB/Mysqli.php +532 -0
  55. lib/Mage/Exception.php +35 -0
  56. lib/Mage/HTTP/Client.php +84 -0
  57. lib/Mage/HTTP/Client/Curl.php +499 -0
  58. lib/Mage/HTTP/Client/Socket.php +537 -0
  59. lib/Mage/HTTP/IClient.php +145 -0
  60. lib/Mage/System/Args.php +102 -0
  61. lib/Mage/System/Dirs.php +82 -0
  62. lib/Mage/Xml/Generator.php +90 -0
  63. lib/Mage/Xml/Parser.php +91 -0
  64. package.xml +18 -0
lib/Mage/Archive.php ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Archive
23
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Class to work with archives
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Archive
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Archive
35
+ {
36
+
37
+ /**
38
+ * Archiver is used for compress.
39
+ */
40
+ const DEFAULT_ARCHIVER = 'gz';
41
+
42
+ /**
43
+ * Default packer for directory.
44
+ */
45
+ const TAPE_ARCHIVER = 'tar';
46
+
47
+ /**
48
+ * Current archiver is used for compress.
49
+ *
50
+ * @var Mage_Archiver_Tar|Mage_Archiver_Gz|Mage_Archiver_Bz
51
+ */
52
+ protected $_archiver=null;
53
+
54
+ /**
55
+ * Accessible formats for compress.
56
+ *
57
+ * @var array
58
+ */
59
+ protected $_formats = array(
60
+ 'tar' => 'tar',
61
+ 'gz' => 'gz',
62
+ 'gzip' => 'gz',
63
+ 'tgz' => 'tar.gz',
64
+ 'tgzip' => 'tar.gz',
65
+ 'bz' => 'bz',
66
+ 'bzip' => 'bz',
67
+ 'bzip2' => 'bz',
68
+ 'bz2' => 'bz',
69
+ 'tbz' => 'tar.bz',
70
+ 'tbzip' => 'tar.bz',
71
+ 'tbz2' => 'tar.bz',
72
+ 'tbzip2' => 'tar.bz');
73
+
74
+ /**
75
+ * Create object of current archiver by $extension.
76
+ *
77
+ * @param string $extension
78
+ * @return Mage_Archiver_Tar|Mage_Archiver_Gz|Mage_Archiver_Bz
79
+ */
80
+ protected function _getArchiver($extension)
81
+ {
82
+ if(array_key_exists(strtolower($extension), $this->_formats)) {
83
+ $format = $this->_formats[$extension];
84
+ } else {
85
+ $format = self::DEFAULT_ARCHIVER;
86
+ }
87
+ $class = 'Mage_Archive_'.ucfirst($format);
88
+ $this->_archiver = new $class();
89
+ return $this->_archiver;
90
+ }
91
+
92
+ /**
93
+ * Split current format to list of archivers.
94
+ *
95
+ * @param string $source
96
+ * @return array
97
+ */
98
+ protected function _getArchivers($source)
99
+ {
100
+ $ext = pathinfo($source, PATHINFO_EXTENSION);
101
+ if(!isset($this->_formats[$ext])) {
102
+ return array();
103
+ }
104
+ $format = $this->_formats[$ext];
105
+ if ($format) {
106
+ $archivers = explode('.', $format);
107
+ return $archivers;
108
+ }
109
+ return array();
110
+ }
111
+
112
+ /**
113
+ * Pack file or directory to archivers are parsed from extension.
114
+ *
115
+ * @param string $source
116
+ * @param string $destination
117
+ * @param boolean $skipRoot skip first level parent
118
+ * @return string Path to file
119
+ */
120
+ public function pack($source, $destination='packed.tgz', $skipRoot=false)
121
+ {
122
+ $archivers = $this->_getArchivers($destination);
123
+ $interimSource = '';
124
+ for ($i=0; $i<count($archivers); $i++ ) {
125
+ if ($i == (count($archivers) - 1)) {
126
+ $packed = $destination;
127
+ } else {
128
+ $packed = dirname($destination) . DS . '~tmp-'. microtime(true) . $archivers[$i] . '.' . $archivers[$i];
129
+ }
130
+ $source = $this->_getArchiver($archivers[$i])->pack($source, $packed, $skipRoot);
131
+ if ($interimSource && $i < count($archivers)) {
132
+ unlink($interimSource);
133
+ }
134
+ $interimSource = $source;
135
+ }
136
+ return $source;
137
+ }
138
+
139
+ /**
140
+ * Unpack file from archivers are parsed from extension.
141
+ * If $tillTar == true unpack file from archivers till
142
+ * meet TAR archiver.
143
+ *
144
+ * @param string $source
145
+ * @param string $destination
146
+ * @param boolean $tillTar
147
+ * @return string Path to file
148
+ */
149
+ public function unpack($source, $destination='.', $tillTar=false, $clearInterm = true)
150
+ {
151
+ $archivers = $this->_getArchivers($source);
152
+ $interimSource = '';
153
+ for ($i=count($archivers)-1; $i>=0; $i--) {
154
+ if ($tillTar && $archivers[$i] == self::TAPE_ARCHIVER) {
155
+ break;
156
+ }
157
+ if ($i == 0) {
158
+ $packed = rtrim($destination, DS) . DS;
159
+ } else {
160
+ $packed = rtrim($destination, DS) . DS . '~tmp-'. microtime(true) . $archivers[$i-1] . '.' . $archivers[$i-1];
161
+ }
162
+ $source = $this->_getArchiver($archivers[$i])->unpack($source, $packed);
163
+
164
+ //var_dump($packed, $source);
165
+
166
+ if ($clearInterm && $interimSource && $i >= 0) {
167
+ unlink($interimSource);
168
+ }
169
+ $interimSource = $source;
170
+ }
171
+ return $source;
172
+ }
173
+
174
+ /**
175
+ * Extract one file from TAR (Tape Archiver).
176
+ *
177
+ * @param string $file
178
+ * @param string $source
179
+ * @param string $destination
180
+ * @return string Path to file
181
+ */
182
+ public function extract($file, $source, $destination='.')
183
+ {
184
+ $tarFile = $this->unpack($source, $destination, true);
185
+ $resFile = $this->_getArchiver(self::TAPE_ARCHIVER)->extract($file, $tarFile, $destination);
186
+ if (!$this->isTar($source)) {
187
+ unlink($tarFile);
188
+ }
189
+ return $resFile;
190
+ }
191
+
192
+ /**
193
+ * Check file is archive.
194
+ *
195
+ * @param string $file
196
+ * @return boolean
197
+ */
198
+ public function isArchive($file)
199
+ {
200
+ $archivers = $this->_getArchivers($file);
201
+ if (count($archivers)) {
202
+ return true;
203
+ }
204
+ return false;
205
+ }
206
+
207
+ /**
208
+ * Check file is TAR.
209
+ *
210
+ * @param mixed $file
211
+ * @return boolean
212
+ */
213
+ public function isTar($file)
214
+ {
215
+ $archivers = $this->_getArchivers($file);
216
+ if (count($archivers)==1 && $archivers[0] == self::TAPE_ARCHIVER) {
217
+ return true;
218
+ }
219
+ return false;
220
+ }
221
+
222
+ }
lib/Mage/Archive/Abstract.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Archive
23
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Class to work with archives
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Archive
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Archive_Abstract
35
+ {
36
+ /**
37
+ * Write data to file. If file can't be opened,
38
+ *
39
+ * @param string $destination
40
+ * @param string $data
41
+ * @return boolean
42
+ */
43
+ protected function _writeFile($destination, $data)
44
+ {
45
+ if(false === file_put_contents($destination, $data)) {
46
+ throw new Mage_Exception("Can't write to file: " . $destination);
47
+ }
48
+ return true;
49
+ }
50
+
51
+ /**
52
+ * Read data from file. If file can't be opened, throw to exception.
53
+ *
54
+ * @param string $source
55
+ * @return string
56
+ */
57
+ protected function _readFile($source)
58
+ {
59
+ $data = '';
60
+ if (is_file($source) && is_readable($source)) {
61
+ $data = @file_get_contents($source);
62
+ if ($data === false) {
63
+ throw new Mage_Exception("Can't get contents from: " . $source);
64
+ }
65
+ }
66
+ return $data;
67
+ }
68
+
69
+ /**
70
+ * Get file name from source (URI) without last extension.
71
+ *
72
+ * @param string $source
73
+ * @return string
74
+ */
75
+ public function getFilename($source, $withExtension=false)
76
+ {
77
+ $file = str_replace(dirname($source) . DS, '', $source);
78
+ if (!$withExtension) {
79
+ $file = substr($file, 0, strrpos($file, '.'));
80
+ }
81
+ return $file;
82
+ }
83
+
84
+ }
lib/Mage/Archive/Bz.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Archive
23
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Class to work with bzip2 archives
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Archive
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Archive_Bz extends Mage_Archive_Abstract implements Mage_Archive_Interface
35
+ {
36
+
37
+ /**
38
+ * Pack file by BZIP2 compressor.
39
+ *
40
+ * @param string $source
41
+ * @param string $destination
42
+ * @return string
43
+ */
44
+ public function pack($source, $destination)
45
+ {
46
+ $data = $this->_readFile($source);
47
+ $bzData = bzcompress($data, 9);
48
+ $this->_writeFile($destination, $bzData);
49
+ return $destination;
50
+ }
51
+
52
+ /**
53
+ * Unpack file by BZIP2 compressor.
54
+ *
55
+ * @param string $source
56
+ * @param string $destination
57
+ * @return string
58
+ */
59
+ public function unpack($source, $destination)
60
+ {
61
+ $data = '';
62
+ $bzPointer = bzopen($source, 'r' );
63
+ if (empty($bzPointer)) {
64
+ throw new Exception('Can\'t open BZ archive : ' . $source);
65
+ }
66
+ while (!feof($bzPointer)) {
67
+ $data .= bzread($bzPointer, 131072);
68
+ }
69
+ bzclose($bzPointer);
70
+ if (is_dir($destination)) {
71
+ $file = $this->getFilename($source);
72
+ $destination = $destination . $file;
73
+ }
74
+ echo $destination;
75
+ $this->_writeFile($destination, $data);
76
+ return $destination;
77
+ }
78
+
79
+ }
lib/Mage/Archive/Gz.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Archive
23
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Class to work with gz archives
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Archive
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Archive_Gz extends Mage_Archive_Abstract implements Mage_Archive_Interface
35
+ {
36
+ /**
37
+ * Pack file by GZ compressor.
38
+ *
39
+ * @param string $source
40
+ * @param string $destination
41
+ * @return string
42
+ */
43
+ public function pack($source, $destination)
44
+ {
45
+ $data = $this->_readFile($source);
46
+ $gzData = gzencode($data, 9);
47
+ $this->_writeFile($destination, $gzData);
48
+ return $destination;
49
+ }
50
+
51
+ /**
52
+ * Unpack file by GZ compressor.
53
+ *
54
+ * @param string $source
55
+ * @param string $destination
56
+ * @return string
57
+ */
58
+ public function unpack($source, $destination)
59
+ {
60
+ $gzPointer = gzopen($source, 'r' );
61
+ if (empty($gzPointer)) {
62
+ throw new Mage_Exception('Can\'t open GZ archive : ' . $source);
63
+ }
64
+ $data = '';
65
+ while (!gzeof($gzPointer)) {
66
+ $data .= gzread($gzPointer, 131072);
67
+ }
68
+ gzclose($gzPointer);
69
+ if (is_dir($destination)) {
70
+ $file = $this->getFilename($source);
71
+ $destination = $destination . $file;
72
+ }
73
+ $this->_writeFile($destination, $data);
74
+ return $destination;
75
+ }
76
+
77
+ }
lib/Mage/Archive/Interface.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Archive
23
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Interface for work with archives
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Archive
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ interface Mage_Archive_Interface
35
+ {
36
+ /**
37
+ * Pack file or directory.
38
+ *
39
+ * @param string $source
40
+ * @param string $destination
41
+ * @return string
42
+ */
43
+ public function pack($source, $destination);
44
+
45
+ /**
46
+ * Unpack file or directory.
47
+ *
48
+ * @param string $source
49
+ * @param string $destination
50
+ * @return string
51
+ */
52
+ public function unpack($source, $destination);
53
+ }
lib/Mage/Archive/Tar.php ADDED
@@ -0,0 +1,372 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Archive
23
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Class to work with tar archives
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Archive
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Mage_Archive_Tar extends Mage_Archive_Abstract implements Mage_Archive_Interface
35
+ {
36
+ /**
37
+ * Constant is used for parse tar's header.
38
+ */
39
+ const FORMAT_PARSE_HEADER = 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor/a155prefix/a12closer';
40
+
41
+ /**
42
+ * Keep file or directory for packing.
43
+ *
44
+ * @var string
45
+ */
46
+ protected $_currentFile;
47
+
48
+ /**
49
+ * Keep path to file or directory for packing.
50
+ *
51
+ * @var mixed
52
+ */
53
+ protected $_currentPath;
54
+
55
+ /**
56
+ * Skip first level parent directory. Example:
57
+ * use test/fip.php instead test/test/fip.php;
58
+ *
59
+ * @var mixed
60
+ */
61
+ protected $_skipRoot;
62
+
63
+ /**
64
+ * Set option that define ability skip first catalog level.
65
+ *
66
+ * @param mixed $skipRoot
67
+ * @return Mage_Archive_Tar
68
+ */
69
+ protected function _setSkipRoot($skipRoot)
70
+ {
71
+ $this->_skipRoot = $skipRoot;
72
+ return $this;
73
+ }
74
+
75
+ /**
76
+ * Set file which is packing.
77
+ *
78
+ * @param string $file
79
+ * @return Mage_Archive_Tar
80
+ */
81
+ protected function _setCurrentFile($file)
82
+ {
83
+ $this->_currentFile = $file .((is_dir($file) && substr($file, -1)!=DS)?DS:'');
84
+ return $this;
85
+ }
86
+
87
+ /**
88
+ * Retrieve file which is packing.
89
+ *
90
+ * @return string
91
+ */
92
+ protected function _getCurrentFile()
93
+ {
94
+ return $this->_currentFile;
95
+ }
96
+
97
+ /**
98
+ * Set path to file which is packing.
99
+ *
100
+ * @param string $path
101
+ * @return Mage_Archive_Tar
102
+ */
103
+ protected function _setCurrentPath($path)
104
+ {
105
+ if ($this->_skipRoot && is_dir($path)) {
106
+ $this->_currentPath = $path.(substr($path, -1)!=DS?DS:'');
107
+ } else {
108
+ $this->_currentPath = dirname($path) . DS;
109
+ }
110
+ return $this;
111
+ }
112
+
113
+ /**
114
+ * Retrieve path to file which is packing.
115
+ *
116
+ * @return string
117
+ */
118
+ protected function _getCurrentPath()
119
+ {
120
+ return $this->_currentPath;
121
+ }
122
+
123
+ /**
124
+ * Walk through directory and add to tar file or directory.
125
+ * Result is packed string on TAR format.
126
+ *
127
+ * @param boolean $skipRoot
128
+ * @return string
129
+ */
130
+ protected function _packToTar($skipRoot=false)
131
+ {
132
+ $file = $this->_getCurrentFile();
133
+ $header = '';
134
+ $data = '';
135
+ if (!$skipRoot) {
136
+ $header = $this->_composeHeader();
137
+ $data = $this->_readFile($file);
138
+ $data = str_pad($data, floor(((is_dir($file) ? 0 : filesize($file)) + 512 - 1) / 512) * 512, "\0");
139
+ }
140
+ $sub = '';
141
+ if (is_dir($file)) {
142
+ $treeDir = scandir($file);
143
+ if (empty($treeDir)) {
144
+ throw new Mage_Exception('Can\'t scan dir: ' . $file);
145
+ }
146
+ array_shift($treeDir); /* remove './'*/
147
+ array_shift($treeDir); /* remove '../'*/
148
+ foreach ($treeDir as $item) {
149
+ $sub .= $this->_setCurrentFile($file.$item)->_packToTar(false);
150
+ }
151
+ }
152
+ $tarData = $header . $data . $sub;
153
+ $tarData = str_pad($tarData, floor((strlen($tarData) - 1) / 1536) * 1536, "\0");
154
+ return $tarData;
155
+ }
156
+
157
+ /**
158
+ * Compose header for current file in TAR format.
159
+ * If length of file's name greater 100 characters,
160
+ * method breaks header to two pieces. First conatins
161
+ * header and data with long name. Second contain only header.
162
+ *
163
+ * @param boolean $long
164
+ * @return string
165
+ */
166
+ protected function _composeHeader($long = false)
167
+ {
168
+ $file = $this->_getCurrentFile();
169
+ $path = $this->_getCurrentPath();
170
+ $infoFile = stat($file);
171
+ $nameFile = str_replace($path, '', $file);
172
+ $nameFile = str_replace('\\', '/', $nameFile);
173
+ $packedHeader = '';
174
+ $longHeader = '';
175
+ if (!$long && strlen($nameFile)>100) {
176
+ $longHeader = $this->_composeHeader(true);
177
+ $longHeader .= str_pad($nameFile, floor((strlen($nameFile) + 512 - 1) / 512) * 512, "\0");
178
+ }
179
+ $header = array();
180
+ $header['100-name'] = $long?'././@LongLink':substr($nameFile, 0, 100);
181
+ $header['8-mode'] = $long?' ':str_pad(substr(sprintf("%07o", $infoFile['mode']),-4), 6, '0', STR_PAD_LEFT);
182
+ $header['8-uid'] = $long || $infoFile['uid']==0?"\0\0\0\0\0\0\0":sprintf("%07o", $infoFile['uid']);
183
+ $header['8-gid'] = $long || $infoFile['gid']==0?"\0\0\0\0\0\0\0":sprintf("%07o", $infoFile['gid']);
184
+ $header['12-size'] = $long?sprintf("%011o", strlen($nameFile)):sprintf("%011o", is_dir($file) ? 0 : filesize($file));
185
+ $header['12-mtime'] = $long?'00000000000':sprintf("%011o", $infoFile['mtime']);
186
+ $header['8-check'] = sprintf('% 8s', '');
187
+ $header['1-type'] = $long?'L':(is_link($file) ? 2 : is_dir ($file) ? 5 : 0);
188
+ $header['100-symlink'] = is_link($file) == 2 ? readlink($item) : '';
189
+ $header['6-magic'] = 'ustar ';
190
+ $header['2-version'] = ' ';
191
+ $a=function_exists('posix_getpwuid')?posix_getpwuid (fileowner($file)):array('name'=>'');
192
+ $header['32-uname'] = $a['name'];
193
+ $a=function_exists('posix_getgrgid')?posix_getgrgid (filegroup($file)):array('name'=>'');
194
+ $header['32-gname'] = $a['name'];
195
+ $header['8-devmajor'] = '';
196
+ $header['8-devminor'] = '';
197
+ $header['155-prefix'] = '';
198
+ $header['12-closer'] = '';
199
+
200
+ $packedHeader = '';
201
+ foreach ($header as $key=>$element) {
202
+ $length = explode('-', $key);
203
+ $packedHeader .= pack('a' . $length[0], $element);
204
+ }
205
+
206
+ $checksum = 0;
207
+ for ($i = 0; $i < 512; $i++) {
208
+ $checksum += ord(substr($packedHeader, $i, 1));
209
+ }
210
+ $packedHeader = substr_replace($packedHeader, sprintf("%07o", $checksum)."\0", 148, 8);
211
+
212
+ return $longHeader . $packedHeader;
213
+ }
214
+
215
+ /**
216
+ * Read TAR string from file, and unpacked it.
217
+ * Create files and directories information about discribed
218
+ * in the string.
219
+ *
220
+ * @param string $destination path to file is unpacked
221
+ * @return array list of files
222
+ */
223
+ protected function _unpackCurrentTar($destination)
224
+ {
225
+ $file = $this->_getCurrentFile();
226
+ $pointer = fopen($file, 'r');
227
+ if (empty($pointer)) {
228
+ throw new Mage_Exception('Can\'t open file: ' . $file);
229
+ }
230
+ $list = array();
231
+ while (!feof($pointer)) {
232
+ $header = $this->_parseHeader($pointer);
233
+ if ($header) {
234
+ $currentFile = $destination . $header['name'];
235
+ if ($header['type']=='5' && @mkdir($currentFile, 0777, true)) {
236
+ $list[] = $currentFile . DS;
237
+ } elseif (in_array($header['type'], array("0",chr(0), ''))) {
238
+ $dirname = dirname($currentFile);
239
+ if(!file_exists($dirname)) {
240
+ @mkdir($dirname, 0777, true);
241
+ }
242
+ $this->_writeFile($currentFile, $header['data']);
243
+ $list[] = $currentFile;
244
+ }
245
+ }
246
+ }
247
+ fclose($pointer);
248
+ return $list;
249
+ }
250
+
251
+ /**
252
+ * Get header from TAR string and unpacked it by format.
253
+ *
254
+ * @param resource $pointer
255
+ * @return string
256
+ */
257
+ protected function _parseHeader(&$pointer)
258
+ {
259
+ $firstLine = fread($pointer, 512);
260
+
261
+ if (strlen($firstLine)<512){
262
+ return false;
263
+ }
264
+
265
+ $fmt = self::FORMAT_PARSE_HEADER;
266
+ $header = unpack ($fmt, $firstLine);
267
+
268
+
269
+ $header['mode']=$header['mode']+0;
270
+ $header['uid']=octdec($header['uid']);
271
+ $header['gid']=octdec($header['gid']);
272
+ $header['size']=octdec($header['size']);
273
+ $header['mtime']=octdec($header['mtime']);
274
+ $header['checksum']=octdec($header['checksum']);
275
+
276
+ if ($header['type'] == "5") {
277
+ $header['size'] = 0;
278
+ }
279
+
280
+ $checksum = 0;
281
+ $firstLine = substr_replace($firstLine, ' ', 148, 8);
282
+ for ($i = 0; $i < 512; $i++) {
283
+ $checksum += ord(substr($firstLine, $i, 1));
284
+ }
285
+
286
+ $isUstar = 'ustar' == strtolower(substr($header['magic'], 0, 5));
287
+
288
+ $checksumOk = $header['checksum'] == $checksum;
289
+ if (isset($header['name']) && $checksumOk) {
290
+ if ($header['name'] == '././@LongLink' && $header['type'] == 'L') {
291
+ $realName = substr(fread($pointer, floor(($header['size'] + 512 - 1) / 512) * 512), 0, $header['size']);
292
+ $headerMain = $this->_parseHeader($pointer);
293
+ $headerMain['name'] = $realName;
294
+ return $headerMain;
295
+ } else {
296
+ if ($header['size']>0) {
297
+ $header['data'] = substr(fread($pointer, floor(($header['size'] + 512 - 1) / 512) * 512), 0, $header['size']);
298
+ } else {
299
+ $header['data'] = '';
300
+ }
301
+ return $header;
302
+ }
303
+ }
304
+ return false;
305
+ }
306
+
307
+ /**
308
+ * Pack file to TAR (Tape Archiver).
309
+ *
310
+ * @param string $source
311
+ * @param string $destination
312
+ * @param boolean $skipRoot
313
+ * @return string
314
+ */
315
+ public function pack($source, $destination, $skipRoot=false)
316
+ {
317
+ $this->_setSkipRoot($skipRoot);
318
+ $source = realpath($source);
319
+ $tarData = $this->_setCurrentPath($source)
320
+ ->_setCurrentFile($source)
321
+ ->_packToTar($skipRoot);
322
+ $this->_writeFile($destination, $tarData);
323
+ return $destination;
324
+ }
325
+
326
+ /**
327
+ * Unpack file from TAR (Tape Archiver).
328
+ *
329
+ * @param string $source
330
+ * @param string $destination
331
+ * @return string
332
+ */
333
+ public function unpack($source, $destination)
334
+ {
335
+ $tempFile = $destination . DS . '~tmp-'.microtime(true).'.tar';
336
+ $data = $this->_readFile($source);
337
+ $this->_writeFile($tempFile, $data);
338
+ $this->_setCurrentFile($tempFile)
339
+ ->_setCurrentPath($tempFile)
340
+ ->_unpackCurrentTar($destination);
341
+ unlink($tempFile);
342
+ return $destination;
343
+ }
344
+
345
+ /**
346
+ * Extract one file from TAR (Tape Archiver).
347
+ *
348
+ * @param string $file
349
+ * @param string $source
350
+ * @param string $destination
351
+ * @return string
352
+ */
353
+ public function extract($file, $source, $destination)
354
+ {
355
+ $pointer = fopen($source, 'r');
356
+ if (empty($pointer)) {
357
+ throw new Mage_Exception('Can\'t open file: '.$source);
358
+ }
359
+ $list = array();
360
+ $extractedFile = '';
361
+ while (!feof($pointer)) {
362
+ $header = $this->_parseHeader($pointer);
363
+ if ($header['name'] == $file) {
364
+ $extractedFile = $destination . basename($header['name']);
365
+ $this->_writeFile($extractedFile, $header['data']);
366
+ break;
367
+ }
368
+ }
369
+ fclose($pointer);
370
+ return $extractedFile;
371
+ }
372
+ }
lib/Mage/Autoload/Simple.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Connect
23
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class Mage_Autoload_Simple
28
+ {
29
+ private static $_instance;
30
+
31
+ public static function instance()
32
+ {
33
+ if (!self::$_instance) {
34
+ $class = __CLASS__;
35
+ self::$_instance = new $class();
36
+ }
37
+ return self::$_instance;
38
+ }
39
+
40
+ public static function register()
41
+ {
42
+ spl_autoload_register(array(self::instance(), 'autoload'));
43
+ }
44
+
45
+ public function autoload($class)
46
+ {
47
+ $classFile = str_replace(' ', DIRECTORY_SEPARATOR, ucwords(str_replace('_', ' ', $class)));
48
+ $classFile.= '.php';
49
+ @include $classFile;
50
+ }
51
+
52
+ }
lib/Mage/Connect/Channel/Generator.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Connect
23
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class Mage_Connect_Channel_Generator extends Mage_Xml_Generator
28
+ {
29
+ protected $_file = 'channel.xml';
30
+ protected $_generator = null;
31
+
32
+ public function __construct($file='')
33
+ {
34
+ if ($file) {
35
+ $this->_file = $file;
36
+ }
37
+ return $this;
38
+ }
39
+
40
+ public function getFile()
41
+ {
42
+ return $this->_file;
43
+ }
44
+
45
+ public function getGenerator()
46
+ {
47
+ if (is_null($this->_generator)) {
48
+ $this->_generator = new Mage_Xml_Generator();
49
+ }
50
+ return $this->_generator;
51
+ }
52
+
53
+ /**
54
+ * @param array $content
55
+ */
56
+ public function save($content)
57
+ {
58
+ $xmlContent = $this->getGenerator()
59
+ ->arrayToXml($content)
60
+ ->save($this->getFile());
61
+ return $this;
62
+ }
63
+ }
lib/Mage/Connect/Channel/Parser.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Connect
23
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
lib/Mage/Connect/Channel/VO.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Connect
23
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ class Mage_Connect_Channel_VO implements Iterator
29
+ {
30
+
31
+ private $_validator = null;
32
+
33
+ protected $properties = array(
34
+ 'name' => '',
35
+ 'uri' => '',
36
+ 'summary' => '',
37
+ );
38
+
39
+ public function rewind() {
40
+ reset($this->properties);
41
+ }
42
+
43
+ public function valid() {
44
+ return current($this->properties) !== false;
45
+ }
46
+
47
+ public function key() {
48
+ return key($this->properties);
49
+ }
50
+
51
+ public function current() {
52
+ return current($this->properties);
53
+ }
54
+
55
+ public function next() {
56
+ next($this->properties);
57
+ }
58
+
59
+ public function __get($var)
60
+ {
61
+ if (isset($this->properties[$var])) {
62
+ return $this->properties[$var];
63
+ }
64
+ return null;
65
+ }
66
+
67
+ public function __set($var, $value)
68
+ {
69
+ if (is_string($value)) {
70
+ $value = trim($value);
71
+ }
72
+ if (isset($this->properties[$var])) {
73
+ if ($value === null) {
74
+ $value = '';
75
+ }
76
+ $this->properties[$var] = $value;
77
+ }
78
+ }
79
+
80
+ public function toArray()
81
+ {
82
+ return array('channel' => $this->properties);
83
+ }
84
+
85
+ public function fromArray(array $arr)
86
+ {
87
+ foreach($arr as $k=>$v) {
88
+ $this->$k = $v;
89
+ }
90
+ }
91
+
92
+
93
+ private function validator()
94
+ {
95
+ if(is_null($this->_validator)) {
96
+ $this->_validator = new Mage_Connect_Validator();
97
+ }
98
+ return $this->_validator;
99
+ }
100
+
101
+ /**
102
+ Stub for validation result
103
+ */
104
+ public function validate()
105
+ {
106
+ $v = $this->validator();
107
+ if(!$v->validatePackageName($this->name)) {
108
+ return false;
109
+ }
110
+ return true;
111
+ }
112
+
113
+ }
lib/Mage/Connect/Command.php ADDED
@@ -0,0 +1,390 @@