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

  1. <?php 
  2. /**
  3.  * Display a horizontal loading bar embedded into 
  4.  * a ITx template system file. 
  5.  * 
  6.  * @version    $Id: template_embedded.php,v 1.2 2003/11/16 17:41:30 farell Exp $
  7.  * @author     Laurent Laville <pear@laurent-laville.org>
  8.  * @package    HTML_Progress
  9.  */
  10.  
  11. require_once ('HTML/QuickForm.php');
  12. require_once ('HTML/QuickForm/Renderer/ITStatic.php');
  13. require_once ('HTML/Template/ITX.php');
  14. require_once ('HTML/Progress.php');
  15.  
  16.  
  17. $tpl = new HTML_Template_ITX('.');
  18. $tpl->loadTemplateFile('installing.html');
  19.         
  20. $vars = array (    
  21.     "L_SETUP_APP_TITLE"    => "SW4P",
  22.     "L_APPNAME"            => basename(__FILE__),
  23.     "L_APPCOPYRIGHT"       => "© 2003 SW4P Team ",
  24. );
  25. $tpl->setVariable($vars);
  26.  
  27. $form = new HTML_QuickForm('form');
  28. $form->addElement('submit', 'launch', 'Launch', 'style="width:100px;"');
  29.  
  30. $styles = array('none' => 'none',
  31.   'solid'  => 'solid',
  32.   'dashed' => 'dashed',
  33.   'dotted' => 'dotted',
  34.   'inset'  => 'inset',
  35.   'outset' => 'outset'
  36. );
  37. $form->addElement('select','border','border style:',$styles);
  38.  
  39. $colors = array('#FFFFFF' => 'white', '#0000FF'=> 'blue', '#7B7B88' => '#7B7B88');
  40. $form->addElement('select','color','border color:',$colors);
  41.  
  42. $defaultValues['border'] = 'solid';
  43. $defaultValues['color']  = '#7B7B88';
  44. $form->setDefaults($defaultValues);
  45.  
  46. if ($form->validate()) {
  47.     $arr = $form->getElementValue('border');
  48.     $border = $arr[0];
  49.     $arr = $form->getElementValue('color');
  50.     $color = $arr[0];
  51. } else {
  52.     $border = $defaultValues['border'];
  53.     $color  = $defaultValues['color'];
  54. }
  55.  
  56.  
  57. $bar = new HTML_Progress();
  58. $bar->setIncrement(10);
  59. $bar->setBorderPainted(true);
  60. $bar->setStringPainted(true);          // get space for the string
  61. $bar->setString('');                   // but don't paint it
  62.  
  63. $ui =& $bar->getUI();
  64. $ui->setCellAttributes('active-color=#7B7B88 inactive-color=#D0D0D0 width=10');
  65. $ui->setBorderAttributes(array(
  66.     'width' => 2,
  67.     'color' => $color,
  68.     'style' => $border
  69. ));
  70. $ui->setStringAttributes(array(
  71.     'width' => 320,
  72.     'font-size' => 10,
  73.         'align' => 'left',
  74.         'valign' => 'bottom',
  75.     'background-color' => '#D0D0D0'  // make it transparent, see styles.css file (#MainWindow)
  76. ));
  77. $ui->setProgressAttributes('width=320');
  78.  
  79. $tpl->setVariable("L_STYLESHEET", $bar->getStyle() );
  80. $tpl->setVariable("L_JAVASCRIPT", $ui->getScript() );
  81. $tpl->setVariable("L_PROGRESS_BAR", $bar->toHtml() );
  82.  
  83. $renderer = new HTML_QuickForm_Renderer_ITStatic($tpl);
  84. $form->accept($renderer);
  85.  
  86. $tpl->show();
  87.  
  88. do {
  89.     $str = ' ';
  90.  
  91.     if ($bar->getPercentComplete() > 0.25) {
  92.         $str = ' - DB schema generated';
  93.     }
  94.     if ($bar->getPercentComplete() > 0.5) {
  95.         $str = ' - Config file created';
  96.     }
  97.     if ($bar->getPercentComplete() == 1) {
  98.         $str = ' - All done !';
  99.     }
  100.     $percent = $bar->getPercentComplete()*100;
  101.     $bar->setString( sprintf("Installation in progress ... %01s%s %s", $percent, '%', $str) );
  102.  
  103.     $bar->display();
  104.     if ($bar->getPercentComplete() == 1) {
  105.         break;   // the progress bar has reached 100%
  106.     }
  107.     $bar->incValue();
  108. } while(1);
  109.  
  110. echo '<p><< <a href="index.html">Back examples TOC</a></p>';
  111.  
  112. ?>