<?php
/*
Decoration.php, obsolete
Copyright (C) 2003-2004 Arend van Beelen, Auton Rijnsburg
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
For any questions, comments or whatever, you may mail me at: hide@address.com
*/
/**
* @brief Provides access to information about decorations and themes.
*
* This class provides information about decorations and themes.
*
* You can use the function theme() to get the currently used theme and the
* function availableThemes() to get a list of all available themes and their
* full names.
*
* Use the function useDecorations() to determine whether the user wants to
* see extra decorations, like page icons.
*
* @sa theme(), availableThemes(), useDecorations()
* @sa PageIcon
*/
class Decoration
{
/**
* Constructor.
*/
private function __construct()
{
$username = (class_exists('Login') ? Login::username() : '');
$this->config = new Config('', $username);
$this->useDecorations = ($this->config->variable('useDecorations', 'true') == 'true');
}
/**
* Returns the currently used theme as the basename of the CSS file used
* for the theme.
*/
public static function theme()
{
$instance = self::instance();
return $instance->config->variable('theme', 'default');
}
/**
* Returns an array containing @p CSS => @p Name pairs. Where @p CSS is
* the basename of the CSS file used for a theme, and @p Name is the
* name of the theme.
*/
public static function availableThemes()
{
$instance = self::instance();
if(isset($instance->themes) == false)
{
$lines = file('resources/base/themes/themes');
foreach($lines as $line)
{
list($css, $name) = explode(':', trim($line));
$instance->themes[$css] = $name;
}
}
return $instance->themes;
}
/**
* Returns whether the user wants to see extra decorations.
*
* @return @p true if decorations are enabled, @p false otherwise.
*/
public static function useDecorations()
{
$instance = self::instance();
return $instance->useDecorations;
}
private static function instance()
{
if(self::$instance == null)
{
self::$instance = new Decoration();
}
return self::$instance;
}
private static $instance = null;
private $config;
private $useDecorations;
private $themes;
}
?>