Source for file Renderer.php
Documentation is available at Renderer.php
* Copyright (c) 2008, Laurent Laville <pear@laurent-laville.org>
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the authors nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* @package PHP_CompatInfo
* @author Laurent Laville <pear@laurent-laville.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version CVS: $Id: Renderer.php,v 1.8 2008/07/22 20:26:19 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @since File available since Release 1.8.0b2
* Base class used by all renderers
* @package PHP_CompatInfo
* @author Laurent Laville <pear@laurent-laville.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version Release: 1.8.0
* @link http://pear.php.net/package/PHP_CompatInfo
* @since Class available since Release 1.8.0b2
* PHP_CompatInfo_Parser instance
* @var mixed Progress bar render options (available only on CLI sapi)
* @var string End of line string (depending of server API)
* Silent mode. Display or not extra info messages.
* Data source parsed final results
* All console arguments that have been parsed and recognized
* A hash containing any additional configuration of specific driver
* Base Renderer Class constructor
* Base Renderer Class constructor (ZE1) for PHP4
* @param object &$parser Instance of the parser (model of MVC pattern)
* @param array $conf A hash containing any additional configuration
* @since version 1.8.0b2 (2008-06-03)
* Base Renderer Class constructor
* Base Renderer Class constructor (ZE2) for PHP5+
* @param object &$parser Instance of the parser (model of MVC pattern)
* @param array $conf A hash containing any additional configuration
* @since version 1.8.0b2 (2008-06-03)
$this->_parser = $parser;
if (isset ($conf['args']) && is_array($conf['args'])) {
// when running the CLI version, take arguments from console
if (isset ($this->args['progress'])) {
$conf['progress'] = $this->args['progress'];
$this->eol = '<br/>'. PHP_EOL;
// activate (or not) the silent mode
if (!isset ($conf['silent'])) {
$this->silent = true; // default behavior
$this->silent = (bool) $conf['silent'];
if (isset ($conf['progress']) && $conf['progress'] == 'bar') {
// wait style = progress bar prefered (if available)
$progressBar = 'Console/ProgressBar.php';
include_once $progressBar;
// default progress bar render options
$default = array ('formatString' => '- %fraction% files' .
' Elapsed Time: %elapsed%',
// apply custom render options if given
if (isset ($conf['progressbar'])) {
$pbar = $conf['progressbar'];
// no progress bar available
// wait style = text prefered
// register the compatInfo view as observer
$parser->addListener (array (&$this, 'update'));
* Create required instance of the Output 'driver'.
* Creates a concrete instance of the renderer depending of $type
* @param object &$parser A concrete instance of the parser
* @param string $type (optional) Type of instance required, case insensitive
* @param array $conf (optional) A hash containing any additional
* configuration information that a subclass might need.
* @return object PHP_CompatInfo_Renderer A concrete PHP_CompatInfo_Renderer
* instance, or null on error.
* @since version 1.8.0b2 (2008-06-03)
function &factory(&$parser, $type = 'array', $conf = array ())
* Attempt to include our version of the named class, but don't treat
* a failure as fatal. The caller may have already included their own
* version of the named class.
// If the class exists, return a new instance of it.
$instance = & new $class($parser, $conf);
* Update the current view
* Interface to update the view with current information.
* Listen events produced by Event_Dispatcher and the PHP_CompatInfo_Parser
* @param object &$auditEvent Instance of Event_Dispatcher
* @since version 1.8.0b2 (2008-06-03)
$notifyName = $auditEvent->getNotificationName ();
$notifyInfo = $auditEvent->getNotificationInfo ();
$notifyInfo['fileindex']);
$notifyInfo['stringindex']);
* Initialize the wait process
* Initialize the wait process, with a simple message or a progress bar.
* @param integer $maxEntries Number of source to parse
* @since version 1.8.0b2 (2008-06-03)
// obey at silent mode protocol
// protect against invalid data source
$this->_pbar = new Console_ProgressBar ($this->_pbar['formatString'],
$this->_pbar['options']);
echo 'Wait while parsing data source ...'
* Update the wait message
* Update the wait message, or status of the progress bar
* @param string $source Source (file, string) currently parsing
* @param string $index Position of the $source in the data source list
* @since version 1.8.0b2 (2008-06-03)
// obey at silent mode protocol
// update the progress bar
$this->_pbar->update ($index);
echo 'Wait while parsing file "' . $source . '"'
echo 'Wait while parsing string "' . $index . '"'
* Finish the wait process
* Finish the wait process, by erasing the progress bar
* @since version 1.8.0b2 (2008-06-03)
// obey at silent mode protocol
// remove the progress bar
$this->_pbar->erase (true );
* Checks if in the include path
* Returns whether or not a file is in the include path
* @param string $file Path to filename to check if includable
* @return boolean True if the file is in the include path, false otherwise
* @since version 1.7.0b4 (2008-04-03)
* Utility function which wraps PHP's class_exists() function to ensure
* consistent behavior between PHP versions 4 and 5. Autoloading behavior
* @param string $class The name of the class whose existence should be tested.
* @return bool True if the class exists, false otherwiser.
* @since version 1.8.0b2 (2008-06-03)
function _classExists ($class)
Documentation generated on Fri, 01 Aug 2008 11:30:31 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.
|