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);
}
}
}
?>

View File

@ -25,7 +25,7 @@
* @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: Canvas.php,v 1.5 2005/09/30 18:59:35 nosey Exp $
* @version CVS: $Id: Canvas.php,v 1.7 2006/02/28 22:46:25 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
@ -357,6 +357,16 @@ class Image_Canvas
$this->_font = $this->_defaultFont;
}
/**
* Reset the canvas.
*
* Includes fillstyle, linestyle, thickness and polygon
*/
function reset()
{
$this->_reset();
}
/**
* Draw a line end
*
@ -588,6 +598,20 @@ class Image_Canvas
{
}
/**
* Set clipping to occur
*
* Parameter array:
*
* 'x0': int X point of Upper-left corner
* 'y0': int X point of Upper-left corner
* 'x1': int X point of lower-right corner
* 'y1': int Y point of lower-right corner
*/
function setClipping($params = false)
{
}
/**
* Start a group.
*

View File

@ -29,7 +29,7 @@
* @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: GD.php,v 1.8 2005/09/25 07:41:43 nosey Exp $
* @version CVS: $Id: GD.php,v 1.16 2007/06/22 20:19:54 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
@ -89,6 +89,10 @@ class Image_Canvas_GD extends Image_Canvas_WithMap
*/
var $_antialias = 'off';
var $_alpha = false;
var $_clipping = array();
/**
* Create the GD canvas.
*
@ -159,6 +163,7 @@ class Image_Canvas_GD extends Image_Canvas_WithMap
);
if ((!isset($param['noalpha'])) || ($param['noalpha'] !== true)) {
ImageAlphaBlending($this->_canvas, true);
$this->_alpha = true;
}
} else {
$this->_canvas = ImageCreate($this->_width, $this->_height);
@ -173,7 +178,7 @@ class Image_Canvas_GD extends Image_Canvas_WithMap
$this->_antialias = 'driver';
}
if (($this->_gd2) && ($this->_antialias === 'native')) {
if (($this->_gd2) && ($this->_antialias === 'native') && (function_exists('ImageAntialias'))) {
ImageAntialias($this->_canvas, true);
}
}
@ -570,7 +575,7 @@ class Image_Canvas_GD extends Image_Canvas_WithMap
parent::setFont($fontOptions);
if (isset($this->_font['ttf'])) {
$this->_font['file'] = str_replace('\\', '/', $this->_mapFont($this->_font['ttf']));
$this->_font['file'] = str_replace('\\', '/', Image_Canvas_Tool::fontMap($this->_font['ttf']));
} elseif (!isset($this->_font['font'])) {
$this->_font['font'] = 1;
}
@ -1204,7 +1209,7 @@ class Image_Canvas_GD extends Image_Canvas_WithMap
$polygon[] = ($y + $ry * sin(deg2rad(max($v1, $v2) % 360)));
}
if (($fill = $this->_getFillStyle($fillColor, $x - $rx - 1, $y - $ry - 1, $x + $rx + 1, $y + $ry + 1)) !== false) {
if ((($fill = $this->_getFillStyle($fillColor, $x - $rx - 1, $y - $ry - 1, $x + $rx + 1, $y + $ry + 1)) !== false) && (count($polygon) > 2)) {
ImageFilledPolygon($this->_canvas, $polygon, count($polygon) / 2, $fill);
}
@ -1283,13 +1288,13 @@ class Image_Canvas_GD extends Image_Canvas_WithMap
}
$linebreaks = substr_count($text, "\n");
if (($angle == 0) && ($linebreaks == 0) && ($force === false)) {
if (($angle == 0) && ($force === false)) {
/*
* if the angle is 0 simply return the size, due to different
* heights for example for x-axis labels, making the labels
* _not_ appear as written on the same baseline
*/
return $this->_font['size'] + 2;
return $this->_font['size'] + ($this->_font['size'] + 2) * $linebreaks;
}
$height = 0;
@ -1321,6 +1326,105 @@ class Image_Canvas_GD extends Image_Canvas_WithMap
}
}
/**
* Calculated the absolute bottom-left position of the text, by simulating
* the calculation of the baseline drop.
* @param int $x The relative x position to write the text
* @param int $y The relative y position to write the text
* @param string $text The text to write
* @param array $align The alignment of the text relative to (x, y)
* @returns array An array containing the absolute x and y positions
* @access private
*/
function _getAbsolutePosition($x, $y, $text, $align)
{
if ($this->_font['angle'] > 0) {
$w0 = $this->textWidth($text);
$h0 = $this->textHeight($text);
if ($align['vertical'] == 'bottom') {
$dy = $y - $h0;
}
else if ($align['vertical'] == 'center') {
$dy = $y - $h0 / 2;
}
else if ($align['vertical'] == 'top') {
$dy = $y;
}
if ($align['horizontal'] == 'right') {
$dx = $x - $w0;
}
else if ($align['horizontal'] == 'center') {
$dx = $x - $w0 / 2;
}
else if ($align['horizontal'] == 'left') {
$dx = $x;
}
if (($this->_font['angle'] < 180) && ($this->_font['angle'] >= 0)) {
$dy += $h0;
}
if (($this->_font['angle'] >= 90) && ($this->_font['angle'] < 270)) {
$dx += $w0;
}
}
else {
// get the maximum size of normal text above base line - sampled by 'Al'
$size1 = imagettfbbox($this->_font['size'], 0, $this->_font['file'], 'Al');
$height1 = abs($size1[7] - $size1[1]);
// get the maximum size of all text above base and below line - sampled by 'AlgjpqyQ'
$size2 = imagettfbbox($this->_font['size'], 0, $this->_font['file'], 'AlgjpqyQ');
$height2 = abs($size2[7] - $size2[1]);
// get the size of the text, simulating height above baseline beinh max, by sampling using 'Al'
$size = imagettfbbox($this->_font['size'], 0, $this->_font['file'], 'Al' . $text);
$height = abs($size[7] - $size[1]);
// if all text is above baseline, i.e. height of text compares to max height above (within 10%)
if (abs($height - $height1)/$height1 < 0.1) {
$dHeight = 0;
}
else {
$dHeight = abs($height2 - $height1);
}
// specifies the bottom-left corner!
$dx = $x + sin(deg2rad($this->_font['angle'])) * $dHeight;
$dy = $y - cos(deg2rad($this->_font['angle'])) * $dHeight;
if ($align['vertical'] == 'top') {
$dy += $height;
}
else if ($align['vertical'] == 'center') {
$dy += ($height + $dHeight) / 2;
}
else if ($align['vertical'] == 'bottom') {
$dy += $dHeight;
}
if ($align['horizontal'] == 'center') {
$factor = 0.5;
}
else if ($align['horizontal'] == 'right') {
$factor = 1;
}
else {
$factor = 0;
}
if ($factor != 0) {
$size = imagettfbbox($this->_font['size'], 0, $this->_font['file'], $text);
$w0 = abs($size[2] - $size[0]);
$dx -= cos(deg2rad($this->_font['angle'])) * $w0 * $factor;
$dy += sin(deg2rad($this->_font['angle'])) * $w0 * $factor;
}
}
return array('x' => $dx, 'y' => $dy);
}
/**
* Writes text
*
@ -1358,53 +1462,52 @@ class Image_Canvas_GD extends Image_Canvas_WithMap
$alignment['horizontal'] = 'left';
}
if ($alignment['vertical'] == 'bottom') {
$y0 = $y0 - $this->textHeight($text, true);
} elseif ($alignment['vertical'] == 'center') {
$y0 = $y0 - ($this->textHeight($text, true) / 2);
if (isset($this->_font['size'])) {
$textHeight = $this->_font['size'] + 2;
}
else {
$textHeight = $this->textHeight('A');
}
$lines = explode("\n", $text);
foreach ($lines as $line) {
$textWidth = $this->textWidth($line);
$textHeight = $this->textHeight($line, true);
$x = $x0;
$y = $y0;
$y0 += $textHeight + 2;
if ($alignment['horizontal'] == 'right') {
$x = $x - $textWidth;
} elseif ($alignment['horizontal'] == 'center') {
$x = $x - ($textWidth / 2);
}
if (($color === false) && (isset($this->_font['color']))) {
$color = $this->_font['color'];
}
if ($color != 'transparent') {
if (isset($this->_font['file'])) {
if (($this->_font['angle'] < 180) && ($this->_font['angle'] >= 0)) {
$y += $textHeight;
}
if (($this->_font['angle'] >= 90) && ($this->_font['angle'] < 270)) {
$x += $textWidth;
}
$result = $this->_getAbsolutePosition($x, $y, $line, $alignment);
ImageTTFText(
$this->_canvas,
$this->_font['size'],
$this->_font['angle'],
$x,
$y,
$result['x'],
$result['y'],
$this->_color($color),
$this->_font['file'],
$line
);
} else {
$width = $this->textWidth($line);
$height = $this->textHeight($line);
if ($alignment['horizontal'] == 'right') {
$x -= $width;
}
else if ($alignment['horizontal'] == 'center') {
$x -= $width / 2;
}
if ($alignment['vertical'] == 'bottom') {
$y -= $height;
}
else if ($alignment['vertical'] == 'center') {
$y -= $height / 2;
}
if ((isset($this->_font['vertical'])) && ($this->_font['vertical'])) {
ImageStringUp(
$this->_canvas,
@ -1542,6 +1645,62 @@ class Image_Canvas_GD extends Image_Canvas_WithMap
parent::image($params);
}
/**
* Set clipping to occur
*
* Parameter array:
*
* 'x0': int X point of Upper-left corner
* 'y0': int X point of Upper-left corner
* 'x1': int X point of lower-right corner
* 'y1': int Y point of lower-right corner
*/
function setClipping($params = false)
{
if ($params === false) {
$index = count($this->_clipping) - 1;
if (isset($this->_clipping[$index])) {
$params = $this->_clipping[$index];
$canvas = $params['canvas'];
ImageCopy(
$canvas,
$this->_canvas,
min($params['x0'], $params['x1']),
min($params['y0'], $params['y1']),
min($params['x0'], $params['x1']),
min($params['y0'], $params['y1']),
abs($params['x1'] - $params['x0'] + 1),
abs($params['y1'] - $params['y0'] + 1)
);
$this->_canvas = $canvas;
unset($this->_clipping[$index]);
}
}
else {
$params['canvas'] = $this->_canvas;
if ($this->_gd2) {
$this->_canvas = ImageCreateTrueColor(
$this->_width,
$this->_height
);
if ($this->_alpha) {
ImageAlphaBlending($this->_canvas, true);
}
} else {
$this->_canvas = ImageCreate($this->_width, $this->_height);
}
if (($this->_gd2) && ($this->_antialias === 'native')) {
ImageAntialias($this->_canvas, true);
}
ImageCopy($this->_canvas, $params['canvas'], 0, 0, 0, 0, $this->_width, $this->_height);
$this->_clipping[count($this->_clipping)] = $params;
}
}
/**
* Get a canvas specific HTML tag.
*
@ -1615,6 +1774,8 @@ class Image_Canvas_GD extends Image_Canvas_WithMap
$php_info, $result))
{
$version = $result[1];
} else {
$version = null;
}
}

View File

@ -25,7 +25,7 @@
* @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 $
* @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
*/
@ -68,7 +68,7 @@ class Image_Canvas_ImageMap extends Image_Canvas
if (isset($params['htmltags'])) {
foreach ($params['htmltags'] as $key => $value) {
$tags .= ' ';
if (strpos($value, '"') >= 0) {
if (strpos($value, '"') !== false) {
$tags .= $key . '=\'' . $value . '\'';
} else {
$tags .= $key . '="' . $value . '"';
@ -331,7 +331,7 @@ class Image_Canvas_ImageMap extends Image_Canvas
function save($params = false)
{
parent::save($params);
$file = fopen($param['filename'], 'w+');
$file = fopen($params['filename'], 'w+');
fwrite($file, $this->toHtml($params));
fclose($file);
}

View File

@ -25,7 +25,7 @@
* @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: PDF.php,v 1.5 2005/10/28 09:54:40 nosey Exp $
* @version CVS: $Id: PDF.php,v 1.6 2006/04/11 21:12:41 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
@ -301,8 +301,6 @@ class Image_Canvas_PDF extends Image_Canvas
}
}
$this->_pdflib = $this->_version();
$addPage = true;
if ((isset($param['pdf'])) && (is_resource($param['pdf']))) {
$this->_pdf =& $param['pdf'];
@ -329,6 +327,8 @@ class Image_Canvas_PDF extends Image_Canvas
pdf_begin_page($this->_pdf, $this->_pageWidth, $this->_pageHeight);
}
$this->_reset();
$this->_pdflib = $this->_version();
}
/**
@ -543,7 +543,7 @@ class Image_Canvas_PDF extends Image_Canvas
$color = (isset($params['color']) ? $params['color'] : false);
if ($this->_setLineStyle($color)) {
pdf_moveto($this->_pdf, $this->_getX($params['x0']), $this->_getY($params['y0']));
pdf_lineto($this->_pdf, $this->_getX($params['x1']), $this->_getY($params['x1']));
pdf_lineto($this->_pdf, $this->_getX($params['x1']), $this->_getY($params['y1']));
pdf_stroke($this->_pdf);
}
parent::line($params);
@ -646,7 +646,7 @@ class Image_Canvas_PDF extends Image_Canvas
$line = $this->_setLineStyle($lineColor);
$fill = $this->_setFillStyle($fillColor);
if (($line) || ($fill)) {
pdf_rect($this->_pdf, $this->_getX(min($x0, $x1)), $this->_getY(max($y0, $y1)), abs($x1 - $x0), abs($y1 - $y0));
pdf_rect($this->_pdf, min($x0, $x1), min($y0, $y1), abs($x1 - $x0), abs($y1 - $y0));
if (($line) && ($fill)) {
pdf_fill_stroke($this->_pdf);
} elseif ($line) {
@ -672,10 +672,10 @@ class Image_Canvas_PDF extends Image_Canvas
*/
function ellipse($params)
{
$x = $this->_getX($params['x']);
$y = $this->_getY($params['y']);
$rx = $this->_getX($params['rx']);
$ry = $this->_getY($params['ry']);
$x = $params['x'];
$y = $params['y'];
$rx = $params['rx'];
$ry = $params['ry'];
$fillColor = (isset($params['fill']) ? $params['line'] : false);
$lineColor = (isset($params['line']) ? $params['line'] : false);
@ -823,7 +823,9 @@ class Image_Canvas_PDF extends Image_Canvas
$x = $x - ($textWidth / 2);
}
if ($alignment['vertical'] == 'top') {
$y -= $textHeight;
if ($alignment['vertical'] == 'bottom') {
$y = $y + $textHeight;
} elseif ($alignment['vertical'] == 'center') {
$y = $y + ($textHeight / 2);
@ -833,7 +835,7 @@ class Image_Canvas_PDF extends Image_Canvas
$color = $this->_font['color'];
}
pdf_show_xy($this->_pdf, $text, $this->_getX($x), $this->_getY($y));
pdf_show_xy($this->_pdf, $text, $x, $y);
parent::addText($params);
}
@ -901,7 +903,7 @@ class Image_Canvas_PDF extends Image_Canvas
$scale = max(($height/$height_), ($width/$width_));
}
pdf_place_image($this->_pdf, $image, $this->_getX($x), $this->_getY($y), $scale);
pdf_place_image($this->_pdf, $image, $x, $y, $scale);
pdf_close_image($this->_pdf, $image);
parent::image($params);
@ -980,8 +982,11 @@ class Image_Canvas_PDF extends Image_Canvas
function _version()
{
$result = false;
$version = '';
if (function_exists('pdf_get_majorversion')) {
$version = pdf_get_majorversion();
} else if (function_exists('pdf_get_value')) {
$version = pdf_get_value($this->_pdf, 'major', 0);
} else {
ob_start();
phpinfo(8);
@ -998,7 +1003,7 @@ class Image_Canvas_PDF extends Image_Canvas
if (ereg('([0-9]{1,2})\.[0-9]{1,2}(\.[0-9]{1,2})?', trim($version), $result)) {
return $result[1];
} else {
return 0;
return $version;
}
}

View File

@ -21,7 +21,7 @@
* @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: SVG.php,v 1.9 2005/11/08 19:00:35 nosey Exp $
* @version CVS: $Id: SVG.php,v 1.17 2007/06/22 20:15:35 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
@ -84,6 +84,13 @@ class Image_Canvas_SVG extends Image_Canvas
*/
var $_groupIDs = array();
/**
* The XML encoding (default iso-8859-1)
* @var string
* @access private
*/
var $_encoding = 'iso-8859-1';
/**
* Create the SVG canvas.
*
@ -93,12 +100,18 @@ class Image_Canvas_SVG extends Image_Canvas
*
* 'height' The height of the graph
*
* 'encoding' The encoding of the SVG document
*
* @param array $param Parameter array
*/
function Image_Canvas_SVG($param)
function Image_Canvas_SVG($params)
{
parent::Image_Canvas($param);
parent::Image_Canvas($params);
$this->_reset();
if (isset($params['encoding'])) {
$this->_encoding = $params['encoding'];
}
}
/**
@ -412,6 +425,8 @@ class Image_Canvas_SVG extends Image_Canvas
$y1 = $this->_getY($params['y1']);
$color = (isset($params['color']) ? $params['color'] : false);
$attrs = (isset($params['attrs']) && is_array($params['attrs'])) ? $this->_getAttributes($params['attrs']) : null;
$style = $this->_getLineStyle($color) . $this->_getFillStyle('transparent');
if ($style != '') {
$this->_addElement(
@ -421,6 +436,7 @@ class Image_Canvas_SVG extends Image_Canvas
'x2="' . round($x1) . '" ' .
'y2="' . round($y1) . '" ' .
'style="' . $style . '"' .
($attrs ? ' ' . $attrs : '') .
'/>',
$params
);
@ -447,6 +463,8 @@ class Image_Canvas_SVG extends Image_Canvas
}
$style = $this->_getLineStyle($lineColor) . $this->_getFillStyle($fillColor);
$attrs = (isset($params['attrs']) && is_array($params['attrs'])) ? $this->_getAttributes($params['attrs']) : null;
$first = true;
$spline = false;
$lastpoint = false;
@ -478,12 +496,13 @@ class Image_Canvas_SVG extends Image_Canvas
$first = false;
}
if ($connectEnds) {
$point .= ' Z';
$points .= ' Z';
}
$this->_addElement(
'<path ' .
'd="' . $points . '" ' .
'style="' . $style . '"' .
($attrs ? ' ' . $attrs : '') .
'/>',
$params
);
@ -512,6 +531,8 @@ class Image_Canvas_SVG extends Image_Canvas
$fillColor = (isset($params['fill']) ? $params['line'] : false);
$lineColor = (isset($params['line']) ? $params['line'] : false);
$attrs = (isset($params['attrs']) && is_array($params['attrs'])) ? $this->_getAttributes($params['attrs']) : null;
$style = $this->_getLineStyle($lineColor) . $this->_getFillStyle($fillColor);
if ($style != '') {
$this->_addElement(
@ -521,6 +542,7 @@ class Image_Canvas_SVG extends Image_Canvas
'width="' . round(abs($x1 - $x0)) . '" ' .
'height="' . round(abs($y1 - $y0)) . '" ' .
'style="' . $style . '"' .
($attrs ? ' ' . $attrs : '') .
'/>',
$params
);
@ -549,6 +571,8 @@ class Image_Canvas_SVG extends Image_Canvas
$fillColor = (isset($params['fill']) ? $params['line'] : false);
$lineColor = (isset($params['line']) ? $params['line'] : false);
$attrs = (isset($params['attrs']) && is_array($params['attrs'])) ? $this->_getAttributes($params['attrs']) : null;
$style = $this->_getLineStyle($lineColor) . $this->_getFillStyle($fillColor);
if ($style != '') {
$this->_addElement(
@ -558,6 +582,7 @@ class Image_Canvas_SVG extends Image_Canvas
'rx="' . round($rx) . '" ' .
'ry="' . round($ry) . '" ' .
'style="' . $style . '"' .
($attrs ? ' ' . $attrs : '') .
'/>',
$params
);
@ -594,6 +619,8 @@ class Image_Canvas_SVG extends Image_Canvas
$fillColor = (isset($params['fill']) ? $params['line'] : false);
$lineColor = (isset($params['line']) ? $params['line'] : false);
$attrs = (isset($params['attrs']) && is_array($params['attrs'])) ? $this->_getAttributes($params['attrs']) : null;
$dv = max($v2, $v1) - min($v2, $v1);
if ($dv >= 360) {
$this->ellipse($params);
@ -613,6 +640,7 @@ class Image_Canvas_SVG extends Image_Canvas
round($x2) . ',' . round($y2) . ' ' .
'Z" ' .
'style="' . $style . '"' .
($attrs ? ' ' . $attrs : '') .
'/>',
$params
);
@ -670,6 +698,8 @@ class Image_Canvas_SVG extends Image_Canvas
$color = (isset($params['color']) ? $params['color'] : false);
$alignment = (isset($params['alignment']) ? $params['alignment'] : false);
$attrs = (isset($params['attrs']) && is_array($params['attrs'])) ? $this->_getAttributes($params['attrs']) : null;
$textHeight = $this->textHeight($text);
if (!is_array($alignment)) {
@ -687,7 +717,7 @@ class Image_Canvas_SVG extends Image_Canvas
$align = '';
if ((isset($this->_font['vertical'])) && ($this->_font['vertical'])) {
$align .= 'writing-mode: tb-rl;';
// $align .= 'writing-mode: tb-rl;';
if ($alignment['vertical'] == 'bottom') {
$align .= 'text-anchor:end;';
@ -718,23 +748,27 @@ class Image_Canvas_SVG extends Image_Canvas
$textOpacity = $this->_opacity($color);
$this->_addElement(
'<text ' .
'x="' . round($x) . '" ' .
'y="' . round($y) . '" ' .
/* (isset($this->_font['angle']) && ($this->_font['angle'] > 0) ?
'rotate="' . $this->_font['angle'] . '" ' :
'<g transform="translate(' . round($x) . ', ' . round($y) . ')">' . "\n" .
$this->_indent . ' <text ' .
'x="0" ' .
'y="0" ' .
(isset($this->_font['angle']) && ($this->_font['angle'] > 0) ?
'transform="rotate(' . (($this->_font['angle'] + 180) % 360) . ')" ' :
''
) .*/
) .
'style="' .
(isset($this->_font['name']) ?
'font-family:' . $this->_font['name'] . ';' : '') .
'font-size:' . $this->_font['size'] . 'px;fill=' .
'font-size:' . $this->_font['size'] . 'px;fill:' .
$textColor . ($textOpacity ? ';fill-opacity:' .
$textOpacity :
''
) . ';' . $align . '">' .
) . ';' . $align . '"' .
($attrs ? ' ' . $attrs : '') .
'>' .
htmlspecialchars($text) .
'</text>',
'</text>' . "\n" .
$this->_indent . '</g>',
$params
);
parent::addText($params);
@ -757,6 +791,8 @@ class Image_Canvas_SVG extends Image_Canvas
$y = $this->_getY($params['y']);
$filename = $params['filename'];
$attrs = (isset($params['attrs']) && is_array($params['attrs'])) ? $this->_getAttributes($params['attrs']) : null;
list($width, $height, $type, $attr) = getimagesize($filename);
$width = (isset($params['width']) ? $params['width'] : $width);
$height = (isset($params['height']) ? $params['height'] : $height);
@ -767,10 +803,12 @@ class Image_Canvas_SVG extends Image_Canvas
fclose($file);
$data = 'data:' . image_type_to_mime_type($type) . ';base64,' . base64_encode($filedata);
$this->_addElement(
'<image xlink:href="' . $data . '" x="' . $x . '" y="' . $y . '"' .
($width ? ' width="' . $width . '"' : '') .
($height ? ' height="' . $height . '"' : '') .
($attrs ? ' ' . $attrs : '') .
' preserveAspectRatio="none"/>',
$params
);
@ -815,19 +853,10 @@ class Image_Canvas_SVG extends Image_Canvas
function show($param = false)
{
parent::show($param);
$output = '<?xml version="1.0" encoding="iso-8859-1"?>' . "\n" .
'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"' . "\n\t" .
' "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">' . "\n" .
'<svg width="' . $this->_width . '" height="' . $this->_height .
'" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">' . "\n" .
($this->_defs ?
' <defs>' . "\n" .
$this->_defs .
' </defs>' . "\n" :
''
) .
$this->_elements .
'</svg>';
$attrs = (isset($param['attrs']) && is_array($param['attrs'])) ? $this->_getAttributes($param['attrs']) : null;
$output = $this->getData($param);
header('Content-Type: image/svg+xml');
header('Content-Disposition: inline; filename = "' . basename($_SERVER['PHP_SELF'], '.php') . '.svg"');
@ -842,11 +871,33 @@ class Image_Canvas_SVG extends Image_Canvas
function save($param = false)
{
parent::save($param);
$output = '<?xml version="1.0" encoding="iso-8859-1"?>' . "\n" .
$output = $this->getData($param);
$file = fopen($param['filename'], 'w+');
fwrite($file, $output);
fclose($file);
}
/**
* Get SVG data
*
* @param array $param Parameter array
*
* @return string
*/
function getData($param = false)
{
$attrs = (isset($param['attrs']) && is_array($param['attrs'])) ? $this->_getAttributes($param['attrs']) : null;
return '<?xml version="1.0" encoding="'. $this->_encoding . '"?>' . "\n" .
'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"' . "\n\t" .
' "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">' . "\n" .
'<svg width="' . $this->_width . '" height="' . $this->_height .
'" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">' . "\n" .
'" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"' .
($attrs ? ' ' . $attrs : '') .
'>' . "\n" .
($this->_defs ?
' <defs>' . "\n" .
$this->_defs .
@ -855,10 +906,37 @@ class Image_Canvas_SVG extends Image_Canvas
) .
$this->_elements .
'</svg>';
}
$file = fopen($param['filename'], 'w+');
fwrite($file, $output);
fclose($file);
/**
* Set clipping to occur
*
* Parameter array:
*
* 'x0': int X point of Upper-left corner
* 'y0': int X point of Upper-left corner
* 'x1': int X point of lower-right corner
* 'y1': int Y point of lower-right corner
*/
function setClipping($params = false)
{
if ($params === false) {
$this->_addElement('</g>');
}
else {
$group = "clipping_" . $this->_id;
$this->_id++;
$this->_addElement('<g clip-path="url(#' . $group . ')">');
$this->_addDefine('<clipPath id="' . $group . '">');
$this->_addDefine(' <path d="' .
'M' . $this->_getX($params['x0']) . ' ' . $this->_getY($params['y0']) .
' H' . $this->_getX($params['x1']) .
' V' . $this->_getY($params['y1']) .
' H' . $this->_getX($params['x0']) .
' Z"/>');
$this->_addDefine('</clipPath>');
}
}
/**
@ -880,6 +958,22 @@ class Image_Canvas_SVG extends Image_Canvas
return '<embed src="' . $params['urlpath'] . $params['filename'] . '" width=' . $params['width'] . ' height=' . $params['height'] . ' type="image/svg+xml">';
}
/**
* Converts array of attributes to string
*
* @param array $attrs Attributes array
* @return array
*/
function _getAttributes($attrs)
{
$string = '';
foreach ($attrs as $key => $value) {
$string .= ' ' . $key . '="' . $value . '"';
}
return $string;
}
}
?>

