Update to PEAR 1.7.2, Image_Canvas 0.3.1, Image_Color 1.0.3, Image_Graph 0.7.2, XML_Parser 1.3.1.

Removed PHP_Compat, and references to it.
Removed ionCube/Zend/mmCache compatibility checks in test.php script.
Changed minimum PHP requirement to 5.0 in test.php script.
This commit is contained in:
anubis 2009-01-04 19:22:54 -05:00
parent 60b674c776
commit fae6352bf2
384 changed files with 34150 additions and 44524 deletions

View File

@ -1,133 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: Compat.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Provides missing functionality in the form of constants and functions
* for older versions of PHP
*
* Optionally, you may simply include the file.
* e.g. require_once 'PHP/Compat/Function/scandir.php';
*
* @category PHP
* @package PHP_Compat
* @version $Revision: 1.1 $
* @author Aidan Lister <aidan@php.net>
* @static
*/
class PHP_Compat
{
/**
* Load a function, or array of functions
*
* @param string|array $function The function or functions to load
* @return bool|array TRUE if loaded, FALSE if not
*/
function loadFunction($function)
{
// Recursiveness
if (is_array($function)) {
$res = array();
foreach ($function as $singlefunc) {
$res[$singlefunc] = PHP_Compat::loadFunction($singlefunc);
}
return $res;
}
// Load function
if (!function_exists($function)) {
$file = sprintf('PHP/Compat/Function/%s.php', $function);
if ((@include_once $file) !== false) {
return true;
}
}
return false;
}
/**
* Load a constant, or array of constants
*
* @param string|array $constant The constant or constants to load
* @return bool|array TRUE if loaded, FALSE if not
*/
function loadConstant($constant)
{
// Recursiveness
if (is_array($constant)) {
$res = array();
foreach ($constant as $singleconst) {
$res[$singleconst] = PHP_Compat::loadConstant($singleconst);
}
return $res;
}
// Load constant
$file = sprintf('PHP/Compat/Constant/%s.php', $constant);
if ((@include_once $file) !== false) {
return true;
}
return false;
}
/**
* Load components for a PHP version
*
* @param string $version PHP Version to load
* @return array An associative array of component names loaded
*/
function loadVersion($version = null)
{
// Include list of components
require 'PHP/Compat/Components.php';
// Include version_compare to work with older versions
PHP_Compat::loadFunction('version_compare');
// Init
$phpversion = phpversion();
$methods = array(
'function' => 'loadFunction',
'constant' => 'loadConstant');
$res = array();
// Iterate each component
foreach ($components as $type => $slice) {
foreach ($slice as $component => $compversion) {
if (($version === null &&
1 === version_compare($compversion, $phpversion)) || // C > PHP
(0 === version_compare($compversion, $version) || // C = S
1 === version_compare($compversion, $phpversion))) { // C > PHP
$res[$type][$component] =
call_user_func(array('PHP_Compat', $methods[$type]), $component);
}
}
}
return $res;
}
}
?>

View File

@ -1,71 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: Components.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
// Functions
$components['function']['array_combine'] = '5.0.0';
$components['function']['array_diff_assoc'] = '4.3.0';
$components['function']['array_diff_key'] = '5.0.2';
$components['function']['array_diff_ukey'] = '5.0.2';
$components['function']['array_intersect_assoc'] = '5.0.0';
$components['function']['array_intersect_key'] = '5.0.2';
$components['function']['array_intersect_uassoc'] = '5.0.0';
$components['function']['array_intersect_ukey'] = '5.0.2';
$components['function']['array_udiff'] = '5.0.0';
$components['function']['array_udiff_assoc'] = '5.0.0';
$components['function']['array_udiff_uassoc'] = '5.0.0';
$components['function']['array_uintersect'] = '5.0.0';
$components['function']['array_uintersect_assoc'] = '5.0.0';
$components['function']['array_uintersect_uassoc'] = '5.0.0';
$components['function']['array_walk_recursive'] = '5.0.0';
$components['function']['clone'] = '5.0.0';
$components['function']['convert_uudecode'] = '5.0.0';
$components['function']['convert_uuencode'] = '5.0.0';
$components['function']['debug_print_backtrace'] = '5.0.0';
$components['function']['file_get_contents'] = '4.3.0';
$components['function']['file_put_contents'] = '5.0.0';
$components['function']['fprintf'] = '5.0.0';
$components['function']['get_headers'] = '5.0.0';
$components['function']['get_include_path'] = '4.3.0';
$components['function']['html_entity_decode'] = '4.3.0';
$components['function']['http_build_query'] = '5.0.0';
$components['function']['image_type_to_mime_type'] = '4.3.0';
$components['function']['ob_get_clean'] = '4.3.0';
$components['function']['ob_get_flush'] = '4.3.0';
$components['function']['php_strip_whitespace'] = '5.0.0';
$components['function']['restore_include_path'] = '4.3.0';
$components['function']['scandir'] = '5.0.0';
$components['function']['set_include_path'] = '4.3.0';
$components['function']['str_ireplace'] = '5.0.0';
$components['function']['str_shuffle'] = '4.3.0';
$components['function']['str_split'] = '5.0.0';
$components['function']['str_word_count'] = '4.3.0';
$components['function']['stripos'] = '5.0.0';
$components['function']['strpbrk'] = '5.0.0';
$components['function']['strripos'] = '5.0.0';
$components['function']['substr_compare'] = '5.0.0';
// Constants
$components['constant']['E_STRICT'] = '5.0.0';
$components['constant']['FILE'] = '4.3.0';
$components['constant']['PHP_EOL'] = '5.0.1';
$components['constant']['STD'] = '4.3.0';
$components['constant']['T'] = '5.0.0';
$components['constant']['UPLOAD_ERR'] = '4.3.0';
?>

View File

@ -1,35 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: E_STRICT.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace constant E_STRICT
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/ref.errorfunc
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 5
*/
if (!defined('E_STRICT')) {
define('E_STRICT', 2048);
}
?>

View File

@ -1,51 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: FILE.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace filesystem constants
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/ref.filesystem
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 5
*/
if (!defined('FILE_USE_INCLUDE_PATH')) {
define('FILE_USE_INCLUDE_PATH', 1);
}
if (!defined('FILE_IGNORE_NEW_LINES')) {
define('FILE_IGNORE_NEW_LINES', 2);
}
if (!defined('FILE_SKIP_EMPTY_LINES')) {
define('FILE_SKIP_EMPTY_LINES', 4);
}
if (!defined('FILE_APPEND')) {
define('FILE_APPEND', 8);
}
if (!defined('FILE_NO_DEFAULT_CONTEXT')) {
define('FILE_NO_DEFAULT_CONTEXT', 16);
}
?>

View File

@ -1,49 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: PHP_EOL.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace PHP_EOL constant
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/reserved.constants.core
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 5.0.2
*/
if (!defined('PHP_EOL')) {
switch (strtoupper(substr(PHP_OS, 0, 3))) {
// Windows
case 'WIN':
define('PHP_EOL', "\r\n");
break;
// Mac
case 'DAR':
define('PHP_EOL', "\r");
break;
// Unix
default:
define('PHP_EOL', "\n");
}
}
?>

View File

@ -1,43 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: STD.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace commandline constants
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/features.commandline
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 4.3.0
*/
if (!defined('STDIN')) {
define('STDIN', fopen('php://stdin', 'r'));
}
if (!defined('STDOUT')) {
define('STDOUT', fopen('php://stdout', 'w'));
}
if (!defined('STDERR')) {
define('STDERR', fopen('php://stderr', 'w'));
}
?>

View File

@ -1,72 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: T.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace tokenizer constants
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/ref.tokenizer
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 5
*/
if (!defined('T_ML_COMMENT')) {
define('T_ML_COMMENT', T_COMMENT);
}
if (!defined('T_DOC_COMMENT')) {
define('T_DOC_COMMENT', T_ML_COMMENT);
}
if (!defined('T_OLD_FUNCTION')) {
define('T_OLD_FUNCTION', -1);
}
if (!defined('T_ABSTRACT')) {
define('T_ABSTRACT', -1);
}
if (!defined('T_CATCH')) {
define('T_CATCH', -1);
}
if (!defined('T_FINAL')) {
define('T_FINAL', -1);
}
if (!defined('T_INSTANCEOF')) {
define('T_INSTANCEOF', -1);
}
if (!defined('T_PRIVATE')) {
define('T_PRIVATE', -1);
}
if (!defined('T_PROTECTED')) {
define('T_PROTECTED', -1);
}
if (!defined('T_PUBLIC')) {
define('T_PUBLIC', -1);
}
if (!defined('T_THROW')) {
define('T_THROW', -1);
}
if (!defined('T_TRY')) {
define('T_TRY', -1);
}
if (!defined('T_CLONE')) {
define('T_CLONE', -1);
}
?>

View File

@ -1,51 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: UPLOAD_ERR.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace upload error constants
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/features.file-upload.errors
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 4.3.0
*/
if (!defined('UPLOAD_ERR_OK')) {
define('UPLOAD_ERR_OK', 0);
}
if (!defined('UPLOAD_ERR_INI_SIZE')) {
define('UPLOAD_ERR_INI_SIZE', 1);
}
if (!defined('UPLOAD_ERR_FORM_SIZE')) {
define('UPLOAD_ERR_FORM_SIZE', 2);
}
if (!defined('UPLOAD_ERR_PARTIAL')) {
define('UPLOAD_ERR_PARTIAL', 3);
}
if (!defined('UPLOAD_ERR_NO_FILE')) {
define('UPLOAD_ERR_NO_FILE', 4);
}
?>

View File

@ -1,71 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: array_combine.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace array_combine()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.array_combine
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 5
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('array_combine')) {
function array_combine($keys, $values)
{
if (!is_array($keys)) {
user_error('array_combine() expects parameter 1 to be array, ' .
gettype($keys) . ' given', E_USER_WARNING);
return;
}
if (!is_array($values)) {
user_error('array_combine() expects parameter 2 to be array, ' .
gettype($values) . ' given', E_USER_WARNING);
return;
}
$key_count = count($keys);
$value_count = count($values);
if ($key_count !== $value_count) {
user_error('array_combine() Both parameters should have equal number of elements', E_USER_WARNING);
return false;
}
if ($key_count === 0 || $value_count === 0) {
user_error('array_combine() Both parameters should have number of elements at least 0', E_USER_WARNING);
return false;
}
$keys = array_values($keys);
$values = array_values($values);
$combined = array();
for ($i = 0; $i < $key_count; $i++) {
$combined[$keys[$i]] = $values[$i];
}
return $combined;
}
}
?>

View File

@ -1,75 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: array_diff_assoc.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace array_diff_assoc()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.array_diff_assoc
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 4.3.0
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('array_diff_assoc')) {
function array_diff_assoc()
{
// Check we have enough arguments
$args = func_get_args();
$count = count($args);
if (count($args) < 2) {
user_error('Wrong parameter count for array_diff_assoc()', E_USER_WARNING);
return;
}
// Check arrays
for ($i = 0; $i < $count; $i++) {
if (!is_array($args[$i])) {
user_error('array_diff_assoc() Argument #' .
($i + 1) . ' is not an array', E_USER_WARNING);
return;
}
}
// Get the comparison array
$array_comp = array_shift($args);
--$count;
// Traverse values of the first array
foreach ($array_comp as $key => $value) {
// Loop through the other arrays
for ($i = 0; $i < $count; $i++) {
// Loop through this arrays key/value pairs and compare
foreach ($args[$i] as $comp_key => $comp_value) {
if ((string)$key === (string)$comp_key &&
(string)$value === (string)$comp_value)
{
unset($array_comp[$key]);
}
}
}
}
return $array_comp;
}
}
?>

View File

@ -1,66 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: array_diff_key.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace array_diff_key()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.array_diff_key
* @author Tom Buskens <ortega@php.net>
* @version $Revision: 1.1 $
* @since PHP 5.0.2
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('array_diff_key')) {
function array_diff_key()
{
$args = func_get_args();
if (count($args) < 2) {
user_error('Wrong parameter count for array_diff_key()', E_USER_WARNING);
return;
}
// Check arrays
$array_count = count($args);
for ($i = 0; $i !== $array_count; $i++) {
if (!is_array($args[$i])) {
user_error('array_diff_key() Argument #' .
($i + 1) . ' is not an array', E_USER_WARNING);
return;
}
}
$result = $args[0];
foreach ($args[0] as $key1 => $value1) {
for ($i = 1; $i !== $array_count; $i++) {
foreach ($args[$i] as $key2 => $value2) {
if ((string) $key1 === (string) $key2) {
unset($result[$key2]);
break 2;
}
}
}
}
return $result;
}
}
?>

View File

@ -1,83 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: array_diff_uassoc.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace array_diff_uassoc()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.array_diff_uassoc
* @version $Revision: 1.1 $
* @since PHP 5.0.0
* @require PHP 4.0.6 (is_callable)
*/
if (!function_exists('array_diff_uassoc')) {
function array_diff_uassoc()
{
// Sanity check
$args = func_get_args();
if (count($args) < 3) {
user_error('Wrong parameter count for array_diff_uassoc()', E_USER_WARNING);
return;
}
// Get compare function
$compare_func = array_pop($args);
if (!is_callable($compare_func)) {
if (is_array($compare_func)) {
$compare_func = $compare_func[0] . '::' . $compare_func[1];
}
user_error('array_diff_uassoc() Not a valid callback ' .
$compare_func, E_USER_WARNING);
return;
}
// Check arrays
$array_count = count($args);
for ($i = 0; $i !== $array_count; $i++) {
if (!is_array($args[$i])) {
user_error('array_diff_uassoc() Argument #' .
($i + 1) . ' is not an array', E_USER_WARNING);
return;
}
}
// Compare entries
$result = array();
foreach ($args[0] as $k => $v) {
for ($i = 1; $i < $array_count; $i++) {
foreach ($args[$i] as $kk => $vv) {
if ($v == $vv) {
$compare = call_user_func_array($compare_func, array($k, $kk));
if ($compare == 0) {
continue 3;
}
}
}
}
$result[$k] = $v;
}
return $result;
}
}
?>

View File

@ -1,79 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: array_diff_ukey.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace array_diff_ukey()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.array_diff_ukey
* @author Tom Buskens <ortega@php.net>
* @version $Revision: 1.1 $
* @since PHP 5.0.2
* @require PHP 4.0.6 (is_callable)
*/
if (!function_exists('array_diff_ukey')) {
function array_diff_ukey()
{
$args = func_get_args();
if (count($args) < 3) {
user_error('Wrong parameter count for array_diff_ukey()', E_USER_WARNING);
return;
}
// Get compare function
$compare_func = array_pop($args);
if (!is_callable($compare_func)) {
if (is_array($compare_func)) {
$compare_func = $compare_func[0].'::'.$compare_func[1];
}
user_error('array_diff_ukey() Not a valid callback ' .
$compare_func, E_USER_WARNING);
return;
}
// Check arrays
$array_count = count($args);
for ($i = 0; $i !== $array_count; $i++) {
if (!is_array($args[$i])) {
user_error('array_diff_ukey() Argument #' .
($i + 1) . ' is not an array', E_USER_WARNING);
return;
}
}
// Compare entries
$result = $args[0];
foreach ($args[0] as $key1 => $value1) {
for ($i = 1; $i !== $array_count; $i++) {
foreach ($args[$i] as $key2 => $value2) {
if (!(call_user_func($compare_func, (string) $key1, (string) $key2))) {
unset($result[$key1]);
break 2;
}
}
}
}
return $result;
}
}
?>

View File

@ -1,69 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: array_intersect_assoc.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace array_intersect_assoc()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.array_intersect_assoc
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 4.3.0
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('array_intersect_assoc')) {
function array_intersect_assoc()
{
// Sanity check
$args = func_get_args();
if (count($args) < 2) {
user_error('wrong parameter count for array_intersect_assoc()', E_USER_WARNING);
return;
}
// Check arrays
$array_count = count($args);
for ($i = 0; $i !== $array_count; $i++) {
if (!is_array($args[$i])) {
user_error('array_intersect_assoc() Argument #' .
($i + 1) . ' is not an array', E_USER_WARNING);
return;
}
}
// Compare entries
$intersect = array();
foreach ($args[0] as $key => $value) {
$intersect[$key] = $value;
for ($i = 1; $i < $array_count; $i++) {
if (!isset($args[$i][$key]) || $args[$i][$key] != $value) {
unset($intersect[$key]);
break;
}
}
}
return $intersect;
}
}
?>

View File

@ -1,67 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: array_intersect_key.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace array_intersect_key()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.array_intersect_key
* @author Tom Buskens <ortega@php.net>
* @version $Revision: 1.1 $
* @since PHP 5.0.2
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('array_intersect_key')) {
function array_intersect_key()
{
$args = func_get_args();
if (count($args) < 2) {
user_error('Wrong parameter count for array_intersect_key()', E_USER_WARNING);
return;
}
// Check arrays
$array_count = count($args);
for ($i = 0; $i !== $array_count; $i++) {
if (!is_array($args[$i])) {
user_error('array_intersect_key() Argument #' .
($i + 1) . ' is not an array', E_USER_WARNING);
return;
}
}
// Compare entries
$result = array();
foreach ($args[0] as $key1 => $value1) {
for ($i = 1; $i !== $array_count; $i++) {
foreach ($args[$i] as $key2 => $value2) {
if ((string) $key1 === (string) $key2) {
$result[$key1] = $value1;
}
}
}
}
return $result;
}
}
?>

View File

@ -1,90 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: array_intersect_uassoc.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace array_intersect_assoc()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.array_intersect_uassoc
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 5
* @require PHP 4.0.6 (is_callable)
*/
if (!function_exists('array_intersect_uassoc')) {
function array_intersect_uassoc()
{
// Sanity check
$args = func_get_args();
if (count($args) < 3) {
user_error('Wrong parameter count for array_intersect_ukey()', E_USER_WARNING);
return;
}
// Get compare function
$compare_func = array_pop($args);
if (!is_callable($compare_func)) {
if (is_array($compare_func)) {
$compare_func = $compare_func[0] . '::' . $compare_func[1];
}
user_error('array_intersect_uassoc() Not a valid callback ' .
$compare_func, E_USER_WARNING);
return;
}
// Check arrays
$array_count = count($args);
for ($i = 0; $i !== $array_count; $i++) {
if (!is_array($args[$i])) {
user_error('array_intersect_uassoc() Argument #' .
($i + 1) . ' is not an array', E_USER_WARNING);
return;
}
}
// Compare entries
$result = array();
foreach ($args[0] as $k => $v) {
for ($i = 0; $i < $array_count; $i++) {
$match = false;
foreach ($args[$i] as $kk => $vv) {
$compare = call_user_func_array($compare_func, array($k, $kk));
if ($compare === 0 && $v == $vv) {
$match = true;
continue 2;
}
}
if ($match === false) {
continue 2;
}
}
if ($match === true) {
$result[$k] = $v;
}
}
return $result;
}
}
?>

View File

@ -1,79 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: array_intersect_ukey.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace array_intersect_ukey()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.array_intersect_ukey
* @author Tom Buskens <ortega@php.net>
* @version $Revision: 1.1 $
* @since PHP 5.0.2
* @require PHP 4.0.6 (is_callable)
*/
if (!function_exists('array_intersect_ukey')) {
function array_intersect_ukey()
{
$args = func_get_args();
if (count($args) < 3) {
user_error('Wrong parameter count for array_intersect_ukey()', E_USER_WARNING);
return;
}
// Get compare function
$compare_func = array_pop($args);
if (!is_callable($compare_func)) {
if (is_array($compare_func)) {
$compare_func = $compare_func[0].'::'.$compare_func[1];
}
user_error('array_diff_ukey() Not a valid callback ' .
$compare_func, E_USER_WARNING);
return;
}
// Check arrays
$array_count = count($args);
for ($i = 0; $i !== $array_count; $i++) {
if (!is_array($args[$i])) {
user_error('array_intersect_ukey() Argument #' .
($i + 1) . ' is not an array', E_USER_WARNING);
return;
}
}
// Compare entries
$result = array();
foreach ($args[0] as $key1 => $value1) {
for ($i = 1; $i !== $array_count; $i++) {
foreach ($args[$i] as $key2 => $value2) {
if (!(call_user_func($compare_func, (string) $key1, (string) $key2))) {
$result[$key1] = $value1;
break 2;
}
}
}
}
return $result;
}
}
?>

View File

@ -1,83 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Stephan Schmidt <schst@php.net> |
// | Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: array_udiff.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace array_udiff()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.array_udiff
* @author Stephan Schmidt <schst@php.net>
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 5
* @require PHP 4.0.6 (is_callable)
*/
if (!function_exists('array_udiff')) {
function array_udiff()
{
$args = func_get_args();
if (count($args) < 3) {
user_error('Wrong parameter count for array_udiff()', E_USER_WARNING);
return;
}
// Get compare function
$compare_func = array_pop($args);
if (!is_callable($compare_func)) {
if (is_array($compare_func)) {
$compare_func = $compare_func[0] . '::' . $compare_func[1];
}
user_error('array_udiff() Not a valid callback ' .
$compare_func, E_USER_WARNING);
return;
}
// Check arrays
$cnt = count($args);
for ($i = 0; $i < $cnt; $i++) {
if (!is_array($args[$i])) {
user_error('array_udiff() Argument #' .
($i + 1). ' is not an array', E_USER_WARNING);
return;
}
}
$diff = array ();
// Traverse values of the first array
foreach ($args[0] as $key => $value) {
// Check all arrays
for ($i = 1; $i < $cnt; $i++) {
foreach ($args[$i] as $cmp_value) {
$result = call_user_func($compare_func, $value, $cmp_value);
if ($result === 0) {
continue 3;
}
}
}
$diff[$key] = $value;
}
return $diff;
}
}
?>

View File

@ -1,85 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Stephan Schmidt <schst@php.net> |
// | Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: array_udiff_assoc.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace array_udiff_assoc()
*
* @category PHP
* @package PHP_Compat
* @author Stephan Schmidt <schst@php.net>
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @link http://php.net/function.array-udiff-assoc
* @since PHP 5
* @require PHP 4.0.6 (is_callable)
*/
if (!function_exists('array_udiff_assoc')) {
function array_udiff_assoc()
{
$args = func_get_args();
if (count($args) < 3) {
user_error('Wrong parameter count for array_udiff_assoc()', E_USER_WARNING);
return;
}
// Get compare function
$compare_func = array_pop($args);
if (!is_callable($compare_func)) {
if (is_array($compare_func)) {
$compare_func = $compare_func[0] . '::' . $compare_func[1];
}
user_error('array_udiff_assoc() Not a valid callback ' .
$compare_func, E_USER_WARNING);
return;
}
// Check arrays
$count = count($args);
for ($i = 0; $i < $count; $i++) {
if (!is_array($args[$i])) {
user_error('array_udiff_assoc() Argument #' .
($i + 1) . ' is not an array', E_USER_WARNING);
return;
}
}
$diff = array ();
// Traverse values of the first array
foreach ($args[0] as $key => $value) {
// Check all arrays
for ($i = 1; $i < $count; $i++) {
if (!array_key_exists($key, $args[$i])) {
continue;
}
$result = call_user_func($compare_func, $value, $args[$i][$key]);
if ($result === 0) {
continue 2;
}
}
$diff[$key] = $value;
}
return $diff;
}
}
?>

View File

@ -1,82 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: array_udiff_uassoc.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace array_udiff_uassoc()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.array_udiff_uassoc
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 5
* @require PHP 4.0.6 (is_callable)
*/
if (!function_exists('array_udiff_uassoc')) {
function array_udiff_uassoc()
{
$args = func_get_args();
if (count($args) < 3) {
user_error('Wrong parameter count for array_udiff_uassoc()', E_USER_WARNING);
return;
}
// Get compare function
$compare_func = array_pop($args);
if (!is_callable($compare_func)) {
if (is_array($compare_func)) {
$compare_func = $compare_func[0] . '::' . $compare_func[1];
}
user_error('array_udiff_uassoc() Not a valid callback ' . $compare_func, E_USER_WARNING);
return;
}
// Check arrays
$count = count($args);
for ($i = 0; $i < $count; $i++) {
if (!is_array($args[$i])) {
user_error('array_udiff_uassoc() Argument #' .
($i + 1) . ' is not an array', E_USER_WARNING);
return;
}
}
// Traverse values of the first array
$diff = array ();
foreach ($args[0] as $key => $value) {
// Check all arrays
for ($i = 1; $i < $count; $i++) {
if (!array_key_exists($key, $args[$i])) {
continue;
}
$result = call_user_func($compare_func, $value, $args[$i][$key]);
if ($result === 0) {
continue 2;
}
}
$diff[$key] = $value;
}
return $diff;
}
}
?>

View File

@ -1,82 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Tom Buskens <ortega@php.net> |
// | Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: array_uintersect.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace array_uintersect()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.array_uintersect
* @author Tom Buskens <ortega@php.net>
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 5
* @require PHP 4.0.6 (is_callable)
*/
if (!function_exists('array_uintersect')) {
function array_uintersect()
{
$args = func_get_args();
if (count($args) < 3) {
user_error('wrong parameter count for array_uintersect()',
E_USER_WARNING);
return;
}
// Get compare function
$user_func = array_pop($args);
if (!is_callable($user_func)) {
if (is_array($user_func)) {
$user_func = $user_func[0] . '::' . $user_func[1];
}
user_error('array_uintersect() Not a valid callback ' .
$user_func, E_USER_WARNING);
return;
}
// Check arrays
$array_count = count($args);
for ($i = 0; $i < $array_count; $i++) {
if (!is_array($args[$i])) {
user_error('array_uintersect() Argument #' .
($i + 1) . ' is not an array', E_USER_WARNING);
return;
}
}
// Compare entries
$output = array();
foreach ($args[0] as $key => $item) {
for ($i = 1; $i !== $array_count; $i++) {
$array = $args[$i];
foreach($array as $key0 => $item0) {
if (!call_user_func($user_func, $item, $item0)) {
$output[$key] = $item;
}
}
}
}
return $output;
}
}
?>

View File

@ -1,81 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Tom Buskens <ortega@php.net> |
// | Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: array_uintersect_assoc.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace array_uintersect_assoc()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.array_uintersect_assoc
* @author Tom Buskens <ortega@php.net>
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 5
* @require PHP 4.0.6 (is_callable)
*/
if (!function_exists('array_uintersect_assoc')) {
function array_uintersect_assoc()
{
$args = func_get_args();
if (count($args) < 3) {
user_error('wrong parameter count for array_uintersect_assoc()', E_USER_WARNING);
return;
}
// Get compare function
$user_func = array_pop($args);
if (!is_callable($user_func)) {
if (is_array($user_func)) {
$user_func = $user_func[0] . '::' . $user_func[1];
}
user_error('array_uintersect_assoc() Not a valid callback ' .
$user_func, E_USER_WARNING);
return;
}
// Check arrays
$array_count = count($args);
for ($i = 0; $i < $array_count; $i++) {
if (!is_array($args[$i])) {
user_error('array_uintersect_assoc() Argument #' .
($i + 1) . ' is not an array', E_USER_WARNING);
return;
}
}
// Compare entries
$output = array();
foreach ($args[0] as $key => $item) {
for ($i = 1; $i !== $array_count; $i++) {
if (array_key_exists($key, $args[$i])) {
$compare = call_user_func($user_func, $item, $args[$i][$key]);
if ($compare === 0) {
$output[$key] = $item;
}
}
}
}
return $output;
}
}
?>

View File

@ -1,97 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: array_uintersect_uassoc.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace array_uintersect_uassoc()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.array_uintersect_uassoc
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 5
* @require PHP 4.0.6 (is_callable)
*/
if (!function_exists('array_uintersect_uassoc')) {
function array_uintersect_uassoc()
{
$args = func_get_args();
if (count($args) < 4) {
user_error('Wrong parameter count for array_uintersect_uassoc()',
E_USER_WARNING);
return;
}
// Get key_compare_func
$key_compare_func = array_pop($args);
if (!is_callable($key_compare_func)) {
if (is_array($key_compare_func)) {
$key_compare_func = $key_compare_func[0] . '::' . $key_compare_func[1];
}
user_error('array_uintersect_uassoc() Not a valid callback ' .
$key_compare_func, E_USER_WARNING);
return;
}
// Get data_compare_func
$data_compare_func = array_pop($args);
if (!is_callable($data_compare_func)) {
if (is_array($data_compare_func)) {
$data_compare_func = $data_compare_func[0] . '::' . $data_compare_func[1];
}
user_error('array_uintersect_uassoc() Not a valid callback '
. $data_compare_func, E_USER_WARNING);
return;
}
// Check arrays
$count = count($args);
for ($i = 0; $i !== $count; $i++) {
if (!is_array($args[$i])) {
user_error('array_uintersect_uassoc() Argument #' .
($i + 1) . ' is not an array', E_USER_WARNING);
return;
}
}
// Traverse values of the first array
$intersect = array ();
foreach ($args[0] as $key => $value) {
// Check against each array
for ($i = 1; $i < $count; $i++) {
// Traverse each element in current array
foreach ($args[$i] as $ckey => $cvalue) {
// Compare key and value
if (call_user_func($key_compare_func, $key, $ckey) === 0 &&
call_user_func($data_compare_func, $value, $cvalue) === 0)
{
$intersect[$key] = $value;
continue;
}
}
}
}
return $intersect;
}
}
?>

View File

@ -1,68 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Tom Buskens <ortega@php.net> |
// | Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: array_walk_recursive.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace array_walk_recursive()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.array_walk_recursive
* @author Tom Buskens <ortega@php.net>
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 5
* @require PHP 4.0.6 (is_callable)
*/
if (!function_exists('array_walk_recursive')) {
function array_walk_recursive(&$input, $funcname)
{
if (!is_callable($funcname)) {
if (is_array($funcname)) {
$funcname = $funcname[0] . '::' . $funcname[1];
}
user_error('array_walk_recursive() Not a valid callback ' . $user_func,
E_USER_WARNING);
return;
}
if (!is_array($input)) {
user_error('array_walk_recursive() The argument should be an array',
E_USER_WARNING);
return;
}
$args = func_get_args();
foreach ($input as $key => $item) {
if (is_array($item)) {
array_walk_recursive($item, $funcname, $args);
$input[$key] = $item;
} else {
$args[0] = &$item;
$args[1] = &$key;
call_user_func_array($funcname, $args);
$input[$key] = $item;
}
}
}
}
?>

View File

