Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.88 KB | None | 0 0
  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@magento.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.magento.com for more information.
  20. *
  21. * @category Mage
  22. * @package Mage_Connect
  23. * @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
  24. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  25. */
  26.  
  27. final class Mage_Connect_Command_Registry
  28. extends Mage_Connect_Command
  29. {
  30.  
  31. /**
  32. * List-installed callback
  33. * @param string $command
  34. * @param array $options
  35. * @param array $params
  36. * @return void
  37. */
  38. public function doList($command, $options, $params)
  39. {
  40. $this->cleanupParams($params);
  41. try {
  42. $packager = $this->getPackager();
  43. $ftp = empty($options['ftp']) ? false : $options['ftp'];
  44. if($ftp) {
  45. list($cache, $ftpObj) = $packager->getRemoteCache($ftp);
  46. } else {
  47. $cache = $this->getSconfig();
  48. }
  49. if(!empty($params[0])) {
  50. $chanName = $conf->chanName($params[0]);
  51. $data = $cache->getInstalledPackages($chanName);
  52. } else {
  53. $data = $cache->getInstalledPackages();
  54. }
  55. if($ftp) {
  56. @unlink($cache->getFilename());
  57. }
  58. $this->ui()->output(array($command=>array('data'=>$data, 'channel-title'=>"Installed package for channel '%s' :")));
  59. } catch (Exception $e) {
  60. if($ftp) {
  61. @unlink($cache->getFilename());
  62. }
  63. $this->doError($command, $e->getMessage());
  64. }
  65.  
  66. }
  67.  
  68. /**
  69. * list-files callback
  70. * @param string $command
  71. * @param array $options
  72. * @param array $params
  73. * @return void
  74. */
  75. public function doFileList($command, $options, $params)
  76. {
  77. $this->cleanupParams($params);
  78. //$this->splitPackageArgs($params);
  79. try {
  80. $channel = false;
  81. if(count($params) < 2) {
  82. throw new Exception("Argument count should be = 2");
  83. }
  84. $channel = $params[0];
  85. $package = $params[1];
  86.  
  87. $packager = $this->getPackager();
  88. $ftp = empty($options['ftp']) ? false : $options['ftp'];
  89. if($ftp) {
  90. list($cache, $config, $ftpObj) = $packager->getRemoteConf($ftp);
  91. } else {
  92. $cache = $this->getSconfig();
  93. $confif = $this->config();
  94. }
  95. if(!$cache->hasPackage($channel, $package)) {
  96. return $this->ui()->output("No package found: {$channel}/{$package}");
  97. }
  98.  
  99. $p = $cache->getPackageObject($channel, $package);
  100. $contents = $p->getContents();
  101. if($ftp) {
  102. $ftpObj->close();
  103. }
  104. if(!count($contents)) {
  105. return $this->ui()->output("No contents for package {$package}");
  106. }
  107. $title = ("Contents of '{$package}': ");
  108. if($ftp) {
  109. @unlink($config->getFilename());
  110. @unlink($cache->getFilename());
  111. }
  112.  
  113. $this->ui()->output(array($command=>array('data'=>$contents, 'title'=>$title)));
  114.  
  115. } catch (Exception $e) {
  116. if($ftp) {
  117. @unlink($config->getFilename());
  118. @unlink($cache->getFilename());
  119. }
  120. $this->doError($command, $e->getMessage());
  121. }
  122.  
  123. }
  124.  
  125. /**
  126. * Installed package info
  127. * info command callback
  128. * @param string $command
  129. * @param array $options
  130. * @param array $params
  131. * @return
  132. */
  133. public function doInfo($command, $options, $params)
  134. {
  135. $this->cleanupParams($params);
  136. //$this->splitPackageArgs($params);
  137.  
  138. try {
  139. $channel = false;
  140. if(count($params) < 2) {
  141. throw new Exception("Argument count should be = 2");
  142. }
  143. $channel = $params[0];
  144. $package = $params[1];
  145. $packager = $this->getPackager();
  146. $ftp = empty($options['ftp']) ? false : $options['ftp'];
  147. if($ftp) {
  148. list($cache, $ftpObj) = $packager->getRemoteCache($ftp);
  149. } else {
  150. $cache = $this->getSconfig();
  151. }
  152.  
  153. if(!$cache->isChannel($channel)) {
  154. throw new Exception("'{$channel}' is not a valid installed channel name/uri");
  155. }
  156. $channelUri = $cache->chanUrl($channel);
  157. $rest = $this->rest();
  158. $rest->setChannel($channelUri);
  159. $releases = $rest->getReleases($package);
  160. if(false === $releases) {
  161. throw new Exception("No information found about {$channel}/{$package}");
  162. }
  163. $data = array($command => array('releases'=>$releases));
  164. if($ftp) {
  165. @unlink($cache->getFilename());
  166. }
  167. $this->ui()->output($data);
  168. } catch (Exception $e) {
  169. if($ftp) {
  170. @unlink($cache->getFilename());
  171. }
  172. $this->doError($command, $e->getMessage());
  173. }
  174. }
  175. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement