Example #1
0
 /**
  * The progress bar's UI extended model class constructor
  *
  * @param      string    $file          file name of model properties
  * @param      string    $type          type of external ressource (phpArray, iniFile, XML ...)
  *
  * @since      1.0
  * @access     public
  * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  */
 function HTML_Progress_Model($file, $type)
 {
     $this->_package = 'HTML_Progress';
     if (!file_exists($file)) {
         return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$file', 'was' => $file, 'expected' => 'file exists', 'paramnum' => 1));
     }
     $conf = new Config();
     if (!$conf->isConfigTypeRegistered($type)) {
         return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$type', 'was' => $type, 'expected' => implode(" | ", array_keys($GLOBALS['CONFIG_TYPES'])), 'paramnum' => 2));
     }
     $data = $conf->parseConfig($file, $type);
     $structure = $data->toArray(false);
     $this->_progress =& $structure['root'];
     if (is_array($this->_progress['cell']['font-family'])) {
         $this->_progress['cell']['font-family'] = implode(",", $this->_progress['cell']['font-family']);
     }
     if (is_array($this->_progress['string']['font-family'])) {
         $this->_progress['string']['font-family'] = implode(",", $this->_progress['string']['font-family']);
     }
     $this->_orientation = $this->_progress['orientation']['shape'];
     $this->_fillWay = $this->_progress['orientation']['fillway'];
     if (isset($this->_progress['script']['file'])) {
         $this->_script = $this->_progress['script']['file'];
     } else {
         $this->_script = null;
     }
     if (isset($this->_progress['cell']['count'])) {
         $this->_cellCount = $this->_progress['cell']['count'];
     } else {
         $this->_cellCount = 10;
     }
     $this->_updateProgressSize();
 }
Example #2
0
function InitProgressBar($increment = 1)
{
    global $progress_bar;
    $progress_bar = new HTML_Progress();
    $progress_bar->setAnimSpeed(100);
    //$progress_bar->setIncrement( (int)$increment );
    //$progress_bar->setIndeterminate(true);
    $progress_bar->setBorderPainted(true);
    $ui =& $progress_bar->getUI();
    $ui->setCellAttributes('active-color=#3874B4 inactive-color=#CCCCCC width=10');
    $ui->setBorderAttributes('width=1 color=navy');
    $ui->setStringAttributes('width=60 font-size=14 background-color=#FFFFFF align=center');
    ?>
	<html>
	<head>
	<style type="text/css">
	<!--
	<?php 
    echo $progress_bar->getStyle();
    ?>

	body {
			background-color: #FFFFFF;
			color: #FFFFFF;
			font-family: Verdana, freesans;
	}

	a:visited, a:active, a:link {
			color: yellow;
	}
	// -->
	</style>
	<script type="text/javascript">
	<!--
	<?php 
    echo $progress_bar->getScript();
    ?>
	//-->
	</script>
	</head>
	<body>

	<div align="center">
	<?php 
    echo $progress_bar->toHtml();
}
<?php

// listing-2.2.2.php
require_once 'HTML/Progress.php';
$progress = new HTML_Progress();
$ui =& $progress->getUI();
$ui->setCellCount(20);
$ui->setBorderAttributes('width=1 color=#000000');
$ui->setCellAttributes(array('active-color' => '#970038', 'inactive-color' => '#FFDDAA', 'width' => 20, 'height' => 20));
?>
<!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>
<style type="text/css">
<!--
<?php 
echo $progress->getStyle();
?>

body {
	background-color: #FFFFFF;
	color: #000000;
	font-family: Verdana, Arial;
}
// -->
</style>
<script type="text/javascript">
<!--
<?php

require_once 'HTML/Progress.php';
$bar = new HTML_Progress();
$bar->setValue(50);
$bar->setBorderPainted(true);
$ui =& $bar->getUI();
$ui->setFillWay('reverse');
$ui->setCellCount(5);
$ui->setCellAttributes('active-color=#970038 inactive-color=#FFDDAA width=20');
$ui->setBorderAttributes('width=1 color=#000000');
$ui->setStringAttributes('font-size=14 color=#FF0000 align=left valign=bottom');
?>
<!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>setStringAttributes example</title>
<style type="text/css">
<!--
<?php 
echo $bar->getStyle();
?>
// -->
</style>
<script type="text/javascript">
<!--
<?php 
echo $ui->getScript();
    if (file_exists($filename)) {
        // Send binary filetype HTTP header
        header('Content-Type: application/octet-stream');
        // Send content-length HTTP header
        header('Content-Length: ' . filesize($filename));
        // Send content-disposition with save file name HTTP header
        header('Content-Disposition: attachment; filename="' . $saveasname . '"');
        // Output file
        readfile($filename);
        // Done
        exit;
    }
    /* END Archive Download */
}
// Set up progress bar
$bar = new HTML_Progress();
$bar->setAnimSpeed(100);
$bar->setIncrement(1);
$bar->setBorderPainted(true);
$ui =& $bar->getUI();
$ui->setCellAttributes('active-color=#000084 inactive-color=#3A6EA5 width=4 spacing=0');
$ui->setBorderAttributes('width=1 style=inset color=white');
$ui->setStringAttributes(array('width' => 200, 'height' => 20, 'font-size' => 14, 'valign' => 'top'));
$ui->setCellCount(100);
// Start building archive
require_once $php_root_path . "/includes/pear/Tar.php";
require_once $php_root_path . "/includes/pear/Zip.php";
//State the current part of zip file that is being extracted
if (empty($_POST["currentZipPart"])) {
    $currentZipPart = 1;
}
Example #6
0
 /**
  * Disables certain buttons for a page.
  *
  * Buttons [ = events] : back, next, cancel, reset, apply, help
  *
  * @param      object    $page          Page where you want to activate buttons
  * @param      array     $events        (optional) List of buttons
  *
  * @since      1.1
  * @access     public
  * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  * @see        enableButton()
  */
 function disableButton(&$page, $events = array())
 {
     if (!is_a($page, 'HTML_QuickForm_Page')) {
         return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$page', 'was' => gettype($page), 'expected' => 'HTML_QuickForm_Page object', 'paramnum' => 1));
     } elseif (!is_array($events)) {
         return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$events', 'was' => gettype($events), 'expected' => 'array', 'paramnum' => 2));
     }
     static $all;
     if (!isset($all)) {
         $all = array('back', 'next', 'cancel', 'reset', 'apply', 'help');
     }
     $buttons = count($events) == 0 ? $all : $events;
     foreach ($buttons as $event) {
         $group = $page->getElement('buttons');
         $elements = $group->getElements();
         foreach (array_keys($elements) as $key) {
             if ($group->getElementName($key) == $page->getButtonName($event)) {
                 $elements[$key]->updateAttributes(array('disabled' => 'true'));
             }
         }
     }
 }
<?php

require_once 'HTML/Progress.php';
$bar = new HTML_Progress();
printf('direct way: maximum = %d <br/>', $bar->getMaximum());
$dm =& $bar->getDM();
printf('another way: maximum = %d <br/>', $dm->getMaximum());
<?php

require_once 'HTML/Progress.php';
$bar = new HTML_Progress();
$ui =& $bar->getUI();
$css =& $ui->getStyle();
print '<pre>';
echo '<h1>object</h1>';
print_r($css);
echo '<h1>plain text</h1><br/>';
print_r($css->toString());
print '</pre>';
Example #9
0
        $obj->display();
        unlink($semaphore);
    }
    // sleep a bit ...
    if ($version > 1.1) {
        $obj->sleep();
    } else {
        for ($i = 0; $i < $obj->_anim_speed * 1000; $i++) {
        }
    }
}
/*
   Which version of html_progress: (stable)1.1 or (beta)1.2.0 RC1, RC2 or RC3
*/
$version = _methodExists('run') ? 1.2 : 1.1;
$progress = new HTML_Progress();
$observer = new logsUpload();
// prepare the progress meter to logs all upload operations
$progress->addListener($observer);
$progress->setIncrement(10);
$progress->setAnimSpeed(100);
$progress->setIndeterminate(true);
// progress bar run in indeterminate mode
$progress->setStringPainted(true);
// get space for the string
$progress->setBorderPainted(true);
$progress->setString("");
// but don't paint it
if ($version > 1.1) {
    // set a progress handler required at least version 1.2.0RC3
    $progress->setProgressHandler('myFunctionHandler');
Example #10
0
 *
 * @version    $Id: hidden.php,v 1.2 2005/07/25 11:23:37 farell Exp $
 * @author     Laurent Laville <*****@*****.**>
 * @package    HTML_Progress
 * @subpackage Examples
 */
require_once 'HTML/Progress.php';
/*
   user callback: job to do while the progress meter is visible
*/
function myFunctionHandler($progressValue, &$obj)
{
    $obj->sleep();
    // nothing to do here, except sleep a bit ...
}
$progress = new HTML_Progress();
$progress->setAnimSpeed(100);
$progress->setIncrement(10);
$progress->setProgressHandler('myFunctionHandler');
?>
<html>
<head>
<style type="text/css">
<!--
body {
    background-color: #CCCC99;
    color: #996;
    font-family: Verdana, Arial;
}

a:visited, a:active, a:link {
Example #11
0
<?php

@(include '../include_path.php');
/**
 * Horizontal no String ProgressBar example.
 * 
 * @version    $Id: nostring.php,v 1.1 2004/07/05 21:32:09 farell Exp $
 * @author     Laurent Laville <*****@*****.**>
 * @package    HTML_Progress
 */
require_once 'HTML/Progress.php';
$bar = new HTML_Progress();
$bar->setAnimSpeed(100);
$bar->setIncrement(10);
$bar->setStringPainted(true);
// get space for the string
$bar->setString('');
// but don't paint it
?>
<html>
<head>
<title>Horizontal no String ProgressBar example</title>
<style type="text/css">
<!--
<?php 
echo $bar->getStyle();
?>

body {
	background-color: #FFFFFF;
	color: #000000;
Example #12
0
 * @package    HTML_Progress
 * @subpackage Examples
 */
require_once 'HTML/Progress.php';
$bar1 = new HTML_Progress(HTML_PROGRESS_BAR_VERTICAL);
$bar1->setAnimSpeed(20);
$bar1->setIdent('PB1');
$bar1->setIncrement(10);
$bar1->setBorderPainted(true);
$ui1 =& $bar1->getUI();
$ui1->setFillWay('natural');
$ui1->setCellCount(15);
$ui1->setCellAttributes('active-color=#970038 inactive-color=#FFDDAA width=50 height=13');
$ui1->setBorderAttributes('width=1 color=#000000');
$ui1->setStringAttributes(array('font-size' => 8, 'color' => '#FF0000', 'background-color' => '#C3C6C3', 'align' => 'center', 'valign' => 'bottom'));
$bar2 = new HTML_Progress(HTML_PROGRESS_BAR_VERTICAL);
$bar2->setAnimSpeed(20);
$bar2->setIdent('PB2');
$bar2->setIncrement(5);
$bar2->setBorderPainted(true);
$ui2 =& $bar2->getUI();
$ui2->setFillWay('reverse');
$ui2->setCellCount(15);
$ui2->setCellAttributes('active-color=#3874B4 inactive-color=#FFDDAA width=50 height=13');
$ui2->setBorderAttributes('width=1 style=dashed color=#000000');
$ui2->setStringAttributes(array('font-size' => 8, 'color' => 'navy', 'background-color' => '#C3C6C3', 'align' => 'center', 'valign' => 'bottom'));
?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?php

require_once 'HTML/Progress.php';
$bar = new HTML_Progress();
$test = "\$res = \$bar->isIndeterminate() ? 'yes':'no';";
eval($test);
printf('try 1: progress bar in indeterminate mode ? %s <br/>', $res);
$bar->setIndeterminate(true);
eval($test);
printf('try 2: progress bar in indeterminate mode ? %s <br/>', $res);
Example #14
0
/**
 * @ignore
 */
class myClassHandler
{
    function myMethodHandler($progressValue, &$bar)
    {
        if (fmod($progressValue, 10) == 0) {
            echo "myMethodHandler -> progress value is = {$progressValue} <br/>\n";
        }
        $bar->sleep();
    }
}
$obs = new myClassHandler();
$monitor = new HTML_Progress_Monitor('frmMonitor3', array('button' => array('style' => 'width:80px;')));
$progress = new HTML_Progress();
$progress->setUI('Progress_Default2');
// Attach a progress ui-model
$progress->setAnimSpeed(20);
$progress->setProgressHandler(array(&$obs, 'myMethodHandler'));
$monitor->setProgressElement($progress);
?>
<html>
<head>
<title>ProgressBar Monitor - Default renderer </title>
<style type="text/css">
<!--
.progressStatus {
    color:#000000;
    font-size:10px;
}
<?php

require_once 'HTML/Progress/monitor.php';
$bar = new HTML_Progress();
$mon = new HTML_Progress_Monitor();
$bar->addListener($mon);
$li = $bar->getListeners();
printf("%d listener(s) <br/>", count($li));
Example #16
0
 */
require_once 'HTML/Progress.php';
$pkg = array('PEAR', 'Archive_Tar', 'Config', 'HTML_QuickForm', 'HTML_CSS', 'HTML_Page', 'HTML_Template_Sigma', 'Log', 'MDB', 'PHPUnit');
function myFunctionHandler($progressValue, &$obj)
{
    global $pkg;
    $obj->sleep();
    $i = floor($progressValue / 10);
    if ($progressValue == 100) {
        $msg = '';
    } else {
        $msg = "&nbsp; installing package ({$progressValue} %) ... : " . $pkg[$i];
    }
    $obj->setString($msg);
}
$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
$bar->setProgressHandler('myFunctionHandler');
$ui =& $bar->getUI();
$ui->setTab('    ');
$ui->setStringAttributes('width=350 align=left');
?>
<html>
<head>
<title>Horizontal String ProgressBar example</title>
<style type="text/css">
<?php

@(include '../include_path.php');
/**
 * Reverse Rectangle Progress example.
 * 
 * @version    $Id: rectangleback.php,v 1.1 2004/06/29 20:48:52 farell Exp $
 * @author     Laurent Laville <*****@*****.**>
 * @package    HTML_Progress
 */
require_once 'HTML/Progress.php';
$bar = new HTML_Progress();
$bar->setAnimSpeed(100);
$bar->setIncrement(10);
$ui =& $bar->getUI();
$ui->setFillWay('reverse');
$ui->setOrientation(HTML_PROGRESS_POLYGONAL);
$ui->setCellAttributes(array('width' => 10, 'height' => 10, 'active-color' => 'red', 'inactive-color' => 'orange'));
$ui->setCellCoordinates(15, 3);
// Rectangle 15x3
?>
<html>
<head>
<title>Reverse Rectangle ProgressBar example</title>
<style type="text/css">
<!--
<?php 
echo $bar->getStyle();
?>

body {
<?php

require_once 'HTML/Progress.php';
$bar = new HTML_Progress();
$bar->setIncrement(5);
$bar->incValue();
printf('value after 1st update = %d <br/>', $bar->getValue());
$dm =& $bar->getDM();
$dm->incValue();
printf('value after 2nd update = %d <br/>', $dm->getValue());
<?php

require_once 'HTML/Progress.php';
$bar = new HTML_Progress();
printf('direct way: increment = %d <br/>', $bar->getIncrement());
$dm =& $bar->getDM();
printf('another way: increment = %d <br/>', $dm->getIncrement());
<?php

require_once 'HTML/Progress.php';
$bar = new HTML_Progress();
$bar->setStringPainted(true);
$bar->setValue(25);
$ui =& $bar->getUI();
$ui->setStringAttributes('width=350 align=left');
?>
<html>
<head>
<title>setStringPainted 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();
Example #21
0
 /**
  * Creates a progress bar with options choosen on all wizard tabs.
  *
  * @since      1.1
  * @access     public
  */
 function createProgressBar()
 {
     $progress = $this->exportValues();
     $bar = new HTML_Progress();
     $bar->setIdent('PB1');
     $bar->setAnimSpeed(intval($progress['rAnimSpeed']));
     if ($progress['model'] != '') {
         $bar->setModel($progress['model'], 'iniCommented');
         $bar->setIncrement(10);
         $ui =& $bar->getUI();
     } else {
         $bar->setBorderPainted($progress['borderpainted'] == '1');
         $bar->setStringPainted($progress['stringpainted'] == '1');
         $ui =& $bar->getUI();
         $structure = array();
         /* Page 1: Progress attributes **************************************************/
         if (strlen(trim($progress['progressclass'])) > 0) {
             $structure['progress']['class'] = $progress['progressclass'];
         }
         if (strlen(trim($progress['progresssize']['bgcolor'])) > 0) {
             $structure['progress']['background-color'] = $progress['progresssize']['bgcolor'];
         }
         if (strlen(trim($progress['progresssize']['width'])) > 0) {
             $structure['progress']['width'] = $progress['progresssize']['width'];
         }
         if (strlen(trim($progress['progresssize']['height'])) > 0) {
             $structure['progress']['height'] = $progress['progresssize']['height'];
         }
         $structure['progress']['auto-size'] = $progress['autosize'] == '1';
         $ui->setProgressAttributes($structure['progress']);
         $orient = $progress['shape'] == '1' ? HTML_PROGRESS_BAR_HORIZONTAL : HTML_PROGRESS_BAR_VERTICAL;
         $ui->setOrientation($orient);
         $ui->setFillWay($progress['way']);
         /* Page 2: Cell attributes ******************************************************/
         if (strlen(trim($progress['cellid'])) > 0) {
             $structure['cell']['id'] = $progress['cellid'];
         }
         if (strlen(trim($progress['cellclass'])) > 0) {
             $structure['cell']['class'] = $progress['cellclass'];
         }
         if (strlen(trim($progress['cellvalue']['min'])) > 0) {
             $bar->setMinimum(intval($progress['cellvalue']['min']));
         }
         if (strlen(trim($progress['cellvalue']['max'])) > 0) {
             $bar->setMaximum(intval($progress['cellvalue']['max']));
         }
         if (strlen(trim($progress['cellvalue']['inc'])) > 0) {
             $bar->setIncrement(intval($progress['cellvalue']['inc']));
         }
         if (strlen(trim($progress['cellsize']['width'])) > 0) {
             $structure['cell']['width'] = $progress['cellsize']['width'];
         }
         if (strlen(trim($progress['cellsize']['height'])) > 0) {
             $structure['cell']['height'] = $progress['cellsize']['height'];
         }
         if (strlen(trim($progress['cellsize']['spacing'])) > 0) {
             $structure['cell']['spacing'] = $progress['cellsize']['spacing'];
         }
         if (strlen(trim($progress['cellsize']['count'])) > 0) {
             $ui->setCellCount(intval($progress['cellsize']['count']));
         }
         if (strlen(trim($progress['cellcolor']['active'])) > 0) {
             $structure['cell']['active-color'] = $progress['cellcolor']['active'];
         }
         if (strlen(trim($progress['cellcolor']['inactive'])) > 0) {
             $structure['cell']['inactive-color'] = $progress['cellcolor']['inactive'];
         }
         if (strlen(trim($progress['cellfont']['family'])) > 0) {
             $structure['cell']['font-family'] = $progress['cellfont']['family'];
         }
         if (strlen(trim($progress['cellfont']['size'])) > 0) {
             $structure['cell']['font-size'] = $progress['cellfont']['size'];
         }
         if (strlen(trim($progress['cellfont']['color'])) > 0) {
             $structure['cell']['color'] = $progress['cellfont']['color'];
         }
         $ui->setCellAttributes($structure['cell']);
         /* Page 3: Border attributes ****************************************************/
         if (strlen(trim($progress['borderclass'])) > 0) {
             $structure['border']['class'] = $progress['borderclass'];
         }
         if (strlen(trim($progress['borderstyle']['width'])) > 0) {
             $structure['border']['width'] = $progress['borderstyle']['width'];
         }
         if (strlen(trim($progress['borderstyle']['style'])) > 0) {
             $structure['border']['style'] = $progress['borderstyle']['style'];
         }
         if (strlen(trim($progress['borderstyle']['color'])) > 0) {
             $structure['border']['color'] = $progress['borderstyle']['color'];
         }
         $ui->setBorderAttributes($structure['border']);
         /* Page 4: String attributes ****************************************************/
         if (strlen(trim($progress['stringid'])) > 0) {
             $structure['string']['id'] = $progress['stringid'];
         }
         if (strlen(trim($progress['stringsize']['width'])) > 0) {
             $structure['string']['width'] = $progress['stringsize']['width'];
         }
         if (strlen(trim($progress['stringsize']['height'])) > 0) {
             $structure['string']['height'] = $progress['stringsize']['height'];
         }
         if (strlen(trim($progress['stringsize']['bgcolor'])) > 0) {
             $structure['string']['background-color'] = $progress['stringsize']['bgcolor'];
         }
         if (strlen(trim($progress['stringalign'])) > 0) {
             $structure['string']['align'] = $progress['stringalign'];
         }
         if (strlen(trim($progress['stringvalign'])) > 0) {
             $structure['string']['valign'] = $progress['stringvalign'];
         }
         if (strlen(trim($progress['stringfont']['family'])) > 0) {
             $structure['string']['font-family'] = $progress['stringfont']['family'];
         }
         if (strlen(trim($progress['stringfont']['size'])) > 0) {
             $structure['string']['font-size'] = $progress['stringfont']['size'];
         }
         if (strlen(trim($progress['stringfont']['color'])) > 0) {
             $structure['string']['color'] = $progress['stringfont']['color'];
         }
         $ui->setStringAttributes($structure['string']);
     }
     // end-if-no-model
     return $bar;
 }
<?php

require_once 'HTML/Progress.php';
$bar = new HTML_Progress();
$bar->setBorderPainted(true);
$ui =& $bar->getUI();
$ui->setCellAttributes('active-color=#3874B4 inactive-color=#EEEECC width=10');
print '<pre>';
var_dump($ui->getCellAttributes());
var_dump($ui->getCellAttributes(true));
print '</pre>';
        $lineFormat = $options['lineFormat'];
        $contextFormat = $options['contextFormat'];
        $file = $err['context']['file'];
        $line = $err['context']['line'];
        $func = $err['context']['class'];
        $func .= $err['context']['type'];
        $func .= $err['context']['function'];
        $context = sprintf($contextFormat, $file, $line, $func);
        printf($lineFormat . "<br />\n", ucfirst($err['level']), $err['message'], $context);
    }
}
$logger['push_callback'] = '_pushCallback';
$logger['error_handler'] = '_errorHandler';
$options = array('lineFormat' => '<b>%1$s</b>: %2$s <hr>%3$s', 'contextFormat' => '<b>Function</b>: %3$s<br/><b>File</b>: %1$s<br/><b>Line</b>: %2$s');
$logger['handler']['display'] = array('conf' => $options);
$bar = new HTML_Progress($logger);
$e = $bar->setAnimSpeed('100');
// < - - - will generate an API exception
if (is_object($e)) {
    if (is_a($e, 'PEAR_Error')) {
        die('<h1>Catch PEAR_Error API exception</h1>' . $e->toString());
    }
}
if (HTML_Progress::hasErrors()) {
    $err = HTML_Progress::getError();
    echo '<pre>';
    print_r($err);
    echo '</pre>';
    die('<h1>Catch HTML_Progress exception</h1>');
}
$e = $bar->setAnimSpeed(10000);
<?php

require_once 'HTML/Progress.php';
$bar = new HTML_Progress();
$dm =& $bar->getDM();
print_r($dm);
Example #25
0
 /**
  * Default callback to generate error messages for any instance
  *
  * @param      array     $err           current error structure with context info
  *
  * @return     string
  * @since      1.2.0RC1
  * @access     private
  * @static
  */
 function _msgCallback($err)
 {
     $messages = HTML_Progress::_getErrorMessage();
     $mainmsg = $messages[$err['code']];
     if (count($err['params'])) {
         foreach ($err['params'] as $name => $val) {
             if (is_array($val)) {
                 $val = implode(', ', $val);
             }
             $mainmsg = str_replace('%' . $name . '%', $val, $mainmsg);
         }
     }
     return $mainmsg;
 }
Example #26
0
    }
    function notify($event)
    {
        $this->progress->display();
        $this->progress->sleep();
        if ($this->progress->getPercentComplete() == 1) {
            $this->progress->setValue(0);
        } else {
            $this->progress->incValue();
        }
    }
}
//
// 2. defines the progress meter
//
$meter = new HTML_Progress();
$ui =& $meter->getUI();
$ui->setProgressAttributes(array('background-color' => '#e0e0e0'));
$ui->setStringAttributes(array('color' => '#996', 'background-color' => '#CCCC99'));
$ui->setCellAttributes(array('active-color' => '#996'));
$meter->setAnimSpeed(200);
$meter->setIncrement(10);
$meter->setStringPainted(true);
// get space for the string
$meter->setString("");
// but don't paint it
$meter->setIndeterminate(true);
// progress meter start in indeterminate mode
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Example #27
0
<?php