@ -1,56 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: clone.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace clone()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/language.oop5.cloning
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 5.0.0
* @require PHP 4.0.0 (user_error)
*/
if (version_compare(phpversion(), '5.0') === -1) {
// Needs to be wrapped in eval as clone is a keyword in PHP5
eval('
function clone($object)
{
// Sanity check
if (!is_object($object)) {
user_error(\'clone() __clone method called on non-object\', E_USER_WARNING);
return;
}
// Use serialize/unserialize trick to deep copy the object
$object = unserialize(serialize($object));
// If there is a __clone method call it on the "new" class
if (method_exists($object, \'__clone\')) {
$object->__clone();
}
return $object;
}
');
}
?>

View File

@ -1,79 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Michael Wallner <mike@php.net> |
// | Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: convert_uudecode.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace convert_uudecode()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.convert_uudecode
* @author Michael Wallner <mike@php.net>
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 5
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('convert_uudecode')) {
function convert_uudecode($string)
{
// Sanity check
if (!is_scalar($string)) {
user_error('convert_uuencode() expects parameter 1 to be string, ' .
gettype($string) . ' given', E_USER_WARNING);
return false;
}
if (strlen($string) < 8) {
user_error('convert_uuencode() The given parameter is not a valid uuencoded string', E_USER_WARNING);
return false;
}
$decoded = '';
foreach (explode("\n", $string) as $line) {
$c = count($bytes = unpack('c*', substr(trim($line), 1)));
while ($c % 4) {
$bytes[++$c] = 0;
}
foreach (array_chunk($bytes, 4) as $b) {
$b0 = $b[0] == 0x60 ? 0 : $b[0] - 0x20;
$b1 = $b[1] == 0x60 ? 0 : $b[1] - 0x20;
$b2 = $b[2] == 0x60 ? 0 : $b[2] - 0x20;
$b3 = $b[3] == 0x60 ? 0 : $b[3] - 0x20;
$b0 <<= 2;
$b0 |= ($b1 >> 4) & 0x03;
$b1 <<= 4;
$b1 |= ($b2 >> 2) & 0x0F;
$b2 <<= 6;
$b2 |= $b3 & 0x3F;
$decoded .= pack('c*', $b0, $b1, $b2);
}
}
return rtrim($decoded, "\0");
}
}
?>

View File

@ -1,79 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Michael Wallner <mike@php.net> |
// | Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: convert_uuencode.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace convert_uuencode()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.convert_uuencode
* @author Michael Wallner <mike@php.net>
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 5
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('convert_uuencode')) {
function convert_uuencode($string)
{
// Sanity check
if (!is_scalar($string)) {
user_error('convert_uuencode() expects parameter 1 to be string, ' .
gettype($string) . ' given', E_USER_WARNING);
return false;
}
$u = 0;
$encoded = '';
while ($c = count($bytes = unpack('c*', substr($string, $u, 45)))) {
$u += 45;
$encoded .= pack('c', $c + 0x20);
while ($c % 3) {
$bytes[++$c] = 0;
}
foreach (array_chunk($bytes, 3) as $b) {
$b0 = ($b[0] & 0xFC) >> 2;
$b1 = (($b[0] & 0x03) << 4) + (($b[1] & 0xF0) >> 4);
$b2 = (($b[1] & 0x0F) << 2) + (($b[2] & 0xC0) >> 6);
$b3 = $b[2] & 0x3F;
$b0 = $b0 ? $b0 + 0x20 : 0x60;
$b1 = $b1 ? $b1 + 0x20 : 0x60;
$b2 = $b2 ? $b2 + 0x20 : 0x60;
$b3 = $b3 ? $b3 + 0x20 : 0x60;
$encoded .= pack('c*', $b0, $b1, $b2, $b3);
}
$encoded .= "\n";
}
// Add termination characters
$encoded .= "\x60\n";
return $encoded;
}
}
?>

View File

@ -1,67 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Laurent Laville <pear@laurent-laville.org> |
// | Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: debug_print_backtrace.php,v 1.1 2005/07/23 05:56:02 Tony Exp $
/**
* Replace debug_print_backtrace()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.debug_print_backtrace
* @author Laurent Laville <pear@laurent-laville.org>
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 5
* @require PHP 4.0.0
*/
if (!function_exists('debug_print_backtrace2')) {
function debug_print_backtrace2()
{
// Get backtrace
$backtrace = debug_backtrace();
// Unset call to debug_print_backtrace
array_shift($backtrace);
// Iterate backtrace
$calls = array();
foreach ($backtrace as $i => $call) {
$location = $call['file'] . ':' . $call['line'];
$function = (isset($call['class'])) ?
$call['class'] . '.' . $call['function'] :
$call['function'];
$params = '';
if (isset($call['args'])) {
$params = implode(', ', $call['args']);
}
$calls[] = sprintf('#%d %s(%s) called at [%s]',
$i,
$function,
$params,
$location);
}
echo implode("\n", $calls);
}
}
?>

View File

@ -1,57 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: file_get_contents.php,v 1.1 2005/07/23 05:56:03 Tony Exp $
/**
* Replace file_get_contents()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.file_get_contents
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @internal resource_context is not supported
* @since PHP 5
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('file_get_contents')) {
function file_get_contents($filename, $incpath = false, $resource_context = null)
{
if (false === $fh = fopen($filename, 'rb', $incpath)) {
user_error('file_get_contents() failed to open stream: No such file or directory',
E_USER_WARNING);
return false;
}
clearstatcache();
if ($fsize = @filesize($filename)) {
$data = fread($fh, $fsize);
} else {
$data = '';
while (!feof($fh)) {
$data .= fread($fh, 8192);
}
}
fclose($fh);
return $data;
}
}
?>

View File

@ -1,104 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: file_put_contents.php,v 1.1 2005/07/23 05:56:03 Tony Exp $
if (!defined('FILE_USE_INCLUDE_PATH')) {
define('FILE_USE_INCLUDE_PATH', 1);
}
if (!defined('FILE_APPEND')) {
define('FILE_APPEND', 8);
}
/**
* Replace file_put_contents()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.file_put_contents
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @internal resource_context is not supported
* @since PHP 5
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('file_put_contents')) {
function file_put_contents($filename, $content, $flags = null, $resource_context = null)
{
// If $content is an array, convert it to a string
if (is_array($content)) {
$content = implode('', $content);
}
// If we don't have a string, throw an error
if (!is_scalar($content)) {
user_error('file_put_contents() The 2nd parameter should be either a string or an array',
E_USER_WARNING);
return false;
}
// Get the length of date to write
$length = strlen($content);
// Check what mode we are using
$mode = ($flags & FILE_APPEND) ?
$mode = 'a' :
$mode = 'w';
// Check if we're using the include path
$use_inc_path = ($flags & FILE_USE_INCLUDE_PATH) ?
true :
false;
// Open the file for writing
if (($fh = @fopen($filename, $mode, $use_inc_path)) === false) {
user_error('file_put_contents() failed to open stream: Permission denied',
E_USER_WARNING);
return false;
}
// Write to the file
$bytes = 0;
if (($bytes = @fwrite($fh, $content)) === false) {
$errormsg = sprintf('file_put_contents() Failed to write %d bytes to %s',
$length,
$filename);
user_error($errormsg, E_USER_WARNING);
return false;
}
// Close the handle
@fclose($fh);
// Check all the data was written
if ($bytes != $length) {
$errormsg = sprintf('file_put_contents() Only %d of %d bytes written, possibly out of free disk space.',
$bytes,
$length);
user_error($errormsg, E_USER_WARNING);
return false;
}
// Return length
return $bytes;
}
}
?>

View File

@ -1,54 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: fprintf.php,v 1.1 2005/07/23 05:56:03 Tony Exp $
/**
* Replace fprintf()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.fprintf
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 5
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('fprintf')) {
function fprintf() {
$args = func_get_args();
if (count($args) < 2) {
user_error('Wrong parameter count for fprintf()', E_USER_WARNING);
return;
}
$resource_handle = array_shift($args);
$format = array_shift($args);
if (!is_resource($resource_handle)) {
user_error('fprintf() supplied argument is not a valid stream resource',
E_USER_WARNING);
return false;
}
return fwrite($resource_handle, vsprintf($format, $args));
}
}
?>

View File

@ -1,77 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: get_headers.php,v 1.1 2005/07/23 05:56:03 Tony Exp $
/**
* Replace get_headers()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.get_headers
* @author Aeontech <aeontech@gmail.com>
* @author Cpurruc <cpurruc@fh-landshut.de>
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 5.0.0
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('get_headers')) {
function get_headers($url, $format = 0)
{
// Init
$urlinfo = parse_url($url);
$port = isset($urlinfo['port']) ? $urlinfo['port'] : 80;
// Connect
$fp = fsockopen($urlinfo['host'], $port, $errno, $errstr, 30);
if ($fp === false) {
return false;
}
// Send request
$head = 'HEAD ' . $urlinfo['path'] .
(isset($urlinfo['query']) ? '?' . $urlinfo['query'] : '') .
' HTTP/1.0' . "\r\n" .
'Host: ' . $urlinfo['host'] . "\r\n\r\n";
fputs($fp, $head);
// Read
while (!feof($fp)) {
if ($header = trim(fgets($fp, 1024))) {
list($key) = explode(':', $header);
if ($format === 1) {
// First element is the HTTP header type, such as HTTP 200 OK
// It doesn't have a separate name, so check for it
if ($key == $header) {
$headers[] = $header;
} else {
$headers[$key] = substr($header, strlen($key)+2);
}
} else {
$headers[] = $header;
}
}
}
return $headers;
}
}
?>

View File

@ -1,39 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Stephan Schmidt <schst@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: get_include_path.php,v 1.1 2005/07/23 05:56:03 Tony Exp $
/**
* Replace get_include_path()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.get_include_path
* @author Stephan Schmidt <schst@php.net>
* @version $Revision: 1.1 $
* @since PHP 4.3.0
* @require PHP 4.0.0
*/
if (!function_exists('get_include_path')) {
function get_include_path()
{
return ini_get('include_path');
}
}
?>

View File

@ -1,72 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: David Irvine <dave@codexweb.co.za> |
// | Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: html_entity_decode.php,v 1.1 2005/07/23 05:56:03 Tony Exp $
if (!defined('ENT_NOQUOTES')) {
define('ENT_NOQUOTES', 0);
}
if (!defined('ENT_COMPAT')) {
define('ENT_COMPAT', 2);
}
if (!defined('ENT_QUOTES')) {
define('ENT_QUOTES', 3);
}
/**
* Replace html_entity_decode()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.html_entity_decode
* @author David Irvine <dave@codexweb.co.za>
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 4.3.0
* @internal Setting the charset will not do anything
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('html_entity_decode')) {
function html_entity_decode($string, $quote_style = ENT_COMPAT, $charset = null)
{
if (!is_int($quote_style)) {
user_error('html_entity_decode() expects parameter 2 to be long, ' .
gettype($quote_style) . ' given', E_USER_WARNING);
return;
}
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
// Add single quote to translation table;
$trans_tbl['&#039;'] = '\'';
// Not translating double quotes
if ($quote_style & ENT_NOQUOTES) {
// Remove double quote from translation table
unset($trans_tbl['&quot;']);
}
return strtr($string, $trans_tbl);
}
}
?>

View File

@ -1,99 +0,0 @@
<?PHP
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Stephan Schmidt <schst@php.net> |
// | Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: http_build_query.php,v 1.1 2005/07/23 05:56:03 Tony Exp $
/**
* Replace function http_build_query()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.http-build-query
* @author Stephan Schmidt <schst@php.net>
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 5
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('http_build_query')) {
function http_build_query($formdata, $numeric_prefix = null)
{
// If $formdata is an object, convert it to an array
if (is_object($formdata)) {
$formdata = get_object_vars($formdata);
}
// Check we have an array to work with
if (!is_array($formdata)) {
user_error('http_build_query() Parameter 1 expected to be Array or Object. Incorrect value given.',
E_USER_WARNING);
return false;
}
// If the array is empty, return null
if (empty($formdata)) {
return;
}
// Argument seperator
$separator = ini_get('arg_separator.output');
// Start building the query
$tmp = array ();
foreach ($formdata as $key => $val) {
if (is_integer($key) && $numeric_prefix != null) {
$key = $numeric_prefix . $key;
}
if (is_scalar($val)) {
array_push($tmp, urlencode($key).'='.urlencode($val));
continue;
}
// If the value is an array, recursively parse it
if (is_array($val)) {
array_push($tmp, __http_build_query($val, urlencode($key)));
continue;
}
}
return implode($separator, $tmp);
}
// Helper function
function __http_build_query ($array, $name)
{
$tmp = array ();
foreach ($array as $key => $value) {
if (is_array($value)) {
array_push($tmp, __http_build_query($value, sprintf('%s[%s]', $name, $key)));
} elseif (is_scalar($value)) {
array_push($tmp, sprintf('%s[%s]=%s', $name, urlencode($key), urlencode($value)));
} elseif (is_object($value)) {
array_push($tmp, __http_build_query(get_object_vars($value), sprintf('%s[%s]', $name, $key)));
}
}
// Argument seperator
$separator = ini_get('arg_separator.output');
return implode($separator, $tmp);
}
}
?>

View File

@ -1,147 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: image_type_to_mime_type.php,v 1.1 2005/07/23 05:56:03 Tony Exp $
if (!defined('IMAGETYPE_GIF')) {
define('IMAGETYPE_GIF', 1);
}
if (!defined('IMAGETYPE_JPEG')) {
define('IMAGETYPE_JPEG', 2);
}
if (!defined('IMAGETYPE_PNG')) {
define('IMAGETYPE_PNG', 3);
}
if (!defined('IMAGETYPE_SWF')) {
define('IMAGETYPE_SWF', 4);
}
if (!defined('IMAGETYPE_PSD')) {
define('IMAGETYPE_PSD', 5);
}
if (!defined('IMAGETYPE_BMP')) {
define('IMAGETYPE_BMP', 6);
}
if (!defined('IMAGETYPE_TIFF_II')) {
define('IMAGETYPE_TIFF_II', 7);
}
if (!defined('IMAGETYPE_TIFF_MM')) {
define('IMAGETYPE_TIFF_MM', 8);
}
if (!defined('IMAGETYPE_JPC')) {
define('IMAGETYPE_JPC', 9);
}
if (!defined('IMAGETYPE_JP2')) {
define('IMAGETYPE_JP2', 10);
}
if (!defined('IMAGETYPE_JPX')) {
define('IMAGETYPE_JPX', 11);
}
if (!defined('IMAGETYPE_JB2')) {
define('IMAGETYPE_JB2', 12);
}
if (!defined('IMAGETYPE_SWC')) {
define('IMAGETYPE_SWC', 13);
}
if (!defined('IMAGETYPE_IFF')) {
define('IMAGETYPE_IFF', 14);
}
if (!defined('IMAGETYPE_WBMP')) {
define('IMAGETYPE_WBMP', 15);
}
if (!defined('IMAGETYPE_XBM')) {
define('IMAGETYPE_XBM', 16);
}
/**
* Replace image_type_to_mime_type()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.image_type_to_mime_type
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 4.3.0
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('image_type_to_mime_type')) {
function image_type_to_mime_type($imagetype)
{
switch ($imagetype):
case IMAGETYPE_GIF:
return 'image/gif';
break;
case IMAGETYPE_JPEG:
return 'image/jpeg';
break;
case IMAGETYPE_PNG:
return 'image/png';
break;
case IMAGETYPE_SWF:
case IMAGETYPE_SWC:
return 'application/x-shockwave-flash';
break;
case IMAGETYPE_PSD:
return 'image/psd';
break;
case IMAGETYPE_BMP:
return 'image/bmp';
break;
case IMAGETYPE_TIFF_MM:
case IMAGETYPE_TIFF_II:
return 'image/tiff';
break;
case IMAGETYPE_JP2:
return 'image/jp2';
break;
case IMAGETYPE_IFF:
return 'image/iff';
break;
case IMAGETYPE_WBMP:
return 'image/vnd.wap.wbmp';
break;
case IMAGETYPE_XBM:
return 'image/xbm';
break;
case IMAGETYPE_JPX:
case IMAGETYPE_JB2:
case IMAGETYPE_JPC:
default:
return 'application/octet-stream';
break;
endswitch;
}
}
?>

View File

@ -1,46 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: ob_get_clean.php,v 1.1 2005/07/23 05:56:03 Tony Exp $
/**
* Replace ob_get_clean()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.ob_get_clean
* @author Aidan Lister <aidan@php.net>
* @author Thiemo Mättig (http://maettig.com/)
* @version $Revision: 1.1 $
* @since PHP 4.3.0
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('ob_get_clean')) {
function ob_get_clean()
{
$contents = ob_get_contents();
if ($contents !== false) {
ob_end_clean();
}
return $contents;
}
}
?>

View File

@ -1,46 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: ob_get_flush.php,v 1.1 2005/07/23 05:56:03 Tony Exp $
/**
* Replace ob_get_flush()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.ob_get_flush
* @author Aidan Lister <aidan@php.net>
* @author Thiemo Mättig (http://maettig.com/)
* @version $Revision: 1.1 $
* @since PHP 4.3.0
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('ob_get_flush')) {
function ob_get_flush()
{
$contents = ob_get_contents();
if ($contents !== false) {
ob_end_flush();
}
return $contents;
}
}
?>

View File

@ -1,86 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: php_strip_whitespace.php,v 1.1 2005/07/23 05:56:03 Tony Exp $
/**
* Replace php_strip_whitespace()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.php_strip_whitespace
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 5
* @require PHP 4.0.0 (user_error) + Tokenizer extension
*/
if (!function_exists('php_strip_whitespace')) {
function php_strip_whitespace($file)
{
// Sanity check
if (!is_scalar($file)) {
user_error('php_strip_whitespace() expects parameter 1 to be string, ' .
gettype($file) . ' given', E_USER_WARNING);
return;
}
// Load file / tokens
$source = implode('', file($file));
$tokens = token_get_all($source);
// Init
$source = '';
$was_ws = false;
// Process
foreach ($tokens as $token) {
if (is_string($token)) {
// Single character tokens
$source .= $token;
} else {
list($id, $text) = $token;
switch ($id) {
// Skip all comments
case T_COMMENT:
case T_ML_COMMENT:
case T_DOC_COMMENT:
break;
// Remove whitespace
case T_WHITESPACE:
// We don't want more than one whitespace in a row replaced
if ($was_ws !== true) {
$source .= ' ';
}
$was_ws = true;
break;
default:
$was_ws = false;
$source .= $text;
break;
}
}
}
return $source;
}
}
?>

View File

@ -1,37 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Stephan Schmidt <schst@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: restore_include_path.php,v 1.1 2005/07/23 05:56:03 Tony Exp $
/**
* Replace restore_include_path()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.restore_include_path
* @author Stephan Schmidt <schst@php.net>
* @version $Revision: 1.1 $
* @since PHP 4.3.0
*/
if (!function_exists('restore_include_path')) {
function restore_include_path()
{
return ini_restore('include_path');
}
}
?>

View File

@ -1,69 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: scandir.php,v 1.1 2005/07/23 05:56:03 Tony Exp $
/**
* Replace scandir()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.scandir
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 5
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('scandir')) {
function scandir($directory, $sorting_order = 0)
{
if (!is_string($directory)) {
user_error('scandir() expects parameter 1 to be string, ' .
gettype($directory) . ' given', E_USER_WARNING);
return;
}
if (!is_int($sorting_order) && !is_bool($sorting_order)) {
user_error('scandir() expects parameter 2 to be long, ' .
gettype($sorting_order) . ' given', E_USER_WARNING);
return;
}
if (!is_dir($directory) || (false === $fh = @opendir($directory))) {
user_error('scandir() failed to open dir: Invalid argument', E_USER_WARNING);
return false;
}
$files = array ();
while (false !== ($filename = readdir($fh))) {
$files[] = $filename;
}
closedir($fh);
if ($sorting_order == 1) {
rsort($files);
} else {
sort($files);
}
return $files;
}
}
?>

View File

@ -1,37 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Stephan Schmidt <schst@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: set_include_path.php,v 1.1 2005/07/23 05:56:03 Tony Exp $
/**
* Replace set_include_path()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.set_include_path
* @author Stephan Schmidt <schst@php.net>
* @version $Revision: 1.1 $
* @since PHP 4.3.0
*/
if (!function_exists('set_include_path')) {
function set_include_path($new_include_path)
{
return ini_set('include_path', $new_include_path);
}
}
?>

View File

@ -1,113 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: str_ireplace.php,v 1.1 2005/07/23 05:56:03 Tony Exp $
/**
* Replace str_ireplace()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.str_ireplace
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 5
* @require PHP 4.0.0 (user_error)
* @note count not by returned by reference, to enable
* change '$count = null' to '&$count'
*/
if (!function_exists('str_ireplace')) {
function str_ireplace($search, $replace, $subject, $count = null)
{
// Sanity check
if (is_string($search) && is_array($replace)) {
user_error('Array to string conversion', E_USER_NOTICE);
$replace = (string) $replace;
}
// If search isn't an array, make it one
if (!is_array($search)) {
$search = array ($search);
}
$search = array_values($search);
// If replace isn't an array, make it one, and pad it to the length of search
if (!is_array($replace)) {
$replace_string = $replace;
$replace = array ();
for ($i = 0, $c = count($search); $i < $c; $i++) {
$replace[$i] = $replace_string;
}
}
$replace = array_values($replace);
// Check the replace array is padded to the correct length
$length_replace = count($replace);
$length_search = count($search);
if ($length_replace < $length_search) {
for ($i = $length_replace; $i < $length_search; $i++) {
$replace[$i] = '';
}
}
// If subject is not an array, make it one
$was_array = false;
if (!is_array($subject)) {
$was_array = true;
$subject = array ($subject);
}
// Loop through each subject
$count = 0;
foreach ($subject as $subject_key => $subject_value) {
// Loop through each search
foreach ($search as $search_key => $search_value) {
// Split the array into segments, in between each part is our search
$segments = explode(strtolower($search_value), strtolower($subject_value));
// The number of replacements done is the number of segments minus the first
$count += count($segments) - 1;
$pos = 0;
// Loop through each segment
foreach ($segments as $segment_key => $segment_value) {
// Replace the lowercase segments with the upper case versions
$segments[$segment_key] = substr($subject_value, $pos, strlen($segment_value));
// Increase the position relative to the initial string
$pos += strlen($segment_value) + strlen($search_value);
}
// Put our original string back together
$subject_value = implode($replace[$search_key], $segments);
}
$result[$subject_key] = $subject_value;
}
// Check if subject was initially a string and return it as a string
if ($was_array === true) {
return $result[0];
}
// Otherwise, just return the array
return $result;
}
}
?>

View File

@ -1,53 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: str_shuffle.php,v 1.1 2005/07/23 05:56:03 Tony Exp $
/**
* Replace str_shuffle()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.str_shuffle
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 4.3.0
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('str_shuffle')) {
function str_shuffle($str)
{
$newstr = '';
$strlen = strlen($str);
$str = (string) $str;
// Seed
list($usec, $sec) = explode(' ', microtime());
$seed = (float) $sec + ((float) $usec * 100000);
mt_srand($seed);
// Shuffle
for ($i = 0; $strlen > $i; $i++) {
$newstr .= $str[mt_rand(0, $strlen - 1)];
}
return $newstr;
}
}
?>

View File

@ -1,52 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: str_split.php,v 1.1 2005/07/23 05:56:03 Tony Exp $
/**
* Replace str_split()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.str_split
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 5
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('str_split')) {
function str_split($string, $split_length = 1)
{
if (!is_scalar($split_length)) {
user_error('str_split() expects parameter 2 to be long, ' .
gettype($split_length) . ' given', E_USER_WARNING);
return false;
}
$split_length = (int) $split_length;
if ($split_length < 1) {
user_error('str_split() The length of each segment must be greater than zero', E_USER_WARNING);
return false;
}
preg_match_all('/.{1,' . $split_length . '}/s', $string, $matches);
return $matches[0];
}
}
?>

View File

@ -1,68 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: str_word_count.php,v 1.1 2005/07/23 05:56:03 Tony Exp $
/**
* Replace str_word_count()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.str_word_count
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 4.3.0
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('str_word_count')) {
function str_word_count($string, $format = null)
{
if ($format !== 1 && $format !== 2 && $format !== null) {
user_error('str_word_count() The specified format parameter, "' . $format . '" is invalid',
E_USER_WARNING);
return false;
}
$word_string = preg_replace('/[0-9]+/', '', $string);
$word_array = preg_split('/[^A-Za-z0-9_\']+/', $word_string, -1, PREG_SPLIT_NO_EMPTY);
switch ($format) {
case null:
$result = count($word_array);
break;
case 1:
$result = $word_array;
break;
case 2:
$lastmatch = 0;
$word_assoc = array();
foreach ($word_array as $word) {
$word_assoc[$lastmatch = strpos($string, $word, $lastmatch)] = $word;
$lastmatch += strlen($word);
}
$result = $word_assoc;
break;
}
return $result;
}
}
?>

View File

@ -1,73 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: stripos.php,v 1.1 2005/07/23 05:56:03 Tony Exp $
/**
* Replace stripos()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.stripos
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 5
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('stripos')) {
function stripos($haystack, $needle, $offset = null)
{
if (!is_scalar($haystack)) {
user_error('stripos() expects parameter 1 to be string, ' .
gettype($haystack) . ' given', E_USER_WARNING);
return false;
}
if (!is_scalar($needle)) {
user_error('stripos() needle is not a string or an integer.', E_USER_WARNING);
return false;
}
if (!is_int($offset) && !is_bool($offset) && !is_null($offset)) {
user_error('stripos() expects parameter 3 to be long, ' .
gettype($offset) . ' given', E_USER_WARNING);
return false;
}
// Manipulate the string if there is an offset
$fix = 0;
if (!is_null($offset)) {
if ($offset > 0) {
$haystack = substr($haystack, $offset, strlen($haystack) - $offset);
$fix = $offset;
}
}
$segments = explode(strtolower($needle), strtolower($haystack), 2);
// Check there was a match
if (count($segments) == 1) {
return false;
}
$position = strlen($segments[0]) + $fix;
return $position;
}
}
?>

View File

@ -1,63 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Stephan Schmidt <schst@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: strpbrk.php,v 1.1 2005/07/23 05:56:03 Tony Exp $
/**
* Replace strpbrk()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.strpbrk
* @author Stephan Schmidt <schst@php.net>
* @version $Revision: 1.1 $
* @since PHP 5
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('strpbrk')) {
function strpbrk($haystack, $char_list)
{
if (!is_scalar($haystack)) {
user_error('strpbrk() expects parameter 1 to be string, ' .
gettype($haystack) . ' given', E_USER_WARNING);
return false;
}
if (!is_scalar($char_list)) {
user_error('strpbrk() expects parameter 2 to be scalar, ' .
gettype($needle) . ' given', E_USER_WARNING);
return false;
}
$haystack = (string) $haystack;
$char_list = (string) $char_list;
$len = strlen($haystack);
for ($i = 0; $i < $len; $i++) {
$char = substr($haystack, $i, 1);
if (strpos($char_list, $char) === false) {
continue;
}
return substr($haystack, $i);
}
return false;
}
}
?>

View File

@ -1,82 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Aidan Lister <aidan@php.net> |
// | Stephan Schmidt <schst@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: strripos.php,v 1.1 2005/07/23 05:56:03 Tony Exp $
/**
* Replace strripos()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.strripos
* @author Aidan Lister <aidan@php.net>
* @author Stephan Schmidt <schst@php.net>
* @version $Revision: 1.1 $
* @since PHP 5
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('strripos')) {
function strripos($haystack, $needle, $offset = null)
{
if (!is_scalar($haystack)) {
user_error('strripos() expects parameter 1 to be scalar, ' .
gettype($haystack) . ' given', E_USER_WARNING);
return false;
}
if (!is_scalar($needle)) {
user_error('strripos() expects parameter 2 to be scalar, ' .
gettype($needle) . ' given', E_USER_WARNING);
return false;
}
if (!is_int($offset) && !is_bool($offset) && !is_null($offset)) {
user_error('strripos() expects parameter 3 to be long, ' .
gettype($offset) . ' given', E_USER_WARNING);
return false;
}
// Manipulate the string if there is an offset
$fix = 0;
if (!is_null($offset)) {
// If the offset is larger than the haystack, return
if (abs($offset) >= strlen($haystack)) {
return false;
}
// Check whether offset is negative or positive
if ($offset > 0) {
$haystack = substr($haystack, $offset, strlen($haystack) - $offset);
// We need to add this to the position of the needle
$fix = $offset;
} else {
$haystack = substr($haystack, 0, strlen($haystack) + $offset);
}
}
$segments = explode(strtolower($needle), strtolower($haystack));
$last_seg = count($segments) - 1;
$position = strlen($haystack) + $fix - strlen($segments[$last_seg]) - strlen($needle);
return $position;
}
}
?>

View File

@ -1,74 +0,0 @@
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Tom Buskens <ortega@php.net> |
// | Aidan Lister <aidan@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: substr_compare.php,v 1.1 2005/07/23 05:56:03 Tony Exp $
/**
* Replace substr_compare()
*
* @category PHP
* @package PHP_Compat
* @link http://php.net/function.substr_compare
* @author Tom Buskens <ortega@php.net>
* @author Aidan Lister <aidan@php.net>
* @version $Revision: 1.1 $
* @since PHP 5
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('substr_compare')) {
function substr_compare($main_str, $str, $offset, $length = null, $case_insensitive = false)
{
if (!is_string($main_str)) {
user_error('substr_compare() expects parameter 1 to be string, ' .
gettype($main_str) . ' given', E_USER_WARNING);
return;
}
if (!is_string($str)) {
user_error('substr_compare() expects parameter 2 to be string, ' .
gettype($str) . ' given', E_USER_WARNING);
return;
}
if (!is_int($offset)) {
user_error('substr_compare() expects parameter 3 to be long, ' .
gettype($offset) . ' given', E_USER_WARNING);
return;
}
if (is_null($length)) {
$length = strlen($main_str) - $offset;
} elseif ($offset >= strlen($main_str)) {
user_error('substr_compare() The start position cannot exceed initial string length',
E_USER_WARNING);
return false;
}
$main_str = substr($main_str, $offset, $length);
$str = substr($str, 0, strlen($main_str));
if ($case_insensitive === false) {
return strcmp($main_str, $str);
} else {
return strcasecmp($main_str, $str);
}
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -1,182 +1,182 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// | PHP Version 4 | // | PHP Version 4 |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group | // | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, | // | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is | // | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at | // | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. | // | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to | // | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to | // | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. | // | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// | Author: Stefan Neufeind <pear.neufeind@speedpartner.de> | // | Author: Stefan Neufeind <pear.neufeind@speedpartner.de> |
// +----------------------------------------------------------------------+ // +----------------------------------------------------------------------+
// //
// $Id: Color.php,v 1.3 2005/09/14 17:25:46 nosey Exp $ // $Id: Color.php,v 1.3 2005/09/14 17:25:46 nosey Exp $
/** /**
* Class for color-handling * Class for color-handling
* *
* @author Stefan Neufeind <pear.neufeind@speedpartner.de> * @author Stefan Neufeind <pear.neufeind@speedpartner.de>
* @package Image_Canvas * @package Image_Canvas
* @category images * @category images
* @license The PHP License, version 2.02 * @license The PHP License, version 2.02
*/ */
/** /**
* Color class to be extended; from package PEAR::Image_Color * Color class to be extended; from package PEAR::Image_Color
*/ */
require_once 'Image/Color.php'; require_once 'Image/Color.php';
/** /**
* Class for color-handling * Class for color-handling
* *
* This is used to extend the functionality of the current PEAR::Image_Color v0.4. * This is used to extend the functionality of the current PEAR::Image_Color v0.4.
* I hope to be allowed to incorporate some of the improvements in a new Image_Color release. * I hope to be allowed to incorporate some of the improvements in a new Image_Color release.
* *
* @author Stefan Neufeind <pear.neufeind@speedpartner.de> * @author Stefan Neufeind <pear.neufeind@speedpartner.de>
* @package Image_Canvas * @package Image_Canvas
* @access public * @access public
*/ */
class Image_Canvas_Color extends Image_Color class Image_Canvas_Color extends Image_Color
{ {
/** /**
* Allocates a color in the given image. * Allocates a color in the given image.
* *
* Userdefined color specifications get translated into * Userdefined color specifications get translated into
* an array of rgb values. * an array of rgb values.
* *
* @param resource GD-resource * @param resource GD-resource
* @param mixed any color representation supported by color2RGB() * @param mixed any color representation supported by color2RGB()
* @return resource Image color handle * @return resource Image color handle
* @see color2RGB() * @see color2RGB()
* @access public * @access public
* @static * @static
*/ */
function allocateColor(&$img, $color) function allocateColor(&$img, $color)
{ {
$color = Image_Canvas_Color::color2RGB($color); $color = Image_Canvas_Color::color2RGB($color);
if (($color[3] == 255) || (!function_exists("imagecolorallocatealpha"))) { if (($color[3] == 255) || (!function_exists("imagecolorallocatealpha"))) {
return imagecolorallocate($img, $color[0], $color[1], $color[2]); return imagecolorallocate($img, $color[0], $color[1], $color[2]);
} else { } else {
return imagecolorallocatealpha($img, $color[0], $color[1], $color[2], 127-round(($color[3]*127)/255)); return imagecolorallocatealpha($img, $color[0], $color[1], $color[2], 127-round(($color[3]*127)/255));
} }
} }
/** /**
* Convert any color-representation into an array of 4 ints (RGBA). * Convert any color-representation into an array of 4 ints (RGBA).
* *
* Userdefined color specifications get translated into * Userdefined color specifications get translated into
* an array of rgb values. * an array of rgb values.
* *
* @param mixed any color representation supported by Image_Canvas_Color::color2RGB() * @param mixed any color representation supported by Image_Canvas_Color::color2RGB()
* @return array Array of 4 ints (RGBA-representation) * @return array Array of 4 ints (RGBA-representation)
* @access public * @access public
* @static * @static
*/ */
function color2RGB($color) function color2RGB($color)
{ {
if (is_array($color)) { if (is_array($color)) {
if (!is_numeric($color[0])) { if (!is_numeric($color[0])) {
return null; // error return null; // error
} }
if (count($color) == 3) { // assume RGB-color if (count($color) == 3) { // assume RGB-color
// 255 = alpha-value; full opaque // 255 = alpha-value; full opaque
return array((int) $color[0], return array((int) $color[0],
(int) $color[1], (int) $color[1],
(int) $color[2], (int) $color[2],
255); 255);
} }
if (count($color) == 4) { // assume RGBA-color if (count($color) == 4) { // assume RGBA-color
// 255 = alpha-value; full opaque // 255 = alpha-value; full opaque
return array((int) $color[0], return array((int) $color[0],
(int) $color[1], (int) $color[1],
(int) $color[2], (int) $color[2],
(int) $color[3]); (int) $color[3]);
} }
return null; // error return null; // error
} elseif (is_string($color)) { } elseif (is_string($color)) {
$alphaPos = strpos($color, '@'); $alphaPos = strpos($color, '@');
if ($alphaPos === false) { if ($alphaPos === false) {
$alpha = 255; $alpha = 255;
} else { } else {
$alphaFloat = (float) substr($color, $alphaPos+1); $alphaFloat = (float) substr($color, $alphaPos+1);
// restrict to range 0..1 // restrict to range 0..1
$alphaFloat = max(min($alphaFloat, 1), 0); $alphaFloat = max(min($alphaFloat, 1), 0);
$alpha = (int) round((float) 255 * $alphaFloat); $alpha = (int) round((float) 255 * $alphaFloat);
$color = substr($color, 0, $alphaPos); $color = substr($color, 0, $alphaPos);
} }
if ($color[0] == '#') { // hex-color given, e.g. #FFB4B4 if ($color[0] == '#') { // hex-color given, e.g. #FFB4B4
$tempColor = parent::hex2rgb($color); $tempColor = parent::hex2rgb($color);
return array((int) $tempColor[0], return array((int) $tempColor[0],
(int) $tempColor[1], (int) $tempColor[1],
(int) $tempColor[2], (int) $tempColor[2],
$alpha); $alpha);
} }
if (strpos($color,'%') !== false) { if (strpos($color,'%') !== false) {
$tempColor = parent::percentageColor2RGB($color); $tempColor = parent::percentageColor2RGB($color);
return array((int) $tempColor[0], return array((int) $tempColor[0],
(int) $tempColor[1], (int) $tempColor[1],
(int) $tempColor[2], (int) $tempColor[2],
$alpha); $alpha);
} else { } else {
$tempColor = parent::namedColor2RGB($color); $tempColor = parent::namedColor2RGB($color);
return array((int) $tempColor[0], return array((int) $tempColor[0],
(int) $tempColor[1], (int) $tempColor[1],
(int) $tempColor[2], (int) $tempColor[2],
$alpha); $alpha);
} }
} else { } else {
return null; // error return null; // error
} }
} }
/** /**
* getRange * getRange
* Given a degree, you can get the range of colors between one color and * Given a degree, you can get the range of colors between one color and
* another color. * another color.
* *
* @access public * @access public
* @param string How much each 'step' between the colors we should take. * @param string How much each 'step' between the colors we should take.
* @return array Returns an array of all the colors, one element for each color. * @return array Returns an array of all the colors, one element for each color.
*/ */
function getRange ($degrees) function getRange ($degrees)
{ {
$tempColors = parent::getRange($degrees); $tempColors = parent::getRange($degrees);
// now add alpha-channel information // now add alpha-channel information
$steps = count($tempColors); $steps = count($tempColors);
for($counter=0;$counter<$steps;$counter++) { for($counter=0;$counter<$steps;$counter++) {
$tempColors[$counter] = parent::hex2rgb($tempColors[$counter]); $tempColors[$counter] = parent::hex2rgb($tempColors[$counter]);
unset($tempColors[$counter]['hex']); unset($tempColors[$counter]['hex']);
$tempColors[$counter][3] = (int) round( $tempColors[$counter][3] = (int) round(
(((float) $this->color1[3]*($steps-$counter))+ (((float) $this->color1[3]*($steps-$counter))+
((float) $this->color2[3]*($counter)) ((float) $this->color2[3]*($counter))
) / $steps ) / $steps
); );
} }
return $tempColors; return $tempColors;
} }
/** /**
* Internal method to correctly set the colors. * Internal method to correctly set the colors.
* *
* @param mixed color 1 * @param mixed color 1
* @param mixed color 2 * @param mixed color 2
* @access private * @access private
*/ */
function _setColors ( $col1, $col2 ) function _setColors ( $col1, $col2 )
{ {
$this->color1 = Image_Canvas_Color::color2RGB($col1); $this->color1 = Image_Canvas_Color::color2RGB($col1);
$this->color2 = Image_Canvas_Color::color2RGB($col2); $this->color2 = Image_Canvas_Color::color2RGB($col2);
} }
} }
?> ?>

View File

@ -1,12 +1,12 @@
This is where the font files are located. This is where the font files are located.
Font files can be found at: Font files can be found at:
MS CoreFonts MS CoreFonts
http://corefonts.sourceforge.net/ http://corefonts.sourceforge.net/
Divide By Zero (most are cartoonish) Divide By Zero (most are cartoonish)
http://fonts.tom7.com/ http://fonts.tom7.com/
MING FDB Fonts MING FDB Fonts
http://ming.sf.net/ http://ming.sf.net/

View File

@ -1,25 +1,25 @@
Arial,arial.ttf Arial,arial.ttf
Arial Bold,arialbd.ttf Arial Bold,arialbd.ttf
Arial Bold Italic,arialbi.ttf Arial Bold Italic,arialbi.ttf
Arial Italic,ariali.ttf Arial Italic,ariali.ttf
Courier New,cour.ttf Courier New,cour.ttf
Courier New Bold,courbd.ttf Courier New Bold,courbd.ttf
Courier New Bold Italic,courbi.ttf Courier New Bold Italic,courbi.ttf
Courier New Italic,couri.ttf Courier New Italic,couri.ttf
Garamond,gara.ttf Garamond,gara.ttf
Garamond Bold,garabd.ttf Garamond Bold,garabd.ttf
Garamond Italic,garait.ttf Garamond Italic,garait.ttf
Gothic,gothic.ttf Gothic,gothic.ttf
Gothic Bold,gothicb.ttf Gothic Bold,gothicb.ttf
Gothic Bold Italic,gothicbi.ttf Gothic Bold Italic,gothicbi.ttf
Gothic Italic,gothici.ttf Gothic Italic,gothici.ttf
Sans Serif,micross.ttf Sans Serif,micross.ttf
Reference Sans Serif,refsan.ttf Reference Sans Serif,refsan.ttf
Times New Roman,times.ttf Times New Roman,times.ttf
Times New Roman Bold,timesbd.ttf Times New Roman Bold,timesbd.ttf
Times New Roman Bold Italic,timesbi.ttf Times New Roman Bold Italic,timesbi.ttf
Times New Roman Italic,timesi.ttf Times New Roman Italic,timesi.ttf
Verdana,verdana.ttf Verdana,verdana.ttf
Verdana Bold,verdanab.ttf Verdana Bold,verdanab.ttf
Verdana Bold Italic,verdanaz.ttf Verdana Bold Italic,verdanaz.ttf
Verdana Italic,verdanai.ttf Verdana Italic,verdanai.ttf

File diff suppressed because it is too large Load Diff

View File

@ -1,119 +1,119 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Canvas * Image_Canvas
* *
* Canvas class to handle JPEG format. * Canvas class to handle JPEG format.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Canvas * @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: JPG.php,v 1.2 2005/08/24 20:37:34 nosey Exp $ * @version CVS: $Id: JPG.php,v 1.2 2005/08/24 20:37:34 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212 * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/ */
/** /**
* Include file Image/Canvas/GD.php * Include file Image/Canvas/GD.php
*/ */
require_once 'Image/Canvas/GD.php'; require_once 'Image/Canvas/GD.php';
/** /**
* JPEG Canvas class. * JPEG Canvas class.
* *
* @category Images * @category Images
* @package Image_Canvas * @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212 * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/ */
class Image_Canvas_GD_JPG extends Image_Canvas_GD class Image_Canvas_GD_JPG extends Image_Canvas_GD
{ {
/** /**
* The JPEG quality * The JPEG quality
* @var int * @var int
* @access private * @access private
*/ */
var $_quality = 75; var $_quality = 75;
/** /**
* Create the JPEG canvas * Create the JPEG canvas
* *
* Additional parameters other than those available for common {@link * Additional parameters other than those available for common {@link
* Image_Graph_Canvas_GD} class are: * Image_Graph_Canvas_GD} class are:
* *
* 'quality' The JPEG quality in as a percentage value from 0 (lowest * 'quality' The JPEG quality in as a percentage value from 0 (lowest
* quality, smallest file) to 100 (highest quality, biggest file) * quality, smallest file) to 100 (highest quality, biggest file)
* *
* @param array $param Parameter array * @param array $param Parameter array
*/ */
function Image_Canvas_GD_JPG($param) function Image_Canvas_GD_JPG($param)
{ {
parent::Image_Canvas_GD($param); parent::Image_Canvas_GD($param);
if (isset($param['quality'])) { if (isset($param['quality'])) {
$this->_quality = max(0, min(100, $param['quality'])); $this->_quality = max(0, min(100, $param['quality']));
} }
$this->rectangle( $this->rectangle(
array( array(
'x0' => $this->_left, 'x0' => $this->_left,
'y0' => $this->_top, 'y0' => $this->_top,
'x1' => $this->_left + $this->_width - 1, 'x1' => $this->_left + $this->_width - 1,
'y1' => $this->_top + $this->_height - 1, 'y1' => $this->_top + $this->_height - 1,
'fill' => 'white', 'fill' => 'white',
'line' => 'transparent' 'line' => 'transparent'
) )
); );
} }
/** /**
* Output the result of the canvas * Output the result of the canvas
* *
* @param array $param Parameter array * @param array $param Parameter array
* @abstract * @abstract
*/ */
function show($param = false) function show($param = false)
{ {
parent::show($param); parent::show($param);
header('Content-type: image/jpg'); header('Content-type: image/jpg');
header('Content-Disposition: inline; filename = \"'. basename($_SERVER['PHP_SELF'], '.php') . '.jpg\"'); header('Content-Disposition: inline; filename = \"'. basename($_SERVER['PHP_SELF'], '.php') . '.jpg\"');
ImageJPEG($this->_canvas, '', $this->_quality); ImageJPEG($this->_canvas, '', $this->_quality);
ImageDestroy($this->_canvas); ImageDestroy($this->_canvas);
} }
/** /**
* Output the result of the canvas * Output the result of the canvas
* *
* @param array $param Parameter array * @param array $param Parameter array
* @abstract * @abstract
*/ */
function save($param = false) function save($param = false)
{ {
parent::save($param); parent::save($param);
ImageJPEG($this->_canvas, $param['filename'], $this->_quality); ImageJPEG($this->_canvas, $param['filename'], $this->_quality);
ImageDestroy($this->_canvas); ImageDestroy($this->_canvas);
} }
} }
?> ?>

View File

@ -1,125 +1,125 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Canvas * Image_Canvas
* *
* Canvas class to handle PNG format. * Canvas class to handle PNG format.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Canvas * @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: PNG.php,v 1.3 2005/08/24 20:37:34 nosey Exp $ * @version CVS: $Id: PNG.php,v 1.3 2005/08/24 20:37:34 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212 * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/ */
/** /**
* Include file Image/Canvas/GD.php * Include file Image/Canvas/GD.php
*/ */
require_once 'Image/Canvas/GD.php'; require_once 'Image/Canvas/GD.php';
/** /**
* PNG Canvas class. * PNG Canvas class.
* *
* @category Images * @category Images
* @package Image_Canvas * @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212 * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/ */
class Image_Canvas_GD_PNG extends Image_Canvas_GD class Image_Canvas_GD_PNG extends Image_Canvas_GD
{ {
/** /**
* Create the PNG canvas * Create the PNG canvas
* *
* @param array $param Parameter array * @param array $param Parameter array
*/ */
function Image_Canvas_GD_PNG($param) function Image_Canvas_GD_PNG($param)
{ {
parent::Image_Canvas_GD($param); parent::Image_Canvas_GD($param);
if ((isset($param['transparent'])) && ($param['transparent']) && if ((isset($param['transparent'])) && ($param['transparent']) &&
($this->_gd2) ($this->_gd2)
) { ) {
if ($param['transparent'] === true) { if ($param['transparent'] === true) {
$transparent = '#123ABD'; $transparent = '#123ABD';
} else { } else {
$transparent = $param['transparent']; $transparent = $param['transparent'];
} }
$color = $this->_color($transparent); $color = $this->_color($transparent);
$trans = ImageColorTransparent($this->_canvas, $color); $trans = ImageColorTransparent($this->_canvas, $color);
$this->rectangle( $this->rectangle(
array( array(
'x0' => $this->_left, 'x0' => $this->_left,
'y0' => $this->_top, 'y0' => $this->_top,
'x1' => $this->_left + $this->_width - 1, 'x1' => $this->_left + $this->_width - 1,
'y1' => $this->_top + $this->_height - 1, 'y1' => $this->_top + $this->_height - 1,
'fill' => 'opague', 'fill' => 'opague',
'line' => 'transparent' 'line' => 'transparent'
) )
); );
} else { } else {
$this->rectangle( $this->rectangle(
array( array(
'x0' => $this->_left, 'x0' => $this->_left,
'y0' => $this->_top, 'y0' => $this->_top,
'x1' => $this->_left + $this->_width - 1, 'x1' => $this->_left + $this->_width - 1,
'y1' => $this->_top + $this->_height - 1, 'y1' => $this->_top + $this->_height - 1,
'fill' => 'white', 'fill' => 'white',
'line' => 'transparent' 'line' => 'transparent'
) )
); );
} }
} }
/** /**
* Output the result of the canvas * Output the result of the canvas
* *
* @param array $param Parameter array * @param array $param Parameter array
* @abstract * @abstract
*/ */
function show($param = false) function show($param = false)
{ {
parent::show($param); parent::show($param);
header('Content-type: image/png'); header('Content-type: image/png');
header('Content-Disposition: inline; filename = \"'. basename($_SERVER['PHP_SELF'], '.php') . '.png\"'); header('Content-Disposition: inline; filename = \"'. basename($_SERVER['PHP_SELF'], '.php') . '.png\"');
ImagePNG($this->_canvas); ImagePNG($this->_canvas);
ImageDestroy($this->_canvas); ImageDestroy($this->_canvas);
} }
/** /**
* Output the result of the canvas * Output the result of the canvas
* *
* @param array $param Parameter array * @param array $param Parameter array
* @abstract * @abstract
*/ */
function save($param = false) function save($param = false)
{ {
parent::save($param); parent::save($param);
ImagePNG($this->_canvas, $param['filename']); ImagePNG($this->_canvas, $param['filename']);
ImageDestroy($this->_canvas); ImageDestroy($this->_canvas);
} }
} }
?> ?>

View File

@ -1,354 +1,354 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Canvas * Image_Canvas
* *
* Class for handling output as a HTML imagemap * Class for handling output as a HTML imagemap
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Canvas * @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: ImageMap.php,v 1.6 2005/08/17 17:59:11 nosey Exp $ * @version CVS: $Id: ImageMap.php,v 1.8 2006/10/24 18:58:16 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212 * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/ */
/** /**
* Class for handling output as a HTML imagemap * Class for handling output as a HTML imagemap
* *
* @category Images * @category Images
* @package Image_Canvas * @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212 * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
* @since version 0.2.0 * @since version 0.2.0
*/ */
class Image_Canvas_ImageMap extends Image_Canvas class Image_Canvas_ImageMap extends Image_Canvas
{ {
/** /**
* The image map (if any) * The image map (if any)
* @var array * @var array
* @access private * @access private
*/ */
var $_map = array(); var $_map = array();
/** /**
* Add a map tag * Add a map tag
* @param string $shape The shape, either rect, circle or polygon * @param string $shape The shape, either rect, circle or polygon
* @param string $coords The list of coordinates for the shape * @param string $coords The list of coordinates for the shape
* @param array $params Parameter array * @param array $params Parameter array
*/ */
function _addMapTag($shape, $coords, $params) function _addMapTag($shape, $coords, $params)
{ {
if (isset($params['url'])) { if (isset($params['url'])) {
$url = $params['url']; $url = $params['url'];
$target = (isset($params['target']) ? $params['target'] : false); $target = (isset($params['target']) ? $params['target'] : false);
$alt = (isset($params['alt']) ? $params['alt'] : false); $alt = (isset($params['alt']) ? $params['alt'] : false);
$tags = ''; $tags = '';
if (isset($params['htmltags'])) { if (isset($params['htmltags'])) {
foreach ($params['htmltags'] as $key => $value) { foreach ($params['htmltags'] as $key => $value) {
$tags .= ' '; $tags .= ' ';
if (strpos($value, '"') >= 0) { if (strpos($value, '"') !== false) {
$tags .= $key . '=\'' . $value . '\''; $tags .= $key . '=\'' . $value . '\'';
} else { } else {
$tags .= $key . '="' . $value . '"'; $tags .= $key . '="' . $value . '"';
} }
} }
} }
$this->_map[] = $this->_map[] =
'<area shape="' . $shape . '" coords="' . $coords . '" href="' . $url . '"' . '<area shape="' . $shape . '" coords="' . $coords . '" href="' . $url . '"' .
($target ? ' target="' . $target . '"' : '') . ($target ? ' target="' . $target . '"' : '') .
($alt ? ' alt="' . $alt . '"' : '') . ($alt ? ' alt="' . $alt . '"' : '') .
(isset($params['id']) ? ' id="' . $params['id'] . '"' : '') . (isset($params['id']) ? ' id="' . $params['id'] . '"' : '') .
$tags . $tags .
'>'; '>';
} }
} }
/** /**
* Draw a line * Draw a line
* *
* Parameter array: * Parameter array:
* 'x0': int X start point * 'x0': int X start point
* 'y0': int Y start point * 'y0': int Y start point
* 'x1': int X end point * 'x1': int X end point
* 'y1': int Y end point * 'y1': int Y end point
* 'color': mixed [optional] The line color * 'color': mixed [optional] The line color
* 'mapsize': int [optional] The size of the image map (surrounding the line) * 'mapsize': int [optional] The size of the image map (surrounding the line)
* @param array $params Parameter array * @param array $params Parameter array
*/ */
function line($params) function line($params)
{ {
if (isset($params['url'])) { if (isset($params['url'])) {
$mapsize = (isset($params['mapsize']) ? $params['mapsize'] : 2); $mapsize = (isset($params['mapsize']) ? $params['mapsize'] : 2);
$this->_addMapTag( $this->_addMapTag(
'polygon', 'polygon',
$this->_getX($params['x0'] - $mapsize) . ',' . $this->_getX($params['x0'] - $mapsize) . ',' .
$this->_getY($params['y0'] - $mapsize) . ',' . $this->_getY($params['y0'] - $mapsize) . ',' .
$this->_getX($params['x1'] + $mapsize) . ',' . $this->_getX($params['x1'] + $mapsize) . ',' .
$this->_getY($params['y1'] - $mapsize) . ',' . $this->_getY($params['y1'] - $mapsize) . ',' .
$this->_getX($params['x1'] + $mapsize) . ',' . $this->_getX($params['x1'] + $mapsize) . ',' .
$this->_getY($params['y1'] + $mapsize) . ',' . $this->_getY($params['y1'] + $mapsize) . ',' .
$this->_getX($params['x0'] - $mapsize) . ',' . $this->_getX($params['x0'] - $mapsize) . ',' .
$this->_getY($params['y0'] + $mapsize), $this->_getY($params['y0'] + $mapsize),
$params $params
); );
} }
parent::line($params); parent::line($params);
} }
/** /**
* Draws a polygon * Draws a polygon
* *
* Parameter array: * Parameter array:
* 'connect': bool [optional] Specifies whether the start point should be * 'connect': bool [optional] Specifies whether the start point should be
* connected to the endpoint (closed polygon) or not (connected line) * connected to the endpoint (closed polygon) or not (connected line)
* 'fill': mixed [optional] The fill color * 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color * 'line': mixed [optional] The line color
* 'map_vertices': bool [optional] Specifies whether the image map should map the vertices instead of the polygon as a whole * 'map_vertices': bool [optional] Specifies whether the image map should map the vertices instead of the polygon as a whole
* 'url': string [optional] URL to link the polygon as a whole to (also used for default in case 'map_vertices' is used) * 'url': string [optional] URL to link the polygon as a whole to (also used for default in case 'map_vertices' is used)
* 'alt': string [optional] Alternative text to show in the image map (also used for default in case 'map_vertices' is used) * 'alt': string [optional] Alternative text to show in the image map (also used for default in case 'map_vertices' is used)
* 'target': string [optional] The link target on the image map (also used for default in case 'map_vertices' is used) * 'target': string [optional] The link target on the image map (also used for default in case 'map_vertices' is used)
* @param array $params Parameter array * @param array $params Parameter array
*/ */
function polygon($params) function polygon($params)
{ {
if ((isset($params['map_vertices'])) && ($params['map_vertices'] === true)) { if ((isset($params['map_vertices'])) && ($params['map_vertices'] === true)) {
$mapsize = (isset($params['mapsize']) ? $params['mapsize'] : 2); $mapsize = (isset($params['mapsize']) ? $params['mapsize'] : 2);
foreach ($this->_polygon as $point) { foreach ($this->_polygon as $point) {
$vertex_param = $params; $vertex_param = $params;
if (isset($point['url'])) { if (isset($point['url'])) {
$vertex_param['url'] = $point['url']; $vertex_param['url'] = $point['url'];
} }
if (isset($point['target'])) { if (isset($point['target'])) {
$vertex_param['target'] = $point['target']; $vertex_param['target'] = $point['target'];
} }
if (isset($point['alt'])) { if (isset($point['alt'])) {
$vertex_param['alt'] = $point['alt']; $vertex_param['alt'] = $point['alt'];
} }
$vertex_mapsize = $mapsize; $vertex_mapsize = $mapsize;
if (isset($point['mapsize'])) { if (isset($point['mapsize'])) {
$vertex_mapsize = $point['mapsize']; $vertex_mapsize = $point['mapsize'];
} }
if (isset($point['htmltags'])) { if (isset($point['htmltags'])) {
$vertex_param['htmltags'] = $point['htmltags']; $vertex_param['htmltags'] = $point['htmltags'];
} }
$this->_addMapTag( $this->_addMapTag(
'circle', 'circle',
$this->_getX($point['X']) . ',' . $this->_getX($point['X']) . ',' .
$this->_getY($point['Y']) . ',' . $this->_getY($point['Y']) . ',' .
$mapsize, $mapsize,
$vertex_param $vertex_param
); );
} }
} }
else if (isset($params['url'])) { else if (isset($params['url'])) {
$points = ''; $points = '';
foreach ($this->_polygon as $point) { foreach ($this->_polygon as $point) {
if ($points != '') { if ($points != '') {
$points .= ','; $points .= ',';
} }
$points .= $this->_getX($point['X']) . ',' . $this->_getY($point['Y']); $points .= $this->_getX($point['X']) . ',' . $this->_getY($point['Y']);
} }
$this->_addMapTag('polygon', $points, $params); $this->_addMapTag('polygon', $points, $params);
} }
parent::polygon($params); parent::polygon($params);
} }
/** /**
* Draw a rectangle * Draw a rectangle
* *
* Parameter array: * Parameter array:
* 'x0': int X start point * 'x0': int X start point
* 'y0': int Y start point * 'y0': int Y start point
* 'x1': int X end point * 'x1': int X end point
* 'y1': int Y end point * 'y1': int Y end point
* 'fill': mixed [optional] The fill color * 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color * 'line': mixed [optional] The line color
* @param array $params Parameter array * @param array $params Parameter array
*/ */
function rectangle($params) function rectangle($params)
{ {
if (isset($params['url'])) { if (isset($params['url'])) {
$this->_addMapTag( $this->_addMapTag(
'rect', 'rect',
$this->_getX($params['x0']) . ',' . $this->_getX($params['x0']) . ',' .
$this->_getY($params['y0']) . ',' . $this->_getY($params['y0']) . ',' .
$this->_getX($params['x1']) . ',' . $this->_getX($params['x1']) . ',' .
$this->_getY($params['y1']), $this->_getY($params['y1']),
$params $params
); );
} }
parent::rectangle($params); parent::rectangle($params);
} }
/** /**
* Draw an ellipse * Draw an ellipse
* *
* Parameter array: * Parameter array:
* 'x': int X center point * 'x': int X center point
* 'y': int Y center point * 'y': int Y center point
* 'rx': int X radius * 'rx': int X radius
* 'ry': int Y radius * 'ry': int Y radius
* 'fill': mixed [optional] The fill color * 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color * 'line': mixed [optional] The line color
* @param array $params Parameter array * @param array $params Parameter array
*/ */
function ellipse($params) function ellipse($params)
{ {
if (isset($params['url'])) { if (isset($params['url'])) {
if ($params['rx'] == $params['ry']) { if ($params['rx'] == $params['ry']) {
$this->_addMapTag( $this->_addMapTag(
'circle', 'circle',
$this->_getX($params['x']) . ',' . $this->_getX($params['x']) . ',' .
$this->_getY($params['y']) . ',' . $this->_getY($params['y']) . ',' .
$this->_getX($params['rx']), $this->_getX($params['rx']),
$params $params
); );
} else { } else {
$points = ''; $points = '';
for ($v = 0; $v <= 360; $v += 30) { for ($v = 0; $v <= 360; $v += 30) {
if ($points != '') { if ($points != '') {
$points .= ','; $points .= ',';
} }
$points .= $points .=
round($this->_getX($params['x']) + $this->_getX($params['rx']) * cos(deg2rad($v % 360))) . ',' . round($this->_getX($params['x']) + $this->_getX($params['rx']) * cos(deg2rad($v % 360))) . ',' .
round($this->_getY($params['y']) + $this->_getX($params['ry']) * sin(deg2rad($v % 360))); round($this->_getY($params['y']) + $this->_getX($params['ry']) * sin(deg2rad($v % 360)));
} }
$this->_addMapTag( $this->_addMapTag(
'polygon', 'polygon',
$points, $points,
$params $params
); );
} }
} }
parent::ellipse($params); parent::ellipse($params);
} }
/** /**
* Draw a pie slice * Draw a pie slice
* *
* Parameter array: * Parameter array:
* 'x': int X center point * 'x': int X center point
* 'y': int Y center point * 'y': int Y center point
* 'rx': int X radius * 'rx': int X radius
* 'ry': int Y radius * 'ry': int Y radius
* 'v1': int The starting angle (in degrees) * 'v1': int The starting angle (in degrees)
* 'v2': int The end angle (in degrees) * 'v2': int The end angle (in degrees)
* 'srx': int [optional] Starting X-radius of the pie slice (i.e. for a doughnut) * 'srx': int [optional] Starting X-radius of the pie slice (i.e. for a doughnut)
* 'sry': int [optional] Starting Y-radius of the pie slice (i.e. for a doughnut) * 'sry': int [optional] Starting Y-radius of the pie slice (i.e. for a doughnut)
* 'fill': mixed [optional] The fill color * 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color * 'line': mixed [optional] The line color
* @param array $params Parameter array * @param array $params Parameter array
*/ */
function pieslice($params) function pieslice($params)
{ {
if (isset($params['url'])) { if (isset($params['url'])) {
$x = $this->_getX($params['x']); $x = $this->_getX($params['x']);
$y = $this->_getY($params['y']); $y = $this->_getY($params['y']);
$rx = $params['rx']; $rx = $params['rx'];
$ry = $params['ry']; $ry = $params['ry'];
$v1a = $params['v1']; $v1a = $params['v1'];
$v2a = $params['v2']; $v2a = $params['v2'];
$v1 = min($v1a, $v2a); $v1 = min($v1a, $v2a);
$v2 = max($v1a, $v2a); $v2 = max($v1a, $v2a);
$srx = (isset($params['srx']) ? $params['srx'] : 0); $srx = (isset($params['srx']) ? $params['srx'] : 0);
$sry = (isset($params['sry']) ? $params['sry'] : 0); $sry = (isset($params['sry']) ? $params['sry'] : 0);
$points = $points =
round(($x + $srx * cos(deg2rad($v1 % 360)))) . ',' . round(($x + $srx * cos(deg2rad($v1 % 360)))) . ',' .
round(($y + $sry * sin(deg2rad($v1 % 360)))) . ','; round(($y + $sry * sin(deg2rad($v1 % 360)))) . ',';
for ($v = $v1; $v < $v2; $v += 30) { for ($v = $v1; $v < $v2; $v += 30) {
$points .= $points .=
round(($x + $rx * cos(deg2rad($v % 360)))) . ',' . round(($x + $rx * cos(deg2rad($v % 360)))) . ',' .
round(($y + $ry * sin(deg2rad($v % 360)))) . ','; round(($y + $ry * sin(deg2rad($v % 360)))) . ',';
} }
$points .= $points .=
round(($x + $rx * cos(deg2rad($v2 % 360)))) . ',' . round(($x + $rx * cos(deg2rad($v2 % 360)))) . ',' .
round(($y + $ry * sin(deg2rad($v2 % 360)))); round(($y + $ry * sin(deg2rad($v2 % 360))));
if (($srx != 0) || ($sry != 0)) { if (($srx != 0) || ($sry != 0)) {
$points .= ','; $points .= ',';
for ($v = $v2; $v > $v1; $v -= 30) { for ($v = $v2; $v > $v1; $v -= 30) {
$points .= $points .=
round(($x + $srx * cos(deg2rad($v % 360)))) . ',' . round(($x + $srx * cos(deg2rad($v % 360)))) . ',' .
round(($y + $sry * sin(deg2rad($v % 360)))) . ','; round(($y + $sry * sin(deg2rad($v % 360)))) . ',';
} }
} }
$this->_addMapTag('polygon', $points, $params); $this->_addMapTag('polygon', $points, $params);
} }
parent::pieslice($params); parent::pieslice($params);
} }
/** /**
* Output the result of the canvas to the browser * Output the result of the canvas to the browser
* *
* @param array $params Parameter array, the contents and meaning depends on the actual Canvas * @param array $params Parameter array, the contents and meaning depends on the actual Canvas
* @abstract * @abstract
*/ */
function show($params = false) function show($params = false)
{ {
parent::show($params); parent::show($params);
if (count($this->_map) > 0) { if (count($this->_map) > 0) {
print $this->toHtml($params); print $this->toHtml($params);
} }
} }
/** /**
* Save the result of the canvas to a file * Save the result of the canvas to a file
* *
* Parameter array: * Parameter array:
* 'filename': string The file to output to * 'filename': string The file to output to
* @param array $params Parameter array, the contents and meaning depends on the actual Canvas * @param array $params Parameter array, the contents and meaning depends on the actual Canvas
* @abstract * @abstract
*/ */
function save($params = false) function save($params = false)
{ {
parent::save($params); parent::save($params);
$file = fopen($param['filename'], 'w+'); $file = fopen($params['filename'], 'w+');
fwrite($file, $this->toHtml($params)); fwrite($file, $this->toHtml($params));
fclose($file); fclose($file);
} }
/** /**
* Get a canvas specific HTML tag. * Get a canvas specific HTML tag.
* *
* Parameter array: * Parameter array:
* 'name': string The name of the image map * 'name': string The name of the image map
*/ */
function toHtml($params) function toHtml($params)
{ {
if (count($this->_map) > 0) { if (count($this->_map) > 0) {
return '<map name="' . $params['name'] . '">' . "\n\t" . implode($this->_map, "\n\t") . "\n</map>"; return '<map name="' . $params['name'] . '">' . "\n\t" . implode($this->_map, "\n\t") . "\n</map>";
} }
return ''; return '';
} }
} }
?> ?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,217 +1,217 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Canvas * Image_Canvas
* *
* Canvas based creation of images to facilitate different output formats * Canvas based creation of images to facilitate different output formats
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Canvas * @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Tool.php,v 1.3 2005/08/22 20:52:11 nosey Exp $ * @version CVS: $Id: Tool.php,v 1.3 2005/08/22 20:52:11 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212 * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/ */
/** /**
* This class contains a set of tool-functions. * This class contains a set of tool-functions.
* *
* These functions are all to be called statically * These functions are all to be called statically
* *
* @category Images * @category Images
* @package Image_Canvas * @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212 * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
* @abstract * @abstract
*/ */
class Image_Canvas_Tool class Image_Canvas_Tool
{ {
/** /**
* Maps a font name to an actual font file (fx. a .ttf file) * Maps a font name to an actual font file (fx. a .ttf file)
* *
* Used to translate names (i.e. 'Courier New' to 'cour.ttf' or * Used to translate names (i.e. 'Courier New' to 'cour.ttf' or
* '/Windows/Fonts/Cour.ttf') * '/Windows/Fonts/Cour.ttf')
* *
* Font names are translated using the tab-separated file * Font names are translated using the tab-separated file
* Image/Canvas/Tool/fontmap.txt. * Image/Canvas/Tool/fontmap.txt.
* *
* The translated font-name (or the original if no translation) exists is * The translated font-name (or the original if no translation) exists is
* then returned if it is an existing file, otherwise the file is searched * then returned if it is an existing file, otherwise the file is searched
* first in the path specified by IMAGE_CANVAS_SYSTEM_FONT_PATH defined in * first in the path specified by IMAGE_CANVAS_SYSTEM_FONT_PATH defined in
* Image/Canvas.php, then in the Image/Canvas/Fonts folder. If a font is * Image/Canvas.php, then in the Image/Canvas/Fonts folder. If a font is
* still not found and the name is not beginning with a '/' the search is * still not found and the name is not beginning with a '/' the search is
* left to the library, otherwise the font is deemed non-existing. * left to the library, otherwise the font is deemed non-existing.
* *
* @param string $name The name of the font * @param string $name The name of the font
* @param string $type The needed file type of the font * @param string $type The needed file type of the font
* @return string The filename of the font * @return string The filename of the font
* @static * @static
*/ */
function fontMap($name, $type = '.ttf') function fontMap($name, $type = '.ttf')
{ {
static $_fontMap; static $_fontMap;
if (!is_array($_fontMap)) { if (!is_array($_fontMap)) {
if (file_exists($fontmap = (dirname(__FILE__) . '/Fonts/fontmap.txt'))) { if (file_exists($fontmap = (dirname(__FILE__) . '/Fonts/fontmap.txt'))) {
$file = file($fontmap); $file = file($fontmap);
foreach($file as $fontmapping) { foreach($file as $fontmapping) {
list($fontname, $filenames) = explode(',', $fontmapping, 2); list($fontname, $filenames) = explode(',', $fontmapping, 2);
$fontname = trim($fontname); $fontname = trim($fontname);
$filenames = trim($filenames); $filenames = trim($filenames);
$filenames = explode(',', $filenames); $filenames = explode(',', $filenames);
foreach ($filenames as $filename) { foreach ($filenames as $filename) {
$type_pos = strrpos($filename, '.'); $type_pos = strrpos($filename, '.');
$type = substr($filename, $type_pos); $type = substr($filename, $type_pos);
$_fontMap[$fontname][$type] = $filename; $_fontMap[$fontname][$type] = $filename;
} }
} }
} }
} }
$type = strtolower($type); $type = strtolower($type);
if ((isset($_fontMap[$name])) && (isset($_fontMap[$name][$type]))) { if ((isset($_fontMap[$name])) && (isset($_fontMap[$name][$type]))) {
$filename = $_fontMap[$name][$type]; $filename = $_fontMap[$name][$type];
} else { } else {
$filename = $name; $filename = $name;
} }
if (substr($filename, -strlen($type)) !== $type) { if (substr($filename, -strlen($type)) !== $type) {
$filename .= $type; $filename .= $type;
} }
$result = false; $result = false;
if (file_exists($filename)) { if (file_exists($filename)) {
$result = $filename; $result = $filename;
} elseif (file_exists($file = (IMAGE_CANVAS_SYSTEM_FONT_PATH . $filename))) { } elseif (file_exists($file = (IMAGE_CANVAS_SYSTEM_FONT_PATH . $filename))) {
$result = $file; $result = $file;
} elseif (file_exists($file = (dirname(__FILE__) . '/Fonts/' . $filename))) { } elseif (file_exists($file = (dirname(__FILE__) . '/Fonts/' . $filename))) {
$result = $file; $result = $file;
} elseif (substr($name, 0, 1) !== '/') { } elseif (substr($name, 0, 1) !== '/') {
// leave it to the library to find the font // leave it to the library to find the font
$result = $name; $result = $name;
} }
return str_replace('\\', '/', $result); return str_replace('\\', '/', $result);
} }
/** /**
* Return the average of 2 points * Return the average of 2 points
* *
* @param double P1 1st point * @param double P1 1st point
* @param double P2 2nd point * @param double P2 2nd point
* @return double The average of P1 and P2 * @return double The average of P1 and P2
* @static * @static
*/ */
function mid($p1, $p2) function mid($p1, $p2)
{ {
return ($p1 + $p2) / 2; return ($p1 + $p2) / 2;
} }
/** /**
* Mirrors P1 in P2 by a amount of Factor * Mirrors P1 in P2 by a amount of Factor
* *
* @param double $p1 1st point, point to mirror * @param double $p1 1st point, point to mirror
* @param double $o2 2nd point, mirror point * @param double $o2 2nd point, mirror point
* @param double $factor Mirror factor, 0 returns $p2, 1 returns a pure * @param double $factor Mirror factor, 0 returns $p2, 1 returns a pure
* mirror, ie $p1 on the exact other side of $p2 * mirror, ie $p1 on the exact other side of $p2
* @return double $p1 mirrored in $p2 by Factor * @return double $p1 mirrored in $p2 by Factor
* @static * @static
*/ */
function mirror($p1, $p2, $factor = 1) function mirror($p1, $p2, $factor = 1)
{ {
return $p2 + $factor * ($p2 - $p1); return $p2 + $factor * ($p2 - $p1);
} }
/** /**
* Calculates a Bezier control point, this function must be called for BOTH * Calculates a Bezier control point, this function must be called for BOTH
* X and Y coordinates (will it work for 3D coordinates!?) * X and Y coordinates (will it work for 3D coordinates!?)
* *
* @param double $p1 1st point * @param double $p1 1st point
* @param double $p2 Point to * @param double $p2 Point to
* @param double $factor Mirror factor, 0 returns P2, 1 returns a pure * @param double $factor Mirror factor, 0 returns P2, 1 returns a pure
* mirror, i.e. P1 on the exact other side of P2 * mirror, i.e. P1 on the exact other side of P2
* @return double P1 mirrored in P2 by Factor * @return double P1 mirrored in P2 by Factor
* @static * @static
*/ */
function controlPoint($p1, $p2, $factor, $smoothFactor = 0.75) function controlPoint($p1, $p2, $factor, $smoothFactor = 0.75)
{ {
$sa = Image_Canvas_Tool::mirror($p1, $p2, $smoothFactor); $sa = Image_Canvas_Tool::mirror($p1, $p2, $smoothFactor);
$sb = Image_Canvas_Tool::mid($p2, $sa); $sb = Image_Canvas_Tool::mid($p2, $sa);
$m = Image_Canvas_Tool::mid($p2, $factor); $m = Image_Canvas_Tool::mid($p2, $factor);
$pC = Image_Canvas_Tool::mid($sb, $m); $pC = Image_Canvas_Tool::mid($sb, $m);
return $pC; return $pC;
} }
/** /**
* Calculates a Bezier point, this function must be called for BOTH X and Y * Calculates a Bezier point, this function must be called for BOTH X and Y
* coordinates (will it work for 3D coordinates!?) * coordinates (will it work for 3D coordinates!?)
* *
* @param double $t A position between $p2 and $p3, value between 0 and 1 * @param double $t A position between $p2 and $p3, value between 0 and 1
* @param double $p1 Point to use for calculating control points * @param double $p1 Point to use for calculating control points
* @param double $p2 Point 1 to calculate bezier curve between * @param double $p2 Point 1 to calculate bezier curve between
* @param double $p3 Point 2 to calculate bezier curve between * @param double $p3 Point 2 to calculate bezier curve between
* @param double $p4 Point to use for calculating control points * @param double $p4 Point to use for calculating control points
* @return double The bezier value of the point t between $p2 and $p3 using * @return double The bezier value of the point t between $p2 and $p3 using
* $p1 and $p4 to calculate control points * $p1 and $p4 to calculate control points
* @static * @static
*/ */
function bezier($t, $p1, $p2, $p3, $p4) function bezier($t, $p1, $p2, $p3, $p4)
{ {
// (1-t)^3*p1 + 3*(1-t)^2*t*p2 + 3*(1-t)*t^2*p3 + t^3*p4 // (1-t)^3*p1 + 3*(1-t)^2*t*p2 + 3*(1-t)*t^2*p3 + t^3*p4
return pow(1 - $t, 3) * $p1 + return pow(1 - $t, 3) * $p1 +
3 * pow(1 - $t, 2) * $t * $p2 + 3 * pow(1 - $t, 2) * $t * $p2 +
3 * (1 - $t) * pow($t, 2) * $p3 + 3 * (1 - $t) * pow($t, 2) * $p3 +
pow($t, 3) * $p4; pow($t, 3) * $p4;
} }
/** /**
* Gets the angle / slope of a line relative to horizontal (left -> right) * Gets the angle / slope of a line relative to horizontal (left -> right)
* *
* @param double $x0 The starting x point * @param double $x0 The starting x point
* @param double $y0 The starting y point * @param double $y0 The starting y point
* @param double $x1 The ending x point * @param double $x1 The ending x point
* @param double $y1 The ending y point * @param double $y1 The ending y point
* @param double The angle in degrees of the line * @param double The angle in degrees of the line
* @static * @static
*/ */
function getAngle($x0, $y0, $x1, $y1) function getAngle($x0, $y0, $x1, $y1)
{ {
$dx = ($x1 - $x0); $dx = ($x1 - $x0);
$dy = ($y1 - $y0); $dy = ($y1 - $y0);
$l = sqrt($dx * $dx + $dy * $dy); $l = sqrt($dx * $dx + $dy * $dy);
$v = rad2deg(asin(($y0 - $y1) / $l)); $v = rad2deg(asin(($y0 - $y1) / $l));
if ($dx < 0) { if ($dx < 0) {
$v = 180 - $v; $v = 180 - $v;
} }
return $v; return $v;
} }
} }
?> ?>

