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_ConsoleController extends Mage_Adminhtml_Controller_Action
00038 {
00039 public function indexAction()
00040 {
00041 $this->loadLayout();
00042
00043 $this->_setActiveMenu('system/extensions/console');
00044
00045 $this->_addContent($this->getLayout()->createBlock('adminhtml/extensions_console_edit'));
00046
00047 $this->renderLayout();
00048 }
00049
00050 public function outputAction()
00051 {
00052 $pear = Varien_Pear::getInstance();
00053 $input = $this->getRequest()->getParam('argv');
00054 $argv = preg_split('#\s+#', $input);
00055 $command = false;
00056 $options = array();
00057 $params = array();
00058
00059 foreach ($argv as $arg) {
00060 if ($arg[0]==='-') {
00061 $opt = '';
00062 if ($arg[1]==='-') {
00063 $opt = substr($arg, 2);
00064 }
00065 if ($opt) {
00066 $options[$opt] = 1;
00067 }
00068 } elseif (empty($command)) {
00069 $command = $arg;
00070 } else {
00071 $params[] = $arg;
00072 }
00073 }
00074
00075 $run = new Varien_Object();
00076 if ($command) {
00077 $run->setComment(Mage::helper('adminhtml')->__('Running:').' "'.$input.'"'."\r\n\r\n");
00078 $run->setCommand($command);
00079 $run->setOptions($options);
00080 $run->setParams($params);
00081 } else {
00082 $run->setComment(Mage::helper('adminhtml')->__('Invalid input:').' "'.$input.'"'."\r\n\r\n");
00083 }
00084 $pear->runHtmlConsole($run);
00085 }
00086
00087 protected function _isAllowed()
00088 {
00089 return Mage::getSingleton('admin/session')->isAllowed('system/extensions');
00090 }
00091 }