home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / ProgressMaker.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  29.0 KB  |  605 lines

  1. <?php
  2. /**
  3.  * ProgressMaker allows to dynamic build Progress bar,
  4.  * give a shot on display.
  5.  * 
  6.  * @version    $Id: ProgressMaker.php,v 1.1 2003/11/15 18:27:10 thesaur Exp $
  7.  * @author     Laurent Laville <pear@laurent-laville.org>
  8.  * @package    HTML_Progress
  9.  */
  10.  
  11. require_once 'HTML/Progress.php';
  12.  
  13. require_once 'HTML/Page.php';
  14. require_once 'HTML/CSS.php';
  15.  
  16. require_once 'HTML/QuickForm/Controller.php';
  17.  
  18. // Load some default action handlers
  19. require_once 'HTML/QuickForm/Action/Submit.php';
  20. require_once 'HTML/QuickForm/Action/Jump.php';
  21. require_once 'HTML/QuickForm/Action/Display.php';
  22. require_once 'HTML/QuickForm/Action/Direct.php';
  23.  
  24. /**
  25.  *  Progress main properties
  26.  */
  27. class Property1 extends HTML_QuickForm_Page
  28. {
  29.     function buildForm()
  30.     {
  31.         $this->_formBuilt = true;
  32.  
  33.         $tabs[] =& $this->createElement('submit', $this->getButtonName('page1'), 'Progress', array('class' => 'flat', 'disabled' => 'disabled'));
  34.         $tabs[] =& $this->createElement('submit', $this->getButtonName('page2'), 'Cell', array('class' => 'flat'));
  35.         $tabs[] =& $this->createElement('submit', $this->getButtonName('page3'), 'Border', array('class' => 'flat'));
  36.         $tabs[] =& $this->createElement('submit', $this->getButtonName('page4'), 'String', array('class' => 'flat'));
  37.         $tabs[] =& $this->createElement('submit', $this->getButtonName('page5'), 'Ready', array('class' => 'flat'));
  38.         $this->addGroup($tabs, 'tabs', null, ' ', false);
  39.  
  40.         $this->addElement('header', null, ' ');
  41.  
  42.         $models = array(
  43.             ''  => '',
  44.             'ancestor.ini'  => 'Ancestor',
  45.             'bluesand.ini'  => 'BlueSand',
  46.             'redsandback.ini'  => 'RedSandBack',
  47.             'bullit.ini'  => 'Bullit',
  48.             'smallest.ini'  => 'Smallest',
  49.             'bgimages.ini'  => 'BgImages'
  50.         );
  51.         $this->addElement('select', 'model', 'pre-set UI models:', $models);
  52.  
  53.         $this->addElement('text', 'progressclass', 'CSS class:', array('size' => 32));
  54.  
  55.         $shape[] =& $this->createElement('radio', null, null, 'Horizontal', '1');
  56.         $shape[] =& $this->createElement('radio', null, null, 'Vertical', '2');
  57.         $this->addGroup($shape, 'shape', 'Progress shape:');
  58.  
  59.         $way[] =& $this->createElement('radio', null, null, 'Natural', 'natural');
  60.         $way[] =& $this->createElement('radio', null, null, 'Reverse', 'reverse');
  61.         $this->addGroup($way, 'way', 'Progress way:');
  62.  
  63.         $autosize[] =& $this->createElement('radio', null, null, 'Yes', true);
  64.         $autosize[] =& $this->createElement('radio', null, null, 'No', false);
  65.         $this->addGroup($autosize, 'autosize', 'Progress best size:');
  66.  
  67.         $progresssize['width']   =& $this->createElement('text', 'width', null, array('size' => 4));
  68.         $progresssize['height']  =& $this->createElement('text', 'height', null, array('size' => 4));
  69.         $progresssize['bgcolor'] =& $this->createElement('text', 'bgcolor', null, array('size' => 7));
  70.         $this->addGroup($progresssize, 'progresssize', 'Size and color (width, height, bgcolor):', ', ');
  71.  
  72.  
  73.         $this->addElement('submit', $this->getButtonName('next'), 'Next >>');
  74.     }
  75. }
  76.  
  77. /**
  78.  *  Cell properties
  79.  */
  80. class Property2 extends HTML_QuickForm_Page
  81. {
  82.     function buildForm()
  83.     {
  84.         $this->_formBuilt = true;
  85.  
  86.         $tabs[] =& $this->createElement('submit', $this->getButtonName('page1'), 'Progress', array('class' => 'flat'));
  87.         $tabs[] =& $this->createElement('submit', $this->getButtonName('page2'), 'Cell', array('class' => 'flat', 'disabled' => 'disabled'));
  88.         $tabs[] =& $this->createElement('submit', $this->getButtonName('page3'), 'Border', array('class' => 'flat'));
  89.         $tabs[] =& $this->createElement('submit', $this->getButtonName('page4'), 'String', array('class' => 'flat'));
  90.         $tabs[] =& $this->createElement('submit', $this->getButtonName('page5'), 'Ready', array('class' => 'flat'));
  91.         $this->addGroup($tabs, 'tabs', null, ' ', false);
  92.  
  93.         $this->addElement('header', null, ' ');
  94.  
  95.         $this->addElement('text', 'cellid', 'Id mask:', array('size' => 32));
  96.         $this->addElement('text', 'cellclass', 'CSS class:', array('size' => 32));
  97.  
  98.         $cellvalue['min'] =& $this->createElement('text', 'min', null, array('size' => 4));
  99.         $cellvalue['max'] =& $this->createElement('text', 'max', null, array('size' => 4));
  100.         $cellvalue['inc'] =& $this->createElement('text', 'inc', null, array('size' => 4));
  101.         $this->addGroup($cellvalue, 'cellvalue', 'Value (minimum, maximum, increment):', ', ');
  102.  
  103.         $cellsize['width']   =& $this->createElement('text', 'width', null, array('size' => 4));
  104.         $cellsize['height']  =& $this->createElement('text', 'height', null, array('size' => 4));
  105.         $cellsize['spacing'] =& $this->createElement('text', 'spacing', null, array('size' => 2));
  106.         $cellsize['count']   =& $this->createElement('text', 'count', null, array('size' => 2));
  107.         $this->addGroup($cellsize, 'cellsize', 'Size (width, height, spacing, count):', ', ');
  108.  
  109.         $cellcolor['active']   =& $this->createElement('text', 'active', null, array('size' => 7));
  110.         $cellcolor['inactive'] =& $this->createElement('text', 'inactive', null, array('size' => 7));
  111.         $this->addGroup($cellcolor, 'cellcolor', 'Color (active, inactive):', ', ');
  112.  
  113.         $cellfont['family'] =& $this->createElement('text', 'family', null, array('size' => 32));
  114.         $cellfont['size']   =& $this->createElement('text', 'size', null, array('size' => 2));
  115.         $cellfont['color']  =& $this->createElement('text', 'color', null, array('size' => 7));
  116.         $this->addGroup($cellfont, 'cellfont', 'Font (family, size, color):', ', ');
  117.  
  118.  
  119.         $prevnext[] =& $this->createElement('submit', $this->getButtonName('back'), '<< Back');
  120.         $prevnext[] =& $this->createElement('submit', $this->getButtonName('next'), 'Next >>');
  121.         $this->addGroup($prevnext, null, '', ' ', false);       
  122.     }
  123. }
  124.  
  125. /**
  126.  *  Progress border properties
  127.  */
  128. class Property3 extends HTML_QuickForm_Page
  129. {
  130.     function buildForm()
  131.     {
  132.         $this->_formBuilt = true;
  133.  
  134.         $tabs[] =& $this->createElement('submit', $this->getButtonName('page1'), 'Progress', array('class' => 'flat'));
  135.         $tabs[] =& $this->createElement('submit', $this->getButtonName('page2'), 'Cell', array('class' => 'flat'));
  136.         $tabs[] =& $this->createElement('submit', $this->getButtonName('page3'), 'Border', array('class' => 'flat', 'disabled' => 'disabled'));
  137.         $tabs[] =& $this->createElement('submit', $this->getButtonName('page4'), 'String', array('class' => 'flat'));
  138.         $tabs[] =& $this->createElement('submit', $this->getButtonName('page5'), 'Ready', array('class' => 'flat'));
  139.         $this->addGroup($tabs, 'tabs', null, ' ', false);
  140.  
  141.         $this->addElement('header', null, ' ');
  142.  
  143.         $borderpainted[] =& $this->createElement('radio', null, null, 'Yes', true);
  144.         $borderpainted[] =& $this->createElement('radio', null, null, 'No', false);
  145.         $this->addGroup($borderpainted, 'borderpainted', 'Display a border around the progress bar:');
  146.  
  147.         $this->addElement('text', 'borderclass', 'CSS class:', array('size' => 32));
  148.  
  149.         $borderstyle['style'] =& $this->createElement('select', 'style', null, array('solid'=>'Solid', 'dashed'=>'Dashed', 'dotted'=>'Dotted', 'inset'=>'Inset', 'outset'=>'Outset'));
  150.         $borderstyle['width'] =& $this->createElement('text', 'width', null, array('size' => 2));
  151.         $borderstyle['color'] =& $this->createElement('text', 'color', null, array('size' => 7));
  152.         $this->addGroup($borderstyle, 'borderstyle', '(style, width, color):', ', ');
  153.  
  154.  
  155.         $prevnext[] =& $this->createElement('submit', $this->getButtonName('back'), '<< Back');
  156.         $prevnext[] =& $this->createElement('submit', $this->getButtonName('next'), 'Next >>');
  157.         $this->addGroup($prevnext, null, '', ' ', false);       
  158.     }
  159. }
  160.  
  161. /**
  162.  *  String properties
  163.  */
  164. class Property4 extends HTML_QuickForm_Page
  165. {
  166.     function buildForm()
  167.     {
  168.         $this->_formBuilt = true;
  169.  
  170.         $tabs[] =& $this->createElement('submit', $this->getButtonName('page1'), 'Progress', array('class' => 'flat'));
  171.         $tabs[] =& $this->createElement('submit', $this->getButtonName('page2'), 'Cell', array('class' => 'flat'));
  172.         $tabs[] =& $this->createElement('submit', $this->getButtonName('page3'), 'Border', array('class' => 'flat'));
  173.         $tabs[] =& $this->createElement('submit', $this->getButtonName('page4'), 'String', array('class' => 'flat', 'disabled' => 'disabled'));
  174.         $tabs[] =& $this->createElement('submit', $this->getButtonName('page5'), 'Ready', array('class' => 'flat'));
  175.         $this->addGroup($tabs, 'tabs', null, ' ', false);
  176.  
  177.         $this->addElement('header', null, ' ');
  178.  
  179.         $stringpainted[] =& $this->createElement('radio', null, null, 'Yes', true);
  180.         $stringpainted[] =& $this->createElement('radio', null, null, 'No', false);
  181.         $this->addGroup($stringpainted, 'stringpainted', 'Render a custom string:');
  182.  
  183.         $this->addElement('text', 'stringid', 'Id:', array('size' => 32));
  184.  
  185.         $stringsize['width']   =& $this->createElement('text', 'width', null, array('size' => 4));
  186.         $stringsize['height']  =& $this->createElement('text', 'height', null, array('size' => 4));
  187.         $stringsize['bgcolor'] =& $this->createElement('text', 'bgcolor', null, array('size' => 7));
  188.         $this->addGroup($stringsize, 'stringsize', 'Size and color (width, height, bgcolor):', ', ');
  189.  
  190.         $stringvalign[] =& $this->createElement('radio', null, null, 'Left', 'left');
  191.         $stringvalign[] =& $this->createElement('radio', null, null, 'Right', 'right');
  192.         $stringvalign[] =& $this->createElement('radio', null, null, 'Top', 'top');
  193.         $stringvalign[] =& $this->createElement('radio', null, null, 'Bottom', 'bottom');
  194.         $this->addGroup($stringvalign, 'stringvalign', 'Vertical alignment:');
  195.  
  196.         $stringalign[] =& $this->createElement('radio', null, null, 'Left', 'left');
  197.         $stringalign[] =& $this->createElement('radio', null, null, 'Right', 'right');
  198.         $stringalign[] =& $this->createElement('radio', null, null, 'Center', 'center');
  199.         $this->addGroup($stringalign, 'stringalign', 'Horizontal alignment:');
  200.  
  201.         $stringfont['family'] =& $this->createElement('text', 'family', null, array('size' => 40));
  202.         $stringfont['size']   =& $this->createElement('text', 'size', null, array('size' => 2));
  203.         $stringfont['color']  =& $this->createElement('text', 'color', null, array('size' => 7));
  204.         $this->addGroup($stringfont, 'stringfont', 'Font (family, size, color):', ', ');
  205.  
  206.         $this->addElement('textarea', 'strings', 'percent, string thrown:', array('rows' => 10, 'cols' => 50));
  207.  
  208.  
  209.         $prevnext[] =& $this->createElement('submit', $this->getButtonName('back'), '<< Back');
  210.         $prevnext[] =& $this->createElement('submit', $this->getButtonName('next'), 'Next >>');
  211.         $this->addGroup($prevnext, null, '', ' ', false);       
  212.     }
  213. }
  214.  
  215. /**
  216.  *  Output page options
  217.  */
  218. class Ready extends HTML_QuickForm_Page
  219. {
  220.     function buildForm()
  221.     {
  222.         $this->_formBuilt = true;
  223.  
  224.         $tabs[] =& $this->createElement('submit', $this->getButtonName('page1'), 'Progress', array('class' => 'flat'));
  225.         $tabs[] =& $this->createElement('submit', $this->getButtonName('page2'), 'Cell', array('class' => 'flat'));
  226.         $tabs[] =& $this->createElement('submit', $this->getButtonName('page3'), 'Border', array('class' => 'flat'));
  227.         $tabs[] =& $this->createElement('submit', $this->getButtonName('page4'), 'String', array('class' => 'flat'));
  228.         $tabs[] =& $this->createElement('submit', $this->getButtonName('page5'), 'Ready', array('class' => 'flat', 'disabled' => 'disabled'));
  229.         $this->addGroup($tabs, 'tabs', null, ' ', false);
  230.  
  231.         $this->addElement('header', null, 'Output page styles');
  232.  
  233.         $outputcolor['bg']   =& $this->createElement('text', 'bg', null, array('size' => 7));
  234.         $outputcolor['fg']   =& $this->createElement('text', 'fg', null, array('size' => 7));
  235.         $outputcolor['link'] =& $this->createElement('text', 'link', null, array('size' => 7));
  236.         $this->addGroup($outputcolor, 'outputcolor', 'Color (background, foreground, link):', ', ');
  237.  
  238.         $this->addElement('text', 'outputcss', 'StyleSheet:', array('size' => 32));
  239.  
  240.         $render[] =& $this->createElement('radio', null, null, 'dump', 'dump');
  241.         $render[] =& $this->createElement('radio', null, null, 'live', 'demo');
  242.         $this->addGroup($render, 'render', 'Render:');
  243.  
  244.  
  245.         $prevnext[] =& $this->createElement('submit', $this->getButtonName('back'), '<< Back');
  246.         $prevnext[] =& $this->createElement('submit', $this->getButtonName('submit'), 'Apply');
  247.         $this->addGroup($prevnext, null, '', ' ', false);       
  248.     }
  249. }
  250.  
  251.  
  252. /**
  253.  *  Class for form rendering
  254.  */
  255. class ActionDisplay extends HTML_QuickForm_Action_Display
  256. {
  257.     function _renderForm(&$page) 
  258.     {
  259.         $renderer =& $page->defaultRenderer();
  260.  
  261.         $p = new HTML_Page(array(
  262.                  'lineend'  => OS_WINDOWS ? 'win' : 'unix',
  263.                  'doctype'  => "XHTML 1.0 Strict",
  264.                  'language' => 'en',
  265.                  'cache'    => 'false'
  266.              ));        
  267.         $p->disableXmlProlog();
  268.         $p->setTitle("PEAR::HTML_Progress - ProgressMaker");
  269.         $p->setMetaData("author", "Laurent Laville");
  270.  
  271.         $renderer->setFormTemplate('<table class="maintable"><form{attributes}>{content}</form></table>');
  272.         $renderer->setHeaderTemplate('<tr><th colspan="2">{header}</th></tr>');
  273.         $renderer->setGroupTemplate('<table><tr>{content}</tr></table>', 'name');
  274.         $renderer->setGroupElementTemplate('<td>{element}<br /><span style="font-size:10px;"><span class="label">{label}</span></span></td>', 'name');
  275.  
  276.         $page->accept($renderer);
  277.  
  278.         $css = new HTML_CSS();
  279.         $css->setStyle('body', 'background-color', '#7B7B88');
  280.         $css->setStyle('body', 'font-family', 'Verdana, Arial, helvetica');
  281.         $css->setStyle('body', 'font-size', '10pt');
  282.         $css->setStyle('h1', 'color', '#FFC');
  283.         $css->setStyle('h1', 'text-align', 'center');
  284.         $css->setStyle('.maintable', 'width', '100%');
  285.         $css->setStyle('.maintable', 'border-width', '0');
  286.         $css->setStyle('.maintable', 'border-style', 'thin dashed');
  287.         $css->setStyle('.maintable', 'border-color', '#D0D0D0');
  288.         $css->setStyle('.maintable', 'background-color', '#EEE');
  289.         $css->setStyle('.maintable', 'cellspacing', '2');
  290.         $css->setStyle('.maintable', 'cellspadding', '3');
  291.         $css->setStyle('th', 'text-align', 'center');
  292.         $css->setStyle('th', 'color', '#FFC');
  293.         $css->setStyle('th', 'background-color', '#AAA');
  294.         $css->setStyle('th', 'white-space', 'nowrap');
  295.         $css->setStyle('input', 'font-family', 'Verdana, Arial, helvetica');
  296.         $css->setStyle('input.flat', 'border-style', 'solid');
  297.         $css->setStyle('input.flat', 'border-width', '2px 2px 0px 2px');
  298.         $css->setStyle('input.flat', 'border-color', '#996');
  299.  
  300.         $p->addStyleDeclaration($css);
  301.         $p->addBodyContent( '<h1>ProgressMaker - Control Panel</h1>'. $renderer->toHtml() );
  302.     $p->display();
  303.     }
  304. }
  305.  
  306. class ActionProcess extends HTML_QuickForm_Action
  307. {
  308.     function perform(&$page, $actionName)
  309.     {
  310.         $progress = $page->controller->exportValues();
  311.  
  312.         $p = new HTML_Page(array(
  313.                  'lineend'  => OS_WINDOWS ? 'win' : 'unix',
  314.                  'doctype'  => "XHTML 1.0 Strict",
  315.                  'language' => 'en',
  316.                  'cache'    => 'false'
  317.              ));        
  318.         $p->disableXmlProlog();
  319.         $p->setTitle("PEAR::HTML_Progress - ProgressMaker");
  320.         $p->setMetaData("author", "Laurent Laville");
  321.  
  322.         $bar = new HTML_Progress();
  323.  
  324.         if ($progress['model'] != '') {
  325.             switch ($progress['model']) {
  326.              case 'ancestor.ini':
  327.                  $progress['outputcolor']['bg'] = "#444444";
  328.                  $progress['outputcolor']['fg'] = "#EEEEEE";
  329.                  $progress['outputcolor']['link'] = "yellow";
  330.                  break;
  331.              case 'bluesand.ini':
  332.                  $progress['outputcolor']['bg'] = "#EEEEEE";
  333.                  $progress['outputcolor']['fg'] = "#000000";
  334.                  $progress['outputcolor']['link'] = "navy";
  335.                  break;
  336.              case 'bullit.ini':
  337.              case 'bgimages.ini':
  338.              case 'smallest.ini':
  339.                  $progress['outputcolor']['bg'] = "#C3C6C3";
  340.                  $progress['outputcolor']['fg'] = "#000000";
  341.                  $progress['outputcolor']['link'] = "navy";
  342.                  break;
  343.             }
  344.             $bar->setModel($progress['model'], 'iniCommented');
  345.             $bar->setIncrement(10);
  346.             $ui =& $bar->getUI();
  347.         } else {
  348.             $bar->setBorderPainted(($progress['borderpainted'] == '1'));
  349.             $bar->setStringPainted(($progress['stringpainted'] == '1'));
  350.             $ui =& $bar->getUI();      
  351.         
  352.             $structure = array();
  353.  
  354.             /* Page 1: Progress attributes **************************************************/
  355.             if (strlen(trim($progress['progressclass'])) > 0) {
  356.                 $structure['progress']['class'] = $progress['progressclass'];
  357.             }
  358.             if (strlen(trim($progress['progresssize']['bgcolor'])) > 0) {
  359.                 $structure['progress']['background-color'] = $progress['progresssize']['bgcolor'];
  360.             }
  361.             if (strlen(trim($progress['progresssize']['width'])) > 0) {
  362.                 $structure['progress']['width'] = $progress['progresssize']['width'];
  363.             }
  364.             if (strlen(trim($progress['progresssize']['height'])) > 0) {
  365.                 $structure['progress']['height'] = $progress['progresssize']['height'];
  366.             }
  367.             $structure['progress']['auto-size'] = ($progress['autosize'] == '1');
  368.  
  369.             $ui->setProgressAttributes($structure['progress']);
  370.             $orient = ($progress['shape'] == '1') ? HTML_PROGRESS_BAR_HORIZONTAL : HTML_PROGRESS_BAR_VERTICAL;
  371.             $ui->setOrientation($orient);
  372.             $ui->setFillWay($progress['way']);
  373.  
  374.             /* Page 2: Cell attributes ******************************************************/
  375.             if (strlen(trim($progress['cellid'])) > 0) {
  376.                 $structure['cell']['id'] = $progress['cellid'];
  377.             }
  378.             if (strlen(trim($progress['cellclass'])) > 0) {
  379.                 $structure['cell']['class'] = $progress['cellclass'];
  380.             }
  381.             if (strlen(trim($progress['cellvalue']['min'])) > 0) {
  382.                 $bar->setMinimum(intval($progress['cellvalue']['min']));
  383.             }
  384.             if (strlen(trim($progress['cellvalue']['max'])) > 0) {
  385.                 $bar->setMaximum(intval($progress['cellvalue']['max']));
  386.             }
  387.             if (strlen(trim($progress['cellvalue']['inc'])) > 0) {
  388.                 $bar->setIncrement(intval($progress['cellvalue']['inc']));
  389.             }
  390.             if (strlen(trim($progress['cellsize']['width'])) > 0) {
  391.                 $structure['cell']['width'] = $progress['cellsize']['width'];
  392.             }
  393.             if (strlen(trim($progress['cellsize']['height'])) > 0) {
  394.                 $structure['cell']['height'] = $progress['cellsize']['height'];
  395.             }
  396.             if (strlen(trim($progress['cellsize']['spacing'])) > 0) {
  397.                 $structure['cell']['spacing'] = $progress['cellsize']['spacing'];
  398.             }
  399.             if (strlen(trim($progress['cellsize']['count'])) > 0) {
  400.                 $ui->setCellCount(intval($progress['cellsize']['count']));
  401.             }
  402.             if (strlen(trim($progress['cellcolor']['active'])) > 0) {
  403.                 $structure['cell']['active-color'] = $progress['cellcolor']['active'];
  404.             }
  405.             if (strlen(trim($progress['cellcolor']['inactive'])) > 0) {
  406.                 $structure['cell']['inactive-color'] = $progress['cellcolor']['inactive'];
  407.             }
  408.             if (strlen(trim($progress['cellfont']['family'])) > 0) {
  409.                 $structure['cell']['font-family'] = $progress['cellfont']['family'];
  410.             }
  411.             if (strlen(trim($progress['cellfont']['size'])) > 0) {
  412.                 $structure['cell']['font-size'] = $progress['cellfont']['size'];
  413.             }
  414.             if (strlen(trim($progress['cellfont']['color'])) > 0) {
  415.                 $structure['cell']['color'] = $progress['cellfont']['color'];
  416.             }
  417.             $ui->setCellAttributes($structure['cell']);
  418.  
  419.             /* Page 3: Border attributes ****************************************************/
  420.             if (strlen(trim($progress['borderclass'])) > 0) {
  421.                 $structure['border']['class'] = $progress['borderclass'];
  422.             }
  423.             if (strlen(trim($progress['borderstyle']['width'])) > 0) {
  424.                 $structure['border']['width'] = $progress['borderstyle']['width'];
  425.             }
  426.             if (strlen(trim($progress['borderstyle']['style'])) > 0) {
  427.                 $structure['border']['style'] = $progress['borderstyle']['style'];
  428.             }
  429.             if (strlen(trim($progress['borderstyle']['color'])) > 0) {
  430.                 $structure['border']['color'] = $progress['borderstyle']['color'];
  431.             }
  432.             $ui->setBorderAttributes($structure['border']);
  433.  
  434.             /* Page 4: String attributes ****************************************************/
  435.             if (strlen(trim($progress['stringid'])) > 0) {
  436.                 $structure['string']['id'] = $progress['stringid'];
  437.             }
  438.             if (strlen(trim($progress['stringsize']['width'])) > 0) {
  439.                 $structure['string']['width'] = $progress['stringsize']['width'];
  440.             }
  441.             if (strlen(trim($progress['stringsize']['height'])) > 0) {
  442.                 $structure['string']['height'] = $progress['stringsize']['height'];
  443.             }
  444.             if (strlen(trim($progress['stringsize']['bgcolor'])) > 0) {
  445.                 $structure['string']['background-color'] = $progress['stringsize']['bgcolor'];
  446.             }
  447.             if (strlen(trim($progress['stringalign'])) > 0) {
  448.                 $structure['string']['align'] = $progress['stringalign'];
  449.             }
  450.             if (strlen(trim($progress['stringvalign'])) > 0) {
  451.                 $structure['string']['valign'] = $progress['stringvalign'];
  452.             }
  453.             if (strlen(trim($progress['stringfont']['family'])) > 0) {
  454.                 $structure['string']['font-family'] = $progress['stringfont']['family'];
  455.             }
  456.             if (strlen(trim($progress['stringfont']['size'])) > 0) {
  457.                 $structure['string']['font-size'] = $progress['stringfont']['size'];
  458.             }
  459.             if (strlen(trim($progress['stringfont']['color'])) > 0) {
  460.                 $structure['string']['color'] = $progress['stringfont']['color'];
  461.             }
  462.             $ui->setStringAttributes($structure['string']);
  463.  
  464.     } // end-if-no-model
  465.  
  466.  
  467.         $css = new HTML_CSS();
  468.         $css->setStyle('body', 'background-color', $progress['outputcolor']['bg']);
  469.         $css->setStyle('body', 'color', $progress['outputcolor']['fg']);
  470.         $css->setStyle('body', 'font-family', 'Verdana, Arial');
  471.         $css->setStyle('a:link', 'color', $progress['outputcolor']['link']);
  472.         $css->setSameStyle('a:visited, a:active', 'a:link');
  473.         $css->setStyle('div.frame', 'margin-left', '10%');
  474.         $css->setStyle('div.frame', 'margin-right', '10%');
  475.         $css->setStyle('div.frame', 'border', '1px solid '.$progress['outputcolor']['link']);
  476.         $css->setStyle('div.frame', 'padding', '1em');
  477.  
  478.         if ($progress['render'] == 'dump') {
  479.             $p->addBodyContent('<pre>');
  480.             ob_start();
  481.             print_r($bar->toArray());
  482.             if (function_exists('ob_get_clean')) {
  483.                 $structure  = ob_get_clean();      // use for PHP 4.3+
  484.             } else {
  485.                 $structure  = ob_get_contents();   // use for PHP 4.2+
  486.                 ob_end_clean();
  487.             }
  488.             $p->addBodyContent($structure);
  489.             ob_get_contents();
  490.             
  491.             $p->addBodyContent('</pre>');
  492.         } else {
  493.             $p->addStyleSheet($progress['outputcss']);
  494.             $p->addStyleDeclaration( $bar->getStyle() . $css->toString() );
  495.             $p->addScriptDeclaration( $ui->getScript() );
  496.             $p->addBodyContent('<div class="frame">');
  497.             $p->addBodyContent('<h1>ProgressMaker</h1>');
  498.             $p->addBodyContent('<i>powered by HTML_Progress 1.0</i>');
  499.             $p->addBodyContent('<p><i><b>Laurent Laville, November 2003</b></i></p>');
  500.             $p->addBodyContent('<p><< <a href="'.getenv('SCRIPT_NAME').'">Replay</a></p>');
  501.             $p->addBodyContent( $bar->toHtml() );
  502.             $p->addBodyContent('</div>');
  503.     }
  504.         $p->display();
  505.  
  506.         if ($progress['render'] == 'demo') {
  507.             do {
  508.                 $percent = $bar->getPercentComplete();
  509.                 if ($bar->isStringPainted()) {
  510.                     if (substr($progress['strings'], -1) == ";") {
  511.                         $strings = explode(";", $progress['strings']);
  512.                     } else {
  513.                         $strings = explode(";", $progress['strings'].";");
  514.                     }
  515.                     for ($i=0; $i<count($strings)-1; $i++) {
  516.                         list ($p, $s) = explode(",", $strings[$i]);
  517.                         if ($percent == floatval($p)/100) {
  518.                             $bar->setString(trim($s));
  519.                         }
  520.                     }
  521.                 }
  522.                 $bar->display();
  523.                 if ($percent == 1) {
  524.                     break;   // the progress bar has reached 100%
  525.                 }
  526.                 $bar->incValue();
  527.             } while(1);
  528.         }
  529.     }
  530. }
  531.  
  532. session_start();
  533.  
  534. $tabbed = new HTML_QuickForm_Controller('Tabbed', false);
  535.  
  536. $tabbed->addPage(new Property1('page1'));
  537. $tabbed->addPage(new Property2('page2'));
  538. $tabbed->addPage(new Property3('page3'));
  539. $tabbed->addPage(new Property4('page4'));
  540. $tabbed->addPage(new Ready('page5'));
  541.  
  542. // These actions manage going directly to the pages with the same name
  543. $tabbed->addAction('page1', new HTML_QuickForm_Action_Direct());
  544. $tabbed->addAction('page2', new HTML_QuickForm_Action_Direct());
  545. $tabbed->addAction('page3', new HTML_QuickForm_Action_Direct());
  546. $tabbed->addAction('page4', new HTML_QuickForm_Action_Direct());
  547. $tabbed->addAction('page5', new HTML_QuickForm_Action_Direct());
  548.  
  549. // We actually add these handlers here for the sake of example
  550. // They can be automatically loaded and added by the controller
  551. $tabbed->addAction('jump', new HTML_QuickForm_Action_Jump());
  552. $tabbed->addAction('submit', new HTML_QuickForm_Action_Submit());
  553.  
  554. // The customized actions
  555. $tabbed->addAction('display', new ActionDisplay());
  556. $tabbed->addAction('process', new ActionProcess());
  557.  
  558. $sess = $tabbed->container();
  559. $defaults = $sess['defaults'];
  560.  
  561. if (count($sess['defaults']) == 0) {
  562.   // ProgressBar default values
  563.   $tabbed->setDefaults(array(
  564.     'progressclass' => 'progressBar',
  565.     'shape'         => HTML_PROGRESS_BAR_HORIZONTAL,
  566.     'way'           => 'natural',
  567.     'autosize'      => true,
  568.     'progresssize'  => array('bgcolor' => '#FFFFFF'),
  569.  
  570.     'borderpainted' => false,
  571.     'borderclass'   => 'progressBarBorder',
  572.     'borderstyle'   => array('style' => 'solid', 'width' => 0, 'color' => '#000000'),
  573.  
  574.     'cellid'        => 'progressCell%01s',
  575.     'cellclass'     => 'cell',
  576.     'cellvalue'     => array('min' => 0, 'max' => 100, 'inc' => 1),
  577.     'cellsize'      => array('width' => 15, 'height' => 20, 'spacing' => 2, 'count' => 10),
  578.     'cellcolor'     => array('active' => '#006600', 'inactive' => '#CCCCCC'),
  579.     'cellfont'      => array('family' => 'Courier, Verdana', 'size' => 8, 'color' => '#000000'),
  580.  
  581.     'stringpainted' => false,
  582.     'stringid'      => 'installationProgress',
  583.     'stringsize'    => array('width' => 50, 'height' => '', 'bgcolor' => '#FFFFFF'),
  584.     'stringvalign'  => 'right',
  585.     'stringalign'   => 'right',
  586.     'stringfont'    => array('family' => 'Verdana, Arial, Helvetica, sans-serif', 'size' => 12, 'color' => '#000000'),
  587.     'strings'       => implode(";\n", array(
  588.                            0 => '10,Hello world',
  589.                            1 => '20,Welcome',
  590.                            2 => '30,to',
  591.                            3 => '40,HTML_Progress 1.0',
  592.                            4 => '60,by',
  593.                            5 => '70,Laurent Laville',
  594.                            6 => '100,Have a nice day !'
  595.                        )),
  596.     'outputcolor'   => array('bg' => '#FFFFFF', 'fg' => '#000000', 'link' => 'navy'),
  597.     'outputcss'     => '',
  598.     'render'        => 'demo'
  599.   ));
  600. }
  601.  
  602. $tabbed->run();
  603.  
  604. ?>
  605.