1
0
mirror of https://github.com/e107inc/e107.git synced 2025-03-14 01:19:44 +01:00

Issue #73 Deprecated message added to old arrayStorage class, and created a new one in core-functions.php

Use: e107::arrayStorage->read() and e107::arrayStorage->write(); (BC aliases added also)
This commit is contained in:
Cameron 2013-02-26 19:12:17 -08:00
parent 4941a1156d
commit 117d0e8deb
3 changed files with 90 additions and 2 deletions

View File

@ -22,6 +22,13 @@ if (!defined('e107_INIT')) { exit; }
*/
class ArrayData {
function __construct()
{
// DO Not translate - debug info only.
e107::getMessage()->addDebug("Deprecated ArrayStorage Class in use. Please remove references to arraystorage_class.php and use e107::getArrayStorage(); instead.");
}
/**
* Return a string containg exported array data.
*

View File

@ -296,5 +296,86 @@ if (!function_exists('multiarray_sort')) {
}
}
/**
* Array Storage Class.
*/
class e_array {
/**
* Returns an array from stored array data.
*
* @param string $ArrayData
* @return array stored data
*/
public function read($ArrayData)
{
if ($ArrayData == ""){
return false;
}
// Saftety mechanism for 0.7 -> 0.8 transition.
if(substr($ArrayData,0,2)=='a:' || substr($ArrayData,0,2)=='s:')
{
$dat = unserialize($ArrayData);
$ArrayData = $this->WriteArray($dat,FALSE);
}
$data = "";
$ArrayData = '$data = '.trim($ArrayData).';';
@eval($ArrayData);
if (!isset($data) || !is_array($data)) {
trigger_error("Bad stored array data - <br /><br />".htmlentities($ArrayData), E_USER_ERROR);
return false;
}
return $data;
}
/**
* Return a string containg exported array data.
*
* @param array $ArrayData array to be stored
* @param bool $AddSlashes default true, add slashes for db storage, else false
* @return string
*/
public function write($ArrayData, $AddSlashes = true)
{
if (!is_array($ArrayData)) {
return false;
}
$Array = var_export($ArrayData, true);
if ($AddSlashes == true) {
$Array = addslashes($Array);
}
return $Array;
}
/**
* DEPRECATED - Backwards Compatible. Use write() instead;
* @param array $ArrayData array to be stored
* @param bool $AddSlashes default true, add slashes for db storage, else false
* @returnReturn a string containg exported array data.
*/
function WriteArray($ArrayData, $AddSlashes = true) {
return $this->write($ArrayData, $AddSlashes);
}
/**
* DEPRECATED: Use read(); instead.
* Returns an array from stored array data.
*
* @param string $ArrayData
* @return array stored data
*/
function ReadArray($ArrayData)
{
return $this->read($ArrayData);
}
}
?>

View File

@ -134,7 +134,6 @@ class e107
* @var array
*/
protected static $_known_handlers = array(
'ArrayData' => '{e_HANDLER}arraystorage_class.php',
'UserHandler' => '{e_HANDLER}user_handler.php',
'comment' => '{e_HANDLER}comment_class.php',
'convert' => '{e_HANDLER}date_handler.php',
@ -154,6 +153,7 @@ class e107
'e_admin_request' => '{e_HANDLER}admin_ui.php',
'e_admin_response' => '{e_HANDLER}admin_ui.php',
'e_admin_ui' => '{e_HANDLER}admin_ui.php',
'e_array' => '{e_HANDLER}core_functions.php', // Old ArrayStorage.
'e_bbcode' => '{e_HANDLER}bbcode_handler.php',
'e_file' => '{e_HANDLER}file_class.php',
'e_form' => '{e_HANDLER}form_handler.php',
@ -1171,7 +1171,7 @@ class e107
*/
public static function getArrayStorage()
{
return self::getSingleton('ArrayData', true);
return self::getSingleton('e_array', true);
}
/**