1. <?php
  2. /**
  3. * Global common actions to perform from any page of the frontend.
  4. *
  5. * @category   PEAR
  6. * @package    PEAR_PackageFileManager_Frontend_Web
  7. * @author     Laurent Laville <pear@laurent-laville.org>
  8. * @copyright  2005-2006 Laurent Laville
  9. * @license    http://www.php.net/license/3_01.txt  PHP License 3.01
  10. * @since      File available since Release 0.1.0
  11. */
  12.  
  13. /**
  14. * Global common actions to perform from any page of the frontend.
  15. *
  16. * These actions are :
  17. * - 'abort'  Quit the frontend without doing any changes on package(2).xml file(s).
  18. *            Ask a confirmation.
  19. * - 'commit' Apply all changes to package(2).xml file(s) before leaving the frontend.
  20. *            Ask a confirmation.
  21. * - 'reset'  Retrieve defaults tab data before you made changes.
  22. *            Ask a confirmation. Only the current tab data are lost (not the other ones).
  23. *
  24. * @category   PEAR
  25. * @package    PEAR_PackageFileManager_Frontend_Web
  26. * @author     Laurent Laville <pear@laurent-laville.org>
  27. * @copyright  2005-2006 Laurent Laville
  28. * @license    http://www.php.net/license/3_01.txt  PHP License 3.01
  29. * @since      Class available since Release 0.1.0
  30. */
  31. class ActionProcess extends HTML_QuickForm_Action
  32. {
  33.     /**
  34.      * Performs an action on a page of the controller (wizard)
  35.      *
  36.      * @param  string   $page          current page displayed by the controller
  37.      * @param  string   $actionName    page action asked
  38.      * @return void
  39.      * @since  0.1.0
  40.      * @access public
  41.      */
  42.     function perform(&$page, $actionName)
  43.     {
  44.         $fe =& PEAR_PackageFileManager_Frontend::singleton();
  45.         $pageName = $page->getAttribute('id');
  46.         $fe->log('debug',
  47.             str_pad($pageName .'('. __LINE__ .')', 20, '.') .
  48.             ' ActionProcess='. $actionName
  49.         );
  50.  
  51.         switch ($actionName) {
  52.             case 'abort':
  53.                 echo '<h1>Task was canceled</h1>';
  54.                 echo '<p>No package was created or modified.</p>';
  55.                 $fe->container(true);
  56.                 die();
  57.  
  58.             case 'commit':
  59.                 $exportV1 = is_null($page->getSubmitValue('exportCompatibleV1')) ? false : true;
  60.                 $changelogOldToNewis_null($page->getSubmitValue('changelogOldToNew')) ? false : true;
  61.                 $simpleOutput = is_null($page->getSubmitValue('simpleOutput')) ? false : true;
  62.  
  63.                 ob_start();
  64.                 $filename = $fe->buildPackageFile(null, $exportV1, $changelogOldToNew, $simpleOutput);
  65.                 ob_end_clean();
  66.                 // reset session data
  67.                 $fe->container(true);
  68.  
  69.                 echo '<h1>Task was proceed</h1>';
  70.                 echo "<p>New package file is available at <b>$filename</b>.</p>";
  71.                 die();
  72.  
  73.             case 'reset':
  74.                 $page->loadValues(null);
  75.                 $page->applyDefaults();
  76.                 $page->controller->applyDefaults($pageName);
  77.                 return $page->handle('display');
  78.         }
  79.     }
  80. }
  81. ?>