View File

@ -1,278 +1,278 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Canvas * Image_Canvas
* *
* Canvas based creation of images to facilitate different output formats * Canvas based creation of images to facilitate different output formats
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Canvas * @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: WithMap.php,v 1.3 2005/08/24 20:37:35 nosey Exp $ * @version CVS: $Id: WithMap.php,v 1.3 2005/08/24 20:37:35 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212 * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/ */
/** /**
* Class for handling different output formats including a HTML image map * Class for handling different output formats including a HTML image map
* *
* @category Images * @category Images
* @package Image_Canvas * @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212 * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
* @since version 0.2.0 * @since version 0.2.0
* @abstract * @abstract
*/ */
class Image_Canvas_WithMap extends Image_Canvas class Image_Canvas_WithMap extends Image_Canvas
{ {
/** /**
* The image map * The image map
* @var Image_Canvas_ImageMap * @var Image_Canvas_ImageMap
* @access private * @access private
*/ */
var $_imageMap = null; var $_imageMap = null;
/** /**
* Create the canvas. * Create the canvas.
* *
* Parameters available: * Parameters available:
* *
* 'width' The width of the graph on the canvas * 'width' The width of the graph on the canvas
* *
* 'height' The height of the graph on the canvas * 'height' The height of the graph on the canvas
* *
* 'left' The left offset of the graph on the canvas * 'left' The left offset of the graph on the canvas
* *
* 'top' The top offset of the graph on the canvas * 'top' The top offset of the graph on the canvas
* *
* 'usemap' Initialize an image map * 'usemap' Initialize an image map
* *
* @param array $params Parameter array * @param array $params Parameter array
* @abstract * @abstract
*/ */
function Image_Canvas_WithMap($params) function Image_Canvas_WithMap($params)
{ {
parent::Image_Canvas($params); parent::Image_Canvas($params);
if ((isset($params['usemap'])) && ($params['usemap'] === true)) { if ((isset($params['usemap'])) && ($params['usemap'] === true)) {
$this->_imageMap =& Image_Canvas::factory( $this->_imageMap =& Image_Canvas::factory(
'ImageMap', 'ImageMap',
array( array(
'left' => $this->_left, 'left' => $this->_left,
'top' => $this->_top, 'top' => $this->_top,
'width' => $this->_width, 'width' => $this->_width,
'height' => $this->_height 'height' => $this->_height
) )
); );
} }
} }
/** /**
* Draw a line * Draw a line
* *
* Parameter array: * Parameter array:
* 'x0': int X start point * 'x0': int X start point
* 'y0': int Y start point * 'y0': int Y start point
* 'x1': int X end point * 'x1': int X end point
* 'y1': int Y end point * 'y1': int Y end point
* 'color': mixed [optional] The line color * 'color': mixed [optional] The line color
* @param array $params Parameter array * @param array $params Parameter array
*/ */
function line($params) function line($params)
{ {
if (isset($this->_imageMap)) { if (isset($this->_imageMap)) {
$this->_imageMap->line($params); $this->_imageMap->line($params);
} }
parent::line($params); parent::line($params);
} }
/** /**
* Adds vertex to a polygon * Adds vertex to a polygon
* *
* Parameter array: * Parameter array:
* 'x': int X point * 'x': int X point
* 'y': int Y point * 'y': int Y point
* @param array $params Parameter array * @param array $params Parameter array
*/ */
function addVertex($params) function addVertex($params)
{ {
if (isset($this->_imageMap)) { if (isset($this->_imageMap)) {
$this->_imageMap->addVertex($params); $this->_imageMap->addVertex($params);
} }
parent::addVertex($params); parent::addVertex($params);
} }
/** /**
* Adds "splined" vertex to a polygon * Adds "splined" vertex to a polygon
* *
* Parameter array: * Parameter array:
* 'x': int X point * 'x': int X point
* 'y': int Y point * 'y': int Y point
* 'p1x': X Control point 1 * 'p1x': X Control point 1
* 'p1y': Y Control point 1 * 'p1y': Y Control point 1
* 'p2x': X Control point 2 * 'p2x': X Control point 2
* 'p2y': Y Control point 2 * 'p2y': Y Control point 2
* @param array $params Parameter array * @param array $params Parameter array
*/ */
function addSpline($params) function addSpline($params)
{ {
if (isset($this->_imageMap)) { if (isset($this->_imageMap)) {
$this->_imageMap->addSpline($params); $this->_imageMap->addSpline($params);
} }
parent::addSpline($params); parent::addSpline($params);
} }
/** /**
* Draws a polygon * Draws a polygon
* *
* Parameter array: * Parameter array:
* 'connect': bool [optional] Specifies whether the start point should be * 'connect': bool [optional] Specifies whether the start point should be
* connected to the endpoint (closed polygon) or not (connected line) * connected to the endpoint (closed polygon) or not (connected line)
* 'fill': mixed [optional] The fill color * 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color * 'line': mixed [optional] The line color
* @param array $params Parameter array * @param array $params Parameter array
*/ */
function polygon($params) function polygon($params)
{ {
if (isset($this->_imageMap)) { if (isset($this->_imageMap)) {
$this->_imageMap->polygon($params); $this->_imageMap->polygon($params);
} }
parent::polygon($params); parent::polygon($params);
} }
/** /**
* Draw a rectangle * Draw a rectangle
* *
* Parameter array: * Parameter array:
* 'x0': int X start point * 'x0': int X start point
* 'y0': int Y start point * 'y0': int Y start point
* 'x1': int X end point * 'x1': int X end point
* 'y1': int Y end point * 'y1': int Y end point
* 'fill': mixed [optional] The fill color * 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color * 'line': mixed [optional] The line color
* @param array $params Parameter array * @param array $params Parameter array
*/ */
function rectangle($params) function rectangle($params)
{ {
if (isset($this->_imageMap)) { if (isset($this->_imageMap)) {
$this->_imageMap->rectangle($params); $this->_imageMap->rectangle($params);
} }
parent::rectangle($params); parent::rectangle($params);
} }
/** /**
* Draw an ellipse * Draw an ellipse
* *
* Parameter array: * Parameter array:
* 'x': int X center point * 'x': int X center point
* 'y': int Y center point * 'y': int Y center point
* 'rx': int X radius * 'rx': int X radius
* 'ry': int Y radius * 'ry': int Y radius
* 'fill': mixed [optional] The fill color * 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color * 'line': mixed [optional] The line color
* @param array $params Parameter array * @param array $params Parameter array
*/ */
function ellipse($params) function ellipse($params)
{ {
if (isset($this->_imageMap)) { if (isset($this->_imageMap)) {
$this->_imageMap->ellipse($params); $this->_imageMap->ellipse($params);
} }
parent::ellipse($params); parent::ellipse($params);
} }
/** /**
* Draw a pie slice * Draw a pie slice
* *
* Parameter array: * Parameter array:
* 'x': int X center point * 'x': int X center point
* 'y': int Y center point * 'y': int Y center point
* 'rx': int X radius * 'rx': int X radius
* 'ry': int Y radius * 'ry': int Y radius
* 'v1': int The starting angle (in degrees) * 'v1': int The starting angle (in degrees)
* 'v2': int The end angle (in degrees) * 'v2': int The end angle (in degrees)
* 'srx': int [optional] Starting X-radius of the pie slice (i.e. for a doughnut) * 'srx': int [optional] Starting X-radius of the pie slice (i.e. for a doughnut)
* 'sry': int [optional] Starting Y-radius of the pie slice (i.e. for a doughnut) * 'sry': int [optional] Starting Y-radius of the pie slice (i.e. for a doughnut)
* 'fill': mixed [optional] The fill color * 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color * 'line': mixed [optional] The line color
* @param array $params Parameter array * @param array $params Parameter array
*/ */
function pieslice($params) function pieslice($params)
{ {
if (isset($this->_imageMap)) { if (isset($this->_imageMap)) {
$this->_imageMap->pieslice($params); $this->_imageMap->pieslice($params);
} }
parent::pieslice($params); parent::pieslice($params);
} }
/** /**
* Writes text * Writes text
* *
* Parameter array: * Parameter array:
* 'x': int X-point of text * 'x': int X-point of text
* 'y': int Y-point of text * 'y': int Y-point of text
* 'text': string The text to add * 'text': string The text to add
* 'alignment': array [optional] Alignment * 'alignment': array [optional] Alignment
* 'color': mixed [optional] The color of the text * 'color': mixed [optional] The color of the text
*/ */
function addText($params) function addText($params)
{ {
if (isset($this->_imageMap)) { if (isset($this->_imageMap)) {
$this->_imageMap->addText($params); $this->_imageMap->addText($params);
} }
parent::addText($params); parent::addText($params);
} }
/** /**
* Overlay image * Overlay image
* *
* Parameter array: * Parameter array:
* 'x': int X-point of overlayed image * 'x': int X-point of overlayed image
* 'y': int Y-point of overlayed image * 'y': int Y-point of overlayed image
* 'filename': string The filename of the image to overlay * 'filename': string The filename of the image to overlay
* 'width': int [optional] The width of the overlayed image (resizing if possible) * 'width': int [optional] The width of the overlayed image (resizing if possible)
* 'height': int [optional] The height of the overlayed image (resizing if possible) * 'height': int [optional] The height of the overlayed image (resizing if possible)
* 'alignment': array [optional] Alignment * 'alignment': array [optional] Alignment
*/ */
function image($params) function image($params)
{ {
if (isset($this->_imageMap)) { if (isset($this->_imageMap)) {
$this->_imageMap->image($params); $this->_imageMap->image($params);
} }
parent::image($params); parent::image($params);
} }
/** /**
* Get the imagemap * Get the imagemap
* @return Image_Graph_ImageMap The image map (or false if none) * @return Image_Graph_ImageMap The image map (or false if none)
*/ */
function &getImageMap() function &getImageMap()
{ {
$result = null; $result = null;
if (isset($this->_imageMap)) { if (isset($this->_imageMap)) {
$result =& $this->_imageMap; $result =& $this->_imageMap;
} }
return $result; return $result;
} }
} }
?> ?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,426 +1,437 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Class for axis handling. * Class for axis handling.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Axis * @subpackage Axis
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Category.php,v 1.17 2005/10/05 20:51:23 nosey Exp $ * @version CVS: $Id: Category.php,v 1.19 2006/03/02 12:15:17 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/Axis.php * Include file Image/Graph/Axis.php
*/ */
require_once 'Image/Graph/Axis.php'; require_once 'Image/Graph/Axis.php';
/** /**
* A normal axis thats displays labels with a 'interval' of 1. * A normal axis thats displays labels with a 'interval' of 1.
* This is basically a normal axis where the range is * This is basically a normal axis where the range is
* the number of labels defined, that is the range is explicitly defined * the number of labels defined, that is the range is explicitly defined
* when constructing the axis. * when constructing the axis.
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Axis * @subpackage Axis
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_Axis_Category extends Image_Graph_Axis class Image_Graph_Axis_Category extends Image_Graph_Axis
{ {
/** /**
* The labels shown on the axis * The labels shown on the axis
* @var array * @var array
* @access private * @access private
*/ */
var $_labels = false; var $_labels = false;
/** /**
* Image_Graph_Axis_Category [Constructor]. * Image_Graph_Axis_Category [Constructor].
* *
* @param int $type The type (direction) of the Axis * @param int $type The type (direction) of the Axis
*/ */
function Image_Graph_Axis_Category($type = IMAGE_GRAPH_AXIS_X) function Image_Graph_Axis_Category($type = IMAGE_GRAPH_AXIS_X)
{ {
parent::Image_Graph_Axis($type); parent::Image_Graph_Axis($type);
$this->_labels = array(); $this->_labels = array();
$this->setlabelInterval(1); $this->setlabelInterval(1);
} }
/** /**
* Gets the minimum value the axis will show. * Gets the minimum value the axis will show.
* *
* This is always 0 * This is always 0
* *
* @return double The minumum value * @return double The minumum value
* @access private * @access private
*/ */
function _getMinimum() function _getMinimum()
{ {
return 0; return 0;
} }
/** /**
* Gets the maximum value the axis will show. * Gets the maximum value the axis will show.
* *
* This is always the number of labels passed to the constructor. * This is always the number of labels passed to the constructor.
* *
* @return double The maximum value * @return double The maximum value
* @access private * @access private
*/ */
function _getMaximum() function _getMaximum()
{ {
return count($this->_labels) - ($this->_pushValues ? 0 : 1); return count($this->_labels) - 1;
} }
/** /**
* Sets the minimum value the axis will show. * Sets the minimum value the axis will show.
* *
* A minimum cannot be set on a SequentialAxis, it is always 0. * A minimum cannot be set on a SequentialAxis, it is always 0.
* *
* @param double Minimum The minumum value to use on the axis * @param double Minimum The minumum value to use on the axis
* @access private * @access private
*/ */
function _setMinimum($minimum) function _setMinimum($minimum)
{ {
} }
/** /**
* Sets the maximum value the axis will show * Sets the maximum value the axis will show
* *
* A maximum cannot be set on a SequentialAxis, it is always the number * A maximum cannot be set on a SequentialAxis, it is always the number
* of labels passed to the constructor. * of labels passed to the constructor.
* *
* @param double Maximum The maximum value to use on the axis * @param double Maximum The maximum value to use on the axis
* @access private * @access private
*/ */
function _setMaximum($maximum) function _setMaximum($maximum)
{ {
} }
/** /**
* Forces the minimum value of the axis * Forces the minimum value of the axis
* *
* A minimum cannot be set on a SequentialAxis, it is always 0. * <b>A minimum cannot be set on this type of axis</b>
* *
* @param double $minimum The minumum value to use on the axis * To modify the labels which are displayed on the axis, instead use
*/ * setLabelInterval($labels) where $labels is an array containing the
function forceMinimum($minimum, $userEnforce = true) * values/labels the axis should display. <b>Note!</b> Only values in
{ * this array will then be displayed on the graph!
} *
* @param double $minimum A minimum cannot be set on this type of axis
/** */
* Forces the maximum value of the axis function forceMinimum($minimum, $userEnforce = true)
* {
* A maximum cannot be set on a SequentialAxis, it is always the number }
* of labels passed to the constructor.
* /**
* @param double $maximum The maximum value to use on the axis * Forces the maximum value of the axis
*/ *
function forceMaximum($maximum, $userEnforce = true) * <b>A maximum cannot be set on this type of axis</b>
{ *
} * To modify the labels which are displayed on the axis, instead use
* setLabelInterval($labels) where $labels is an array containing the
/** * values/labels the axis should display. <b>Note!</b> Only values in
* Sets an interval for where labels are shown on the axis. * this array will then be displayed on the graph!
* *
* The label interval is rounded to nearest integer value * @param double $maximum A maximum cannot be set on this type of axis
* */
* @param double $labelInterval The interval with which labels are shown function forceMaximum($maximum, $userEnforce = true)
*/ {
function setLabelInterval($labelInterval = 'auto', $level = 1) }
{
if ($labelInterval == 'auto') { /**
parent::setLabelInterval(1); * Sets an interval for where labels are shown on the axis.
} else { *
parent::setLabelInterval(round($labelInterval)); * The label interval is rounded to nearest integer value.
} *
} * @param double $labelInterval The interval with which labels are shown
*/
/** function setLabelInterval($labelInterval = 'auto', $level = 1)
* Preprocessor for values, ie for using logarithmic axis {
* if (is_array($labelInterval)) {
* @param double $value The value to preprocess parent::setLabelInterval($labelInterval);
* @return double The preprocessed value } elseif ($labelInterval == 'auto') {
* @access private parent::setLabelInterval(1);
*/ } else {
function _value($value) parent::setLabelInterval(round($labelInterval));
{ }
// $the_value = array_search($value, $this->_labels); }
if (isset($this->_labels[$value])) {
$the_value = $this->_labels[$value]; /**
if ($the_value !== false) { * Preprocessor for values, ie for using logarithmic axis
return $the_value + ($this->_pushValues ? 0.5 : 0); *
} else { * @param double $value The value to preprocess
return 0; * @return double The preprocessed value
} * @access private
} */
} function _value($value)
{
// $the_value = array_search($value, $this->_labels);
/** if (isset($this->_labels[$value])) {
* Get the minor label interval with which axis label ticks are drawn. $the_value = $this->_labels[$value];
* if ($the_value !== false) {
* For a sequential axis this is always disabled (i.e false) return $the_value + ($this->_pushValues ? 0.5 : 0);
* } else {
* @return double The minor label interval, always false return 0;
* @access private }
*/ }
function _minorLabelInterval() }
{
return false;
} /**
* Get the minor label interval with which axis label ticks are drawn.
/** *
* Get the size in pixels of the axis. * For a sequential axis this is always disabled (i.e false)
* *
* For an x-axis this is the width of the axis including labels, and for an * @return double The minor label interval, always false
* y-axis it is the corrresponding height * @access private
* */
* @return int The size of the axis function _minorLabelInterval()
* @access private {
*/ return false;
function _size() }
{
if (!$this->_visible) { /**
return 0; * Get the size in pixels of the axis.
} *
* For an x-axis this is the width of the axis including labels, and for an
$this->_canvas->setFont($this->_getFont()); * y-axis it is the corrresponding height
*
$maxSize = 0; * @return int The size of the axis
foreach($this->_labels as $label => $id) { * @access private
$labelPosition = $this->_point($label); */
function _size()
if (is_object($this->_dataPreProcessor)) { {
$labelText = $this->_dataPreProcessor->_process($label); if (!$this->_visible) {
} else { return 0;
$labelText = $label; }
}
$this->_canvas->setFont($this->_getFont());
if ((($this->_type == IMAGE_GRAPH_AXIS_X) && (!$this->_transpose)) ||
(($this->_type != IMAGE_GRAPH_AXIS_X) && ($this->_transpose))) $maxSize = 0;
{ foreach($this->_labels as $label => $id) {
$maxSize = max($maxSize, $this->_canvas->textHeight($labelText)); $labelPosition = $this->_point($label);
} else {
$maxSize = max($maxSize, $this->_canvas->textWidth($labelText)); if (is_object($this->_dataPreProcessor)) {
} $labelText = $this->_dataPreProcessor->_process($label);
} } else {
$labelText = $label;
if ($this->_title) { }
$this->_canvas->setFont($this->_getTitleFont());
if ((($this->_type == IMAGE_GRAPH_AXIS_X) && (!$this->_transpose)) ||
if ((($this->_type == IMAGE_GRAPH_AXIS_X) && (!$this->_transpose)) || (($this->_type != IMAGE_GRAPH_AXIS_X) && ($this->_transpose)))
(($this->_type != IMAGE_GRAPH_AXIS_X) && ($this->_transpose))) {
{ $maxSize = max($maxSize, $this->_canvas->textHeight($labelText));
$maxSize += $this->_canvas->textHeight($this->_title); } else {
} else { $maxSize = max($maxSize, $this->_canvas->textWidth($labelText));
$maxSize += $this->_canvas->textWidth($this->_title); }
} }
$maxSize += 10;
} if ($this->_title) {
return $maxSize +3; $this->_canvas->setFont($this->_getTitleFont());
}
if ((($this->_type == IMAGE_GRAPH_AXIS_X) && (!$this->_transpose)) ||
/** (($this->_type != IMAGE_GRAPH_AXIS_X) && ($this->_transpose)))
* Apply the dataset to the axis. {
* $maxSize += $this->_canvas->textHeight($this->_title);
* This calculates the order of the categories, which is very important } else {
* for fx. line plots, so that the line does not "go backwards", consider $maxSize += $this->_canvas->textWidth($this->_title);
* these X-sets:<p> }
* 1: (1, 2, 3, 4, 5, 6)<br> $maxSize += 10;
* 2: (0, 1, 2, 3, 4, 5, 6, 7)<p> }
* If they are not ordered, but simply appended, the categories on the axis return $maxSize +3;
* would be:<p> }
* X: (1, 2, 3, 4, 5, 6, 0, 7)<p>
* Which would render the a line for the second plot to show incorrectly. /**
* Instead this algorithm, uses and 'value- is- before' method to see that * Apply the dataset to the axis.
* the 0 is before a 1 in the second set, and that it should also be before *
* a 1 in the X set. Hence:<p> * This calculates the order of the categories, which is very important
* X: (0, 1, 2, 3, 4, 5, 6, 7) * for fx. line plots, so that the line does not "go backwards", consider
* * these X-sets:<p>
* @param Image_Graph_Dataset $dataset The dataset * 1: (1, 2, 3, 4, 5, 6)<br>
* @access private * 2: (0, 1, 2, 3, 4, 5, 6, 7)<p>
*/ * If they are not ordered, but simply appended, the categories on the axis
function _applyDataset(&$dataset) * would be:<p>
{ * X: (1, 2, 3, 4, 5, 6, 0, 7)<p>
$newLabels = array(); * Which would render the a line for the second plot to show incorrectly.
$allLabels = array(); * Instead this algorithm, uses and 'value- is- before' method to see that
* the 0 is before a 1 in the second set, and that it should also be before
$dataset->_reset(); * a 1 in the X set. Hence:<p>
$count = 0; * X: (0, 1, 2, 3, 4, 5, 6, 7)
$count_new = 0; *
while ($point = $dataset->_next()) { * @param Image_Graph_Dataset $dataset The dataset
if ($this->_type == IMAGE_GRAPH_AXIS_X) { * @access private
$data = $point['X']; */
} else { function _applyDataset(&$dataset)
$data = $point['Y']; {
} $newLabels = array();
if (!isset($this->_labels[$data])) { $allLabels = array();
$newLabels[$data] = $count_new++;
//$this->_labels[] = $data; $dataset->_reset();
} $count = 0;
$allLabels[$data] = $count++; $count_new = 0;
} while ($point = $dataset->_next()) {
if ($this->_type == IMAGE_GRAPH_AXIS_X) {
if (count($this->_labels) == 0) { $data = $point['X'];
$this->_labels = $newLabels; } else {
} elseif ((is_array($newLabels)) && (count($newLabels) > 0)) { $data = $point['Y'];
// get all intersecting labels }
$intersect = array_intersect(array_keys($allLabels), array_keys($this->_labels)); if (!isset($this->_labels[$data])) {
// traverse all new and find their relative position withing the $newLabels[$data] = $count_new++;
// intersec, fx value X0 is before X1 in the intersection, which //$this->_labels[] = $data;
// means that X0 should be placed before X1 in the label array }
foreach($newLabels as $newLabel => $id) { $allLabels[$data] = $count++;
$key = $allLabels[$newLabel]; }
reset($intersect);
$this_value = false; if (count($this->_labels) == 0) {
// intersect indexes are the same as in allLabels! $this->_labels = $newLabels;
$first = true; } elseif ((is_array($newLabels)) && (count($newLabels) > 0)) {
while ((list($id, $value) = each($intersect)) && // get all intersecting labels
($this_value === false)) $intersect = array_intersect(array_keys($allLabels), array_keys($this->_labels));
{ // traverse all new and find their relative position withing the
if (($first) && ($id > $key)) { // intersec, fx value X0 is before X1 in the intersection, which
$this_value = $value; // means that X0 should be placed before X1 in the label array
} elseif ($id >= $key) { foreach($newLabels as $newLabel => $id) {
$this_value = $value; $key = $allLabels[$newLabel];
} reset($intersect);
$first = false; $this_value = false;
} // intersect indexes are the same as in allLabels!
$first = true;
if ($this_value === false) { while ((list($id, $value) = each($intersect)) &&
// the new label was not found before anything in the ($this_value === false))
// intersection -> append it {
$this->_labels[$newLabel] = count($this->_labels); if (($first) && ($id > $key)) {
} else { $this_value = $value;
// the new label was found before $this_value in the } elseif ($id >= $key) {
// intersection, insert the label before this position in $this_value = $value;
// the label array }
// $key = $this->_labels[$this_value]; $first = false;
$keys = array_keys($this->_labels); }
$key = array_search($this_value, $keys);
$pre = array_slice($keys, 0, $key); if ($this_value === false) {
$pre[] = $newLabel; // the new label was not found before anything in the
$post = array_slice($keys, $key); // intersection -> append it
$this->_labels = array_flip(array_merge($pre, $post)); $this->_labels[$newLabel] = count($this->_labels);
} } else {
} // the new label was found before $this_value in the
unset($keys); // intersection, insert the label before this position in
} // the label array
// $key = $this->_labels[$this_value];
$labels = array_keys($this->_labels); $keys = array_keys($this->_labels);
$i = 0; $key = array_search($this_value, $keys);
foreach ($labels as $label) { $pre = array_slice($keys, 0, $key);
$this->_labels[$label] = $i++; $pre[] = $newLabel;
} $post = array_slice($keys, $key);
$this->_labels = array_flip(array_merge($pre, $post));
// $this->_labels = array_values(array_unique($this->_labels)); }
$this->_calcLabelInterval(); }
} unset($keys);
}
/**
* Return the label distance. $labels = array_keys($this->_labels);
* $i = 0;
* @return int The distance between 2 adjacent labels foreach ($labels as $label) {
* @access private $this->_labels[$label] = $i++;
*/ }
function _labelDistance($level = 1)
{ // $this->_labels = array_values(array_unique($this->_labels));
reset($this->_labels); $this->_calcLabelInterval();
list($l1) = each($this->_labels); }
list($l2) = each($this->_labels);
return abs($this->_point($l2) - $this->_point($l1)); /**
} * Return the label distance.
*
/** * @return int The distance between 2 adjacent labels
* Get next label point * @access private
* */
* @param doubt $point The current point, if omitted or false, the first is function _labelDistance($level = 1)
* returned {
* @return double The next label point reset($this->_labels);
* @access private list($l1) = each($this->_labels);
*/ list($l2) = each($this->_labels);
function _getNextLabel($currentLabel = false, $level = 1) return abs($this->_point($l2) - $this->_point($l1));
{ }
if ($currentLabel === false) {
reset($this->_labels); /**
} * Get next label point
$result = false; *
$count = ($currentLabel === false ? $this->_labelInterval() - 1 : 0); * @param doubt $point The current point, if omitted or false, the first is
while ($count < $this->_labelInterval()) { * returned
$result = (list($label) = each($this->_labels)); * @return double The next label point
$count++; * @access private
} */
if ($result) { function _getNextLabel($currentLabel = false, $level = 1)
return $label; {
} else { if ($currentLabel === false) {
return false; reset($this->_labels);
} }
} $result = false;
$count = ($currentLabel === false ? $this->_labelInterval() - 1 : 0);
/** while ($count < $this->_labelInterval()) {
* Is the axis numeric or not? $result = (list($label) = each($this->_labels));
* $count++;
* @return bool True if numeric, false if not }
* @access private if ($result) {
*/ return $label;
function _isNumeric() } else {
{ return false;
return false; }
} }
/** /**
* Output the axis * Is the axis numeric or not?
* *
* @return bool Was the output 'good' (true) or 'bad' (false). * @return bool True if numeric, false if not
* @access private * @access private
*/ */
function _done() function _isNumeric()
{ {
$result = true; return false;
if (Image_Graph_Element::_done() === false) { }
$result = false;
} /**
* Output the axis
$this->_canvas->startGroup(get_class($this)); *
* @return bool Was the output 'good' (true) or 'bad' (false).
$this->_drawAxisLines(); * @access private
*/
$this->_canvas->startGroup(get_class($this) . '_ticks'); function _done()
$label = false; {
while (($label = $this->_getNextLabel($label)) !== false) { $result = true;
$this->_drawTick($label); if (Image_Graph_Element::_done() === false) {
} $result = false;
$this->_canvas->endGroup(); }
$this->_canvas->endGroup(); $this->_canvas->startGroup(get_class($this));
return $result; $this->_drawAxisLines();
}
$this->_canvas->startGroup(get_class($this) . '_ticks');
} $label = false;
while (($label = $this->_getNextLabel($label)) !== false) {
$this->_drawTick($label);
}
$this->_canvas->endGroup();
$this->_canvas->endGroup();
return $result;
}
}
?> ?>

View File

@ -1,175 +1,152 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Class for axis handling. * Class for axis handling.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Axis * @subpackage Axis
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Logarithmic.php,v 1.13 2005/09/25 17:52:17 nosey Exp $ * @version CVS: $Id: Logarithmic.php,v 1.15 2006/03/02 12:35:57 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/Axis.php * Include file Image/Graph/Axis.php
*/ */
require_once 'Image/Graph/Axis.php'; require_once 'Image/Graph/Axis.php';
/** /**
* Diplays a logarithmic axis (either X- or Y-axis). * Diplays a logarithmic axis (either X- or Y-axis).
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Axis * @subpackage Axis
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_Axis_Logarithmic extends Image_Graph_Axis class Image_Graph_Axis_Logarithmic extends Image_Graph_Axis
{ {
/** /**
* Image_Graph_AxisLogarithmic [Constructor]. * Image_Graph_AxisLogarithmic [Constructor].
* *
* Normally a manual creation should not be necessary, axis are * Normally a manual creation should not be necessary, axis are
* created automatically by the {@link Image_Graph_Plotarea} constructor * created automatically by the {@link Image_Graph_Plotarea} constructor
* unless explicitly defined otherwise * unless explicitly defined otherwise
* *
* @param int $type The type (direction) of the Axis, use IMAGE_GRAPH_AXIS_X * @param int $type The type (direction) of the Axis, use IMAGE_GRAPH_AXIS_X
* for an X-axis (default, may be omitted) and IMAGE_GRAPH_AXIS_Y for Y- * for an X-axis (default, may be omitted) and IMAGE_GRAPH_AXIS_Y for Y-
* axis) * axis)
*/ */
function Image_Graph_Axis_Logarithmic($type = IMAGE_GRAPH_AXIS_X) function Image_Graph_Axis_Logarithmic($type = IMAGE_GRAPH_AXIS_X)
{ {
parent::Image_Graph_Axis($type); parent::Image_Graph_Axis($type);
$this->showLabel(IMAGE_GRAPH_LABEL_MINIMUM + IMAGE_GRAPH_LABEL_MAXIMUM); $this->showLabel(IMAGE_GRAPH_LABEL_MINIMUM + IMAGE_GRAPH_LABEL_MAXIMUM);
} $this->_minimum = 1;
$this->_minimumSet = true;
/** }
* Calculate the label interval
* /**
* If explicitly defined this will be calucated to an approximate best. * Calculate the label interval
* *
* @return double The label interval * If explicitly defined this will be calucated to an approximate best.
* @access private *
*/ * @return double The label interval
function _calcLabelInterval() * @access private
{ */
$result = parent::_calcLabelInterval(); function _calcLabelInterval()
$this->_axisValueSpan = $this->_value($this->_axisSpan); {
return $result; $result = parent::_calcLabelInterval();
} $this->_axisValueSpan = $this->_value($this->_axisSpan);
return $result;
/** }
* Forces the minimum value of the axis.
* /**
* For an logarithimc axis this is always 0 * Preprocessor for values, ie for using logarithmic axis
* *
* @param double $minimum The minumum value to use on the axis * @param double $value The value to preprocess
*/ * @return double The preprocessed value
function forceMinimum($minimum) * @access private
{ */
parent::forceMinimum(0); function _value($value)
} {
return log10($value) - log10($this->_minimum);
/** }
* Gets the minimum value the axis will show.
* /**
* For an logarithimc axis this is always 0 * Get next label point
* *
* @return double The minumum value * @param doubt $point The current point, if omitted or false, the first is
* @access private * returned
*/ * @return double The next label point
function _getMinimum() * @access private
{ */
return 0; function _getNextLabel($currentLabel = false, $level = 1)
} {
if (is_array($this->_labelOptions[$level]['interval'])) {
/** return parent::_getNextLabel($currentLabel, $level);
* Preprocessor for values, ie for using logarithmic axis }
*
* @param double $value The value to preprocess if ($currentLabel !== false) {
* @return double The preprocessed value $value = log10($currentLabel);
* @access private $base = floor($value);
*/ $frac = $value - $base;
function _value($value) for ($i = 2; $i < 10; $i++) {
{ if ($frac <= (log10($i)-0.01)) {
return log10($value); $label = pow(10, $base)*$i;
} if ($label > $this->_getMaximum()) {
return false;
/** } else {
* Get next label point return $label;
* }
* @param doubt $point The current point, if omitted or false, the first is }
* returned }
* @return double The next label point return pow(10, $base+1);
* @access private }
*/
function _getNextLabel($currentLabel = false, $level = 1) return max(1, $this->_minimum);
{ }
if (is_array($this->_labelOptions[$level]['interval'])) {
return parent::_getNextLabel($currentLabel, $level); /**
} * Get the axis intersection pixel position
*
if ($currentLabel !== false) { * This is only to be called prior to output! I.e. between the user
$value = log10($currentLabel); * invokation of Image_Graph::done() and any actual output is performed.
$base = floor($value); * This is because it can change the axis range.
$frac = $value - $base; *
for ($i = 2; $i < 10; $i++) { * @param double $value the intersection value to get the pixel-point for
if ($frac <= (log10($i)-0.01)) { * @return double The pixel position along the axis
$label = pow(10, $base)*$i; * @access private
if ($label > $this->_getMaximum()) { */
return false; function _intersectPoint($value)
} else { {
return $label; if (($value <= 0) && ($value !== 'max') && ($value !== 'min')) {
} $value = 1;
} }
} return parent::_intersectPoint($value);
return pow(10, $base+1); }
}
}
return 1;
}
/**
* Get the axis intersection pixel position
*
* This is only to be called prior to output! I.e. between the user
* invokation of Image_Graph::done() and any actual output is performed.
* This is because it can change the axis range.
*
* @param double $value the intersection value to get the pixel-point for
* @return double The pixel position along the axis
* @access private
*/
function _intersectPoint($value)
{
if (($value <= 0) && ($value !== 'max') && ($value !== 'min')) {
$value = 1;
}
return parent::_intersectPoint($value);
}
}
?> ?>

View File

@ -1,156 +1,156 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Class file containing a axis marker used for explicitly highlighting a area * Class file containing a axis marker used for explicitly highlighting a area
* on the graph, based on an interval specified on an axis. * on the graph, based on an interval specified on an axis.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Grid * @subpackage Grid
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Area.php,v 1.11 2005/08/24 20:36:04 nosey Exp $ * @version CVS: $Id: Area.php,v 1.11 2005/08/24 20:36:04 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/Grid.php * Include file Image/Graph/Grid.php
*/ */
require_once 'Image/Graph/Grid.php'; require_once 'Image/Graph/Grid.php';
/** /**
* Display a grid * Display a grid
* *
* {@link Image_Graph_Grid} * {@link Image_Graph_Grid}
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Grid * @subpackage Grid
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_Axis_Marker_Area extends Image_Graph_Grid class Image_Graph_Axis_Marker_Area extends Image_Graph_Grid
{ {
/** /**
* The lower bound * The lower bound
* @var double * @var double
* @access private * @access private
*/ */
var $_lower = false; var $_lower = false;
/** /**
* The upper bound * The upper bound
* @var double * @var double
* @access private * @access private
*/ */
var $_upper = false; var $_upper = false;
/** /**
* [Constructor] * [Constructor]
*/ */
function Image_Graph_Axis_Marker_Area() function Image_Graph_Axis_Marker_Area()
{ {
parent::Image_Graph_Grid(); parent::Image_Graph_Grid();
$this->_lineStyle = false; $this->_lineStyle = false;
} }
/** /**
* Sets the lower bound of the area (value on the axis) * Sets the lower bound of the area (value on the axis)
* *
* @param double $lower the lower bound * @param double $lower the lower bound
*/ */
function setLowerBound($lower) function setLowerBound($lower)
{ {
$this->_lower = $lower; $this->_lower = $lower;
} }
/** /**
* Sets the upper bound of the area (value on the axis) * Sets the upper bound of the area (value on the axis)
* *
* @param double $upper the upper bound * @param double $upper the upper bound
*/ */
function setUpperBound($upper) function setUpperBound($upper)
{ {
$this->_upper = $upper; $this->_upper = $upper;
} }
/** /**
* Output the grid * Output the grid
* *
* @return bool Was the output 'good' (true) or 'bad' (false). * @return bool Was the output 'good' (true) or 'bad' (false).
* @access private * @access private
*/ */
function _done() function _done()
{ {
if (parent::_done() === false) { if (parent::_done() === false) {
return false; return false;
} }
if (!$this->_primaryAxis) { if (!$this->_primaryAxis) {
return false; return false;
} }
$this->_canvas->startGroup(get_class($this)); $this->_canvas->startGroup(get_class($this));
$i = 0; $i = 0;
$this->_lower = max($this->_primaryAxis->_getMinimum(), $this->_lower); $this->_lower = max($this->_primaryAxis->_getMinimum(), $this->_lower);
$this->_upper = min($this->_primaryAxis->_getMaximum(), $this->_upper); $this->_upper = min($this->_primaryAxis->_getMaximum(), $this->_upper);
$secondaryPoints = $this->_getSecondaryAxisPoints(); $secondaryPoints = $this->_getSecondaryAxisPoints();
reset($secondaryPoints); reset($secondaryPoints);
list ($id, $previousSecondaryValue) = each($secondaryPoints); list ($id, $previousSecondaryValue) = each($secondaryPoints);
while (list ($id, $secondaryValue) = each($secondaryPoints)) { while (list ($id, $secondaryValue) = each($secondaryPoints)) {
if ($this->_primaryAxis->_type == IMAGE_GRAPH_AXIS_X) { if ($this->_primaryAxis->_type == IMAGE_GRAPH_AXIS_X) {
$p1 = array ('Y' => $secondaryValue, 'X' => $this->_lower); $p1 = array ('Y' => $secondaryValue, 'X' => $this->_lower);
$p2 = array ('Y' => $previousSecondaryValue, 'X' => $this->_lower); $p2 = array ('Y' => $previousSecondaryValue, 'X' => $this->_lower);
$p3 = array ('Y' => $previousSecondaryValue, 'X' => $this->_upper); $p3 = array ('Y' => $previousSecondaryValue, 'X' => $this->_upper);
$p4 = array ('Y' => $secondaryValue, 'X' => $this->_upper); $p4 = array ('Y' => $secondaryValue, 'X' => $this->_upper);
} else { } else {
$p1 = array ('X' => $secondaryValue, 'Y' => $this->_lower); $p1 = array ('X' => $secondaryValue, 'Y' => $this->_lower);
$p2 = array ('X' => $previousSecondaryValue, 'Y' => $this->_lower); $p2 = array ('X' => $previousSecondaryValue, 'Y' => $this->_lower);
$p3 = array ('X' => $previousSecondaryValue, 'Y' => $this->_upper); $p3 = array ('X' => $previousSecondaryValue, 'Y' => $this->_upper);
$p4 = array ('X' => $secondaryValue, 'Y' => $this->_upper); $p4 = array ('X' => $secondaryValue, 'Y' => $this->_upper);
} }
$this->_canvas->addVertex(array('x' => $this->_pointX($p1), 'y' => $this->_pointY($p1))); $this->_canvas->addVertex(array('x' => $this->_pointX($p1), 'y' => $this->_pointY($p1)));
$this->_canvas->addVertex(array('x' => $this->_pointX($p2), 'y' => $this->_pointY($p2))); $this->_canvas->addVertex(array('x' => $this->_pointX($p2), 'y' => $this->_pointY($p2)));
$this->_canvas->addVertex(array('x' => $this->_pointX($p3), 'y' => $this->_pointY($p3))); $this->_canvas->addVertex(array('x' => $this->_pointX($p3), 'y' => $this->_pointY($p3)));
$this->_canvas->addVertex(array('x' => $this->_pointX($p4), 'y' => $this->_pointY($p4))); $this->_canvas->addVertex(array('x' => $this->_pointX($p4), 'y' => $this->_pointY($p4)));
$previousSecondaryValue = $secondaryValue; $previousSecondaryValue = $secondaryValue;
$this->_getLineStyle(); $this->_getLineStyle();
$this->_getFillStyle(); $this->_getFillStyle();
$this->_canvas->polygon(array('connect' => true)); $this->_canvas->polygon(array('connect' => true));
} }
$this->_canvas->endGroup(); $this->_canvas->endGroup();
return true; return true;
} }
} }
?> ?>

View File

@ -1,124 +1,124 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Class file containing a axis marker used for explicitly highlighting a point * Class file containing a axis marker used for explicitly highlighting a point
* (line) on the graph, based on an value specified on an axis. * (line) on the graph, based on an value specified on an axis.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Grid * @subpackage Grid
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Line.php,v 1.11 2005/08/03 21:21:58 nosey Exp $ * @version CVS: $Id: Line.php,v 1.11 2005/08/03 21:21:58 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/Grid.php * Include file Image/Graph/Grid.php
*/ */
require_once 'Image/Graph/Grid.php'; require_once 'Image/Graph/Grid.php';
/** /**
* Display a grid * Display a grid
* *
* {@link Image_Graph_Grid} * {@link Image_Graph_Grid}
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Grid * @subpackage Grid
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_Axis_Marker_Line extends Image_Graph_Grid class Image_Graph_Axis_Marker_Line extends Image_Graph_Grid
{ {
/** /**
* The value * The value
* @var double * @var double
* @access private * @access private
*/ */
var $_value = false; var $_value = false;
/** /**
* Sets the value of the line marker (value on the axis) * Sets the value of the line marker (value on the axis)
* *
* @param double $value the value * @param double $value the value
*/ */
function setValue($value) function setValue($value)
{ {
$this->_value = $value; $this->_value = $value;
} }
/** /**
* Output the grid * Output the grid
* *
* @return bool Was the output 'good' (true) or 'bad' (false). * @return bool Was the output 'good' (true) or 'bad' (false).
* @access private * @access private
*/ */
function _done() function _done()
{ {
if (parent::_done() === false) { if (parent::_done() === false) {
return false; return false;
} }
if (!$this->_primaryAxis) { if (!$this->_primaryAxis) {
return false; return false;
} }
$this->_canvas->startGroup(get_class($this)); $this->_canvas->startGroup(get_class($this));
$i = 0; $i = 0;
$this->_value = min($this->_primaryAxis->_getMaximum(), max($this->_primaryAxis->_getMinimum(), $this->_value)); $this->_value = min($this->_primaryAxis->_getMaximum(), max($this->_primaryAxis->_getMinimum(), $this->_value));
$secondaryPoints = $this->_getSecondaryAxisPoints(); $secondaryPoints = $this->_getSecondaryAxisPoints();
reset($secondaryPoints); reset($secondaryPoints);
list ($id, $previousSecondaryValue) = each($secondaryPoints); list ($id, $previousSecondaryValue) = each($secondaryPoints);
while (list ($id, $secondaryValue) = each($secondaryPoints)) { while (list ($id, $secondaryValue) = each($secondaryPoints)) {
if ($this->_primaryAxis->_type == IMAGE_GRAPH_AXIS_X) { if ($this->_primaryAxis->_type == IMAGE_GRAPH_AXIS_X) {
$p1 = array ('X' => $this->_value, 'Y' => $secondaryValue); $p1 = array ('X' => $this->_value, 'Y' => $secondaryValue);
$p2 = array ('X' => $this->_value, 'Y' => $previousSecondaryValue); $p2 = array ('X' => $this->_value, 'Y' => $previousSecondaryValue);
} else { } else {
$p1 = array ('X' => $secondaryValue, 'Y' => $this->_value); $p1 = array ('X' => $secondaryValue, 'Y' => $this->_value);
$p2 = array ('X' => $previousSecondaryValue, 'Y' => $this->_value); $p2 = array ('X' => $previousSecondaryValue, 'Y' => $this->_value);
} }
$x1 = $this->_pointX($p1); $x1 = $this->_pointX($p1);
$y1 = $this->_pointY($p1); $y1 = $this->_pointY($p1);
$x2 = $this->_pointX($p2); $x2 = $this->_pointX($p2);
$y2 = $this->_pointY($p2); $y2 = $this->_pointY($p2);
$previousSecondaryValue = $secondaryValue; $previousSecondaryValue = $secondaryValue;
$this->_getLineStyle(); $this->_getLineStyle();
$this->_canvas->line(array('x0' => $x1, 'y0' => $y1, 'x1' => $x2, 'y1' => $y2)); $this->_canvas->line(array('x0' => $x1, 'y0' => $y1, 'x1' => $x2, 'y1' => $y2));
} }
$this->_canvas->endGroup(); $this->_canvas->endGroup();
return true; return true;
} }
} }
?> ?>

View File

@ -1,204 +1,204 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Class for axis handling. * Class for axis handling.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Axis * @subpackage Axis
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Radar.php,v 1.6 2005/08/03 21:22:11 nosey Exp $ * @version CVS: $Id: Radar.php,v 1.6 2005/08/03 21:22:11 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/Axis/Category.php * Include file Image/Graph/Axis/Category.php
*/ */
require_once 'Image/Graph/Axis/Category.php'; require_once 'Image/Graph/Axis/Category.php';
/** /**
* Displays an 'X'-axis in a radar plot chart. * Displays an 'X'-axis in a radar plot chart.
* *
* This axis maps the number of elements in the dataset to a angle (from 0- * This axis maps the number of elements in the dataset to a angle (from 0-
* 360 degrees). Displaying the axis consist of drawing a number of lines from * 360 degrees). Displaying the axis consist of drawing a number of lines from
* center to the edge of the 'circle' than encloses the radar plot. The labels * center to the edge of the 'circle' than encloses the radar plot. The labels
* are drawn on the 'ends' of these radial lines. * are drawn on the 'ends' of these radial lines.
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Axis * @subpackage Axis
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_Axis_Radar extends Image_Graph_Axis_Category class Image_Graph_Axis_Radar extends Image_Graph_Axis_Category
{ {
/** /**
* Specifies the number of pixels, the labels is offsetted from the end of * Specifies the number of pixels, the labels is offsetted from the end of
* the axis * the axis
* *
* @var int * @var int
* @access private * @access private
*/ */
var $_distanceFromEnd = 5; var $_distanceFromEnd = 5;
/** /**
* Gets the minimum value the axis will show. * Gets the minimum value the axis will show.
* *
* This is always 0 * This is always 0
* *
* @return double The minumum value * @return double The minumum value
* @access private * @access private
*/ */
function _getMinimum() function _getMinimum()
{ {
return 0; return 0;
} }
/** /**
* Gets the maximum value the axis will show. * Gets the maximum value the axis will show.
* *
* This is always the number of labels passed to the constructor. * This is always the number of labels passed to the constructor.
* *
* @return double The maximum value * @return double The maximum value
* @access private * @access private
*/ */
function _getMaximum() function _getMaximum()
{ {
return count($this->_labels); return count($this->_labels);
} }
/** /**
* Calculate the delta value (the number of pixels representing one unit * Calculate the delta value (the number of pixels representing one unit
* on the axis) * on the axis)
* *
* @return double The label interval * @return double The label interval
* @access private * @access private
*/ */
function _calcDelta() function _calcDelta()
{ {
if (abs($this->_getMaximum() - $this->_getMinimum()) == 0) { if (abs($this->_getMaximum() - $this->_getMinimum()) == 0) {
$this->_delta = false; $this->_delta = false;
} else { } else {
$this->_delta = 360 / ($this->_getMaximum() - $this->_getMinimum()); $this->_delta = 360 / ($this->_getMaximum() - $this->_getMinimum());
} }
} }
/** /**
* Get the pixel position represented by a value on the canvas * Get the pixel position represented by a value on the canvas
* *
* @param double $value the value to get the pixel-point for * @param double $value the value to get the pixel-point for
* @return double The pixel position along the axis * @return double The pixel position along the axis
* @access private * @access private
*/ */
function _point($value) function _point($value)
{ {
return (90 + (int) ($this->_value($value) * $this->_delta)) % 360; return (90 + (int) ($this->_value($value) * $this->_delta)) % 360;
} }
/** /**
* Get the size in pixels of the axis. * Get the size in pixels of the axis.
* *
* For a radar plot this is always 0 * For a radar plot this is always 0
* *
* @return int The size of the axis * @return int The size of the axis
* @access private * @access private
*/ */
function _size() function _size()
{ {
return 0; return 0;
} }
/** /**
* Sets the distance from the end of the category lines to the label. * Sets the distance from the end of the category lines to the label.
* *
* @param int $distance The distance in pixels * @param int $distance The distance in pixels
*/ */
function setDistanceFromEnd($distance = 5) function setDistanceFromEnd($distance = 5)
{ {
$this->_distanceFromEnd = $distance; $this->_distanceFromEnd = $distance;
} }
/** /**
* Draws axis lines. * Draws axis lines.
* *
* @access private * @access private
*/ */
function _drawAxisLines() function _drawAxisLines()
{ {
} }
/** /**
* Output an axis tick mark. * Output an axis tick mark.
* *
* @param int $value The value to output * @param int $value The value to output
* @access private * @access private
*/ */
function _drawTick($value, $level = 1) function _drawTick($value, $level = 1)
{ {
$centerX = (int) (($this->_left + $this->_right) / 2); $centerX = (int) (($this->_left + $this->_right) / 2);
$centerY = (int) (($this->_top + $this->_bottom) / 2); $centerY = (int) (($this->_top + $this->_bottom) / 2);
$radius = min($this->height(), $this->width()) / 2; $radius = min($this->height(), $this->width()) / 2;
$endPoint = array ('X' => $value, 'Y' => '#max#'); $endPoint = array ('X' => $value, 'Y' => '#max#');
$dX = $this->_pointX($endPoint); $dX = $this->_pointX($endPoint);
$dY = $this->_pointY($endPoint); $dY = $this->_pointY($endPoint);
$offX = ($dX - $centerX); $offX = ($dX - $centerX);
$offY = ($dY - $centerY); $offY = ($dY - $centerY);
$hyp = sqrt($offX*$offX + $offY*$offY); $hyp = sqrt($offX*$offX + $offY*$offY);
if ($hyp != 0) { if ($hyp != 0) {
$scale = $this->_distanceFromEnd / $hyp; $scale = $this->_distanceFromEnd / $hyp;
} else { } else {
$scale = 1; $scale = 1;
} }
$adX = $dX + $offX * $scale; $adX = $dX + $offX * $scale;
$adY = $dY + $offY * $scale; $adY = $dY + $offY * $scale;
if (is_object($this->_dataPreProcessor)) { if (is_object($this->_dataPreProcessor)) {
$labelText = $this->_dataPreProcessor->_process($value); $labelText = $this->_dataPreProcessor->_process($value);
} else { } else {
$labelText = $value; $labelText = $value;
} }
if ((abs($dX - $centerX) < 1.5) && ($dY < $centerY)) { if ((abs($dX - $centerX) < 1.5) && ($dY < $centerY)) {
$align = IMAGE_GRAPH_ALIGN_BOTTOM + IMAGE_GRAPH_ALIGN_CENTER_X; $align = IMAGE_GRAPH_ALIGN_BOTTOM + IMAGE_GRAPH_ALIGN_CENTER_X;
} elseif ((abs($dX - $centerX) < 1.5) && ($dY > $centerY)) { } elseif ((abs($dX - $centerX) < 1.5) && ($dY > $centerY)) {
$align = IMAGE_GRAPH_ALIGN_TOP + IMAGE_GRAPH_ALIGN_CENTER_X; $align = IMAGE_GRAPH_ALIGN_TOP + IMAGE_GRAPH_ALIGN_CENTER_X;
} elseif ($dX < $centerX) { } elseif ($dX < $centerX) {
$align = IMAGE_GRAPH_ALIGN_RIGHT + IMAGE_GRAPH_ALIGN_CENTER_Y; $align = IMAGE_GRAPH_ALIGN_RIGHT + IMAGE_GRAPH_ALIGN_CENTER_Y;
} else { } else {
$align = IMAGE_GRAPH_ALIGN_LEFT + IMAGE_GRAPH_ALIGN_CENTER_Y; $align = IMAGE_GRAPH_ALIGN_LEFT + IMAGE_GRAPH_ALIGN_CENTER_Y;
} }
$this->write($adX, $adY, $labelText, $align); $this->write($adX, $adY, $labelText, $align);
$this->_getLineStyle(); $this->_getLineStyle();
$this->_canvas->line(array('x0' => $centerX, 'y0' => $centerY, 'x1' => $dX, 'y1' => $dY)); $this->_canvas->line(array('x0' => $centerX, 'y0' => $centerY, 'x1' => $dX, 'y1' => $dY));
} }
} }
?> ?>

View File

@ -1,308 +1,313 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - Main class for the graph creation. * Image_Graph - Main class for the graph creation.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Common.php,v 1.14 2005/10/05 20:51:21 nosey Exp $ * @version CVS: $Id: Common.php,v 1.16 2006/02/28 22:48:07 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
if (!function_exists('is_a')) { if (!function_exists('is_a')) {
/** /**
* Check if an object is of a given class, this function is available as of PHP 4.2.0, so if it exist it will not be declared * Check if an object is of a given class, this function is available as of PHP 4.2.0, so if it exist it will not be declared
* *
* @link http://www.php.net/manual/en/function.is-a.php PHP.net Online Manual for function is_a() * @link http://www.php.net/manual/en/function.is-a.php PHP.net Online Manual for function is_a()
* @param object $object The object to check class for * @param object $object The object to check class for
* @param string $class_name The name of the class to check the object for * @param string $class_name The name of the class to check the object for
* @return bool Returns TRUE if the object is of this class or has this class as one of its parents * @return bool Returns TRUE if the object is of this class or has this class as one of its parents
*/ */
function is_a($object, $class_name) function is_a($object, $class_name)
{ {
if (empty ($object)) { if (empty ($object)) {
return false; return false;
} }
$object = is_object($object) ? get_class($object) : $object; $object = is_object($object) ? get_class($object) : $object;
if (strtolower($object) == strtolower($class_name)) { if (strtolower($object) == strtolower($class_name)) {
return true; return true;
} }
return is_a(get_parent_class($object), $class_name); return is_a(get_parent_class($object), $class_name);
} }
} }
/** /**
* Include file Image/Canvas.php * Include file Image/Canvas.php
*/ */
require_once 'Image/Canvas.php'; require_once 'Image/Canvas.php';
/** /**
* The ultimate ancestor of all Image_Graph classes. * The ultimate ancestor of all Image_Graph classes.
* *
* This class contains common functionality needed by all Image_Graph classes. * This class contains common functionality needed by all Image_Graph classes.
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
* @abstract * @abstract
*/ */
class Image_Graph_Common class Image_Graph_Common
{ {
/** /**
* The parent container of the current Image_Graph object * The parent container of the current Image_Graph object
* *
* @var Image_Graph_Common * @var Image_Graph_Common
* @access private * @access private
*/ */
var $_parent = null; var $_parent = null;
/** /**
* The sub-elements of the current Image_Graph container object * The sub-elements of the current Image_Graph container object
* *
* @var array * @var array
* @access private * @access private
*/ */
var $_elements; var $_elements;
/** /**
* The canvas for output. * The canvas for output.
* *
* Enables support for multiple output formats. * Enables support for multiple output formats.
* *
* @var Image_Canvas * @var Image_Canvas
* @access private * @access private
*/ */
var $_canvas = null; var $_canvas = null;
/** /**
* Is the object visible? * Is the object visible?
* *
* @var bool * @var bool
* @access private * @access private
*/ */
var $_visible = true; var $_visible = true;
/** /**
* Constructor [Image_Graph_Common] * Constructor [Image_Graph_Common]
*/ */
function Image_Graph_Common() function Image_Graph_Common()
{ {
} }
/** /**
* Resets the elements * Resets the elements
* *
* @access private * @access private
*/ */
function _reset() function _reset()
{ {
if (is_array($this->_elements)) { if (is_array($this->_elements)) {
$keys = array_keys($this->_elements); $keys = array_keys($this->_elements);
foreach ($keys as $key) { foreach ($keys as $key) {
if (is_object($this->_elements[$key])) { if (is_object($this->_elements[$key])) {
$this->_elements[$key]->_setParent($this); $this->_elements[$key]->_setParent($this);
@$result =& $this->_elements[$key]->_reset(); $result =& $this->_elements[$key]->_reset();
if (PEAR::isError($result)) { if (PEAR::isError($result)) {
return $result; return $result;
} }
} }
} }
unset($keys); unset($keys);
} }
return true; return true;
} }
/** /**
* Sets the parent. The parent chain should ultimately be a GraPHP object * Sets the parent. The parent chain should ultimately be a GraPHP object
* *
* @see Image_Graph_Common * @see Image_Graph_Common
* @param Image_Graph_Common $parent The parent * @param Image_Graph_Common $parent The parent
* @access private * @access private
*/ */
function _setParent(& $parent) function _setParent(& $parent)
{ {
$this->_parent =& $parent; $this->_parent =& $parent;
$this->_canvas =& $this->_parent->_getCanvas(); $this->_canvas =& $this->_parent->_getCanvas();
if (is_array($this->_elements)) { if (is_array($this->_elements)) {
$keys = array_keys($this->_elements); $keys = array_keys($this->_elements);
foreach ($keys as $key) { foreach ($keys as $key) {
if (is_object($this->_elements[$key])) { if (is_object($this->_elements[$key])) {
$this->_elements[$key]->_setParent($this); $this->_elements[$key]->_setParent($this);
} }
} }
unset($keys); unset($keys);
} }
} }
/** /**
* Hide the element * Hide the element
*/ */
function hide() function hide()
{ {
$this->_visible = false; $this->_visible = false;
} }
/** /**
* Get the canvas * Get the canvas
* *
* @return Image_Canvas The canvas * @return Image_Canvas The canvas
* @access private * @access private
*/ */
function &_getCanvas() function &_getCanvas()
{ {
if (($this->_canvas !== null) || ($this->_canvas !== false)) { if (($this->_canvas !== null) || ($this->_canvas !== false)) {
return $this->_canvas; return $this->_canvas;
} elseif (is_a($this->_parent, 'Image_Graph_Common')) { } elseif (is_a($this->_parent, 'Image_Graph_Common')) {
$this->_canvas =& $this->_parent->_getCanvas(); $this->_canvas =& $this->_parent->_getCanvas();
return $this->_canvas; return $this->_canvas;
} else { } else {
$this->_error('Invalid canvas'); $this->_error('Invalid canvas');
$result = null; $result = null;
return $result; return $result;
} }
} }
/** /**
* Adds an element to the objects element list. * Adds an element to the objects element list.
* *
* The new Image_Graph_elements parent is automatically set. * The new Image_Graph_elements parent is automatically set.
* *
* @param Image_Graph_Common $element The new Image_Graph_element * @param Image_Graph_Common $element The new Image_Graph_element
* @return Image_Graph_Common The new Image_Graph_element * @return Image_Graph_Common The new Image_Graph_element
*/ */
function &add(& $element) function &add(& $element)
{ {
if (!is_a($element, 'Image_Graph_Font')) { if (!is_a($element, 'Image_Graph_Font')) {
$this->_elements[] = &$element; $this->_elements[] = &$element;
} }
$element->_setParent($this); $element->_setParent($this);
return $element; return $element;
} }
/** /**
* Creates an object from the class and adds it to the objects element list. * Creates an object from the class and adds it to the objects element list.
* *
* Creates an object from the class specified and adds it to the objects * Creates an object from the class specified and adds it to the objects
* element list. If only one parameter is required for the constructor of * element list. If only one parameter is required for the constructor of
* the class simply pass this parameter as the $params parameter, unless the * the class simply pass this parameter as the $params parameter, unless the
* parameter is an array or a reference to a value, in that case you must * parameter is an array or a reference to a value, in that case you must
* 'enclose' the parameter in an array. Similar if the constructor takes * 'enclose' the parameter in an array. Similar if the constructor takes
* more than one parameter specify the parameters in an array. * more than one parameter specify the parameters in an array.
* *
* @see Image_Graph::factory() * @see Image_Graph::factory()
* @param string $class The class for the object * @param string $class The class for the object
* @param mixed $params The paramaters to pass to the constructor * @param mixed $params The paramaters to pass to the constructor
* @return Image_Graph_Common The new Image_Graph_element * @return Image_Graph_Common The new Image_Graph_element
*/ */
function &addNew($class, $params = null, $additional = false) function &addNew($class, $params = null, $additional = false)
{ {
include_once 'Image/Graph.php'; include_once 'Image/Graph.php';
$element =& Image_Graph::factory($class, $params); $element =& Image_Graph::factory($class, $params);
if ($additional === false) { if ($additional === false) {
$obj =& $this->add($element); $obj =& $this->add($element);
} else { } else {
$obj =& $this->add($element, $additional); $obj =& $this->add($element, $additional);
} }
return $obj; return $obj;
} }
/** /**
* Shows an error message box on the canvas * Shows an error message box on the canvas
* *
* @param string $text The error text * @param string $text The error text
* @param array $params An array containing error specific details * @param array $params An array containing error specific details
* @param int $error_code Error code * @param int $error_code Error code
* @access private * @access private
*/ */
function _error($text, $params = false, $error_code = IMAGE_GRAPH_ERROR_GENERIC) function _error($text, $params = false, $error_code = IMAGE_GRAPH_ERROR_GENERIC)
{ {
foreach ($params as $name => $key) { if ((is_array($params)) && (count($params) > 0)) {
if (isset($parameters)) { foreach ($params as $name => $key) {
$parameters .= ' '; if (isset($parameters)) {
} $parameters .= ' ';
$parameters .= $name . '=' . $key; }
} else {
$error =& PEAR::raiseError( $parameters = '';
$text . }
($error_code != IMAGE_GRAPH_ERROR_GENERIC ? ' error:' . IMAGE_GRAPH_ERROR_GENERIC : '') . $parameters .= $name . '=' . $key;
(isset($parameters) ? ' parameters:[' . $parameters . ']' : '') }
); }
} $error =& PEAR::raiseError(
$text .
/** ($error_code != IMAGE_GRAPH_ERROR_GENERIC ? ' error:' . IMAGE_GRAPH_ERROR_GENERIC : '') .
* Causes the object to update all sub elements coordinates (isset($parameters) ? ' parameters:[' . $parameters . ']' : '')
* );
* (Image_Graph_Common, does not itself have coordinates, this is basically }
* an abstract method)
* /**
* @access private * Causes the object to update all sub elements coordinates
*/ *
function _updateCoords() * (Image_Graph_Common, does not itself have coordinates, this is basically
{ * an abstract method)
if (is_array($this->_elements)) { *
$keys = array_keys($this->_elements); * @access private
foreach ($keys as $key) { */
if (is_object($this->_elements[$key])) { function _updateCoords()
$this->_elements[$key]->_updateCoords(); {
} if (is_array($this->_elements)) {
} $keys = array_keys($this->_elements);
unset($keys); foreach ($keys as $key) {
} if (is_object($this->_elements[$key])) {
return true; $this->_elements[$key]->_updateCoords();
} }
}
/** unset($keys);
* Causes output to canvas }
* return true;
* The last method to call. Calling Done causes output to the canvas. All }
* sub elements done() method will be invoked
* /**
* @return bool Was the output 'good' (true) or 'bad' (false). * Causes output to canvas
* @access private *
*/ * The last method to call. Calling Done causes output to the canvas. All
function _done() * sub elements done() method will be invoked
{ *
if (($this->_canvas == null) || (!is_a($this->_canvas, 'Image_Canvas'))) { * @return bool Was the output 'good' (true) or 'bad' (false).
return false; * @access private
} */
function _done()
if (is_array($this->_elements)) { {
$keys = array_keys($this->_elements); if (($this->_canvas == null) || (!is_a($this->_canvas, 'Image_Canvas'))) {
foreach ($keys as $key) { return false;
if (($this->_elements[$key]->_visible) && ($this->_elements[$key]->_done() === false)) { }
return false;
} if (is_array($this->_elements)) {
} $keys = array_keys($this->_elements);
unset($keys); foreach ($keys as $key) {
} if (($this->_elements[$key]->_visible) && ($this->_elements[$key]->_done() === false)) {
return true; return false;
} }
}
} unset($keys);
}
return true;
}
}
?> ?>

View File

@ -1,30 +1,30 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - Main class for the graph creation. * Image_Graph - Main class for the graph creation.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Config.php,v 1.7 2005/08/03 21:21:52 nosey Exp $ * @version CVS: $Id: Config.php,v 1.7 2005/08/03 21:21:52 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
?> ?>

View File

@ -1,225 +1,225 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - Main class for the graph creation. * Image_Graph - Main class for the graph creation.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Constants.php,v 1.7 2005/08/03 21:21:52 nosey Exp $ * @version CVS: $Id: Constants.php,v 1.7 2005/08/03 21:21:52 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/Font.php * Include file Image/Graph/Font.php
*/ */
require_once 'Image/Graph/Font.php'; require_once 'Image/Graph/Font.php';
// Constant declarations // Constant declarations
/** /**
* Defines an X (horizontal) axis * Defines an X (horizontal) axis
*/ */
define('IMAGE_GRAPH_AXIS_X', 1); define('IMAGE_GRAPH_AXIS_X', 1);
/** /**
* Defines an Y (vertical) axis * Defines an Y (vertical) axis
*/ */
define('IMAGE_GRAPH_AXIS_Y', 2); define('IMAGE_GRAPH_AXIS_Y', 2);
/** /**
* Defines an Y (vertical) axis * Defines an Y (vertical) axis
*/ */
define('IMAGE_GRAPH_AXIS_Y_SECONDARY', 3); define('IMAGE_GRAPH_AXIS_Y_SECONDARY', 3);
/** /**
* Defines an horizontal (X) axis * Defines an horizontal (X) axis
*/ */
define('IMAGE_GRAPH_AXIS_HORIZONTAL', 1); define('IMAGE_GRAPH_AXIS_HORIZONTAL', 1);
/** /**
* Defines an vertical (Y) axis * Defines an vertical (Y) axis
*/ */
define('IMAGE_GRAPH_AXIS_VERTICAL', 2); define('IMAGE_GRAPH_AXIS_VERTICAL', 2);
/** /**
* Define if label should be shown for axis minimum value * Define if label should be shown for axis minimum value
*/ */
define('IMAGE_GRAPH_LABEL_MINIMUM', 1); define('IMAGE_GRAPH_LABEL_MINIMUM', 1);
/** /**
* Define if label should be shown for axis 0 (zero) value * Define if label should be shown for axis 0 (zero) value
*/ */
define('IMAGE_GRAPH_LABEL_ZERO', 2); define('IMAGE_GRAPH_LABEL_ZERO', 2);
/** /**
* Define if label should be shown for axis maximum value * Define if label should be shown for axis maximum value
*/ */
define('IMAGE_GRAPH_LABEL_MAXIMUM', 4); define('IMAGE_GRAPH_LABEL_MAXIMUM', 4);
/** /**
* Defines a horizontal gradient fill * Defines a horizontal gradient fill
*/ */
define('IMAGE_GRAPH_GRAD_HORIZONTAL', 1); define('IMAGE_GRAPH_GRAD_HORIZONTAL', 1);
/** /**
* Defines a vertical gradient fill * Defines a vertical gradient fill
*/ */
define('IMAGE_GRAPH_GRAD_VERTICAL', 2); define('IMAGE_GRAPH_GRAD_VERTICAL', 2);
/** /**
* Defines a horizontally mirrored gradient fill * Defines a horizontally mirrored gradient fill
*/ */
define('IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED', 3); define('IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED', 3);
/** /**
* Defines a vertically mirrored gradient fill * Defines a vertically mirrored gradient fill
*/ */
define('IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED', 4); define('IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED', 4);
/** /**
* Defines a diagonal gradient fill from top-left to bottom-right * Defines a diagonal gradient fill from top-left to bottom-right
*/ */
define('IMAGE_GRAPH_GRAD_DIAGONALLY_TL_BR', 5); define('IMAGE_GRAPH_GRAD_DIAGONALLY_TL_BR', 5);
/** /**
* Defines a diagonal gradient fill from bottom-left to top-right * Defines a diagonal gradient fill from bottom-left to top-right
*/ */
define('IMAGE_GRAPH_GRAD_DIAGONALLY_BL_TR', 6); define('IMAGE_GRAPH_GRAD_DIAGONALLY_BL_TR', 6);
/** /**
* Defines a radial gradient fill * Defines a radial gradient fill
*/ */
define('IMAGE_GRAPH_GRAD_RADIAL', 7); define('IMAGE_GRAPH_GRAD_RADIAL', 7);
/** /**
* Defines the default builtin font * Defines the default builtin font
*/ */
define('IMAGE_GRAPH_FONT', 1); define('IMAGE_GRAPH_FONT', 1);
/** /**
* Defines a X value should be used * Defines a X value should be used
*/ */
define('IMAGE_GRAPH_VALUE_X', 0); define('IMAGE_GRAPH_VALUE_X', 0);
/** /**
* Defines a Y value should be used * Defines a Y value should be used
*/ */
define('IMAGE_GRAPH_VALUE_Y', 1); define('IMAGE_GRAPH_VALUE_Y', 1);
/** /**
* Defines a min X% value should be used * Defines a min X% value should be used
*/ */
define('IMAGE_GRAPH_PCT_X_MIN', 2); define('IMAGE_GRAPH_PCT_X_MIN', 2);
/** /**
* Defines a max X% value should be used * Defines a max X% value should be used
*/ */
define('IMAGE_GRAPH_PCT_X_MAX', 3); define('IMAGE_GRAPH_PCT_X_MAX', 3);
/** /**
* Defines a min Y% value should be used * Defines a min Y% value should be used
*/ */
define('IMAGE_GRAPH_PCT_Y_MIN', 4); define('IMAGE_GRAPH_PCT_Y_MIN', 4);
/** /**
* Defines a max Y% value should be used * Defines a max Y% value should be used
*/ */
define('IMAGE_GRAPH_PCT_Y_MAX', 5); define('IMAGE_GRAPH_PCT_Y_MAX', 5);
/** /**
* Defines a total Y% value should be used * Defines a total Y% value should be used
*/ */
define('IMAGE_GRAPH_PCT_Y_TOTAL', 6); define('IMAGE_GRAPH_PCT_Y_TOTAL', 6);
/** /**
* Defines a ID value should be used * Defines a ID value should be used
*/ */
define('IMAGE_GRAPH_POINT_ID', 7); define('IMAGE_GRAPH_POINT_ID', 7);
/** /**
* Align text left * Align text left
*/ */
define('IMAGE_GRAPH_ALIGN_LEFT', 0x1); define('IMAGE_GRAPH_ALIGN_LEFT', 0x1);
/** /**
* Align text right * Align text right
*/ */
define('IMAGE_GRAPH_ALIGN_RIGHT', 0x2); define('IMAGE_GRAPH_ALIGN_RIGHT', 0x2);
/** /**
* Align text center x (horizontal) * Align text center x (horizontal)
*/ */
define('IMAGE_GRAPH_ALIGN_CENTER_X', 0x4); define('IMAGE_GRAPH_ALIGN_CENTER_X', 0x4);
/** /**
* Align text top * Align text top
*/ */
define('IMAGE_GRAPH_ALIGN_TOP', 0x8); define('IMAGE_GRAPH_ALIGN_TOP', 0x8);
/** /**
* Align text bottom * Align text bottom
*/ */
define('IMAGE_GRAPH_ALIGN_BOTTOM', 0x10); define('IMAGE_GRAPH_ALIGN_BOTTOM', 0x10);
/** /**
* Align text center y (vertical) * Align text center y (vertical)
*/ */
define('IMAGE_GRAPH_ALIGN_CENTER_Y', 0x20); define('IMAGE_GRAPH_ALIGN_CENTER_Y', 0x20);
/** /**
* Align text center (both x and y) * Align text center (both x and y)
*/ */
define('IMAGE_GRAPH_ALIGN_CENTER', IMAGE_GRAPH_ALIGN_CENTER_X + IMAGE_GRAPH_ALIGN_CENTER_Y); define('IMAGE_GRAPH_ALIGN_CENTER', IMAGE_GRAPH_ALIGN_CENTER_X + IMAGE_GRAPH_ALIGN_CENTER_Y);
/** /**
* Align text top left * Align text top left
*/ */
define('IMAGE_GRAPH_ALIGN_TOP_LEFT', IMAGE_GRAPH_ALIGN_TOP + IMAGE_GRAPH_ALIGN_LEFT); define('IMAGE_GRAPH_ALIGN_TOP_LEFT', IMAGE_GRAPH_ALIGN_TOP + IMAGE_GRAPH_ALIGN_LEFT);
/** /**
* Align text top right * Align text top right
*/ */
define('IMAGE_GRAPH_ALIGN_TOP_RIGHT', IMAGE_GRAPH_ALIGN_TOP + IMAGE_GRAPH_ALIGN_RIGHT); define('IMAGE_GRAPH_ALIGN_TOP_RIGHT', IMAGE_GRAPH_ALIGN_TOP + IMAGE_GRAPH_ALIGN_RIGHT);
/** /**
* Align text bottom left * Align text bottom left
*/ */
define('IMAGE_GRAPH_ALIGN_BOTTOM_LEFT', IMAGE_GRAPH_ALIGN_BOTTOM + IMAGE_GRAPH_ALIGN_LEFT); define('IMAGE_GRAPH_ALIGN_BOTTOM_LEFT', IMAGE_GRAPH_ALIGN_BOTTOM + IMAGE_GRAPH_ALIGN_LEFT);
/** /**
* Align text bottom right * Align text bottom right
*/ */
define('IMAGE_GRAPH_ALIGN_BOTTOM_RIGHT', IMAGE_GRAPH_ALIGN_BOTTOM + IMAGE_GRAPH_ALIGN_RIGHT); define('IMAGE_GRAPH_ALIGN_BOTTOM_RIGHT', IMAGE_GRAPH_ALIGN_BOTTOM + IMAGE_GRAPH_ALIGN_RIGHT);
/** /**
* Align vertical * Align vertical
*/ */
define('IMAGE_GRAPH_ALIGN_VERTICAL', IMAGE_GRAPH_ALIGN_TOP); define('IMAGE_GRAPH_ALIGN_VERTICAL', IMAGE_GRAPH_ALIGN_TOP);
/** /**
* Align horizontal * Align horizontal
*/ */
define('IMAGE_GRAPH_ALIGN_HORIZONTAL', IMAGE_GRAPH_ALIGN_LEFT); define('IMAGE_GRAPH_ALIGN_HORIZONTAL', IMAGE_GRAPH_ALIGN_LEFT);
// Error codes // Error codes
define('IMAGE_GRAPH_ERROR_GENERIC', 0); define('IMAGE_GRAPH_ERROR_GENERIC', 0);
?> ?>

View File

@ -1,74 +1,74 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataPreprocessor * @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: DataPreprocessor.php,v 1.7 2005/08/24 20:35:55 nosey Exp $ * @version CVS: $Id: DataPreprocessor.php,v 1.7 2005/08/24 20:35:55 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Data preprocessor used for preformatting a data. * Data preprocessor used for preformatting a data.
* *
* A data preprocessor is used in cases where a value from a dataset or label must be * A data preprocessor is used in cases where a value from a dataset or label must be
* displayed in another format or way than entered. This could for example be the need * displayed in another format or way than entered. This could for example be the need
* to display X-values as a date instead of 1, 2, 3, .. or even worse unix-timestamps. * to display X-values as a date instead of 1, 2, 3, .. or even worse unix-timestamps.
* It could also be when a {@link Image_Graph_Marker_Value} needs to display values as percentages * It could also be when a {@link Image_Graph_Marker_Value} needs to display values as percentages
* with 1 decimal digit instead of the default formatting (fx. 12.01271 -> 12.0%). * with 1 decimal digit instead of the default formatting (fx. 12.01271 -> 12.0%).
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataPreprocessor * @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
* @abstract * @abstract
*/ */
class Image_Graph_DataPreprocessor class Image_Graph_DataPreprocessor
{ {
/** /**
* Image_Graph_DataPreprocessor [Constructor]. * Image_Graph_DataPreprocessor [Constructor].
*/ */
function Image_Graph_DataPreprocessor() function Image_Graph_DataPreprocessor()
{ {
} }
/** /**
* Process the value * Process the value
* *
* @param var $value The value to process/format * @param var $value The value to process/format
* @return string The processed value * @return string The processed value
* @access private * @access private
*/ */
function _process($value) function _process($value)
{ {
return $value; return $value;
} }
} }
?> ?>

View File

@ -1,103 +1,103 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataPreprocessor * @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Array.php,v 1.6 2005/08/24 20:35:59 nosey Exp $ * @version CVS: $Id: Array.php,v 1.6 2005/08/24 20:35:59 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/DataPreprocessor.php * Include file Image/Graph/DataPreprocessor.php
*/ */
require_once 'Image/Graph/DataPreprocessor.php'; require_once 'Image/Graph/DataPreprocessor.php';
/** /**
* Format data as looked up in an array. * Format data as looked up in an array.
* *
* ArrayData is useful when a numercal value is to be translated to * ArrayData is useful when a numercal value is to be translated to
* something thats cannot directly be calculated from this value, this could for * something thats cannot directly be calculated from this value, this could for
* example be a dataset meant to plot population of various countries. Since x- * example be a dataset meant to plot population of various countries. Since x-
* values are numerical and they should really be country names, but there is no * values are numerical and they should really be country names, but there is no
* linear correlation between the number and the name, we use an array to 'map' * linear correlation between the number and the name, we use an array to 'map'
* the numbers to the name, i.e. $array[0] = 'Denmark'; $array[1] = 'Sweden'; * the numbers to the name, i.e. $array[0] = 'Denmark'; $array[1] = 'Sweden';
* ..., where the indexes are the numerical values from the dataset. This is NOT * ..., where the indexes are the numerical values from the dataset. This is NOT
* usefull when the x-values are a large domain, i.e. to map unix timestamps to * usefull when the x-values are a large domain, i.e. to map unix timestamps to
* date-strings for an x-axis. This is because the x-axis will selecte arbitrary * date-strings for an x-axis. This is because the x-axis will selecte arbitrary
* values for labels, which would in principle require the ArrayData to hold * values for labels, which would in principle require the ArrayData to hold
* values for every unix timestamp. However ArrayData can still be used to solve * values for every unix timestamp. However ArrayData can still be used to solve
* such a situation, since one can use another value for X-data in the dataset * such a situation, since one can use another value for X-data in the dataset
* and then map this (smaller domain) value to a date. That is we for example * and then map this (smaller domain) value to a date. That is we for example
* instead of using the unix-timestamp we use value 0 to represent the 1st date, * instead of using the unix-timestamp we use value 0 to represent the 1st date,
* 1 to represent the next date, etc. * 1 to represent the next date, etc.
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataPreprocessor * @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_DataPreprocessor_Array extends Image_Graph_DataPreprocessor class Image_Graph_DataPreprocessor_Array extends Image_Graph_DataPreprocessor
{ {
/** /**
* The data label array * The data label array
* @var array * @var array
* @access private * @access private
*/ */
var $_dataArray; var $_dataArray;
/** /**
* Image_Graph_ArrayData [Constructor]. * Image_Graph_ArrayData [Constructor].
* *
* @param array $array The array to use as a lookup table * @param array $array The array to use as a lookup table
*/ */
function Image_Graph_DataPreprocessor_Array($array) function Image_Graph_DataPreprocessor_Array($array)
{ {
parent::Image_Graph_DataPreprocessor(); parent::Image_Graph_DataPreprocessor();
$this->_dataArray = $array; $this->_dataArray = $array;
} }
/** /**
* Process the value * Process the value
* *
* @param var $value The value to process/format * @param var $value The value to process/format
* @return string The processed value * @return string The processed value
* @access private * @access private
*/ */
function _process($value) function _process($value)
{ {
if ((is_array($this->_dataArray)) && (isset ($this->_dataArray[$value]))) { if ((is_array($this->_dataArray)) && (isset ($this->_dataArray[$value]))) {
return $this->_dataArray[$value]; return $this->_dataArray[$value];
} else { } else {
return $value; return $value;
} }
} }
} }
?> ?>

View File

@ -1,66 +1,66 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataPreprocessor * @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Currency.php,v 1.6 2005/08/24 20:35:59 nosey Exp $ * @version CVS: $Id: Currency.php,v 1.6 2005/08/24 20:35:59 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/DataPreprocessor/Formatted.php * Include file Image/Graph/DataPreprocessor/Formatted.php
*/ */
require_once 'Image/Graph/DataPreprocessor/Formatted.php'; require_once 'Image/Graph/DataPreprocessor/Formatted.php';
/** /**
* Format data as a currency. * Format data as a currency.
* *
* Uses the {@link Image_Graph_DataPreprocessor_Formatted} to represent the * Uses the {@link Image_Graph_DataPreprocessor_Formatted} to represent the
* values as a currency, i.e. 10 => 10.00 * values as a currency, i.e. 10 => 10.00
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataPreprocessor * @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_DataPreprocessor_Currency extends Image_Graph_DataPreprocessor_Formatted class Image_Graph_DataPreprocessor_Currency extends Image_Graph_DataPreprocessor_Formatted
{ {
/** /**
* Image_Graph_CurrencyData [Constructor]. * Image_Graph_CurrencyData [Constructor].
* *
* @param string $currencySymbol The symbol representing the currency * @param string $currencySymbol The symbol representing the currency
*/ */
function Image_Graph_DataPreprocessor_Currency($currencySymbol) function Image_Graph_DataPreprocessor_Currency($currencySymbol)
{ {
parent::Image_Graph_DataPreprocessor_Formatted("$currencySymbol %0.2f"); parent::Image_Graph_DataPreprocessor_Formatted("$currencySymbol %0.2f");
} }
} }
?> ?>

View File

@ -1,90 +1,90 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataPreprocessor * @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Date.php,v 1.6 2005/08/24 20:35:59 nosey Exp $ * @version CVS: $Id: Date.php,v 1.6 2005/08/24 20:35:59 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/DataPreprocessor.php * Include file Image/Graph/DataPreprocessor.php
*/ */
require_once 'Image/Graph/DataPreprocessor.php'; require_once 'Image/Graph/DataPreprocessor.php';
/** /**
* Formats Unix timestamp as a date using specified format. * Formats Unix timestamp as a date using specified format.
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataPreprocessor * @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_DataPreprocessor_Date extends Image_Graph_DataPreprocessor class Image_Graph_DataPreprocessor_Date extends Image_Graph_DataPreprocessor
{ {
/** /**
* The format of the Unix time stamp. * The format of the Unix time stamp.
* See <a href = 'http://www.php.net/manual/en/function.date.php'>PHP * See <a href = 'http://www.php.net/manual/en/function.date.php'>PHP
* Manual</a> for a description * Manual</a> for a description
* @var string * @var string
* @access private * @access private
*/ */
var $_format; var $_format;
/** /**
* Create a DateData preprocessor [Constructor] * Create a DateData preprocessor [Constructor]
* *
* @param string $format See {@link http://www.php.net/manual/en/function.date.php * @param string $format See {@link http://www.php.net/manual/en/function.date.php
* PHP Manual} for a description * PHP Manual} for a description
*/ */
function Image_Graph_DataPreprocessor_Date($format) function Image_Graph_DataPreprocessor_Date($format)
{ {
parent::Image_Graph_DataPreprocessor(); parent::Image_Graph_DataPreprocessor();
$this->_format = $format; $this->_format = $format;
} }
/** /**
* Process the value * Process the value
* *
* @param var $value The value to process/format * @param var $value The value to process/format
* @return string The processed value * @return string The processed value
* @access private * @access private
*/ */
function _process($value) function _process($value)
{ {
if (!$value) { if (!$value) {
return false; return false;
} else { } else {
return date($this->_format, $value); return date($this->_format, $value);
} }
} }
} }
?> ?>