View File

@ -18,7 +18,7 @@
* @author Andrew Morton <drewish@katherinehouse.com>
* @copyright 2003-2005 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id: Color.php,v 1.15 2005/09/12 19:12:02 drewish Exp $
* @version CVS: $Id: Color.php,v 1.17 2008/10/26 18:27:10 clockwerx Exp $
* @link http://pear.php.net/package/Image_Color
*/
@ -213,6 +213,7 @@ class Image_Color
$color2 =& $this->color2;
for ($x = 0; $x < 3; $x++) {
if (isset($color1[$x])) {
if (($color1[$x] + $degree) < 256) {
if (($color1[$x] + $degree) > -1) {
$color1[$x] += $degree;
@ -222,7 +223,9 @@ class Image_Color
} else {
$color1[$x] = 255;
}
}
if (isset($color2[$x])) {
if (($color2[$x] + $degree) < 256) {
if (($color2[$x] + $degree) > -1) {
$color2[$x] += $degree;
@ -234,6 +237,7 @@ class Image_Color
}
}
}
}
/**
* Determine if a light or dark text color would be more readable on a
@ -432,7 +436,7 @@ class Image_Color
break;
}
}
return $this->rgb2hex(array($r, $g, $b));
return Image_Color::rgb2hex(array($r, $g, $b));
}
/**

View File

@ -23,7 +23,7 @@
* @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: Graph.php,v 1.57 2005/10/05 20:51:22 nosey Exp $
* @version CVS: $Id: Graph.php,v 1.58 2005/11/27 18:48:05 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -162,9 +162,7 @@ class Image_Graph extends Image_Graph_Element
$this->_canvas =& $params;
$width = $this->_canvas->getWidth();
$height = $this->_canvas->getHeight();
}
if (is_int($params)) {
} elseif (is_numeric($params)) {
$width = $params;
}

View File

@ -24,7 +24,7 @@
* @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: Axis.php,v 1.33 2005/10/05 20:51:22 nosey Exp $
* @version CVS: $Id: Axis.php,v 1.35 2006/02/28 22:48:07 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -182,12 +182,16 @@ require_once 'Image/Graph/Plotarea/Element.php';
1 => array(
'interval' => 1,
'type' => 'auto',
'tick' => array('start' => -2, 'end' => 2),
'tick' => array(
'start' => -2,
'end' => 2,
'color' => false // default color
),
'showtext' => true,
'showoffset' => false,
'font' => array(),
'offset' => 0,
'position' => 'outside'
'position' => 'outside',
)
);
@ -702,9 +706,9 @@ require_once 'Image/Graph/Plotarea/Element.php';
if ($this->_axisValueSpan == 0) {
$this->_delta = false;
} elseif ($this->_type == IMAGE_GRAPH_AXIS_X) {
$this->_delta = (($this->_transpose ? $this->height() : $this->width()) - ($this->_axisPadding['low'] + $this->_axisPadding['high'])) / $this->_axisValueSpan;
$this->_delta = (($this->_transpose ? $this->height() : $this->width()) - ($this->_axisPadding['low'] + $this->_axisPadding['high'])) / ($this->_axisValueSpan + ($this->_pushValues ? 1 : 0));
} else {
$this->_delta = (($this->_transpose ? $this->width() : $this->height()) - ($this->_axisPadding['low'] + $this->_axisPadding['high'])) / $this->_axisValueSpan;
$this->_delta = (($this->_transpose ? $this->width() : $this->height()) - ($this->_axisPadding['low'] + $this->_axisPadding['high'])) / ($this->_axisValueSpan + ($this->_pushValues ? 1 : 0));
}
}
@ -1168,9 +1172,9 @@ require_once 'Image/Graph/Plotarea/Element.php';
} else {
$this->write(
$labelPosition,
$this->_top + 3 + $offset,
$this->_top + 6 + $offset + $font['size'] * (substr_count($labelText, "\n") + 1),
$labelText,
IMAGE_GRAPH_ALIGN_TOP | IMAGE_GRAPH_ALIGN_CENTER_X,
IMAGE_GRAPH_ALIGN_BOTTOM | IMAGE_GRAPH_ALIGN_CENTER_X,
$font
);
}
@ -1199,9 +1203,9 @@ require_once 'Image/Graph/Plotarea/Element.php';
if ($labelInside) {
$this->write(
$labelPosition,
$this->_bottom + 3 + $offset,
$this->_bottom + 6 + $offset + $font['size'] * (substr_count($labelText, "\n") + 1),
$labelText,
IMAGE_GRAPH_ALIGN_TOP | IMAGE_GRAPH_ALIGN_CENTER_X,
IMAGE_GRAPH_ALIGN_BOTTOM | IMAGE_GRAPH_ALIGN_CENTER_X,
$font
);
} else {
@ -1265,9 +1269,9 @@ require_once 'Image/Graph/Plotarea/Element.php';
} else {
$this->write(
$labelPosition,
$this->_top + 3 + $offset,
$this->_top + 6 + $offset + $font['size'] * (substr_count($labelText, "\n") + 1),
$labelText,
IMAGE_GRAPH_ALIGN_CENTER_X | IMAGE_GRAPH_ALIGN_TOP,
IMAGE_GRAPH_ALIGN_CENTER_X | IMAGE_GRAPH_ALIGN_BOTTOM,
$font
);
}
@ -1276,15 +1280,40 @@ require_once 'Image/Graph/Plotarea/Element.php';
}
}
$tickColor = false;
if (isset($this->_labelOptions[$level]['tick'])) {
if (isset($this->_labelOptions[$level]['tick']['start'])) {
$tickStart = $this->_labelOptions[$level]['tick']['start'];
} else {
$tickStart = false;
}
if (isset($this->_labelOptions[$level]['tick']['end'])) {
$tickEnd = $this->_labelOptions[$level]['tick']['end'];
} else {
$tickEnd = false;
}
if ((isset($this->_labelOptions[$level]['tick']['color'])) && ($this->_labelOptions[$level]['tick']['color'] !== false)) {
$tickColor = $this->_labelOptions[$level]['tick']['color'];
}
}
if ($tickStart === false) {
$tickStart = -2;
}
if ($tickEnd === false) {
$tickEnd = 2;
}
if ($tickColor !== false) {
$this->_canvas->setLineColor($tickColor);
}
else {
$this->_getLineStyle();
}
if ($this->_type == IMAGE_GRAPH_AXIS_Y) {
if ($tickStart === 'auto') {
$tickStart = -$offset;
@ -1389,9 +1418,15 @@ require_once 'Image/Graph/Plotarea/Element.php';
}
if ($this->_showArrow) {
if ($this->_getMaximum() <= 0) {
$data['end0'] = 'arrow2';
$data['size0'] = 7;
}
else {
$data['end1'] = 'arrow2';
$data['size1'] = 7;
}
}
$this->_canvas->line($data);
@ -1427,9 +1462,15 @@ require_once 'Image/Graph/Plotarea/Element.php';
);
}
if ($this->_showArrow) {
if ($this->_getMaximum() <= 0) {
$data['end0'] = 'arrow2';
$data['size0'] = 7;
}
else {
$data['end1'] = 'arrow2';
$data['size1'] = 7;
}
}
$this->_canvas->line($data);
if ($this->_title) {
@ -1464,9 +1505,15 @@ require_once 'Image/Graph/Plotarea/Element.php';
);
}
if ($this->_showArrow) {
if ($this->_getMaximum() <= 0) {
$data['end0'] = 'arrow2';
$data['size0'] = 7;
}
else {
$data['end1'] = 'arrow2';
$data['size1'] = 7;
}
}
$this->_canvas->line($data);
if ($this->_title) {

View File

@ -24,7 +24,7 @@
* @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 $
* @version CVS: $Id: Category.php,v 1.19 2006/03/02 12:15:17 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -93,7 +93,7 @@ class Image_Graph_Axis_Category extends Image_Graph_Axis
*/
function _getMaximum()
{
return count($this->_labels) - ($this->_pushValues ? 0 : 1);
return count($this->_labels) - 1;
}
/**
@ -124,9 +124,14 @@ class Image_Graph_Axis_Category extends Image_Graph_Axis
/**
* Forces the minimum value of the axis
*
* A minimum cannot be set on a SequentialAxis, it is always 0.
* <b>A minimum cannot be set on this type of axis</b>
*
* @param double $minimum The minumum value to use on the axis
* To modify the labels which are displayed on the axis, instead use
* setLabelInterval($labels) where $labels is an array containing the
* 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)
{
@ -135,10 +140,14 @@ class Image_Graph_Axis_Category extends Image_Graph_Axis
/**
* 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.
* <b>A maximum cannot be set on this type of axis</b>
*
* @param double $maximum The maximum value to use on the axis
* To modify the labels which are displayed on the axis, instead use
* setLabelInterval($labels) where $labels is an array containing the
* 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)
{
@ -147,13 +156,15 @@ class Image_Graph_Axis_Category extends Image_Graph_Axis
/**
* Sets an interval for where labels are shown on the axis.
*
* The label interval is rounded to nearest integer value
* 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') {
if (is_array($labelInterval)) {
parent::setLabelInterval($labelInterval);
} elseif ($labelInterval == 'auto') {
parent::setLabelInterval(1);
} else {
parent::setLabelInterval(round($labelInterval));

View File

@ -24,7 +24,7 @@
* @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 $
* @version CVS: $Id: Logarithmic.php,v 1.15 2006/03/02 12:35:57 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -63,6 +63,8 @@ class Image_Graph_Axis_Logarithmic extends Image_Graph_Axis
{
parent::Image_Graph_Axis($type);
$this->showLabel(IMAGE_GRAPH_LABEL_MINIMUM + IMAGE_GRAPH_LABEL_MAXIMUM);
$this->_minimum = 1;
$this->_minimumSet = true;
}
/**
@ -80,31 +82,6 @@ class Image_Graph_Axis_Logarithmic extends Image_Graph_Axis
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
*
@ -114,7 +91,7 @@ class Image_Graph_Axis_Logarithmic extends Image_Graph_Axis
*/
function _value($value)
{
return log10($value);
return log10($value) - log10($this->_minimum);
}
/**
@ -148,7 +125,7 @@ class Image_Graph_Axis_Logarithmic extends Image_Graph_Axis
return pow(10, $base+1);
}
return 1;
return max(1, $this->_minimum);
}
/**

View File

@ -23,7 +23,7 @@
* @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 $
* @version CVS: $Id: Common.php,v 1.16 2006/02/28 22:48:07 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -125,7 +125,7 @@ class Image_Graph_Common
foreach ($keys as $key) {
if (is_object($this->_elements[$key])) {
$this->_elements[$key]->_setParent($this);
@$result =& $this->_elements[$key]->_reset();
$result =& $this->_elements[$key]->_reset();
if (PEAR::isError($result)) {
return $result;
}
@ -241,12 +241,17 @@ class Image_Graph_Common
*/
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 : '') .

View File

@ -24,7 +24,7 @@
* @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 $
* @version CVS: $Id: Function.php,v 1.7 2005/11/11 17:53:44 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -84,7 +84,7 @@ class Image_Graph_DataPreprocessor_Function extends Image_Graph_DataPreprocessor
function _process($value)
{
$function = $this->_dataFunction;
return $function ($value);
return call_user_func($function, $value);
}
}

View File

@ -23,7 +23,7 @@
* @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: Element.php,v 1.16 2005/08/03 21:21:52 nosey Exp $
* @version CVS: $Id: Element.php,v 1.18 2006/02/28 22:48:07 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -146,7 +146,7 @@ class Image_Graph_Element extends Image_Graph_Common
* @var int
* @access private
*/
var $_padding = 0;
var $_padding = array('left' => 0, 'top' => 0, 'right' => 0, 'bottom' => 0);
/**
* Sets the background fill style of the element
@ -466,6 +466,27 @@ class Image_Graph_Element extends Image_Graph_Common
$this->_fontOptions['color'] = $color;
}
/**
* Clip the canvas to the coordinates of the element
*
* @param $enable bool Whether clipping should be enabled or disabled
* @access protected
*/
function _clip($enable)
{
$this->_canvas->setClipping(
($enable ?
array(
'x0' => min($this->_left, $this->_right),
'y0' => min($this->_top, $this->_bottom),
'x1' => max($this->_left, $this->_right),
'y1' => max($this->_top, $this->_bottom)
)
: false
)
);
}
/**
* Sets the coordinates of the element
*
@ -541,11 +562,26 @@ class Image_Graph_Element extends Image_Graph_Common
/**
* Sets padding of the element
*
* @param int $padding Number of pixels the element should be padded with
* @param mixed $padding Number of pixels the element should be padded with
* or an array of paddings (left, top, right and bottom as index)
*/
function setPadding($padding)
{
$this->_padding = $padding;
if (is_array($padding)) {
$this->_padding = array();
$this->_padding['left'] = (isset($padding['left']) ? $padding['left'] : 0);
$this->_padding['top'] = (isset($padding['top']) ? $padding['top'] : 0);
$this->_padding['right'] = (isset($padding['right']) ? $padding['right'] : 0);
$this->_padding['bottom'] = (isset($padding['bottom']) ? $padding['bottom'] : 0);
}
else {
$this->_padding = array(
'left' => $padding,
'top' => $padding,
'right' => $padding,
'bottom' => $padding
);
}
}
/**
@ -576,7 +612,7 @@ class Image_Graph_Element extends Image_Graph_Common
*/
function _fillLeft()
{
return $this->_left + $this->_padding;
return $this->_left + $this->_padding['left'];
}
/**
@ -587,7 +623,7 @@ class Image_Graph_Element extends Image_Graph_Common
*/
function _fillTop()
{
return $this->_top + $this->_padding;
return $this->_top + $this->_padding['top'];
}
/**
@ -598,7 +634,7 @@ class Image_Graph_Element extends Image_Graph_Common
*/
function _fillRight()
{
return $this->_right - $this->_padding;
return $this->_right - $this->_padding['right'];
}
/**
@ -609,7 +645,7 @@ class Image_Graph_Element extends Image_Graph_Common
*/
function _fillBottom()
{
return $this->_bottom - $this->_padding;
return $this->_bottom - $this->_padding['bottom'];
}
/**

View File

@ -24,7 +24,7 @@
* @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: Layout.php,v 1.11 2005/09/14 20:27:25 nosey Exp $
* @version CVS: $Id: Layout.php,v 1.12 2006/02/28 22:48:07 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -71,7 +71,7 @@ class Image_Graph_Layout extends Image_Graph_Plotarea_Element
function Image_Graph_Layout()
{
parent::Image_Graph_Element();
$this->_padding = 2;
$this->_padding = array('left' => 2, 'top' => 2, 'right' => 2, 'bottom' => 2);
}
/**
@ -146,10 +146,10 @@ class Image_Graph_Layout extends Image_Graph_Plotarea_Element
);
$this->_setCoords(
$left + $this->_padding,
$top + $this->_padding,
$right - $this->_padding,
$bottom - $this->_padding
$left + $this->_padding['left'],
$top + $this->_padding['top'],
$right - $this->_padding['right'],
$bottom - $this->_padding['bottom']
);
}
}

View File

@ -24,7 +24,7 @@
* @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: Horizontal.php,v 1.10 2005/08/24 20:35:58 nosey Exp $
* @version CVS: $Id: Horizontal.php,v 1.11 2006/02/28 22:48:07 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -115,7 +115,7 @@ class Image_Graph_Layout_Horizontal extends Image_Graph_Layout
$this->_percentage = max(0, min(100, $percentage));
}
$this->_split();
$this->_padding = 0;
$this->_padding = array('left' => 0, 'top' => 0, 'right' => 0, 'bottom' => 0);
}
/**

View File

@ -24,7 +24,7 @@
* @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: Legend.php,v 1.15 2005/09/30 18:59:18 nosey Exp $
* @version CVS: $Id: Legend.php,v 1.16 2006/02/28 22:48:07 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -81,7 +81,7 @@ class Image_Graph_Legend extends Image_Graph_Layout
function Image_Graph_Legend()
{
parent::Image_Graph_Layout();
$this->_padding = 5;
$this->_padding = array('left' => 5, 'top' => 5, 'right' => 5, 'bottom' => 5);
}
/**
@ -120,13 +120,13 @@ class Image_Graph_Legend extends Image_Graph_Layout
*/
function _parameterArray($simulate = false)
{
$param['left'] = $this->_left + $this->_padding;
$param['top'] = $this->_top + $this->_padding;
$param['right'] = $this->_right - $this->_padding;
$param['bottom'] = $this->_bottom - $this->_padding;
$param['left'] = $this->_left + $this->_padding['left'];
$param['top'] = $this->_top + $this->_padding['top'];
$param['right'] = $this->_right - $this->_padding['right'];
$param['bottom'] = $this->_bottom - $this->_padding['bottom'];
$param['align'] = $this->_alignment;
$param['x'] = $this->_left + $this->_padding;
$param['y'] = $this->_top + $this->_padding;
$param['x'] = $this->_left + $this->_padding['left'];
$param['y'] = $this->_top + $this->_padding['top'];
$param['width'] = 16;
$param['height'] = 16;
$param['show_marker'] = $this->_showMarker;
@ -166,7 +166,7 @@ class Image_Graph_Legend extends Image_Graph_Layout
unset($keys2);
}
unset($keys);
return abs($param['y'] - $param0['y']) + 2*$this->_padding;
return abs($param['y'] - $param0['y']) + $this->_padding['top'] + $this->_padding['bottom'];
} else {
return parent::height();
}
@ -234,15 +234,15 @@ class Image_Graph_Legend extends Image_Graph_Layout
}
if (($this->_alignment & IMAGE_GRAPH_ALIGN_BOTTOM) != 0) {
$y = $this->_parent->_fillBottom() - $h - $this->_padding;
$y = $this->_parent->_fillBottom() - $h - $this->_padding['bottom'];
} else {
$y = $this->_parent->_fillTop() + $this->_padding;
$y = $this->_parent->_fillTop() + $this->_padding['top'];
}
if (($this->_alignment & IMAGE_GRAPH_ALIGN_LEFT) != 0) {
$x = $this->_parent->_fillLeft() + $this->_padding;
$x = $this->_parent->_fillLeft() + $this->_padding['left'];
} else {
$x = $this->_parent->_fillRight() - $w - $this->_padding;
$x = $this->_parent->_fillRight() - $w - $this->_padding['right'];
}
$this->_setCoords($x, $y, $x + $w, $y + $h);

View File

@ -24,7 +24,7 @@
* @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: Value.php,v 1.9 2005/08/24 20:35:52 nosey Exp $
* @version CVS: $Id: Value.php,v 1.10 2006/02/28 22:48:07 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -72,7 +72,7 @@ class Image_Graph_Marker_Value extends Image_Graph_Marker
function Image_Graph_Marker_Value($useValue = IMAGE_GRAPH_VALUE_X)
{
parent::Image_Graph_Marker();
$this->_padding = 2;
$this->_padding = array('left' => 2, 'top' => 2, 'right' => 2, 'bottom' => 2);
$this->_useValue = $useValue;
$this->_fillStyle = 'white';
$this->_borderStyle = 'black';
@ -192,8 +192,8 @@ class Image_Graph_Marker_Value extends Image_Graph_Marker
$width = $this->_canvas->textWidth($value);
$height = $this->_canvas->textHeight($value);
$offsetX = $width/2 + $this->_padding;
$offsetY = $height/2 + $this->_padding;
$offsetX = $width/2 + $this->_padding['left'];
$offsetY = $height/2 + $this->_padding['top'];
$this->_getFillStyle();
$this->_getBorderStyle();

View File

@ -24,7 +24,7 @@
* @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: Plot.php,v 1.18 2005/09/30 18:59:19 nosey Exp $
* @version CVS: $Id: Plot.php,v 1.20 2006/02/28 22:33:00 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -453,7 +453,7 @@ class Image_Graph_Plot extends Image_Graph_Plotarea_Element
$x = $point['X'];
$y = $point['Y'];
if (((!is_object($this->_dataSelector)) ||
($this->_dataSelector->_select($point))) && ($point['Y'] != null))
($this->_dataSelector->_select($point))) && ($point['Y'] !== null))
{
$point = $this->_getMarkerData(
@ -704,12 +704,17 @@ class Image_Graph_Plot extends Image_Graph_Plotarea_Element
$dataset->_reset();
while ($point = $dataset->_next()) {
$x = $point['X'];
if (is_numeric($point['Y'])) {
$total['ALL_SUM_Y'] += $point['Y'];
if (isset($total['TOTAL_Y'][$x])) {
$total['TOTAL_Y'][$x] += $point['Y'];
} else {
$total['TOTAL_Y'][$x] = $point['Y'];
}
}
if (is_numeric($point['X'])) {
if (isset($total['TOTAL_X'][$x])) {
$total['TOTAL_X'][$x] += $point['X'];
} else {
@ -717,6 +722,7 @@ class Image_Graph_Plot extends Image_Graph_Plotarea_Element
}
}
}
}
unset($keys);
return $total;
}

View File

@ -24,7 +24,7 @@
* @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.12 2005/08/08 19:09:18 nosey Exp $
* @version CVS: $Id: Area.php,v 1.13 2005/11/27 22:21:17 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -88,6 +88,9 @@ class Image_Graph_Plot_Area extends Image_Graph_Plot
}
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
$base = array();
if ($this->_multiType == 'stacked') {
reset($this->_dataset);
@ -179,7 +182,10 @@ class Image_Graph_Plot_Area extends Image_Graph_Plot
}
unset($keys);
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup();
return true;
}

View File

@ -24,7 +24,7 @@
* @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: Band.php,v 1.11 2005/08/23 21:01:46 nosey Exp $
* @version CVS: $Id: Band.php,v 1.12 2005/11/27 22:21:16 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
* @since File available since Release 0.3.0dev2
*/
@ -102,6 +102,10 @@ class Image_Graph_Plot_Band extends Image_Graph_Plot
$current = array();
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
@ -189,7 +193,10 @@ class Image_Graph_Plot_Band extends Image_Graph_Plot
}
unset($keys);
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup();
return true;
}

View File

@ -24,7 +24,7 @@
* @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: Bar.php,v 1.13 2005/08/24 16:02:49 nosey Exp $
* @version CVS: $Id: Bar.php,v 1.14 2005/11/27 22:21:16 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -133,6 +133,8 @@ class Image_Graph_Plot_Bar extends Image_Graph_Plot
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
if ($this->_width == 'auto') {
$width = $this->_parent->_labelDistance(IMAGE_GRAPH_AXIS_X) / 2;
} elseif ($this->_width['unit'] == '%') {
@ -294,7 +296,10 @@ class Image_Graph_Plot_Bar extends Image_Graph_Plot
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup();
return true;
}
}

View File

@ -24,7 +24,7 @@
* @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: BoxWhisker.php,v 1.13 2005/09/08 19:02:18 nosey Exp $
* @version CVS: $Id: BoxWhisker.php,v 1.14 2005/11/27 22:21:17 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
* @since File available since Release 0.3.0dev2
*/
@ -206,6 +206,8 @@ class Image_Graph_Plot_BoxWhisker extends Image_Graph_Plot
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
if ($this->_multiType == 'stacked100pct') {
$total = $this->_getTotals();
}
@ -285,6 +287,8 @@ class Image_Graph_Plot_BoxWhisker extends Image_Graph_Plot
unset($keys);
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup();
return true;
}

View File

@ -24,7 +24,7 @@
* @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: CandleStick.php,v 1.11 2005/08/30 21:25:24 nosey Exp $
* @version CVS: $Id: CandleStick.php,v 1.12 2005/11/27 22:21:16 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
* @since File available since Release 0.3.0dev2
*/
@ -161,6 +161,8 @@ class Image_Graph_Plot_CandleStick extends Image_Graph_Plot
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
if ($this->_multiType == 'stacked100pct') {
$total = $this->_getTotals();
}
@ -237,6 +239,8 @@ class Image_Graph_Plot_CandleStick extends Image_Graph_Plot
unset($keys);
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup($this->_title);
return true;

View File

@ -24,7 +24,7 @@
* @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: Dot.php,v 1.10 2005/08/03 21:21:56 nosey Exp $
* @version CVS: $Id: Dot.php,v 1.11 2005/11/27 22:21:16 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -84,8 +84,12 @@ class Image_Graph_Plot_Dot extends Image_Graph_Plot
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup();
return true;

View File

@ -24,7 +24,7 @@
* @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.1 2005/09/14 20:27:25 nosey Exp $
* @version CVS: $Id: Line.php,v 1.2 2005/11/27 22:21:18 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -84,6 +84,7 @@ class Image_Graph_Plot_Fit_Line extends Image_Graph_Plot
}
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
@ -107,6 +108,7 @@ class Image_Graph_Plot_Fit_Line extends Image_Graph_Plot
)
);
}
$this->_clip(false);
$this->_canvas->endGroup();
return true;

View File

@ -24,7 +24,7 @@
* @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: Impulse.php,v 1.12 2005/08/08 19:09:18 nosey Exp $
* @version CVS: $Id: Impulse.php,v 1.13 2005/11/27 22:21:17 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -80,7 +80,7 @@ class Image_Graph_Plot_Impulse extends Image_Graph_Plot
}
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
if ($this->_multiType == 'stacked100pct') {
$total = $this->_getTotals();
@ -194,6 +194,7 @@ class Image_Graph_Plot_Impulse extends Image_Graph_Plot
}
unset($keys);
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup();
return true;
}

View File

@ -24,7 +24,7 @@
* @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.12 2005/08/08 19:09:18 nosey Exp $
* @version CVS: $Id: Line.php,v 1.15 2006/03/02 12:37:37 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -98,7 +98,7 @@ class Image_Graph_Plot_Line extends Image_Graph_Plot
}
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
reset($this->_dataset);
if ($this->_multiType == 'stacked100pct') {
@ -134,6 +134,9 @@ class Image_Graph_Plot_Line extends Image_Graph_Plot
$this->_getLineStyle($key);
$this->_canvas->polygon(array('connect' => false, 'map_vertices' => true));
}
else {
$this->_canvas->reset();
}
$numPoints = 0;
} else {
$p2['X'] = $this->_pointX($point);
@ -152,9 +155,13 @@ class Image_Graph_Plot_Line extends Image_Graph_Plot
$this->_getLineStyle($key);
$this->_canvas->polygon(array('connect' => false, 'map_vertices' => true));
}
else {
$this->_canvas->reset();
}
}
unset($keys);
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup();
return true;
}

View File

@ -24,7 +24,7 @@
* @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: Odo.php,v 1.2 2005/09/30 18:59:19 nosey Exp $
* @version CVS: $Id: Odo.php,v 1.3 2005/11/27 22:21:16 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -639,6 +639,7 @@ class Image_Graph_Plot_Odo extends Image_Graph_Plot
if (is_array($this->_dataset)) {
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
$totals = $this->_getTotals();
$totals['CENTER_X'] = (int) (($this->_left + $this->_right) / 2);
@ -710,6 +711,7 @@ class Image_Graph_Plot_Odo extends Image_Graph_Plot
}
}
unset($keys);
$this->_clip(false);
$this->_canvas->endGroup();
}
}

View File

@ -24,7 +24,7 @@
* @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: Pie.php,v 1.17 2005/09/29 18:21:24 nosey Exp $
* @version CVS: $Id: Pie.php,v 1.19 2005/11/27 22:21:16 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -83,6 +83,20 @@ class Image_Graph_Plot_Pie extends Image_Graph_Plot
*/
var $_diameter = false;
/**
* Group items below this limit together as "the rest"
* @access private
* @var double
*/
var $_restGroupLimit = false;
/**
* Rest group title
* @access private
* @var string
*/
var $_restGroupTitle = 'The rest';
/**
* Perform the actual drawing on the legend.
*
@ -200,7 +214,12 @@ class Image_Graph_Plot_Pie extends Image_Graph_Plot
$dataset->_reset();
$currentY = 0;
$the_rest = 0;
while ($point = $dataset->_next()) {
if (($this->_restGroupLimit !== false) && ($point['Y'] <= $this->_restGroupLimit)) {
$the_rest += $point['Y'];
}
else {
if ((!is_object($this->_dataSelector)) ||
($this->_dataSelector->select($point))
) {
@ -219,6 +238,23 @@ class Image_Graph_Plot_Pie extends Image_Graph_Plot
}
}
}
}
if ($the_rest > 0) {
$point = array('X' => $this->_restGroupTitle, 'Y' => $the_rest);
$point = $this->_getMarkerData(
$point,
false,
false,
$totals
);
if (is_array($point)) {
$this->_marker->_drawMarker(
$point['MARKER_X'],
$point['MARKER_Y'],
$point
);
}
}
$number++;
}
unset($keys);
@ -273,6 +309,20 @@ class Image_Graph_Plot_Pie extends Image_Graph_Plot
$this->_diameter = $diameter;
}
/**
* Set the limit for the y-value, where values below are grouped together
* as "the rest"
*
* @param double $limit The limit
* @param string $title The title to display in the legends (default 'The
* rest')
*/
function setRestGroup($limit, $title = 'The rest')
{
$this->_restGroupLimit = $limit;
$this->_restGroupTitle = $title;
}
/**
* Get the diameter of the plot
* @return int The number of pixels the diameter is
@ -342,7 +392,12 @@ class Image_Graph_Plot_Pie extends Image_Graph_Plot
$radius1 = ($number + 1) * $dr;
}
$the_rest = 0;
while ($point = $dataset->_next()) {
if (($this->_restGroupLimit !== false) && ($point['Y'] <= $this->_restGroupLimit)) {
$the_rest += $point['Y'];
}
else {
$angle1 = 360 * ($currentY / $totalY) + $this->_startingAngle;
$currentY += $this->_angleDirection * $point['Y'];
$angle2 = 360 * ($currentY / $totalY) + $this->_startingAngle;
@ -383,6 +438,49 @@ class Image_Graph_Plot_Pie extends Image_Graph_Plot
)
);
}
}
if ($the_rest > 0) {
$angle1 = 360 * ($currentY / $totalY) + $this->_startingAngle;
$currentY += $this->_angleDirection * $the_rest;
$angle2 = 360 * ($currentY / $totalY) + $this->_startingAngle;
$x = 'rest';
$id = 'rest';
$dX = 0;
$dY = 0;
$explodeRadius = 0;
if ((is_array($this->_explode)) && (isset($this->_explode[$x]))) {
$explodeRadius = $this->_explode[$x];
} elseif (is_numeric($this->_explode)) {
$explodeRadius = $this->_explode;
}
if ($explodeRadius > 0) {
$dX = $explodeRadius * cos(deg2rad(($angle1 + $angle2) / 2));
$dY = $explodeRadius * sin(deg2rad(($angle1 + $angle2) / 2));
}
$ID = $id;
$this->_getFillStyle($ID);
$this->_getLineStyle($ID);
$this->_canvas->pieslice(
$this->_mergeData(
$point,
array(
'x' => $centerX + $dX,
'y' => $centerY + $dY,
'rx' => $radius1,
'ry' => $radius1,
'v1' => $angle1,
'v2' => $angle2,
'srx' => $radius0,
'sry' => $radius0
)
)
);
}
$number++;
}
unset($keys);
@ -401,6 +499,7 @@ class Image_Graph_Plot_Pie extends Image_Graph_Plot
if (is_array($this->_dataset)) {
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
$totals = $this->_getTotals();
$totals['CENTER_X'] = (int) (($this->_left + $this->_right) / 2);
@ -419,9 +518,13 @@ class Image_Graph_Plot_Pie extends Image_Graph_Plot
$count++;
$dataset->_reset();
$the_rest = 0;
while ($point = $dataset->_next()) {
$caption = $point['X'];
if (($this->_restGroupLimit !== false) && ($point['Y'] <= $this->_restGroupLimit)) {
$the_rest += $point['Y'];
}
else {
$this->_canvas->setFont($param['font']);
$width = 20 + $param['width'] + $this->_canvas->textWidth($caption);
$param['maxwidth'] = max($param['maxwidth'], $width);
@ -471,7 +574,46 @@ class Image_Graph_Plot_Pie extends Image_Graph_Plot
}
}
}
if ($the_rest > 0) {
$this->_canvas->setFont($param['font']);
$width = 20 + $param['width'] + $this->_canvas->textWidth($this->_restGroupTitle);
$param['maxwidth'] = max($param['maxwidth'], $width);
$x2 = $param['x'] + $width;
$y2 = $param['y'] + $param['height']+5;
if ((($param['align'] & IMAGE_GRAPH_ALIGN_VERTICAL) != 0) && ($y2 > $param['bottom'])) {
$param['y'] = $param['top'];
$param['x'] = $x2;
$y2 = $param['y'] + $param['height'];
} elseif ((($param['align'] & IMAGE_GRAPH_ALIGN_VERTICAL) == 0) && ($x2 > $param['right'])) {
$param['x'] = $param['left'];
$param['y'] = $y2;
$x2 = $param['x'] + 20 + $param['width'] + $this->_canvas->textWidth($this->_restGroupTitle);
}
$x = $x0 = $param['x'];
$y = $param['y'];
$y0 = $param['y'] - $param['height']/2;
$x1 = $param['x'] + $param['width'];
$y1 = $param['y'] + $param['height']/2;
if (!isset($param['simulate'])) {
$this->_getFillStyle('rest');
$this->_getLineStyle('rest');
$this->_drawLegendSample($x0, $y0, $x1, $y1);
$this->write($x + $param['width'] + 10, $y, $this->_restGroupTitle, IMAGE_GRAPH_ALIGN_CENTER_Y | IMAGE_GRAPH_ALIGN_LEFT, $param['font']);
}
if (($param['align'] & IMAGE_GRAPH_ALIGN_VERTICAL) != 0) {
$param['y'] = $y2;
} else {
$param['x'] = $x2;
}
}
}
unset($keys);
$this->_clip(false);
$this->_canvas->endGroup();
}
}

View File

@ -24,7 +24,7 @@
* @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.10 2005/08/03 21:21:55 nosey Exp $
* @version CVS: $Id: Radar.php,v 1.11 2005/11/27 22:21:16 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -85,6 +85,7 @@ class Image_Graph_Plot_Radar extends Image_Graph_Plot
function _done()
{
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
if (is_a($this->_parent, 'Image_Graph_Plotarea_Radar')) {
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
@ -107,6 +108,7 @@ class Image_Graph_Plot_Radar extends Image_Graph_Plot
}
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup();
return parent::_done();
}

View File

@ -24,7 +24,7 @@
* @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.10 2005/08/03 21:21:52 nosey Exp $
* @version CVS: $Id: Area.php,v 1.11 2005/11/27 22:21:17 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -85,6 +85,8 @@ class Image_Graph_Plot_Smoothed_Area extends Image_Graph_Plot_Smoothed_Bezier
}
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
@ -133,6 +135,7 @@ class Image_Graph_Plot_Smoothed_Area extends Image_Graph_Plot_Smoothed_Bezier
}
unset($keys);
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup();
return true;
}

View File

@ -24,7 +24,7 @@
* @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/08 19:09:19 nosey Exp $
* @version CVS: $Id: Line.php,v 1.14 2006/03/02 12:37:37 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -94,6 +94,7 @@ class Image_Graph_Plot_Smoothed_Line extends Image_Graph_Plot_Smoothed_Bezier
}
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
$dataset =& $this->_dataset[$key];
@ -105,6 +106,9 @@ class Image_Graph_Plot_Smoothed_Line extends Image_Graph_Plot_Smoothed_Bezier
$this->_getLineStyle($key);
$this->_canvas->polygon(array('connect' => false, 'map_vertices' => true));
}
else {
$this->_canvas->reset();
}
$numPoints = 0;
} else {
$p0 = $dataset->_nearby(-2);
@ -153,9 +157,13 @@ class Image_Graph_Plot_Smoothed_Line extends Image_Graph_Plot_Smoothed_Bezier
$this->_getLineStyle();
$this->_canvas->polygon(array('connect' => false, 'map_vertices' => true));
}
else {
$this->_canvas->reset();
}
}
unset($keys);
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup();
return true;
}

View File

@ -24,7 +24,7 @@
* @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.9 2005/08/03 21:21:52 nosey Exp $
* @version CVS: $Id: Radar.php,v 1.10 2005/11/27 22:21:17 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
* @since File available since Release 0.3.0dev2
*/
@ -59,6 +59,7 @@ class Image_Graph_Plot_Smoothed_Radar extends Image_Graph_Plot_Smoothed_Bezier
function _done()
{
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
if (is_a($this->_parent, 'Image_Graph_Plotarea_Radar')) {
$keys = array_keys($this->_dataset);
foreach ($keys as $key) {
@ -131,6 +132,7 @@ class Image_Graph_Plot_Smoothed_Radar extends Image_Graph_Plot_Smoothed_Bezier
unset($keys);
}
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup($this->_title);
return parent::_done();
}

View File

@ -24,7 +24,7 @@
* @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: Step.php,v 1.14 2005/10/05 20:51:21 nosey Exp $
* @version CVS: $Id: Step.php,v 1.15 2005/11/27 22:21:16 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -107,6 +107,7 @@ class Image_Graph_Plot_Step extends Image_Graph_Plot
}
$this->_canvas->startGroup(get_class($this) . '_' . $this->_title);
$this->_clip(true);
if ($this->_multiType == 'stacked100pct') {
$total = $this->_getTotals();
@ -190,6 +191,7 @@ class Image_Graph_Plot_Step extends Image_Graph_Plot
}
unset($keys);
$this->_drawMarker();
$this->_clip(false);
$this->_canvas->endGroup();
return true;
}

