mirror of
https://github.com/e107inc/e107.git
synced 2025-07-15 12:06:19 +02: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:
@ -22,6 +22,13 @@ if (!defined('e107_INIT')) { exit; }
|
|||||||
*/
|
*/
|
||||||
class ArrayData {
|
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.
|
* Return a string containg exported array data.
|
||||||
*
|
*
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
@ -134,7 +134,6 @@ class e107
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected static $_known_handlers = array(
|
protected static $_known_handlers = array(
|
||||||
'ArrayData' => '{e_HANDLER}arraystorage_class.php',
|
|
||||||
'UserHandler' => '{e_HANDLER}user_handler.php',
|
'UserHandler' => '{e_HANDLER}user_handler.php',
|
||||||
'comment' => '{e_HANDLER}comment_class.php',
|
'comment' => '{e_HANDLER}comment_class.php',
|
||||||
'convert' => '{e_HANDLER}date_handler.php',
|
'convert' => '{e_HANDLER}date_handler.php',
|
||||||
@ -154,6 +153,7 @@ class e107
|
|||||||
'e_admin_request' => '{e_HANDLER}admin_ui.php',
|
'e_admin_request' => '{e_HANDLER}admin_ui.php',
|
||||||
'e_admin_response' => '{e_HANDLER}admin_ui.php',
|
'e_admin_response' => '{e_HANDLER}admin_ui.php',
|
||||||
'e_admin_ui' => '{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_bbcode' => '{e_HANDLER}bbcode_handler.php',
|
||||||
'e_file' => '{e_HANDLER}file_class.php',
|
'e_file' => '{e_HANDLER}file_class.php',
|
||||||
'e_form' => '{e_HANDLER}form_handler.php',
|
'e_form' => '{e_HANDLER}form_handler.php',
|
||||||
@ -1171,7 +1171,7 @@ class e107
|
|||||||
*/
|
*/
|
||||||
public static function getArrayStorage()
|
public static function getArrayStorage()
|
||||||
{
|
{
|
||||||
return self::getSingleton('ArrayData', true);
|
return self::getSingleton('e_array', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user