cvs: pear /HTML_Progress/tutorials/HTML_Progress HTML_Progress.pkg indeterminate.pkg

From: Date: Wed, 05 May 2004 18:26:17 +0000
Subject: cvs: pear /HTML_Progress/tutorials/HTML_Progress HTML_Progress.pkg indeterminate.pkg
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-19238@lists.php.net to get a copy of this message
farell Wed May 5 14:26:17 2004 EDT Modified files: /pear/HTML_Progress/tutorials/HTML_Progress HTML_Progress.pkg indeterminate.pkg Log: indeterminate tutorial is now up-to-date with versions HTML_Progress 1.1+

http://cvs.php.net/diff.php/pear/HTML_Progress/tutorials/HTML_Progress/HTML_Progress.pkg?r1=1.2&r2=1.3&ty=u Index: pear/HTML_Progress/tutorials/HTML_Progress/HTML_Progress.pkg diff -u pear/HTML_Progress/tutorials/HTML_Progress/HTML_Progress.pkg:1.2 pear/HTML_Progress/tutorials/HTML_Progress/HTML_Progress.pkg:1.3 --- pear/HTML_Progress/tutorials/HTML_Progress/HTML_Progress.pkg:1.2 Sun Apr 18 10:35:28 2004 +++ pear/HTML_Progress/tutorials/HTML_Progress/HTML_Progress.pkg Wed May 5 14:26:17 2004 @@ -9,8 +9,8 @@ by Laurent Laville <authorblurb>{@link mailto:pear@laurent-laville.org}</authorblurb> </author> - <copyright>March 2004, Laurent Laville</copyright> - <releaseinfo>HTML_Progress 1.2</releaseinfo> + <copyright>May 2004, Laurent Laville</copyright> + <releaseinfo>HTML_Progress 1.2.0</releaseinfo> </refsynopsisdivinfo> </refsynopsisdiv> {@toc} @@ -50,8 +50,11 @@ </unorderedlist> </para> </listitem> - <listitem><emphasis>2004-03-xx (version 1.2)</emphasis> + <listitem><emphasis>2004-05-xx (version 1.2)</emphasis> <para> + <unorderedlist> + <listitem>new shapes such as <important>circle, ellipse, square, rectangle</important> are allowed.</listitem> + </unorderedlist> </para> </listitem> </unorderedlist> @@ -72,29 +75,6 @@ bar to show activity before the task's scope is known. </para> </listitem> - <listitem>Error_Raise - <author> - by Greg Beaver - <authorblurb>{@link mailto:cellog@php.net}</authorblurb> - </author> - <para>The Error_Raise static class contains tremendously simple and powerful - error management based on error codes. - </para> - </listitem> - <listitem>Error_Util - <author> - by Greg Beaver - <authorblurb>{@link mailto:cellog@php.net}</authorblurb> - </author> - <para>This class is used for advanced retrieval of context information, and for - callback validation. It also has a few miscellaneous functions for processing - display of variables. - </para> - </listitem> - <para>Until this package is accepted as a PEAR package, it can be downloaded at - {@link http://www.chiaraquartet.net/Error_Raise-0.2.2.tgz}, and was integrated - in {@link http://pear.php.net/package/HTML_Progress HTML_Progress} package. - </para> </unorderedlist> </para> </refsect2> http://cvs.php.net/diff.php/pear/HTML_Progress/tutorials/HTML_Progress/indeterminate.pkg?r1=1.3&r2=1.4&ty=u Index: pear/HTML_Progress/tutorials/HTML_Progress/indeterminate.pkg diff -u pear/HTML_Progress/tutorials/HTML_Progress/indeterminate.pkg:1.3 pear/HTML_Progress/tutorials/HTML_Progress/indeterminate.pkg:1.4 --- pear/HTML_Progress/tutorials/HTML_Progress/indeterminate.pkg:1.3 Sun Apr 18 10:35:28 2004 +++ pear/HTML_Progress/tutorials/HTML_Progress/indeterminate.pkg Wed May 5 14:26:17 2004 @@ -9,8 +9,8 @@ by Laurent Laville <authorblurb>{@link mailto:pear@laurent-laville.org}</authorblurb> </author> - <copyright>April 2004, Laurent Laville</copyright> - <releaseinfo>HTML_Progress 1.2+</releaseinfo> + <copyright>May 2004, Laurent Laville</copyright> + <releaseinfo>HTML_Progress 1.1+</releaseinfo> </refsynopsisdivinfo> </refsynopsisdiv> {@toc} @@ -29,260 +29,9 @@ </refsect1> <refsect1 id="{@id useit}"> <title>Using Indeterminate Mode</title> - <para> - In example that follow, we have created a Task Class that extends the default monitoring - {@link HTML_Progress_Monitor} class. - </para> - <para> - The most important code additions are calls to the {@link HTML_Progress::setIndeterminate()} - method. When the user clicks the Start button, <important>setIndeterminate(true)</important> - is invoked ({@tutorial indeterminate.pkg#useit.ex-listing line 143}) so that the user can tell - that the task as started, even before any meaningful information about the task's progress - can be conveyed. Once the progress bar has some concrete status to display, a call to - <important>setIndeterminate(false)</important> ({@tutorial indeterminate.pkg#useit.ex-listing line 76}) - switches the progress bar back into its normal mode. The {@link HTML_Progress::isIndeterminate()} - method ({@tutorial indeterminate.pkg#useit.ex-listing line 75}) is used to test the - progress bar's current state. + <para>If you want to know more and learn how to use indeterminate mode + of HTML_Progress 1.1+, read article + {@link http://www.laurent-laville.org/spip/article.php3?id_article=15 Indeterminate Mode}. </para> - <para> - The other changes in the code are related to string display. A progress bar that displays - a string is likely to be taller than one that doesn't, and, as the demo designers, - we've arbitarily decided that this progress bar should display a string only when - it's in the default, determinate mode. However, we want to avoid the layout ugliness - that might result if the progress bar changed height when it changed modes. - Thus, the code leaves in the call to {@link HTML_Progress::setStringPainted()} method - with <emphasis>true</emphasis> value ({@tutorial indeterminate.pkg#useit.ex-listing line 39}), - but adds a call to {@link HTML_Progress::setString()} method - ({@tutorial indeterminate.pkg#useit.ex-listing line 40}) with <emphasis>empty string</emphasis> - value, so that no text will be displayed. Later, when the progress bar switches from - indeterminate to determinate mode, invoking <important>setString(null)</important> - ({@tutorial indeterminate.pkg#useit.ex-listing line 77}) makes the progress bar display - its default string. - </para> - <para> - One change we did not make was removing the call to {@link HTML_Progress::setValue()} from - the timer's action handler (notify method). The call doesn't do any harm because an - indeterminate progress bar doesn't use its value property, except perharps to display it in - the status string. In fact, keeping the progress bar's data as up-to-date as possible is a - good practice, since some look and feels might not support indeterminate mode. - </para> - <refsect2 id="{@id ex-listing}"> - <title>Full example listing</title> - <programlisting role="php"> - <![CDATA[ -<?php -require_once ('HTML/Progress/monitor.php'); - -class Task extends HTML_Progress_Monitor -{ - var $_current; - - function Task() - { - $this->_current = 0; - $this->_id = md5(microtime()); - - $this->_form = new HTML_QuickForm('ProgressBarDialog'); - - $renderer =& $this->_form->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> - '); - - $this->_form->addElement('header', 'windowsname', 'Progress...'); - $this->_form->addElement('static', 'progress'); - $this->_form->addElement('static', 'status'); - - $buttons[] = &HTML_QuickForm::createElement('submit', 'start', 'Start', 'style="width:80px;"'); - $buttons[] = &HTML_QuickForm::createElement('submit', 'cancel', 'Cancel', 'style="width:80px;"'); - $this->_form->addGroup($buttons); - - - $this->_progress = new HTML_Progress(); - $this->_progress->setAnimSpeed(100); - $this->_progress->setIncrement(10); - $this->_progress->setStringPainted(true); // get space for the string - $this->_progress->setString(""); // but don't paint it - - $ui = & $this->_progress->getUI(); - $ui->setProgressAttributes(array( - 'background-color' => '#e0e0e0' - )); - $ui->setStringAttributes(array( - 'color' => '#996', - 'background-color' => '#CCCC99' - )); - $ui->setCellAttributes(array( - 'active-color' => '#996' - )); - - $bar =& $this->_form->getElement('progress'); - $bar->setText( $this->_progress->toHtml() ); - - $str =& $this->_form->getElement('status'); - $str->setText('<div id="status" style="color:#000000; font-size:10px;">&nbsp;</div>'); - - $this->_progress->addListener($this); - } - - function notify($event) - { - if (is_array($event)) { - $log = strtolower($event['log']); - $val = $event['value']; - - switch (strtolower($log)) { - case 'incvalue': - case 'setvalue': - $this->_current = $this->getCurrent() + 16; - $s = $this->getMessage(); - if (!is_null($s)) { - if ($this->_progress->isIndeterminate()) { - $this->_progress->setIndeterminate(false); - $this->_progress->setString(null); // display % string - $this->_progress->setValue(0); - } - if ($this->isDone()) { - $this->_progress->removeListener($this); - $this->_progress->setString(""); // hide % string - } - } - $this->_progress->display(); - - if ($this->_progress->getPercentComplete() == 1) { - if ($this->_progress->isIndeterminate()) { - $this->_progress->setValue(0); - } - } else { - $this->_progress->incValue(); - } - break; - default: - } - } - } - - function getCurrent() - { - return $this->_current; - } - - function getMessage() - { - $c = $this->getCurrent(); - $s = "completed $c out of 416"; - - if (function_exists('ob_get_clean')) { - $status = ob_get_clean(); // use for PHP 4.3+ - } else { - $status = ob_get_contents(); // use for PHP 4.2+ - ob_end_clean(); - } - $status = '<script type="text/javascript">self.setStatus("'.$s.'"); </script>'; - echo $status; - ob_start(); - - if ($c >= 240 ) { - return $s; - } else { - return null; - } - } - - function isDone() - { - return ( ($this->_progress->getPercentComplete() == 1) && - ($this->_progress->isIndeterminate() == false) ); - } - - - function isStarted() - { - $action = $this->_form->getSubmitValues(); - - if (isset($action['start'])) { - return true; - } - - return false; - } - - function run() - { - if ($this->isStarted()) { - $this->_progress->setIndeterminate(true); - $this->_progress->incValue(); - - } else { - $abort = $this->isCanceled(); - } - } - -} - -$task = new Task(); - -?> -<!DOCTYPE html - PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> -<head> -<title>Indeterminate Mode Progress example</title> -<style type="text/css"> -<!-- -<?php echo $task->getStyle(); ?> - -body { - background-color: #444444; - color: #EEEEEE; - font-family: Verdana, Arial; -} - -a:visited, a:active, a:link { - color: yellow; -} -// --> -</style> -<script type="text/javascript"> -<!-- -<?php echo $task->getScript(); ?> - -function setStatus(pString) -{ - if (isDom) - prog = document.getElementById('status'); - if (isIE) - prog = document.all['status']; - if (isNS4) - prog = document.layers['status']; - if (prog != null) - prog.innerHTML = pString; -} -//--> -</script> -</head> -<body> - -<?php -echo $task->toHtml(); - -$task->run(); -?> - -</body> -</html> - ]]> - </programlisting> - </refsect2> </refsect1> </refentry>
« previous php.pear.cvs (#19238) next »