mirror of
https://github.com/e107inc/e107.git
synced 2025-08-05 14:17:49 +02:00
model/pref handlers optimization
This commit is contained in:
@@ -9,9 +9,9 @@
|
|||||||
* e107 Base Model
|
* e107 Base Model
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/model_class.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_handlers/model_class.php,v $
|
||||||
* $Revision: 1.5 $
|
* $Revision: 1.6 $
|
||||||
* $Date: 2009-09-03 22:27:32 $
|
* $Date: 2009-09-04 15:27:28 $
|
||||||
* $Author: e107coders $
|
* $Author: secretr $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('e107_INIT')) { exit; }
|
if (!defined('e107_INIT')) { exit; }
|
||||||
@@ -531,14 +531,17 @@ class e_model
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tp = e107::getParser();
|
|
||||||
//TODO - sanitize method based on validation rules OR _FIELD_TYPES array?
|
//TODO - sanitize method based on validation rules OR _FIELD_TYPES array?
|
||||||
if($sanitize)
|
if($sanitize)
|
||||||
{
|
{
|
||||||
$src_data = $tp->toDB($src_data);
|
$src_data = e107::getParser()->toDB($src_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setData($src_data, null, $strict);
|
foreach ($src_data as $key => $value)
|
||||||
|
{
|
||||||
|
$this->setData($key, $value, $strict);
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1043,6 +1046,6 @@ class e_model
|
|||||||
*/
|
*/
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
return $this->toString((func_get_arg(0) === true));
|
return $this->toString((@func_get_arg(0) === true));
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -9,8 +9,8 @@
|
|||||||
* e107 Preference Handler
|
* e107 Preference Handler
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/pref_class.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_handlers/pref_class.php,v $
|
||||||
* $Revision: 1.17 $
|
* $Revision: 1.18 $
|
||||||
* $Date: 2009-09-03 14:15:36 $
|
* $Date: 2009-09-04 15:27:28 $
|
||||||
* $Author: secretr $
|
* $Author: secretr $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -130,6 +130,14 @@ class e_pref extends e_model
|
|||||||
{
|
{
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Merge only allowed
|
||||||
|
if(is_array($pref_name))
|
||||||
|
{
|
||||||
|
$this->mergeData($pref_name, false, false, false);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
parent::setData($pref_name, $value, false);
|
parent::setData($pref_name, $value, false);
|
||||||
|
|
||||||
//BC
|
//BC
|
||||||
@@ -142,12 +150,13 @@ class e_pref extends e_model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Advanced setter - $pref_name is parsed (multidimensional arrays support)
|
* Advanced setter - $pref_name is parsed (multidimensional arrays support)
|
||||||
* Object data reseting is not allowed, adding new pref is not allowed
|
* Object data reseting is not allowed, adding new pref is controlled by $strict parameter
|
||||||
* @param string|array $pref_name
|
* @param string|array $pref_name
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
|
* @param boolean $strict true - update only, false - same as setPref()
|
||||||
* @return e_pref
|
* @return e_pref
|
||||||
*/
|
*/
|
||||||
public function updatePref($pref_name, $value = null)
|
public function updatePref($pref_name, $value = null, $strict = false)
|
||||||
{
|
{
|
||||||
global $pref;
|
global $pref;
|
||||||
//object reset not allowed, adding new pref is not allowed
|
//object reset not allowed, adding new pref is not allowed
|
||||||
@@ -155,7 +164,15 @@ class e_pref extends e_model
|
|||||||
{
|
{
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
parent::setData($pref_name, $value, true);
|
|
||||||
|
//Merge only allowed
|
||||||
|
if(is_array($pref_name))
|
||||||
|
{
|
||||||
|
$this->mergeData($pref_name, $strict, false, false);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::setData($pref_name, $value, $strict);
|
||||||
|
|
||||||
//BC
|
//BC
|
||||||
if($this->alias === 'core')
|
if($this->alias === 'core')
|
||||||
|
Reference in New Issue
Block a user