/** * List available * @param $command * @param $options * @param $params * @return unknown_type */ public function doListAvailable($command, $options, $params) { $this->cleanupParams($params); try { $packager = new Mage_Connect_Packager(); $ftp = empty($options['ftp']) ? false : $options['ftp']; if ($ftp) { list($cache, $config, $ftpObj) = $packager->getRemoteConf($ftp); } else { $cache = $this->getSconfig(); $config = $this->config(); } if (!empty($params[0])) { $channels = array($params[0]); $cache->getChannel($channels[0]); } else { $channels = $cache->getChannelNames(); } $packs = array(); foreach ($channels as $channel) { try { $chan = $cache->getChannel($channel); $uri = $cache->chanUrl($channel); $rest = $this->rest(); $rest->setChannel($uri); $packages = $rest->getPackages(); if (!count($packages)) { $this->ui()->output("Channel '{$channel}' has no packages"); continue; } $packs[$channel]['title'] = "Packages for channel '" . $channel . "':"; foreach ($packages as $p) { $packageName = $p['n']; $releases = array(); foreach ($p['r'] as $k => $r) { $releases[$r] = $rest->shortStateToLong($k); } $packs[$channel]['packages'][$packageName]['releases'] = $releases; } } catch (Exception $e) { $this->doError($command, $e->getMessage()); } } $dataOut = array(); $dataOut[$command] = array('data' => $packs); $this->ui()->output($dataOut); } catch (Exception $e) { $this->doError($command, $e->getMessage()); } }
/** * Retrieve object of config and set it to Mage_Connect_Command * * @return Mage_Connect_Config */ public function getConfig() { if (!$this->_config) { $this->_config = new Mage_Connect_Config(); $ftp = $this->_config->__get('remote_config'); if (!empty($ftp)) { $packager = new Mage_Connect_Packager(); list($cache, $config, $ftpObj) = $packager->getRemoteConf($ftp); $this->_config = $config; $this->_sconfig = $cache; } $this->_config->magento_root = dirname(dirname(__FILE__)) . DS . '..'; //Mage_Connect_Command::setConfigObject($this->_config); } return $this->_config; }