public function checkDownloads() { $pear = new Varien_Pear(); $pkg = new PEAR_PackageFile($pear->getConfig(), false); $result = true; foreach ($this->getPackages() as $package) { $obj = $pkg->fromAnyFile($package, PEAR_VALIDATE_NORMAL); if (PEAR::isError($obj)) { $uinfo = $obj->getUserInfo(); if (is_array($uinfo)) { foreach ($uinfo as $message) { if (is_array($message)) { $message = $message['message']; } Mage::getSingleton('Mage_Install_Model_Session')->addError($message); } } else { print_r($obj->getUserInfo()); #Mage::getSingleton('Mage_Install_Model_Session')->addError($message); } $result = false; } } return $result; }
public function getInstance() { if (!self::$_instance) { self::$_instance = new self(); } return self::$_instance; }
public function outputAction() { $pear = Varien_Pear::getInstance(); $input = $this->getRequest()->getParam('argv'); $argv = preg_split('#\\s+#', $input); $command = false; $options = array(); $params = array(); foreach ($argv as $arg) { if ($arg[0] === '-') { $opt = ''; if ($arg[1] === '-') { $opt = substr($arg, 2); } if ($opt) { $options[$opt] = 1; } } elseif (empty($command)) { $command = $arg; } else { $params[] = $arg; } } $run = new Varien_Object(); if ($command) { $run->setComment(Mage::helper('adminhtml')->__('Running:') . ' "' . $input . '"' . "\r\n\r\n"); $run->setCommand($command); $run->setOptions($options); $run->setParams($params); } else { $run->setComment(Mage::helper('adminhtml')->__('Invalid input:') . ' "' . $input . '"' . "\r\n\r\n"); } $pear->runHtmlConsole($run); }
public function initForm() { $pear = Varien_Pear::getInstance(); $form = new Varien_Data_Form(); $fieldset = $form->addFieldset('cache_enable', array('legend' => AO::helper('adminhtml')->__('PEAR config'))); $fieldset->addField('preferred_state', 'select', array('name' => 'preferred_state', 'label' => AO::helper('adminhtml')->__('Preferred state'), 'value' => $pear->getConfig()->get('preferred_state'), 'options' => AO::getModel('adminhtml/extension')->getStabilityOptions())); $this->setForm($form); return $this; }
public function upgradeAllAction() { $params = array('comment' => Mage::helper('adminhtml')->__("Upgrading all packages, please wait...") . "\r\n\r\n"); if ($this->getRequest()->getParam('do')) { $params['command'] = 'upgrade'; $params['options'] = array(); $params['params'] = array($pkg); } $result = Varien_Pear::getInstance()->runHtmlConsole($params); if (!$result instanceof PEAR_Error) { Mage::app()->cleanCache(); } }
protected function _fetchPackages() { // fetch installed packages $pear = Varien_Pear::getInstance(); $channels = Mage::getModel('adminhtml/extension')->getKnownChannels(); #$channels = array('var-dev.varien.com'=>1);#, 'pear.php.net'=>1); $channelData = array(); foreach ($channels as $channel => $name) { $data = array(); if (Mage::app()->useCache('pear')) { $channelKey = 'PEAR_channel_packages_' . preg_replace('#[^a-z0-9]+#', '_', $channel); $data = unserialize(Mage::app()->loadCache($channelKey)); } if (empty($data)) { $pear->getFrontend()->clear(); $pear->run('list-all', array('channel' => $channel)); $output = $pear->getOutput(); if (empty($output)) { continue; } $data = $output[0]['output']; if (Mage::app()->useCache('pear')) { Mage::app()->saveCache(serialize($data), $channelKey, array('pear'), 3600); } } $channelData[$channel] = $data; } // load available packages into array $packages = array(); foreach ($channelData as $channel) { if (!isset($channel['headline'])) { continue; } if (!empty($channel['data'])) { foreach ($channel['data'] as $category => $pkglist) { foreach ($pkglist as $pkg) { $pkgNameArr = explode('/', $pkg[0]); $pkgName = isset($pkgNameArr[1]) ? $pkgNameArr[1] : $pkgNameArr[0]; $packages[] = array('id' => $channel['channel'] . '|' . $pkgName, 'category' => $category, 'channel' => $channel['channel'], 'name' => $pkgName, 'remote_version' => isset($pkg[1]) ? $pkg[1] : '', 'local_version' => isset($pkg[2]) ? $pkg[2] : '', 'summary' => isset($pkg[3]) ? $pkg[3] : ''); } } } } return $packages; }
protected function _fetchPackages() { // fetch installed packages $pear = Varien_Pear::getInstance(); $pear->run('list', array('allchannels' => 1)); $output = $pear->getOutput(); // load available packages into array $packages = array(); foreach ($output as $i => $channelRoot) { $channel = $channelRoot['output']; if (!isset($channel['headline'])) { continue; } foreach ($channel['data'] as $j => $pkg) { $packages[] = array('id' => $channel['channel'] . '|' . $pkg[0], 'channel' => $channel['channel'], 'name' => $pkg[0], 'version' => $pkg[1], 'stability' => $pkg[2]); } } return $packages; }
public function saveAction() { $pear = Varien_Pear::getInstance(); $error = Mage::helper('adminhtml')->__("Unknown error"); $state = $this->getRequest()->getPost('preferred_state'); if (!empty($state)) { $session = Mage::getSingleton('adminhtml/session'); $result = $pear->run('config-set', array(), array('preferred_state', $state)); if ($result instanceof PEAR_Error) { $error = $result->getMessage(); } else { $error = false; } } if ($error) { $session->addError($result->getMessage()); } else { $session->addSuccess(Mage::helper('adminhtml')->__("PEAR Configuration was successfully saved")); } $this->_redirect('*/*'); }
public function createPackage() { $pear = Varien_Pear::getInstance(); $dir = Mage::getBaseDir('var') . DS . 'pear'; if (!Mage::getConfig()->createDirIfNotExists($dir)) { return false; } $curDir = getcwd(); chdir($dir); $result = $pear->run('mage-package', array(), array('package.xml')); chdir($curDir); if ($result instanceof PEAR_Error) { return $result; } return true; }
public function __construct() { $this->_pear = Varien_Pear::getInstance(); }
public function massInstallRunAction() { $params = array('comment' => Mage::helper('adminhtml')->__("Installing selected packages, please wait...") . "\r\n\r\n"); if ($this->getRequest()->getParam('do')) { $params['command'] = 'install'; $params['options'] = array(); $packages = array(); foreach ($this->getRequest()->getPost('package') as $package) { $packages[] = str_replace('|', '/', $package); } $params['params'] = $packages; } $result = Varien_Pear::getInstance()->runHtmlConsole($params); if (!$result instanceof PEAR_Error) { Mage::app()->cleanCache(); } Mage::app()->getFrontController()->getResponse()->clearAllHeaders(); }
public function installAction() { $pear = Varien_Pear::getInstance(); $params = array('comment' => Mage::helper('install')->__("Downloading and installing Magento, please wait...") . "\r\n\r\n"); if ($this->getRequest()->getParam('do')) { if ($state = $this->getRequest()->getParam('state', 'beta')) { $result = $pear->runHtmlConsole(array('comment' => Mage::helper('install')->__("Setting preferred state to: %s", $state) . "\r\n\r\n", 'command' => 'config-set', 'params' => array('preferred_state', $state))); if ($result instanceof PEAR_Error) { $this->installFailureCallback(); exit; } } $params['command'] = 'install'; $params['options'] = array('onlyreqdeps' => 1); $params['params'] = Mage::getModel('install/installer_pear')->getPackages(); $params['success_callback'] = array($this, 'installSuccessCallback'); $params['failure_callback'] = array($this, 'installFailureCallback'); } $pear->runHtmlConsole($params); Mage::app()->getFrontController()->getResponse()->clearAllHeaders(); }
public function releaseAction() { #Varien_Pear::getInstance()->runHtmlConsole(array('command'=>'list-channels')); if (empty($_POST)) { $serFiles = @glob(Mage::getBaseDir('var') . DS . 'pear' . DS . '*.ser'); if (!$serFiles) { return; } $pkg = new Varien_Object(); echo '<html><head><style type="text/css">* { font:normal 12px Arial }</style></head> <body><form method="post"><table border="1" cellpadding="3" cellspacing="0"><thead> <tr><th>Update/Package</th><th>Version</th><th>State</th></tr> </thead><tbody>'; foreach ($serFiles as $i => $file) { $serialized = file_get_contents($file); $pkg->setData(unserialize($serialized)); $n = $pkg->getName(); echo '<tr><td><input type="checkbox" name="pkgs[' . $i . '][name]" id="pkg_' . $i . '" value="' . $n . '"/> <label for="pkg_' . $i . '">' . $n . '</label> <input type="hidden" name="pkgs[' . $i . '][file]" value="' . $file . '"/> </td> <td><input name="pkgs[' . $i . '][release_version]" value="' . $pkg->getData('release_version') . '"/></td> <td><input name="pkgs[' . $i . '][release_stability]" value="' . $pkg->getData('release_stability') . '"/></td> </tr>'; #echo "<pre>"; print_r($pkg->getData()); echo "</pre>"; exit; } echo '</tbody></table><button type="submit">Save and Generate Packages</button></form></body></html>'; } else { @set_time_limit(0); ob_implicit_flush(); foreach ($_POST['pkgs'] as $r) { if (empty($r['name'])) { continue; } echo "<hr/><h4>" . $r['name'] . "</h4>"; $ext = Mage::getModel('adminhtml/extension'); $ext->setData(unserialize(file_get_contents($r['file']))); $ext->setData('release_version', $r['release_version']); $ext->setData('release_stability', $r['release_stability']); #echo "<pre>"; print_r($ext->getData()); echo "</pre>"; $result = $ext->savePackage(); if (!$result) { echo "ERROR while creating the package"; continue; } else { echo "Package created; "; } $result = $ext->createPackage(); $pear = Varien_Pear::getInstance(); if ($result) { $data = $pear->getOutput(); print_r($data[0]['output']); } else { echo "ERROR:"; print_r($result->getMessage()); } } echo '<hr/><a href="' . $_SERVER['REQUEST_URI'] . '">Refresh</a>'; } exit; }
public function createPackage() { $pear = Varien_Pear::getInstance(); $dir = Mage::getBaseDir('var') . DS . 'pear'; $result = $pear->run('mage-package', array('targetdir' => $dir), array($dir . '/package.xml')); if ($result instanceof PEAR_Error) { return $result; } return true; }
public function testAction() { Varien_Pear::getInstance()->runHtmlConsole(array('command' => 'list-channels')); }