1. <?php
  2. /**
  3. * Common wizard presentation.
  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. * Common wizard presentation.
  15. *
  16. * Creates all tabs and buttons as common layout for the frontend.
  17. *
  18. * @category   PEAR
  19. * @package    PEAR_PackageFileManager_Frontend_Web
  20. * @author     Laurent Laville <pear@laurent-laville.org>
  21. * @copyright  2005-2006 Laurent Laville
  22. * @license    http://www.php.net/license/3_01.txt  PHP License 3.01
  23. * @since      Class available since Release 0.1.0
  24. */
  25. class TabbedPage extends HTML_QuickForm_Page
  26. {
  27.     /**
  28.      * Builds tabs of the Wizard.
  29.      *
  30.      * @return void
  31.      * @since  0.1.0
  32.      * @access public
  33.      */
  34.     function buildTabs()
  35.     {
  36.         $this->_formBuilt = true;
  37.  
  38.         // Here we get all page names in the controller
  39.         $pages  = array();
  40.         $myName = $current = $this->getAttribute('id');
  41.         while (null !== ($current = $this->controller->getPrevName($current))) {
  42.             $pages[] = $current;
  43.         }
  44.         $pages = array_reverse($pages);
  45.         $pages[] = $current = $myName;
  46.         while (null !== ($current = $this->controller->getNextName($current))) {
  47.             $pages[] = $current;
  48.         }
  49.         // Here we display buttons for all pages, the current one's is disabled
  50.         foreach ($pages as $pageName) {
  51.             $tabs[] = $this->createElement(
  52.                         'submit', $this->getButtonName($pageName), ucfirst($pageName),
  53.                         array('class' => 'flat') + ($pageName == $myName? array('disabled' => 'disabled'): array())
  54.                       );
  55.         }
  56.         $this->addGroup($tabs, 'tabs', null, '&nbsp;', false);
  57.     }
  58.  
  59.     /**
  60.      * Builds command buttons of the Wizard.
  61.      *
  62.      * @return void
  63.      * @since  0.1.0
  64.      * @access public
  65.      */
  66.     function buildButtons($disable = null, $commands = null)
  67.     {
  68.         $buttons = array('abort', 'commit', 'reset', 'dump');
  69.         if (isset($commands)) {
  70.             $buttons = array_merge($buttons, $commands);
  71.         }
  72.  
  73.         if (!isset($disable)) {
  74.             $disable = array();
  75.         } elseif (!isset($disable[0])) {
  76.             $disable = array($disable);
  77.         }
  78.  
  79.         $confirm = $attributes = array('style' => 'width:80px;');
  80.         $confirm['onclick'] = "return(confirm('Are you sure ?'));";
  81.  
  82.         $prevnext = array();
  83.  
  84.         foreach ($buttons as $event) {
  85.             switch ($event) {
  86.                 case 'abort':
  87.                 case 'commit':
  88.                 case 'reset':
  89.                 case 'remove':
  90.                     $type = 'submit';
  91.                     $attrs = $confirm;
  92.                     break;
  93.                 default :
  94.                     $type = 'submit';
  95.                     $attrs = $attributes;
  96.                     break;
  97.             }
  98.             if (in_array($event, $disable)) {
  99.                 $attrs['disabled'] = 'true';
  100.             }
  101.             if ($event == 'dump') {
  102.                 $fe =& PEAR_PackageFileManager_Frontend::singleton();
  103.                 $dump = $fe->getOption(array('settings','gui','actions','dump'));
  104.                 if ($dump === false) {
  105.                     continue;
  106.                 }
  107.                 $opts = array('0' => 'PFM options', '1' => 'GUI options',
  108.                     '2' => 'Forms values container', '3' => 'Warnings Stack',
  109.                     '4' => 'Included Files', '5' => 'PFM package info',
  110.                     '6' => 'Declared Classes'
  111.                     );
  112.                 $prevnext[] =&HTML_QuickForm::createElement('select', 'dumpOption', '', $opts);
  113.             }
  114.             $prevnext[] =&HTML_QuickForm::createElement($type, $this->getButtonName($event), ucfirst($event), HTML_Common::_getAttrString($attrs));
  115.         }
  116.         $this->addGroup($prevnext, 'buttons', '', '&nbsp;', false);
  117.     }
  118.  
  119.     /**
  120.      * Abstract implementation of the method that set default values for a page
  121.      * of the Wizard.
  122.      *
  123.      * @return void
  124.      * @since  0.1.0
  125.      */
  126.     function applyDefaults()
  127.     {
  128.     }
  129. }
  130.  
  131. require_once PEAR_PACKAGEFILEMANAGER_FRONTEND_WEBDIR . 'PackagePage.php';
  132. require_once PEAR_PACKAGEFILEMANAGER_FRONTEND_WEBDIR . 'ReleasePage.php';
  133. require_once PEAR_PACKAGEFILEMANAGER_FRONTEND_WEBDIR . 'MaintainersPage.php';
  134. require_once PEAR_PACKAGEFILEMANAGER_FRONTEND_WEBDIR . 'DependenciesPage.php';
  135. require_once PEAR_PACKAGEFILEMANAGER_FRONTEND_WEBDIR . 'ReplacementsPage.php';
  136. require_once PEAR_PACKAGEFILEMANAGER_FRONTEND_WEBDIR . 'RolesPage.php';
  137. require_once PEAR_PACKAGEFILEMANAGER_FRONTEND_WEBDIR . 'ExceptionsPage.php';
  138. require_once PEAR_PACKAGEFILEMANAGER_FRONTEND_WEBDIR . 'PreviewPage.php';
  139. require_once PEAR_PACKAGEFILEMANAGER_FRONTEND_WEBDIR . 'ErrorsPage.php';
  140.  
  141. if (isset($_GET['arrow_ltr'])) {
  142.     $filename = PEAR_PACKAGEFILEMANAGER_FRONTEND_WEBDIR . 'arrow_ltr.gif';
  143.     header('content-type: image/gif');
  144.     readfile($filename);
  145.     exit();
  146. }
  147. ?>