Mage_Adminhtml_Extensions_CustomController Class Reference

Inheritance diagram for Mage_Adminhtml_Extensions_CustomController:

Mage_Adminhtml_Controller_Action Mage_Core_Controller_Varien_Action

List of all members.

Public Member Functions

 indexAction ()
 editAction ()
 resetAction ()
 loadAction ()
 saveAction ()
 createAction ()
 releaseAction ()
 loadtabAction ()
 gridAction ()

Protected Member Functions

 _isAllowed ()


Detailed Description

Definition at line 37 of file CustomController.php.


Member Function Documentation

_isAllowed (  )  [protected]

Reimplemented from Mage_Adminhtml_Controller_Action.

Definition at line 246 of file CustomController.php.

00247     {
00248         return Mage::getSingleton('admin/session')->isAllowed('system/extensions/custom');
00249     }

createAction (  ) 

Definition at line 153 of file CustomController.php.

00154     {
00155         $session = Mage::getSingleton('adminhtml/session');
00156         try {
00157             $p = $this->getRequest()->getPost();
00158             $session->setCustomExtensionPackageFormData($p);
00159             $ext = Mage::getModel('adminhtml/extension');
00160             $ext->setData($p);
00161             $result = $ext->createPackage();
00162             $pear = Varien_Pear::getInstance();
00163             if ($result) {
00164                 $data = $pear->getOutput();
00165                 $session->addSuccess($data[0]['output']);
00166                 $this->_redirect('*/*');
00167                 #$this->_forward('reset');
00168             } else {
00169                 $session->addError($result->getMessage());
00170                 $this->_redirect('*/*');
00171             }
00172         }
00173         catch(Mage_Core_Exception $e){
00174             $session->addError($e->getMessage());
00175             $this->_redirect('*/*');
00176         }
00177         catch(Exception $e){
00178             $session->addError($e->getMessage());
00179             $this->_redirect('*/*');
00180         }
00181     }

editAction (  ) 

Definition at line 44 of file CustomController.php.

00045     {
00046         $this->loadLayout();
00047 
00048         $this->_setActiveMenu('system/extensions/custom');
00049 
00050         $this->_addContent($this->getLayout()->createBlock('adminhtml/extensions_custom_edit'));
00051 
00052         $this->_addLeft($this->getLayout()->createBlock('adminhtml/extensions_custom_edit_tabs'));
00053 
00054         $this->renderLayout();
00055     }

gridAction (  ) 

Grid for loading packages

Definition at line 266 of file CustomController.php.

00267     {
00268         $this->getResponse()->setBody(
00269             $this->getLayout()->createBlock('adminhtml/extensions_custom_edit_tab_grid')->toHtml()
00270         );
00271     }

indexAction (  ) 

Definition at line 39 of file CustomController.php.

00040     {
00041         $this->_forward('edit');
00042     }

loadAction (  ) 

Definition at line 63 of file CustomController.php.

00064     {
00065         $package = $this->getRequest()->getParam('id');
00066         if ($package) {
00067             $session = Mage::getSingleton('adminhtml/session');
00068             try {
00069                 $data = $this->_loadPackageFile(Mage::getBaseDir('var') . DS . 'pear' . DS . $package);
00070 
00071                 $data = array_merge($data, array('file_name' => $package));
00072 
00073                 $session->setCustomExtensionPackageFormData($data);
00074                 $session->addSuccess(Mage::helper('adminhtml')->__("Package %s data was successfully loaded", $package));
00075             }
00076             catch (Exception $e) {
00077                 $session->addError($e->getMessage());
00078             }
00079         }
00080         $this->_redirect('*/*/edit');
00081     }

loadtabAction (  ) 

Grid for loading packages

Definition at line 255 of file CustomController.php.

00256     {
00257         $this->getResponse()->setBody(
00258             $this->getLayout()->createBlock('adminhtml/extensions_custom_edit_tab_load')->toHtml()
00259         );
00260     }

releaseAction (  ) 

Definition at line 183 of file CustomController.php.