View File

@ -24,7 +24,7 @@
* @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: Plotarea.php,v 1.21 2005/10/05 20:51:21 nosey Exp $
* @version CVS: $Id: Plotarea.php,v 1.23 2006/02/28 22:48:07 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -133,7 +133,7 @@ class Image_Graph_Plotarea extends Image_Graph_Layout
{
parent::Image_Graph_Layout();
$this->_padding = 5;
$this->_padding = array('left' => 5, 'top' => 5, 'right' => 5, 'bottom' => 5);;
include_once 'Image/Graph.php';
@ -628,7 +628,9 @@ class Image_Graph_Plotarea extends Image_Graph_Layout
(is_a($element, 'Image_Graph_Plot_CandleStick')) ||
(is_a($element, 'Image_Graph_Plot_BoxWhisker')) ||
(is_a($element, 'Image_Graph_Plot_Impulse'))) &&
($this->_axisX != null))
($this->_axisX != null) &&
(strtolower(get_class($this->_axisX)) != 'image_graph_axis') // do not push plot if x-axis is linear
)
{
$this->_axisX->_pushValues();
}
@ -643,10 +645,10 @@ class Image_Graph_Plotarea extends Image_Graph_Layout
$pctWidth = (int) ($this->width() * 0.05);
$pctHeight = (int) ($this->height() * 0.05);
$left = $this->_left + $this->_padding;
$top = $this->_top + $this->_padding;
$right = $this->_right - $this->_padding;
$bottom = $this->_bottom - $this->_padding;
$left = $this->_left + $this->_padding['left'];
$top = $this->_top + $this->_padding['top'];
$right = $this->_right - $this->_padding['right'];
$bottom = $this->_bottom - $this->_padding['bottom'];
// temporary place holder for axis point calculations
$axisPoints['x'] = array($left, $top, $right, $bottom);

View File

@ -24,7 +24,7 @@
* @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: Map.php,v 1.9 2005/08/24 20:36:01 nosey Exp $
* @version CVS: $Id: Map.php,v 1.10 2006/02/28 22:48:07 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -119,7 +119,7 @@ class Image_Graph_Plotarea_Map extends Image_Graph_Plotarea
*/
function _fillLeft()
{
return $this->_left + $this->_padding;
return $this->_left + $this->_padding['left'];
}
/**
@ -130,7 +130,7 @@ class Image_Graph_Plotarea_Map extends Image_Graph_Plotarea
*/
function _fillTop()
{
return $this->_top + $this->_padding;
return $this->_top + $this->_padding['top'];
}
/**
@ -141,7 +141,7 @@ class Image_Graph_Plotarea_Map extends Image_Graph_Plotarea
*/
function _fillRight()
{
return $this->_right - $this->_padding;
return $this->_right - $this->_padding['right'];
}
/**
@ -152,7 +152,7 @@ class Image_Graph_Plotarea_Map extends Image_Graph_Plotarea
*/
function _fillBottom()
{
return $this->_bottom - $this->_padding;
return $this->_bottom - $this->_padding['bottom'];
}
/**

View File

@ -24,7 +24,7 @@
* @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.7 2005/08/24 20:36:02 nosey Exp $
* @version CVS: $Id: Radar.php,v 1.8 2006/02/28 22:48:07 nosey Exp $
* @link http://pear.php.net/package/Image_Graph
*/
@ -54,7 +54,7 @@ class Image_Graph_Plotarea_Radar extends Image_Graph_Plotarea
function Image_Graph_Plotarea_Radar()
{
parent::Image_Graph_Element();
$this->_padding = 10;
$this->_padding = array('left' => 10, 'top' => 10, 'right' => 10, 'bottom' => 10);
$this->_axisX =& Image_Graph::factory('Image_Graph_Axis_Radar');
$this->_axisX->_setParent($this);
$this->_axisY =& Image_Graph::factory('Image_Graph_Axis', IMAGE_GRAPH_AXIS_Y);

View File

@ -1,48 +0,0 @@
**************************
Image_Canvas - Changelog
**************************
Version 0.2.4 [2005-Nov-08] - Jesper Veggerby <pear.nosey@veggerby.dk>
* Fixed a bug causing in Image_Canvas_SVG causing grouping to give a "Missing argument..." error (this rendered Image_Graph using SVG broken)
* Fixed a bug causing rectangles not being displayed, if points were given in the wrong order
Version 0.2.3 [2005-Oct-28] - Jesper Veggerby <pear.nosey@veggerby.dk>
* Fixed Bug #5786 "Error in producing SVG"
* Fixed Bug #5805 "Canvas\Fonts\fontmap.txt is missing"
Version 0.2.2 [2005-Sep-30] - Jesper Veggerby <pear.nosey@veggerby.dk>
* Added 'border' and 'cssclass' option to Image_Canvas_GD::toHtml()
* Added image support when using SVG (using embedded base64 encoding)
* Added link ("imagemap") support with SVG
* Made image loading in GD canvas use getimagesize() to determine type instead of relying on extension
* Fixed bug where 'htmltags' were not transferred to image mapping of polygon vertices
* Fixed bug in SVG where pie slices with some specific angles curled the wrong way
* Fixed bug in Image_Canvas_ImageMap::show() and Image_Canvas_ImageMap::save() calling non-existing method _toHtml()
* Fixed bug in Image_Canvas_SVG::polygon() not showing polygon if last point was a spline - addSpline()
* Fixed bug causing line ends not to show if color not exlicitly defined
* Fixed Bug #5066 "Reference Notices" (from Image_Graph)
* Fixed bug #5175 "Unable to define IMAGE_GRAPH_SYSTEM_FONT_PATH outside of Config.php"
* Fixed Bug #5325 "Image/Color.php compatibility with old PHP versions"
Version 0.2.1 [2005-Aug-08] - Jesper Veggerby <pear.nosey@veggerby.dk>
* Added Request #4997 "HTML attributes and JS actions in imagemaps" - using 'htmltags' entry
* Fixed bug with fonts, now it's not required for the font to have a name
* Changed examples to use require_once instead of include/require
Version 0.2.0 [2005-Aug-01] - Jesper Veggerby <pear.nosey@veggerby.dk>
* First released package in PEAR
* Added support for image maps - a separate canvas (Image_Canvas_ImageMap) has been created to accomplish this
* Added support for antialiasing images when using GD (both using native GD method and Image_Graph own implementation)
* Added support for multi line texts
* Added a toHtml() method for to easy facilitate including canvas in HTML (this includes the associated image map, if any)
* Added line ends - only supported in GD canvases currently and not on polygons (yet!)
Version 0.1.2 [2005-Jul-21] - Jesper Veggerby <pear.nosey@veggerby.dk>
* Changed write() to addText()
* Split done() into show() and save()
* Changed all methods with more than 1 parameter to use hashed array as parameters
Version 0.1.1 [2005-Mar-21] - Jesper Veggerby <pear.nosey@veggerby.dk>
* Renamed package to Image_Canvas
Version 0.1.0 [2005-Feb-14] - Jesper Veggerby <pear.nosey@veggerby.dk>
* First "stand-alone" release ("outside" Image_Graph)

View File

@ -1,344 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called 'this License').
Each licensee is addressed as 'you'.
A 'library' means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The 'Library', below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term 'modification'.)
'Source code' for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a 'work that uses the Library'. Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a 'work that uses the Library' with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a 'work that uses the Library' uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a 'work that uses the Library' with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
'any later version', you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY 'AS IS' WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS

View File

@ -1,41 +0,0 @@
*******************************
Image_Canvas
*******************************
version 0.2.4
------ CopyRight (C) Jesper Veggerby Hansen, 2003-2005 ------
http://pear.php.net/pepr/pepr-proposal-show.php?id=212
_________________________________________________________________
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.
_________________________________________________________________
Image_Canvas
Requirements
------------
The only system requirement is PHP4/PHP5 support.
For GD output GD support is required with GD 2 for optimal performance. For PDF
support, PDFlib is required (planned File_PDF support when released in working
version).
Documentation
-------------
See http://pear.veggerby.dk/Image_Canvas/docs/ for documentation
History
-------
Release history of Image_Canvas
0.2.4 08-Nov-2005
0.2.3 28-Oct-2005
0.2.2 30-Sep-2005
0.2.1 08-Aug-2005 First version used by Image_Graph
0.2.0 01-Aug-2005 First PEAR release
0.1.2 21-Jul-2005
0.1.1 21-Mar-2005
0.1.0 14-Feb-2005

View File

