mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
Preference handler fixes and BC, save_prefs() is using pref handler now and is deprecated, theme handler changes to reflect new preference management.
This commit is contained in:
37
class2.php
37
class2.php
@@ -9,9 +9,9 @@
|
|||||||
* General purpose file
|
* General purpose file
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/class2.php,v $
|
* $Source: /cvs_backup/e107_0.8/class2.php,v $
|
||||||
* $Revision: 1.129 $
|
* $Revision: 1.130 $
|
||||||
* $Date: 2009-08-16 23:58:30 $
|
* $Date: 2009-08-17 14:40:23 $
|
||||||
* $Author: e107coders $
|
* $Author: secretr $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
//
|
//
|
||||||
@@ -1472,10 +1472,36 @@ function get_user_data($uid, $extra = '')
|
|||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
|
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
|
||||||
|
//SO MUCH DEPRECATED - use e107::getConfig(alias)->save() instead
|
||||||
function save_prefs($table = 'core', $uid = USERID, $row_val = '')
|
function save_prefs($table = 'core', $uid = USERID, $row_val = '')
|
||||||
{
|
{
|
||||||
global $pref, $user_pref, $tp, $PrefCache, $sql, $eArrayStorage, $theme_pref, $iconpool;
|
global $pref, $user_pref, $tp, $PrefCache, $sql, $eArrayStorage, $theme_pref, $iconpool;
|
||||||
|
|
||||||
|
switch($table)
|
||||||
|
{
|
||||||
|
case 'core':
|
||||||
|
//brute load, force update
|
||||||
|
return e107::getConfig()->loadData($pref, false)->save(false, true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'iconpool':
|
||||||
|
//brute load, force update
|
||||||
|
return e107::getConfig('ipool')->loadData($iconpool, true)->save(false, true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'theme':
|
||||||
|
//brute load, force update
|
||||||
|
return e107::getConfig()->set('sitetheme_pref', $theme_pref)->save(false, true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
$_user_pref = $tp->toDB($user_pref, true, true);
|
||||||
|
$tmp = $eArrayStorage->WriteArray($_user_pref);
|
||||||
|
$sql->db_Update('user', "user_prefs='$tmp' WHERE user_id=".intval($uid));
|
||||||
|
return $tmp;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/*
|
||||||
if ($table == 'core')
|
if ($table == 'core')
|
||||||
{
|
{
|
||||||
if ($row_val == '')
|
if ($row_val == '')
|
||||||
@@ -1526,6 +1552,7 @@ function save_prefs($table = 'core', $uid = USERID, $row_val = '')
|
|||||||
$sql->db_Update('user', "user_prefs='$tmp' WHERE user_id=".intval($uid));
|
$sql->db_Update('user', "user_prefs='$tmp' WHERE user_id=".intval($uid));
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -9,9 +9,9 @@
|
|||||||
* e107 Main
|
* e107 Main
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/e107_class.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_handlers/e107_class.php,v $
|
||||||
* $Revision: 1.36 $
|
* $Revision: 1.37 $
|
||||||
* $Date: 2009-08-17 11:29:41 $
|
* $Date: 2009-08-17 14:40:22 $
|
||||||
* $Author: e107coders $
|
* $Author: secretr $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('e107_INIT')) { exit; }
|
if (!defined('e107_INIT')) { exit; }
|
||||||
@@ -370,7 +370,7 @@ class e107
|
|||||||
*/
|
*/
|
||||||
public static function getPlugPref($plug_name, $pref_name, $default = null)
|
public static function getPlugPref($plug_name, $pref_name, $default = null)
|
||||||
{
|
{
|
||||||
return self::getPlugConfig($plug_name)->get($pref_name, $default);
|
return empty($pref_name) ? self::getPlugConfig($plug_name)->getPref() : self::getPlugConfig($plug_name)->get($pref_name, $default);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -398,10 +398,9 @@ class e107
|
|||||||
* @param mixed $default default value if preference is not found
|
* @param mixed $default default value if preference is not found
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public static function getThemePref($pref_name, $default = null, $index = null)
|
public static function getThemePref($pref_name = '', $default = null, $index = null)
|
||||||
{
|
{
|
||||||
$prefobj = e107::getConfig();
|
return e107::getConfig()->getPref('sitetheme_pref/'.$pref_name, $default, $index);
|
||||||
return $prefobj->getPref('sitetheme_pref/'.$pref_name, $default, $index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -9,9 +9,9 @@
|
|||||||
* 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.9 $
|
* $Revision: 1.10 $
|
||||||
* $Date: 2009-08-08 08:11:02 $
|
* $Date: 2009-08-17 14:40:23 $
|
||||||
* $Author: marj_nl_fr $
|
* $Author: secretr $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('e107_INIT')) { exit; }
|
if (!defined('e107_INIT')) { exit; }
|
||||||
@@ -84,6 +84,7 @@ class e_pref extends e_model
|
|||||||
$alias = $prefid;
|
$alias = $prefid;
|
||||||
}
|
}
|
||||||
$this->alias = preg_replace('/[^\w\-]/', '', $alias);
|
$this->alias = preg_replace('/[^\w\-]/', '', $alias);
|
||||||
|
|
||||||
$this->loadData($data, $sanitize_data);
|
$this->loadData($data, $sanitize_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,13 +116,39 @@ 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 allowed
|
||||||
* @param string|array $pref_name
|
* @param string|array $pref_name
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @return e_pref
|
* @return e_pref
|
||||||
*/
|
*/
|
||||||
public function setPref($pref_name, $value = null)
|
public function setPref($pref_name, $value = null)
|
||||||
{
|
{
|
||||||
|
global $pref;
|
||||||
|
//object reset not allowed, adding new pref is allowed
|
||||||
|
if(empty($pref_name))
|
||||||
|
{
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
parent::setData($pref_name, $value, false);
|
||||||
|
|
||||||
|
//BC
|
||||||
|
if($this->alias === 'core')
|
||||||
|
{
|
||||||
|
$pref = $this->getData();
|
||||||
|
}
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Advanced setter - $pref_name is parsed (multidimensional arrays support)
|
||||||
|
* Object data reseting is not allowed, adding new pref is not allowed
|
||||||
|
* @param string|array $pref_name
|
||||||
|
* @param mixed $value
|
||||||
|
* @return e_pref
|
||||||
|
*/
|
||||||
|
public function updatePref($pref_name, $value = null)
|
||||||
|
{
|
||||||
|
global $pref;
|
||||||
//object reset not allowed, adding new pref is not allowed
|
//object reset not allowed, adding new pref is not allowed
|
||||||
if(empty($pref_name))
|
if(empty($pref_name))
|
||||||
{
|
{
|
||||||
@@ -129,25 +156,17 @@ class e_pref extends e_model
|
|||||||
}
|
}
|
||||||
parent::setData($pref_name, $value, true);
|
parent::setData($pref_name, $value, true);
|
||||||
|
|
||||||
return $this;
|
//BC
|
||||||
}
|
if($this->alias === 'core')
|
||||||
|
{
|
||||||
/**
|
$pref = $this->getData();
|
||||||
* Alias of {@link setPref()}
|
}
|
||||||
*
|
|
||||||
* @param string $pref_name
|
|
||||||
* @param mixed $value
|
|
||||||
* @return e_pref
|
|
||||||
*/
|
|
||||||
public function updatePref($pref_name, $value)
|
|
||||||
{
|
|
||||||
$this->setPref($pref_name, $value);
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple setter - $pref_name is not parsed (no multidimensional arrays support)
|
* Simple setter - $pref_name is not parsed (no multidimensional arrays support)
|
||||||
* Adding new pref is not allowed
|
* Adding new pref is allowed
|
||||||
*
|
*
|
||||||
* @param string $pref_name
|
* @param string $pref_name
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
@@ -155,16 +174,24 @@ class e_pref extends e_model
|
|||||||
*/
|
*/
|
||||||
public function set(string $pref_name, $value)
|
public function set(string $pref_name, $value)
|
||||||
{
|
{
|
||||||
|
global $pref;
|
||||||
if(empty($pref_name))
|
if(empty($pref_name))
|
||||||
{
|
{
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
parent::set($pref_name, $value, true);
|
parent::set($pref_name, $value, false);
|
||||||
|
|
||||||
|
//BC
|
||||||
|
if($this->alias === 'core')
|
||||||
|
{
|
||||||
|
$pref = $this->getData();
|
||||||
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alias of {@link set()}
|
* Simple setter - $pref_name is not parsed (no multidimensional arrays support)
|
||||||
|
* Non existing setting will be not created
|
||||||
*
|
*
|
||||||
* @param string $pref_name
|
* @param string $pref_name
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
@@ -172,7 +199,18 @@ class e_pref extends e_model
|
|||||||
*/
|
*/
|
||||||
public function update(string $pref_name, $value)
|
public function update(string $pref_name, $value)
|
||||||
{
|
{
|
||||||
$this->set($pref_name, $value);
|
global $pref;
|
||||||
|
if(empty($pref_name))
|
||||||
|
{
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
parent::set($pref_name, $value, true);
|
||||||
|
|
||||||
|
//BC
|
||||||
|
if($this->alias === 'core')
|
||||||
|
{
|
||||||
|
$pref = $this->getData();
|
||||||
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +229,7 @@ class e_pref extends e_model
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
$this->addData($pref_name, $value);
|
$this->addData($pref_name, $value);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -217,7 +255,14 @@ class e_pref extends e_model
|
|||||||
*/
|
*/
|
||||||
public function remove(string $pref_name)
|
public function remove(string $pref_name)
|
||||||
{
|
{
|
||||||
|
global $pref;
|
||||||
parent::remove($pref_name);
|
parent::remove($pref_name);
|
||||||
|
|
||||||
|
//BC
|
||||||
|
if($this->alias === 'core')
|
||||||
|
{
|
||||||
|
$pref = $this->getData();
|
||||||
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,7 +289,13 @@ class e_pref extends e_model
|
|||||||
*/
|
*/
|
||||||
final public function addData($pref_name, $value = null)
|
final public function addData($pref_name, $value = null)
|
||||||
{
|
{
|
||||||
|
global $pref;
|
||||||
parent::addData($pref_name, $value, false);
|
parent::addData($pref_name, $value, false);
|
||||||
|
//BC
|
||||||
|
if($this->alias === 'core')
|
||||||
|
{
|
||||||
|
$pref = $this->getData();
|
||||||
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,7 +309,14 @@ class e_pref extends e_model
|
|||||||
*/
|
*/
|
||||||
final public function setData($pref_name, $value = null)
|
final public function setData($pref_name, $value = null)
|
||||||
{
|
{
|
||||||
|
global $pref;
|
||||||
parent::setData($pref_name, $value, true);
|
parent::setData($pref_name, $value, true);
|
||||||
|
|
||||||
|
//BC
|
||||||
|
if($this->alias === 'core')
|
||||||
|
{
|
||||||
|
$pref = $this->getData();
|
||||||
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,7 +329,14 @@ class e_pref extends e_model
|
|||||||
*/
|
*/
|
||||||
final public function removeData(string $pref_name)
|
final public function removeData(string $pref_name)
|
||||||
{
|
{
|
||||||
|
global $pref;
|
||||||
parent::removeData($pref_name);
|
parent::removeData($pref_name);
|
||||||
|
|
||||||
|
//BC
|
||||||
|
if($this->alias === 'core')
|
||||||
|
{
|
||||||
|
$pref = $this->getData();
|
||||||
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,6 +349,7 @@ class e_pref extends e_model
|
|||||||
*/
|
*/
|
||||||
public function loadData(array $data, $sanitize = true)
|
public function loadData(array $data, $sanitize = true)
|
||||||
{
|
{
|
||||||
|
global $pref;
|
||||||
if(!empty($data))
|
if(!empty($data))
|
||||||
{
|
{
|
||||||
if($sanitize)
|
if($sanitize)
|
||||||
@@ -292,6 +358,11 @@ class e_pref extends e_model
|
|||||||
}
|
}
|
||||||
parent::setData($data, null, false);
|
parent::setData($data, null, false);
|
||||||
$this->pref_cache = e107::getArrayStorage()->WriteArray($data, false); //runtime cache
|
$this->pref_cache = e107::getArrayStorage()->WriteArray($data, false); //runtime cache
|
||||||
|
//BC
|
||||||
|
if($this->alias === 'core')
|
||||||
|
{
|
||||||
|
$pref = $this->getData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -305,10 +376,16 @@ class e_pref extends e_model
|
|||||||
*/
|
*/
|
||||||
public function load($force = false)
|
public function load($force = false)
|
||||||
{
|
{
|
||||||
|
global $pref;
|
||||||
if($force || !$this->hasData())
|
if($force || !$this->hasData())
|
||||||
{
|
{
|
||||||
$this->data_has_changed = false;
|
$this->data_has_changed = false;
|
||||||
$this->_load($force);
|
$this->_load($force);
|
||||||
|
//BC
|
||||||
|
if($this->alias === 'core')
|
||||||
|
{
|
||||||
|
$pref = $this->getData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@@ -327,12 +404,11 @@ class e_pref extends e_model
|
|||||||
|
|
||||||
if($data !== false)
|
if($data !== false)
|
||||||
{
|
{
|
||||||
//var_dump('Pref cache used: '.$this->alias);
|
|
||||||
$this->pref_cache = e107::getArrayStorage()->WriteArray($data, false); //runtime cache
|
$this->pref_cache = e107::getArrayStorage()->WriteArray($data, false); //runtime cache
|
||||||
return $this->loadData($data, false);
|
$this->loadData($data, false);
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//var_dump('Pref cache not used: '.$this->alias);
|
|
||||||
if (e107::getDb()->db_Select('core', 'e107_value', "e107_name='{$id}'"))
|
if (e107::getDb()->db_Select('core', 'e107_value', "e107_name='{$id}'"))
|
||||||
{
|
{
|
||||||
$row = e107::getDb()->db_Fetch();
|
$row = e107::getDb()->db_Fetch();
|
||||||
@@ -354,7 +430,8 @@ class e_pref extends e_model
|
|||||||
if(empty($data))
|
if(empty($data))
|
||||||
$data = array();
|
$data = array();
|
||||||
|
|
||||||
return $this->loadData($data, false);
|
$this->loadData($data, false);
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -367,9 +444,10 @@ class e_pref extends e_model
|
|||||||
*/
|
*/
|
||||||
public function save($from_post = true, $force = false, $session_messages = false)
|
public function save($from_post = true, $force = false, $session_messages = false)
|
||||||
{
|
{
|
||||||
|
global $pref;
|
||||||
if(!$this->prefid)
|
if(!$this->prefid)
|
||||||
{
|
{
|
||||||
return $this;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($from_post)
|
if($from_post)
|
||||||
@@ -401,6 +479,9 @@ class e_pref extends e_model
|
|||||||
|
|
||||||
if(e107::getDb()->db_Select_gen("REPLACE INTO `#core` (e107_name,e107_value) values ('{$this->prefid}', '".addslashes($dbdata)."') "))
|
if(e107::getDb()->db_Select_gen("REPLACE INTO `#core` (e107_name,e107_value) values ('{$this->prefid}', '".addslashes($dbdata)."') "))
|
||||||
{
|
{
|
||||||
|
$this->data_has_changed = false; //reset status
|
||||||
|
$this->setPrefCache($this->toString(false), true); //reset pref cache - runtime & file
|
||||||
|
|
||||||
if($this->set_backup === true)
|
if($this->set_backup === true)
|
||||||
{
|
{
|
||||||
if($this->serial_bc)
|
if($this->serial_bc)
|
||||||
@@ -411,16 +492,19 @@ class e_pref extends e_model
|
|||||||
{
|
{
|
||||||
$dbdata = $this->pref_cache;
|
$dbdata = $this->pref_cache;
|
||||||
}
|
}
|
||||||
if(e107::getDb()->db_Select_gen("REPLACE INTO `#core` (e107_name,e107_value) values ('{$this->prefid}_Backup', '".addslashes($dbdata)."') "))
|
if(e107::getDb()->db_Select_gen("REPLACE INTO `#core` (e107_name,e107_value) values ('".$this->prefid."_Backup', '".addslashes($dbdata)."') "))
|
||||||
{
|
{
|
||||||
$emessage->add('Backup successfully created.', E_MESSAGE_SUCCESS, $session_messages);
|
$emessage->add('Backup successfully created.', E_MESSAGE_SUCCESS, $session_messages);
|
||||||
ecache::clear_sys('Config_'.$this->alias.'_backup');
|
ecache::clear_sys('Config_'.$this->alias.'_backup');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->data_has_changed = false; //reset status
|
|
||||||
$this->setPrefCache($this->toString(false), true); //reset pref cache - runtime & file
|
|
||||||
$emessage->add('Settings successfully saved.', E_MESSAGE_SUCCESS, $session_messages);
|
$emessage->add('Settings successfully saved.', E_MESSAGE_SUCCESS, $session_messages);
|
||||||
|
//BC
|
||||||
|
if($this->alias === 'core')
|
||||||
|
{
|
||||||
|
$pref = $this->getData();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//TODO - DB error messages
|
//TODO - DB error messages
|
||||||
@@ -476,7 +560,6 @@ class e_pref extends e_model
|
|||||||
}
|
}
|
||||||
if($save)
|
if($save)
|
||||||
{
|
{
|
||||||
|
|
||||||
ecache::set_sys('Config_'.($save !== true ? $save : $this->alias), $cache_string, true);
|
ecache::set_sys('Config_'.($save !== true ? $save : $this->alias), $cache_string, true);
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
@@ -916,7 +999,6 @@ class e_model
|
|||||||
*/
|
*/
|
||||||
public function set($key, $value = null, $strict = false)
|
public function set($key, $value = null, $strict = false)
|
||||||
{
|
{
|
||||||
$this->data_has_changed = true;
|
|
||||||
return $this->_setDataSimple($key, $value, $strict);
|
return $this->_setDataSimple($key, $value, $strict);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1120,6 +1202,14 @@ class e_model
|
|||||||
return ($strict ? $newData !== $postedData : $newData != $postedData);
|
return ($strict ? $newData !== $postedData : $newData != $postedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function dataHasChanged()
|
||||||
|
{
|
||||||
|
return $this->data_has_changed;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge posted data with the object data
|
* Merge posted data with the object data
|
||||||
* Should be used on edit/update/create record (back-end)
|
* Should be used on edit/update/create record (back-end)
|
||||||
@@ -1383,12 +1473,12 @@ class e_model
|
|||||||
{
|
{
|
||||||
if(!$strict)
|
if(!$strict)
|
||||||
{
|
{
|
||||||
$this->{$data_src}[$key] = $value;
|
|
||||||
//data has changed
|
//data has changed
|
||||||
if('_data' === $data_src && !$this->data_has_changed)
|
if('_data' === $data_src && !$this->data_has_changed)
|
||||||
{
|
{
|
||||||
$this->data_has_changed = (isset($this->_data[$key]) && $this->_data[$key] != $value);
|
$this->data_has_changed = (isset($this->_data[$key]) && $this->_data[$key] != $value);
|
||||||
}
|
}
|
||||||
|
$this->{$data_src}[$key] = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,9 +10,9 @@
|
|||||||
| GNU General Public License (http://gnu.org).
|
| GNU General Public License (http://gnu.org).
|
||||||
|
|
|
|
||||||
| $Source: /cvs_backup/e107_0.8/e107_handlers/theme_handler.php,v $
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/theme_handler.php,v $
|
||||||
| $Revision: 1.45 $
|
| $Revision: 1.46 $
|
||||||
| $Date: 2009-08-17 12:48:52 $
|
| $Date: 2009-08-17 14:40:22 $
|
||||||
| $Author: e107coders $
|
| $Author: secretr $
|
||||||
+----------------------------------------------------------------------------+
|
+----------------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -76,16 +76,22 @@ class themeHandler{
|
|||||||
if(isset($_POST['submit_adminstyle']))
|
if(isset($_POST['submit_adminstyle']))
|
||||||
{
|
{
|
||||||
$this -> id = $_POST['curTheme'];
|
$this -> id = $_POST['curTheme'];
|
||||||
$this -> setAdminStyle();
|
if($this -> setAdminStyle())
|
||||||
|
{
|
||||||
|
eMessage::getInstance()->add(TPVLAN_43, E_MESSAGE_SUCCESS);
|
||||||
|
}
|
||||||
|
e107::getConfig()->save(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($_POST['submit_style']))
|
if(isset($_POST['submit_style']))
|
||||||
{
|
{
|
||||||
$this -> id = $_POST['curTheme'];
|
$this -> id = $_POST['curTheme'];
|
||||||
$this -> setStyle();
|
|
||||||
$this -> SetCustomPages($_POST['custompages']);
|
$this -> SetCustomPages($_POST['custompages']);
|
||||||
|
$this -> setStyle();
|
||||||
|
|
||||||
|
e107::getConfig()->save(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($_POST['installplugin']))
|
if(isset($_POST['installplugin']))
|
||||||
@@ -564,9 +570,7 @@ class themeHandler{
|
|||||||
|
|
||||||
function setThemeConfig()
|
function setThemeConfig()
|
||||||
{
|
{
|
||||||
global $theme_pref;
|
|
||||||
$this -> loadThemeConfig();
|
$this -> loadThemeConfig();
|
||||||
|
|
||||||
if($this->themeConfigObj)
|
if($this->themeConfigObj)
|
||||||
{
|
{
|
||||||
return call_user_method("process",$this->themeConfigObj);
|
return call_user_method("process",$this->themeConfigObj);
|
||||||
@@ -1044,27 +1048,24 @@ class themeHandler{
|
|||||||
function setStyle()
|
function setStyle()
|
||||||
{
|
{
|
||||||
global $pref, $e107cache, $ns, $sql, $emessage;
|
global $pref, $e107cache, $ns, $sql, $emessage;
|
||||||
$pref['themecss'] = $_POST['themecss'];
|
//TODO adminlog
|
||||||
$pref['image_preload'] = $_POST['image_preload'];
|
e107::getConfig()->setPosted('themecss', $_POST['themecss'])
|
||||||
$pref['sitetheme_deflayout'] = $_POST['layout_default'];
|
->setPosted('image_preload', $_POST['image_preload'])
|
||||||
|
->setPosted('sitetheme_deflayout', $_POST['layout_default']);
|
||||||
$e107cache->clear_sys();
|
|
||||||
if(save_prefs())
|
$msg = $this->setThemeConfig();
|
||||||
|
if($msg)
|
||||||
{
|
{
|
||||||
$emessage->add(TPVLAN_37, E_MESSAGE_SUCCESS); // Default Message
|
$emessage->add(TPVLAN_37, E_MESSAGE_SUCCESS);
|
||||||
$emessage->add($this -> setThemeConfig(),E_MESSAGE_SUCCESS); // Custom Message from theme config.
|
if(is_array($msg))
|
||||||
$this->theme_adminlog('03',$pref['image_preload'].', '.$pref['themecss']);
|
$emessage->add($msg[0], $msg[1]);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$emessage->add(TPVLAN_43, E_MESSAGE_ERROR);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setAdminStyle()
|
function setAdminStyle()
|
||||||
{
|
{
|
||||||
global $pref, $e107cache, $ns, $emessage;
|
global $pref, $e107cache, $ns, $emessage;
|
||||||
$pref['admincss'] = $_POST['admincss'];
|
/*$pref['admincss'] = $_POST['admincss'];
|
||||||
$pref['adminstyle'] = $_POST['adminstyle'];
|
$pref['adminstyle'] = $_POST['adminstyle'];
|
||||||
|
|
||||||
|
|
||||||
@@ -1077,23 +1078,31 @@ class themeHandler{
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$emessage->add(TPVLAN_43, E_MESSAGE_ERROR);
|
$emessage->add(TPVLAN_43, E_MESSAGE_ERROR);
|
||||||
}
|
}*/
|
||||||
|
//TODO adminlog
|
||||||
|
e107::getConfig()->setPosted('admincss', $_POST['admincss'])
|
||||||
|
->setPosted('adminstyle', $_POST['adminstyle']);
|
||||||
|
|
||||||
|
return (e107::getConfig()->dataHasChangedFor('admincss') || e107::getConfig()->dataHasChangedFor('adminstyle'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function SetCustomPages($array)
|
function SetCustomPages($array)
|
||||||
{
|
{
|
||||||
if(!is_array($array)){ return; }
|
if(!is_array($array)){ return; }
|
||||||
|
|
||||||
global $pref;
|
//global $pref;
|
||||||
$key = key($array);
|
$key = key($array);
|
||||||
|
//['sitetheme_custompages']
|
||||||
|
$array[$key] = trim(str_replace("\r\n", "\n", $array[$key]));
|
||||||
|
$newprefs[$key] = array_filter(explode("\n", $array[$key]));
|
||||||
|
$newprefs[$key] = array_unique($newprefs[$key]);
|
||||||
|
|
||||||
$pref['sitetheme_custompages'][$key] = array_filter(explode("\n",trim($array[$key])));
|
if(e107::getPref('sitetheme_deflayout') == 'legacyCustom')
|
||||||
|
|
||||||
if($pref['sitetheme_deflayout'] == 'legacyCustom')
|
|
||||||
{
|
{
|
||||||
$pref['sitetheme_custompages']['legacyCustom'] = array();
|
$newprefs['legacyCustom'] = array();
|
||||||
}
|
}
|
||||||
save_prefs();
|
//setPosted couldn't be used here - sitetheme_custompages structure is not defined
|
||||||
|
e107::getConfig()->set('sitetheme_custompages', e107::getParser()->toDB($newprefs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -4,20 +4,19 @@
|
|||||||
class theme__blank
|
class theme__blank
|
||||||
{
|
{
|
||||||
var $themePref;
|
var $themePref;
|
||||||
|
|
||||||
|
|
||||||
function process()
|
function process()
|
||||||
{
|
{
|
||||||
$theme_pref = array();
|
|
||||||
|
|
||||||
$pref = e107::getConfig();
|
$pref = e107::getConfig();
|
||||||
|
|
||||||
|
$theme_pref = array();
|
||||||
$theme_pref['example'] = $_POST['_blank_example'];
|
$theme_pref['example'] = $_POST['_blank_example'];
|
||||||
$theme_pref['example2'] = $_POST['_blank_example2'];
|
$theme_pref['example2'] = $_POST['_blank_example2'];
|
||||||
|
|
||||||
// print_a($theme_pref);
|
$pref->set('sitetheme_pref', $theme_pref);
|
||||||
$pref->add('sitetheme_pref', $theme_pref);
|
|
||||||
print_a($pref->get('sitetheme_pref'));
|
return $pref->dataHasChanged();
|
||||||
var_dump($pref->add('sitetheme_pref', $theme_pref)->save(FALSE));
|
|
||||||
// save_prefs($pref['sitetheme_pref']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function config()
|
function config()
|
||||||
@@ -27,7 +26,7 @@ class theme__blank
|
|||||||
|
|
||||||
$var[1]['caption'] = "Another Example";
|
$var[1]['caption'] = "Another Example";
|
||||||
$var[1]['html'] = "<input type='text' name='_blank_example2' value='".e107::getThemePref('example2')."' />";
|
$var[1]['html'] = "<input type='text' name='_blank_example2' value='".e107::getThemePref('example2')."' />";
|
||||||
var_dump(e107::getThemePref());
|
//var_dump(e107::getThemePref());
|
||||||
return $var;
|
return $var;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user