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
00029
00030
00031
00032
00033
00034
00035 class Mage_Adminhtml_Extensions_FileController extends Mage_Adminhtml_Controller_Action
00036 {
00037 public function indexAction()
00038 {
00039 $this->loadLayout();
00040
00041 $this->_setActiveMenu('system/extensions');
00042
00043 $this->_addContent($this->getLayout()->createBlock('adminhtml/extensions_file_form')->initForm());
00044
00045 $this->renderLayout();
00046 }
00047
00048 public function installAction()
00049 {
00050 $params = array('comment'=>Mage::helper('adminhtml')->__("Pending installation...")."\r\n\r\n");
00051 if ($this->getRequest()->getParam('do')) {
00052 switch ($this->getRequest()->getParam('file_type')) {
00053 case 'local':
00054 if (empty($_FILES['local']['tmp_name'])) {
00055 $params['comment'] = Mage::helper('adminhtml')->__("Error uploading the file")."\r\n\r\n";
00056 break;
00057 }
00058 $tmpDir = Mage::getBaseDir('var').DS.'pear';
00059 if (!is_dir($tmpDir)) {
00060 mkdir($tmpDir, 0777, true);
00061 }
00062 $pkg = $tmpDir.DS.$_FILES['local']['name'];
00063 move_uploaded_file($_FILES['local']['tmp_name'], $pkg);
00064
00065 break;
00066
00067 case 'remote':
00068 $pkg = $this->getRequest()->getParam('remote');
00069 if (empty($pkg)) {
00070 $params['comment'] = Mage::helper('adminhtml')->__("Invalid URL")."\r\n\r\n";
00071 }
00072 break;
00073 }
00074 if (!empty($pkg)) {
00075 $params['comment'] = Mage::helper('adminhtml')->__("Installing $pkg, please wait...")."\r\n\r\n";
00076 $params['command'] = 'install';
00077 $params['options'] = array();
00078 $params['params'] = array($pkg);
00079 }
00080 }
00081 $result = Varien_Pear::getInstance()->runHtmlConsole($params);
00082 if (!$result instanceof PEAR_Error) {
00083 Mage::getModel('adminhtml/extension')->clearAllCache();
00084 }
00085 }
00086
00087 public function upgradeAllAction()
00088 {
00089 $params = array('comment'=>Mage::helper('adminhtml')->__("Upgrading all packages, please wait...")."\r\n\r\n");
00090 if ($this->getRequest()->getParam('do')) {
00091 $params['command'] = 'upgrade';
00092 $params['options'] = array();
00093 $params['params'] = array($pkg);
00094 }
00095 $result = Varien_Pear::getInstance()->runHtmlConsole($params);
00096 if (!$result instanceof PEAR_Error) {
00097 Mage::app()->cleanCache();
00098 }
00099 }
00100
00101 protected function _isAllowed()
00102 {
00103 return Mage::getSingleton('admin/session')->isAllowed('system/extensions');
00104 }
00105 }