@ -1,142 +0,0 @@
List of supported named colors (extract from Image/Color.php)
aliceblue
antiquewhite
aqua
aquamarine
azure
beige
bisque
black
blanchedalmond
blue
blueviolet
brown
burlywood
cadetblue
chartreuse
chocolate
coral
cornflowerblue
cornsilk
crimson
cyan
darkblue
darkcyan
darkgoldenrod
darkgray
darkgreen
darkkhaki
darkmagenta
darkolivegreen
darkorange
darkorchid
darkred
darksalmon
darkseagreen
darkslateblue
darkslategray
darkturquoise
darkviolet
deeppink
deepskyblue
dimgray
dodgerblue
firebrick
floralwhite
forestgreen
fuchsia
gainsboro
ghostwhite
gold
goldenrod
gray
green
greenyellow
honeydew
hotpink
indianred
indigo
ivory
khaki
lavender
lavenderblush
lawngreen
lemonchiffon
lightblue
lightcoral
lightcyan
lightgoldenrodyellow
lightgreen
lightgrey
lightpink
lightsalmon
lightseagreen
lightskyblue
lightslategray
lightsteelblue
lightyellow
lime
limegreen
linen
magenta
maroon
mediumaquamarine
mediumblue
mediumorchid
mediumpurple
mediumseagreen
mediumslateblue
mediumspringgreen
mediumturquoise
mediumvioletred
midnightblue
mintcream
mistyrose
moccasin
navajowhite
navy
oldlace
olive
olivedrab
orange
orangered
orchid
palegoldenrod
palegreen
paleturquoise
palevioletred
papayawhip
peachpuff
peru
pink
plum
powderblue
purple
red
rosybrown
royalblue
saddlebrown
salmon
sandybrown
seagreen
seashell
sienna
silver
skyblue
slateblue
slategray
snow
springgreen
steelblue
tan
teal
thistle
tomato
turquoise
violet
wheat
white
whitesmoke
yellow
yellowgreen

View File

@ -1,104 +0,0 @@
<?php
/**
* Usage example for Image_Graph.
*
* Main purpose:
* Antialiasing usage
*
* Other:
* Setup canvas, Many plotareas with one legend, Setup fillarray (filling one
* plot with different colors depeding on dataset)
*
* $Id: antialias.php,v 1.4 2005/08/03 21:21:53 nosey Exp $
*
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
*/
// include libraries
require_once 'Image/Graph.php';
require_once 'Image/Canvas.php';
// create a PNG canvas and enable antialiasing (canvas implementation)
$Canvas =& Image_Canvas::factory('png', array('width' => 600, 'height' => 300, 'antialias' => 'native'));
// create the graph
$Graph =& Image_Graph::factory('graph', $Canvas);
// add a TrueType font
$Font =& $Graph->addNew('font', 'Verdana');
// set the font size to 8 pixels
$Font->setSize(8);
// set the font
$Graph->setFont($Font);
// create the layout
$Graph->add(
Image_Graph::vertical(
Image_Graph::factory('title', array('Antialiased Sample Chart', 12)),
Image_Graph::vertical(
Image_Graph::horizontal(
$Plotarea1 = Image_Graph::factory('plotarea'),
$Plotarea2 = Image_Graph::factory('plotarea')
),
$Legend = Image_Graph::factory('legend'),
80
),
5
)
);
// add grids
$Grid =& $Plotarea1->addNew('line_grid', IMAGE_GRAPH_AXIS_Y);
$Grid->setLineColor('silver');
$Grid =& $Plotarea2->addNew('line_grid', IMAGE_GRAPH_AXIS_Y);
$Grid->setLineColor('silver');
// setup legend
$Legend->setPlotarea($Plotarea1);
$Legend->setPlotarea($Plotarea2);
// create the dataset
$Datasets =
array(
Image_Graph::factory('random', array(10, 2, 15, true)),
Image_Graph::factory('random', array(10, 2, 15, true)),
Image_Graph::factory('random', array(10, 2, 15, true))
);
// create the plot as stacked area chart using the datasets
$Plot =& $Plotarea1->addNew('Image_Graph_Plot_Area', array($Datasets, 'stacked'));
// set names for datasets (for legend)
$Datasets[0]->setName('Jylland');
$Datasets[1]->setName('Fyn');
$Datasets[2]->setName('Sjælland');
// set line color for plot
$Plot->setLineColor('gray');
// create and populate the fillarray
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
$FillArray->addColor('blue@0.2');
$FillArray->addColor('yellow@0.2');
$FillArray->addColor('green@0.2');
// set a fill style
$Plot->setFillStyle($FillArray);
// add other plots
$Plot =& $Plotarea2->addNew('line', $Datasets[0]);
$Plot->setLineColor('blue@0.2');
$Plot =& $Plotarea2->addNew('line', $Datasets[1]);
$Plot->setLineColor('yellow@0.2');
$Plot =& $Plotarea2->addNew('line', $Datasets[2]);
$Plot->setLineColor('green@0.2');
// set color
$Plotarea1->setFillColor('silver@0.3');
$Plotarea2->setFillColor('silver@0.3');
// output the Graph
$Graph->done();
?>

View File

@ -1,54 +0,0 @@
<?php
/**
* Usage example for Image_Graph.
*
* Main purpose:
* Axis direction
*
* Other:
* None specific
*
* $Id: axis_direction.php,v 1.1 2005/09/30 18:59:17 nosey Exp $
*
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
*/
require_once 'Image/Graph.php';
// create the graph
$Graph =& Image_Graph::factory('graph', array(600, 300));
// add a TrueType font
$Font =& $Graph->addNew('font', 'Verdana');
// set the font size to 11 pixels
$Font->setSize(10);
$Graph->setFont($Font);
// setup the plotarea, legend and their layout
$Graph->add(
Image_Graph::vertical(
Image_Graph::factory('title', array('Changing Axis Direction', 12)),
Image_Graph::horizontal(
$Plotarea1 = Image_Graph::factory('plotarea'),
$Plotarea2 = Image_Graph::factory('plotarea'),
50
),
5
)
);
$Dataset =& Image_Graph::factory('random', array(10, 2, 15, true));
$Plot1 =& $Plotarea1->addNew('line', array(&$Dataset));
$Plot1->setLineColor('red');
$Plot2 =& $Plotarea2->addNew('line', array(&$Dataset));
$Plot2->setLineColor('red');
$AxisY =& $Plotarea2->getAxis('y');
$AxisY->setInverted(true);
// output the Graph
$Graph->done();
?>

View File

@ -1,61 +0,0 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* This is just a basic example with some non-specific geometric shapes and
* texts.
*
* 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: canvas.php,v 1.1 2005/08/03 21:11:22 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
include_once 'Image/Canvas.php';
$Canvas =& Image_Canvas::factory((isset($_GET['canvas']) ? $_GET['canvas'] : 'png'), array('width' => 400, 'height' => 300));
$Canvas->setLineColor('black');
$Canvas->rectangle(array('x0' => 0, 'y0' => 0, 'x1' => 399, 'y1' => 299));
$Canvas->setGradientFill(array('direction' => 'horizontal', 'start' => 'red', 'end' => 'blue'));
$Canvas->setLineColor('black');
$Canvas->ellipse(array('x' => 199, 'y' => 149, 'rx' => 50, 'ry' => 50));
$Canvas->setFont(array('name' => 'Arial', 'size' => 12));
$Canvas->addText(array('x' => 0, 'y' => 0, 'text' => 'Demonstration of what Image_Canvas do!'));
$Canvas->setFont(array('name' => 'Times New Roman', 'size' => 12));
$Canvas->addText(array('x' => 399, 'y' => 20, 'text' => 'This does not demonstrate what is does!', 'alignment' => array('horizontal' => 'right')));
$Canvas->setFont(array('name' => 'Courier New', 'size' => 7, 'angle' => 270));
$Canvas->addText(array('x' => 350, 'y' => 50, 'text' => 'True, but it\'s all independent of the format!', 'alignment' => array('horizontal' => 'right')));
$Canvas->setFont(array('name' => 'Garamond', 'size' => 10));
$Canvas->addText(array('x' => 199, 'y' => 295, 'text' => '[Changing format is done by changing 3 letters in the source]', 'alignment' => array('horizontal' => 'center', 'vertical' => 'bottom')));
$Canvas->addVertex(array('x' => 50, 'y' => 200));
$Canvas->addVertex(array('x' => 100, 'y' => 200));
$Canvas->addVertex(array('x' => 100, 'y' => 250));
$Canvas->setFillColor('red@0.2');
$Canvas->polygon(array('connect' => true));
$Canvas->image(array('x' => 398, 'y' => 298, 'filename' => './pear-icon.png', 'alignment' => array('horizontal' => 'right', 'vertical' => 'bottom')));
$Canvas->show();
?>

View File

@ -1,84 +0,0 @@
<?php
/**
* Usage example for Image_Graph.
*
* Main purpose:
* Explaining category axis ordering
*
* Other:
* None specifc
*
* $Id: category_axis_explanation.php,v 1.4 2005/08/03 21:21:52 nosey Exp $
*
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
*/
require_once 'Image/Graph.php';
require_once 'Image/Canvas.php';
$Canvas =& Image_Canvas::factory('png', array('width' => 500, 'height' => 200, 'antialias' => true));
// create the graph
$Graph =& Image_Graph::factory('graph', $Canvas);
// add a TrueType font
$Font =& $Graph->addNew('font', 'Verdana');
// set the font size to 11 pixels
$Font->setSize(9);
$Graph->setFont($Font);
$Plotarea =& $Graph->addNew('plotarea');
$Datasets[0] =& Image_Graph::factory('dataset');
$Datasets[1] =& Image_Graph::factory('dataset');
$Datasets[2] =& Image_Graph::factory('dataset');
$Datasets[0]->addPoint('this', 1);
$Datasets[0]->addPoint('can', 3);
$Datasets[0]->addPoint('make', 2);
$Datasets[0]->addPoint('correctly', 1);
$Datasets[1]->addPoint('sentence', 1);
$Datasets[1]->addPoint('can', 1);
$Datasets[1]->addPoint('sense', 2);
$Datasets[1]->addPoint('written', 2);
$Datasets[1]->addPoint('correctly', 2);
$Datasets[2]->addPoint('actually', 3);
$Datasets[2]->addPoint('make', 2);
$Datasets[2]->addPoint('if', 3);
$Datasets[2]->addPoint('written', 1);
// expecting the following X-axis order
// 'this sentence can actually make sense if written correctly'
// making points be placed in the following order:
//
// |this|sentence|can|actually|make|sense|if|written|correctly|
// 1 |_1__|________|_2_|________|_3__|_____|__|_______|____4____|
// 2 |____|___1____|_2_|________|____|__3__|__|___4___|____5____|
// 3 |____|________|___|___1____|_2__|_____|3_|___4___|_________|
//
// if an append-algorithm were to be (wrongly) used it would yield
// 'this can make correctly sentence sense written actually if'
// making points be placed in the following order:
//
// |this|can|make|correctly|sentence|sense|written|actually|if|
// 1 |_1__|_2_|_3__|____4____|________|_____|_______|________|__|
// 2 |____|_2_|____|____5____|___1____|__3__|___4___|________|__|
// 3 |____|___|_2__|_________|________|_____|___4___|___1____|3_|
$Plot1 =& $Plotarea->addNew('line', array(&$Datasets[0]));
$Plot2 =& $Plotarea->addNew('line', array(&$Datasets[1]));
$Plot3 =& $Plotarea->addNew('line', array(&$Datasets[2]));
$Plot1->setLineColor('red');
$Plot2->setLineColor('blue');
$Plot3->setLineColor('green');
// output the Graph
$Graph->done();
?>

View File

@ -1,51 +0,0 @@
<?php
/**
* Not a real usage example for Image_Graph.
*
* Main purpose:
* Color chart of named colors
*
* Other:
* Using canvass "outside" Image_Graph
*
* $Id: color_chart.php,v 1.2 2005/08/03 21:21:52 nosey Exp $
*
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
*/
$file = file('./data/colors.txt');
require_once 'Image/Canvas.php';
require_once 'Image/Graph/Color.php';
require_once 'Image/Graph/Constants.php';
$Canvas =& Image_Canvas::factory('gd', array('width' => 600, 'height' => 1200));
$i = 0;
$cols = 10;
$Width = ($Canvas->getWidth() / $cols);
$rows = count($file) / $cols;
$rows = floor($rows) + ($rows > floor($rows) ? 1 : 0);
$Height = ($Canvas->getHeight() / $rows);
while (list($id, $color) = each($file)) {
$color = trim($color);
$x = ($i % $cols) * $Width + $Width / 2;
$y = floor($i / $cols) * $Height;
$Canvas->setLineColor('black');
$Canvas->setFillColor($color);
$Canvas->rectangle($x - $Width / 4, $y, $x + $Width / 4, $y + $Height / 3);
$Canvas->write($x, $y + $Height / 3 + 3, $color, IMAGE_GRAPH_ALIGN_CENTER_X + IMAGE_GRAPH_ALIGN_TOP);
$rgbColor = Image_Graph_Color::color2RGB($color);
$rgbs = 'RGB: ';
unset($rgbColor[3]);
while (list($id, $rgb) = each($rgbColor)) {
$rgbs .= ($rgb < 0x10 ? '0' : '') . dechex($rgb);
}
$Canvas->write($x, $y + $Height / 3 + 13, $rgbs, IMAGE_GRAPH_ALIGN_CENTER_X + IMAGE_GRAPH_ALIGN_TOP);
$i++;
}
$Canvas->done();
?>