/**
 * Easy set options of a progress meter with PEAR::Config package
 * and a configuration container style 'iniCommented'.
 *
 * @version    $Id: inicommented.php,v 1.2 2005/07/25 10:25:43 farell Exp $
 * @author     Laurent Laville <*****@*****.**>
 * @package    HTML_Progress
 * @subpackage Examples
 */
require 'HTML/Progress.php';
$bar = new HTML_Progress();
$bar->setModel('javadanse.ini', 'inicommented');
if (HTML_Progress::hasErrors()) {
    $err = HTML_Progress::getError();
    die('<h1>Your configuration file is erroneous</h1>' . $err['message']);
}
?>
<!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>Model Progress example</title>
<style type="text/css">
<!--
<?php 
echo $bar->getStyle();
?>
 /**
  * Draw all circle segment pictures
  *
  * @param      string    $dir           (optional) Directory where pictures should be created
  * @param      string    $fileMask      (optional) sprintf format for pictures filename
  *
  * @return     array
  * @since      1.2.0RC1
  * @access     public
  * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  */
 function drawCircleSegments($dir = '.', $fileMask = 'c%s.png')
 {
     if (!is_string($dir)) {
         return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$dir', 'was' => gettype($dir), 'expected' => 'string', 'paramnum' => 1));
     } elseif (!is_string($fileMask)) {
         return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$fileMask', 'was' => gettype($fileMask), 'expected' => 'string', 'paramnum' => 2));
     }
     include_once 'Image/Color.php';
     $cellAttr = $this->getCellAttributes();
     $cellCount = $this->getCellCount();
     $w = $cellAttr['width'];
     $h = $cellAttr['height'];
     $s = $cellAttr['spacing'];
     $c = intval(360 / $cellCount);
     $cx = floor($w / 2);
     if (fmod($w, 2) == 0) {
         $cx = $cx - 0.5;
     }
     $cy = floor($h / 2);
     if (fmod($h, 2) == 0) {
         $cy = $cy - 0.5;
     }
     $image = imagecreate($w, $h);
     $bg = Image_Color::allocateColor($image, $cellAttr['background-color']);
     $colorA = Image_Color::allocateColor($image, $cellAttr['active-color']);
     $colorI = Image_Color::allocateColor($image, $cellAttr['inactive-color']);
     imagefilledarc($image, $cx, $cy, $w, $h, 0, 360, $colorI, IMG_ARC_EDGED);
     $filename = $dir . DIRECTORY_SEPARATOR . sprintf($fileMask, 0);
     imagepng($image, $filename);
     $this->setCellAttributes(array('background-image' => $filename), 0);
     for ($i = 0; $i < $cellCount; $i++) {
         if ($this->getFillWay() == 'natural') {
             $sA = $i * $c;
             $eA = ($i + 1) * $c;
             $sI = ($i + 1) * $c;
             $eI = 360;
         } else {
             $sA = 360 - ($i + 1) * $c;
             $eA = 360 - $i * $c;
             $sI = 0;
             $eI = 360 - ($i + 1) * $c;
         }
         if ($s > 0) {
             imagefilledarc($image, $cx, $cy, $w, $h, 0, $sA, $colorI, IMG_ARC_EDGED);
         }
         imagefilledarc($image, $cx, $cy, $w, $h, $sA, $eA, $colorA, IMG_ARC_EDGED);
         imagefilledarc($image, $cx, $cy, $w, $h, $sI, $eI, $colorI, IMG_ARC_EDGED);
         $filename = $dir . DIRECTORY_SEPARATOR . sprintf($fileMask, $i + 1);
         imagepng($image, $filename);
         $this->setCellAttributes(array('background-image' => $filename), $i + 1);
     }
     imagedestroy($image);
 }
