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
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | 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 |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.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. |
// +----------------------------------------------------------------------+
// | Author: Stefan Neufeind <pear.neufeind@speedpartner.de> |
// +----------------------------------------------------------------------+
//
// $Id: Color.php,v 1.3 2005/09/14 17:25:46 nosey Exp $
/**
* Class for color-handling
*
* @author Stefan Neufeind <pear.neufeind@speedpartner.de>
* @package Image_Canvas
* @category images
* @license The PHP License, version 2.02
*/
/**
* Color class to be extended; from package PEAR::Image_Color
*/
require_once 'Image/Color.php';
/**
* Class for color-handling
*
* 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.
*
* @author Stefan Neufeind <pear.neufeind@speedpartner.de>
* @package Image_Canvas
* @access public
*/
class Image_Canvas_Color extends Image_Color
{
/**
* Allocates a color in the given image.
*
* Userdefined color specifications get translated into
* an array of rgb values.
*
* @param resource GD-resource
* @param mixed any color representation supported by color2RGB()
* @return resource Image color handle
* @see color2RGB()
* @access public
* @static
*/
function allocateColor(&$img, $color)
{
$color = Image_Canvas_Color::color2RGB($color);
if (($color[3] == 255) || (!function_exists("imagecolorallocatealpha"))) {
return imagecolorallocate($img, $color[0], $color[1], $color[2]);
} else {
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).
*
* Userdefined color specifications get translated into
* an array of rgb values.
*
* @param mixed any color representation supported by Image_Canvas_Color::color2RGB()
* @return array Array of 4 ints (RGBA-representation)
* @access public
* @static
*/
function color2RGB($color)
{
if (is_array($color)) {
if (!is_numeric($color[0])) {
return null; // error
}
if (count($color) == 3) { // assume RGB-color
// 255 = alpha-value; full opaque
return array((int) $color[0],
(int) $color[1],
(int) $color[2],
255);
}
if (count($color) == 4) { // assume RGBA-color
// 255 = alpha-value; full opaque
return array((int) $color[0],
(int) $color[1],
(int) $color[2],
(int) $color[3]);
}
return null; // error
} elseif (is_string($color)) {
$alphaPos = strpos($color, '@');
if ($alphaPos === false) {
$alpha = 255;
} else {
$alphaFloat = (float) substr($color, $alphaPos+1);
// restrict to range 0..1
$alphaFloat = max(min($alphaFloat, 1), 0);
$alpha = (int) round((float) 255 * $alphaFloat);
$color = substr($color, 0, $alphaPos);
}
if ($color[0] == '#') { // hex-color given, e.g. #FFB4B4
$tempColor = parent::hex2rgb($color);
return array((int) $tempColor[0],
(int) $tempColor[1],
(int) $tempColor[2],
$alpha);
}
if (strpos($color,'%') !== false) {
$tempColor = parent::percentageColor2RGB($color);
return array((int) $tempColor[0],
(int) $tempColor[1],
(int) $tempColor[2],
$alpha);
} else {
$tempColor = parent::namedColor2RGB($color);
return array((int) $tempColor[0],
(int) $tempColor[1],
(int) $tempColor[2],
$alpha);
}
} else {
return null; // error
}
}
/**
* getRange
* Given a degree, you can get the range of colors between one color and
* another color.
*
* @access public
* @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.
*/
function getRange ($degrees)
{
$tempColors = parent::getRange($degrees);
// now add alpha-channel information
$steps = count($tempColors);
for($counter=0;$counter<$steps;$counter++) {
$tempColors[$counter] = parent::hex2rgb($tempColors[$counter]);
unset($tempColors[$counter]['hex']);
$tempColors[$counter][3] = (int) round(
(((float) $this->color1[3]*($steps-$counter))+
((float) $this->color2[3]*($counter))
) / $steps
);
}
return $tempColors;
}
/**
* Internal method to correctly set the colors.
*
* @param mixed color 1
* @param mixed color 2
* @access private
*/
function _setColors ( $col1, $col2 )
{
$this->color1 = Image_Canvas_Color::color2RGB($col1);
$this->color2 = Image_Canvas_Color::color2RGB($col2);
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | 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 |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.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. |
// +----------------------------------------------------------------------+
// | Author: Stefan Neufeind <pear.neufeind@speedpartner.de> |
// +----------------------------------------------------------------------+
//
// $Id: Color.php,v 1.3 2005/09/14 17:25:46 nosey Exp $
/**
* Class for color-handling
*
* @author Stefan Neufeind <pear.neufeind@speedpartner.de>
* @package Image_Canvas
* @category images
* @license The PHP License, version 2.02
*/
/**
* Color class to be extended; from package PEAR::Image_Color
*/
require_once 'Image/Color.php';
/**
* Class for color-handling
*
* 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.
*
* @author Stefan Neufeind <pear.neufeind@speedpartner.de>
* @package Image_Canvas
* @access public
*/
class Image_Canvas_Color extends Image_Color
{
/**
* Allocates a color in the given image.
*
* Userdefined color specifications get translated into
* an array of rgb values.
*
* @param resource GD-resource
* @param mixed any color representation supported by color2RGB()
* @return resource Image color handle
* @see color2RGB()
* @access public
* @static
*/
function allocateColor(&$img, $color)
{
$color = Image_Canvas_Color::color2RGB($color);
if (($color[3] == 255) || (!function_exists("imagecolorallocatealpha"))) {
return imagecolorallocate($img, $color[0], $color[1], $color[2]);
} else {
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).
*
* Userdefined color specifications get translated into
* an array of rgb values.
*
* @param mixed any color representation supported by Image_Canvas_Color::color2RGB()
* @return array Array of 4 ints (RGBA-representation)
* @access public
* @static
*/
function color2RGB($color)
{
if (is_array($color)) {
if (!is_numeric($color[0])) {
return null; // error
}
if (count($color) == 3) { // assume RGB-color
// 255 = alpha-value; full opaque
return array((int) $color[0],
(int) $color[1],
(int) $color[2],
255);
}
if (count($color) == 4) { // assume RGBA-color
// 255 = alpha-value; full opaque
return array((int) $color[0],
(int) $color[1],
(int) $color[2],
(int) $color[3]);
}
return null; // error
} elseif (is_string($color)) {
$alphaPos = strpos($color, '@');
if ($alphaPos === false) {
$alpha = 255;
} else {
$alphaFloat = (float) substr($color, $alphaPos+1);
// restrict to range 0..1
$alphaFloat = max(min($alphaFloat, 1), 0);
$alpha = (int) round((float) 255 * $alphaFloat);
$color = substr($color, 0, $alphaPos);
}
if ($color[0] == '#') { // hex-color given, e.g. #FFB4B4
$tempColor = parent::hex2rgb($color);
return array((int) $tempColor[0],
(int) $tempColor[1],
(int) $tempColor[2],
$alpha);
}
if (strpos($color,'%') !== false) {
$tempColor = parent::percentageColor2RGB($color);
return array((int) $tempColor[0],
(int) $tempColor[1],
(int) $tempColor[2],
$alpha);
} else {
$tempColor = parent::namedColor2RGB($color);
return array((int) $tempColor[0],
(int) $tempColor[1],
(int) $tempColor[2],
$alpha);
}
} else {
return null; // error
}
}
/**
* getRange
* Given a degree, you can get the range of colors between one color and
* another color.
*
* @access public
* @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.
*/
function getRange ($degrees)
{
$tempColors = parent::getRange($degrees);
// now add alpha-channel information
$steps = count($tempColors);
for($counter=0;$counter<$steps;$counter++) {
$tempColors[$counter] = parent::hex2rgb($tempColors[$counter]);
unset($tempColors[$counter]['hex']);
$tempColors[$counter][3] = (int) round(
(((float) $this->color1[3]*($steps-$counter))+
((float) $this->color2[3]*($counter))
) / $steps
);
}
return $tempColors;
}
/**
* Internal method to correctly set the colors.
*
* @param mixed color 1
* @param mixed color 2
* @access private
*/
function _setColors ( $col1, $col2 )
{
$this->color1 = Image_Canvas_Color::color2RGB($col1);
$this->color2 = Image_Canvas_Color::color2RGB($col2);
}
}
?>

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -1,119 +1,119 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Canvas class to handle JPEG format.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* Include file Image/Canvas/GD.php
*/
require_once 'Image/Canvas/GD.php';
/**
* JPEG Canvas class.
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
class Image_Canvas_GD_JPG extends Image_Canvas_GD
{
/**
* The JPEG quality
* @var int
* @access private
*/
var $_quality = 75;
/**
* Create the JPEG canvas
*
* Additional parameters other than those available for common {@link
* Image_Graph_Canvas_GD} class are:
*
* 'quality' The JPEG quality in as a percentage value from 0 (lowest
* quality, smallest file) to 100 (highest quality, biggest file)
*
* @param array $param Parameter array
*/
function Image_Canvas_GD_JPG($param)
{
parent::Image_Canvas_GD($param);
if (isset($param['quality'])) {
$this->_quality = max(0, min(100, $param['quality']));
}
$this->rectangle(
array(
'x0' => $this->_left,
'y0' => $this->_top,
'x1' => $this->_left + $this->_width - 1,
'y1' => $this->_top + $this->_height - 1,
'fill' => 'white',
'line' => 'transparent'
)
);
}
/**
* Output the result of the canvas
*
* @param array $param Parameter array
* @abstract
*/
function show($param = false)
{
parent::show($param);
header('Content-type: image/jpg');
header('Content-Disposition: inline; filename = \"'. basename($_SERVER['PHP_SELF'], '.php') . '.jpg\"');
ImageJPEG($this->_canvas, '', $this->_quality);
ImageDestroy($this->_canvas);
}
/**
* Output the result of the canvas
*
* @param array $param Parameter array
* @abstract
*/
function save($param = false)
{
parent::save($param);
ImageJPEG($this->_canvas, $param['filename'], $this->_quality);
ImageDestroy($this->_canvas);
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Canvas class to handle JPEG format.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* Include file Image/Canvas/GD.php
*/
require_once 'Image/Canvas/GD.php';
/**
* JPEG Canvas class.
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
class Image_Canvas_GD_JPG extends Image_Canvas_GD
{
/**
* The JPEG quality
* @var int
* @access private
*/
var $_quality = 75;
/**
* Create the JPEG canvas
*
* Additional parameters other than those available for common {@link
* Image_Graph_Canvas_GD} class are:
*
* 'quality' The JPEG quality in as a percentage value from 0 (lowest
* quality, smallest file) to 100 (highest quality, biggest file)
*
* @param array $param Parameter array
*/
function Image_Canvas_GD_JPG($param)
{
parent::Image_Canvas_GD($param);
if (isset($param['quality'])) {
$this->_quality = max(0, min(100, $param['quality']));
}
$this->rectangle(
array(
'x0' => $this->_left,
'y0' => $this->_top,
'x1' => $this->_left + $this->_width - 1,
'y1' => $this->_top + $this->_height - 1,
'fill' => 'white',
'line' => 'transparent'
)
);
}
/**
* Output the result of the canvas
*
* @param array $param Parameter array
* @abstract
*/
function show($param = false)
{
parent::show($param);
header('Content-type: image/jpg');
header('Content-Disposition: inline; filename = \"'. basename($_SERVER['PHP_SELF'], '.php') . '.jpg\"');
ImageJPEG($this->_canvas, '', $this->_quality);
ImageDestroy($this->_canvas);
}
/**
* Output the result of the canvas
*
* @param array $param Parameter array
* @abstract
*/
function save($param = false)
{
parent::save($param);
ImageJPEG($this->_canvas, $param['filename'], $this->_quality);
ImageDestroy($this->_canvas);
}
}
?>

View File

@ -1,125 +1,125 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Canvas class to handle PNG format.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* Include file Image/Canvas/GD.php
*/
require_once 'Image/Canvas/GD.php';
/**
* PNG Canvas class.
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
class Image_Canvas_GD_PNG extends Image_Canvas_GD
{
/**
* Create the PNG canvas
*
* @param array $param Parameter array
*/
function Image_Canvas_GD_PNG($param)
{
parent::Image_Canvas_GD($param);
if ((isset($param['transparent'])) && ($param['transparent']) &&
($this->_gd2)
) {
if ($param['transparent'] === true) {
$transparent = '#123ABD';
} else {
$transparent = $param['transparent'];
}
$color = $this->_color($transparent);
$trans = ImageColorTransparent($this->_canvas, $color);
$this->rectangle(
array(
'x0' => $this->_left,
'y0' => $this->_top,
'x1' => $this->_left + $this->_width - 1,
'y1' => $this->_top + $this->_height - 1,
'fill' => 'opague',
'line' => 'transparent'
)
);
} else {
$this->rectangle(
array(
'x0' => $this->_left,
'y0' => $this->_top,
'x1' => $this->_left + $this->_width - 1,
'y1' => $this->_top + $this->_height - 1,
'fill' => 'white',
'line' => 'transparent'
)
);
}
}
/**
* Output the result of the canvas
*
* @param array $param Parameter array
* @abstract
*/
function show($param = false)
{
parent::show($param);
header('Content-type: image/png');
header('Content-Disposition: inline; filename = \"'. basename($_SERVER['PHP_SELF'], '.php') . '.png\"');
ImagePNG($this->_canvas);
ImageDestroy($this->_canvas);
}
/**
* Output the result of the canvas
*
* @param array $param Parameter array
* @abstract
*/
function save($param = false)
{
parent::save($param);
ImagePNG($this->_canvas, $param['filename']);
ImageDestroy($this->_canvas);
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Canvas class to handle PNG format.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* Include file Image/Canvas/GD.php
*/
require_once 'Image/Canvas/GD.php';
/**
* PNG Canvas class.
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
class Image_Canvas_GD_PNG extends Image_Canvas_GD
{
/**
* Create the PNG canvas
*
* @param array $param Parameter array
*/
function Image_Canvas_GD_PNG($param)
{
parent::Image_Canvas_GD($param);
if ((isset($param['transparent'])) && ($param['transparent']) &&
($this->_gd2)
) {
if ($param['transparent'] === true) {
$transparent = '#123ABD';
} else {
$transparent = $param['transparent'];
}
$color = $this->_color($transparent);
$trans = ImageColorTransparent($this->_canvas, $color);
$this->rectangle(
array(
'x0' => $this->_left,
'y0' => $this->_top,
'x1' => $this->_left + $this->_width - 1,
'y1' => $this->_top + $this->_height - 1,
'fill' => 'opague',
'line' => 'transparent'
)
);
} else {
$this->rectangle(
array(
'x0' => $this->_left,
'y0' => $this->_top,
'x1' => $this->_left + $this->_width - 1,
'y1' => $this->_top + $this->_height - 1,
'fill' => 'white',
'line' => 'transparent'
)
);
}
}
/**
* Output the result of the canvas
*
* @param array $param Parameter array
* @abstract
*/
function show($param = false)
{
parent::show($param);
header('Content-type: image/png');
header('Content-Disposition: inline; filename = \"'. basename($_SERVER['PHP_SELF'], '.php') . '.png\"');
ImagePNG($this->_canvas);
ImageDestroy($this->_canvas);
}
/**
* Output the result of the canvas
*
* @param array $param Parameter array
* @abstract
*/
function save($param = false)
{
parent::save($param);
ImagePNG($this->_canvas, $param['filename']);
ImageDestroy($this->_canvas);
}
}
?>

View File

@ -1,354 +1,354 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Class for handling output as a HTML imagemap
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* Class for handling output as a HTML imagemap
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
* @since version 0.2.0
*/
class Image_Canvas_ImageMap extends Image_Canvas
{
/**
* The image map (if any)
* @var array
* @access private
*/
var $_map = array();
/**
* Add a map tag
* @param string $shape The shape, either rect, circle or polygon
* @param string $coords The list of coordinates for the shape
* @param array $params Parameter array
*/
function _addMapTag($shape, $coords, $params)
{
if (isset($params['url'])) {
$url = $params['url'];
$target = (isset($params['target']) ? $params['target'] : false);
$alt = (isset($params['alt']) ? $params['alt'] : false);
$tags = '';
if (isset($params['htmltags'])) {
foreach ($params['htmltags'] as $key => $value) {
$tags .= ' ';
if (strpos($value, '"') >= 0) {
$tags .= $key . '=\'' . $value . '\'';
} else {
$tags .= $key . '="' . $value . '"';
}
}
}
$this->_map[] =
'<area shape="' . $shape . '" coords="' . $coords . '" href="' . $url . '"' .
($target ? ' target="' . $target . '"' : '') .
($alt ? ' alt="' . $alt . '"' : '') .
(isset($params['id']) ? ' id="' . $params['id'] . '"' : '') .
$tags .
'>';
}
}
/**
* Draw a line
*
* Parameter array:
* 'x0': int X start point
* 'y0': int Y start point
* 'x1': int X end point
* 'y1': int Y end point
* 'color': mixed [optional] The line color
* 'mapsize': int [optional] The size of the image map (surrounding the line)
* @param array $params Parameter array
*/
function line($params)
{
if (isset($params['url'])) {
$mapsize = (isset($params['mapsize']) ? $params['mapsize'] : 2);
$this->_addMapTag(
'polygon',
$this->_getX($params['x0'] - $mapsize) . ',' .
$this->_getY($params['y0'] - $mapsize) . ',' .
$this->_getX($params['x1'] + $mapsize) . ',' .
$this->_getY($params['y1'] - $mapsize) . ',' .
$this->_getX($params['x1'] + $mapsize) . ',' .
$this->_getY($params['y1'] + $mapsize) . ',' .
$this->_getX($params['x0'] - $mapsize) . ',' .
$this->_getY($params['y0'] + $mapsize),
$params
);
}
parent::line($params);
}
/**
* Draws a polygon
*
* Parameter array:
* 'connect': bool [optional] Specifies whether the start point should be
* connected to the endpoint (closed polygon) or not (connected line)
* 'fill': mixed [optional] The fill 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
* '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)
* '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
*/
function polygon($params)
{
if ((isset($params['map_vertices'])) && ($params['map_vertices'] === true)) {
$mapsize = (isset($params['mapsize']) ? $params['mapsize'] : 2);
foreach ($this->_polygon as $point) {
$vertex_param = $params;
if (isset($point['url'])) {
$vertex_param['url'] = $point['url'];
}
if (isset($point['target'])) {
$vertex_param['target'] = $point['target'];
}
if (isset($point['alt'])) {
$vertex_param['alt'] = $point['alt'];
}
$vertex_mapsize = $mapsize;
if (isset($point['mapsize'])) {
$vertex_mapsize = $point['mapsize'];
}
if (isset($point['htmltags'])) {
$vertex_param['htmltags'] = $point['htmltags'];
}
$this->_addMapTag(
'circle',
$this->_getX($point['X']) . ',' .
$this->_getY($point['Y']) . ',' .
$mapsize,
$vertex_param
);
}
}
else if (isset($params['url'])) {
$points = '';
foreach ($this->_polygon as $point) {
if ($points != '') {
$points .= ',';
}
$points .= $this->_getX($point['X']) . ',' . $this->_getY($point['Y']);
}
$this->_addMapTag('polygon', $points, $params);
}
parent::polygon($params);
}
/**
* Draw a rectangle
*
* Parameter array:
* 'x0': int X start point
* 'y0': int Y start point
* 'x1': int X end point
* 'y1': int Y end point
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function rectangle($params)
{
if (isset($params['url'])) {
$this->_addMapTag(
'rect',
$this->_getX($params['x0']) . ',' .
$this->_getY($params['y0']) . ',' .
$this->_getX($params['x1']) . ',' .
$this->_getY($params['y1']),
$params
);
}
parent::rectangle($params);
}
/**
* Draw an ellipse
*
* Parameter array:
* 'x': int X center point
* 'y': int Y center point
* 'rx': int X radius
* 'ry': int Y radius
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function ellipse($params)
{
if (isset($params['url'])) {
if ($params['rx'] == $params['ry']) {
$this->_addMapTag(
'circle',
$this->_getX($params['x']) . ',' .
$this->_getY($params['y']) . ',' .
$this->_getX($params['rx']),
$params
);
} else {
$points = '';
for ($v = 0; $v <= 360; $v += 30) {
if ($points != '') {
$points .= ',';
}
$points .=
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)));
}
$this->_addMapTag(
'polygon',
$points,
$params
);
}
}
parent::ellipse($params);
}
/**
* Draw a pie slice
*
* Parameter array:
* 'x': int X center point
* 'y': int Y center point
* 'rx': int X radius
* 'ry': int Y radius
* 'v1': int The starting 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)
* 'sry': int [optional] Starting Y-radius of the pie slice (i.e. for a doughnut)
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function pieslice($params)
{
if (isset($params['url'])) {
$x = $this->_getX($params['x']);
$y = $this->_getY($params['y']);
$rx = $params['rx'];
$ry = $params['ry'];
$v1a = $params['v1'];
$v2a = $params['v2'];
$v1 = min($v1a, $v2a);
$v2 = max($v1a, $v2a);
$srx = (isset($params['srx']) ? $params['srx'] : 0);
$sry = (isset($params['sry']) ? $params['sry'] : 0);
$points =
round(($x + $srx * cos(deg2rad($v1 % 360)))) . ',' .
round(($y + $sry * sin(deg2rad($v1 % 360)))) . ',';
for ($v = $v1; $v < $v2; $v += 30) {
$points .=
round(($x + $rx * cos(deg2rad($v % 360)))) . ',' .
round(($y + $ry * sin(deg2rad($v % 360)))) . ',';
}
$points .=
round(($x + $rx * cos(deg2rad($v2 % 360)))) . ',' .
round(($y + $ry * sin(deg2rad($v2 % 360))));
if (($srx != 0) || ($sry != 0)) {
$points .= ',';
for ($v = $v2; $v > $v1; $v -= 30) {
$points .=
round(($x + $srx * cos(deg2rad($v % 360)))) . ',' .
round(($y + $sry * sin(deg2rad($v % 360)))) . ',';
}
}
$this->_addMapTag('polygon', $points, $params);
}
parent::pieslice($params);
}
/**
* Output the result of the canvas to the browser
*
* @param array $params Parameter array, the contents and meaning depends on the actual Canvas
* @abstract
*/
function show($params = false)
{
parent::show($params);
if (count($this->_map) > 0) {
print $this->toHtml($params);
}
}
/**
* Save the result of the canvas to a file
*
* Parameter array:
* 'filename': string The file to output to
* @param array $params Parameter array, the contents and meaning depends on the actual Canvas
* @abstract
*/
function save($params = false)
{
parent::save($params);
$file = fopen($param['filename'], 'w+');
fwrite($file, $this->toHtml($params));
fclose($file);
}
/**
* Get a canvas specific HTML tag.
*
* Parameter array:
* 'name': string The name of the image map
*/
function toHtml($params)
{
if (count($this->_map) > 0) {
return '<map name="' . $params['name'] . '">' . "\n\t" . implode($this->_map, "\n\t") . "\n</map>";
}
return '';
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Class for handling output as a HTML imagemap
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @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
*/
/**
* Class for handling output as a HTML imagemap
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
* @since version 0.2.0
*/
class Image_Canvas_ImageMap extends Image_Canvas
{
/**
* The image map (if any)
* @var array
* @access private
*/
var $_map = array();
/**
* Add a map tag
* @param string $shape The shape, either rect, circle or polygon
* @param string $coords The list of coordinates for the shape
* @param array $params Parameter array
*/
function _addMapTag($shape, $coords, $params)
{
if (isset($params['url'])) {
$url = $params['url'];
$target = (isset($params['target']) ? $params['target'] : false);
$alt = (isset($params['alt']) ? $params['alt'] : false);
$tags = '';
if (isset($params['htmltags'])) {
foreach ($params['htmltags'] as $key => $value) {
$tags .= ' ';
if (strpos($value, '"') !== false) {
$tags .= $key . '=\'' . $value . '\'';
} else {
$tags .= $key . '="' . $value . '"';
}
}
}
$this->_map[] =
'<area shape="' . $shape . '" coords="' . $coords . '" href="' . $url . '"' .
($target ? ' target="' . $target . '"' : '') .
($alt ? ' alt="' . $alt . '"' : '') .
(isset($params['id']) ? ' id="' . $params['id'] . '"' : '') .
$tags .
'>';
}
}
/**
* Draw a line
*
* Parameter array:
* 'x0': int X start point
* 'y0': int Y start point
* 'x1': int X end point
* 'y1': int Y end point
* 'color': mixed [optional] The line color
* 'mapsize': int [optional] The size of the image map (surrounding the line)
* @param array $params Parameter array
*/
function line($params)
{
if (isset($params['url'])) {
$mapsize = (isset($params['mapsize']) ? $params['mapsize'] : 2);
$this->_addMapTag(
'polygon',
$this->_getX($params['x0'] - $mapsize) . ',' .
$this->_getY($params['y0'] - $mapsize) . ',' .
$this->_getX($params['x1'] + $mapsize) . ',' .
$this->_getY($params['y1'] - $mapsize) . ',' .
$this->_getX($params['x1'] + $mapsize) . ',' .
$this->_getY($params['y1'] + $mapsize) . ',' .
$this->_getX($params['x0'] - $mapsize) . ',' .
$this->_getY($params['y0'] + $mapsize),
$params
);
}
parent::line($params);
}
/**
* Draws a polygon
*
* Parameter array:
* 'connect': bool [optional] Specifies whether the start point should be
* connected to the endpoint (closed polygon) or not (connected line)
* 'fill': mixed [optional] The fill 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
* '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)
* '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
*/
function polygon($params)
{
if ((isset($params['map_vertices'])) && ($params['map_vertices'] === true)) {
$mapsize = (isset($params['mapsize']) ? $params['mapsize'] : 2);
foreach ($this->_polygon as $point) {
$vertex_param = $params;
if (isset($point['url'])) {
$vertex_param['url'] = $point['url'];
}
if (isset($point['target'])) {
$vertex_param['target'] = $point['target'];
}
if (isset($point['alt'])) {
$vertex_param['alt'] = $point['alt'];
}
$vertex_mapsize = $mapsize;
if (isset($point['mapsize'])) {
$vertex_mapsize = $point['mapsize'];
}
if (isset($point['htmltags'])) {
$vertex_param['htmltags'] = $point['htmltags'];
}
$this->_addMapTag(
'circle',
$this->_getX($point['X']) . ',' .
$this->_getY($point['Y']) . ',' .
$mapsize,
$vertex_param
);
}
}
else if (isset($params['url'])) {
$points = '';
foreach ($this->_polygon as $point) {
if ($points != '') {
$points .= ',';
}
$points .= $this->_getX($point['X']) . ',' . $this->_getY($point['Y']);
}
$this->_addMapTag('polygon', $points, $params);
}
parent::polygon($params);
}
/**
* Draw a rectangle
*
* Parameter array:
* 'x0': int X start point
* 'y0': int Y start point
* 'x1': int X end point
* 'y1': int Y end point
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function rectangle($params)
{
if (isset($params['url'])) {
$this->_addMapTag(
'rect',
$this->_getX($params['x0']) . ',' .
$this->_getY($params['y0']) . ',' .
$this->_getX($params['x1']) . ',' .
$this->_getY($params['y1']),
$params
);
}
parent::rectangle($params);
}
/**
* Draw an ellipse
*
* Parameter array:
* 'x': int X center point
* 'y': int Y center point
* 'rx': int X radius
* 'ry': int Y radius
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function ellipse($params)
{
if (isset($params['url'])) {
if ($params['rx'] == $params['ry']) {
$this->_addMapTag(
'circle',
$this->_getX($params['x']) . ',' .
$this->_getY($params['y']) . ',' .
$this->_getX($params['rx']),
$params
);
} else {
$points = '';
for ($v = 0; $v <= 360; $v += 30) {
if ($points != '') {
$points .= ',';
}
$points .=
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)));
}
$this->_addMapTag(
'polygon',
$points,
$params
);
}
}
parent::ellipse($params);
}
/**
* Draw a pie slice
*
* Parameter array:
* 'x': int X center point
* 'y': int Y center point
* 'rx': int X radius
* 'ry': int Y radius
* 'v1': int The starting 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)
* 'sry': int [optional] Starting Y-radius of the pie slice (i.e. for a doughnut)
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function pieslice($params)
{
if (isset($params['url'])) {
$x = $this->_getX($params['x']);
$y = $this->_getY($params['y']);
$rx = $params['rx'];
$ry = $params['ry'];
$v1a = $params['v1'];
$v2a = $params['v2'];
$v1 = min($v1a, $v2a);
$v2 = max($v1a, $v2a);
$srx = (isset($params['srx']) ? $params['srx'] : 0);
$sry = (isset($params['sry']) ? $params['sry'] : 0);
$points =
round(($x + $srx * cos(deg2rad($v1 % 360)))) . ',' .
round(($y + $sry * sin(deg2rad($v1 % 360)))) . ',';
for ($v = $v1; $v < $v2; $v += 30) {
$points .=
round(($x + $rx * cos(deg2rad($v % 360)))) . ',' .
round(($y + $ry * sin(deg2rad($v % 360)))) . ',';
}
$points .=
round(($x + $rx * cos(deg2rad($v2 % 360)))) . ',' .
round(($y + $ry * sin(deg2rad($v2 % 360))));
if (($srx != 0) || ($sry != 0)) {
$points .= ',';
for ($v = $v2; $v > $v1; $v -= 30) {
$points .=
round(($x + $srx * cos(deg2rad($v % 360)))) . ',' .
round(($y + $sry * sin(deg2rad($v % 360)))) . ',';
}
}
$this->_addMapTag('polygon', $points, $params);
}
parent::pieslice($params);
}
/**
* Output the result of the canvas to the browser
*
* @param array $params Parameter array, the contents and meaning depends on the actual Canvas
* @abstract
*/
function show($params = false)
{
parent::show($params);
if (count($this->_map) > 0) {
print $this->toHtml($params);
}
}
/**
* Save the result of the canvas to a file
*
* Parameter array:
* 'filename': string The file to output to
* @param array $params Parameter array, the contents and meaning depends on the actual Canvas
* @abstract
*/
function save($params = false)
{
parent::save($params);
$file = fopen($params['filename'], 'w+');
fwrite($file, $this->toHtml($params));
fclose($file);
}
/**
* Get a canvas specific HTML tag.
*
* Parameter array:
* 'name': string The name of the image map
*/
function toHtml($params)
{
if (count($this->_map) > 0) {
return '<map name="' . $params['name'] . '">' . "\n\t" . implode($this->_map, "\n\t") . "\n</map>";
}
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
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Canvas based creation of images to facilitate different output formats
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* This class contains a set of tool-functions.
*
* These functions are all to be called statically
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
* @abstract
*/
class Image_Canvas_Tool
{
/**
* 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
* '/Windows/Fonts/Cour.ttf')
*
* Font names are translated using the tab-separated file
* Image/Canvas/Tool/fontmap.txt.
*
* 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
* 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
* 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.
*
* @param string $name The name of the font
* @param string $type The needed file type of the font
* @return string The filename of the font
* @static
*/
function fontMap($name, $type = '.ttf')
{
static $_fontMap;
if (!is_array($_fontMap)) {
if (file_exists($fontmap = (dirname(__FILE__) . '/Fonts/fontmap.txt'))) {
$file = file($fontmap);
foreach($file as $fontmapping) {
list($fontname, $filenames) = explode(',', $fontmapping, 2);
$fontname = trim($fontname);
$filenames = trim($filenames);
$filenames = explode(',', $filenames);
foreach ($filenames as $filename) {
$type_pos = strrpos($filename, '.');
$type = substr($filename, $type_pos);
$_fontMap[$fontname][$type] = $filename;
}
}
}
}
$type = strtolower($type);
if ((isset($_fontMap[$name])) && (isset($_fontMap[$name][$type]))) {
$filename = $_fontMap[$name][$type];
} else {
$filename = $name;
}
if (substr($filename, -strlen($type)) !== $type) {
$filename .= $type;
}
$result = false;
if (file_exists($filename)) {
$result = $filename;
} elseif (file_exists($file = (IMAGE_CANVAS_SYSTEM_FONT_PATH . $filename))) {
$result = $file;
} elseif (file_exists($file = (dirname(__FILE__) . '/Fonts/' . $filename))) {
$result = $file;
} elseif (substr($name, 0, 1) !== '/') {
// leave it to the library to find the font
$result = $name;
}
return str_replace('\\', '/', $result);
}
/**
* Return the average of 2 points
*
* @param double P1 1st point
* @param double P2 2nd point
* @return double The average of P1 and P2
* @static
*/
function mid($p1, $p2)
{
return ($p1 + $p2) / 2;
}
/**
* Mirrors P1 in P2 by a amount of Factor
*
* @param double $p1 1st point, point to mirror
* @param double $o2 2nd point, mirror point
* @param double $factor Mirror factor, 0 returns $p2, 1 returns a pure
* mirror, ie $p1 on the exact other side of $p2
* @return double $p1 mirrored in $p2 by Factor
* @static
*/
function mirror($p1, $p2, $factor = 1)
{
return $p2 + $factor * ($p2 - $p1);
}
/**
* Calculates a Bezier control point, this function must be called for BOTH
* X and Y coordinates (will it work for 3D coordinates!?)
*
* @param double $p1 1st point
* @param double $p2 Point to
* @param double $factor Mirror factor, 0 returns P2, 1 returns a pure
* mirror, i.e. P1 on the exact other side of P2
* @return double P1 mirrored in P2 by Factor
* @static
*/
function controlPoint($p1, $p2, $factor, $smoothFactor = 0.75)
{
$sa = Image_Canvas_Tool::mirror($p1, $p2, $smoothFactor);
$sb = Image_Canvas_Tool::mid($p2, $sa);
$m = Image_Canvas_Tool::mid($p2, $factor);
$pC = Image_Canvas_Tool::mid($sb, $m);
return $pC;
}
/**
* Calculates a Bezier point, this function must be called for BOTH X and Y
* coordinates (will it work for 3D coordinates!?)
*
* @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 $p2 Point 1 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
* @return double The bezier value of the point t between $p2 and $p3 using
* $p1 and $p4 to calculate control points
* @static
*/
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
return pow(1 - $t, 3) * $p1 +
3 * pow(1 - $t, 2) * $t * $p2 +
3 * (1 - $t) * pow($t, 2) * $p3 +
pow($t, 3) * $p4;
}
/**
* Gets the angle / slope of a line relative to horizontal (left -> right)
*
* @param double $x0 The starting x point
* @param double $y0 The starting y point
* @param double $x1 The ending x point
* @param double $y1 The ending y point
* @param double The angle in degrees of the line
* @static
*/
function getAngle($x0, $y0, $x1, $y1)
{
$dx = ($x1 - $x0);
$dy = ($y1 - $y0);
$l = sqrt($dx * $dx + $dy * $dy);
$v = rad2deg(asin(($y0 - $y1) / $l));
if ($dx < 0) {
$v = 180 - $v;
}
return $v;
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Canvas based creation of images to facilitate different output formats
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* This class contains a set of tool-functions.
*
* These functions are all to be called statically
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
* @abstract
*/
class Image_Canvas_Tool
{
/**
* 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
* '/Windows/Fonts/Cour.ttf')
*
* Font names are translated using the tab-separated file
* Image/Canvas/Tool/fontmap.txt.
*
* 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
* 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
* 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.
*
* @param string $name The name of the font
* @param string $type The needed file type of the font
* @return string The filename of the font
* @static
*/
function fontMap($name, $type = '.ttf')
{
static $_fontMap;
if (!is_array($_fontMap)) {
if (file_exists($fontmap = (dirname(__FILE__) . '/Fonts/fontmap.txt'))) {
$file = file($fontmap);
foreach($file as $fontmapping) {
list($fontname, $filenames) = explode(',', $fontmapping, 2);
$fontname = trim($fontname);
$filenames = trim($filenames);
$filenames = explode(',', $filenames);
foreach ($filenames as $filename) {
$type_pos = strrpos($filename, '.');
$type = substr($filename, $type_pos);
$_fontMap[$fontname][$type] = $filename;
}
}
}
}
$type = strtolower($type);
if ((isset($_fontMap[$name])) && (isset($_fontMap[$name][$type]))) {
$filename = $_fontMap[$name][$type];
} else {
$filename = $name;
}
if (substr($filename, -strlen($type)) !== $type) {
$filename .= $type;
}
$result = false;
if (file_exists($filename)) {
$result = $filename;
} elseif (file_exists($file = (IMAGE_CANVAS_SYSTEM_FONT_PATH . $filename))) {
$result = $file;
} elseif (file_exists($file = (dirname(__FILE__) . '/Fonts/' . $filename))) {
$result = $file;
} elseif (substr($name, 0, 1) !== '/') {
// leave it to the library to find the font
$result = $name;
}
return str_replace('\\', '/', $result);
}
/**
* Return the average of 2 points
*
* @param double P1 1st point
* @param double P2 2nd point
* @return double The average of P1 and P2
* @static
*/
function mid($p1, $p2)
{
return ($p1 + $p2) / 2;
}
/**
* Mirrors P1 in P2 by a amount of Factor
*
* @param double $p1 1st point, point to mirror
* @param double $o2 2nd point, mirror point
* @param double $factor Mirror factor, 0 returns $p2, 1 returns a pure
* mirror, ie $p1 on the exact other side of $p2
* @return double $p1 mirrored in $p2 by Factor
* @static
*/
function mirror($p1, $p2, $factor = 1)
{
return $p2 + $factor * ($p2 - $p1);
}
/**
* Calculates a Bezier control point, this function must be called for BOTH
* X and Y coordinates (will it work for 3D coordinates!?)
*
* @param double $p1 1st point
* @param double $p2 Point to
* @param double $factor Mirror factor, 0 returns P2, 1 returns a pure
* mirror, i.e. P1 on the exact other side of P2
* @return double P1 mirrored in P2 by Factor
* @static
*/
function controlPoint($p1, $p2, $factor, $smoothFactor = 0.75)
{
$sa = Image_Canvas_Tool::mirror($p1, $p2, $smoothFactor);
$sb = Image_Canvas_Tool::mid($p2, $sa);
$m = Image_Canvas_Tool::mid($p2, $factor);
$pC = Image_Canvas_Tool::mid($sb, $m);
return $pC;
}
/**
* Calculates a Bezier point, this function must be called for BOTH X and Y
* coordinates (will it work for 3D coordinates!?)
*
* @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 $p2 Point 1 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
* @return double The bezier value of the point t between $p2 and $p3 using
* $p1 and $p4 to calculate control points
* @static
*/
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
return pow(1 - $t, 3) * $p1 +
3 * pow(1 - $t, 2) * $t * $p2 +
3 * (1 - $t) * pow($t, 2) * $p3 +
pow($t, 3) * $p4;
}
/**
* Gets the angle / slope of a line relative to horizontal (left -> right)
*
* @param double $x0 The starting x point
* @param double $y0 The starting y point
* @param double $x1 The ending x point
* @param double $y1 The ending y point
* @param double The angle in degrees of the line
* @static
*/
function getAngle($x0, $y0, $x1, $y1)
{
$dx = ($x1 - $x0);
$dy = ($y1 - $y0);
$l = sqrt($dx * $dx + $dy * $dy);
$v = rad2deg(asin(($y0 - $y1) / $l));
if ($dx < 0) {
$v = 180 - $v;
}
return $v;
}
}
?>

View File

@ -1,278 +1,278 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Canvas based creation of images to facilitate different output formats
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* Class for handling different output formats including a HTML image map
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
* @since version 0.2.0
* @abstract
*/
class Image_Canvas_WithMap extends Image_Canvas
{
/**
* The image map
* @var Image_Canvas_ImageMap
* @access private
*/
var $_imageMap = null;
/**
* Create the canvas.
*
* Parameters available:
*
* 'width' The width 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
*
* 'top' The top offset of the graph on the canvas
*
* 'usemap' Initialize an image map
*
* @param array $params Parameter array
* @abstract
*/
function Image_Canvas_WithMap($params)
{
parent::Image_Canvas($params);
if ((isset($params['usemap'])) && ($params['usemap'] === true)) {
$this->_imageMap =& Image_Canvas::factory(
'ImageMap',
array(
'left' => $this->_left,
'top' => $this->_top,
'width' => $this->_width,
'height' => $this->_height
)
);
}
}
/**
* Draw a line
*
* Parameter array:
* 'x0': int X start point
* 'y0': int Y start point
* 'x1': int X end point
* 'y1': int Y end point
* 'color': mixed [optional] The line color
* @param array $params Parameter array
*/
function line($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->line($params);
}
parent::line($params);
}
/**
* Adds vertex to a polygon
*
* Parameter array:
* 'x': int X point
* 'y': int Y point
* @param array $params Parameter array
*/
function addVertex($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->addVertex($params);
}
parent::addVertex($params);
}
/**
* Adds "splined" vertex to a polygon
*
* Parameter array:
* 'x': int X point
* 'y': int Y point
* 'p1x': X Control point 1
* 'p1y': Y Control point 1
* 'p2x': X Control point 2
* 'p2y': Y Control point 2
* @param array $params Parameter array
*/
function addSpline($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->addSpline($params);
}
parent::addSpline($params);
}
/**
* Draws a polygon
*
* Parameter array:
* 'connect': bool [optional] Specifies whether the start point should be
* connected to the endpoint (closed polygon) or not (connected line)
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function polygon($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->polygon($params);
}
parent::polygon($params);
}
/**
* Draw a rectangle
*
* Parameter array:
* 'x0': int X start point
* 'y0': int Y start point
* 'x1': int X end point
* 'y1': int Y end point
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function rectangle($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->rectangle($params);
}
parent::rectangle($params);
}
/**
* Draw an ellipse
*
* Parameter array:
* 'x': int X center point
* 'y': int Y center point
* 'rx': int X radius
* 'ry': int Y radius
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function ellipse($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->ellipse($params);
}
parent::ellipse($params);
}
/**
* Draw a pie slice
*
* Parameter array:
* 'x': int X center point
* 'y': int Y center point
* 'rx': int X radius
* 'ry': int Y radius
* 'v1': int The starting 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)
* 'sry': int [optional] Starting Y-radius of the pie slice (i.e. for a doughnut)
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function pieslice($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->pieslice($params);
}
parent::pieslice($params);
}
/**
* Writes text
*
* Parameter array:
* 'x': int X-point of text
* 'y': int Y-point of text
* 'text': string The text to add
* 'alignment': array [optional] Alignment
* 'color': mixed [optional] The color of the text
*/
function addText($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->addText($params);
}
parent::addText($params);
}
/**
* Overlay image
*
* Parameter array:
* 'x': int X-point of overlayed image
* 'y': int Y-point of overlayed image
* 'filename': string The filename of the image to overlay
* 'width': int [optional] The width of the overlayed image (resizing if possible)
* 'height': int [optional] The height of the overlayed image (resizing if possible)
* 'alignment': array [optional] Alignment
*/
function image($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->image($params);
}
parent::image($params);
}
/**
* Get the imagemap
* @return Image_Graph_ImageMap The image map (or false if none)
*/
function &getImageMap()
{
$result = null;
if (isset($this->_imageMap)) {
$result =& $this->_imageMap;
}
return $result;
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Canvas
*
* Canvas based creation of images to facilitate different output formats
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
/**
* Class for handling different output formats including a HTML image map
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
* @since version 0.2.0
* @abstract
*/
class Image_Canvas_WithMap extends Image_Canvas
{
/**
* The image map
* @var Image_Canvas_ImageMap
* @access private
*/
var $_imageMap = null;
/**
* Create the canvas.
*
* Parameters available:
*
* 'width' The width 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
*
* 'top' The top offset of the graph on the canvas
*
* 'usemap' Initialize an image map
*
* @param array $params Parameter array
* @abstract
*/
function Image_Canvas_WithMap($params)
{
parent::Image_Canvas($params);
if ((isset($params['usemap'])) && ($params['usemap'] === true)) {
$this->_imageMap =& Image_Canvas::factory(
'ImageMap',
array(
'left' => $this->_left,
'top' => $this->_top,
'width' => $this->_width,
'height' => $this->_height
)
);
}
}
/**
* Draw a line
*
* Parameter array:
* 'x0': int X start point
* 'y0': int Y start point
* 'x1': int X end point
* 'y1': int Y end point
* 'color': mixed [optional] The line color
* @param array $params Parameter array
*/
function line($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->line($params);
}
parent::line($params);
}
/**
* Adds vertex to a polygon
*
* Parameter array:
* 'x': int X point
* 'y': int Y point
* @param array $params Parameter array
*/
function addVertex($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->addVertex($params);
}
parent::addVertex($params);
}
/**
* Adds "splined" vertex to a polygon
*
* Parameter array:
* 'x': int X point
* 'y': int Y point
* 'p1x': X Control point 1
* 'p1y': Y Control point 1
* 'p2x': X Control point 2
* 'p2y': Y Control point 2
* @param array $params Parameter array
*/
function addSpline($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->addSpline($params);
}
parent::addSpline($params);
}
/**
* Draws a polygon
*
* Parameter array:
* 'connect': bool [optional] Specifies whether the start point should be
* connected to the endpoint (closed polygon) or not (connected line)
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function polygon($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->polygon($params);
}
parent::polygon($params);
}
/**
* Draw a rectangle
*
* Parameter array:
* 'x0': int X start point
* 'y0': int Y start point
* 'x1': int X end point
* 'y1': int Y end point
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function rectangle($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->rectangle($params);
}
parent::rectangle($params);
}
/**
* Draw an ellipse
*
* Parameter array:
* 'x': int X center point
* 'y': int Y center point
* 'rx': int X radius
* 'ry': int Y radius
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function ellipse($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->ellipse($params);
}
parent::ellipse($params);
}
/**
* Draw a pie slice
*
* Parameter array:
* 'x': int X center point
* 'y': int Y center point
* 'rx': int X radius
* 'ry': int Y radius
* 'v1': int The starting 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)
* 'sry': int [optional] Starting Y-radius of the pie slice (i.e. for a doughnut)
* 'fill': mixed [optional] The fill color
* 'line': mixed [optional] The line color
* @param array $params Parameter array
*/
function pieslice($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->pieslice($params);
}
parent::pieslice($params);
}
/**
* Writes text
*
* Parameter array:
* 'x': int X-point of text
* 'y': int Y-point of text
* 'text': string The text to add
* 'alignment': array [optional] Alignment
* 'color': mixed [optional] The color of the text
*/
function addText($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->addText($params);
}
parent::addText($params);
}
/**
* Overlay image
*
* Parameter array:
* 'x': int X-point of overlayed image
* 'y': int Y-point of overlayed image
* 'filename': string The filename of the image to overlay
* 'width': int [optional] The width of the overlayed image (resizing if possible)
* 'height': int [optional] The height of the overlayed image (resizing if possible)
* 'alignment': array [optional] Alignment
*/
function image($params)
{
if (isset($this->_imageMap)) {
$this->_imageMap->image($params);
}
parent::image($params);
}
/**
* Get the imagemap
* @return Image_Graph_ImageMap The image map (or false if none)
*/
function &getImageMap()
{
$result = null;
if (isset($this->_imageMap)) {
$result =& $this->_imageMap;
}
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
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Class for axis handling.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Axis
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Axis.php
*/
require_once 'Image/Graph/Axis.php';
/**
* A normal axis thats displays labels with a 'interval' of 1.
* This is basically a normal axis where the range is
* the number of labels defined, that is the range is explicitly defined
* when constructing the axis.
*
* @category Images
* @package Image_Graph
* @subpackage Axis
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Axis_Category extends Image_Graph_Axis
{
/**
* The labels shown on the axis
* @var array
* @access private
*/
var $_labels = false;
/**
* Image_Graph_Axis_Category [Constructor].
*
* @param int $type The type (direction) of the Axis
*/
function Image_Graph_Axis_Category($type = IMAGE_GRAPH_AXIS_X)
{
parent::Image_Graph_Axis($type);
$this->_labels = array();
$this->setlabelInterval(1);
}
/**
* Gets the minimum value the axis will show.
*
* This is always 0
*
* @return double The minumum value
* @access private
*/
function _getMinimum()
{
return 0;
}
/**
* Gets the maximum value the axis will show.
*
* This is always the number of labels passed to the constructor.
*
* @return double The maximum value
* @access private
*/
function _getMaximum()
{
return count($this->_labels) - ($this->_pushValues ? 0 : 1);
}
/**
* Sets the minimum value the axis will show.
*
* A minimum cannot be set on a SequentialAxis, it is always 0.
*
* @param double Minimum The minumum value to use on the axis
* @access private
*/
function _setMinimum($minimum)
{
}
/**
* Sets the maximum value the axis will show
*
* 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
* @access private
*/
function _setMaximum($maximum)
{
}
/**
* Forces the minimum value of the axis
*
* A minimum cannot be set on a SequentialAxis, it is always 0.
*
* @param double $minimum The minumum value to use on the axis
*/
function forceMinimum($minimum, $userEnforce = true)
{
}
/**
* Forces the maximum value of the axis
*
* 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
*/
function forceMaximum($maximum, $userEnforce = true)
{
}
/**
* Sets an interval for where labels are shown on the axis.
*
* 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)
{
if ($labelInterval == 'auto') {
parent::setLabelInterval(1);
} else {
parent::setLabelInterval(round($labelInterval));
}
}
/**
* Preprocessor for values, ie for using logarithmic axis
*
* @param double $value The value to preprocess
* @return double The preprocessed value
* @access private
*/
function _value($value)
{
// $the_value = array_search($value, $this->_labels);
if (isset($this->_labels[$value])) {
$the_value = $this->_labels[$value];
if ($the_value !== false) {
return $the_value + ($this->_pushValues ? 0.5 : 0);
} else {
return 0;
}
}
}
/**
* Get the minor label interval with which axis label ticks are drawn.
*
* For a sequential axis this is always disabled (i.e false)
*
* @return double The minor label interval, always false
* @access private
*/
function _minorLabelInterval()
{
return false;
}
/**
* Get the size in pixels of the axis.
*
* For an x-axis this is the width of the axis including labels, and for an
* y-axis it is the corrresponding height
*
* @return int The size of the axis
* @access private
*/
function _size()
{
if (!$this->_visible) {
return 0;
}
$this->_canvas->setFont($this->_getFont());
$maxSize = 0;
foreach($this->_labels as $label => $id) {
$labelPosition = $this->_point($label);
if (is_object($this->_dataPreProcessor)) {
$labelText = $this->_dataPreProcessor->_process($label);
} else {
$labelText = $label;
}
if ((($this->_type == IMAGE_GRAPH_AXIS_X) && (!$this->_transpose)) ||
(($this->_type != IMAGE_GRAPH_AXIS_X) && ($this->_transpose)))
{
$maxSize = max($maxSize, $this->_canvas->textHeight($labelText));
} else {
$maxSize = max($maxSize, $this->_canvas->textWidth($labelText));
}
}
if ($this->_title) {
$this->_canvas->setFont($this->_getTitleFont());
if ((($this->_type == IMAGE_GRAPH_AXIS_X) && (!$this->_transpose)) ||
(($this->_type != IMAGE_GRAPH_AXIS_X) && ($this->_transpose)))
{
$maxSize += $this->_canvas->textHeight($this->_title);
} else {
$maxSize += $this->_canvas->textWidth($this->_title);
}
$maxSize += 10;
}
return $maxSize +3;
}
/**
* Apply the dataset to the axis.
*
* This calculates the order of the categories, which is very important
* for fx. line plots, so that the line does not "go backwards", consider
* these X-sets:<p>
* 1: (1, 2, 3, 4, 5, 6)<br>
* 2: (0, 1, 2, 3, 4, 5, 6, 7)<p>
* If they are not ordered, but simply appended, the categories on the axis
* 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
* 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>
* X: (0, 1, 2, 3, 4, 5, 6, 7)
*
* @param Image_Graph_Dataset $dataset The dataset
* @access private
*/
function _applyDataset(&$dataset)
{
$newLabels = array();
$allLabels = array();
$dataset->_reset();
$count = 0;
$count_new = 0;
while ($point = $dataset->_next()) {
if ($this->_type == IMAGE_GRAPH_AXIS_X) {
$data = $point['X'];
} else {
$data = $point['Y'];
}
if (!isset($this->_labels[$data])) {
$newLabels[$data] = $count_new++;
//$this->_labels[] = $data;
}
$allLabels[$data] = $count++;
}
if (count($this->_labels) == 0) {
$this->_labels = $newLabels;
} elseif ((is_array($newLabels)) && (count($newLabels) > 0)) {
// get all intersecting labels
$intersect = array_intersect(array_keys($allLabels), array_keys($this->_labels));
// traverse all new and find their relative position withing the
// intersec, fx value X0 is before X1 in the intersection, which
// means that X0 should be placed before X1 in the label array
foreach($newLabels as $newLabel => $id) {
$key = $allLabels[$newLabel];
reset($intersect);
$this_value = false;
// intersect indexes are the same as in allLabels!
$first = true;
while ((list($id, $value) = each($intersect)) &&
($this_value === false))
{
if (($first) && ($id > $key)) {
$this_value = $value;
} elseif ($id >= $key) {
$this_value = $value;
}
$first = false;
}
if ($this_value === false) {
// the new label was not found before anything in the
// intersection -> append it
$this->_labels[$newLabel] = count($this->_labels);
} else {
// the new label was found before $this_value in the
// intersection, insert the label before this position in
// the label array
// $key = $this->_labels[$this_value];
$keys = array_keys($this->_labels);
$key = array_search($this_value, $keys);
$pre = array_slice($keys, 0, $key);
$pre[] = $newLabel;
$post = array_slice($keys, $key);
$this->_labels = array_flip(array_merge($pre, $post));
}
}
unset($keys);
}
$labels = array_keys($this->_labels);
$i = 0;
foreach ($labels as $label) {
$this->_labels[$label] = $i++;
}
// $this->_labels = array_values(array_unique($this->_labels));
$this->_calcLabelInterval();
}
/**
* Return the label distance.
*
* @return int The distance between 2 adjacent labels
* @access private
*/
function _labelDistance($level = 1)
{
reset($this->_labels);
list($l1) = each($this->_labels);
list($l2) = each($this->_labels);
return abs($this->_point($l2) - $this->_point($l1));
}
/**
* Get next label point
*
* @param doubt $point The current point, if omitted or false, the first is
* returned
* @return double The next label point
* @access private
*/
function _getNextLabel($currentLabel = false, $level = 1)
{
if ($currentLabel === false) {
reset($this->_labels);
}
$result = false;
$count = ($currentLabel === false ? $this->_labelInterval() - 1 : 0);
while ($count < $this->_labelInterval()) {
$result = (list($label) = each($this->_labels));
$count++;
}
if ($result) {
return $label;
} else {
return false;
}
}
/**
* Is the axis numeric or not?
*
* @return bool True if numeric, false if not
* @access private
*/
function _isNumeric()
{
return false;
}
/**
* Output the axis
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
$result = true;
if (Image_Graph_Element::_done() === false) {
$result = false;
}
$this->_canvas->startGroup(get_class($this));
$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;
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Class for axis handling.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Axis
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Category.php,v 1.19 2006/03/02 12:15:17 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Axis.php
*/
require_once 'Image/Graph/Axis.php';
/**
* A normal axis thats displays labels with a 'interval' of 1.
* This is basically a normal axis where the range is
* the number of labels defined, that is the range is explicitly defined
* when constructing the axis.
*
* @category Images
* @package Image_Graph
* @subpackage Axis
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Axis_Category extends Image_Graph_Axis
{
/**
* The labels shown on the axis
* @var array
* @access private
*/
var $_labels = false;
/**
* Image_Graph_Axis_Category [Constructor].
*
* @param int $type The type (direction) of the Axis
*/
function Image_Graph_Axis_Category($type = IMAGE_GRAPH_AXIS_X)
{
parent::Image_Graph_Axis($type);
$this->_labels = array();
$this->setlabelInterval(1);
}
/**
* Gets the minimum value the axis will show.
*
* This is always 0
*
* @return double The minumum value
* @access private
*/
function _getMinimum()
{
return 0;
}
/**
* Gets the maximum value the axis will show.
*
* This is always the number of labels passed to the constructor.
*
* @return double The maximum value
* @access private
*/
function _getMaximum()
{
return count($this->_labels) - 1;
}
/**
* Sets the minimum value the axis will show.
*
* A minimum cannot be set on a SequentialAxis, it is always 0.
*
* @param double Minimum The minumum value to use on the axis
* @access private
*/
function _setMinimum($minimum)
{
}
/**
* Sets the maximum value the axis will show
*
* 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
* @access private
*/
function _setMaximum($maximum)
{
}
/**
* Forces the minimum value of the axis
*
* <b>A minimum 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
* this array will then be displayed on the graph!
*
* @param double $minimum A minimum cannot be set on this type of axis
*/
function forceMinimum($minimum, $userEnforce = true)
{
}
/**
* Forces the maximum value of the axis
*
* <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
* this array will then be displayed on the graph!
*
* @param double $maximum A maximum cannot be set on this type of axis
*/
function forceMaximum($maximum, $userEnforce = true)
{
}
/**
* Sets an interval for where labels are shown on the axis.
*
* 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)
{
if (is_array($labelInterval)) {
parent::setLabelInterval($labelInterval);
} elseif ($labelInterval == 'auto') {
parent::setLabelInterval(1);
} else {
parent::setLabelInterval(round($labelInterval));
}
}
/**
* Preprocessor for values, ie for using logarithmic axis
*
* @param double $value The value to preprocess
* @return double The preprocessed value
* @access private
*/
function _value($value)
{
// $the_value = array_search($value, $this->_labels);
if (isset($this->_labels[$value])) {
$the_value = $this->_labels[$value];
if ($the_value !== false) {
return $the_value + ($this->_pushValues ? 0.5 : 0);
} else {
return 0;
}
}
}
/**
* Get the minor label interval with which axis label ticks are drawn.
*
* For a sequential axis this is always disabled (i.e false)
*
* @return double The minor label interval, always false
* @access private
*/
function _minorLabelInterval()
{
return false;
}
/**
* Get the size in pixels of the axis.
*
* For an x-axis this is the width of the axis including labels, and for an
* y-axis it is the corrresponding height
*
* @return int The size of the axis
* @access private
*/
function _size()
{
if (!$this->_visible) {
return 0;
}
$this->_canvas->setFont($this->_getFont());
$maxSize = 0;
foreach($this->_labels as $label => $id) {
$labelPosition = $this->_point($label);
if (is_object($this->_dataPreProcessor)) {
$labelText = $this->_dataPreProcessor->_process($label);
} else {
$labelText = $label;
}
if ((($this->_type == IMAGE_GRAPH_AXIS_X) && (!$this->_transpose)) ||
(($this->_type != IMAGE_GRAPH_AXIS_X) && ($this->_transpose)))
{
$maxSize = max($maxSize, $this->_canvas->textHeight($labelText));
} else {
$maxSize = max($maxSize, $this->_canvas->textWidth($labelText));
}
}
if ($this->_title) {
$this->_canvas->setFont($this->_getTitleFont());
if ((($this->_type == IMAGE_GRAPH_AXIS_X) && (!$this->_transpose)) ||
(($this->_type != IMAGE_GRAPH_AXIS_X) && ($this->_transpose)))
{
$maxSize += $this->_canvas->textHeight($this->_title);
} else {
$maxSize += $this->_canvas->textWidth($this->_title);
}
$maxSize += 10;
}
return $maxSize +3;
}
/**
* Apply the dataset to the axis.
*
* This calculates the order of the categories, which is very important
* for fx. line plots, so that the line does not "go backwards", consider
* these X-sets:<p>
* 1: (1, 2, 3, 4, 5, 6)<br>
* 2: (0, 1, 2, 3, 4, 5, 6, 7)<p>
* If they are not ordered, but simply appended, the categories on the axis
* 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
* 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>
* X: (0, 1, 2, 3, 4, 5, 6, 7)
*
* @param Image_Graph_Dataset $dataset The dataset
* @access private
*/
function _applyDataset(&$dataset)
{
$newLabels = array();
$allLabels = array();
$dataset->_reset();
$count = 0;
$count_new = 0;
while ($point = $dataset->_next()) {
if ($this->_type == IMAGE_GRAPH_AXIS_X) {
$data = $point['X'];
} else {
$data = $point['Y'];
}
if (!isset($this->_labels[$data])) {
$newLabels[$data] = $count_new++;
//$this->_labels[] = $data;
}
$allLabels[$data] = $count++;
}
if (count($this->_labels) == 0) {
$this->_labels = $newLabels;
} elseif ((is_array($newLabels)) && (count($newLabels) > 0)) {
// get all intersecting labels
$intersect = array_intersect(array_keys($allLabels), array_keys($this->_labels));
// traverse all new and find their relative position withing the
// intersec, fx value X0 is before X1 in the intersection, which
// means that X0 should be placed before X1 in the label array
foreach($newLabels as $newLabel => $id) {
$key = $allLabels[$newLabel];
reset($intersect);
$this_value = false;
// intersect indexes are the same as in allLabels!
$first = true;
while ((list($id, $value) = each($intersect)) &&
($this_value === false))
{
if (($first) && ($id > $key)) {
$this_value = $value;
} elseif ($id >= $key) {
$this_value = $value;
}
$first = false;
}
if ($this_value === false) {
// the new label was not found before anything in the
// intersection -> append it
$this->_labels[$newLabel] = count($this->_labels);
} else {
// the new label was found before $this_value in the
// intersection, insert the label before this position in
// the label array
// $key = $this->_labels[$this_value];
$keys = array_keys($this->_labels);
$key = array_search($this_value, $keys);
$pre = array_slice($keys, 0, $key);
$pre[] = $newLabel;
$post = array_slice($keys, $key);
$this->_labels = array_flip(array_merge($pre, $post));
}
}
unset($keys);
}
$labels = array_keys($this->_labels);
$i = 0;
foreach ($labels as $label) {
$this->_labels[$label] = $i++;
}
// $this->_labels = array_values(array_unique($this->_labels));
$this->_calcLabelInterval();
}
/**
* Return the label distance.
*
* @return int The distance between 2 adjacent labels
* @access private
*/
function _labelDistance($level = 1)
{
reset($this->_labels);
list($l1) = each($this->_labels);
list($l2) = each($this->_labels);
return abs($this->_point($l2) - $this->_point($l1));
}
/**
* Get next label point
*
* @param doubt $point The current point, if omitted or false, the first is
* returned
* @return double The next label point
* @access private
*/
function _getNextLabel($currentLabel = false, $level = 1)
{
if ($currentLabel === false) {
reset($this->_labels);
}
$result = false;
$count = ($currentLabel === false ? $this->_labelInterval() - 1 : 0);
while ($count < $this->_labelInterval()) {
$result = (list($label) = each($this->_labels));
$count++;
}
if ($result) {
return $label;
} else {
return false;
}
}
/**
* Is the axis numeric or not?
*
* @return bool True if numeric, false if not
* @access private
*/
function _isNumeric()
{
return false;
}
/**
* Output the axis
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
$result = true;
if (Image_Graph_Element::_done() === false) {
$result = false;
}
$this->_canvas->startGroup(get_class($this));
$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
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Class for axis handling.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Axis
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Axis.php
*/
require_once 'Image/Graph/Axis.php';
/**
* Diplays a logarithmic axis (either X- or Y-axis).
*
* @category Images
* @package Image_Graph
* @subpackage Axis
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Axis_Logarithmic extends Image_Graph_Axis
{
/**
* Image_Graph_AxisLogarithmic [Constructor].
*
* Normally a manual creation should not be necessary, axis are
* created automatically by the {@link Image_Graph_Plotarea} constructor
* unless explicitly defined otherwise
*
* @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-
* axis)
*/
function Image_Graph_Axis_Logarithmic($type = IMAGE_GRAPH_AXIS_X)
{
parent::Image_Graph_Axis($type);
$this->showLabel(IMAGE_GRAPH_LABEL_MINIMUM + IMAGE_GRAPH_LABEL_MAXIMUM);
}
/**
* Calculate the label interval
*
* If explicitly defined this will be calucated to an approximate best.
*
* @return double The label interval
* @access private
*/
function _calcLabelInterval()
{
$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
*
* @param double $minimum The minumum value to use on the axis
*/
function forceMinimum($minimum)
{
parent::forceMinimum(0);
}
/**
* Gets the minimum value the axis will show.
*
* For an logarithimc axis this is always 0
*
* @return double The minumum value
* @access private
*/
function _getMinimum()
{
return 0;
}
/**
* Preprocessor for values, ie for using logarithmic axis
*
* @param double $value The value to preprocess
* @return double The preprocessed value
* @access private
*/
function _value($value)
{
return log10($value);
}
/**
* Get next label point
*
* @param doubt $point The current point, if omitted or false, the first is
* returned
* @return double The next label point
* @access private
*/
function _getNextLabel($currentLabel = false, $level = 1)
{
if (is_array($this->_labelOptions[$level]['interval'])) {
return parent::_getNextLabel($currentLabel, $level);
}
if ($currentLabel !== false) {
$value = log10($currentLabel);
$base = floor($value);
$frac = $value - $base;
for ($i = 2; $i < 10; $i++) {
if ($frac <= (log10($i)-0.01)) {
$label = pow(10, $base)*$i;
if ($label > $this->_getMaximum()) {
return false;
} else {
return $label;
}
}
}
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);
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Class for axis handling.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Axis
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Logarithmic.php,v 1.15 2006/03/02 12:35:57 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Axis.php
*/
require_once 'Image/Graph/Axis.php';
/**
* Diplays a logarithmic axis (either X- or Y-axis).
*
* @category Images
* @package Image_Graph
* @subpackage Axis
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Axis_Logarithmic extends Image_Graph_Axis
{
/**
* Image_Graph_AxisLogarithmic [Constructor].
*
* Normally a manual creation should not be necessary, axis are
* created automatically by the {@link Image_Graph_Plotarea} constructor
* unless explicitly defined otherwise
*
* @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-
* axis)
*/
function Image_Graph_Axis_Logarithmic($type = IMAGE_GRAPH_AXIS_X)
{
parent::Image_Graph_Axis($type);
$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.
*
* @return double The label interval
* @access private
*/
function _calcLabelInterval()
{
$result = parent::_calcLabelInterval();
$this->_axisValueSpan = $this->_value($this->_axisSpan);
return $result;
}
/**
* Preprocessor for values, ie for using logarithmic axis
*
* @param double $value The value to preprocess
* @return double The preprocessed value
* @access private
*/
function _value($value)
{
return log10($value) - log10($this->_minimum);
}
/**
* Get next label point
*
* @param doubt $point The current point, if omitted or false, the first is
* returned
* @return double The next label point
* @access private
*/
function _getNextLabel($currentLabel = false, $level = 1)
{
if (is_array($this->_labelOptions[$level]['interval'])) {
return parent::_getNextLabel($currentLabel, $level);
}
if ($currentLabel !== false) {
$value = log10($currentLabel);
$base = floor($value);
$frac = $value - $base;
for ($i = 2; $i < 10; $i++) {
if ($frac <= (log10($i)-0.01)) {
$label = pow(10, $base)*$i;
if ($label > $this->_getMaximum()) {
return false;
} else {
return $label;
}
}
}
return pow(10, $base+1);
}
return max(1, $this->_minimum);
}
/**
* 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
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Class file containing a axis marker used for explicitly highlighting a area
* on the graph, based on an interval specified on an axis.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Grid
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Grid.php
*/
require_once 'Image/Graph/Grid.php';
/**
* Display a grid
*
* {@link Image_Graph_Grid}
*
* @category Images
* @package Image_Graph
* @subpackage Grid
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Axis_Marker_Area extends Image_Graph_Grid
{
/**
* The lower bound
* @var double
* @access private
*/
var $_lower = false;
/**
* The upper bound
* @var double
* @access private
*/
var $_upper = false;
/**
* [Constructor]
*/
function Image_Graph_Axis_Marker_Area()
{
parent::Image_Graph_Grid();
$this->_lineStyle = false;
}
/**
* Sets the lower bound of the area (value on the axis)
*
* @param double $lower the lower bound
*/
function setLowerBound($lower)
{
$this->_lower = $lower;
}
/**
* Sets the upper bound of the area (value on the axis)
*
* @param double $upper the upper bound
*/
function setUpperBound($upper)
{
$this->_upper = $upper;
}
/**
* Output the grid
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
if (!$this->_primaryAxis) {
return false;
}
$this->_canvas->startGroup(get_class($this));
$i = 0;
$this->_lower = max($this->_primaryAxis->_getMinimum(), $this->_lower);
$this->_upper = min($this->_primaryAxis->_getMaximum(), $this->_upper);
$secondaryPoints = $this->_getSecondaryAxisPoints();
reset($secondaryPoints);
list ($id, $previousSecondaryValue) = each($secondaryPoints);
while (list ($id, $secondaryValue) = each($secondaryPoints)) {
if ($this->_primaryAxis->_type == IMAGE_GRAPH_AXIS_X) {
$p1 = array ('Y' => $secondaryValue, 'X' => $this->_lower);
$p2 = array ('Y' => $previousSecondaryValue, 'X' => $this->_lower);
$p3 = array ('Y' => $previousSecondaryValue, 'X' => $this->_upper);
$p4 = array ('Y' => $secondaryValue, 'X' => $this->_upper);
} else {
$p1 = array ('X' => $secondaryValue, 'Y' => $this->_lower);
$p2 = array ('X' => $previousSecondaryValue, 'Y' => $this->_lower);
$p3 = array ('X' => $previousSecondaryValue, '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($p2), 'y' => $this->_pointY($p2)));
$this->_canvas->addVertex(array('x' => $this->_pointX($p3), 'y' => $this->_pointY($p3)));
$this->_canvas->addVertex(array('x' => $this->_pointX($p4), 'y' => $this->_pointY($p4)));
$previousSecondaryValue = $secondaryValue;
$this->_getLineStyle();
$this->_getFillStyle();
$this->_canvas->polygon(array('connect' => true));
}
$this->_canvas->endGroup();
return true;
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Class file containing a axis marker used for explicitly highlighting a area
* on the graph, based on an interval specified on an axis.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Grid
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Grid.php
*/
require_once 'Image/Graph/Grid.php';
/**
* Display a grid
*
* {@link Image_Graph_Grid}
*
* @category Images
* @package Image_Graph
* @subpackage Grid
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Axis_Marker_Area extends Image_Graph_Grid
{
/**
* The lower bound
* @var double
* @access private
*/
var $_lower = false;
/**
* The upper bound
* @var double
* @access private
*/
var $_upper = false;
/**
* [Constructor]
*/
function Image_Graph_Axis_Marker_Area()
{
parent::Image_Graph_Grid();
$this->_lineStyle = false;
}
/**
* Sets the lower bound of the area (value on the axis)
*
* @param double $lower the lower bound
*/
function setLowerBound($lower)
{
$this->_lower = $lower;
}
/**
* Sets the upper bound of the area (value on the axis)
*
* @param double $upper the upper bound
*/
function setUpperBound($upper)
{
$this->_upper = $upper;
}
/**
* Output the grid
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
if (!$this->_primaryAxis) {
return false;
}
$this->_canvas->startGroup(get_class($this));
$i = 0;
$this->_lower = max($this->_primaryAxis->_getMinimum(), $this->_lower);
$this->_upper = min($this->_primaryAxis->_getMaximum(), $this->_upper);
$secondaryPoints = $this->_getSecondaryAxisPoints();
reset($secondaryPoints);
list ($id, $previousSecondaryValue) = each($secondaryPoints);
while (list ($id, $secondaryValue) = each($secondaryPoints)) {
if ($this->_primaryAxis->_type == IMAGE_GRAPH_AXIS_X) {
$p1 = array ('Y' => $secondaryValue, 'X' => $this->_lower);
$p2 = array ('Y' => $previousSecondaryValue, 'X' => $this->_lower);
$p3 = array ('Y' => $previousSecondaryValue, 'X' => $this->_upper);
$p4 = array ('Y' => $secondaryValue, 'X' => $this->_upper);
} else {
$p1 = array ('X' => $secondaryValue, 'Y' => $this->_lower);
$p2 = array ('X' => $previousSecondaryValue, 'Y' => $this->_lower);
$p3 = array ('X' => $previousSecondaryValue, '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($p2), 'y' => $this->_pointY($p2)));
$this->_canvas->addVertex(array('x' => $this->_pointX($p3), 'y' => $this->_pointY($p3)));
$this->_canvas->addVertex(array('x' => $this->_pointX($p4), 'y' => $this->_pointY($p4)));
$previousSecondaryValue = $secondaryValue;
$this->_getLineStyle();
$this->_getFillStyle();
$this->_canvas->polygon(array('connect' => true));
}
$this->_canvas->endGroup();
return true;
}
}
?>

View File

@ -1,124 +1,124 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Class file containing a axis marker used for explicitly highlighting a point
* (line) on the graph, based on an value specified on an axis.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Grid
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Grid.php
*/
require_once 'Image/Graph/Grid.php';
/**
* Display a grid
*
* {@link Image_Graph_Grid}
*
* @category Images
* @package Image_Graph
* @subpackage Grid
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Axis_Marker_Line extends Image_Graph_Grid
{
/**
* The value
* @var double
* @access private
*/
var $_value = false;
/**
* Sets the value of the line marker (value on the axis)
*
* @param double $value the value
*/
function setValue($value)
{
$this->_value = $value;
}
/**
* Output the grid
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
if (!$this->_primaryAxis) {
return false;
}
$this->_canvas->startGroup(get_class($this));
$i = 0;
$this->_value = min($this->_primaryAxis->_getMaximum(), max($this->_primaryAxis->_getMinimum(), $this->_value));
$secondaryPoints = $this->_getSecondaryAxisPoints();
reset($secondaryPoints);
list ($id, $previousSecondaryValue) = each($secondaryPoints);
while (list ($id, $secondaryValue) = each($secondaryPoints)) {
if ($this->_primaryAxis->_type == IMAGE_GRAPH_AXIS_X) {
$p1 = array ('X' => $this->_value, 'Y' => $secondaryValue);
$p2 = array ('X' => $this->_value, 'Y' => $previousSecondaryValue);
} else {
$p1 = array ('X' => $secondaryValue, 'Y' => $this->_value);
$p2 = array ('X' => $previousSecondaryValue, 'Y' => $this->_value);
}
$x1 = $this->_pointX($p1);
$y1 = $this->_pointY($p1);
$x2 = $this->_pointX($p2);
$y2 = $this->_pointY($p2);
$previousSecondaryValue = $secondaryValue;
$this->_getLineStyle();
$this->_canvas->line(array('x0' => $x1, 'y0' => $y1, 'x1' => $x2, 'y1' => $y2));
}
$this->_canvas->endGroup();
return true;
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Class file containing a axis marker used for explicitly highlighting a point
* (line) on the graph, based on an value specified on an axis.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Grid
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Grid.php
*/
require_once 'Image/Graph/Grid.php';
/**
* Display a grid
*
* {@link Image_Graph_Grid}
*
* @category Images
* @package Image_Graph
* @subpackage Grid
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Axis_Marker_Line extends Image_Graph_Grid
{
/**
* The value
* @var double
* @access private
*/
var $_value = false;
/**
* Sets the value of the line marker (value on the axis)
*
* @param double $value the value
*/
function setValue($value)
{
$this->_value = $value;
}
/**
* Output the grid
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
if (!$this->_primaryAxis) {
return false;
}
$this->_canvas->startGroup(get_class($this));
$i = 0;
$this->_value = min($this->_primaryAxis->_getMaximum(), max($this->_primaryAxis->_getMinimum(), $this->_value));
$secondaryPoints = $this->_getSecondaryAxisPoints();
reset($secondaryPoints);
list ($id, $previousSecondaryValue) = each($secondaryPoints);
while (list ($id, $secondaryValue) = each($secondaryPoints)) {
if ($this->_primaryAxis->_type == IMAGE_GRAPH_AXIS_X) {
$p1 = array ('X' => $this->_value, 'Y' => $secondaryValue);
$p2 = array ('X' => $this->_value, 'Y' => $previousSecondaryValue);
} else {
$p1 = array ('X' => $secondaryValue, 'Y' => $this->_value);
$p2 = array ('X' => $previousSecondaryValue, 'Y' => $this->_value);
}
$x1 = $this->_pointX($p1);
$y1 = $this->_pointY($p1);
$x2 = $this->_pointX($p2);
$y2 = $this->_pointY($p2);
$previousSecondaryValue = $secondaryValue;
$this->_getLineStyle();
$this->_canvas->line(array('x0' => $x1, 'y0' => $y1, 'x1' => $x2, 'y1' => $y2));
}
$this->_canvas->endGroup();
return true;
}
}
?>

View File

@ -1,204 +1,204 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Class for axis handling.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Axis
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Axis/Category.php
*/
require_once 'Image/Graph/Axis/Category.php';
/**
* Displays an 'X'-axis in a radar plot chart.
*
* 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
* center to the edge of the 'circle' than encloses the radar plot. The labels
* are drawn on the 'ends' of these radial lines.
*
* @category Images
* @package Image_Graph
* @subpackage Axis
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Axis_Radar extends Image_Graph_Axis_Category
{
/**
* Specifies the number of pixels, the labels is offsetted from the end of
* the axis
*
* @var int
* @access private
*/
var $_distanceFromEnd = 5;
/**
* Gets the minimum value the axis will show.
*
* This is always 0
*
* @return double The minumum value
* @access private
*/
function _getMinimum()
{
return 0;
}
/**
* Gets the maximum value the axis will show.
*
* This is always the number of labels passed to the constructor.
*
* @return double The maximum value
* @access private
*/
function _getMaximum()
{
return count($this->_labels);
}
/**
* Calculate the delta value (the number of pixels representing one unit
* on the axis)
*
* @return double The label interval
* @access private
*/
function _calcDelta()
{
if (abs($this->_getMaximum() - $this->_getMinimum()) == 0) {
$this->_delta = false;
} else {
$this->_delta = 360 / ($this->_getMaximum() - $this->_getMinimum());
}
}
/**
* Get the pixel position represented by a value on the canvas
*
* @param double $value the value to get the pixel-point for
* @return double The pixel position along the axis
* @access private
*/
function _point($value)
{
return (90 + (int) ($this->_value($value) * $this->_delta)) % 360;
}
/**
* Get the size in pixels of the axis.
*
* For a radar plot this is always 0
*
* @return int The size of the axis
* @access private
*/
function _size()
{
return 0;
}
/**
* Sets the distance from the end of the category lines to the label.
*
* @param int $distance The distance in pixels
*/
function setDistanceFromEnd($distance = 5)
{
$this->_distanceFromEnd = $distance;
}
/**
* Draws axis lines.
*
* @access private
*/
function _drawAxisLines()
{
}
/**
* Output an axis tick mark.
*
* @param int $value The value to output
* @access private
*/
function _drawTick($value, $level = 1)
{
$centerX = (int) (($this->_left + $this->_right) / 2);
$centerY = (int) (($this->_top + $this->_bottom) / 2);
$radius = min($this->height(), $this->width()) / 2;
$endPoint = array ('X' => $value, 'Y' => '#max#');
$dX = $this->_pointX($endPoint);
$dY = $this->_pointY($endPoint);
$offX = ($dX - $centerX);
$offY = ($dY - $centerY);
$hyp = sqrt($offX*$offX + $offY*$offY);
if ($hyp != 0) {
$scale = $this->_distanceFromEnd / $hyp;
} else {
$scale = 1;
}
$adX = $dX + $offX * $scale;
$adY = $dY + $offY * $scale;
if (is_object($this->_dataPreProcessor)) {
$labelText = $this->_dataPreProcessor->_process($value);
} else {
$labelText = $value;
}
if ((abs($dX - $centerX) < 1.5) && ($dY < $centerY)) {
$align = IMAGE_GRAPH_ALIGN_BOTTOM + IMAGE_GRAPH_ALIGN_CENTER_X;
} elseif ((abs($dX - $centerX) < 1.5) && ($dY > $centerY)) {
$align = IMAGE_GRAPH_ALIGN_TOP + IMAGE_GRAPH_ALIGN_CENTER_X;
} elseif ($dX < $centerX) {
$align = IMAGE_GRAPH_ALIGN_RIGHT + IMAGE_GRAPH_ALIGN_CENTER_Y;
} else {
$align = IMAGE_GRAPH_ALIGN_LEFT + IMAGE_GRAPH_ALIGN_CENTER_Y;
}
$this->write($adX, $adY, $labelText, $align);
$this->_getLineStyle();
$this->_canvas->line(array('x0' => $centerX, 'y0' => $centerY, 'x1' => $dX, 'y1' => $dY));
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Class for axis handling.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Axis
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Axis/Category.php
*/
require_once 'Image/Graph/Axis/Category.php';
/**
* Displays an 'X'-axis in a radar plot chart.
*
* 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
* center to the edge of the 'circle' than encloses the radar plot. The labels
* are drawn on the 'ends' of these radial lines.
*
* @category Images
* @package Image_Graph
* @subpackage Axis
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Axis_Radar extends Image_Graph_Axis_Category
{
/**
* Specifies the number of pixels, the labels is offsetted from the end of
* the axis
*
* @var int
* @access private
*/
var $_distanceFromEnd = 5;
/**
* Gets the minimum value the axis will show.
*
* This is always 0
*
* @return double The minumum value
* @access private
*/
function _getMinimum()
{
return 0;
}
/**
* Gets the maximum value the axis will show.
*
* This is always the number of labels passed to the constructor.
*
* @return double The maximum value
* @access private
*/
function _getMaximum()
{
return count($this->_labels);
}
/**
* Calculate the delta value (the number of pixels representing one unit
* on the axis)
*
* @return double The label interval
* @access private
*/
function _calcDelta()
{
if (abs($this->_getMaximum() - $this->_getMinimum()) == 0) {
$this->_delta = false;
} else {
$this->_delta = 360 / ($this->_getMaximum() - $this->_getMinimum());
}
}
/**
* Get the pixel position represented by a value on the canvas
*
* @param double $value the value to get the pixel-point for
* @return double The pixel position along the axis
* @access private
*/
function _point($value)
{
return (90 + (int) ($this->_value($value) * $this->_delta)) % 360;
}
/**
* Get the size in pixels of the axis.
*
* For a radar plot this is always 0
*
* @return int The size of the axis
* @access private
*/
function _size()
{
return 0;
}
/**
* Sets the distance from the end of the category lines to the label.
*
* @param int $distance The distance in pixels
*/
function setDistanceFromEnd($distance = 5)
{
$this->_distanceFromEnd = $distance;
}
/**
* Draws axis lines.
*
* @access private
*/
function _drawAxisLines()
{
}
/**
* Output an axis tick mark.
*
* @param int $value The value to output
* @access private
*/
function _drawTick($value, $level = 1)
{
$centerX = (int) (($this->_left + $this->_right) / 2);
$centerY = (int) (($this->_top + $this->_bottom) / 2);
$radius = min($this->height(), $this->width()) / 2;
$endPoint = array ('X' => $value, 'Y' => '#max#');
$dX = $this->_pointX($endPoint);
$dY = $this->_pointY($endPoint);
$offX = ($dX - $centerX);
$offY = ($dY - $centerY);
$hyp = sqrt($offX*$offX + $offY*$offY);
if ($hyp != 0) {
$scale = $this->_distanceFromEnd / $hyp;
} else {
$scale = 1;
}
$adX = $dX + $offX * $scale;
$adY = $dY + $offY * $scale;
if (is_object($this->_dataPreProcessor)) {
$labelText = $this->_dataPreProcessor->_process($value);
} else {
$labelText = $value;
}
if ((abs($dX - $centerX) < 1.5) && ($dY < $centerY)) {
$align = IMAGE_GRAPH_ALIGN_BOTTOM + IMAGE_GRAPH_ALIGN_CENTER_X;
} elseif ((abs($dX - $centerX) < 1.5) && ($dY > $centerY)) {
$align = IMAGE_GRAPH_ALIGN_TOP + IMAGE_GRAPH_ALIGN_CENTER_X;
} elseif ($dX < $centerX) {
$align = IMAGE_GRAPH_ALIGN_RIGHT + IMAGE_GRAPH_ALIGN_CENTER_Y;
} else {
$align = IMAGE_GRAPH_ALIGN_LEFT + IMAGE_GRAPH_ALIGN_CENTER_Y;
}
$this->write($adX, $adY, $labelText, $align);
$this->_getLineStyle();
$this->_canvas->line(array('x0' => $centerX, 'y0' => $centerY, 'x1' => $dX, 'y1' => $dY));
}
}
?>

View File

@ -1,308 +1,313 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - Main class for the graph creation.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
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
*
* @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 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
*/
function is_a($object, $class_name)
{
if (empty ($object)) {
return false;
}
$object = is_object($object) ? get_class($object) : $object;
if (strtolower($object) == strtolower($class_name)) {
return true;
}
return is_a(get_parent_class($object), $class_name);
}
}
/**
* Include file Image/Canvas.php
*/
require_once 'Image/Canvas.php';
/**
* The ultimate ancestor of all Image_Graph classes.
*
* This class contains common functionality needed by all Image_Graph classes.
*
* @category Images
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
* @abstract
*/
class Image_Graph_Common
{
/**
* The parent container of the current Image_Graph object
*
* @var Image_Graph_Common
* @access private
*/
var $_parent = null;
/**
* The sub-elements of the current Image_Graph container object
*
* @var array
* @access private
*/
var $_elements;
/**
* The canvas for output.
*
* Enables support for multiple output formats.
*
* @var Image_Canvas
* @access private
*/
var $_canvas = null;
/**
* Is the object visible?
*
* @var bool
* @access private
*/
var $_visible = true;
/**
* Constructor [Image_Graph_Common]
*/
function Image_Graph_Common()
{
}
/**
* Resets the elements
*
* @access private
*/
function _reset()
{
if (is_array($this->_elements)) {
$keys = array_keys($this->_elements);
foreach ($keys as $key) {
if (is_object($this->_elements[$key])) {
$this->_elements[$key]->_setParent($this);
@$result =& $this->_elements[$key]->_reset();
if (PEAR::isError($result)) {
return $result;
}
}
}
unset($keys);
}
return true;
}
/**
* Sets the parent. The parent chain should ultimately be a GraPHP object
*
* @see Image_Graph_Common
* @param Image_Graph_Common $parent The parent
* @access private
*/
function _setParent(& $parent)
{
$this->_parent =& $parent;
$this->_canvas =& $this->_parent->_getCanvas();
if (is_array($this->_elements)) {
$keys = array_keys($this->_elements);
foreach ($keys as $key) {
if (is_object($this->_elements[$key])) {
$this->_elements[$key]->_setParent($this);
}
}
unset($keys);
}
}
/**
* Hide the element
*/
function hide()
{
$this->_visible = false;
}
/**
* Get the canvas
*
* @return Image_Canvas The canvas
* @access private
*/
function &_getCanvas()
{
if (($this->_canvas !== null) || ($this->_canvas !== false)) {
return $this->_canvas;
} elseif (is_a($this->_parent, 'Image_Graph_Common')) {
$this->_canvas =& $this->_parent->_getCanvas();
return $this->_canvas;
} else {
$this->_error('Invalid canvas');
$result = null;
return $result;
}
}
/**
* Adds an element to the objects element list.
*
* The new Image_Graph_elements parent is automatically set.
*
* @param Image_Graph_Common $element The new Image_Graph_element
* @return Image_Graph_Common The new Image_Graph_element
*/
function &add(& $element)
{
if (!is_a($element, 'Image_Graph_Font')) {
$this->_elements[] = &$element;
}
$element->_setParent($this);
return $element;
}
/**
* 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
* element list. If only one parameter is required for the constructor of
* 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
* 'enclose' the parameter in an array. Similar if the constructor takes
* more than one parameter specify the parameters in an array.
*
* @see Image_Graph::factory()
* @param string $class The class for the object
* @param mixed $params The paramaters to pass to the constructor
* @return Image_Graph_Common The new Image_Graph_element
*/
function &addNew($class, $params = null, $additional = false)
{
include_once 'Image/Graph.php';
$element =& Image_Graph::factory($class, $params);
if ($additional === false) {
$obj =& $this->add($element);
} else {
$obj =& $this->add($element, $additional);
}
return $obj;
}
/**
* Shows an error message box on the canvas
*
* @param string $text The error text
* @param array $params An array containing error specific details
* @param int $error_code Error code
* @access private
*/
function _error($text, $params = false, $error_code = IMAGE_GRAPH_ERROR_GENERIC)
{
foreach ($params as $name => $key) {
if (isset($parameters)) {
$parameters .= ' ';
}
$parameters .= $name . '=' . $key;
}
$error =& PEAR::raiseError(
$text .
($error_code != IMAGE_GRAPH_ERROR_GENERIC ? ' error:' . IMAGE_GRAPH_ERROR_GENERIC : '') .
(isset($parameters) ? ' parameters:[' . $parameters . ']' : '')
);
}
/**
* Causes the object to update all sub elements coordinates
*
* (Image_Graph_Common, does not itself have coordinates, this is basically
* an abstract method)
*
* @access private
*/
function _updateCoords()
{
if (is_array($this->_elements)) {
$keys = array_keys($this->_elements);
foreach ($keys as $key) {
if (is_object($this->_elements[$key])) {
$this->_elements[$key]->_updateCoords();
}
}
unset($keys);
}
return true;
}
/**
* Causes output to canvas
*
* 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).
* @access private
*/
function _done()
{
if (($this->_canvas == null) || (!is_a($this->_canvas, 'Image_Canvas'))) {
return false;
}
if (is_array($this->_elements)) {
$keys = array_keys($this->_elements);
foreach ($keys as $key) {
if (($this->_elements[$key]->_visible) && ($this->_elements[$key]->_done() === false)) {
return false;
}
}
unset($keys);
}
return true;
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - Main class for the graph creation.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Common.php,v 1.16 2006/02/28 22:48:07 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
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
*
* @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 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
*/
function is_a($object, $class_name)
{
if (empty ($object)) {
return false;
}
$object = is_object($object) ? get_class($object) : $object;
if (strtolower($object) == strtolower($class_name)) {
return true;
}
return is_a(get_parent_class($object), $class_name);
}
}
/**
* Include file Image/Canvas.php
*/
require_once 'Image/Canvas.php';
/**
* The ultimate ancestor of all Image_Graph classes.
*
* This class contains common functionality needed by all Image_Graph classes.
*
* @category Images
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
* @abstract
*/
class Image_Graph_Common
{
/**
* The parent container of the current Image_Graph object
*
* @var Image_Graph_Common
* @access private
*/
var $_parent = null;
/**
* The sub-elements of the current Image_Graph container object
*
* @var array
* @access private
*/
var $_elements;
/**
* The canvas for output.
*
* Enables support for multiple output formats.
*
* @var Image_Canvas
* @access private
*/
var $_canvas = null;
/**
* Is the object visible?
*
* @var bool
* @access private
*/
var $_visible = true;
/**
* Constructor [Image_Graph_Common]
*/
function Image_Graph_Common()
{
}
/**
* Resets the elements
*
* @access private
*/
function _reset()
{
if (is_array($this->_elements)) {
$keys = array_keys($this->_elements);
foreach ($keys as $key) {
if (is_object($this->_elements[$key])) {
$this->_elements[$key]->_setParent($this);
$result =& $this->_elements[$key]->_reset();
if (PEAR::isError($result)) {
return $result;
}
}
}
unset($keys);
}
return true;
}
/**
* Sets the parent. The parent chain should ultimately be a GraPHP object
*
* @see Image_Graph_Common
* @param Image_Graph_Common $parent The parent
* @access private
*/
function _setParent(& $parent)
{
$this->_parent =& $parent;
$this->_canvas =& $this->_parent->_getCanvas();
if (is_array($this->_elements)) {
$keys = array_keys($this->_elements);
foreach ($keys as $key) {
if (is_object($this->_elements[$key])) {
$this->_elements[$key]->_setParent($this);
}
}
unset($keys);
}
}
/**
* Hide the element
*/
function hide()
{
$this->_visible = false;
}
/**
* Get the canvas
*
* @return Image_Canvas The canvas
* @access private
*/
function &_getCanvas()
{
if (($this->_canvas !== null) || ($this->_canvas !== false)) {
return $this->_canvas;
} elseif (is_a($this->_parent, 'Image_Graph_Common')) {
$this->_canvas =& $this->_parent->_getCanvas();
return $this->_canvas;
} else {
$this->_error('Invalid canvas');
$result = null;
return $result;
}
}
/**
* Adds an element to the objects element list.
*
* The new Image_Graph_elements parent is automatically set.
*
* @param Image_Graph_Common $element The new Image_Graph_element
* @return Image_Graph_Common The new Image_Graph_element
*/
function &add(& $element)
{
if (!is_a($element, 'Image_Graph_Font')) {
$this->_elements[] = &$element;
}
$element->_setParent($this);
return $element;
}
/**
* 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
* element list. If only one parameter is required for the constructor of
* 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
* 'enclose' the parameter in an array. Similar if the constructor takes
* more than one parameter specify the parameters in an array.
*
* @see Image_Graph::factory()
* @param string $class The class for the object
* @param mixed $params The paramaters to pass to the constructor
* @return Image_Graph_Common The new Image_Graph_element
*/
function &addNew($class, $params = null, $additional = false)
{
include_once 'Image/Graph.php';
$element =& Image_Graph::factory($class, $params);
if ($additional === false) {
$obj =& $this->add($element);
} else {
$obj =& $this->add($element, $additional);
}
return $obj;
}
/**
* Shows an error message box on the canvas
*
* @param string $text The error text
* @param array $params An array containing error specific details
* @param int $error_code Error code
* @access private
*/
function _error($text, $params = false, $error_code = IMAGE_GRAPH_ERROR_GENERIC)
{
if ((is_array($params)) && (count($params) > 0)) {
foreach ($params as $name => $key) {
if (isset($parameters)) {
$parameters .= ' ';
}
else {
$parameters = '';
}
$parameters .= $name . '=' . $key;
}
}
$error =& PEAR::raiseError(
$text .
($error_code != IMAGE_GRAPH_ERROR_GENERIC ? ' error:' . IMAGE_GRAPH_ERROR_GENERIC : '') .
(isset($parameters) ? ' parameters:[' . $parameters . ']' : '')
);
}
/**
* Causes the object to update all sub elements coordinates
*
* (Image_Graph_Common, does not itself have coordinates, this is basically
* an abstract method)
*
* @access private
*/
function _updateCoords()
{
if (is_array($this->_elements)) {
$keys = array_keys($this->_elements);
foreach ($keys as $key) {
if (is_object($this->_elements[$key])) {
$this->_elements[$key]->_updateCoords();
}
}
unset($keys);
}
return true;
}
/**
* Causes output to canvas
*
* 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).
* @access private
*/
function _done()
{
if (($this->_canvas == null) || (!is_a($this->_canvas, 'Image_Canvas'))) {
return false;
}
if (is_array($this->_elements)) {
$keys = array_keys($this->_elements);
foreach ($keys as $key) {
if (($this->_elements[$key]->_visible) && ($this->_elements[$key]->_done() === false)) {
return false;
}
}
unset($keys);
}
return true;
}
}
?>

View File

@ -1,30 +1,30 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - Main class for the graph creation.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - Main class for the graph creation.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
?>

View File

@ -1,225 +1,225 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - Main class for the graph creation.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Font.php
*/
require_once 'Image/Graph/Font.php';
// Constant declarations
/**
* Defines an X (horizontal) axis
*/
define('IMAGE_GRAPH_AXIS_X', 1);
/**
* Defines an Y (vertical) axis
*/
define('IMAGE_GRAPH_AXIS_Y', 2);
/**
* Defines an Y (vertical) axis
*/
define('IMAGE_GRAPH_AXIS_Y_SECONDARY', 3);
/**
* Defines an horizontal (X) axis
*/
define('IMAGE_GRAPH_AXIS_HORIZONTAL', 1);
/**
* Defines an vertical (Y) axis
*/
define('IMAGE_GRAPH_AXIS_VERTICAL', 2);
/**
* Define if label should be shown for axis minimum value
*/
define('IMAGE_GRAPH_LABEL_MINIMUM', 1);
/**
* Define if label should be shown for axis 0 (zero) value
*/
define('IMAGE_GRAPH_LABEL_ZERO', 2);
/**
* Define if label should be shown for axis maximum value
*/
define('IMAGE_GRAPH_LABEL_MAXIMUM', 4);
/**
* Defines a horizontal gradient fill
*/
define('IMAGE_GRAPH_GRAD_HORIZONTAL', 1);
/**
* Defines a vertical gradient fill
*/
define('IMAGE_GRAPH_GRAD_VERTICAL', 2);
/**
* Defines a horizontally mirrored gradient fill
*/
define('IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED', 3);
/**
* Defines a vertically mirrored gradient fill
*/
define('IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED', 4);
/**
* Defines a diagonal gradient fill from top-left to bottom-right
*/
define('IMAGE_GRAPH_GRAD_DIAGONALLY_TL_BR', 5);
/**
* Defines a diagonal gradient fill from bottom-left to top-right
*/
define('IMAGE_GRAPH_GRAD_DIAGONALLY_BL_TR', 6);
/**
* Defines a radial gradient fill
*/
define('IMAGE_GRAPH_GRAD_RADIAL', 7);
/**
* Defines the default builtin font
*/
define('IMAGE_GRAPH_FONT', 1);
/**
* Defines a X value should be used
*/
define('IMAGE_GRAPH_VALUE_X', 0);
/**
* Defines a Y value should be used
*/
define('IMAGE_GRAPH_VALUE_Y', 1);
/**
* Defines a min X% value should be used
*/
define('IMAGE_GRAPH_PCT_X_MIN', 2);
/**
* Defines a max X% value should be used
*/
define('IMAGE_GRAPH_PCT_X_MAX', 3);
/**
* Defines a min Y% value should be used
*/
define('IMAGE_GRAPH_PCT_Y_MIN', 4);
/**
* Defines a max Y% value should be used
*/
define('IMAGE_GRAPH_PCT_Y_MAX', 5);
/**
* Defines a total Y% value should be used
*/
define('IMAGE_GRAPH_PCT_Y_TOTAL', 6);
/**
* Defines a ID value should be used
*/
define('IMAGE_GRAPH_POINT_ID', 7);
/**
* Align text left
*/
define('IMAGE_GRAPH_ALIGN_LEFT', 0x1);
/**
* Align text right
*/
define('IMAGE_GRAPH_ALIGN_RIGHT', 0x2);
/**
* Align text center x (horizontal)
*/
define('IMAGE_GRAPH_ALIGN_CENTER_X', 0x4);
/**
* Align text top
*/
define('IMAGE_GRAPH_ALIGN_TOP', 0x8);
/**
* Align text bottom
*/
define('IMAGE_GRAPH_ALIGN_BOTTOM', 0x10);
/**
* Align text center y (vertical)
*/
define('IMAGE_GRAPH_ALIGN_CENTER_Y', 0x20);
/**
* Align text center (both x and y)
*/
define('IMAGE_GRAPH_ALIGN_CENTER', IMAGE_GRAPH_ALIGN_CENTER_X + IMAGE_GRAPH_ALIGN_CENTER_Y);
/**
* Align text top left
*/
define('IMAGE_GRAPH_ALIGN_TOP_LEFT', IMAGE_GRAPH_ALIGN_TOP + IMAGE_GRAPH_ALIGN_LEFT);
/**
* Align text top right
*/
define('IMAGE_GRAPH_ALIGN_TOP_RIGHT', IMAGE_GRAPH_ALIGN_TOP + IMAGE_GRAPH_ALIGN_RIGHT);
/**
* Align text bottom left
*/
define('IMAGE_GRAPH_ALIGN_BOTTOM_LEFT', IMAGE_GRAPH_ALIGN_BOTTOM + IMAGE_GRAPH_ALIGN_LEFT);
/**
* Align text bottom right
*/
define('IMAGE_GRAPH_ALIGN_BOTTOM_RIGHT', IMAGE_GRAPH_ALIGN_BOTTOM + IMAGE_GRAPH_ALIGN_RIGHT);
/**
* Align vertical
*/
define('IMAGE_GRAPH_ALIGN_VERTICAL', IMAGE_GRAPH_ALIGN_TOP);
/**
* Align horizontal
*/
define('IMAGE_GRAPH_ALIGN_HORIZONTAL', IMAGE_GRAPH_ALIGN_LEFT);
// Error codes
define('IMAGE_GRAPH_ERROR_GENERIC', 0);
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - Main class for the graph creation.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Font.php
*/
require_once 'Image/Graph/Font.php';
// Constant declarations
/**
* Defines an X (horizontal) axis
*/
define('IMAGE_GRAPH_AXIS_X', 1);
/**
* Defines an Y (vertical) axis
*/
define('IMAGE_GRAPH_AXIS_Y', 2);
/**
* Defines an Y (vertical) axis
*/
define('IMAGE_GRAPH_AXIS_Y_SECONDARY', 3);
/**
* Defines an horizontal (X) axis
*/
define('IMAGE_GRAPH_AXIS_HORIZONTAL', 1);
/**
* Defines an vertical (Y) axis
*/
define('IMAGE_GRAPH_AXIS_VERTICAL', 2);
/**
* Define if label should be shown for axis minimum value
*/
define('IMAGE_GRAPH_LABEL_MINIMUM', 1);
/**
* Define if label should be shown for axis 0 (zero) value
*/
define('IMAGE_GRAPH_LABEL_ZERO', 2);
/**
* Define if label should be shown for axis maximum value
*/
define('IMAGE_GRAPH_LABEL_MAXIMUM', 4);
/**
* Defines a horizontal gradient fill
*/
define('IMAGE_GRAPH_GRAD_HORIZONTAL', 1);
/**
* Defines a vertical gradient fill
*/
define('IMAGE_GRAPH_GRAD_VERTICAL', 2);
/**
* Defines a horizontally mirrored gradient fill
*/
define('IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED', 3);
/**
* Defines a vertically mirrored gradient fill
*/
define('IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED', 4);
/**
* Defines a diagonal gradient fill from top-left to bottom-right
*/
define('IMAGE_GRAPH_GRAD_DIAGONALLY_TL_BR', 5);
/**
* Defines a diagonal gradient fill from bottom-left to top-right
*/
define('IMAGE_GRAPH_GRAD_DIAGONALLY_BL_TR', 6);
/**
* Defines a radial gradient fill
*/
define('IMAGE_GRAPH_GRAD_RADIAL', 7);
/**
* Defines the default builtin font
*/
define('IMAGE_GRAPH_FONT', 1);
/**
* Defines a X value should be used
*/
define('IMAGE_GRAPH_VALUE_X', 0);
/**
* Defines a Y value should be used
*/
define('IMAGE_GRAPH_VALUE_Y', 1);
/**
* Defines a min X% value should be used
*/
define('IMAGE_GRAPH_PCT_X_MIN', 2);
/**
* Defines a max X% value should be used
*/
define('IMAGE_GRAPH_PCT_X_MAX', 3);
/**
* Defines a min Y% value should be used
*/
define('IMAGE_GRAPH_PCT_Y_MIN', 4);
/**
* Defines a max Y% value should be used
*/
define('IMAGE_GRAPH_PCT_Y_MAX', 5);
/**
* Defines a total Y% value should be used
*/
define('IMAGE_GRAPH_PCT_Y_TOTAL', 6);
/**
* Defines a ID value should be used
*/
define('IMAGE_GRAPH_POINT_ID', 7);
/**
* Align text left
*/
define('IMAGE_GRAPH_ALIGN_LEFT', 0x1);
/**
* Align text right
*/
define('IMAGE_GRAPH_ALIGN_RIGHT', 0x2);
/**
* Align text center x (horizontal)
*/
define('IMAGE_GRAPH_ALIGN_CENTER_X', 0x4);
/**
* Align text top
*/
define('IMAGE_GRAPH_ALIGN_TOP', 0x8);
/**
* Align text bottom
*/
define('IMAGE_GRAPH_ALIGN_BOTTOM', 0x10);
/**
* Align text center y (vertical)
*/
define('IMAGE_GRAPH_ALIGN_CENTER_Y', 0x20);
/**
* Align text center (both x and y)
*/
define('IMAGE_GRAPH_ALIGN_CENTER', IMAGE_GRAPH_ALIGN_CENTER_X + IMAGE_GRAPH_ALIGN_CENTER_Y);
/**
* Align text top left
*/
define('IMAGE_GRAPH_ALIGN_TOP_LEFT', IMAGE_GRAPH_ALIGN_TOP + IMAGE_GRAPH_ALIGN_LEFT);
/**
* Align text top right
*/
define('IMAGE_GRAPH_ALIGN_TOP_RIGHT', IMAGE_GRAPH_ALIGN_TOP + IMAGE_GRAPH_ALIGN_RIGHT);
/**
* Align text bottom left
*/
define('IMAGE_GRAPH_ALIGN_BOTTOM_LEFT', IMAGE_GRAPH_ALIGN_BOTTOM + IMAGE_GRAPH_ALIGN_LEFT);
/**
* Align text bottom right
*/
define('IMAGE_GRAPH_ALIGN_BOTTOM_RIGHT', IMAGE_GRAPH_ALIGN_BOTTOM + IMAGE_GRAPH_ALIGN_RIGHT);
/**
* Align vertical
*/
define('IMAGE_GRAPH_ALIGN_VERTICAL', IMAGE_GRAPH_ALIGN_TOP);
/**
* Align horizontal
*/
define('IMAGE_GRAPH_ALIGN_HORIZONTAL', IMAGE_GRAPH_ALIGN_LEFT);
// Error codes
define('IMAGE_GRAPH_ERROR_GENERIC', 0);
?>

View File

@ -1,74 +1,74 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Data preprocessor used for preformatting a data.
*
* 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
* 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
* with 1 decimal digit instead of the default formatting (fx. 12.01271 -> 12.0%).
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
* @abstract
*/
class Image_Graph_DataPreprocessor
{
/**
* Image_Graph_DataPreprocessor [Constructor].
*/
function Image_Graph_DataPreprocessor()
{
}
/**
* Process the value
*
* @param var $value The value to process/format
* @return string The processed value
* @access private
*/
function _process($value)
{
return $value;
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Data preprocessor used for preformatting a data.
*
* 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
* 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
* with 1 decimal digit instead of the default formatting (fx. 12.01271 -> 12.0%).
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
* @abstract
*/
class Image_Graph_DataPreprocessor
{
/**
* Image_Graph_DataPreprocessor [Constructor].
*/
function Image_Graph_DataPreprocessor()
{
}
/**
* Process the value
*
* @param var $value The value to process/format
* @return string The processed value
* @access private
*/
function _process($value)
{
return $value;
}
}
?>

View File

@ -1,103 +1,103 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataPreprocessor.php
*/
require_once 'Image/Graph/DataPreprocessor.php';
/**
* Format data as looked up in an array.
*
* ArrayData is useful when a numercal value is to be translated to
* 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-
* 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'
* 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
* 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
* 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
* 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
* instead of using the unix-timestamp we use value 0 to represent the 1st date,
* 1 to represent the next date, etc.
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataPreprocessor_Array extends Image_Graph_DataPreprocessor
{
/**
* The data label array
* @var array
* @access private
*/
var $_dataArray;
/**
* Image_Graph_ArrayData [Constructor].
*
* @param array $array The array to use as a lookup table
*/
function Image_Graph_DataPreprocessor_Array($array)
{
parent::Image_Graph_DataPreprocessor();
$this->_dataArray = $array;
}
/**
* Process the value
*
* @param var $value The value to process/format
* @return string The processed value
* @access private
*/
function _process($value)
{
if ((is_array($this->_dataArray)) && (isset ($this->_dataArray[$value]))) {
return $this->_dataArray[$value];
} else {
return $value;
}
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataPreprocessor.php
*/
require_once 'Image/Graph/DataPreprocessor.php';
/**
* Format data as looked up in an array.
*
* ArrayData is useful when a numercal value is to be translated to
* 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-
* 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'
* 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
* 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
* 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
* 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
* instead of using the unix-timestamp we use value 0 to represent the 1st date,
* 1 to represent the next date, etc.
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataPreprocessor_Array extends Image_Graph_DataPreprocessor
{
/**
* The data label array
* @var array
* @access private
*/
var $_dataArray;
/**
* Image_Graph_ArrayData [Constructor].
*
* @param array $array The array to use as a lookup table
*/
function Image_Graph_DataPreprocessor_Array($array)
{
parent::Image_Graph_DataPreprocessor();
$this->_dataArray = $array;
}
/**
* Process the value
*
* @param var $value The value to process/format
* @return string The processed value
* @access private
*/
function _process($value)
{
if ((is_array($this->_dataArray)) && (isset ($this->_dataArray[$value]))) {
return $this->_dataArray[$value];
} else {
return $value;
}
}
}
?>

View File

@ -1,66 +1,66 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataPreprocessor/Formatted.php
*/
require_once 'Image/Graph/DataPreprocessor/Formatted.php';
/**
* Format data as a currency.
*
* Uses the {@link Image_Graph_DataPreprocessor_Formatted} to represent the
* values as a currency, i.e. 10 => 10.00
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataPreprocessor_Currency extends Image_Graph_DataPreprocessor_Formatted
{
/**
* Image_Graph_CurrencyData [Constructor].
*
* @param string $currencySymbol The symbol representing the currency
*/
function Image_Graph_DataPreprocessor_Currency($currencySymbol)
{
parent::Image_Graph_DataPreprocessor_Formatted("$currencySymbol %0.2f");
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataPreprocessor/Formatted.php
*/
require_once 'Image/Graph/DataPreprocessor/Formatted.php';
/**
* Format data as a currency.
*
* Uses the {@link Image_Graph_DataPreprocessor_Formatted} to represent the
* values as a currency, i.e. 10 => 10.00
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataPreprocessor_Currency extends Image_Graph_DataPreprocessor_Formatted
{
/**
* Image_Graph_CurrencyData [Constructor].
*
* @param string $currencySymbol The symbol representing the currency
*/
function Image_Graph_DataPreprocessor_Currency($currencySymbol)
{
parent::Image_Graph_DataPreprocessor_Formatted("$currencySymbol %0.2f");
}
}
?>

View File

@ -1,90 +1,90 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataPreprocessor.php
*/
require_once 'Image/Graph/DataPreprocessor.php';
/**
* Formats Unix timestamp as a date using specified format.
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataPreprocessor_Date extends Image_Graph_DataPreprocessor
{
/**
* The format of the Unix time stamp.
* See <a href = 'http://www.php.net/manual/en/function.date.php'>PHP
* Manual</a> for a description
* @var string
* @access private
*/
var $_format;
/**
* Create a DateData preprocessor [Constructor]
*
* @param string $format See {@link http://www.php.net/manual/en/function.date.php
* PHP Manual} for a description
*/
function Image_Graph_DataPreprocessor_Date($format)
{
parent::Image_Graph_DataPreprocessor();
$this->_format = $format;
}
/**
* Process the value
*
* @param var $value The value to process/format
* @return string The processed value
* @access private
*/
function _process($value)
{
if (!$value) {
return false;
} else {
return date($this->_format, $value);
}
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataPreprocessor.php
*/
require_once 'Image/Graph/DataPreprocessor.php';
/**
* Formats Unix timestamp as a date using specified format.
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataPreprocessor_Date extends Image_Graph_DataPreprocessor
{
/**
* The format of the Unix time stamp.
* See <a href = 'http://www.php.net/manual/en/function.date.php'>PHP
* Manual</a> for a description
* @var string
* @access private
*/
var $_format;
/**
* Create a DateData preprocessor [Constructor]
*
* @param string $format See {@link http://www.php.net/manual/en/function.date.php
* PHP Manual} for a description
*/
function Image_Graph_DataPreprocessor_Date($format)
{
parent::Image_Graph_DataPreprocessor();
$this->_format = $format;
}
/**
* Process the value
*
* @param var $value The value to process/format
* @return string The processed value
* @access private
*/
function _process($value)
{
if (!$value) {
return false;
} else {
return date($this->_format, $value);
}
}
}
?>

View File

@ -1,90 +1,90 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataPreprocessor.php
*/
require_once 'Image/Graph/DataPreprocessor.php';
/**
* Format data using a (s)printf pattern.
*
* 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.
* sprintf.php PHP manual}
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataPreprocessor_Formatted extends Image_Graph_DataPreprocessor
{
/**
* A (s)printf format string.
* See {@link http://www.php.net/manual/en/function.sprintf.php PHP Manual}
* for a description
* @var string
* @access private
*/
var $_format;
/**
* Create a (s)printf format data preprocessor
*
* @param string $format See {@link http://www.php.net/manual/en/function.sprintf.php
* PHP Manual} for a description
*/
function Image_Graph_DataPreprocessor_Formatted($format)
{
parent::Image_Graph_DataPreprocessor();
$this->_format = $format;
}
/**
* Process the value
*
* @param var $value The value to process/format
* @return string The processed value
* @access private
*/
function _process($value)
{
return sprintf($this->_format, $value);
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataPreprocessor.php
*/
require_once 'Image/Graph/DataPreprocessor.php';
/**
* Format data using a (s)printf pattern.
*
* 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.
* sprintf.php PHP manual}
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataPreprocessor_Formatted extends Image_Graph_DataPreprocessor
{
/**
* A (s)printf format string.
* See {@link http://www.php.net/manual/en/function.sprintf.php PHP Manual}
* for a description
* @var string
* @access private
*/
var $_format;
/**
* Create a (s)printf format data preprocessor
*
* @param string $format See {@link http://www.php.net/manual/en/function.sprintf.php
* PHP Manual} for a description
*/
function Image_Graph_DataPreprocessor_Formatted($format)
{
parent::Image_Graph_DataPreprocessor();
$this->_format = $format;
}
/**
* Process the value
*
* @param var $value The value to process/format
* @return string The processed value
* @access private
*/
function _process($value)
{
return sprintf($this->_format, $value);
}
}
?>

View File

@ -1,92 +1,92 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataPreprocessor.php
*/
require_once 'Image/Graph/DataPreprocessor.php';
/**
* Formatting a value using a userdefined function.
*
* 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
* 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
* and use the FunctionData datapreprocessor to make Image_Graph use this function.
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataPreprocessor_Function extends Image_Graph_DataPreprocessor
{
/**
* The name of the PHP function
* @var string
* @access private
*/
var $_dataFunction;
/**
* Create a FunctionData preprocessor
*
* @param string $function The name of the PHP function to use as
* a preprocessor, this function must take a single parameter and return a
* formatted version of this parameter
*/
function Image_Graph_DataPreprocessor_Function($function)
{
parent::Image_Graph_DataPreprocessor();
$this->_dataFunction = $function;
}
/**
* Process the value
*
* @param var $value The value to process/format
* @return string The processed value
* @access private
*/
function _process($value)
{
$function = $this->_dataFunction;
return $function ($value);
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: Function.php,v 1.7 2005/11/11 17:53:44 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataPreprocessor.php
*/
require_once 'Image/Graph/DataPreprocessor.php';
/**
* Formatting a value using a userdefined function.
*
* 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
* 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
* and use the FunctionData datapreprocessor to make Image_Graph use this function.
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataPreprocessor_Function extends Image_Graph_DataPreprocessor
{
/**
* The name of the PHP function
* @var string
* @access private
*/
var $_dataFunction;
/**
* Create a FunctionData preprocessor
*
* @param string $function The name of the PHP function to use as
* a preprocessor, this function must take a single parameter and return a
* formatted version of this parameter
*/
function Image_Graph_DataPreprocessor_Function($function)
{
parent::Image_Graph_DataPreprocessor();
$this->_dataFunction = $function;
}
/**
* Process the value
*
* @param var $value The value to process/format
* @return string The processed value
* @access private
*/
function _process($value)
{
$function = $this->_dataFunction;
return call_user_func($function, $value);
}
}
?>

View File

@ -1,89 +1,89 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataPreprocessor.php
*/
require_once 'Image/Graph/DataPreprocessor.php';
/**
* 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.
* Requires Numbers_Words
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataPreprocessor_NumberText extends Image_Graph_DataPreprocessor
{
/**
* The language identifier
* @var string
* @access private
*/
var $_language;
/**
* Image_Graph_NumberText [Constructor].
*
* Supported languages see {@link http://pear.php.net/package/Numbers_Words Numbers_Words}
*
* @param string $langugage The language identifier for the language.
*/
function Image_Graph_DataPreprocessor_NumberText($language = 'en_US')
{
parent::Image_Graph_DataPreprocessor();
$this->_language = $language;
require_once 'Numbers/Words.php';
}
/**
* Process the value
*
* @param var $value The value to process/format
* @return string The processed value
* @access private
*/
function _process($value)
{
return Numbers_Words::toWords($value, $this->_language);
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataPreprocessor.php
*/
require_once 'Image/Graph/DataPreprocessor.php';
/**
* 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.
* Requires Numbers_Words
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataPreprocessor_NumberText extends Image_Graph_DataPreprocessor
{
/**
* The language identifier
* @var string
* @access private
*/
var $_language;
/**
* Image_Graph_NumberText [Constructor].
*
* Supported languages see {@link http://pear.php.net/package/Numbers_Words Numbers_Words}
*
* @param string $langugage The language identifier for the language.
*/
function Image_Graph_DataPreprocessor_NumberText($language = 'en_US')
{
parent::Image_Graph_DataPreprocessor();
$this->_language = $language;
require_once 'Numbers/Words.php';
}
/**
* Process the value
*
* @param var $value The value to process/format
* @return string The processed value
* @access private
*/
function _process($value)
{
return Numbers_Words::toWords($value, $this->_language);
}
}
?>

View File

@ -1,79 +1,79 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataPreprocessor.php
*/
require_once 'Image/Graph/DataPreprocessor.php';
/**
* Formatting a value as a roman numerals.
*
* Values are formatted as roman numeral, i.e. 1 = I, 2 = II, 9 = IX, 2004 = MMIV.
* Requires Numbers_Roman
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataPreprocessor_RomanNumerals extends Image_Graph_DataPreprocessor
{
/**
* Create a RomanNumerals preprocessor
*
* See {@link http://pear.php.net/package/Numbers_Roman Numbers_Roman}
*/
function Image_Graph_DataPreprocessor_RomanNumerals()
{
parent::Image_Graph_DataPreprocessor();
include_once 'Numbers/Roman.php';
}
/**
* Process the value
*
* @param var $value The value to process/format
* @return string The processed value
* @access private
*/
function _process($value)
{
return Numbers_Roman::toNumeral($value);
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataPreprocessor.php
*/
require_once 'Image/Graph/DataPreprocessor.php';
/**
* Formatting a value as a roman numerals.
*
* Values are formatted as roman numeral, i.e. 1 = I, 2 = II, 9 = IX, 2004 = MMIV.
* Requires Numbers_Roman
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataPreprocessor_RomanNumerals extends Image_Graph_DataPreprocessor
{
/**
* Create a RomanNumerals preprocessor
*
* See {@link http://pear.php.net/package/Numbers_Roman Numbers_Roman}
*/
function Image_Graph_DataPreprocessor_RomanNumerals()
{
parent::Image_Graph_DataPreprocessor();
include_once 'Numbers/Roman.php';
}
/**
* Process the value
*
* @param var $value The value to process/format
* @return string The processed value
* @access private
*/
function _process($value)
{
return Numbers_Roman::toNumeral($value);
}
}
?>

View File

@ -1,67 +1,67 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataPreprocessor/Array.php
*/
require_once 'Image/Graph/DataPreprocessor/Array.php';
/**
* Formatting values using a sequential data label array, ie. returning the
* 'next label' when asked for any label.
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataPreprocessor_Sequential extends Image_Graph_DataPreprocessor_Array
{
/**
* Process the value
*
* @param var $value The value to process/format
* @return string The processed value
* @access private
*/
function _process($value)
{
list ($id, $value) = each($this->_dataArray);
return $value;
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataPreprocessor/Array.php
*/
require_once 'Image/Graph/DataPreprocessor/Array.php';
/**
* Formatting values using a sequential data label array, ie. returning the
* 'next label' when asked for any label.
*
* @category Images
* @package Image_Graph
* @subpackage DataPreprocessor
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataPreprocessor_Sequential extends Image_Graph_DataPreprocessor_Array
{
/**
* Process the value
*
* @param var $value The value to process/format
* @return string The processed value
* @access private
*/
function _process($value)
{
list ($id, $value) = each($this->_dataArray);
return $value;
}
}
?>

View File

@ -1,67 +1,67 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Filter used for selecting which data to show as markers
*
* @category Images
* @package Image_Graph
* @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataSelector
{
/**
* Image_Graph_DataSelector [Constructor]
*/
function Image_Graph_DataSelector()
{
}
/**
* Check if a specified value should be 'selected', ie shown as a marker
*
* @param array $values The values to check
* @return bool True if the Values should cause a marker to be shown, false if not
* @access private
*/
function _select($values)
{
return true;
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Filter used for selecting which data to show as markers
*
* @category Images
* @package Image_Graph
* @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataSelector
{
/**
* Image_Graph_DataSelector [Constructor]
*/
function Image_Graph_DataSelector()
{
}
/**
* Check if a specified value should be 'selected', ie shown as a marker
*
* @param array $values The values to check
* @return bool True if the Values should cause a marker to be shown, false if not
* @access private
*/
function _select($values)
{
return true;
}
}
?>

View File

@ -1,97 +1,97 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataSelector.php
*/
require_once 'Image/Graph/DataSelector.php';
/**
* Filter out all points except every Nth point.
*
* 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.
*
* @category Images
* @package Image_Graph
* @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataSelector_EveryNthPoint extends Image_Graph_DataSelector
{
/**
* The number of points checked
* @var int
* @access private
*/
var $_pointNum = 0;
/**
* The number of points between every 'show', default: 10
* @var int
* @access private
*/
var $_pointInterval = 10;
/**
* EvertNthPoint [Constructor]
*
* @param int $pointInterval The number of points between every 'show',
* default: 10
*/
function Image_Graph_DataSelector_EveryNthpoint($pointInterval = 10)
{
parent::Image_Graph_DataSelector();
$this->_pointInterval = $pointInterval;
}
/**
* Check if a specified value should be 'selected', ie shown as a marker
*
* @param array $values The values to check
* @return bool True if the Values should cause a marker to be shown,
* false if not
* @access private
*/
function _select($values)
{
$oldPointNum = $this->_pointNum;
$this->_pointNum++;
return (($oldPointNum % $this->_pointInterval) == 0);
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataSelector.php
*/
require_once 'Image/Graph/DataSelector.php';
/**
* Filter out all points except every Nth point.
*
* 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.
*
* @category Images
* @package Image_Graph
* @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataSelector_EveryNthPoint extends Image_Graph_DataSelector
{
/**
* The number of points checked
* @var int
* @access private
*/
var $_pointNum = 0;
/**
* The number of points between every 'show', default: 10
* @var int
* @access private
*/
var $_pointInterval = 10;
/**
* EvertNthPoint [Constructor]
*
* @param int $pointInterval The number of points between every 'show',
* default: 10
*/
function Image_Graph_DataSelector_EveryNthpoint($pointInterval = 10)
{
parent::Image_Graph_DataSelector();
$this->_pointInterval = $pointInterval;
}
/**
* Check if a specified value should be 'selected', ie shown as a marker
*
* @param array $values The values to check
* @return bool True if the Values should cause a marker to be shown,
* false if not
* @access private
*/
function _select($values)
{
$oldPointNum = $this->_pointNum;
$this->_pointNum++;
return (($oldPointNum % $this->_pointInterval) == 0);
}
}
?>

View File

@ -1,68 +1,68 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataSelector.php
*/
require_once 'Image/Graph/DataSelector.php';
/**
* Filter out all zero's.
*
* Display all Y-values as markers, except those with Y = 0
*
* @category Images
* @package Image_Graph
* @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataSelector_NoZeros extends Image_Graph_DataSelector
{
/**
* Check if a specified value should be 'selected', ie shown as a marker
*
* @param array $values The values to check
* @return bool True if the Values should cause a marker to be shown, false
* if not
* @access private
*/
function _select($values)
{
return ($values['Y'] != 0);
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataSelector.php
*/
require_once 'Image/Graph/DataSelector.php';
/**
* Filter out all zero's.
*
* Display all Y-values as markers, except those with Y = 0
*
* @category Images
* @package Image_Graph
* @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataSelector_NoZeros extends Image_Graph_DataSelector
{
/**
* Check if a specified value should be 'selected', ie shown as a marker
*
* @param array $values The values to check
* @return bool True if the Values should cause a marker to be shown, false
* if not
* @access private
*/
function _select($values)
{
return ($values['Y'] != 0);
}
}
?>

View File

@ -1,90 +1,90 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataSelector.php
*/
require_once 'Image/Graph/DataSelector.php';
/**
* Filter out all but the specified values.
*
* @category Images
* @package Image_Graph
* @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataSelector_Values extends Image_Graph_DataSelector {
/**
* The array with values that should be included
* @var array
* @access private
*/
var $_values;
/**
* ValueArray [Constructor]
*
* @param array $valueArray The array to use as filter (default empty)
*/
function &Image_Graph_DataSelector_Values($values)
{
parent::Image_Graph_DataSelector();
$this->_values = $values;
}
/**
* Sets the array to use
*/
function setValueArray($values)
{
$this->_values = $values;
}
/**
* Check if a specified value should be 'selected', ie shown as a marker
*
* @param array $values The values to check
* @return bool True if the Values should cause a marker to be shown, false
* if not
* @access private
*/
function _select($values)
{
return ( in_array($values['Y'], $this->_values) );
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/DataSelector.php
*/
require_once 'Image/Graph/DataSelector.php';
/**
* Filter out all but the specified values.
*
* @category Images
* @package Image_Graph
* @subpackage DataSelector
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_DataSelector_Values extends Image_Graph_DataSelector {
/**
* The array with values that should be included
* @var array
* @access private
*/
var $_values;
/**
* ValueArray [Constructor]
*
* @param array $valueArray The array to use as filter (default empty)
*/
function &Image_Graph_DataSelector_Values($values)
{
parent::Image_Graph_DataSelector();
$this->_values = $values;
}
/**
* Sets the array to use
*/
function setValueArray($values)
{
$this->_values = $values;
}
/**
* Check if a specified value should be 'selected', ie shown as a marker
*
* @param array $values The values to check
* @return bool True if the Values should cause a marker to be shown, false
* if not
* @access private
*/
function _select($values)
{
return ( in_array($values['Y'], $this->_values) );
}
}
?>

View File

@ -1,483 +1,483 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Data set used to represent a data collection to plot in a chart
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
* @abstract
*/
class Image_Graph_Dataset
{
/**
* The pointer of the data set
* @var int
* @access private
*/
var $_posX = 0;
/**
* The minimum X value of the dataset
* @var int
* @access private
*/
var $_minimumX = 0;
/**
* The maximum X value of the dataset
* @var int
* @access private
*/
var $_maximumX = 0;
/**
* The minimum Y value of the dataset
* @var int
* @access private
*/
var $_minimumY = 0;
/**
* The maximum Y value of the dataset
* @var int
* @access private
*/
var $_maximumY = 0;
/**
* The number of points in the dataset
* @var int
* @access private
*/
var $_count = 0;
/**
* The name of the dataset, used for legending
* @var string
* @access private
*/
var $_name = '';
/**
* Image_Graph_Dataset [Constructor]
*/
function Image_Graph_Dataset()
{
}
/**
* Sets the name of the data set, used for legending
*
* @param string $name The name of the dataset
*/
function setName($name)
{
$this->_name = $name;
}
/**
* 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
* values used for creation of the HTML image map. This is achieved using is an an associated array
* with the following values:
*
* 'url' The URL to create the link to
*
* 'alt' [optional] The alt text on 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'
*
* @param int $x The X value to add
* @param int $y The Y value to add, can be omited
* @param var $ID The ID of the point
*/
function addPoint($x, $y = false, $ID = false)
{
if ($y !== null) {
if (is_array($y)) {
$maxY = max($y);
$minY = min($y);
} else {
$maxY = $y;
$minY = $y;
}
}
if ($this->_count) {
$this->_minimumX = min($x, $this->_minimumX);
$this->_maximumX = max($x, $this->_maximumX);
if ($y !== null) {
$this->_minimumY = min($minY, $this->_minimumY);
$this->_maximumY = max($maxY, $this->_maximumY);
}
} else {
$this->_minimumX = $x;
$this->_maximumX = $x;
if ($y !== null) {
$this->_minimumY = $minY;
$this->_maximumY = $maxY;
}
}
$this->_count++;
}
/**
* The number of values in the dataset
*
* @return int The number of values in the dataset
*/
function count()
{
return $this->_count;
}
/**
* Gets a X point from the dataset
*
* @param var $x The variable to return an X value from, fx in a vector
* function data set
* @return var The X value of the variable
* @access private
*/
function _getPointX($x)
{
return $x;
}
/**
* Gets a Y point from the dataset
*
* @param var $x The variable to return an Y value from, fx in a vector
* function data set
* @return var The Y value of the variable
* @access private
*/
function _getPointY($x)
{
return $x;
}
/**
* Gets a ID from the dataset
*
* @param var $x The variable to return an Y value from, fx in a vector
* function data set
* @return var The ID value of the variable
* @access private
*/
function _getPointID($x)
{
return false;
}
/**
* Gets point data from the dataset
*
* @param var $x The variable to return an Y value from, fx in a vector
* function data set
* @return array The data for the point
* @access private
*/
function _getPointData($x)
{
return false;
}
/**
* The minimum X value
*
* @return var The minimum X value
*/
function minimumX()
{
return $this->_minimumX;
}
/**
* The maximum X value
*
* @return var The maximum X value
*/
function maximumX()
{
return $this->_maximumX;
}
/**
* The minimum Y value
*
* @return var The minimum Y value
*/
function minimumY()
{
return $this->_minimumY;
}
/**
* The maximum Y value
*
* @return var The maximum Y value
*/
function maximumY()
{
return $this->_maximumY;
}
/**
* The first point
*
* @return array The last point
*/
function first()
{
return array('X' => $this->minimumX(), 'Y' => $this->minimumY());
}
/**
* The last point
*
* @return array The first point
*/
function last()
{
return array('X' => $this->maximumX(), 'Y' => $this->maximumY());
}
/**
* The minimum X value
*
* @param var $value The minimum X value
* @access private
*/
function _setMinimumX($value)
{
$this->_minimumX = $value;
}
/**
* The maximum X value
*
* @param var $value The maximum X value
* @access private
*/
function _setMaximumX($value)
{
$this->_maximumX = $value;
}
/**
* The minimum Y value
*
* @param var $value The minimum X value
* @access private
*/
function _setMinimumY($value)
{
$this->_minimumY = $value;
}
/**
* The maximum Y value
*
* @param var $value The maximum X value
* @access private
*/
function _setMaximumY($value)
{
$this->_maximumY = $value;
}
/**
* The interval between 2 adjacent X values
*
* @return var The interval
* @access private
*/
function _stepX()
{
return 1;
}
/**
* The interval between 2 adjacent Y values
*
* @return var The interval
* @access private
*/
function _stepY()
{
return 1;
}
/**
* Reset the intertal dataset pointer
*
* @return var The first X value
* @access private
*/
function _reset()
{
$this->_posX = $this->_minimumX;
return $this->_posX;
}
/**
* Get a point close to the internal pointer
*
* @param int Step Number of points next to the internal pointer, negative
* Step is towards lower X values, positive towards higher X values
* @return array The point
* @access private
*/
function _nearby($step = 0)
{
$x = $this->_getPointX($this->_posX + $this->_stepX() * $step);
$y = $this->_getPointY($this->_posX + $this->_stepX() * $step);
$ID = $this->_getPointID($this->_posX + $this->_stepX() * $step);
$data = $this->_getPointData($this->_posX + $this->_stepX() * $step);
if (($x === false) || ($y === false)) {
return false;
} else {
return array ('X' => $x, 'Y' => $y, 'ID' => $ID, 'data' => $data);
}
}
/**
* Get the next point the internal pointer refers to and advance the pointer
*
* @return array The next point
* @access private
*/
function _next()
{
if ($this->_posX > $this->_maximumX) {
return false;
}
$x = $this->_getPointX($this->_posX);
$y = $this->_getPointY($this->_posX);
$ID = $this->_getPointID($this->_posX);
$data = $this->_getPointData($this->_posX);
$this->_posX += $this->_stepX();
return array ('X' => $x, 'Y' => $y, 'ID' => $ID, 'data' => $data);
}
/**
* Get the average of the dataset's Y points
*
* @return var The Y-average across the dataset
* @access private
*/
function _averageY()
{
$posX = $this->_minimumX;
$count = 0;
$total = 0;
while ($posX < $this->_maximumX) {
$count ++;
$total += $this->_getPointY($posX);
$posX += $this->_stepX();
}
if ($count != 0) {
return $total / $count;
} else {
return false;
}
}
/**
* Get the median of the array passed Y points
*
* @param array $data The data-array to get 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
* @access private
*/
function _median($data, $quartile = 'second')
{
sort($data);
$point = (count($data) - 1) / 2;
if ($quartile == 'first') {
$lowPoint = 0;
$highPoint = floor($point);
} elseif ($quartile == 'third') {
$lowPoint = round($point);
$highPoint = count($data) - 1;
} else {
$lowPoint = 0;
$highPoint = count($data) - 1;
}
$point = ($lowPoint + $highPoint) / 2;
if (floor($point) != $point) {
$point = floor($point);
return ($data[$point] + $data[($point + 1)]) / 2;
} else {
return $data[$point];
}
}
/**
* Get the median of the datasets Y points
*
* @param int $quartile The quartile to return the median from
* @return var The Y-median across the dataset from the specified quartile
* @access private
*/
function _medianY($quartile = 'second')
{
$pointsY = array();
$posX = $this->_minimumX;
while ($posX <= $this->_maximumX) {
$pointsY[] = $this->_getPointY($posX);
$posX += $this->_stepX();
}
return $this->_median($pointsY, $quartile);
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Data set used to represent a data collection to plot in a chart
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
* @abstract
*/
class Image_Graph_Dataset
{
/**
* The pointer of the data set
* @var int
* @access private
*/
var $_posX = 0;
/**
* The minimum X value of the dataset
* @var int
* @access private
*/
var $_minimumX = 0;
/**
* The maximum X value of the dataset
* @var int
* @access private
*/
var $_maximumX = 0;
/**
* The minimum Y value of the dataset
* @var int
* @access private
*/
var $_minimumY = 0;
/**
* The maximum Y value of the dataset
* @var int
* @access private
*/
var $_maximumY = 0;
/**
* The number of points in the dataset
* @var int
* @access private
*/
var $_count = 0;
/**
* The name of the dataset, used for legending
* @var string
* @access private
*/
var $_name = '';
/**
* Image_Graph_Dataset [Constructor]
*/
function Image_Graph_Dataset()
{
}
/**
* Sets the name of the data set, used for legending
*
* @param string $name The name of the dataset
*/
function setName($name)
{
$this->_name = $name;
}
/**
* 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
* values used for creation of the HTML image map. This is achieved using is an an associated array
* with the following values:
*
* 'url' The URL to create the link to
*
* 'alt' [optional] The alt text on 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'
*
* @param int $x The X value to add
* @param int $y The Y value to add, can be omited
* @param var $ID The ID of the point
*/
function addPoint($x, $y = false, $ID = false)
{
if ($y !== null) {
if (is_array($y)) {
$maxY = max($y);
$minY = min($y);
} else {
$maxY = $y;
$minY = $y;
}
}
if ($this->_count) {
$this->_minimumX = min($x, $this->_minimumX);
$this->_maximumX = max($x, $this->_maximumX);
if ($y !== null) {
$this->_minimumY = min($minY, $this->_minimumY);
$this->_maximumY = max($maxY, $this->_maximumY);
}
} else {
$this->_minimumX = $x;
$this->_maximumX = $x;
if ($y !== null) {
$this->_minimumY = $minY;
$this->_maximumY = $maxY;
}
}
$this->_count++;
}
/**
* The number of values in the dataset
*
* @return int The number of values in the dataset
*/
function count()
{
return $this->_count;
}
/**
* Gets a X point from the dataset
*
* @param var $x The variable to return an X value from, fx in a vector
* function data set
* @return var The X value of the variable
* @access private
*/
function _getPointX($x)
{
return $x;
}
/**
* Gets a Y point from the dataset
*
* @param var $x The variable to return an Y value from, fx in a vector
* function data set
* @return var The Y value of the variable
* @access private
*/
function _getPointY($x)
{
return $x;
}
/**
* Gets a ID from the dataset
*
* @param var $x The variable to return an Y value from, fx in a vector
* function data set
* @return var The ID value of the variable
* @access private
*/
function _getPointID($x)
{
return false;
}
/**
* Gets point data from the dataset
*
* @param var $x The variable to return an Y value from, fx in a vector
* function data set
* @return array The data for the point
* @access private
*/
function _getPointData($x)
{
return false;
}
/**
* The minimum X value
*
* @return var The minimum X value
*/
function minimumX()
{
return $this->_minimumX;
}
/**
* The maximum X value
*
* @return var The maximum X value
*/
function maximumX()
{
return $this->_maximumX;
}
/**
* The minimum Y value
*
* @return var The minimum Y value
*/
function minimumY()
{
return $this->_minimumY;
}
/**
* The maximum Y value
*
* @return var The maximum Y value
*/
function maximumY()
{
return $this->_maximumY;
}
/**
* The first point
*
* @return array The last point
*/
function first()
{
return array('X' => $this->minimumX(), 'Y' => $this->minimumY());
}
/**
* The last point
*
* @return array The first point
*/
function last()
{
return array('X' => $this->maximumX(), 'Y' => $this->maximumY());
}
/**
* The minimum X value
*
* @param var $value The minimum X value
* @access private
*/
function _setMinimumX($value)
{
$this->_minimumX = $value;
}
/**
* The maximum X value
*
* @param var $value The maximum X value
* @access private
*/
function _setMaximumX($value)
{
$this->_maximumX = $value;
}
/**
* The minimum Y value
*
* @param var $value The minimum X value
* @access private
*/
function _setMinimumY($value)
{
$this->_minimumY = $value;
}
/**
* The maximum Y value
*
* @param var $value The maximum X value
* @access private
*/
function _setMaximumY($value)
{
$this->_maximumY = $value;
}
/**
* The interval between 2 adjacent X values
*
* @return var The interval
* @access private
*/
function _stepX()
{
return 1;
}
/**
* The interval between 2 adjacent Y values
*
* @return var The interval
* @access private
*/
function _stepY()
{
return 1;
}
/**
* Reset the intertal dataset pointer
*
* @return var The first X value
* @access private
*/
function _reset()
{
$this->_posX = $this->_minimumX;
return $this->_posX;
}
/**
* Get a point close to the internal pointer
*
* @param int Step Number of points next to the internal pointer, negative
* Step is towards lower X values, positive towards higher X values
* @return array The point
* @access private
*/
function _nearby($step = 0)
{
$x = $this->_getPointX($this->_posX + $this->_stepX() * $step);
$y = $this->_getPointY($this->_posX + $this->_stepX() * $step);
$ID = $this->_getPointID($this->_posX + $this->_stepX() * $step);
$data = $this->_getPointData($this->_posX + $this->_stepX() * $step);
if (($x === false) || ($y === false)) {
return false;
} else {
return array ('X' => $x, 'Y' => $y, 'ID' => $ID, 'data' => $data);
}
}
/**
* Get the next point the internal pointer refers to and advance the pointer
*
* @return array The next point
* @access private
*/
function _next()
{
if ($this->_posX > $this->_maximumX) {
return false;
}
$x = $this->_getPointX($this->_posX);
$y = $this->_getPointY($this->_posX);
$ID = $this->_getPointID($this->_posX);
$data = $this->_getPointData($this->_posX);
$this->_posX += $this->_stepX();
return array ('X' => $x, 'Y' => $y, 'ID' => $ID, 'data' => $data);
}
/**
* Get the average of the dataset's Y points
*
* @return var The Y-average across the dataset
* @access private
*/
function _averageY()
{
$posX = $this->_minimumX;
$count = 0;
$total = 0;
while ($posX < $this->_maximumX) {
$count ++;
$total += $this->_getPointY($posX);
$posX += $this->_stepX();
}
if ($count != 0) {
return $total / $count;
} else {
return false;
}
}
/**
* Get the median of the array passed Y points
*
* @param array $data The data-array to get 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
* @access private
*/
function _median($data, $quartile = 'second')
{
sort($data);
$point = (count($data) - 1) / 2;
if ($quartile == 'first') {
$lowPoint = 0;
$highPoint = floor($point);
} elseif ($quartile == 'third') {
$lowPoint = round($point);
$highPoint = count($data) - 1;
} else {
$lowPoint = 0;
$highPoint = count($data) - 1;
}
$point = ($lowPoint + $highPoint) / 2;
if (floor($point) != $point) {
$point = floor($point);
return ($data[$point] + $data[($point + 1)]) / 2;
} else {
return $data[$point];
}
}
/**
* Get the median of the datasets Y points
*
* @param int $quartile The quartile to return the median from
* @return var The Y-median across the dataset from the specified quartile
* @access private
*/
function _medianY($quartile = 'second')
{
$pointsY = array();
$posX = $this->_minimumX;
while ($posX <= $this->_maximumX) {
$pointsY[] = $this->_getPointY($posX);
$posX += $this->_stepX();
}
return $this->_median($pointsY, $quartile);
}
}
?>

View File

@ -1,147 +1,147 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Dataset.php
*/
require_once 'Image/Graph/Dataset.php';
/**
* Function data set, points are generated by calling an external function.
*
* 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
* used if they are such, i.e: function myFunction($variable)
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Dataset_Function extends Image_Graph_Dataset
{
/**
* The name of the function
* @var string
* @access private
*/
var $_dataFunction;
/**
* Image_Graph_FunctionDataset [Constructor]
*
* @param double $minimumX The minimum X value
* @param double $maximumX The maximum X value
* @param string $function The name of the function, if must be a single
* parameter function like fx sin(x) or cos(x)
* @param int $points The number of points to create
*/
function Image_Graph_Dataset_Function($minimumX, $maximumX, $function, $points)
{
parent::Image_Graph_Dataset();
$this->_minimumX = $minimumX;
$this->_maximumX = $maximumX;
$this->_dataFunction = $function;
$this->_count = $points;
$this->_calculateMaxima();
}
/**
* Add a point to the dataset.
*
* You can't add points to a function dataset
*
* @param int $x The X value to add
* @param int $y The Y value to add, can be omited
* @param var $ID The ID of the point
*/
function addPoint($x, $y = false, $ID = false)
{
}
/**
* Gets a Y point from the dataset
*
* @param var $x The variable to apply the function to
* @return var The function applied to the X value
* @access private
*/
function _getPointY($x)
{
$function = $this->_dataFunction;
return $function ($x);
}
/**
* The number of values in the dataset
*
* @return int The number of values in the dataset
* @access private
*/
function _count()
{
return $this->_count;
}
/**
* The interval between 2 adjacent Y values
*
* @return var The interval
* @access private
*/
function _stepX()
{
return ($this->_maximumX - $this->_minimumX) / $this->_count();
}
/**
* Calculates the Y extrema of the function
*
* @access private
*/
function _calculateMaxima()
{
$x = $this->_minimumX;
while ($x <= $this->_maximumX) {
$y = $this->_getPointY($x);
$this->_minimumY = min($y, $this->_minimumY);
$this->_maximumY = max($y, $this->_maximumY);
$x += $this->_stepX();
}
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Dataset.php
*/
require_once 'Image/Graph/Dataset.php';
/**
* Function data set, points are generated by calling an external function.
*
* 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
* used if they are such, i.e: function myFunction($variable)
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Dataset_Function extends Image_Graph_Dataset
{
/**
* The name of the function
* @var string
* @access private
*/
var $_dataFunction;
/**
* Image_Graph_FunctionDataset [Constructor]
*
* @param double $minimumX The minimum X value
* @param double $maximumX The maximum X value
* @param string $function The name of the function, if must be a single
* parameter function like fx sin(x) or cos(x)
* @param int $points The number of points to create
*/
function Image_Graph_Dataset_Function($minimumX, $maximumX, $function, $points)
{
parent::Image_Graph_Dataset();
$this->_minimumX = $minimumX;
$this->_maximumX = $maximumX;
$this->_dataFunction = $function;
$this->_count = $points;
$this->_calculateMaxima();
}
/**
* Add a point to the dataset.
*
* You can't add points to a function dataset
*
* @param int $x The X value to add
* @param int $y The Y value to add, can be omited
* @param var $ID The ID of the point
*/
function addPoint($x, $y = false, $ID = false)
{
}
/**
* Gets a Y point from the dataset
*
* @param var $x The variable to apply the function to
* @return var The function applied to the X value
* @access private
*/
function _getPointY($x)
{
$function = $this->_dataFunction;
return $function ($x);
}
/**
* The number of values in the dataset
*
* @return int The number of values in the dataset
* @access private
*/
function _count()
{
return $this->_count;
}
/**
* The interval between 2 adjacent Y values
*
* @return var The interval
* @access private
*/
function _stepX()
{
return ($this->_maximumX - $this->_minimumX) / $this->_count();
}
/**
* Calculates the Y extrema of the function
*
* @access private
*/
function _calculateMaxima()
{
$x = $this->_minimumX;
while ($x <= $this->_maximumX) {
$y = $this->_getPointY($x);
$this->_minimumY = min($y, $this->_minimumY);
$this->_maximumY = max($y, $this->_maximumY);
$x += $this->_stepX();
}
}
}
?>

View File

@ -1,77 +1,77 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Dataset/Trivial.php
*/
require_once 'Image/Graph/Dataset/Trivial.php';
/**
* Random data set, points are generated by random.
*
* This dataset is mostly (if not solely) used for demo-purposes.
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Dataset_Random extends Image_Graph_Dataset_Trivial
{
/**
* RandomDataset [Constructor]
*
* @param int $count The number of points to create
* @param double $minimum The minimum 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
* value, may be omitted, default: false</false>
*/
function Image_Graph_Dataset_Random($count, $minimum, $maximum, $includeZero = false)
{
parent::Image_Graph_Dataset_Trivial();
$i = 0;
while ($i < $count) {
$this->addPoint(
$ixc = ($includeZero ? $i : $i +1),
rand($minimum, $maximum)
);
$i ++;
}
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Dataset/Trivial.php
*/
require_once 'Image/Graph/Dataset/Trivial.php';
/**
* Random data set, points are generated by random.
*
* This dataset is mostly (if not solely) used for demo-purposes.
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Dataset_Random extends Image_Graph_Dataset_Trivial
{
/**
* RandomDataset [Constructor]
*
* @param int $count The number of points to create
* @param double $minimum The minimum 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
* value, may be omitted, default: false</false>
*/
function Image_Graph_Dataset_Random($count, $minimum, $maximum, $includeZero = false)
{
parent::Image_Graph_Dataset_Trivial();
$i = 0;
while ($i < $count) {
$this->addPoint(
$ixc = ($includeZero ? $i : $i +1),
rand($minimum, $maximum)
);
$i ++;
}
}
}
?>

View File

@ -1,114 +1,114 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Dataset/Trivial.php
*/
require_once 'Image/Graph/Dataset/Trivial.php';
/**
* 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,
* y2), (2, y3)... Where the X-value is implicitly incremented. This is useful
* for example for barcharts, where you could fx. use an {@link
* Image_Graph_Dataset_Array} datapreprocessor to make sence of the x-values.
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Dataset_Sequential extends Image_Graph_Dataset_Trivial
{
/**
* Image_Graph_SequentialDataset [Constructor]
*/
function Image_Graph_Dataset_Sequential($dataArray = false)
{
parent::Image_Graph_Dataset_Trivial();
if (is_array($dataArray)) {
reset($dataArray);
foreach ($dataArray as $value) {
$this->addPoint($value);
}
}
}
/**
* Add a point to the dataset
*
* @param int $y The Y value to add, can be omited
* @param var $ID The ID of the point
*/
function addPoint($y, $ID = false)
{
parent::addPoint($this->count(), $y);
}
/**
* Gets a X point from the dataset
*
* @param var $x The variable to return an X value from, fx in a
* vector function data set
* @return var The X value of the variable
* @access private
*/
function _getPointX($x)
{
return ((int) $x);
}
/**
* The minimum X value
* @return var The minimum X value
*/
function minimumX()
{
return 0;
}
/**
* The maximum X value
* @return var The maximum X value
*/
function maximumX()
{
return $this->count();
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Dataset/Trivial.php
*/
require_once 'Image/Graph/Dataset/Trivial.php';
/**
* 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,
* y2), (2, y3)... Where the X-value is implicitly incremented. This is useful
* for example for barcharts, where you could fx. use an {@link
* Image_Graph_Dataset_Array} datapreprocessor to make sence of the x-values.
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Dataset_Sequential extends Image_Graph_Dataset_Trivial
{
/**
* Image_Graph_SequentialDataset [Constructor]
*/
function Image_Graph_Dataset_Sequential($dataArray = false)
{
parent::Image_Graph_Dataset_Trivial();
if (is_array($dataArray)) {
reset($dataArray);
foreach ($dataArray as $value) {
$this->addPoint($value);
}
}
}
/**
* Add a point to the dataset
*
* @param int $y The Y value to add, can be omited
* @param var $ID The ID of the point
*/
function addPoint($y, $ID = false)
{
parent::addPoint($this->count(), $y);
}
/**
* Gets a X point from the dataset
*
* @param var $x The variable to return an X value from, fx in a
* vector function data set
* @return var The X value of the variable
* @access private
*/
function _getPointX($x)
{
return ((int) $x);
}
/**
* The minimum X value
* @return var The minimum X value
*/
function minimumX()
{
return 0;
}
/**
* The maximum X value
* @return var The maximum X value
*/
function maximumX()
{
return $this->count();
}
}
?>

View File

@ -1,260 +1,260 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Dataset.php
*/
require_once 'Image/Graph/Dataset.php';
/**
* Trivial data set, simply add points (x, y) 1 by 1
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Dataset_Trivial extends Image_Graph_Dataset
{
/**
* Data storage
* @var array
* @access private
*/
var $_data;
/**
* Image_Graph_Dataset_Trivial [Constructor]
*
* Pass an associated array ($data[$x] = $y) to the constructor for easy
* data addition. Alternatively (if multiple entries with same x value is
* required) pass an array with (x, y) values: $data[$id] = array('x' => $x,
* 'y' => $y);
*
* 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
* the 2nd type the key/index of the "outermost" array will be the id tag
* (i.e. $id in the example)
*
* @param array $dataArray An associated array with values to the dataset
*/
function Image_Graph_Dataset_Trivial($dataArray = false)
{
parent::Image_Graph_Dataset();
$this->_data = array ();
if (is_array($dataArray)) {
reset($dataArray);
$keys = array_keys($dataArray);
foreach ($keys as $x) {
$y =& $dataArray[$x];
if ((is_array($y)) && (isset($y['x'])) && (isset($y['y']))) {
$this->addPoint($y['x'], $y['y'], (isset($y['id']) ? $y['id'] : $x));
} else {
$this->addPoint($x, $y, $x);
}
}
}
}
/**
* 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
* values used for creation of the HTML image map. This is achieved using is an an associated array
* with the following values:
*
* 'url' The URL to create the link to
*
* 'alt' [optional] The alt text on 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'
*
* @param int $x The X value to add
* @param int $y The Y value to add, can be omited
* @param var $ID The ID of the point
*/
function addPoint($x, $y = false, $ID = false)
{
parent::addPoint($x, $y, $ID);
if (is_array($ID)) {
$data = $ID;
$ID = (isset($data['id']) ? $data['id'] : false);
} else {
$data = false;
}
$this->_data[] = array ('X' => $x, 'Y' => $y, 'ID' => $ID, 'data' => $data);
if (!is_numeric($x)) {
$this->_maximumX = count($this->_data);
}
}
/**
* The first point
*
* @return array The last point
*/
function first()
{
reset($this->_data);
return current($this->_data);
}
/**
* The last point
*
* @return array The first point
*/
function last()
{
return end($this->_data);
}
/**
* Gets a X point from the dataset
*
* @param var $x The variable to return an X value from, fx in a
* vector function data set
* @return var The X value of the variable
* @access private
*/
function _getPointX($x)
{
if (isset($this->_data[$x])) {
return $this->_data[$x]['X'];
} else {
return false;
}
}
/**
* Gets a Y point from the dataset
*
* @param var $x The variable to return an Y value from, fx in a
* vector function data set
* @return var The Y value of the variable
* @access private
*/
function _getPointY($x)
{
if (isset($this->_data[$x])) {
return $this->_data[$x]['Y'];
} else {
return false;
}
}
/**
* Gets a ID from the dataset
*
* @param var $x The variable to return an Y value from, fx in a
* vector function data set
* @return var The ID value of the variable
* @access private
*/
function _getPointID($x)
{
if (isset($this->_data[$x])) {
return $this->_data[$x]['ID'];
} else {
return false;
}
}
/**
* Gets point data from the dataset
*
* @param var $x The variable to return an Y value from, fx in a vector
* function data set
* @return array The data for the point
* @access private
*/
function _getPointData($x)
{
if (isset($this->_data[$x])) {
return $this->_data[$x]['data'];
} else {
return false;
}
}
/**
* The number of values in the dataset
*
* @return int The number of values in the dataset
*/
function count()
{
return count($this->_data);
}
/**
* Reset the intertal dataset pointer
*
* @return var The first X value
* @access private
*/
function _reset()
{
$this->_posX = 0;
return $this->_posX;
}
/**
* Get the next point the internal pointer refers to and advance the pointer
*
* @return array The next point
* @access private
*/
function _next()
{
if ($this->_posX >= $this->count()) {
return false;
}
$x = $this->_getPointX($this->_posX);
$y = $this->_getPointY($this->_posX);
$ID = $this->_getPointID($this->_posX);
$data = $this->_getPointData($this->_posX);
$this->_posX += $this->_stepX();
return array('X' => $x, 'Y' => $y, 'ID' => $ID, 'data' => $data);
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Dataset.php
*/
require_once 'Image/Graph/Dataset.php';
/**
* Trivial data set, simply add points (x, y) 1 by 1
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Dataset_Trivial extends Image_Graph_Dataset
{
/**
* Data storage
* @var array
* @access private
*/
var $_data;
/**
* Image_Graph_Dataset_Trivial [Constructor]
*
* Pass an associated array ($data[$x] = $y) to the constructor for easy
* data addition. Alternatively (if multiple entries with same x value is
* required) pass an array with (x, y) values: $data[$id] = array('x' => $x,
* 'y' => $y);
*
* 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
* the 2nd type the key/index of the "outermost" array will be the id tag
* (i.e. $id in the example)
*
* @param array $dataArray An associated array with values to the dataset
*/
function Image_Graph_Dataset_Trivial($dataArray = false)
{
parent::Image_Graph_Dataset();
$this->_data = array ();
if (is_array($dataArray)) {
reset($dataArray);
$keys = array_keys($dataArray);
foreach ($keys as $x) {
$y =& $dataArray[$x];
if ((is_array($y)) && (isset($y['x'])) && (isset($y['y']))) {
$this->addPoint($y['x'], $y['y'], (isset($y['id']) ? $y['id'] : $x));
} else {
$this->addPoint($x, $y, $x);
}
}
}
}
/**
* 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
* values used for creation of the HTML image map. This is achieved using is an an associated array
* with the following values:
*
* 'url' The URL to create the link to
*
* 'alt' [optional] The alt text on 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'
*
* @param int $x The X value to add
* @param int $y The Y value to add, can be omited
* @param var $ID The ID of the point
*/
function addPoint($x, $y = false, $ID = false)
{
parent::addPoint($x, $y, $ID);
if (is_array($ID)) {
$data = $ID;
$ID = (isset($data['id']) ? $data['id'] : false);
} else {
$data = false;
}
$this->_data[] = array ('X' => $x, 'Y' => $y, 'ID' => $ID, 'data' => $data);
if (!is_numeric($x)) {
$this->_maximumX = count($this->_data);
}
}
/**
* The first point
*
* @return array The last point
*/
function first()
{
reset($this->_data);
return current($this->_data);
}
/**
* The last point
*
* @return array The first point
*/
function last()
{
return end($this->_data);
}
/**
* Gets a X point from the dataset
*
* @param var $x The variable to return an X value from, fx in a
* vector function data set
* @return var The X value of the variable
* @access private
*/
function _getPointX($x)
{
if (isset($this->_data[$x])) {
return $this->_data[$x]['X'];
} else {
return false;
}
}
/**
* Gets a Y point from the dataset
*
* @param var $x The variable to return an Y value from, fx in a
* vector function data set
* @return var The Y value of the variable
* @access private
*/
function _getPointY($x)
{
if (isset($this->_data[$x])) {
return $this->_data[$x]['Y'];
} else {
return false;
}
}
/**
* Gets a ID from the dataset
*
* @param var $x The variable to return an Y value from, fx in a
* vector function data set
* @return var The ID value of the variable
* @access private
*/
function _getPointID($x)
{
if (isset($this->_data[$x])) {
return $this->_data[$x]['ID'];
} else {
return false;
}
}
/**
* Gets point data from the dataset
*
* @param var $x The variable to return an Y value from, fx in a vector
* function data set
* @return array The data for the point
* @access private
*/
function _getPointData($x)
{
if (isset($this->_data[$x])) {
return $this->_data[$x]['data'];
} else {
return false;
}
}
/**
* The number of values in the dataset
*
* @return int The number of values in the dataset
*/
function count()
{
return count($this->_data);
}
/**
* Reset the intertal dataset pointer
*
* @return var The first X value
* @access private
*/
function _reset()
{
$this->_posX = 0;
return $this->_posX;
}
/**
* Get the next point the internal pointer refers to and advance the pointer
*
* @return array The next point
* @access private
*/
function _next()
{
if ($this->_posX >= $this->count()) {
return false;
}
$x = $this->_getPointX($this->_posX);
$y = $this->_getPointY($this->_posX);
$ID = $this->_getPointID($this->_posX);
$data = $this->_getPointData($this->_posX);
$this->_posX += $this->_stepX();
return array('X' => $x, 'Y' => $y, 'ID' => $ID, 'data' => $data);
}
}
?>

View File

@ -1,185 +1,185 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Dataset.php
*/
require_once 'Image/Graph/Dataset.php';
/**
* Vector Function data set.
*
* Points are generated by calling 2 external functions, fx. x = sin(t) and y =
* cos(t)
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Dataset_VectorFunction extends Image_Graph_Dataset
{
/**
* The name of the X function
* @var string
* @access private
*/
var $_functionX;
/**
* The name of the Y function
* @var string
* @access private
*/
var $_functionY;
/**
* The minimum of the vector function variable
* @var double
* @access private
*/
var $_minimumT;
/**
* The maximum of the vector function variable
* @var double
* @access private
*/
var $_maximumT;
/**
* Image_Graph_VectorFunctionDataset [Constructor]
*
* @param double $minimumT The minimum 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
* parameter function like fx sin(x) or cos(x)
* @param string $functionY The name of the Y function, if must be a single
* parameter function like fx sin(x) or cos(x)
* @param int $points The number of points to create
*/
function Image_Graph_Dataset_VectorFunction($minimumT, $maximumT, $functionX, $functionY, $points)
{
parent::Image_Graph_Dataset();
$this->_minimumT = $minimumT;
$this->_maximumT = $maximumT;
$this->_functionX = $functionX;
$this->_functionY = $functionY;
$this->_count = $points;
$this->_calculateMaxima();
}
/**
* Add a point to the dataset
*
* @param int $x The X value to add
* @param int $y The Y value to add, can be omited
* @param var $ID The ID of the point
*/
function addPoint($x, $y = false, $ID = false)
{
}
/**
* Gets a X point from the dataset
*
* @param var $x The variable to apply the X function to
* @return var The X function applied to the X value
* @access private
*/
function _getPointX($x)
{
$functionX = $this->_functionX;
return $functionX ($x);
}
/**
* Gets a Y point from the dataset
*
* @param var $x The variable to apply the Y function to
* @return var The Y function applied to the X value
* @access private
*/
function _getPointY($x)
{
$functionY = $this->_functionY;
return $functionY ($x);
}
/**
* Reset the intertal dataset pointer
*
* @return var The first T value
* @access private
*/
function _reset()
{
$this->_posX = $this->_minimumT;
return $this->_posX;
}
/**
* The interval between 2 adjacent T values
*
* @return var The interval
* @access private
*/
function _stepX()
{
return ($this->_maximumT - $this->_minimumT) / $this->count();
}
/**
* Calculates the X and Y extrema of the functions
*
* @access private
*/
function _calculateMaxima()
{
$t = $this->_minimumT;
while ($t <= $this->_maximumT) {
$x = $this->_getPointX($t);
$y = $this->_getPointY($t);
$this->_minimumX = min($x, $this->_minimumX);
$this->_maximumX = max($x, $this->_maximumX);
$this->_minimumY = min($y, $this->_minimumY);
$this->_maximumY = max($y, $this->_maximumY);
$t += $this->_stepX();
}
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Dataset.php
*/
require_once 'Image/Graph/Dataset.php';
/**
* Vector Function data set.
*
* Points are generated by calling 2 external functions, fx. x = sin(t) and y =
* cos(t)
*
* @category Images
* @package Image_Graph
* @subpackage Dataset
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Dataset_VectorFunction extends Image_Graph_Dataset
{
/**
* The name of the X function
* @var string
* @access private
*/
var $_functionX;
/**
* The name of the Y function
* @var string
* @access private
*/
var $_functionY;
/**
* The minimum of the vector function variable
* @var double
* @access private
*/
var $_minimumT;
/**
* The maximum of the vector function variable
* @var double
* @access private
*/
var $_maximumT;
/**
* Image_Graph_VectorFunctionDataset [Constructor]
*
* @param double $minimumT The minimum 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
* parameter function like fx sin(x) or cos(x)
* @param string $functionY The name of the Y function, if must be a single
* parameter function like fx sin(x) or cos(x)
* @param int $points The number of points to create
*/
function Image_Graph_Dataset_VectorFunction($minimumT, $maximumT, $functionX, $functionY, $points)
{
parent::Image_Graph_Dataset();
$this->_minimumT = $minimumT;
$this->_maximumT = $maximumT;
$this->_functionX = $functionX;
$this->_functionY = $functionY;
$this->_count = $points;
$this->_calculateMaxima();
}
/**
* Add a point to the dataset
*
* @param int $x The X value to add
* @param int $y The Y value to add, can be omited
* @param var $ID The ID of the point
*/
function addPoint($x, $y = false, $ID = false)
{
}
/**
* Gets a X point from the dataset
*
* @param var $x The variable to apply the X function to
* @return var The X function applied to the X value
* @access private
*/
function _getPointX($x)
{
$functionX = $this->_functionX;
return $functionX ($x);
}
/**
* Gets a Y point from the dataset
*
* @param var $x The variable to apply the Y function to
* @return var The Y function applied to the X value
* @access private
*/
function _getPointY($x)
{
$functionY = $this->_functionY;
return $functionY ($x);
}
/**
* Reset the intertal dataset pointer
*
* @return var The first T value
* @access private
*/
function _reset()
{
$this->_posX = $this->_minimumT;
return $this->_posX;
}
/**
* The interval between 2 adjacent T values
*
* @return var The interval
* @access private
*/
function _stepX()
{
return ($this->_maximumT - $this->_minimumT) / $this->count();
}
/**
* Calculates the X and Y extrema of the functions
*
* @access private
*/
function _calculateMaxima()
{
$t = $this->_minimumT;
while ($t <= $this->_maximumT) {
$x = $this->_getPointX($t);
$y = $this->_getPointY($t);
$this->_minimumX = min($x, $this->_minimumX);
$this->_maximumX = max($x, $this->_maximumX);
$this->_minimumY = min($y, $this->_minimumY);
$this->_maximumY = max($y, $this->_maximumY);
$t += $this->_stepX();
}
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -1,64 +1,64 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Figure/Ellipse.php
*/
require_once 'Image/Graph/Figure/Ellipse.php';
/**
* Circle to draw on the canvas
*
* @category Images
* @package Image_Graph
* @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Figure_Circle extends Image_Graph_Figure_Ellipse
{
/**
* Image_Graph_Circle [Constructor]
*
* @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 $radius The radius in pixels of the circle
*/
function Image_Graph_Figure_Circle($x, $y, $radius)
{
parent::Image_Graph_Ellipse($x, $y, $radius, $radius);
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Figure/Ellipse.php
*/
require_once 'Image/Graph/Figure/Ellipse.php';
/**
* Circle to draw on the canvas
*
* @category Images
* @package Image_Graph
* @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Figure_Circle extends Image_Graph_Figure_Ellipse
{
/**
* Image_Graph_Circle [Constructor]
*
* @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 $radius The radius in pixels of the circle
*/
function Image_Graph_Figure_Circle($x, $y, $radius)
{
parent::Image_Graph_Ellipse($x, $y, $radius, $radius);
}
}
?>

View File

@ -1,97 +1,97 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Element.php
*/
require_once 'Image/Graph/Element.php';
/**
* Ellipse to draw on the canvas
*
* @category Images
* @package Image_Graph
* @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Figure_Ellipse extends Image_Graph_Element
{
/**
* Ellipse [Constructor]
*
* @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 $radiusX The width 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)
{
parent::Image_Graph_Element();
$this->_setCoords($x - $radiusX, $y - $radiusY, $x + $radiusX, $y + $radiusY);
}
/**
* Output the ellipse
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
$this->_canvas->startGroup(get_class($this));
$this->_getFillStyle();
$this->_getLineStyle();
$this->_canvas->ellipse(
array(
'x' => ($this->_left + $this->_right) / 2,
'y' => ($this->_top + $this->_bottom) / 2,
'rx' => $this->width(),
'ry' => $this->height()
)
);
$this->_canvas->endGroup();
return true;
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Element.php
*/
require_once 'Image/Graph/Element.php';
/**
* Ellipse to draw on the canvas
*
* @category Images
* @package Image_Graph
* @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Figure_Ellipse extends Image_Graph_Element
{
/**
* Ellipse [Constructor]
*
* @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 $radiusX The width 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)
{
parent::Image_Graph_Element();
$this->_setCoords($x - $radiusX, $y - $radiusY, $x + $radiusX, $y + $radiusY);
}
/**
* Output the ellipse
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
$this->_canvas->startGroup(get_class($this));
$this->_getFillStyle();
$this->_getLineStyle();
$this->_canvas->ellipse(
array(
'x' => ($this->_left + $this->_right) / 2,
'y' => ($this->_top + $this->_bottom) / 2,
'rx' => $this->width(),
'ry' => $this->height()
)
);
$this->_canvas->endGroup();
return true;
}
}
?>

View File

@ -1,94 +1,94 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Element.php
*/
require_once 'Image/Graph/Element.php';
/**
* Polygon to draw on the canvas
*
* @category Images
* @package Image_Graph
* @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Figure_Polygon extends Image_Graph_Element
{
/**
* Polygon vertices
*
* @var array
* @access private
*/
var $_polygon = array ();
/**
* Add a vertex to the polygon
*
* @param int $x X-coordinate
* @param int $y Y-coordinate
*/
function addVertex($x, $y)
{
$this->_canvas->addVertex(array('x' => $x, 'y' => $y));
}
/**
* Output the polygon
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
$this->_canvas->startGroup(get_class($this));
$this->_getFillStyle();
$this->_getLineStyle();
$this->_canvas->polygon(array('connect' => true));
$this->_canvas->endGroup();
return true;
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Element.php
*/
require_once 'Image/Graph/Element.php';
/**
* Polygon to draw on the canvas
*
* @category Images
* @package Image_Graph
* @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Figure_Polygon extends Image_Graph_Element
{
/**
* Polygon vertices
*
* @var array
* @access private
*/
var $_polygon = array ();
/**
* Add a vertex to the polygon
*
* @param int $x X-coordinate
* @param int $y Y-coordinate
*/
function addVertex($x, $y)
{
$this->_canvas->addVertex(array('x' => $x, 'y' => $y));
}
/**
* Output the polygon
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
$this->_canvas->startGroup(get_class($this));
$this->_getFillStyle();
$this->_getLineStyle();
$this->_canvas->polygon(array('connect' => true));
$this->_canvas->endGroup();
return true;
}
}
?>

View File

@ -1,96 +1,96 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Element.php
*/
require_once 'Image/Graph/Element.php';
/**
* Rectangle to draw on the canvas
*
* @category Images
* @package Image_Graph
* @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Figure_Rectangle extends Image_Graph_Element
{
/**
* Rectangle [Construcor]
*
* @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 $width The width 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)
{
parent::Image_Graph_Element();
$this->_setCoords($x, $y, $x + $width, $y + $height);
}
/**
* Output the box
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
$this->_canvas->startGroup(get_class($this));
$this->_getFillStyle();
$this->_getLineStyle();
$this->_canvas->rectangle(
array(
'x0' => $this->_left,
'y0' => $this->_top,
'x1' => $this->_right,
'y1' => $this->_bottom
)
);
$this->_canvas->endGroup();
return true;
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Element.php
*/
require_once 'Image/Graph/Element.php';
/**
* Rectangle to draw on the canvas
*
* @category Images
* @package Image_Graph
* @subpackage Figure
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Figure_Rectangle extends Image_Graph_Element
{
/**
* Rectangle [Construcor]
*
* @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 $width The width 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)
{
parent::Image_Graph_Element();
$this->_setCoords($x, $y, $x + $width, $y + $height);
}
/**
* Output the box
*
* @return bool Was the output 'good' (true) or 'bad' (false).
* @access private
*/
function _done()
{
if (parent::_done() === false) {
return false;
}
$this->_canvas->startGroup(get_class($this));
$this->_getFillStyle();
$this->_getLineStyle();
$this->_canvas->rectangle(
array(
'x0' => $this->_left,
'y0' => $this->_top,
'x1' => $this->_right,
'y1' => $this->_bottom
)
);
$this->_canvas->endGroup();
return true;
}
}
?>

View File

@ -1,63 +1,63 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Element.php
*/
require_once 'Image/Graph/Element.php';
/**
* Style used for filling elements.
*
* @category Images
* @package Image_Graph
* @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
* @abstract
*/
class Image_Graph_Fill extends Image_Graph_Common
{
/**
* Resets the fillstyle
*
* @access private
*/
function _reset()
{
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Element.php
*/
require_once 'Image/Graph/Element.php';
/**
* Style used for filling elements.
*
* @category Images
* @package Image_Graph
* @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
* @abstract
*/
class Image_Graph_Fill extends Image_Graph_Common
{
/**
* Resets the fillstyle
*
* @access private
*/
function _reset()
{
}
}
?>

View File

@ -1,137 +1,137 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Fill.php
*/
require_once 'Image/Graph/Fill.php';
/**
* A sequential array of fillstyles.
*
* This is used for filling multiple objects within the same element with
* different styles. This is done by adding multiple fillstyles to a FillArrray
* structure. The fillarray will then when requested return the 'next' 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
* 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
* fillarray.
*
* @category Images
* @package Image_Graph
* @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Fill_Array extends Image_Graph_Fill
{
/**
* The fill array
* @var array
* @access private
*/
var $_fillStyles = array ();
/**
* Resets the fillstyle
*
* @access private
*/
function _reset()
{
reset($this->_fillStyles);
}
/**
* Add a fill style to the array
*
* @param Image_Graph_Fill $style The style to add
* @param string $id The id or name of the style
*/
function &add(& $style, $id = '')
{
if ($id == '') {
$this->_fillStyles[] =& $style;
} else {
$this->_fillStyles[$id] =& $style;
}
reset($this->_fillStyles);
return $style;
}
/**
* Add a color to the array
*
* @param int $color The color
* @param string $id The id or name of the color
*/
function addColor($color, $id = false)
{
if ($id !== false) {
$this->_fillStyles[$id] = $color;
} else {
$this->_fillStyles[] = $color;
}
reset($this->_fillStyles);
}
/**
* Return the fillstyle
*
* @return int A GD fillstyle
* @access private
*/
function _getFillStyle($ID = false)
{
if (($ID === false) || (!isset($this->_fillStyles[$ID]))) {
$ID = key($this->_fillStyles);
if (!next($this->_fillStyles)) {
reset($this->_fillStyles);
}
}
$fillStyle =& $this->_fillStyles[$ID];
if (is_object($fillStyle)) {
return $fillStyle->_getFillStyle($ID);
} elseif ($fillStyle !== null) {
return $fillStyle;
} else {
return parent::_getFillStyle($ID);
}
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Fill.php
*/
require_once 'Image/Graph/Fill.php';
/**
* A sequential array of fillstyles.
*
* This is used for filling multiple objects within the same element with
* different styles. This is done by adding multiple fillstyles to a FillArrray
* structure. The fillarray will then when requested return the 'next' 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
* 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
* fillarray.
*
* @category Images
* @package Image_Graph
* @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Fill_Array extends Image_Graph_Fill
{
/**
* The fill array
* @var array
* @access private
*/
var $_fillStyles = array ();
/**
* Resets the fillstyle
*
* @access private
*/
function _reset()
{
reset($this->_fillStyles);
}
/**
* Add a fill style to the array
*
* @param Image_Graph_Fill $style The style to add
* @param string $id The id or name of the style
*/
function &add(& $style, $id = '')
{
if ($id == '') {
$this->_fillStyles[] =& $style;
} else {
$this->_fillStyles[$id] =& $style;
}
reset($this->_fillStyles);
return $style;
}
/**
* Add a color to the array
*
* @param int $color The color
* @param string $id The id or name of the color
*/
function addColor($color, $id = false)
{
if ($id !== false) {
$this->_fillStyles[$id] = $color;
} else {
$this->_fillStyles[] = $color;
}
reset($this->_fillStyles);
}
/**
* Return the fillstyle
*
* @return int A GD fillstyle
* @access private
*/
function _getFillStyle($ID = false)
{
if (($ID === false) || (!isset($this->_fillStyles[$ID]))) {
$ID = key($this->_fillStyles);
if (!next($this->_fillStyles)) {
reset($this->_fillStyles);
}
}
$fillStyle =& $this->_fillStyles[$ID];
if (is_object($fillStyle)) {
return $fillStyle->_getFillStyle($ID);
} elseif ($fillStyle !== null) {
return $fillStyle;
} else {
return parent::_getFillStyle($ID);
}
}
}
?>

View File

@ -1,149 +1,149 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Fill/Image.php
*/
require_once 'Image/Graph/Fill/Image.php';
/**
* Fill using a gradient color.
* This creates a scaled fillstyle with colors flowing gradiently between 2
* specified RGB values. Several directions are supported:
*
* 1 Vertically (IMAGE_GRAPH_GRAD_VERTICAL)
*
* 2 Horizontally (IMAGE_GRAPH_GRAD_HORIZONTAL)
*
* 3 Mirrored vertically (the color grades from a- b-a vertically)
* (IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED)
*
* 4 Mirrored horizontally (the color grades from a-b-a horizontally)
* IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED
*
* 5 Diagonally from top-left to right-bottom
* (IMAGE_GRAPH_GRAD_DIAGONALLY_TL_BR)
*
* 6 Diagonally from bottom-left to top-right
* (IMAGE_GRAPH_GRAD_DIAGONALLY_BL_TR)
*
* 7 Radially (concentric circles in the center) (IMAGE_GRAPH_GRAD_RADIAL)
*
* @category Images
* @package Image_Graph
* @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Fill_Gradient extends Image_Graph_Fill //Image_Graph_Fill_Image
{
/**
* The direction of the gradient
* @var int
* @access private
*/
var $_direction;
/**
* The first color to gradient
* @var mixed
* @access private
*/
var $_startColor;
/**
* The last color to gradient
* @var mixed
* @access private
*/
var $_endColor;
/**
* Image_Graph_GradientFill [Constructor]
*
* @param int $direction The direction of the gradient
* @param mixed $startColor The value of the starting color
* @param mixed $endColor The value of the ending color
*/
function Image_Graph_Fill_Gradient($direction, $startColor, $endColor)
{
parent::Image_Graph_Fill();
$this->_direction = $direction;
$this->_startColor = $startColor;
$this->_endColor = $endColor;
}
/**
* Return the fillstyle
*
* @return int A GD fillstyle
* @access private
*/
function _getFillStyle($ID = false)
{
switch ($this->_direction) {
case IMAGE_GRAPH_GRAD_HORIZONTAL:
$direction = 'horizontal';
break;
case IMAGE_GRAPH_GRAD_VERTICAL:
$direction = 'vertical';
break;
case IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED:
$direction = 'horizontal_mirror';
break;
case IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED:
$direction = 'vertical_mirror';
break;
case IMAGE_GRAPH_GRAD_DIAGONALLY_TL_BR:
$direction = 'diagonal_tl_br';
break;
case IMAGE_GRAPH_GRAD_DIAGONALLY_BL_TR:
$direction = 'diagonal_bl_tr';
break;
case IMAGE_GRAPH_GRAD_RADIAL:
$direction = 'radial';
break;
}
return array(
'type' => 'gradient',
'start' => $this->_startColor,
'end' => $this->_endColor,
'direction' => $direction
);
}
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Image_Graph - PEAR PHP OO Graph Rendering Utility.
*
* PHP versions 4 and 5
*
* 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
* 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
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* 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
* 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
* 02111-1307 USA
*
* @category Images
* @package Image_Graph
* @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @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 $
* @link http://pear.php.net/package/Image_Graph
*/
/**
* Include file Image/Graph/Fill/Image.php
*/
require_once 'Image/Graph/Fill/Image.php';
/**
* Fill using a gradient color.
* This creates a scaled fillstyle with colors flowing gradiently between 2
* specified RGB values. Several directions are supported:
*
* 1 Vertically (IMAGE_GRAPH_GRAD_VERTICAL)
*
* 2 Horizontally (IMAGE_GRAPH_GRAD_HORIZONTAL)
*
* 3 Mirrored vertically (the color grades from a- b-a vertically)
* (IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED)
*
* 4 Mirrored horizontally (the color grades from a-b-a horizontally)
* IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED
*
* 5 Diagonally from top-left to right-bottom
* (IMAGE_GRAPH_GRAD_DIAGONALLY_TL_BR)
*
* 6 Diagonally from bottom-left to top-right
* (IMAGE_GRAPH_GRAD_DIAGONALLY_BL_TR)
*
* 7 Radially (concentric circles in the center) (IMAGE_GRAPH_GRAD_RADIAL)
*
* @category Images
* @package Image_Graph
* @subpackage Fill
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version Release: @package_version@
* @link http://pear.php.net/package/Image_Graph
*/
class Image_Graph_Fill_Gradient extends Image_Graph_Fill //Image_Graph_Fill_Image
{
/**
* The direction of the gradient
* @var int
* @access private
*/
var $_direction;
/**
* The first color to gradient
* @var mixed
* @access private
*/
var $_startColor;
/**
* The last color to gradient
* @var mixed
* @access private
*/
var $_endColor;
/**
* Image_Graph_GradientFill [Constructor]
*
* @param int $direction The direction of the gradient
* @param mixed $startColor The value of the starting color
* @param mixed $endColor The value of the ending color
*/
function Image_Graph_Fill_Gradient($direction, $startColor, $endColor)
{
parent::Image_Graph_Fill();
$this->_direction = $direction;
$this->_startColor = $startColor;
$this->_endColor = $endColor;
}
/**
* Return the fillstyle
*
* @return int A GD fillstyle
* @access private
*/
function _getFillStyle($ID = false)
{
switch ($this->_direction) {
case IMAGE_GRAPH_GRAD_HORIZONTAL:
$direction = 'horizontal';
break;
case IMAGE_GRAPH_GRAD_VERTICAL:
$direction = 'vertical';
break;
case IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED:
$direction = 'horizontal_mirror';
break;
case IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED:
$direction = 'vertical_mirror';
break;
case IMAGE_GRAPH_GRAD_DIAGONALLY_TL_BR:
$direction = 'diagonal_tl_br';
break;
case IMAGE_GRAPH_GRAD_DIAGONALLY_BL_TR:
$direction = 'diagonal_bl_tr';
break;
case IMAGE_GRAPH_GRAD_RADIAL:
$direction = 'radial';
break;
}
return array(
'type' => 'gradient',
'start' => $this->_startColor,
'end' => $this->_endColor,
'direction' => $direction
);
}
}
?>

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