1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 11:50:30 +02:00

Added e107::serialize() and e107::unserialize() (static alias of e107::getArrayStorage()->read/write() functions)

This commit is contained in:
Cameron
2013-03-31 05:55:08 -07:00
parent 6becda09d4
commit 82ac19d038
6 changed files with 43 additions and 9 deletions

View File

@@ -321,7 +321,7 @@ class e_array {
* @param string $ArrayData
* @return array stored data
*/
public function read($ArrayData)
public function unserialize($ArrayData)
{
if ($ArrayData == ""){
return false;
@@ -353,7 +353,7 @@ class e_array {
* @param bool $AddSlashes default true, add slashes for db storage, else false
* @return string
*/
public function write($ArrayData, $AddSlashes = true)
public function serialize($ArrayData, $AddSlashes = false)
{
if (!is_array($ArrayData)) {
return false;
@@ -374,7 +374,13 @@ class e_array {
*/
function WriteArray($ArrayData, $AddSlashes = true) {
return $this->write($ArrayData, $AddSlashes);
return $this->serialize($ArrayData, $AddSlashes);
}
function write($ArrayData, $AddSlashes = true) {
return $this->serialize($ArrayData, $AddSlashes);
}
@@ -387,7 +393,12 @@ class e_array {
*/
function ReadArray($ArrayData)
{
return $this->read($ArrayData);
return $this->unserialize($ArrayData);
}
function read($ArrayData)
{
return $this->unserialize($ArrayData);
}
}

View File

@@ -1405,6 +1405,29 @@ class e107
}
/**
* Return a string containg exported array data. - preferred.
*
* @param array $ArrayData array to be stored
* @param bool $AddSlashes default false, add slashes for db storage, else false
* @return string
*/
public static function serialize($ArrayData, $AddSlashes = false)
{
return self::getArrayStorage()->serialize($ArrayData, $AddSlashes);
}
/**
* Returns an array from stored array data.
*
* @param string $ArrayData
* @return array stored data
*/
public static function unserialize($ArrayData)
{
return self::getArrayStorage()->unserialize($ArrayData);
}
/**
* Retrieve current user model object.

View File

@@ -791,7 +791,7 @@ class e_db_mysql
{
if(!isset($arg['_FIELD_TYPES']['_DEFAULT']))
{
$arg['_FIELD_TYPES']['_DEFAULT'] = 'todb';
$arg['_FIELD_TYPES']['_DEFAULT'] = 'string';
}
$fieldTypes = $arg['_FIELD_TYPES'];
unset($arg['_FIELD_TYPES']);

View File

@@ -164,7 +164,7 @@ class user_class
}
}
$userCache = e107::getArrayStorage()->write($this->class_tree, FALSE);
$userCache = e107::serialize($this->class_tree, FALSE);
$e107->ecache->set_sys(UC_CACHE_TAG,$userCache);
unset($userCache);
}

View File

@@ -168,7 +168,7 @@ class e107forum
$fid = intval($data['dl']);
$array = $sql->retrieve('forum_post','post_user,post_attachments','post_id='.intval($data['id']));
$attach = e107::getArrayStorage()->read($array['post_attachments']);
$attach = e107::serialize($array['post_attachments']);
$file = $this->getAttachmentPath($array['post_user']).varset($attach['file'][$fid]);
e107::getFile()->send($file);

View File

@@ -256,11 +256,11 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
// if($ur['fname']) { $_tmp .= '*'.$ur['fname']; }
$type = $ur['type'];
$newValues[$type][] = basename($ur['fname']);
$newValues[$type][] = $ur['fname'];
// $attachments[] = $_tmp;
}
// $postInfo['_FIELD_TYPES']['post_attachments'] = 'array'; //XXX Horrible "FIELD_TYPES" idea.
$postInfo['post_attachments'] = e107::getArrayStorage()->write($newValues); //FIXME
$postInfo['post_attachments'] = e107::serialize($newValues); //FIXME
}
// var_dump($uploadResult);