From 0520b74f39f4d22ec8f8486ae93e81f4db51d360 Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Fri, 24 Oct 2014 11:02:37 +0200 Subject: [PATCH] Enhanced theme support to support more details in about.txt --- src/include/functions_common.php | 2 + src/include/functions_themes.php | 61 +++++++++++++++++++++++++------ src/templates/include_header.html | 2 +- src/themes/dark/about.txt | 5 ++- src/themes/default/about.txt | 5 ++- 5 files changed, 58 insertions(+), 17 deletions(-) diff --git a/src/include/functions_common.php b/src/include/functions_common.php index bd3c386..1efdaf1 100644 --- a/src/include/functions_common.php +++ b/src/include/functions_common.php @@ -945,9 +945,11 @@ function InitConfigurationValues() else $content['user_theme'] = $content['web_theme']; +/* // Init Theme About Info ^^ InitThemeAbout($content['user_theme']); // --- +*/ // --- Handle HTML Injection stuff if ( strlen(GetConfigSetting("InjectHtmlHeader", false)) > 0 ) diff --git a/src/include/functions_themes.php b/src/include/functions_themes.php index bbdbb04..4317678 100644 --- a/src/include/functions_themes.php +++ b/src/include/functions_themes.php @@ -79,20 +79,27 @@ function CreateThemesList() $alldirectories = list_directories( $gl_root_path . "themes/"); for($i = 0; $i < count($alldirectories); $i++) { - // --- web_theme - $content['STYLES'][$i]['StyleName'] = $alldirectories[$i]; - if ( $content['web_theme'] == $alldirectories[$i] ) - $content['STYLES'][$i]['selected'] = "selected"; - else - $content['STYLES'][$i]['selected'] = ""; - // --- + // Init Theme Settings + $themename = $alldirectories[$i]; + $content['STYLES'][$themename]['StyleName'] = $themename; + + // Init stuff from abvout + InitThemeAbout($themename); + + // Copy to userstyles array + $content['USERSTYLES'][$themename] = $content['STYLES'][$themename]; - // --- user_theme - $content['USERSTYLES'][$i]['StyleName'] = $alldirectories[$i]; - if ( $content['user_theme'] == $alldirectories[$i] ) - $content['USERSTYLES'][$i]['is_selected'] = "selected"; + // --- web_theme + if ( $content['web_theme'] == $themename ) + $content['STYLES'][$themename]['selected'] = "selected"; else - $content['USERSTYLES'][$i]['is_selected'] = ""; + $content['STYLES'][$themename]['selected'] = ""; + // --- + // --- user_theme + if ( $content['user_theme'] == $themename ) + $content['USERSTYLES'][$themename]['is_selected'] = "selected"; + else + $content['USERSTYLES'][$themename]['is_selected'] = ""; // --- } } @@ -111,6 +118,12 @@ function InitThemeAbout( $themename ) { global $content, $gl_root_path; $szAboutFile = $gl_root_path . "themes/" . $themename . "/about.txt"; + + // Init variables + $content['STYLES'][$themename]['Author'] = ""; + $content['STYLES'][$themename]['Link'] = ""; + $content['STYLES'][$themename]['DisplayName'] = $themename; + if ( is_file( $szAboutFile ) ) { //Read About Info! $aboutfile = fopen($szAboutFile, 'r'); @@ -119,16 +132,40 @@ function InitThemeAbout( $themename ) while (!feof ($aboutfile)) { $tmpline = fgets($aboutfile, 1024); + if ( strpos($tmpline, ":") !== false ) + { + // Split array + $aLine = explode(":", $tmpline); + switch ( $aLine[0] ) + { + case "Author": + $content['STYLES'][$themename]['Author'] = trim($aLine[1]); + break; + case "Link": + $content['STYLES'][$themename]['Link'] = trim($aLine[1]); + break; + case "DisplayName": + $content['STYLES'][$themename]['DisplayName'] = trim($aLine[1]); + break; + } + } +/* if (!isset($content["theme_madeby"]) ) $content["theme_madeby"] = substr( trim($tmpline), 0, 25); else if (!isset($content["theme_madebylink"]) ) $content["theme_madebylink"] = substr( trim($tmpline), 0, 256); + else if (!isset($content["theme_name"]) ) + $content["theme_name"] = substr( trim($tmpline), 0, 256); else { $content["theme_madebyenable"] = "true"; break; } +*/ } + + // Enable madeby display + $content["theme_madebyenable"] = "true"; } fclose($aboutfile); } diff --git a/src/templates/include_header.html b/src/templates/include_header.html index 331b0d2..cd0af14 100644 --- a/src/templates/include_header.html +++ b/src/templates/include_header.html @@ -71,7 +71,7 @@ diff --git a/src/themes/dark/about.txt b/src/themes/dark/about.txt index d0fcffa..615ae64 100644 --- a/src/themes/dark/about.txt +++ b/src/themes/dark/about.txt @@ -1,2 +1,3 @@ -Andre Lorbach -http://www.adiscon.com +Author: Andre Lorbach +Link: http://www.adiscon.com +DisplayName: Dark diff --git a/src/themes/default/about.txt b/src/themes/default/about.txt index d0fcffa..69fadfe 100644 --- a/src/themes/default/about.txt +++ b/src/themes/default/about.txt @@ -1,2 +1,3 @@ -Andre Lorbach -http://www.adiscon.com +Author: Andre Lorbach +Link: http://www.adiscon.com +DisplayName: Default \ No newline at end of file