View File

@ -1,90 +1,90 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataPreprocessor * @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Formatted.php,v 1.6 2005/08/24 20:35:59 nosey Exp $ * @version CVS: $Id: Formatted.php,v 1.6 2005/08/24 20:35:59 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/DataPreprocessor.php * Include file Image/Graph/DataPreprocessor.php
*/ */
require_once 'Image/Graph/DataPreprocessor.php'; require_once 'Image/Graph/DataPreprocessor.php';
/** /**
* Format data using a (s)printf pattern. * Format data using a (s)printf pattern.
* *
* This method is useful when data must displayed using a simple (s) printf * This method is useful when data must displayed using a simple (s) printf
* pattern as described in the {@link http://www.php. net/manual/en/function. * pattern as described in the {@link http://www.php. net/manual/en/function.
* sprintf.php PHP manual} * sprintf.php PHP manual}
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataPreprocessor * @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_DataPreprocessor_Formatted extends Image_Graph_DataPreprocessor class Image_Graph_DataPreprocessor_Formatted extends Image_Graph_DataPreprocessor
{ {
/** /**
* A (s)printf format string. * A (s)printf format string.
* See {@link http://www.php.net/manual/en/function.sprintf.php PHP Manual} * See {@link http://www.php.net/manual/en/function.sprintf.php PHP Manual}
* for a description * for a description
* @var string * @var string
* @access private * @access private
*/ */
var $_format; var $_format;
/** /**
* Create a (s)printf format data preprocessor * Create a (s)printf format data preprocessor
* *
* @param string $format See {@link http://www.php.net/manual/en/function.sprintf.php * @param string $format See {@link http://www.php.net/manual/en/function.sprintf.php
* PHP Manual} for a description * PHP Manual} for a description
*/ */
function Image_Graph_DataPreprocessor_Formatted($format) function Image_Graph_DataPreprocessor_Formatted($format)
{ {
parent::Image_Graph_DataPreprocessor(); parent::Image_Graph_DataPreprocessor();
$this->_format = $format; $this->_format = $format;
} }
/** /**
* Process the value * Process the value
* *
* @param var $value The value to process/format * @param var $value The value to process/format
* @return string The processed value * @return string The processed value
* @access private * @access private
*/ */
function _process($value) function _process($value)
{ {
return sprintf($this->_format, $value); return sprintf($this->_format, $value);
} }
} }
?> ?>