View File

@ -1,116 +0,0 @@
<?php
/**
* Usage example for Image_Graph.
*
* Main purpose:
* Customizing axis and legends
*
* Other:
* None specific
*
* $Id: customize.php,v 1.4 2005/09/08 19:02:17 nosey Exp $
*
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
*/
require_once 'Image/Graph.php';
// create the graph
$Graph =& Image_Graph::factory('graph', array(450, 300));
// add a TrueType font
$Font =& $Graph->addNew('font', 'Verdana');
// set the font size to 11 pixels
$Font->setSize(8);
$Graph->setFont($Font);
// create the plotarea
$Graph->add(
Image_Graph::vertical(
Image_Graph::factory('title', array('Stacked Bar Chart with defined axis properties', 12)),
$Plotarea = Image_Graph::factory('plotarea'),
5
)
);
$MarkerX =& $Plotarea->addNew('Image_Graph_Axis_Marker_Area', null, IMAGE_GRAPH_AXIS_X);
$MarkerX->setFillColor('blue@0.3');
$MarkerX->setLineColor('blue@0.3');
$MarkerX->setLowerBound(7);
$MarkerX->setUpperBound(8);
$MarkerY =& $Plotarea->addNew('Image_Graph_Axis_Marker_Area', null, IMAGE_GRAPH_AXIS_Y);
$MarkerY->setFillColor('green@0.3');
$MarkerY->setLineColor('green@0.3');
$MarkerY->setLowerBound(5.2);
$MarkerY->setUpperBound(9.3);
$MarkerY =& $Plotarea->addNew('Image_Graph_Axis_Marker_Line', null, IMAGE_GRAPH_AXIS_Y);
$MarkerY->setLineColor('red');
$MarkerY->setValue(14.4);
// create the 1st plot as smoothed area chart using the 1st dataset
$Plot1 =& $Plotarea->add(
Image_Graph::factory('bar',
array(
$Dataset = array(
Image_Graph::factory('random', array(8, 1, 10, false)),
Image_Graph::factory('random', array(8, 1, 10, false)),
Image_Graph::factory('random', array(8, 1, 10, false))
),
'stacked'
)
)
);
$Dataset[0]->setName('Dataset one');
$Dataset[1]->setName('Numero duo');
$Dataset[2]->setName('En-to-tre');
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
$FillArray->addColor('blue@0.1', 0);
$FillArray->addColor('red@0.1', 1);
$FillArray->addColor('yellow@0.1', 2);
$Plot1->setFillStyle($FillArray);
// Show arrow heads on the axis
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
$AxisY->addMark(5);
$AxisY->addMark(7);
$AxisY->setFontSize(7);
$AxisY->addMark(10.8, 17.5);
$AxisY->setFillColor('red@0.7');
$AxisY->setLabelInterval(array(1, 5, 9, 12, 13, 14, 19, 21));
$AxisY->setTickOptions(-3, 2);
$AxisY->setLabelInterval('auto', 2);
$AxisY->setTickOptions(-1, 1, 2);
$AxisY->setLabelOptions(
array(
'showtext' => true,
'font' => array(
'size' => 3,
'color' => 'red'
)
), 2
);
$AxisY->setLabelOption('showoffset', true, 1);
$AxisX->showArrow();
$Legend =& $Plotarea->addNew('legend');
$Legend->setFillColor('white@0.7');
$Legend->setFontSize(8);
$Legend->showShadow();
$Plot1->setLineColor('black@0.1');
// output the Graph
$Graph->done();
?>

View File

@ -1,140 +0,0 @@
aliceblue
antiquewhite
aqua
aquamarine
azure
beige
bisque
black
blanchedalmond
blue
blueviolet
brown
burlywood
cadetblue
chartreuse
chocolate
coral
cornflowerblue
cornsilk
crimson
cyan
darkblue
darkcyan
darkgoldenrod
darkgray
darkgreen
darkkhaki
darkmagenta
darkolivegreen
darkorange
darkorchid
darkred
darksalmon
darkseagreen
darkslateblue
darkslategray
darkturquoise
darkviolet
deeppink
deepskyblue
dimgray
dodgerblue
firebrick
floralwhite
forestgreen
fuchsia
gainsboro
ghostwhite
gold
goldenrod
gray
green
greenyellow
honeydew
hotpink
indianred
indigo
ivory
khaki
lavender
lavenderblush
lawngreen
lemonchiffon
lightblue
lightcoral
lightcyan
lightgoldenrodyellow
lightgreen
lightgrey
lightpink
lightsalmon
lightseagreen
lightskyblue
lightslategray
lightsteelblue
lightyellow
lime
limegreen
linen
magenta
maroon
mediumaquamarine
mediumblue
mediumorchid
mediumpurple
mediumseagreen
mediumslateblue
mediumspringgreen
mediumturquoise
mediumvioletred
midnightblue
mintcream
mistyrose
moccasin
navajowhite
navy
oldlace
olive
olivedrab
orange
orangered
orchid
palegoldenrod
palegreen
paleturquoise
palevioletred
papayawhip
peachpuff
peru
pink
plum
powderblue
purple
red
rosybrown
royalblue
saddlebrown
salmon
sandybrown
seagreen
seashell
sienna
silver
skyblue
slateblue
slategray
snow
springgreen
steelblue
tan
teal
thistle
tomato
turquoise
violet
wheat
white
whitesmoke
yellow
yellowgreen

View File

@ -1,99 +0,0 @@
<?php
/**
* Usage example for Image_Graph.
*
* Main purpose:
* Datapreprocessing usage and idea
*
* Other:
* Matrix layout
*
* $Id: datapreprocessor.php,v 1.4 2005/08/03 21:21:52 nosey Exp $
*
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
*/
error_reporting(E_ALL);
include('Image/Graph.php');
function foo($value) {
return '-' . chr($value+63) . '-';
}
// create the graph
$Graph =& Image_Graph::factory('Image_Graph', array(600, 400));
// add a TrueType font
$Font =& $Graph->addNew('font', 'Verdana');
// set the font size to 11 pixels
$Font->setSize(7);
$Graph->setFont($Font);
// create the plotarea
$Graph->add(
Image_Graph::vertical(
Image_Graph::factory('Image_Graph_Title', array('DataPreprocessor Example', 11)),
$Matrix = Image_Graph::factory('Image_Graph_Layout_Matrix', array(2, 2)),
5
)
);
$Charts = array('bar', 'line', 'Image_Graph_Plot_Smoothed_Line', 'Image_Graph_Plot_Area');
for ($i = 0; $i < 2; $i++) {
for ($j = 0; $j < 2; $j++) {
$Plotarea =& $Matrix->getEntry($i, $j);
$Chart = $Charts[($i*2+$j)];
$GridY =& $Plotarea->addNew('bar_grid', IMAGE_GRAPH_AXIS_Y);
$GridY->setFillStyle(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'lightgrey')));
$Var = "Plot$i$j";
$Dataset =& Image_Graph::factory('Image_Graph_Dataset_Random', array(8, 10, 100, $Chart == 'Image_Graph_Plot_Area'));
$$Var =& $Plotarea->addNew($Chart, array(&$Dataset));
}
}
$Plotarea =& $Matrix->getEntry(0, 0);
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
$AxisX->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_RomanNumerals'));
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
$AxisY->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_NumberText'));
$Plotarea =& $Matrix->getEntry(0, 1);
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
$AxisX->setDataPreprocessor(
Image_Graph::factory('Image_Graph_DataPreprocessor_Array',
array(
array(
1 => '30 Jul',
2 => '31 Jul',
3 => '1 Aug',
4 => '2 Aug',
5 => '3 Aug',
6 => '4 Aug',
7 => '5 Aug',
8 => '6 Aug'
)
)
)
);
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
$AxisY->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '+ %0.1f%%'));
$Plotarea =& $Matrix->getEntry(1, 0);
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
$AxisX->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Function', 'foo'));
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
$AxisY->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Currency', 'US$'));
// just for looks
$Plot00->setFillColor('red@0.2');
$Plot11->setFillColor('blue@0.2');
// output the Graph
$Graph->done();
?>

View File

@ -1,100 +0,0 @@
<?php
/**
* Usage example for Image_Graph.
*
* Main purpose:
* PDF canvas
*
* Other:
* Datapreprocessor, Axis markers
*
* $Id: double_category_axis.php,v 1.2 2005/10/05 20:51:18 nosey Exp $
*
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
*/
require_once 'Image/Graph.php';
// create the graph
$Graph =& Image_Graph::factory('graph', array(400, 300));
// add a TrueType font
$Font =& $Graph->addNew('ttf_font', 'Verdana');
// set the font size to 11 pixels
$Font->setSize(7);
$Graph->setFont($Font);
// create the plotarea
$Graph->add(
Image_Graph::vertical(
Image_Graph::factory('title', array('Testing Category Axis', 10)),
$Plotarea = Image_Graph::factory('plotarea', array('Image_Graph_Axis_Category', 'Image_Graph_Axis_Category')),
5
)
);
//$DS =& Image_Graph::factory('dataset');
//$DS->addPoint('Apache', 'Open Source');
//$DS->addPoint('BSD', 'Open Source');
//$DS->addPoint('Linux', 'Open Source');
//$DS->addPoint('Microsoft', 'Proprietary');
//$DS->addPoint('Micro', 'Proprietary');
//$DS->addPoint('Minisoft', 'Proprie');
//$DS->addPoint('Millisoft', 'Prop');
//
//$DS2 =& Image_Graph::factory('dataset');
//$DS->addPoint('Apache', 'Open Source');
//$DS->addPoint('BSD', 'Open Source');
//$DS->addPoint('Linux', 'Open Source');
//$DS->addPoint('Microsoft', 'Proprietary');
//$DS->addPoint('Micro', 'Proprietary');
//$DS->addPoint('Minisoft', 'Proprie');
//$DS->addPoint('Miniority', 'Proprias');
//
//$Plot =& $Plotarea->addNew('scatter', $DS);
//$Marker =& Image_Graph::factory('Image_Graph_Marker_Plus');
//$Marker->setFillColor('red');
//$Marker->setLineColor('black');
//$Plot->setMarker($Marker);
//
//$Plot2 =& $Plotarea->addNew('scatter', $DS2);
//$Marker =& Image_Graph::factory('Image_Graph_Marker_Cross');
//$Marker->setFillColor('blue');
//$Marker->setLineColor('black');
//$Plot2->setMarker($Marker);
//
//$Graph->done();
$DS =& Image_Graph::factory('dataset');
$DS->addPoint('Germany', 'England');
$DS->addPoint('Denmark', 'France');
$DS->addPoint('Sweden', 'Denmark');
$DS->addPoint('England', 'France');
$DS->addPoint('Norway', 'Finland');
$DS->addPoint('Denmark', 'Finland');
$DS->addPoint('Iceland', 'Germany');
$DS->addPoint('Norway', 'France');
$DS2 =& Image_Graph::factory('dataset');
$DS2->addPoint('Sweden', 'France');
$DS2->addPoint('Austria', 'Germany');
$DS2->addPoint('Norway', 'Holland');
$DS2->addPoint('Denmark', 'Germany');
$DS2->addPoint('Sweden', 'Holland');
$DS2->addPoint('Iceland', 'Denmark');
$Plot =& $Plotarea->addNew('scatter', $DS);
$Marker =& Image_Graph::factory('Image_Graph_Marker_Cross');
$Marker->setFillColor('blue');
$Marker->setLineColor('black');
$Plot->setMarker($Marker);
$Plot2 =& $Plotarea->addNew('scatter', $DS2);
$Marker2 =& Image_Graph::factory('Image_Graph_Marker_Plus');
$Marker2->setFillColor('yellow');
$Marker2->setLineColor('black');
$Plot2->setMarker($Marker2);
$Graph->done();
?>

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