cvs: pear /HTML_Progress/tutorials/HTML_Progress/examples indeterminate.php monitor_indeterminate.php
| From: | Laurent Laville | Date: | Sat, 11 Sep 2004 23:41:18 +0000 |
| Subject: | cvs: pear /HTML_Progress/tutorials/HTML_Progress/examples indeterminate.php monitor_indeterminate.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-23847@lists.php.net to get a copy of this message | ||
farell Sat Sep 11 19:41:18 2004 EDT
Added files:
/pear/HTML_Progress/tutorials/HTML_Progress/examples
indeterminate.php
monitor_indeterminate.php
Log:
adds indeterminate mode examples (basic and monitor)
http://cvs.php.net/co.php/pear/HTML_Progress/tutorials/HTML_Progress/examples/indeterminate.php?r=1.1&p=1
Index: pear/HTML_Progress/tutorials/HTML_Progress/examples/indeterminate.php
+++ pear/HTML_Progress/tutorials/HTML_Progress/examples/indeterminate.php
<?php
require_once 'HTML/Progress.php';
function myProgressHandler($progressValue, &$bar)
{
static $c;
static $t;
if (!isset($c)) {
$c = time();
$t = 0;
}
// wait a bit ...
$bar->sleep();
if ($bar->isIndeterminate()) {
$elapse = time() - $c;
if ($elapse > $t) {
echo "myProgressHandler -> elapse time = $elapse s.<br/>\n";
$t++;
}
/* rules to determine when switch back
from indeterminate to determinate mode
*/
if ($elapse >= 12) {
$bar->setIndeterminate(false);
$bar->setValue(0);
$bar->setString(null);
$bar->setIncrement(1);
}
}
}
$progress = new HTML_Progress();
$progress->setAnimSpeed(200);
$progress->setIncrement(10);
$progress->setStringPainted(true); // get space for the string
$progress->setString(""); // but don't paint it
$progress->setIndeterminate(true); // Progress start in indeterminate mode
$progress->setProgressHandler('myProgressHandler');
$ui = & $progress->getUI();
$ui->setProgressAttributes('background-color = #e0e0e0');
$ui->setStringAttributes(array(
'color' => '#996',
'background-color' => '#CCCC99'
));
$ui->setCellAttributes('active-color = #996');
?>
<html>
<head>
<title>Basic Indeterminate Mode </title>
<style type="text/css">
<!--
body {
background-color: #CCCC99;
color: #996;
font-family: Verdana, Arial;
}
<?php echo $progress->getStyle(); ?>
// -->
</style>
<script type="text/javascript">
<!--
<?php echo $progress->getScript(); ?>
//-->
</script>
</head>
<body>
<?php
echo $progress->toHtml();
$progress->run();
?>
</body>
</html>
http://cvs.php.net/co.php/pear/HTML_Progress/tutorials/HTML_Progress/examples/monitor_indeterminate.php?r=1.1&p=1
Index: pear/HTML_Progress/tutorials/HTML_Progress/examples/monitor_indeterminate.php
+++ pear/HTML_Progress/tutorials/HTML_Progress/examples/monitor_indeterminate.php
<?php
require_once 'HTML/Progress/monitor.php';
function myProgressHandler($progressValue, &$obj)
{
static $c;
if (!isset($c)) {
$c = 0;
}
$c += 16;
$obj->setCaption("completed $c out of 400");
$bar =& $obj->getProgressElement();
/* rules to determine when switch back
from indeterminate to determinate mode
*/
if ($c >= 240 && $bar->isIndeterminate()) {
$bar->setIndeterminate(false);
$bar->setString(null); // show percent-info
$bar->setValue(0);
}
if ($bar->getPercentComplete() == 1) {
if ($bar->isIndeterminate()) {
$bar->setValue(0);
} else {
$bar->setString(''); // hide percent-info
}
}
}
$monitor = new HTML_Progress_Monitor('frmMonitor',
array( 'button' => array('style' => 'width:80px;'),
'title' => 'Progress ...' )
);
// your custom user process goes here !
$monitor->setProgressHandler('myProgressHandler');
// Attach a progress bar custom model
$progress = new HTML_Progress();
$ui = & $progress->getUI();
$ui->setProgressAttributes(array(
'background-color' => '#e0e0e0'
));
$ui->setStringAttributes(array(
'color' => '#996',
'background-color' => '#CCCC99'
));
$ui->setCellAttributes(array(
'active-color' => '#996'
));
$progress->setAnimSpeed(100);
$progress->setIncrement(10);
$progress->setStringPainted(true);
$progress->setString("");
$progress->setIndeterminate(true);
$monitor->setProgressElement($progress);
?>
<html>
<head>
<title>Indeterminate Mode Progress example</title>
<style type="text/css">
<!--..progressStatus {
color:#000000;
font-size:10px;
}
body {
background-color: #444444;
color: #EEEEEE;
font-family: Verdana, Arial;
}
<?php echo $monitor->getStyle(); ?>
// -->
</style>
<script type="text/javascript">
<!--
<?php echo $monitor->getScript(); ?>
//-->
</script>
</head>
<body>
<?php
$renderer =& HTML_QuickForm::defaultRenderer();
$renderer->setFormTemplate('
<table width="450" border="0" cellpadding="3"
cellspacing="2" bgcolor="#CCCC99">
<form{attributes}>{content}
</form>
</table>
');
$renderer->setHeaderTemplate('
<tr>
<td style="white-space:nowrap;background:#996;color:#ffc;" align="left"
colspan="2">
<b>{header}</b>
</td>
</tr>
');
$monitor->accept($renderer);
// Display progress monitor dialog box
echo $renderer->toHtml();
$monitor->run();
?>
</body>
</html>