New Feature: PLA icons and CSS can now be themeble

This commit is contained in:
Deon George
2009-07-08 16:14:50 +10:00
parent b4653e84a2
commit 7273ad292b
121 changed files with 96 additions and 88 deletions

View File

@@ -404,7 +404,7 @@ class Attribute {
}
public function getIcon() {
return $this->icon;
return $this->icon ? sprintf('%s/%s',IMGDIR,$this->icon) : '';
}
public function getHint() {

View File

@@ -892,7 +892,7 @@ class Template extends xmlTemplate {
* Get template icon
*/
public function getIcon() {
return isset($this->icon) ? $this->icon : '';
return isset($this->icon) ? sprintf('%s/%s',IMGDIR,$this->icon) : '';
}
/**

View File

@@ -1821,9 +1821,7 @@ function fillRec(id,value) {
$this->draw('UrlValueIcon',$attribute,$val);
else {
$icon = $attribute->getIcon();
if ($icon)
if ($icon = $attribute->getIcon())
printf('<img src="%s" alt="Icon" align="top" />&nbsp;',$icon);
}
}

View File

@@ -160,6 +160,17 @@ error_reporting(E_ALL);
# Start our session.
app_session_start();
# See if we have a session, we can then get our theme out
$app['theme'] = 'default';
if (isset($_SESSION[APPCONFIG]))
if (is_dir(realpath(sprintf('images/%s',$_SESSION[APPCONFIG]->getValue('appearance','theme'))))
&& is_file(realpath(sprintf('css/%s/%s',$_SESSION[APPCONFIG]->getValue('appearance','theme'),$_SESSION[APPCONFIG]->getValue('appearance','stylesheet')))))
$app['theme'] = $_SESSION[APPCONFIG]->getValue('appearance','theme');
define('CSSDIR',sprintf('css/%s',$app['theme']));
define('IMGDIR',sprintf('images/%s',$app['theme']));
# Initialise the hooks
require_once LIBDIR.'hooks.php';

View File

@@ -191,6 +191,10 @@ class Config {
'desc'=>'Style sheet to use',
'default'=>'style.css');
$this->default->appearance['theme'] = array(
'desc'=>'Which theme to use',
'default'=>'default');
/** Tree display
* An array of format strings used to display enties in the
* tree viewer (left-hand side). The first format string that

View File

@@ -22,8 +22,6 @@ define('QUERYDIR',sprintf('%s/',realpath(LIBDIR.'../queries/')));
define('TMPLDIR',sprintf('%s/',realpath(LIBDIR.'../templates/')));
define('DOCDIR',sprintf('%s/',realpath(LIBDIR.'../doc/')));
define('HOOKSDIR',sprintf('%s/',realpath(LIBDIR.'../hooks/')));
define('CSSDIR','css/');
define('IMGDIR','images/');
define('JSDIR','js/');
/**
@@ -1616,9 +1614,9 @@ function get_icon($server_id,$dn,$object_classes=array()) {
$cval = explode('=',$tmp[0],2);
$cval = isset($cval[1]) ? $cval[1] : false;
if ($cval && false === strpos($cval,'..') &&
file_exists(realpath(sprintf('%s/countries/%s.png',IMGDIR,strtolower($cval)))))
file_exists(realpath(sprintf('%s/../countries/%s.png',IMGDIR,strtolower($cval)))))
return sprintf('countries/%s.png',strtolower($cval));
return sprintf('../countries/%s.png',strtolower($cval));
else
return 'country.png';

View File

@@ -31,15 +31,21 @@ class page {
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED)
debug_log('Entered with [%s]',129,__FILE__,__LINE__,__METHOD__,$index);
$this->index = $index;
# To be defined in a configuration file.
$this->_app['title'] = app_name();
$this->_app['logo'] = IMGDIR.'/logo-small.png';
if (! is_null($index))
$this->_app['urlcss'] = sprintf('%s/%s',CSSDIR,$_SESSION[APPCONFIG]->getValue('appearance','stylesheet'));
else
$this->_app['urlcss'] = sprintf('%s/%s',CSSDIR,'style.css');
# Default Values for configurable items.
$this->_default['stylecss'] = CSSDIR.'style.css';
$this->_default['logo'] = IMGDIR.'logo-small.png';
$this->_default['sysmsg']['error'] = IMGDIR.'error-big.png';
$this->_default['sysmsg']['warn'] = IMGDIR.'warn-big.png';
$this->_default['sysmsg']['info'] = IMGDIR.'info-big.png';
$this->_default['sysmsg']['error'] = IMGDIR.'/error-big.png';
$this->_default['sysmsg']['warn'] = IMGDIR.'/warn-big.png';
$this->_default['sysmsg']['info'] = IMGDIR.'/info-big.png';
# Capture any output so far (in case we send some headers below) - there shouldnt be any output anyway.
$preOutput = '';
@@ -75,15 +81,6 @@ class page {
$this->_pageheader[] .= "\n";
$this->_pageheader[] .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="auto" lang="auto" dir="ltr">'."\n";
$this->_pageheader[] .= "\n";
$this->_app['logo'] = $this->_default['logo'];
if (! is_null($index))
$this->_app['urlcss'] = sprintf('%s%s',CSSDIR,$_SESSION[APPCONFIG]->getValue('appearance','stylesheet'));
else
$this->_app['urlcss'] = sprintf('%s%s',CSSDIR,'style.css');
$this->index = $index;
}
/* Add to the HTML Header */