From 32ae4efbcf73d200afcb8d3a80ad0a61d6a9b26b Mon Sep 17 00:00:00 2001 From: Tortle Date: Wed, 2 Jun 2021 17:07:31 -0700 Subject: [PATCH] Make CSS styles configurable (#222) Make CSS styles configurable Co-authored-by: Tortle Reviewed-on: https://code.rocketnine.space/tslocum/tinyib/pulls/222 Co-Authored-By: Tortle Co-Committed-By: Tortle --- inc/defines.php | 7 +++++++ inc/html.php | 50 ++++++++++++++++++++++++++++++++++++++++---- settings.default.php | 7 +++++++ 3 files changed, 60 insertions(+), 4 deletions(-) diff --git a/inc/defines.php b/inc/defines.php index c21ec3d..71b6a70 100644 --- a/inc/defines.php +++ b/inc/defines.php @@ -149,6 +149,13 @@ if (!defined('TINYIB_DBPATH')) { define('TINYIB_DBPATH', '.tinyib.db'); } } +if (!defined('TINYIB_DEFAULTSTYLE')) { + define('TINYIB_DEFAULTSTYLE', 'futaba'); +} +if (!isset($tinyib_stylesheets)) { + $tinyib_stylesheets = array('futaba' => 'Futaba', + 'burichan' => 'Burichan'); +} if (!isset($tinyib_hidefieldsop)) { $tinyib_hidefieldsop = array(); } diff --git a/inc/html.php b/inc/html.php index 3f135ab..1041140 100644 --- a/inc/html.php +++ b/inc/html.php @@ -20,6 +20,8 @@ function pageHeader() { $js_captcha .= ''; } + $stylesheets = pageStylesheets(); + return << @@ -33,9 +35,7 @@ function pageHeader() { $title - - - + $stylesheets $js_captcha @@ -43,6 +43,31 @@ function pageHeader() { EOF; } +function pageStylesheets() { + global $tinyib_stylesheets; + + // Global stylesheet + $return = ''; + + // Default stylesheet + $default_style_value = htmlentities(TINYIB_DEFAULTSTYLE, ENT_QUOTES); + $default_style_name = htmlentities($tinyib_stylesheets[TINYIB_DEFAULTSTYLE]); + $return .= ''; + + // Additional stylesheets + foreach($tinyib_stylesheets as $value => $display_name) { + if ($value === TINYIB_DEFAULTSTYLE) { + continue; + } + + $value_html = htmlentities($value, ENT_QUOTES); + $name_html = htmlentities($display_name, ENT_QUOTES); + $return .= ''; + } + + return $return; +} + function pageFooter() { // If the footer link is removed from the page, please link to TinyIB somewhere on the site. // This is all I ask in return for the free software you are using. @@ -559,6 +584,8 @@ EOF; } function buildPage($htmlposts, $parent, $pages = 0, $thispage = 0, $lastpostid = 0) { + global $tinyib_stylesheets; + $cataloglink = TINYIB_CATALOG ? ('[' . __('Catalog') . ']') : ''; $managelink = (TINYIB_MANAGEKEY == '') ? ('[' . __('Manage') . ']') : ''; @@ -625,12 +652,27 @@ EOF; $txt_password = __('Password'); $txt_delete = __('Delete'); $txt_delete_post = __('Delete Post'); + + $style_select = ''; + + if (count($tinyib_stylesheets) > 1) { + $options = ''; + + foreach($tinyib_stylesheets as $value => $display_name) { + $value_html = htmlentities($value, ENT_QUOTES); + $name_html = htmlentities($display_name); + $options .= ''; + } + + $style_select = ''; + } + $body = <<
$cataloglink $managelink - + $style_select