/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Copyright ©2006 by sTEFANs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* This file contains a class that encapsulates and stores / restores
* @copyright Copyright ©2006 by sTEFANs
* @license http://opensource.org/licenses/lgpl-license.php GNU General Public License
/** Common utility functions */
require_once('inc/utils.inc.php');
/** Common definitions */
require_once('inc/var.inc.php');
/** A singleton containing settings made by the user via GUI.
* The instance of the class can be
* retrieved via <b>GetInstance</b>.
private static $instance =
NULL;
* Returns the single instance of this class.
* @return SwcUserSettings Single instance of this class.
if (self::$instance ==
NULL){
self::$instance =
new SwcUserSettings();
* Determines whether the top control bar should be minimized.
* @return boolean True if the control bar schould be minimized.
return ($this->configs[OPT_MINIMIZE_CTRL_BAR] ==
1 ?
true :
false);
* Sets whether the top control bar should be minimized.
* @param boolean $minimize True if the control bar schould be minimized.
* Determines whether the project page should always be shown,
* regardles of the current action.
* @return boolean True if the project page should always be shown.
* Sets whether the project page should always be shown.
* @param boolean $pin True if project page should always be shown.
* Determines whether the webspace should automatically
* be updated if it is outdated.
* @return boolean True if the webspace should
* automatically be updated.
* Sets whether the webspace should automatically
* be updated if it is outdated.
* @param boolean $enable True if the webspace should
* automatically be updated.
* Determines whether command execution result
* should be opened within a separate browser window.
* @return boolean True if command execution result
* should be opened within a separate browser window.
* Determines whether command execution result
* should be opened within a separate browser window.
* @return boolean True if command execution result
* should be opened within a separate browser window.
* Provides the width in pixel for the project frame.
* @return int Frame width in pixel.
* Sets the width in pixel for the project frame.
* @param int $width Frame width in pixel.
* Provides the height in pixel for the project frame.
* @return int Frame height in pixel.
* Sets the height in pixel for the project frame.
* @param int $width Frame height in pixel.
* Sets SVN command bar to visible or invisible.
* @param boolean $enable True if SVN command bar should
* Determines whether SVN command bar is visible.
* @return boolean True if SVN command bar is visible.
* Sets SVN switch bar to visible or invisible.
* @param boolean $enable True if SVN switch bar should
* Determines whether SVN switch bar is visible.
* @return boolean True if SVN switch bar is visible.
* Processes the user settings. This basically
* means, that the function scans <b>$_GET</b>
* and <b>$_POST</b> (preferred) for changes
* in the settings, stores the changes and
* restores the user settings.<br/>
* Because user settings are stored via cookies,
* it is important that this function is invoked
* before any HTML or whitespace is printed!
* @return boolean True if a user setting
* has been changed within <b>$_POST</b> or
* <b>$_GET</b>, false otherwise.
* Scans the given array for user settings.
* @param array $array Array to scan.
* @return boolean True if changed settings are found.
while ($idx <
count($idxs)){
if (isset
($array[$idxs[$idx]])){
$this->configs[$idxs[$idx]] =
$array[$idxs[$idx]];
* Stores the user settings within a cookie.
while ($idx <
count($idxs)-
1){
$vals .=
$this->configs[$idxs[$idx]].
';';
$vals .=
$this->configs[$idxs[count($idxs)-
1]];
// expires after 120 days
$expire =
time()+
60*
60*
24*
120;
// store them in the session as well in case user does not accept cookies.
* Restores the user settings from the cookie.
while ($idx <
count($idxs)){
$this->configs[$idxs[$idx]] =
$vals[$idx];
* Returns an array that provides mapping of index. The key
* of this array is numeric and the value is the index
* for the internal array.
* Singleton c'tor. Initializes user settings with default values.
$this->configs[$idxs[0]] =
'v01';
$this->configs[$idxs[1]] =
0;
$this->configs[$idxs[2]] =
0;
$this->configs[$idxs[3]] =
0;
$this->configs[$idxs[4]] =
0;
$this->configs[$idxs[5]] =
1024;
$this->configs[$idxs[6]] =
768;
$this->configs[$idxs[7]] =
1;
$this->configs[$idxs[8]] =
1;
* Does nothing else as prevent from beeing cloned.