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

  1. <?php 
  2. /**
  3.  * Complex Monitor ProgressBar example.
  4.  *
  5.  * @version    $Id: monitor_complex.php,v 1.1 2003/11/15 18:27:10 thesaur Exp $
  6.  * @author     Laurent Laville <pear@laurent-laville.org>
  7.  * @package    HTML_Progress
  8.  */
  9.  
  10. require_once ('HTML/Progress/monitor.php');
  11. require_once ('HTML/QuickForm/Renderer/ITStatic.php');
  12. require_once ('HTML/Template/ITX.php');
  13.  
  14. class ProgressMonitor extends HTML_Progress_Monitor
  15. {
  16.     
  17.     function ProgressMonitor()
  18.     {
  19.         $this->_id = md5(microtime());
  20.  
  21.         $this->_form = new HTML_QuickForm('form');
  22.         
  23.         $this->_form->addElement('header', 'windowsname', 'Progress...');
  24.         $this->_form->addElement('static', 'progress');
  25.         $this->_form->addElement('submit', 'cancel', 'Cancel');
  26.         
  27.         $this->attachProgress();
  28.     }
  29.  
  30.     function attachProgress()
  31.     {
  32.         $this->_progress = new HTML_Progress();
  33.         $this->_progress->setIncrement(10);
  34.  
  35.         $ui =& $this->_progress->getUI();
  36.         $ui->setProgressAttributes('background-color=#EEE');
  37.         $ui->setCellAttributes('inactive-color=#FFF active-color=#444444');
  38.         $ui->setStringAttributes('background-color=#EEE color=navy');
  39.  
  40.         $this->_progress->addListener($this);
  41.         
  42.         $bar =& $this->_form->getElement('progress');
  43.         $bar->setText( $this->_progress->toHtml() );
  44.     }
  45.  
  46.     function toHtml()
  47.     {
  48.         $tpl =& new HTML_Template_ITX('.');
  49.         $tpl->loadTemplateFile('monitor.html');
  50.  
  51.         $js  = $this->getScript();
  52.         $css = $this->getStyle();
  53.         $tpl->setVariable("monitor_script", $js);
  54.         $tpl->setVariable("monitor_style", $css);
  55.  
  56.         $renderer =& new HTML_QuickForm_Renderer_ITStatic($tpl);       
  57.         $this->_form->accept($renderer);
  58.         return $tpl->get();
  59.     }
  60.  
  61.     function display()
  62.     {
  63.         print $this->toHtml();
  64.     }
  65. }
  66.  
  67. $progressMonitor = new ProgressMonitor();
  68. $progressMonitor->display();
  69. $progressMonitor->run();
  70.  
  71. ?>
  72.