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_LocalController extends Mage_Adminhtml_Controller_Action
00038 {
00039 public function indexAction()
00040 {
00041 $url = Mage::getBaseUrl('web').'downloader/?return='.urlencode(Mage::getUrl('adminhtml'));
00042 $this->getResponse()->setRedirect($url);
00043 return;
00044
00045 $this->loadLayout();
00046
00047 $this->_setActiveMenu('system/extensions/local');
00048
00049 $this->_addContent($this->getLayout()->createBlock('adminhtml/extensions_local'));
00050
00051 $this->renderLayout();
00052 }
00053
00054 public function gridAction()
00055 {
00056 $this->getResponse()->setBody($this->getLayout()->createBlock('adminhtml/extensions_local_grid')->toHtml());
00057 }
00058
00059 public function editAction()
00060 {
00061 $this->loadLayout();
00062
00063 $pkg = str_replace('|', '/', $this->getRequest()->getParam('id'));
00064 $ext = Mage::getModel('adminhtml/extension')->loadLocal($pkg);
00065 Mage::register('local_extension', $ext);
00066 #echo "<pre>".print_r($ext->getData(),1)."</pre>";
00067 $this->_setActiveMenu('system/extensions/local');
00068
00069 $this->_addContent($this->getLayout()->createBlock('adminhtml/extensions_local_edit'));
00070 $this->_addLeft($this->getLayout()->createBlock('adminhtml/extensions_local_edit_tabs'));
00071
00072 $this->renderLayout();
00073 }
00074
00075 public function prepareAction()
00076 {
00077 $pkg = str_replace('|', '/', $this->getRequest()->getParam('id'));
00078 $params = array('comment'=>Mage::helper('adminhtml')->__("Preparing to change $pkg, please wait...")."\r\n\r\n");
00079 Varien_Pear::getInstance()->runHtmlConsole($params);
00080 }
00081
00082 public function upgradeAction()
00083 {
00084 $pkg = str_replace('|', '/', $this->getRequest()->getParam('id'));
00085 $params = array('comment'=>Mage::helper('adminhtml')->__("Upgrading $pkg, please wait...")."\r\n\r\n");
00086 if ($this->getRequest()->getParam('do')) {
00087 $params['command'] = 'upgrade';
00088 $params['options'] = array();
00089 $params['params'] = array($pkg);
00090 }
00091 $result = Varien_Pear::getInstance()->runHtmlConsole($params);
00092 if (!$result instanceof PEAR_Error) {
00093 Mage::app()->cleanCache();
00094 }
00095 Mage::app()->getFrontController()->getResponse()->clearAllHeaders();
00096 }
00097
00098 public function uninstallAction()
00099 {
00100 $pkg = str_replace('|', '/', $this->getRequest()->getParam('id'));
00101 $params = array('comment'=>Mage::helper('adminhtml')->__("Uninstalling $pkg, please wait...")."\r\n\r\n");
00102 if ($this->getRequest()->getParam('do')) {
00103 $params['command'] = 'uninstall';
00104 $params['options'] = array();
00105 $params['params'] = array($pkg);
00106 }
00107 $result = Varien_Pear::getInstance()->runHtmlConsole($params);
00108 if (!$result instanceof PEAR_Error) {
00109 Mage::app()->cleanCache();
00110 }
00111 Mage::app()->getFrontController()->getResponse()->clearAllHeaders();
00112 }
00113
00114 public function upgradeAllAction()
00115 {
00116 $this->loadLayout();
00117
00118 $this->_setActiveMenu('system/extensions');
00119
00120 $this->_addContent($this->getLayout()->createBlock('adminhtml/extensions_local_upgrade')->initForm());
00121
00122 $this->renderLayout();
00123 }
00124
00125 public function upgradeAllRunAction()
00126 {
00127 $params = array('comment'=>Mage::helper('adminhtml')->__("Upgrading all available packages, please wait...")."\r\n\r\n");
00128 if ($this->getRequest()->getParam('do')) {
00129 $params['command'] = 'upgrade-all';
00130 $params['options'] = array();
00131 $params['params'] = array();
00132 }
00133 $result = Varien_Pear::getInstance()->runHtmlConsole($params);
00134 if (!$result instanceof PEAR_Error) {
00135 Mage::app()->cleanCache();
00136 echo "ALL UPGRADES ARE DONE.\n";
00137 } else {
00138 echo "ERROR DURING UPGRADES.\n";
00139 }
00140 Mage::app()->getFrontController()->getResponse()->clearAllHeaders();
00141 }
00142
00143 public function massUninstallAction()
00144 {
00145 $this->loadLayout();
00146
00147 $this->_setActiveMenu('system/extensions');
00148
00149 $this->_addContent($this->getLayout()->createBlock('adminhtml/extensions_mass_uninstall')->initForm());
00150
00151 $this->renderLayout();
00152 }
00153
00154 public function massUninstallRunAction()
00155 {
00156 $params = array('comment'=>Mage::helper('adminhtml')->__("Uninstalling selected packages, please wait...")."\r\n\r\n");
00157 if ($this->getRequest()->getParam('do')) {
00158 $params['command'] = 'uninstall';
00159 $params['options'] = array();
00160 $packages = array();
00161 foreach ($this->getRequest()->getPost('package') as $package) {
00162 $packages[] = str_replace('|', '/', $package);
00163 }
00164 $params['params'] = $packages;
00165 }
00166 $result = Varien_Pear::getInstance()->runHtmlConsole($params);
00167 if (!$result instanceof PEAR_Error) {
00168 Mage::app()->cleanCache();
00169 }
00170 Mage::app()->getFrontController()->getResponse()->clearAllHeaders();
00171 }
00172
00173 public function massUpgradeAction()
00174 {
00175 $this->loadLayout();
00176
00177 $this->_setActiveMenu('system/extensions');
00178
00179 $this->_addContent($this->getLayout()->createBlock('adminhtml/extensions_mass_upgrade')->initForm());
00180
00181 $this->renderLayout();
00182 }
00183
00184 public function massUpgradeRunAction()
00185 {
00186 $params = array('comment'=>Mage::helper('adminhtml')->__("Upgrading selected packages, please wait...")."\r\n\r\n");
00187 if ($this->getRequest()->getParam('do')) {
00188 $params['command'] = 'upgrade';
00189 $params['options'] = array();
00190 $packages = array();
00191 foreach ($this->getRequest()->getPost('package') as $package) {
00192 $packages[] = str_replace('|', '/', $package);
00193 }
00194 $params['params'] = $packages;
00195 }
00196 $result = Varien_Pear::getInstance()->runHtmlConsole($params);
00197 if (!$result instanceof PEAR_Error) {
00198 Mage::app()->cleanCache();
00199 }
00200 Mage::app()->getFrontController()->getResponse()->clearAllHeaders();
00201 }
00202
00203 protected function _isAllowed()
00204 {
00205 return Mage::getSingleton('admin/session')->isAllowed('system/extensions/local');
00206 }
00207 }