mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 00:29:38 +01:00
Finding of templates and their themes, if they are packaged in dirs as
apps
This commit is contained in:
parent
472a420231
commit
3a15cdcd6e
@ -572,74 +572,6 @@ class common
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* list themes available
|
||||
*
|
||||
* themes can either be css file like in HEAD (if the template has a css-dir and has css-files in is) \
|
||||
* or ordinary .14 themes-files
|
||||
*/
|
||||
function list_themes()
|
||||
{
|
||||
$tpl_dir = self::get_tpl_dir('phpgwapi');
|
||||
|
||||
if ($dh = @opendir($tpl_dir . SEP . 'css'))
|
||||
{
|
||||
while ($file = readdir($dh))
|
||||
{
|
||||
if (preg_match('/'."\.css$".'/i', $file) && $file != 'phpgw.css')
|
||||
{
|
||||
$list[] = substr($file,0,strpos($file,'.'));
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
if(!is_array($list))
|
||||
{
|
||||
$dh = opendir(EGW_SERVER_ROOT . '/phpgwapi/themes');
|
||||
while ($file = readdir($dh))
|
||||
{
|
||||
if (preg_match('/'."\.theme$".'/i', $file))
|
||||
{
|
||||
$list[] = substr($file,0,strpos($file,'.'));
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
reset ($list);
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* List available templates
|
||||
*
|
||||
* @returns array alphabetically sorted list of templates
|
||||
*/
|
||||
function list_templates()
|
||||
{
|
||||
$list = array();
|
||||
$d = dir(EGW_SERVER_ROOT . '/phpgwapi/templates');
|
||||
while (($entry=$d->read()))
|
||||
{
|
||||
if ($entry != '..' && file_exists(EGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry .'/class.'.$entry.'_framework.inc.php'))
|
||||
{
|
||||
$list[$entry]['name'] = $entry;
|
||||
if (file_exists ($f = EGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry . '/setup/setup.inc.php'))
|
||||
{
|
||||
include($f);
|
||||
$list[$entry]['title'] = $GLOBALS['egw_info']['template'][$entry]['title'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$list[$entry]['title'] = $entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
$d->close();
|
||||
ksort($list);
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* get template dir of an application
|
||||
*
|
||||
|
@ -780,6 +780,78 @@ abstract class egw_framework
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List available themes
|
||||
*
|
||||
* Themes are css file in the template directory
|
||||
*
|
||||
* @param string $themes_dir='css'
|
||||
*/
|
||||
function list_themes()
|
||||
{
|
||||
$list = array();
|
||||
if (($dh = @opendir(EGW_SERVER_ROOT.$this->template_dir . SEP . 'css')))
|
||||
{
|
||||
while (($file = readdir($dh)))
|
||||
{
|
||||
if (preg_match('/'."\.css$".'/i', $file))
|
||||
{
|
||||
list($name) = explode('.',$file);
|
||||
$list[$name] = $name;
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* List available templates
|
||||
*
|
||||
* @returns array alphabetically sorted list of templates
|
||||
*/
|
||||
static function list_templates()
|
||||
{
|
||||
$list = array();
|
||||
// templates packaged in the api
|
||||
$d = dir(EGW_SERVER_ROOT . '/phpgwapi/templates');
|
||||
while (($entry=$d->read()))
|
||||
{
|
||||
if ($entry != '..' && file_exists(EGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry .'/class.'.$entry.'_framework.inc.php'))
|
||||
{
|
||||
if (file_exists ($f = EGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry . '/setup/setup.inc.php'))
|
||||
{
|
||||
include($f);
|
||||
$list[$entry] = $GLOBALS['egw_info']['template'][$entry]['title'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$list[$entry] = $entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
$d->close();
|
||||
// templates packaged like apps in own directories (containing as setup/setup.inc.php file!)
|
||||
$d = dir(EGW_SERVER_ROOT);
|
||||
while (($entry=$d->read()))
|
||||
{
|
||||
if ($entry != '..' && !isset($GLOBALS['egw_info']['apps'][$entry]) &&
|
||||
file_exists(EGW_SERVER_ROOT . '/' . $entry .'/setup/setup.inc.php'))
|
||||
{
|
||||
include($f);
|
||||
if (isset($GLOBALS['egw_info']['template'][$entry]))
|
||||
{
|
||||
$list[$entry] = $GLOBALS['egw_info']['template'][$entry]['title'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$d->close();
|
||||
ksort($list);
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,19 +21,6 @@ class preferences_hooks
|
||||
*/
|
||||
static public function settings($hook_data)
|
||||
{
|
||||
// Setup some values to fill the array of this app's settings below
|
||||
$templates = common::list_templates();
|
||||
foreach($templates as $var => $value)
|
||||
{
|
||||
$_templates[$var] = $templates[$var]['title'];
|
||||
}
|
||||
|
||||
$themes = common::list_themes();
|
||||
foreach($themes as $value)
|
||||
{
|
||||
$_themes[$value] = $value;
|
||||
}
|
||||
|
||||
$navbar_format = array(
|
||||
'icons' => lang('Icons only'),
|
||||
'icons_and_text' => lang('Icons and text'),
|
||||
@ -135,7 +122,7 @@ class preferences_hooks
|
||||
'type' => 'select',
|
||||
'label' => 'Interface/Template Selection',
|
||||
'name' => 'template_set',
|
||||
'values' => $_templates,
|
||||
'values' => egw_framework::list_templates(),
|
||||
'help' => 'A template defines the layout of eGroupWare and it contains icons for each application.',
|
||||
'xmlrpc' => True,
|
||||
'admin' => False,
|
||||
@ -145,7 +132,7 @@ class preferences_hooks
|
||||
'type' => 'select',
|
||||
'label' => 'Theme (colors/fonts) Selection',
|
||||
'name' => 'theme',
|
||||
'values' => $_themes,
|
||||
'values' => isset($GLOBALS['egw']->framework) ? $GLOBALS['egw']->framework->list_themes() : array(),
|
||||
'help' => 'A theme defines the colors and fonts used by the template.',
|
||||
'xmlrpc' => True,
|
||||
'admin' => False,
|
||||
|
Loading…
Reference in New Issue
Block a user