1. <?php
  2. /**
  3. * Creates the page for displaying main options
  4. * that relate to the entire package, regardless of the release.
  5. *
  6. * Package options are those such as: base install directory,
  7. * license, package name, etc...
  8. *
  9. * @category   PEAR
  10. * @package    PEAR_PackageFileManager_Frontend_Web
  11. * @author     Laurent Laville <pear@laurent-laville.org>
  12. * @copyright  2005-2006 Laurent Laville
  13. * @license    http://www.php.net/license/3_01.txt  PHP License 3.01
  14. * @since      File available since Release 0.1.0
  15. */
  16.  
  17. /**
  18. * Creates the page for displaying main options
  19. * that relate to the entire package, regardless of the release.
  20. *
  21. * @category   PEAR
  22. * @package    PEAR_PackageFileManager_Frontend_Web
  23. * @author     Laurent Laville <pear@laurent-laville.org>
  24. * @copyright  2005-2006 Laurent Laville
  25. * @license    http://www.php.net/license/3_01.txt  PHP License 3.01
  26. * @since      Class available since Release 0.1.0
  27. */
  28. class PackagePage extends TabbedPage
  29. {
  30.     /**
  31.      * Builds the current form-page.
  32.      *
  33.      * @since  0.1.0
  34.      * @access public
  35.      */
  36.     function buildForm()
  37.     {
  38.         $this->buildTabs();
  39.         // tab caption
  40.         $this->addElement('header', null, 'Package Summary');
  41.  
  42.         // We need a simple entry box for the channel selection.
  43.         $this->addElement('text', 'channel',
  44.                           array('Channel :', 'Default download source'),
  45.                           array('size' => 50)
  46.         );
  47.  
  48.         // We need a group entry box for the PEAR installer version.
  49.         $installer['min']         =& $this->createElement('text', 'min', 'min', array('size' => 12));
  50.         $installer['max']         =& $this->createElement('text', 'max', 'max', array('size' => 12));
  51.         $installer['recommended'] =& $this->createElement('text', 'recommended', 'recommended', array('size' => 12));
  52.         $installer['exclude']     =& $this->createElement('text', 'exclude', 'exclude', array('size' => 12));
  53.         $this->addGroup($installer, 'pearInstaller', 'PEAR installer :', '');
  54.  
  55.         // We need a group entry box for the PHP version.
  56.         $php['min']     =& $this->createElement('text', 'min', 'min', array('size' => 12));
  57.         $php['max']     =& $this->createElement('text', 'max', 'max', array('size' => 12));
  58.         $php['exclude'] =& $this->createElement('text', 'exclude', 'exclude', array('size' => 12));
  59.         $this->addGroup($php, 'phpVersion', 'PHP version :', '');
  60.  
  61.         // Package type options list: (value => text, with value === text)
  62.         $fe =& PEAR_PackageFileManager_Frontend::singleton();
  63.         $settings = $fe->getOption(array('settings', 'pfm'), false);
  64.         $packagetype = $settings['pfm']['package_type'];
  65.         sort($packagetype, SORT_ASC);
  66.         $packagetype = array_combine($packagetype, $packagetype);
  67.  
  68.         // We need a simple combo box for the package type selection.
  69.         $this->addElement('select', 'packageType',
  70.                           array('Package Type :', 'Specify the content type of a release'),
  71.                           $packagetype
  72.         );
  73.  
  74.         // We need a simple entry box for the package directory selection.
  75.         $this->addElement('text', 'packageDir',
  76.                           array('Package File Directory :', 'The path to the base directory of the package'),
  77.                           array('size' => 100)
  78.         );
  79.  
  80.         // We need a simple entry box for the package output directory.
  81.         $this->addElement('text', 'packageOutputDir',
  82.                           array('Package Output Directory :', 'The path in which to place the generated package.xml'),
  83.                           array('size' => 100)
  84.         );
  85.  
  86.         // We need a simple entry box for the package filename.
  87.         $this->addElement('text', 'packageFileName',
  88.                           array('Package FileName :', 'The name of the packagefile, defaults to package.xml'),
  89.                           array('size' => 50)
  90.         );
  91.  
  92.         // We need a simple entry box for the package name.
  93.         $this->addElement('text', 'packageName',
  94.                           array('Package Name :', 'Use this to create a new package.xml, or overwrite an existing one'),
  95.                           array('size' => 50)
  96.         );
  97.  
  98.         // We need a simple entry box for the base install directory.
  99.         $this->addElement('text', 'baseInstallDir',
  100.                           array('Base Install Dir :', 'The base directory to install the package in'),
  101.                           array('size' => 50)
  102.         );
  103.  
  104.         // We need a simple entry box for the package summary.
  105.         $this->addElement('text', 'packageSummary',
  106.                           array('Package Summary :', 'Summary of package purpose'),
  107.                           array('size' => 100)
  108.         );
  109.  
  110.         // We need a text area for the package description.
  111.         $this->addElement('textarea', 'packageDescription',
  112.                           array('Package Description :', 'Description of package purpose'),
  113.                           array('rows' => 4, 'cols' => 74)
  114.         );
  115.  
  116.         // Validation form rules
  117.         $installerRules['min'][0] = array('Minimum version is required', 'required');
  118.         $this->addGroupRule('pearInstaller', $installerRules);
  119.  
  120.         $phpRules['min'][0] = array('Minimum version is required', 'required');
  121.         $this->addGroupRule('phpVersion', $phpRules);
  122.  
  123.         $this->addRule('packageType', 'The package type is required'                               , 'required');
  124.         $this->addRule('packageDir', 'The path to the base directory of the package is required'   , 'required');
  125.         $this->addRule('packageName', 'The package name is required'                               , 'required');
  126.         $this->addRule('baseInstallDir', 'The base directory to install the package in is required', 'required');
  127.         $this->addRule('packageSummary', 'Summary of package purpose is required'                  , 'required');
  128.         $this->addRule('packageDescription', 'Description of package is required'                  , 'required');
  129.  
  130.         // Buttons of the wizard to do the job
  131.         $this->buildButtons(array('commit'));
  132.     }
  133. }
  134. ?>