Example #29
0
<?php

/**
 * Natural Horizontal with background images ProgressBar example.
 * See also ProgressMaker usage with pre-set UI model 'BgImages'.
 *
 * @version    $Id: bgimages.php,v 1.2 2005/07/25 10:25:30 farell Exp $
 * @author     Laurent Laville <*****@*****.**>
 * @package    HTML_Progress
 * @subpackage Examples
 */
require_once 'HTML/Progress.php';
$bar = new HTML_Progress();
$bar->setAnimSpeed(100);
$bar->setIncrement(10);
$bar->setBorderPainted(true);
$ui =& $bar->getUI();
$ui->setTab('    ');
$ui->setCellAttributes(array('active-color' => '#000084', 'inactive-color' => '#3A6EA5', 'width' => 25, 'spacing' => 0, 'background-image' => 'download.gif'));
$ui->setBorderAttributes('width=1 style=inset color=white');
$ui->setStringAttributes(array('width' => 60, 'font-size' => 10, 'background-color' => '#C3C6C3', 'align' => 'center', 'valign' => 'left'));
?>
<!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>BgImages Progress example</title>
<style type="text/css">
<!--
Example #30
0
    if (!isset($c)) {
        $c = time();
    }
    // wait a bit ...
    $bar->sleep();
    /* rules to determine when switch back from indeterminate to determinate mode */
    $elapse = time() - $c;
    echo "myProgressHandler -> elapse time = {$elapse} s.<br/>\n";
    if ($elapse >= 12) {
        if ($bar->isIndeterminate()) {
            $bar->setIndeterminate(false);
            $bar->setValue(100);
        }
    }
}
$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(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');
?>
<html>