/lib/php/HTML/tutorials/HTML_Progress/examples/setstring.php
PHP | 57 lines | 48 code | 7 blank | 2 comment | 5 complexity | a9dc03125a7cccc2a863b3516ded5b98 MD5 | raw file
Possible License(s): Apache-2.0, MPL-2.0-no-copyleft-exception, LGPL-2.1, BSD-2-Clause, GPL-2.0, LGPL-3.0
- <?php
- require_once 'HTML/Progress.php';
-
- $bar = new HTML_Progress();
- $bar->setAnimSpeed(100);
- $bar->setIncrement(5);
- $bar->setStringPainted(true); // get space for the string
- $bar->setString(''); // but don't paint it
-
- $ui =& $bar->getUI();
- $ui->setStringAttributes('width=350 align=left');
- ?>
- <html>
- <head>
- <title>setString example</title>
- <style type="text/css">
- <!--
- <?php echo $bar->getStyle(); ?>
- // -->
- </style>
- <script type="text/javascript">
- <!--
- <?php echo $bar->getScript(); ?>
- //-->
- </script>
- </head>
- <body>
-
- <?php
- echo $bar->toHtml();
-
- $pkg = array('PEAR', 'Archive_Tar', 'Config',
- 'HTML_QuickForm', 'HTML_CSS', 'HTML_Page', 'HTML_Template_Sigma',
- 'Log', 'MDB', 'PHPUnit');
-
- do {
- $val = $bar->getValue();
- $i = floor($val / 10);
- if ($val == 100) {
- $msg = '';
- } else {
- $msg = " installing package ($val %) ... : ";
- $msg .= $pkg[$i];
- }
- $bar->setString($msg);
-
- $bar->display();
- if ($bar->getPercentComplete() == 1) {
- break; // the progress bar has reached 100%
- }
- $bar->sleep(); // for purpose of demo only
- $bar->incValue();
- } while(1);
- ?>
-
- </body>
- </html>