View File

@ -1,92 +1,92 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataPreprocessor * @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Function.php,v 1.6 2005/08/24 20:35:59 nosey Exp $ * @version CVS: $Id: Function.php,v 1.7 2005/11/11 17:53:44 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/DataPreprocessor.php * Include file Image/Graph/DataPreprocessor.php
*/ */
require_once 'Image/Graph/DataPreprocessor.php'; require_once 'Image/Graph/DataPreprocessor.php';
/** /**
* Formatting a value using a userdefined function. * Formatting a value using a userdefined function.
* *
* Use this method to convert/format a value to a 'displayable' lable using a (perhaps) * Use this method to convert/format a value to a 'displayable' lable using a (perhaps)
* more complex function. An example could be (not very applicable though) if one would * more complex function. An example could be (not very applicable though) if one would
* need for values to be displayed on the reverse order, i.e. 1234 would be displayed as * need for values to be displayed on the reverse order, i.e. 1234 would be displayed as
* 4321, then this method can solve this by creating the function that converts the value * 4321, then this method can solve this by creating the function that converts the value
* and use the FunctionData datapreprocessor to make Image_Graph use this function. * and use the FunctionData datapreprocessor to make Image_Graph use this function.
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataPreprocessor * @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_DataPreprocessor_Function extends Image_Graph_DataPreprocessor class Image_Graph_DataPreprocessor_Function extends Image_Graph_DataPreprocessor
{ {
/** /**
* The name of the PHP function * The name of the PHP function
* @var string * @var string
* @access private * @access private
*/ */
var $_dataFunction; var $_dataFunction;
/** /**
* Create a FunctionData preprocessor * Create a FunctionData preprocessor
* *
* @param string $function The name of the PHP function to use as * @param string $function The name of the PHP function to use as
* a preprocessor, this function must take a single parameter and return a * a preprocessor, this function must take a single parameter and return a
* formatted version of this parameter * formatted version of this parameter
*/ */
function Image_Graph_DataPreprocessor_Function($function) function Image_Graph_DataPreprocessor_Function($function)
{ {
parent::Image_Graph_DataPreprocessor(); parent::Image_Graph_DataPreprocessor();
$this->_dataFunction = $function; $this->_dataFunction = $function;
} }
/** /**
* Process the value * Process the value
* *
* @param var $value The value to process/format * @param var $value The value to process/format
* @return string The processed value * @return string The processed value
* @access private * @access private
*/ */
function _process($value) function _process($value)
{ {
$function = $this->_dataFunction; $function = $this->_dataFunction;
return $function ($value); return call_user_func($function, $value);
} }
} }
?> ?>

View File

@ -1,89 +1,89 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataPreprocessor * @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: NumberText.php,v 1.6 2005/08/24 20:35:59 nosey Exp $ * @version CVS: $Id: NumberText.php,v 1.6 2005/08/24 20:35:59 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/DataPreprocessor.php * Include file Image/Graph/DataPreprocessor.php
*/ */
require_once 'Image/Graph/DataPreprocessor.php'; require_once 'Image/Graph/DataPreprocessor.php';
/** /**
* Formatting a number as its written in languages supported by Numbers_Words. * Formatting a number as its written in languages supported by Numbers_Words.
* *
* Used to display values as text, i.e. 123 is displayed as one hundred and twenty three. * Used to display values as text, i.e. 123 is displayed as one hundred and twenty three.
* Requires Numbers_Words * Requires Numbers_Words
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataPreprocessor * @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_DataPreprocessor_NumberText extends Image_Graph_DataPreprocessor class Image_Graph_DataPreprocessor_NumberText extends Image_Graph_DataPreprocessor
{ {
/** /**
* The language identifier * The language identifier
* @var string * @var string
* @access private * @access private
*/ */
var $_language; var $_language;
/** /**
* Image_Graph_NumberText [Constructor]. * Image_Graph_NumberText [Constructor].
* *
* Supported languages see {@link http://pear.php.net/package/Numbers_Words Numbers_Words} * Supported languages see {@link http://pear.php.net/package/Numbers_Words Numbers_Words}
* *
* @param string $langugage The language identifier for the language. * @param string $langugage The language identifier for the language.
*/ */
function Image_Graph_DataPreprocessor_NumberText($language = 'en_US') function Image_Graph_DataPreprocessor_NumberText($language = 'en_US')
{ {
parent::Image_Graph_DataPreprocessor(); parent::Image_Graph_DataPreprocessor();
$this->_language = $language; $this->_language = $language;
require_once 'Numbers/Words.php'; require_once 'Numbers/Words.php';
} }
/** /**
* Process the value * Process the value
* *
* @param var $value The value to process/format * @param var $value The value to process/format
* @return string The processed value * @return string The processed value
* @access private * @access private
*/ */
function _process($value) function _process($value)
{ {
return Numbers_Words::toWords($value, $this->_language); return Numbers_Words::toWords($value, $this->_language);
} }
} }
?> ?>

View File

@ -1,79 +1,79 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataPreprocessor * @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: RomanNumerals.php,v 1.6 2005/08/24 20:35:59 nosey Exp $ * @version CVS: $Id: RomanNumerals.php,v 1.6 2005/08/24 20:35:59 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/DataPreprocessor.php * Include file Image/Graph/DataPreprocessor.php
*/ */
require_once 'Image/Graph/DataPreprocessor.php'; require_once 'Image/Graph/DataPreprocessor.php';
/** /**
* Formatting a value as a roman numerals. * Formatting a value as a roman numerals.
* *
* Values are formatted as roman numeral, i.e. 1 = I, 2 = II, 9 = IX, 2004 = MMIV. * Values are formatted as roman numeral, i.e. 1 = I, 2 = II, 9 = IX, 2004 = MMIV.
* Requires Numbers_Roman * Requires Numbers_Roman
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataPreprocessor * @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_DataPreprocessor_RomanNumerals extends Image_Graph_DataPreprocessor class Image_Graph_DataPreprocessor_RomanNumerals extends Image_Graph_DataPreprocessor
{ {
/** /**
* Create a RomanNumerals preprocessor * Create a RomanNumerals preprocessor
* *
* See {@link http://pear.php.net/package/Numbers_Roman Numbers_Roman} * See {@link http://pear.php.net/package/Numbers_Roman Numbers_Roman}
*/ */
function Image_Graph_DataPreprocessor_RomanNumerals() function Image_Graph_DataPreprocessor_RomanNumerals()
{ {
parent::Image_Graph_DataPreprocessor(); parent::Image_Graph_DataPreprocessor();
include_once 'Numbers/Roman.php'; include_once 'Numbers/Roman.php';
} }
/** /**
* Process the value * Process the value
* *
* @param var $value The value to process/format * @param var $value The value to process/format
* @return string The processed value * @return string The processed value
* @access private * @access private
*/ */
function _process($value) function _process($value)
{ {
return Numbers_Roman::toNumeral($value); return Numbers_Roman::toNumeral($value);
} }
} }
?> ?>

View File

@ -1,67 +1,67 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataPreprocessor * @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Sequential.php,v 1.5 2005/02/21 20:49:50 nosey Exp $ * @version CVS: $Id: Sequential.php,v 1.5 2005/02/21 20:49:50 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/DataPreprocessor/Array.php * Include file Image/Graph/DataPreprocessor/Array.php
*/ */
require_once 'Image/Graph/DataPreprocessor/Array.php'; require_once 'Image/Graph/DataPreprocessor/Array.php';
/** /**
* Formatting values using a sequential data label array, ie. returning the * Formatting values using a sequential data label array, ie. returning the
* 'next label' when asked for any label. * 'next label' when asked for any label.
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataPreprocessor * @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_DataPreprocessor_Sequential extends Image_Graph_DataPreprocessor_Array class Image_Graph_DataPreprocessor_Sequential extends Image_Graph_DataPreprocessor_Array
{ {
/** /**
* Process the value * Process the value
* *
* @param var $value The value to process/format * @param var $value The value to process/format
* @return string The processed value * @return string The processed value
* @access private * @access private
*/ */
function _process($value) function _process($value)
{ {
list ($id, $value) = each($this->_dataArray); list ($id, $value) = each($this->_dataArray);
return $value; return $value;
} }
} }
?> ?>