00184     {
00185         #Varien_Pear::getInstance()->runHtmlConsole(array('command'=>'list-channels'));
00186         if (empty($_POST)) {
00187             $serFiles = @glob(Mage::getBaseDir('var').DS.'pear'.DS.'*.ser');
00188             if (!$serFiles) {
00189                 return;
00190             }
00191             $pkg = new Varien_Object();
00192             echo '<html><head><style type="text/css">* { font:normal 12px Arial }</style></head>
00193             <body><form method="post"><table border="1" cellpadding="3" cellspacing="0"><thead>
00194                     <tr><th>Update/Package</th><th>Version</th><th>State</th></tr>
00195                 </thead><tbody>';
00196             foreach ($serFiles as $i=>$file) {
00197                 $serialized = file_get_contents($file);
00198                 $pkg->setData(unserialize($serialized));
00199                 $n = $pkg->getName();
00200                 echo '<tr><td><input type="checkbox" name="pkgs['.$i.'][name]" id="pkg_'.$i.'" value="'.$n.'"/>
00201                         <label for="pkg_'.$i.'">'.$n.'</label>
00202                         <input type="hidden" name="pkgs['.$i.'][file]" value="'.$file.'"/>
00203                     </td>
00204                     <td><input name="pkgs['.$i.'][release_version]" value="'.$pkg->getData('release_version').'"/></td>
00205                     <td><input name="pkgs['.$i.'][release_stability]" value="'.$pkg->getData('release_stability').'"/></td>
00206                 </tr>';
00207                 #echo "<pre>"; print_r($pkg->getData()); echo "</pre>"; exit;
00208             }
00209             echo '</tbody></table><button type="submit">Save and Generate Packages</button></form></body></html>';
00210         } else {
00211             @set_time_limit(0);
00212             ob_implicit_flush();
00213             foreach ($_POST['pkgs'] as $r) {
00214                 if (empty($r['name'])) {
00215                     continue;
00216                 }
00217                 echo "<hr/><h4>".$r['name']."</h4>";
00218 
00219                 $ext = Mage::getModel('adminhtml/extension');
00220                 $ext->setData(unserialize(file_get_contents($r['file'])));
00221                 $ext->setData('release_version', $r['release_version']);
00222                 $ext->setData('release_stability', $r['release_stability']);
00223 #echo "<pre>"; print_r($ext->getData()); echo "</pre>";
00224                 $result = $ext->savePackage();
00225                 if (!$result) {
00226                     echo "ERROR while creating the package";
00227                     continue;
00228                 } else {
00229                     echo "Package created; ";
00230                 }
00231                 $result = $ext->createPackage();
00232                 $pear = Varien_Pear::getInstance();
00233                 if ($result) {
00234                     $data = $pear->getOutput();
00235                     print_r($data[0]['output']);
00236                 } else {
00237                     echo "ERROR:";
00238                     print_r($result->getMessage());
00239                 }
00240             }
00241             echo '<hr/><a href="'.$_SERVER['REQUEST_URI'].'">Refresh</a>';
00242         }
00243         exit;
00244     }

resetAction (  ) 

Definition at line 57 of file CustomController.php.

00058     {
00059         Mage::getSingleton('adminhtml/session')->unsCustomExtensionPackageFormData();
00060         $this->_redirect('*/*/edit');
00061     }

saveAction (  ) 

Definition at line 111 of file CustomController.php.

00112     {
00113         $session = Mage::getSingleton('adminhtml/session');
00114         $p = $this->getRequest()->getPost();
00115 
00116         if (!empty($p['_create'])) {
00117             $create = true;
00118             unset($p['_create']);
00119         }
00120 
00121         if ($p['file_name'] == '') {
00122             $p['file_name'] = $p['name'];
00123         }
00124 
00125         $session->setCustomExtensionPackageFormData($p);
00126         try {
00127             $ext = Mage::getModel('adminhtml/extension');
00128             /* @var $ext Mage_Adminhtml_Model_Extension */
00129             $ext->setData($p);
00130             $output = $ext->getPear()->getOutput();
00131             if ($ext->savePackage()) {
00132                 $session->addSuccess('Package data was successfully saved');
00133             } else {
00134                 $session->addError('There was a problem saving package data');
00135                 $this->_redirect('*/*/edit');
00136             }
00137             if (empty($create)) {
00138                 $this->_redirect('*/*/edit');
00139             } else {
00140                 $this->_forward('create');
00141             }
00142         }
00143         catch(Mage_Core_Exception $e){
00144             $session->addError($e->getMessage());
00145             $this->_redirect('*/*');
00146         }
00147         catch(Exception $e){
00148             $session->addError($e->getMessage());
00149             $this->_redirect('*/*');
00150         }
00151     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:12 2009 for Magento by  doxygen 1.5.8