00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 require_once 'Varien/Pear/Package.php';
00029
00030
00031
00032
00033
00034
00035
00036
00037 class Mage_Adminhtml_Extensions_RemoteController extends Mage_Adminhtml_Controller_Action
00038 {
00039 public function indexAction()
00040 {
00041 $this->loadLayout();
00042
00043 $this->_setActiveMenu('system/extensions/remote');
00044
00045 $this->_addContent($this->getLayout()->createBlock('adminhtml/extensions_remote'));
00046
00047 $this->renderLayout();
00048 }
00049
00050 public function gridAction()
00051 {
00052 $this->getResponse()->setBody($this->getLayout()->createBlock('adminhtml/extensions_remote_grid')->toHtml());
00053 }
00054
00055 public function editAction()
00056 {
00057 $this->loadLayout();
00058
00059 $pkg = str_replace('|', '/', $this->getRequest()->getParam('id'));
00060 $ext = Mage::getModel('adminhtml/extension')->loadRemote($pkg);
00061 #echo "<pre>".print_r($ext->getData(),1)."</pre>";
00062 Mage::register('remote_extension', $ext);
00063 $this->_setActiveMenu('system/extensions/remote');
00064
00065 $this->_addContent($this->getLayout()->createBlock('adminhtml/extensions_remote_edit'));
00066 $this->_addLeft($this->getLayout()->createBlock('adminhtml/extensions_remote_edit_tabs'));
00067
00068 $this->renderLayout();
00069 }
00070
00071 public function installAction()
00072 {
00073 $pkg = str_replace('|', '/', $this->getRequest()->getParam('id'));
00074 $params = array('comment'=>Mage::helper('adminhtml')->__("Downloading and installing $pkg, please wait...")."\r\n\r\n");
00075 if ($this->getRequest()->getParam('do')) {
00076 $params['command'] = 'install';
00077 $params['options'] = array('onlyreqdeps'=>1);
00078 $params['params'] = array($pkg);
00079 }
00080 $result = Varien_Pear::getInstance()->runHtmlConsole($params);
00081 if (!$result instanceof PEAR_Error) {
00082 Mage::app()->cleanCache();
00083 }
00084 Mage::app()->getFrontController()->getResponse()->clearAllHeaders();
00085 }
00086
00087 public function upgradeAction()
00088 {
00089 $pkg = str_replace('|', '/', $this->getRequest()->getParam('id'));
00090 $params = array('comment'=>Mage::helper('adminhtml')->__("Upgrading $pkg, please wait...")."\r\n\r\n");
00091 if ($this->getRequest()->getParam('do')) {
00092 $params['command'] = 'upgrade';
00093 $params['options'] = array();
00094 $params['params'] = array($pkg);
00095 }
00096 $result = Varien_Pear::getInstance()->runHtmlConsole($params);
00097 if (!$result instanceof PEAR_Error) {
00098 Mage::app()->cleanCache();
00099 }
00100 Mage::app()->getFrontController()->getResponse()->clearAllHeaders();
00101 }
00102
00103 public function massInstallAction()
00104 {
00105 $this->loadLayout();
00106
00107 $this->_setActiveMenu('system/extensions');
00108
00109 $this->_addContent($this->getLayout()->createBlock('adminhtml/extensions_mass_install')->initForm());
00110
00111 $this->renderLayout();
00112 }
00113
00114 public function massInstallRunAction()
00115 {
00116 $params = array('comment'=>Mage::helper('adminhtml')->__("Installing selected packages, please wait...")."\r\n\r\n");
00117 if ($this->getRequest()->getParam('do')) {
00118 $params['command'] = 'install';
00119 $params['options'] = array();
00120 $packages = array();
00121 foreach ($this->getRequest()->getPost('package') as $package) {
00122 $packages[] = str_replace('|', '/', $package);
00123 }
00124 $params['params'] = $packages;
00125 }
00126 $result = Varien_Pear::getInstance()->runHtmlConsole($params);
00127 if (!$result instanceof PEAR_Error) {
00128 Mage::app()->cleanCache();
00129 }
00130 Mage::app()->getFrontController()->getResponse()->clearAllHeaders();
00131 }
00132
00133 protected function _isAllowed()
00134 {
00135 return Mage::getSingleton('admin/session')->isAllowed('system/extensions/remote');
00136 }
00137 }