View File

@ -1,67 +1,67 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataSelector * @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: DataSelector.php,v 1.7 2005/08/24 20:35:56 nosey Exp $ * @version CVS: $Id: DataSelector.php,v 1.7 2005/08/24 20:35:56 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Filter used for selecting which data to show as markers * Filter used for selecting which data to show as markers
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataSelector * @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_DataSelector class Image_Graph_DataSelector
{ {
/** /**
* Image_Graph_DataSelector [Constructor] * Image_Graph_DataSelector [Constructor]
*/ */
function Image_Graph_DataSelector() function Image_Graph_DataSelector()
{ {
} }
/** /**
* Check if a specified value should be 'selected', ie shown as a marker * Check if a specified value should be 'selected', ie shown as a marker
* *
* @param array $values The values to check * @param array $values The values to check
* @return bool True if the Values should cause a marker to be shown, false if not * @return bool True if the Values should cause a marker to be shown, false if not
* @access private * @access private
*/ */
function _select($values) function _select($values)
{ {
return true; return true;
} }
} }
?> ?>

View File

@ -1,97 +1,97 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataSelector * @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: EveryNthPoint.php,v 1.6 2005/08/24 20:35:59 nosey Exp $ * @version CVS: $Id: EveryNthPoint.php,v 1.6 2005/08/24 20:35:59 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/DataSelector.php * Include file Image/Graph/DataSelector.php
*/ */
require_once 'Image/Graph/DataSelector.php'; require_once 'Image/Graph/DataSelector.php';
/** /**
* Filter out all points except every Nth point. * Filter out all points except every Nth point.
* *
* Use this dataselector if you have a large number of datapoints, but only want to * Use this dataselector if you have a large number of datapoints, but only want to
* show markers for a small number of them, say every 10th. * show markers for a small number of them, say every 10th.
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataSelector * @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_DataSelector_EveryNthPoint extends Image_Graph_DataSelector class Image_Graph_DataSelector_EveryNthPoint extends Image_Graph_DataSelector
{ {
/** /**
* The number of points checked * The number of points checked
* @var int * @var int
* @access private * @access private
*/ */
var $_pointNum = 0; var $_pointNum = 0;
/** /**
* The number of points between every 'show', default: 10 * The number of points between every 'show', default: 10
* @var int * @var int
* @access private * @access private
*/ */
var $_pointInterval = 10; var $_pointInterval = 10;
/** /**
* EvertNthPoint [Constructor] * EvertNthPoint [Constructor]
* *
* @param int $pointInterval The number of points between every 'show', * @param int $pointInterval The number of points between every 'show',
* default: 10 * default: 10
*/ */
function Image_Graph_DataSelector_EveryNthpoint($pointInterval = 10) function Image_Graph_DataSelector_EveryNthpoint($pointInterval = 10)
{ {
parent::Image_Graph_DataSelector(); parent::Image_Graph_DataSelector();
$this->_pointInterval = $pointInterval; $this->_pointInterval = $pointInterval;
} }
/** /**
* Check if a specified value should be 'selected', ie shown as a marker * Check if a specified value should be 'selected', ie shown as a marker
* *
* @param array $values The values to check * @param array $values The values to check
* @return bool True if the Values should cause a marker to be shown, * @return bool True if the Values should cause a marker to be shown,
* false if not * false if not
* @access private * @access private
*/ */
function _select($values) function _select($values)
{ {
$oldPointNum = $this->_pointNum; $oldPointNum = $this->_pointNum;
$this->_pointNum++; $this->_pointNum++;
return (($oldPointNum % $this->_pointInterval) == 0); return (($oldPointNum % $this->_pointInterval) == 0);
} }
} }
?> ?>

View File

@ -1,68 +1,68 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataSelector * @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: NoZeros.php,v 1.5 2005/02/21 20:49:58 nosey Exp $ * @version CVS: $Id: NoZeros.php,v 1.5 2005/02/21 20:49:58 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/DataSelector.php * Include file Image/Graph/DataSelector.php
*/ */
require_once 'Image/Graph/DataSelector.php'; require_once 'Image/Graph/DataSelector.php';
/** /**
* Filter out all zero's. * Filter out all zero's.
* *
* Display all Y-values as markers, except those with Y = 0 * Display all Y-values as markers, except those with Y = 0
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataSelector * @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_DataSelector_NoZeros extends Image_Graph_DataSelector class Image_Graph_DataSelector_NoZeros extends Image_Graph_DataSelector
{ {
/** /**
* Check if a specified value should be 'selected', ie shown as a marker * Check if a specified value should be 'selected', ie shown as a marker
* *
* @param array $values The values to check * @param array $values The values to check
* @return bool True if the Values should cause a marker to be shown, false * @return bool True if the Values should cause a marker to be shown, false
* if not * if not
* @access private * @access private
*/ */
function _select($values) function _select($values)
{ {
return ($values['Y'] != 0); return ($values['Y'] != 0);
} }
} }
?> ?>

View File

@ -1,90 +1,90 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataSelector * @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Values.php,v 1.2 2005/10/05 20:51:21 nosey Exp $ * @version CVS: $Id: Values.php,v 1.2 2005/10/05 20:51:21 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/DataSelector.php * Include file Image/Graph/DataSelector.php
*/ */
require_once 'Image/Graph/DataSelector.php'; require_once 'Image/Graph/DataSelector.php';
/** /**
* Filter out all but the specified values. * Filter out all but the specified values.
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage DataSelector * @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_DataSelector_Values extends Image_Graph_DataSelector { class Image_Graph_DataSelector_Values extends Image_Graph_DataSelector {
/** /**
* The array with values that should be included * The array with values that should be included
* @var array * @var array
* @access private * @access private
*/ */
var $_values; var $_values;
/** /**
* ValueArray [Constructor] * ValueArray [Constructor]
* *
* @param array $valueArray The array to use as filter (default empty) * @param array $valueArray The array to use as filter (default empty)
*/ */
function &Image_Graph_DataSelector_Values($values) function &Image_Graph_DataSelector_Values($values)
{ {
parent::Image_Graph_DataSelector(); parent::Image_Graph_DataSelector();
$this->_values = $values; $this->_values = $values;
} }
/** /**
* Sets the array to use * Sets the array to use
*/ */
function setValueArray($values) function setValueArray($values)
{ {
$this->_values = $values; $this->_values = $values;
} }
/** /**
* Check if a specified value should be 'selected', ie shown as a marker * Check if a specified value should be 'selected', ie shown as a marker
* *
* @param array $values The values to check * @param array $values The values to check
* @return bool True if the Values should cause a marker to be shown, false * @return bool True if the Values should cause a marker to be shown, false
* if not * if not
* @access private * @access private
*/ */
function _select($values) function _select($values)
{ {
return ( in_array($values['Y'], $this->_values) ); return ( in_array($values['Y'], $this->_values) );
} }
} }
?> ?>

View File

@ -1,483 +1,483 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Dataset * @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Dataset.php,v 1.10 2005/08/24 20:35:55 nosey Exp $ * @version CVS: $Id: Dataset.php,v 1.10 2005/08/24 20:35:55 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Data set used to represent a data collection to plot in a chart * Data set used to represent a data collection to plot in a chart
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Dataset * @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
* @abstract * @abstract
*/ */
class Image_Graph_Dataset class Image_Graph_Dataset
{ {
/** /**
* The pointer of the data set * The pointer of the data set
* @var int * @var int
* @access private * @access private
*/ */
var $_posX = 0; var $_posX = 0;
/** /**
* The minimum X value of the dataset * The minimum X value of the dataset
* @var int * @var int
* @access private * @access private
*/ */
var $_minimumX = 0; var $_minimumX = 0;
/** /**
* The maximum X value of the dataset * The maximum X value of the dataset
* @var int * @var int
* @access private * @access private
*/ */
var $_maximumX = 0; var $_maximumX = 0;
/** /**
* The minimum Y value of the dataset * The minimum Y value of the dataset
* @var int * @var int
* @access private * @access private
*/ */
var $_minimumY = 0; var $_minimumY = 0;
/** /**
* The maximum Y value of the dataset * The maximum Y value of the dataset
* @var int * @var int
* @access private * @access private
*/ */
var $_maximumY = 0; var $_maximumY = 0;
/** /**
* The number of points in the dataset * The number of points in the dataset
* @var int * @var int
* @access private * @access private
*/ */
var $_count = 0; var $_count = 0;
/** /**
* The name of the dataset, used for legending * The name of the dataset, used for legending
* @var string * @var string
* @access private * @access private
*/ */
var $_name = ''; var $_name = '';
/** /**
* Image_Graph_Dataset [Constructor] * Image_Graph_Dataset [Constructor]
*/ */
function Image_Graph_Dataset() function Image_Graph_Dataset()
{ {
} }
/** /**
* Sets the name of the data set, used for legending * Sets the name of the data set, used for legending
* *
* @param string $name The name of the dataset * @param string $name The name of the dataset
*/ */
function setName($name) function setName($name)
{ {
$this->_name = $name; $this->_name = $name;
} }
/** /**
* Add a point to the dataset * Add a point to the dataset
* *
* $ID can contain either the ID of the point, i.e. 'DK', 123, 'George', etc. or it can contain * $ID can contain either the ID of the point, i.e. 'DK', 123, 'George', etc. or it can contain
* values used for creation of the HTML image map. This is achieved using is an an associated array * values used for creation of the HTML image map. This is achieved using is an an associated array
* with the following values: * with the following values:
* *
* 'url' The URL to create the link to * 'url' The URL to create the link to
* *
* 'alt' [optional] The alt text on the link * 'alt' [optional] The alt text on the link
* *
* 'target' [optional] The target of the link * 'target' [optional] The target of the link
* *
* 'htmltags' [optional] An associated array with html tags (tag as key), fx. 'onMouseOver' => 'history.go(-1);', 'id' => 'thelink' * 'htmltags' [optional] An associated array with html tags (tag as key), fx. 'onMouseOver' => 'history.go(-1);', 'id' => 'thelink'
* *
* @param int $x The X value to add * @param int $x The X value to add
* @param int $y The Y value to add, can be omited * @param int $y The Y value to add, can be omited
* @param var $ID The ID of the point * @param var $ID The ID of the point
*/ */
function addPoint($x, $y = false, $ID = false) function addPoint($x, $y = false, $ID = false)
{ {
if ($y !== null) { if ($y !== null) {
if (is_array($y)) { if (is_array($y)) {
$maxY = max($y); $maxY = max($y);
$minY = min($y); $minY = min($y);
} else { } else {
$maxY = $y; $maxY = $y;
$minY = $y; $minY = $y;
} }
} }
if ($this->_count) { if ($this->_count) {
$this->_minimumX = min($x, $this->_minimumX); $this->_minimumX = min($x, $this->_minimumX);
$this->_maximumX = max($x, $this->_maximumX); $this->_maximumX = max($x, $this->_maximumX);
if ($y !== null) { if ($y !== null) {
$this->_minimumY = min($minY, $this->_minimumY); $this->_minimumY = min($minY, $this->_minimumY);
$this->_maximumY = max($maxY, $this->_maximumY); $this->_maximumY = max($maxY, $this->_maximumY);
} }
} else { } else {
$this->_minimumX = $x; $this->_minimumX = $x;
$this->_maximumX = $x; $this->_maximumX = $x;
if ($y !== null) { if ($y !== null) {
$this->_minimumY = $minY; $this->_minimumY = $minY;
$this->_maximumY = $maxY; $this->_maximumY = $maxY;
} }
} }
$this->_count++; $this->_count++;
} }
/** /**
* The number of values in the dataset * The number of values in the dataset
* *
* @return int The number of values in the dataset * @return int The number of values in the dataset
*/ */
function count() function count()
{ {
return $this->_count; return $this->_count;
} }
/** /**
* Gets a X point from the dataset * Gets a X point from the dataset
* *
* @param var $x The variable to return an X value from, fx in a vector * @param var $x The variable to return an X value from, fx in a vector
* function data set * function data set
* @return var The X value of the variable * @return var The X value of the variable
* @access private * @access private
*/ */
function _getPointX($x) function _getPointX($x)
{ {
return $x; return $x;
} }
/** /**
* Gets a Y point from the dataset * Gets a Y point from the dataset
* *
* @param var $x The variable to return an Y value from, fx in a vector * @param var $x The variable to return an Y value from, fx in a vector
* function data set * function data set
* @return var The Y value of the variable * @return var The Y value of the variable
* @access private * @access private
*/ */
function _getPointY($x) function _getPointY($x)
{ {
return $x; return $x;
} }
/** /**
* Gets a ID from the dataset * Gets a ID from the dataset
* *
* @param var $x The variable to return an Y value from, fx in a vector * @param var $x The variable to return an Y value from, fx in a vector
* function data set * function data set
* @return var The ID value of the variable * @return var The ID value of the variable
* @access private * @access private
*/ */
function _getPointID($x) function _getPointID($x)
{ {
return false; return false;
} }
/** /**
* Gets point data from the dataset * Gets point data from the dataset
* *
* @param var $x The variable to return an Y value from, fx in a vector * @param var $x The variable to return an Y value from, fx in a vector
* function data set * function data set
* @return array The data for the point * @return array The data for the point
* @access private * @access private
*/ */
function _getPointData($x) function _getPointData($x)
{ {
return false; return false;
} }
/** /**
* The minimum X value * The minimum X value
* *
* @return var The minimum X value * @return var The minimum X value
*/ */
function minimumX() function minimumX()
{ {
return $this->_minimumX; return $this->_minimumX;
} }
/** /**
* The maximum X value * The maximum X value
* *
* @return var The maximum X value * @return var The maximum X value
*/ */
function maximumX() function maximumX()
{ {
return $this->_maximumX; return $this->_maximumX;
} }
/** /**
* The minimum Y value * The minimum Y value
* *
* @return var The minimum Y value * @return var The minimum Y value
*/ */
function minimumY() function minimumY()
{ {
return $this->_minimumY; return $this->_minimumY;
} }
/** /**
* The maximum Y value * The maximum Y value
* *
* @return var The maximum Y value * @return var The maximum Y value
*/ */
function maximumY() function maximumY()
{ {
return $this->_maximumY; return $this->_maximumY;
} }
/** /**
* The first point * The first point
* *
* @return array The last point * @return array The last point
*/ */
function first() function first()
{ {
return array('X' => $this->minimumX(), 'Y' => $this->minimumY()); return array('X' => $this->minimumX(), 'Y' => $this->minimumY());
} }
/** /**
* The last point * The last point
* *
* @return array The first point * @return array The first point
*/ */
function last() function last()
{ {
return array('X' => $this->maximumX(), 'Y' => $this->maximumY()); return array('X' => $this->maximumX(), 'Y' => $this->maximumY());
} }
/** /**
* The minimum X value * The minimum X value
* *
* @param var $value The minimum X value * @param var $value The minimum X value
* @access private * @access private
*/ */
function _setMinimumX($value) function _setMinimumX($value)
{ {
$this->_minimumX = $value; $this->_minimumX = $value;
} }
/** /**
* The maximum X value * The maximum X value
* *
* @param var $value The maximum X value * @param var $value The maximum X value
* @access private * @access private
*/ */
function _setMaximumX($value) function _setMaximumX($value)
{ {
$this->_maximumX = $value; $this->_maximumX = $value;
} }
/** /**
* The minimum Y value * The minimum Y value
* *
* @param var $value The minimum X value * @param var $value The minimum X value
* @access private * @access private
*/ */
function _setMinimumY($value) function _setMinimumY($value)
{ {
$this->_minimumY = $value; $this->_minimumY = $value;
} }
/** /**
* The maximum Y value * The maximum Y value
* *
* @param var $value The maximum X value * @param var $value The maximum X value
* @access private * @access private
*/ */
function _setMaximumY($value) function _setMaximumY($value)
{ {
$this->_maximumY = $value; $this->_maximumY = $value;
} }
/** /**
* The interval between 2 adjacent X values * The interval between 2 adjacent X values
* *
* @return var The interval * @return var The interval
* @access private * @access private
*/ */
function _stepX() function _stepX()
{ {
return 1; return 1;
} }
/** /**
* The interval between 2 adjacent Y values * The interval between 2 adjacent Y values
* *
* @return var The interval * @return var The interval
* @access private * @access private
*/ */
function _stepY() function _stepY()
{ {
return 1; return 1;
} }
/** /**
* Reset the intertal dataset pointer * Reset the intertal dataset pointer
* *
* @return var The first X value * @return var The first X value
* @access private * @access private
*/ */
function _reset() function _reset()
{ {
$this->_posX = $this->_minimumX; $this->_posX = $this->_minimumX;
return $this->_posX; return $this->_posX;
} }
/** /**
* Get a point close to the internal pointer * Get a point close to the internal pointer
* *
* @param int Step Number of points next to the internal pointer, negative * @param int Step Number of points next to the internal pointer, negative
* Step is towards lower X values, positive towards higher X values * Step is towards lower X values, positive towards higher X values
* @return array The point * @return array The point
* @access private * @access private
*/ */
function _nearby($step = 0) function _nearby($step = 0)
{ {
$x = $this->_getPointX($this->_posX + $this->_stepX() * $step); $x = $this->_getPointX($this->_posX + $this->_stepX() * $step);
$y = $this->_getPointY($this->_posX + $this->_stepX() * $step); $y = $this->_getPointY($this->_posX + $this->_stepX() * $step);
$ID = $this->_getPointID($this->_posX + $this->_stepX() * $step); $ID = $this->_getPointID($this->_posX + $this->_stepX() * $step);
$data = $this->_getPointData($this->_posX + $this->_stepX() * $step); $data = $this->_getPointData($this->_posX + $this->_stepX() * $step);
if (($x === false) || ($y === false)) { if (($x === false) || ($y === false)) {
return false; return false;
} else { } else {
return array ('X' => $x, 'Y' => $y, 'ID' => $ID, 'data' => $data); return array ('X' => $x, 'Y' => $y, 'ID' => $ID, 'data' => $data);
} }
} }
/** /**
* Get the next point the internal pointer refers to and advance the pointer * Get the next point the internal pointer refers to and advance the pointer
* *
* @return array The next point * @return array The next point
* @access private * @access private
*/ */
function _next() function _next()
{ {
if ($this->_posX > $this->_maximumX) { if ($this->_posX > $this->_maximumX) {
return false; return false;
} }
$x = $this->_getPointX($this->_posX); $x = $this->_getPointX($this->_posX);
$y = $this->_getPointY($this->_posX); $y = $this->_getPointY($this->_posX);
$ID = $this->_getPointID($this->_posX); $ID = $this->_getPointID($this->_posX);
$data = $this->_getPointData($this->_posX); $data = $this->_getPointData($this->_posX);
$this->_posX += $this->_stepX(); $this->_posX += $this->_stepX();
return array ('X' => $x, 'Y' => $y, 'ID' => $ID, 'data' => $data); return array ('X' => $x, 'Y' => $y, 'ID' => $ID, 'data' => $data);
} }
/** /**
* Get the average of the dataset's Y points * Get the average of the dataset's Y points
* *
* @return var The Y-average across the dataset * @return var The Y-average across the dataset
* @access private * @access private
*/ */
function _averageY() function _averageY()
{ {
$posX = $this->_minimumX; $posX = $this->_minimumX;
$count = 0; $count = 0;
$total = 0; $total = 0;
while ($posX < $this->_maximumX) { while ($posX < $this->_maximumX) {
$count ++; $count ++;
$total += $this->_getPointY($posX); $total += $this->_getPointY($posX);
$posX += $this->_stepX(); $posX += $this->_stepX();
} }
if ($count != 0) { if ($count != 0) {
return $total / $count; return $total / $count;
} else { } else {
return false; return false;
} }
} }
/** /**
* Get the median of the array passed Y points * Get the median of the array passed Y points
* *
* @param array $data The data-array to get the median from * @param array $data The data-array to get the median from
* @param int $quartile The quartile to return the median from * @param int $quartile The quartile to return the median from
* @return var The Y-median across the dataset from the specified quartile * @return var The Y-median across the dataset from the specified quartile
* @access private * @access private
*/ */
function _median($data, $quartile = 'second') function _median($data, $quartile = 'second')
{ {
sort($data); sort($data);
$point = (count($data) - 1) / 2; $point = (count($data) - 1) / 2;
if ($quartile == 'first') { if ($quartile == 'first') {
$lowPoint = 0; $lowPoint = 0;
$highPoint = floor($point); $highPoint = floor($point);
} elseif ($quartile == 'third') { } elseif ($quartile == 'third') {
$lowPoint = round($point); $lowPoint = round($point);
$highPoint = count($data) - 1; $highPoint = count($data) - 1;
} else { } else {
$lowPoint = 0; $lowPoint = 0;
$highPoint = count($data) - 1; $highPoint = count($data) - 1;
} }
$point = ($lowPoint + $highPoint) / 2; $point = ($lowPoint + $highPoint) / 2;
if (floor($point) != $point) { if (floor($point) != $point) {
$point = floor($point); $point = floor($point);
return ($data[$point] + $data[($point + 1)]) / 2; return ($data[$point] + $data[($point + 1)]) / 2;
} else { } else {
return $data[$point]; return $data[$point];
} }
} }
/** /**
* Get the median of the datasets Y points * Get the median of the datasets Y points
* *
* @param int $quartile The quartile to return the median from * @param int $quartile The quartile to return the median from
* @return var The Y-median across the dataset from the specified quartile * @return var The Y-median across the dataset from the specified quartile
* @access private * @access private
*/ */
function _medianY($quartile = 'second') function _medianY($quartile = 'second')
{ {
$pointsY = array(); $pointsY = array();
$posX = $this->_minimumX; $posX = $this->_minimumX;
while ($posX <= $this->_maximumX) { while ($posX <= $this->_maximumX) {
$pointsY[] = $this->_getPointY($posX); $pointsY[] = $this->_getPointY($posX);
$posX += $this->_stepX(); $posX += $this->_stepX();
} }
return $this->_median($pointsY, $quartile); return $this->_median($pointsY, $quartile);
} }
} }
?> ?>

View File

@ -1,147 +1,147 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Dataset * @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Function.php,v 1.7 2005/08/24 20:35:57 nosey Exp $ * @version CVS: $Id: Function.php,v 1.7 2005/08/24 20:35:57 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/Dataset.php * Include file Image/Graph/Dataset.php
*/ */
require_once 'Image/Graph/Dataset.php'; require_once 'Image/Graph/Dataset.php';
/** /**
* Function data set, points are generated by calling an external function. * Function data set, points are generated by calling an external function.
* *
* The function must be a single variable function and return a the result, * The function must be a single variable function and return a the result,
* builtin functions that are fx sin() or cos(). User defined function can be * builtin functions that are fx sin() or cos(). User defined function can be
* used if they are such, i.e: function myFunction($variable) * used if they are such, i.e: function myFunction($variable)
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Dataset * @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_Dataset_Function extends Image_Graph_Dataset class Image_Graph_Dataset_Function extends Image_Graph_Dataset
{ {
/** /**
* The name of the function * The name of the function
* @var string * @var string
* @access private * @access private
*/ */
var $_dataFunction; var $_dataFunction;
/** /**
* Image_Graph_FunctionDataset [Constructor] * Image_Graph_FunctionDataset [Constructor]
* *
* @param double $minimumX The minimum X value * @param double $minimumX The minimum X value
* @param double $maximumX The maximum X value * @param double $maximumX The maximum X value
* @param string $function The name of the function, if must be a single * @param string $function The name of the function, if must be a single
* parameter function like fx sin(x) or cos(x) * parameter function like fx sin(x) or cos(x)
* @param int $points The number of points to create * @param int $points The number of points to create
*/ */
function Image_Graph_Dataset_Function($minimumX, $maximumX, $function, $points) function Image_Graph_Dataset_Function($minimumX, $maximumX, $function, $points)
{ {
parent::Image_Graph_Dataset(); parent::Image_Graph_Dataset();
$this->_minimumX = $minimumX; $this->_minimumX = $minimumX;
$this->_maximumX = $maximumX; $this->_maximumX = $maximumX;
$this->_dataFunction = $function; $this->_dataFunction = $function;
$this->_count = $points; $this->_count = $points;
$this->_calculateMaxima(); $this->_calculateMaxima();
} }
/** /**
* Add a point to the dataset. * Add a point to the dataset.
* *
* You can't add points to a function dataset * You can't add points to a function dataset
* *
* @param int $x The X value to add * @param int $x The X value to add
* @param int $y The Y value to add, can be omited * @param int $y The Y value to add, can be omited
* @param var $ID The ID of the point * @param var $ID The ID of the point
*/ */
function addPoint($x, $y = false, $ID = false) function addPoint($x, $y = false, $ID = false)
{ {
} }
/** /**
* Gets a Y point from the dataset * Gets a Y point from the dataset
* *
* @param var $x The variable to apply the function to * @param var $x The variable to apply the function to
* @return var The function applied to the X value * @return var The function applied to the X value
* @access private * @access private
*/ */
function _getPointY($x) function _getPointY($x)
{ {
$function = $this->_dataFunction; $function = $this->_dataFunction;
return $function ($x); return $function ($x);
} }
/** /**
* The number of values in the dataset * The number of values in the dataset
* *
* @return int The number of values in the dataset * @return int The number of values in the dataset
* @access private * @access private
*/ */
function _count() function _count()
{ {
return $this->_count; return $this->_count;
} }
/** /**
* The interval between 2 adjacent Y values * The interval between 2 adjacent Y values
* *
* @return var The interval * @return var The interval
* @access private * @access private
*/ */
function _stepX() function _stepX()
{ {
return ($this->_maximumX - $this->_minimumX) / $this->_count(); return ($this->_maximumX - $this->_minimumX) / $this->_count();
} }
/** /**
* Calculates the Y extrema of the function * Calculates the Y extrema of the function
* *
* @access private * @access private
*/ */
function _calculateMaxima() function _calculateMaxima()
{ {
$x = $this->_minimumX; $x = $this->_minimumX;
while ($x <= $this->_maximumX) { while ($x <= $this->_maximumX) {
$y = $this->_getPointY($x); $y = $this->_getPointY($x);
$this->_minimumY = min($y, $this->_minimumY); $this->_minimumY = min($y, $this->_minimumY);
$this->_maximumY = max($y, $this->_maximumY); $this->_maximumY = max($y, $this->_maximumY);
$x += $this->_stepX(); $x += $this->_stepX();
} }
} }
} }
?> ?>

View File

@ -1,77 +1,77 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Dataset * @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Random.php,v 1.6 2005/08/24 20:35:57 nosey Exp $ * @version CVS: $Id: Random.php,v 1.6 2005/08/24 20:35:57 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/Dataset/Trivial.php * Include file Image/Graph/Dataset/Trivial.php
*/ */
require_once 'Image/Graph/Dataset/Trivial.php'; require_once 'Image/Graph/Dataset/Trivial.php';
/** /**
* Random data set, points are generated by random. * Random data set, points are generated by random.
* *
* This dataset is mostly (if not solely) used for demo-purposes. * This dataset is mostly (if not solely) used for demo-purposes.
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Dataset * @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_Dataset_Random extends Image_Graph_Dataset_Trivial class Image_Graph_Dataset_Random extends Image_Graph_Dataset_Trivial
{ {
/** /**
* RandomDataset [Constructor] * RandomDataset [Constructor]
* *
* @param int $count The number of points to create * @param int $count The number of points to create
* @param double $minimum The minimum value the random set can be * @param double $minimum The minimum value the random set can be
* @param double $maximum The maximum value the random set can be * @param double $maximum The maximum value the random set can be
* @param bool $includeZero Whether 0 should be included or not as an X * @param bool $includeZero Whether 0 should be included or not as an X
* value, may be omitted, default: false</false> * value, may be omitted, default: false</false>
*/ */
function Image_Graph_Dataset_Random($count, $minimum, $maximum, $includeZero = false) function Image_Graph_Dataset_Random($count, $minimum, $maximum, $includeZero = false)
{ {
parent::Image_Graph_Dataset_Trivial(); parent::Image_Graph_Dataset_Trivial();
$i = 0; $i = 0;
while ($i < $count) { while ($i < $count) {
$this->addPoint( $this->addPoint(
$ixc = ($includeZero ? $i : $i +1), $ixc = ($includeZero ? $i : $i +1),
rand($minimum, $maximum) rand($minimum, $maximum)
); );
$i ++; $i ++;
} }
} }
} }
?> ?>

View File

@ -1,114 +1,114 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Dataset * @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Sequential.php,v 1.7 2005/08/24 20:35:58 nosey Exp $ * @version CVS: $Id: Sequential.php,v 1.7 2005/08/24 20:35:58 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/Dataset/Trivial.php * Include file Image/Graph/Dataset/Trivial.php
*/ */
require_once 'Image/Graph/Dataset/Trivial.php'; require_once 'Image/Graph/Dataset/Trivial.php';
/** /**
* Sequential data set, simply add points (y) 1 by 1. * Sequential data set, simply add points (y) 1 by 1.
* *
* This is a single point (1D) dataset, all points are of the type (0, y1), (1, * This is a single point (1D) dataset, all points are of the type (0, y1), (1,
* y2), (2, y3)... Where the X-value is implicitly incremented. This is useful * y2), (2, y3)... Where the X-value is implicitly incremented. This is useful
* for example for barcharts, where you could fx. use an {@link * for example for barcharts, where you could fx. use an {@link
* Image_Graph_Dataset_Array} datapreprocessor to make sence of the x-values. * Image_Graph_Dataset_Array} datapreprocessor to make sence of the x-values.
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Dataset * @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_Dataset_Sequential extends Image_Graph_Dataset_Trivial class Image_Graph_Dataset_Sequential extends Image_Graph_Dataset_Trivial
{ {
/** /**
* Image_Graph_SequentialDataset [Constructor] * Image_Graph_SequentialDataset [Constructor]
*/ */
function Image_Graph_Dataset_Sequential($dataArray = false) function Image_Graph_Dataset_Sequential($dataArray = false)
{ {
parent::Image_Graph_Dataset_Trivial(); parent::Image_Graph_Dataset_Trivial();
if (is_array($dataArray)) { if (is_array($dataArray)) {
reset($dataArray); reset($dataArray);
foreach ($dataArray as $value) { foreach ($dataArray as $value) {
$this->addPoint($value); $this->addPoint($value);
} }
} }
} }
/** /**
* Add a point to the dataset * Add a point to the dataset
* *
* @param int $y The Y value to add, can be omited * @param int $y The Y value to add, can be omited
* @param var $ID The ID of the point * @param var $ID The ID of the point
*/ */
function addPoint($y, $ID = false) function addPoint($y, $ID = false)
{ {
parent::addPoint($this->count(), $y); parent::addPoint($this->count(), $y);
} }
/** /**
* Gets a X point from the dataset * Gets a X point from the dataset
* *
* @param var $x The variable to return an X value from, fx in a * @param var $x The variable to return an X value from, fx in a
* vector function data set * vector function data set
* @return var The X value of the variable * @return var The X value of the variable
* @access private * @access private
*/ */
function _getPointX($x) function _getPointX($x)
{ {
return ((int) $x); return ((int) $x);
} }
/** /**
* The minimum X value * The minimum X value
* @return var The minimum X value * @return var The minimum X value
*/ */
function minimumX() function minimumX()
{ {
return 0; return 0;
} }
/** /**
* The maximum X value * The maximum X value
* @return var The maximum X value * @return var The maximum X value
*/ */
function maximumX() function maximumX()
{ {
return $this->count(); return $this->count();
} }
} }
?> ?>

View File

@ -1,260 +1,260 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Dataset * @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Trivial.php,v 1.10 2005/09/25 18:08:56 nosey Exp $ * @version CVS: $Id: Trivial.php,v 1.10 2005/09/25 18:08:56 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/Dataset.php * Include file Image/Graph/Dataset.php
*/ */
require_once 'Image/Graph/Dataset.php'; require_once 'Image/Graph/Dataset.php';
/** /**
* Trivial data set, simply add points (x, y) 1 by 1 * Trivial data set, simply add points (x, y) 1 by 1
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Dataset * @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_Dataset_Trivial extends Image_Graph_Dataset class Image_Graph_Dataset_Trivial extends Image_Graph_Dataset
{ {
/** /**
* Data storage * Data storage
* @var array * @var array
* @access private * @access private
*/ */
var $_data; var $_data;
/** /**
* Image_Graph_Dataset_Trivial [Constructor] * Image_Graph_Dataset_Trivial [Constructor]
* *
* Pass an associated array ($data[$x] = $y) to the constructor for easy * Pass an associated array ($data[$x] = $y) to the constructor for easy
* data addition. Alternatively (if multiple entries with same x value is * data addition. Alternatively (if multiple entries with same x value is
* required) pass an array with (x, y) values: $data[$id] = array('x' => $x, * required) pass an array with (x, y) values: $data[$id] = array('x' => $x,
* 'y' => $y); * 'y' => $y);
* *
* NB! If passing the 1st type array at this point, the x-values will also * NB! If passing the 1st type array at this point, the x-values will also
* be used for ID tags, i.e. when using {@link Image_Graph_Fill_Array}. In * be used for ID tags, i.e. when using {@link Image_Graph_Fill_Array}. In
* the 2nd type the key/index of the "outermost" array will be the id tag * the 2nd type the key/index of the "outermost" array will be the id tag
* (i.e. $id in the example) * (i.e. $id in the example)
* *
* @param array $dataArray An associated array with values to the dataset * @param array $dataArray An associated array with values to the dataset
*/ */
function Image_Graph_Dataset_Trivial($dataArray = false) function Image_Graph_Dataset_Trivial($dataArray = false)
{ {
parent::Image_Graph_Dataset(); parent::Image_Graph_Dataset();
$this->_data = array (); $this->_data = array ();
if (is_array($dataArray)) { if (is_array($dataArray)) {
reset($dataArray); reset($dataArray);
$keys = array_keys($dataArray); $keys = array_keys($dataArray);
foreach ($keys as $x) { foreach ($keys as $x) {
$y =& $dataArray[$x]; $y =& $dataArray[$x];
if ((is_array($y)) && (isset($y['x'])) && (isset($y['y']))) { if ((is_array($y)) && (isset($y['x'])) && (isset($y['y']))) {
$this->addPoint($y['x'], $y['y'], (isset($y['id']) ? $y['id'] : $x)); $this->addPoint($y['x'], $y['y'], (isset($y['id']) ? $y['id'] : $x));
} else { } else {
$this->addPoint($x, $y, $x); $this->addPoint($x, $y, $x);
} }
} }
} }
} }
/** /**
* Add a point to the dataset * Add a point to the dataset
* *
* $ID can contain either the ID of the point, i.e. 'DK', 123, 'George', etc. or it can contain * $ID can contain either the ID of the point, i.e. 'DK', 123, 'George', etc. or it can contain
* values used for creation of the HTML image map. This is achieved using is an an associated array * values used for creation of the HTML image map. This is achieved using is an an associated array
* with the following values: * with the following values:
* *
* 'url' The URL to create the link to * 'url' The URL to create the link to
* *
* 'alt' [optional] The alt text on the link * 'alt' [optional] The alt text on the link
* *
* 'target' [optional] The target of the link * 'target' [optional] The target of the link
* *
* 'htmltags' [optional] An associated array with html tags (tag as key), fx. 'onMouseOver' => 'history.go(-1);', 'id' => 'thelink' * 'htmltags' [optional] An associated array with html tags (tag as key), fx. 'onMouseOver' => 'history.go(-1);', 'id' => 'thelink'
* *
* @param int $x The X value to add * @param int $x The X value to add
* @param int $y The Y value to add, can be omited * @param int $y The Y value to add, can be omited
* @param var $ID The ID of the point * @param var $ID The ID of the point
*/ */
function addPoint($x, $y = false, $ID = false) function addPoint($x, $y = false, $ID = false)
{ {
parent::addPoint($x, $y, $ID); parent::addPoint($x, $y, $ID);
if (is_array($ID)) { if (is_array($ID)) {
$data = $ID; $data = $ID;
$ID = (isset($data['id']) ? $data['id'] : false); $ID = (isset($data['id']) ? $data['id'] : false);
} else { } else {
$data = false; $data = false;
} }
$this->_data[] = array ('X' => $x, 'Y' => $y, 'ID' => $ID, 'data' => $data); $this->_data[] = array ('X' => $x, 'Y' => $y, 'ID' => $ID, 'data' => $data);
if (!is_numeric($x)) { if (!is_numeric($x)) {
$this->_maximumX = count($this->_data); $this->_maximumX = count($this->_data);
} }
} }
/** /**
* The first point * The first point
* *
* @return array The last point * @return array The last point
*/ */
function first() function first()
{ {
reset($this->_data); reset($this->_data);
return current($this->_data); return current($this->_data);
} }
/** /**
* The last point * The last point
* *
* @return array The first point * @return array The first point
*/ */
function last() function last()
{ {
return end($this->_data); return end($this->_data);
} }
/** /**
* Gets a X point from the dataset * Gets a X point from the dataset
* *
* @param var $x The variable to return an X value from, fx in a * @param var $x The variable to return an X value from, fx in a
* vector function data set * vector function data set
* @return var The X value of the variable * @return var The X value of the variable
* @access private * @access private
*/ */
function _getPointX($x) function _getPointX($x)
{ {
if (isset($this->_data[$x])) { if (isset($this->_data[$x])) {
return $this->_data[$x]['X']; return $this->_data[$x]['X'];
} else { } else {
return false; return false;
} }
} }
/** /**
* Gets a Y point from the dataset * Gets a Y point from the dataset
* *
* @param var $x The variable to return an Y value from, fx in a * @param var $x The variable to return an Y value from, fx in a
* vector function data set * vector function data set
* @return var The Y value of the variable * @return var The Y value of the variable
* @access private * @access private
*/ */
function _getPointY($x) function _getPointY($x)
{ {
if (isset($this->_data[$x])) { if (isset($this->_data[$x])) {
return $this->_data[$x]['Y']; return $this->_data[$x]['Y'];
} else { } else {
return false; return false;
} }
} }
/** /**
* Gets a ID from the dataset * Gets a ID from the dataset
* *
* @param var $x The variable to return an Y value from, fx in a * @param var $x The variable to return an Y value from, fx in a
* vector function data set * vector function data set
* @return var The ID value of the variable * @return var The ID value of the variable
* @access private * @access private
*/ */
function _getPointID($x) function _getPointID($x)
{ {
if (isset($this->_data[$x])) { if (isset($this->_data[$x])) {
return $this->_data[$x]['ID']; return $this->_data[$x]['ID'];
} else { } else {
return false; return false;
} }
} }
/** /**
* Gets point data from the dataset * Gets point data from the dataset
* *
* @param var $x The variable to return an Y value from, fx in a vector * @param var $x The variable to return an Y value from, fx in a vector
* function data set * function data set
* @return array The data for the point * @return array The data for the point
* @access private * @access private
*/ */
function _getPointData($x) function _getPointData($x)
{ {
if (isset($this->_data[$x])) { if (isset($this->_data[$x])) {
return $this->_data[$x]['data']; return $this->_data[$x]['data'];
} else { } else {
return false; return false;
} }
} }
/** /**
* The number of values in the dataset * The number of values in the dataset
* *
* @return int The number of values in the dataset * @return int The number of values in the dataset
*/ */
function count() function count()
{ {
return count($this->_data); return count($this->_data);
} }
/** /**
* Reset the intertal dataset pointer * Reset the intertal dataset pointer
* *
* @return var The first X value * @return var The first X value
* @access private * @access private
*/ */
function _reset() function _reset()
{ {
$this->_posX = 0; $this->_posX = 0;
return $this->_posX; return $this->_posX;
} }
/** /**
* Get the next point the internal pointer refers to and advance the pointer * Get the next point the internal pointer refers to and advance the pointer
* *
* @return array The next point * @return array The next point
* @access private * @access private
*/ */
function _next() function _next()
{ {
if ($this->_posX >= $this->count()) { if ($this->_posX >= $this->count()) {
return false; return false;
} }
$x = $this->_getPointX($this->_posX); $x = $this->_getPointX($this->_posX);
$y = $this->_getPointY($this->_posX); $y = $this->_getPointY($this->_posX);
$ID = $this->_getPointID($this->_posX); $ID = $this->_getPointID($this->_posX);
$data = $this->_getPointData($this->_posX); $data = $this->_getPointData($this->_posX);
$this->_posX += $this->_stepX(); $this->_posX += $this->_stepX();
return array('X' => $x, 'Y' => $y, 'ID' => $ID, 'data' => $data); return array('X' => $x, 'Y' => $y, 'ID' => $ID, 'data' => $data);
} }
} }
?> ?>

View File

@ -1,185 +1,185 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Dataset * @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: VectorFunction.php,v 1.6 2005/08/24 20:35:57 nosey Exp $ * @version CVS: $Id: VectorFunction.php,v 1.6 2005/08/24 20:35:57 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/Dataset.php * Include file Image/Graph/Dataset.php
*/ */
require_once 'Image/Graph/Dataset.php'; require_once 'Image/Graph/Dataset.php';
/** /**
* Vector Function data set. * Vector Function data set.
* *
* Points are generated by calling 2 external functions, fx. x = sin(t) and y = * Points are generated by calling 2 external functions, fx. x = sin(t) and y =
* cos(t) * cos(t)
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Dataset * @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_Dataset_VectorFunction extends Image_Graph_Dataset class Image_Graph_Dataset_VectorFunction extends Image_Graph_Dataset
{ {
/** /**
* The name of the X function * The name of the X function
* @var string * @var string
* @access private * @access private
*/ */
var $_functionX; var $_functionX;
/** /**
* The name of the Y function * The name of the Y function
* @var string * @var string
* @access private * @access private
*/ */
var $_functionY; var $_functionY;
/** /**
* The minimum of the vector function variable * The minimum of the vector function variable
* @var double * @var double
* @access private * @access private
*/ */
var $_minimumT; var $_minimumT;
/** /**
* The maximum of the vector function variable * The maximum of the vector function variable
* @var double * @var double
* @access private * @access private
*/ */
var $_maximumT; var $_maximumT;
/** /**
* Image_Graph_VectorFunctionDataset [Constructor] * Image_Graph_VectorFunctionDataset [Constructor]
* *
* @param double $minimumT The minimum value of the vector function variable * @param double $minimumT The minimum value of the vector function variable
* @param double $maximumT The maximum value of the vector function variable * @param double $maximumT The maximum value of the vector function variable
* @param string $functionX The name of the X function, if must be a single * @param string $functionX The name of the X function, if must be a single
* parameter function like fx sin(x) or cos(x) * parameter function like fx sin(x) or cos(x)
* @param string $functionY The name of the Y function, if must be a single * @param string $functionY The name of the Y function, if must be a single
* parameter function like fx sin(x) or cos(x) * parameter function like fx sin(x) or cos(x)
* @param int $points The number of points to create * @param int $points The number of points to create
*/ */
function Image_Graph_Dataset_VectorFunction($minimumT, $maximumT, $functionX, $functionY, $points) function Image_Graph_Dataset_VectorFunction($minimumT, $maximumT, $functionX, $functionY, $points)
{ {
parent::Image_Graph_Dataset(); parent::Image_Graph_Dataset();
$this->_minimumT = $minimumT; $this->_minimumT = $minimumT;
$this->_maximumT = $maximumT; $this->_maximumT = $maximumT;
$this->_functionX = $functionX; $this->_functionX = $functionX;
$this->_functionY = $functionY; $this->_functionY = $functionY;
$this->_count = $points; $this->_count = $points;
$this->_calculateMaxima(); $this->_calculateMaxima();
} }
/** /**
* Add a point to the dataset * Add a point to the dataset
* *
* @param int $x The X value to add * @param int $x The X value to add
* @param int $y The Y value to add, can be omited * @param int $y The Y value to add, can be omited
* @param var $ID The ID of the point * @param var $ID The ID of the point
*/ */
function addPoint($x, $y = false, $ID = false) function addPoint($x, $y = false, $ID = false)
{ {
} }
/** /**
* Gets a X point from the dataset * Gets a X point from the dataset
* *
* @param var $x The variable to apply the X function to * @param var $x The variable to apply the X function to
* @return var The X function applied to the X value * @return var The X function applied to the X value
* @access private * @access private
*/ */
function _getPointX($x) function _getPointX($x)
{ {
$functionX = $this->_functionX; $functionX = $this->_functionX;
return $functionX ($x); return $functionX ($x);
} }
/** /**
* Gets a Y point from the dataset * Gets a Y point from the dataset
* *
* @param var $x The variable to apply the Y function to * @param var $x The variable to apply the Y function to
* @return var The Y function applied to the X value * @return var The Y function applied to the X value
* @access private * @access private
*/ */
function _getPointY($x) function _getPointY($x)
{ {
$functionY = $this->_functionY; $functionY = $this->_functionY;
return $functionY ($x); return $functionY ($x);
} }
/** /**
* Reset the intertal dataset pointer * Reset the intertal dataset pointer
* *
* @return var The first T value * @return var The first T value
* @access private * @access private
*/ */
function _reset() function _reset()
{ {
$this->_posX = $this->_minimumT; $this->_posX = $this->_minimumT;
return $this->_posX; return $this->_posX;
} }
/** /**
* The interval between 2 adjacent T values * The interval between 2 adjacent T values
* *
* @return var The interval * @return var The interval
* @access private * @access private
*/ */
function _stepX() function _stepX()
{ {
return ($this->_maximumT - $this->_minimumT) / $this->count(); return ($this->_maximumT - $this->_minimumT) / $this->count();
} }
/** /**
* Calculates the X and Y extrema of the functions * Calculates the X and Y extrema of the functions
* *
* @access private * @access private
*/ */
function _calculateMaxima() function _calculateMaxima()
{ {
$t = $this->_minimumT; $t = $this->_minimumT;
while ($t <= $this->_maximumT) { while ($t <= $this->_maximumT) {
$x = $this->_getPointX($t); $x = $this->_getPointX($t);
$y = $this->_getPointY($t); $y = $this->_getPointY($t);
$this->_minimumX = min($x, $this->_minimumX); $this->_minimumX = min($x, $this->_minimumX);
$this->_maximumX = max($x, $this->_maximumX); $this->_maximumX = max($x, $this->_maximumX);
$this->_minimumY = min($y, $this->_minimumY); $this->_minimumY = min($y, $this->_minimumY);
$this->_maximumY = max($y, $this->_maximumY); $this->_maximumY = max($y, $this->_maximumY);
$t += $this->_stepX(); $t += $this->_stepX();
} }
} }
} }
?> ?>

File diff suppressed because it is too large Load Diff

View File

@ -1,64 +1,64 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Figure * @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Circle.php,v 1.6 2005/08/24 20:36:01 nosey Exp $ * @version CVS: $Id: Circle.php,v 1.6 2005/08/24 20:36:01 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/Figure/Ellipse.php * Include file Image/Graph/Figure/Ellipse.php
*/ */
require_once 'Image/Graph/Figure/Ellipse.php'; require_once 'Image/Graph/Figure/Ellipse.php';
/** /**
* Circle to draw on the canvas * Circle to draw on the canvas
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Figure * @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_Figure_Circle extends Image_Graph_Figure_Ellipse class Image_Graph_Figure_Circle extends Image_Graph_Figure_Ellipse
{ {
/** /**
* Image_Graph_Circle [Constructor] * Image_Graph_Circle [Constructor]
* *
* @param int $x The center pixel of the circle on the canvas * @param int $x The center pixel of the circle on the canvas
* @param int $y The center pixel of the circle on the canvas * @param int $y The center pixel of the circle on the canvas
* @param int $radius The radius in pixels of the circle * @param int $radius The radius in pixels of the circle
*/ */
function Image_Graph_Figure_Circle($x, $y, $radius) function Image_Graph_Figure_Circle($x, $y, $radius)
{ {
parent::Image_Graph_Ellipse($x, $y, $radius, $radius); parent::Image_Graph_Ellipse($x, $y, $radius, $radius);
} }
} }
?> ?>

View File

@ -1,97 +1,97 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Figure * @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Ellipse.php,v 1.9 2005/08/24 20:36:00 nosey Exp $ * @version CVS: $Id: Ellipse.php,v 1.9 2005/08/24 20:36:00 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/Element.php * Include file Image/Graph/Element.php
*/ */
require_once 'Image/Graph/Element.php'; require_once 'Image/Graph/Element.php';
/** /**
* Ellipse to draw on the canvas * Ellipse to draw on the canvas
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Figure * @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_Figure_Ellipse extends Image_Graph_Element class Image_Graph_Figure_Ellipse extends Image_Graph_Element
{ {
/** /**
* Ellipse [Constructor] * Ellipse [Constructor]
* *
* @param int $x The center pixel of the ellipse on the canvas * @param int $x The center pixel of the ellipse on the canvas
* @param int $y The center pixel of the ellipse on the canvas * @param int $y The center pixel of the ellipse on the canvas
* @param int $radiusX The width in pixels of the box on the canvas * @param int $radiusX The width in pixels of the box on the canvas
* @param int $radiusY The height in pixels of the box on the canvas * @param int $radiusY The height in pixels of the box on the canvas
*/ */
function Image_Graph_Figure_Ellipse($x, $y, $radiusX, $radiusY) function Image_Graph_Figure_Ellipse($x, $y, $radiusX, $radiusY)
{ {
parent::Image_Graph_Element(); parent::Image_Graph_Element();
$this->_setCoords($x - $radiusX, $y - $radiusY, $x + $radiusX, $y + $radiusY); $this->_setCoords($x - $radiusX, $y - $radiusY, $x + $radiusX, $y + $radiusY);
} }
/** /**
* Output the ellipse * Output the ellipse
* *
* @return bool Was the output 'good' (true) or 'bad' (false). * @return bool Was the output 'good' (true) or 'bad' (false).
* @access private * @access private
*/ */
function _done() function _done()
{ {
if (parent::_done() === false) { if (parent::_done() === false) {
return false; return false;
} }
$this->_canvas->startGroup(get_class($this)); $this->_canvas->startGroup(get_class($this));
$this->_getFillStyle(); $this->_getFillStyle();
$this->_getLineStyle(); $this->_getLineStyle();
$this->_canvas->ellipse( $this->_canvas->ellipse(
array( array(
'x' => ($this->_left + $this->_right) / 2, 'x' => ($this->_left + $this->_right) / 2,
'y' => ($this->_top + $this->_bottom) / 2, 'y' => ($this->_top + $this->_bottom) / 2,
'rx' => $this->width(), 'rx' => $this->width(),
'ry' => $this->height() 'ry' => $this->height()
) )
); );
$this->_canvas->endGroup(); $this->_canvas->endGroup();
return true; return true;
} }
} }
?> ?>

View File

@ -1,94 +1,94 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Figure * @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Polygon.php,v 1.8 2005/08/03 21:21:57 nosey Exp $ * @version CVS: $Id: Polygon.php,v 1.8 2005/08/03 21:21:57 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/Element.php * Include file Image/Graph/Element.php
*/ */
require_once 'Image/Graph/Element.php'; require_once 'Image/Graph/Element.php';
/** /**
* Polygon to draw on the canvas * Polygon to draw on the canvas
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Figure * @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_Figure_Polygon extends Image_Graph_Element class Image_Graph_Figure_Polygon extends Image_Graph_Element
{ {
/** /**
* Polygon vertices * Polygon vertices
* *
* @var array * @var array
* @access private * @access private
*/ */
var $_polygon = array (); var $_polygon = array ();
/** /**
* Add a vertex to the polygon * Add a vertex to the polygon
* *
* @param int $x X-coordinate * @param int $x X-coordinate
* @param int $y Y-coordinate * @param int $y Y-coordinate
*/ */
function addVertex($x, $y) function addVertex($x, $y)
{ {
$this->_canvas->addVertex(array('x' => $x, 'y' => $y)); $this->_canvas->addVertex(array('x' => $x, 'y' => $y));
} }
/** /**
* Output the polygon * Output the polygon
* *
* @return bool Was the output 'good' (true) or 'bad' (false). * @return bool Was the output 'good' (true) or 'bad' (false).
* @access private * @access private
*/ */
function _done() function _done()
{ {
if (parent::_done() === false) { if (parent::_done() === false) {
return false; return false;
} }
$this->_canvas->startGroup(get_class($this)); $this->_canvas->startGroup(get_class($this));
$this->_getFillStyle(); $this->_getFillStyle();
$this->_getLineStyle(); $this->_getLineStyle();
$this->_canvas->polygon(array('connect' => true)); $this->_canvas->polygon(array('connect' => true));
$this->_canvas->endGroup(); $this->_canvas->endGroup();
return true; return true;
} }
} }
?> ?>

View File

@ -1,96 +1,96 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Figure * @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Rectangle.php,v 1.9 2005/08/24 20:36:01 nosey Exp $ * @version CVS: $Id: Rectangle.php,v 1.9 2005/08/24 20:36:01 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/Element.php * Include file Image/Graph/Element.php
*/ */
require_once 'Image/Graph/Element.php'; require_once 'Image/Graph/Element.php';
/** /**
* Rectangle to draw on the canvas * Rectangle to draw on the canvas
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Figure * @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_Figure_Rectangle extends Image_Graph_Element class Image_Graph_Figure_Rectangle extends Image_Graph_Element
{ {
/** /**
* Rectangle [Construcor] * Rectangle [Construcor]
* *
* @param int $x The leftmost pixel of the box on the canvas * @param int $x The leftmost pixel of the box on the canvas
* @param int $y The topmost pixel of the box on the canvas * @param int $y The topmost pixel of the box on the canvas
* @param int $width The width in pixels of the box on the canvas * @param int $width The width in pixels of the box on the canvas
* @param int $height The height in pixels of the box on the canvas * @param int $height The height in pixels of the box on the canvas
*/ */
function Image_Graph_Figure_Rectangle($x, $y, $width, $height) function Image_Graph_Figure_Rectangle($x, $y, $width, $height)
{ {
parent::Image_Graph_Element(); parent::Image_Graph_Element();
$this->_setCoords($x, $y, $x + $width, $y + $height); $this->_setCoords($x, $y, $x + $width, $y + $height);
} }
/** /**
* Output the box * Output the box
* *
* @return bool Was the output 'good' (true) or 'bad' (false). * @return bool Was the output 'good' (true) or 'bad' (false).
* @access private * @access private
*/ */
function _done() function _done()
{ {
if (parent::_done() === false) { if (parent::_done() === false) {
return false; return false;
} }
$this->_canvas->startGroup(get_class($this)); $this->_canvas->startGroup(get_class($this));
$this->_getFillStyle(); $this->_getFillStyle();
$this->_getLineStyle(); $this->_getLineStyle();
$this->_canvas->rectangle( $this->_canvas->rectangle(
array( array(
'x0' => $this->_left, 'x0' => $this->_left,
'y0' => $this->_top, 'y0' => $this->_top,
'x1' => $this->_right, 'x1' => $this->_right,
'y1' => $this->_bottom 'y1' => $this->_bottom
) )
); );
$this->_canvas->endGroup(); $this->_canvas->endGroup();
return true; return true;
} }
} }
?> ?>

View File

@ -1,63 +1,63 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Fill * @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Fill.php,v 1.6 2005/02/21 20:49:46 nosey Exp $ * @version CVS: $Id: Fill.php,v 1.6 2005/02/21 20:49:46 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/Element.php * Include file Image/Graph/Element.php
*/ */
require_once 'Image/Graph/Element.php'; require_once 'Image/Graph/Element.php';
/** /**
* Style used for filling elements. * Style used for filling elements.
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Fill * @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
* @abstract * @abstract
*/ */
class Image_Graph_Fill extends Image_Graph_Common class Image_Graph_Fill extends Image_Graph_Common
{ {
/** /**
* Resets the fillstyle * Resets the fillstyle
* *
* @access private * @access private
*/ */
function _reset() function _reset()
{ {
} }
} }
?> ?>

View File

@ -1,137 +1,137 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Fill * @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Array.php,v 1.8 2005/08/24 20:36:03 nosey Exp $ * @version CVS: $Id: Array.php,v 1.8 2005/08/24 20:36:03 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/Fill.php * Include file Image/Graph/Fill.php
*/ */
require_once 'Image/Graph/Fill.php'; require_once 'Image/Graph/Fill.php';
/** /**
* A sequential array of fillstyles. * A sequential array of fillstyles.
* *
* This is used for filling multiple objects within the same element with * This is used for filling multiple objects within the same element with
* different styles. This is done by adding multiple fillstyles to a FillArrray * different styles. This is done by adding multiple fillstyles to a FillArrray
* structure. The fillarray will then when requested return the 'next' fillstyle * structure. The fillarray will then when requested return the 'next' fillstyle
* in sequential order. It is possible to specify ID tags to each fillstyle, * in sequential order. It is possible to specify ID tags to each fillstyle,
* which is used to make sure some data uses a specific fillstyle (i.e. in a * which is used to make sure some data uses a specific fillstyle (i.e. in a
* multiple-/stackedbarchart you name the {@link Image_Graph_Dataset}s and uses * multiple-/stackedbarchart you name the {@link Image_Graph_Dataset}s and uses
* this name as ID tag when adding the dataset's associated fillstyle to the * this name as ID tag when adding the dataset's associated fillstyle to the
* fillarray. * fillarray.
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Fill * @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_Fill_Array extends Image_Graph_Fill class Image_Graph_Fill_Array extends Image_Graph_Fill
{ {
/** /**
* The fill array * The fill array
* @var array * @var array
* @access private * @access private
*/ */
var $_fillStyles = array (); var $_fillStyles = array ();
/** /**
* Resets the fillstyle * Resets the fillstyle
* *
* @access private * @access private
*/ */
function _reset() function _reset()
{ {
reset($this->_fillStyles); reset($this->_fillStyles);
} }
/** /**
* Add a fill style to the array * Add a fill style to the array
* *
* @param Image_Graph_Fill $style The style to add * @param Image_Graph_Fill $style The style to add
* @param string $id The id or name of the style * @param string $id The id or name of the style
*/ */
function &add(& $style, $id = '') function &add(& $style, $id = '')
{ {
if ($id == '') { if ($id == '') {
$this->_fillStyles[] =& $style; $this->_fillStyles[] =& $style;
} else { } else {
$this->_fillStyles[$id] =& $style; $this->_fillStyles[$id] =& $style;
} }
reset($this->_fillStyles); reset($this->_fillStyles);
return $style; return $style;
} }
/** /**
* Add a color to the array * Add a color to the array
* *
* @param int $color The color * @param int $color The color
* @param string $id The id or name of the color * @param string $id The id or name of the color
*/ */
function addColor($color, $id = false) function addColor($color, $id = false)
{ {
if ($id !== false) { if ($id !== false) {
$this->_fillStyles[$id] = $color; $this->_fillStyles[$id] = $color;
} else { } else {
$this->_fillStyles[] = $color; $this->_fillStyles[] = $color;
} }
reset($this->_fillStyles); reset($this->_fillStyles);
} }
/** /**
* Return the fillstyle * Return the fillstyle
* *
* @return int A GD fillstyle * @return int A GD fillstyle
* @access private * @access private
*/ */
function _getFillStyle($ID = false) function _getFillStyle($ID = false)
{ {
if (($ID === false) || (!isset($this->_fillStyles[$ID]))) { if (($ID === false) || (!isset($this->_fillStyles[$ID]))) {
$ID = key($this->_fillStyles); $ID = key($this->_fillStyles);
if (!next($this->_fillStyles)) { if (!next($this->_fillStyles)) {
reset($this->_fillStyles); reset($this->_fillStyles);
} }
} }
$fillStyle =& $this->_fillStyles[$ID]; $fillStyle =& $this->_fillStyles[$ID];
if (is_object($fillStyle)) { if (is_object($fillStyle)) {
return $fillStyle->_getFillStyle($ID); return $fillStyle->_getFillStyle($ID);
} elseif ($fillStyle !== null) { } elseif ($fillStyle !== null) {
return $fillStyle; return $fillStyle;
} else { } else {
return parent::_getFillStyle($ID); return parent::_getFillStyle($ID);
} }
} }
} }
?> ?>

View File

@ -1,149 +1,149 @@
<?php <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/** /**
* Image_Graph - PEAR PHP OO Graph Rendering Utility. * Image_Graph - PEAR PHP OO Graph Rendering Utility.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* LICENSE: This library is free software; you can redistribute it and/or modify * LICENSE: This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your * the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version. This library is distributed in the hope that it * option) any later version. This library is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of * General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write * the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA * 02111-1307 USA
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Fill * @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Gradient.php,v 1.15 2005/08/24 20:36:03 nosey Exp $ * @version CVS: $Id: Gradient.php,v 1.15 2005/08/24 20:36:03 nosey Exp $
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
/** /**
* Include file Image/Graph/Fill/Image.php * Include file Image/Graph/Fill/Image.php
*/ */
require_once 'Image/Graph/Fill/Image.php'; require_once 'Image/Graph/Fill/Image.php';
/** /**
* Fill using a gradient color. * Fill using a gradient color.
* This creates a scaled fillstyle with colors flowing gradiently between 2 * This creates a scaled fillstyle with colors flowing gradiently between 2
* specified RGB values. Several directions are supported: * specified RGB values. Several directions are supported:
* *
* 1 Vertically (IMAGE_GRAPH_GRAD_VERTICAL) * 1 Vertically (IMAGE_GRAPH_GRAD_VERTICAL)
* *
* 2 Horizontally (IMAGE_GRAPH_GRAD_HORIZONTAL) * 2 Horizontally (IMAGE_GRAPH_GRAD_HORIZONTAL)
* *
* 3 Mirrored vertically (the color grades from a- b-a vertically) * 3 Mirrored vertically (the color grades from a- b-a vertically)
* (IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED) * (IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED)
* *
* 4 Mirrored horizontally (the color grades from a-b-a horizontally) * 4 Mirrored horizontally (the color grades from a-b-a horizontally)
* IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED * IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED
* *
* 5 Diagonally from top-left to right-bottom * 5 Diagonally from top-left to right-bottom
* (IMAGE_GRAPH_GRAD_DIAGONALLY_TL_BR) * (IMAGE_GRAPH_GRAD_DIAGONALLY_TL_BR)
* *
* 6 Diagonally from bottom-left to top-right * 6 Diagonally from bottom-left to top-right
* (IMAGE_GRAPH_GRAD_DIAGONALLY_BL_TR) * (IMAGE_GRAPH_GRAD_DIAGONALLY_BL_TR)
* *
* 7 Radially (concentric circles in the center) (IMAGE_GRAPH_GRAD_RADIAL) * 7 Radially (concentric circles in the center) (IMAGE_GRAPH_GRAD_RADIAL)
* *
* @category Images * @category Images
* @package Image_Graph * @package Image_Graph
* @subpackage Fill * @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk> * @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@ * @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph * @link http://pear.php.net/package/Image_Graph
*/ */
class Image_Graph_Fill_Gradient extends Image_Graph_Fill //Image_Graph_Fill_Image class Image_Graph_Fill_Gradient extends Image_Graph_Fill //Image_Graph_Fill_Image
{ {
/** /**
* The direction of the gradient * The direction of the gradient
* @var int * @var int
* @access private * @access private
*/ */
var $_direction; var $_direction;
/** /**
* The first color to gradient * The first color to gradient
* @var mixed * @var mixed
* @access private * @access private
*/ */
var $_startColor; var $_startColor;
/** /**
* The last color to gradient * The last color to gradient
* @var mixed * @var mixed
* @access private * @access private
*/ */
var $_endColor; var $_endColor;
/** /**
* Image_Graph_GradientFill [Constructor] * Image_Graph_GradientFill [Constructor]
* *
* @param int $direction The direction of the gradient * @param int $direction The direction of the gradient
* @param mixed $startColor The value of the starting color * @param mixed $startColor The value of the starting color
* @param mixed $endColor The value of the ending color * @param mixed $endColor The value of the ending color
*/ */
function Image_Graph_Fill_Gradient($direction, $startColor, $endColor) function Image_Graph_Fill_Gradient($direction, $startColor, $endColor)
{ {
parent::Image_Graph_Fill(); parent::Image_Graph_Fill();
$this->_direction = $direction; $this->_direction = $direction;
$this->_startColor = $startColor; $this->_startColor = $startColor;
$this->_endColor = $endColor; $this->_endColor = $endColor;
} }
/** /**
* Return the fillstyle * Return the fillstyle
* *
* @return int A GD fillstyle * @return int A GD fillstyle
* @access private * @access private
*/ */
function _getFillStyle($ID = false) function _getFillStyle($ID = false)
{ {
switch ($this->_direction) { switch ($this->_direction) {
case IMAGE_GRAPH_GRAD_HORIZONTAL: case IMAGE_GRAPH_GRAD_HORIZONTAL:
$direction = 'horizontal'; $direction = 'horizontal';
break; break;
case IMAGE_GRAPH_GRAD_VERTICAL: case IMAGE_GRAPH_GRAD_VERTICAL:
$direction = 'vertical'; $direction = 'vertical';
break; break;
case IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED: case IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED:
$direction = 'horizontal_mirror'; $direction = 'horizontal_mirror';
break; break;
case IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED: case IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED:
$direction = 'vertical_mirror'; $direction = 'vertical_mirror';
break; break;
case IMAGE_GRAPH_GRAD_DIAGONALLY_TL_BR: case IMAGE_GRAPH_GRAD_DIAGONALLY_TL_BR:
$direction = 'diagonal_tl_br'; $direction = 'diagonal_tl_br';
break; break;
case IMAGE_GRAPH_GRAD_DIAGONALLY_BL_TR: case IMAGE_GRAPH_GRAD_DIAGONALLY_BL_TR:
$direction = 'diagonal_bl_tr'; $direction = 'diagonal_bl_tr';
break; break;
case IMAGE_GRAPH_GRAD_RADIAL: case IMAGE_GRAPH_GRAD_RADIAL:
$direction = 'radial'; $direction = 'radial';
break; break;
} }
return array( return array(
'type' => 'gradient', 'type' => 'gradient',
'start' => $this->_startColor, 'start' => $this->_startColor,
'end' => $this->_endColor, 'end' => $this->_endColor,
'direction' => $direction 'direction' => $direction
); );
} }
} }
?> ?>

Some files were not shown because too many files have changed in this diff Show More