diff --git a/core/event.php b/core/event.php index 349a6ce0..c9064c3e 100644 --- a/core/event.php +++ b/core/event.php @@ -60,7 +60,7 @@ class PageRequestEvent extends Event // if path is not specified, use the default front page if (empty($path)) { /* empty is faster than strlen */ - $path = $config->get_string('front_page'); + $path = $config->get_string(SetupConfig::FRONT_PAGE); } // break the path into parts diff --git a/core/imageboard/image.php b/core/imageboard/image.php index 3e2529b8..598a2ab7 100644 --- a/core/imageboard/image.php +++ b/core/imageboard/image.php @@ -813,7 +813,7 @@ class Image $tmpl = str_replace('$size', "{$this->width}x{$this->height}", $tmpl); $tmpl = str_replace('$filesize', to_shorthand_int($this->filesize), $tmpl); $tmpl = str_replace('$filename', $_escape($base_fname), $tmpl); - $tmpl = str_replace('$title', $_escape($config->get_string("title")), $tmpl); + $tmpl = str_replace('$title', $_escape($config->get_string(SetupConfig::TITLE)), $tmpl); $tmpl = str_replace('$date', $_escape(autodate($this->posted, false)), $tmpl); // nothing seems to use this, sending the event out to 50 exts is a lot of overhead diff --git a/core/page.php b/core/page.php index e31ed7d3..e779290a 100644 --- a/core/page.php +++ b/core/page.php @@ -405,7 +405,7 @@ class Page global $config; $data_href = get_base_href(); - $theme_name = $config->get_string('theme', 'default'); + $theme_name = $config->get_string(SetupConfig::THEME, 'default'); $this->add_html_header("", 40); diff --git a/core/urls.php b/core/urls.php index e4fc0977..3bdc9c71 100644 --- a/core/urls.php +++ b/core/urls.php @@ -14,7 +14,7 @@ function make_link(?string $page=null, ?string $query=null): string global $config; if (is_null($page)) { - $page = $config->get_string('main_page'); + $page = $config->get_string(SetupConfig::MAIN_PAGE); } if (!is_null(BASE_URL)) { diff --git a/core/util.php b/core/util.php index aa310c45..7017078d 100644 --- a/core/util.php +++ b/core/util.php @@ -16,7 +16,7 @@ function mtimefile(string $file): string function get_theme(): string { global $config; - $theme = $config->get_string("theme", "default"); + $theme = $config->get_string(SetupConfig::THEME, "default"); if (!file_exists("themes/$theme")) { $theme = "default"; } diff --git a/ext/browser_search/main.php b/ext/browser_search/main.php index 7c1fcc82..301ca0db 100644 --- a/ext/browser_search/main.php +++ b/ext/browser_search/main.php @@ -27,14 +27,14 @@ class BrowserSearch extends Extension // Add in header code to let the browser know that the search plugin exists // We need to build the data for the header - $search_title = $config->get_string('title'); + $search_title = $config->get_string(SetupConfig::TITLE); $search_file_url = make_link('browser_search/please_dont_use_this_tag_as_it_would_break_stuff__search.xml'); $page->add_html_header(""); // The search.xml file that is generated on the fly if ($event->page_matches("browser_search/please_dont_use_this_tag_as_it_would_break_stuff__search.xml")) { // First, we need to build all the variables we'll need - $search_title = $config->get_string('title'); + $search_title = $config->get_string(SetupConfig::TITLE); $search_form_url = make_link('post/list/{searchTerms}'); $suggenton_url = make_link('browser_search/')."{searchTerms}"; $icon_b64 = base64_encode(file_get_contents("ext/handle_static/static/favicon.ico")); diff --git a/ext/custom_html_headers/main.php b/ext/custom_html_headers/main.php index 3125f3b1..58715e9b 100644 --- a/ext/custom_html_headers/main.php +++ b/ext/custom_html_headers/main.php @@ -65,7 +65,7 @@ class custom_html_headers extends Extension global $config, $page; // get config values - $site_title = $config->get_string("title"); + $site_title = $config->get_string(SetupConfig::TITLE); $sitename_in_title = $config->get_int("sitename_in_title"); // if feature is enabled & sitename isn't already in title diff --git a/ext/downtime/theme.php b/ext/downtime/theme.php index caedcfda..99c4cffc 100644 --- a/ext/downtime/theme.php +++ b/ext/downtime/theme.php @@ -21,7 +21,7 @@ class DowntimeTheme extends Themelet public function display_message(string $message) { global $config, $user, $page; - $theme_name = $config->get_string('theme'); + $theme_name = $config->get_string(SetupConfig::THEME); $data_href = get_base_href(); $login_link = make_link("user_admin/login"); $auth = $user->get_auth_html(); diff --git a/ext/et/main.php b/ext/et/main.php index e344710d..f342a39f 100644 --- a/ext/et/main.php +++ b/ext/et/main.php @@ -40,8 +40,8 @@ class ET extends Extension global $config, $database; $info = []; - $info['site_title'] = $config->get_string("title"); - $info['site_theme'] = $config->get_string("theme"); + $info['site_title'] = $config->get_string(SetupConfig::TITLE); + $info['site_theme'] = $config->get_string(SetupConfig::THEME); $info['site_url'] = "http://" . $_SERVER["HTTP_HOST"] . get_base_href(); $info['sys_shimmie'] = VERSION; diff --git a/ext/handle_static/main.php b/ext/handle_static/main.php index fb20dd59..69918964 100644 --- a/ext/handle_static/main.php +++ b/ext/handle_static/main.php @@ -17,7 +17,7 @@ class HandleStatic extends Extension if ($page->mode == PageMode::PAGE && (!isset($page->blocks) || $this->count_main($page->blocks) == 0)) { $h_pagename = html_escape(implode('/', $event->args)); $f_pagename = preg_replace("/[^a-z_\-\.]+/", "_", $h_pagename); - $theme_name = $config->get_string("theme", "default"); + $theme_name = $config->get_string(SetupConfig::THEME, "default"); $theme_file = "themes/$theme_name/static/$f_pagename"; $static_file = "ext/handle_static/static/$f_pagename"; diff --git a/ext/home/main.php b/ext/home/main.php index 34b9422f..156035c6 100644 --- a/ext/home/main.php +++ b/ext/home/main.php @@ -22,8 +22,8 @@ class Home extends Extension global $config, $page; if ($event->page_matches("home")) { $base_href = get_base_href(); - $sitename = $config->get_string('title'); - $theme_name = $config->get_string('theme'); + $sitename = $config->get_string(SetupConfig::TITLE); + $theme_name = $config->get_string(SetupConfig::THEME); $body = $this->get_body(); @@ -52,7 +52,7 @@ class Home extends Extension // returns just the contents of the body global $config; $base_href = get_base_href(); - $sitename = $config->get_string('title'); + $sitename = $config->get_string(SetupConfig::TITLE); $contact_link = contact_link(); if (is_null($contact_link)) { $contact_link = ""; diff --git a/ext/index/theme.php b/ext/index/theme.php index 5b58d627..f04e124c 100644 --- a/ext/index/theme.php +++ b/ext/index/theme.php @@ -110,7 +110,7 @@ and of course start organising your images :-) global $config; if (count($this->search_terms) == 0) { - $page_title = $config->get_string('title'); + $page_title = $config->get_string(SetupConfig::TITLE); } else { $search_string = implode(' ', $this->search_terms); $page_title = html_escape($search_string); diff --git a/ext/numeric_score/theme.php b/ext/numeric_score/theme.php index 1852548c..05199b11 100644 --- a/ext/numeric_score/theme.php +++ b/ext/numeric_score/theme.php @@ -87,7 +87,7 @@ class NumericScoreTheme extends Themelet $nav_html = "Index"; - $page->set_heading($config->get_string('title')); + $page->set_heading($config->get_string(SetupConfig::TITLE)); $page->add_block(new Block("Navigation", $nav_html, "left", 10)); $page->add_block(new Block(null, $html, "main", 30)); } diff --git a/ext/rss_comments/main.php b/ext/rss_comments/main.php index b00f92aa..f882ca40 100644 --- a/ext/rss_comments/main.php +++ b/ext/rss_comments/main.php @@ -14,7 +14,7 @@ class RSS_Comments extends Extension public function onPostListBuilding(PostListBuildingEvent $event) { global $config, $page; - $title = $config->get_string('title'); + $title = $config->get_string(SetupConfig::TITLE); $page->add_html_header(""); @@ -60,7 +60,7 @@ class RSS_Comments extends Extension "; } - $title = $config->get_string('title'); + $title = $config->get_string(SetupConfig::TITLE); $base_href = make_http(get_base_href()); $version = $config->get_string('version'); $xml = <<get_string('title'); + $title = $config->get_string(SetupConfig::TITLE); if (count($event->search_terms) > 0) { $search = html_escape(implode(' ', $event->search_terms)); @@ -47,7 +47,7 @@ class RSS_Images extends Extension $data .= $this->thumb($image); } - $title = $config->get_string('title'); + $title = $config->get_string(SetupConfig::TITLE); $base_href = make_http(get_base_href()); $search = ""; if (count($search_terms) > 0) { diff --git a/ext/setup/config.php b/ext/setup/config.php new file mode 100644 index 00000000..2b5be64e --- /dev/null +++ b/ext/setup/config.php @@ -0,0 +1,12 @@ +set_default_string("title", "Shimmie"); - $config->set_default_string("front_page", "post/list"); - $config->set_default_string("main_page", "post/list"); - $config->set_default_string("theme", "default"); - $config->set_default_bool("word_wrap", true); - $config->set_default_bool("comment_captcha", false); + $config->set_default_string(SetupConfig::TITLE, "Shimmie"); + $config->set_default_string(SetupConfig::FRONT_PAGE, "post/list"); + $config->set_default_string(SetupConfig::MAIN_PAGE, "post/list"); + $config->set_default_string(SetupConfig::THEME, "default"); + $config->set_default_bool(SetupConfig::WORD_WRAP, true); } public function onPageRequest(PageRequestEvent $event) @@ -368,11 +369,11 @@ class Setup extends Extension "; $sb = new SetupBlock("General"); $sb->position = 0; - $sb->add_text_option("title", "Site title: "); - $sb->add_text_option("front_page", "
Front page: "); - $sb->add_text_option("main_page", "
Main page: "); + $sb->add_text_option(SetupConfig::TITLE, "Site title: "); + $sb->add_text_option(SetupConfig::FRONT_PAGE, "
Front page: "); + $sb->add_text_option(SetupConfig::MAIN_PAGE, "
Main page: "); $sb->add_text_option("contact_link", "
Contact URL: "); - $sb->add_choice_option("theme", $themes, "
Theme: "); + $sb->add_choice_option(SetupConfig::THEME, $themes, "
Theme: "); //$sb->add_multichoice_option("testarray", array("a" => "b", "c" => "d"), "
Test Array: "); $sb->add_bool_option("nice_urls", "
Nice URLs: "); $sb->add_label("(Javascript inactive, can't test!)$nicescript"); diff --git a/ext/sitemap/main.php b/ext/sitemap/main.php index 4ff80f88..6bf8b4a3 100644 --- a/ext/sitemap/main.php +++ b/ext/sitemap/main.php @@ -74,7 +74,7 @@ class XMLSitemap extends Extension // add index $index = []; - $index[0] = $config->get_string("front_page"); + $index[0] = $config->get_string(SetupConfig::FRONT_PAGE); $this->add_sitemap_queue($index, "weekly", "1"); /* --- Add 20 most used tags --- */ diff --git a/ext/upload/theme.php b/ext/upload/theme.php index 6b3b503a..efa407c8 100644 --- a/ext/upload/theme.php +++ b/ext/upload/theme.php @@ -189,7 +189,7 @@ class UploadTheme extends Themelet global $config; $link = make_http(make_link("upload")); $main_page = make_http(make_link()); - $title = $config->get_string('title'); + $title = $config->get_string(SetupConfig::TITLE); $max_size = $config->get_int('upload_size'); $max_kb = to_shorthand_int($max_size); $delimiter = $config->get_bool('nice_urls') ? '?' : '&'; @@ -235,7 +235,7 @@ class UploadTheme extends Themelet if (class_exists("VideoFileHandler")) { $supported_ext .= " flv mp4 ogv webm m4v"; } - $title = "Booru to " . $config->get_string('title'); + $title = "Booru to " . $config->get_string(SetupConfig::TITLE); // CA=0: Ask to use current or new tags | CA=1: Always use current tags | CA=2: Always use new tags $html .= '

{$this->subheading}"; } - $site_name = $config->get_string('title'); // bzchan: change from normal default to get title for top of page - $main_page = $config->get_string('main_page'); // bzchan: change from normal default to get main page for top of page + $site_name = $config->get_string(SetupConfig::TITLE); // bzchan: change from normal default to get title for top of page + $main_page = $config->get_string(SetupConfig::MAIN_PAGE); // bzchan: change from normal default to get main page for top of page - // bzchan: CUSTOM LINKS are prepared here, change these to whatever you like $custom_links = ""; if ($user->is_anonymous()) { $custom_links .= $this->navlinks(make_link('user_admin/login'), "My Account", ["user", "user_admin", "setup", "admin"]); diff --git a/themes/danbooru2/index.theme.php b/themes/danbooru2/index.theme.php index 51455d43..a62fdf8c 100644 --- a/themes/danbooru2/index.theme.php +++ b/themes/danbooru2/index.theme.php @@ -11,7 +11,7 @@ class CustomIndexTheme extends IndexTheme if (count($this->search_terms) == 0) { $query = null; - $page_title = $config->get_string('title'); + $page_title = $config->get_string(SetupConfig::TITLE); } else { $search_string = implode(' ', $this->search_terms); $query = url_escape($search_string); diff --git a/themes/danbooru2/layout.class.php b/themes/danbooru2/layout.class.php index 6c4514f2..e3d0116a 100644 --- a/themes/danbooru2/layout.class.php +++ b/themes/danbooru2/layout.class.php @@ -48,7 +48,7 @@ class Layout { global $config, $user; - //$theme_name = $config->get_string('theme'); + //$theme_name = $config->get_string(SetupConfig::THEME); //$base_href = $config->get_string('base_href'); //$data_href = get_base_href(); $contact_link = contact_link(); @@ -92,10 +92,9 @@ class Layout $subheading = "

{$this->subheading}
"; } - $site_name = $config->get_string('title'); // bzchan: change from normal default to get title for top of page - $main_page = $config->get_string('main_page'); // bzchan: change from normal default to get main page for top of page + $site_name = $config->get_string(SetupConfig::TITLE); // bzchan: change from normal default to get title for top of page + $main_page = $config->get_string(SetupConfig::MAIN_PAGE); // bzchan: change from normal default to get main page for top of page - // bzchan: CUSTOM LINKS are prepared here, change these to whatever you like $custom_links = ""; if ($user->is_anonymous()) { $custom_links .= $this->navlinks(make_link('user_admin/login'), "Sign in", ["user", "user_admin", "setup", "admin"]); diff --git a/themes/default/layout.class.php b/themes/default/layout.class.php index e67309bb..973c0bb0 100644 --- a/themes/default/layout.class.php +++ b/themes/default/layout.class.php @@ -11,7 +11,7 @@ class Layout { global $config; - //$theme_name = $config->get_string('theme', 'default'); + //$theme_name = $config->get_string(SetupConfig::THEME, 'default'); //$data_href = get_base_href(); $contact_link = contact_link(); $header_html = $page->get_all_html_headers(); diff --git a/themes/futaba/comment.theme.php b/themes/futaba/comment.theme.php index 7647c322..5ae42be1 100644 --- a/themes/futaba/comment.theme.php +++ b/themes/futaba/comment.theme.php @@ -11,7 +11,7 @@ class CustomCommentListTheme extends CommentListTheme //$prev = $page_number - 1; //$next = $page_number + 1; - $page_title = $config->get_string('title'); + $page_title = $config->get_string(SetupConfig::TITLE); $page->set_title($page_title); $page->set_heading($page_title); $page->disable_left(); diff --git a/themes/futaba/layout.class.php b/themes/futaba/layout.class.php index faccb090..98076afb 100644 --- a/themes/futaba/layout.class.php +++ b/themes/futaba/layout.class.php @@ -6,7 +6,7 @@ class Layout { global $config; - $theme_name = $config->get_string('theme', 'default'); + $theme_name = $config->get_string(SetupConfig::THEME, 'default'); $data_href = get_base_href(); $contact_link = contact_link(); $header_html = $page->get_all_html_headers(); diff --git a/themes/lite/layout.class.php b/themes/lite/layout.class.php index 747b0086..3c1e1b2f 100644 --- a/themes/lite/layout.class.php +++ b/themes/lite/layout.class.php @@ -13,8 +13,8 @@ class Layout { global $config, $user; - $theme_name = $config->get_string('theme', 'lite'); - $site_name = $config->get_string('title'); + $theme_name = $config->get_string(SetupConfig::THEME, 'lite'); + $site_name = $config->get_string(SetupConfig::TITLE); $data_href = get_base_href(); $contact_link = contact_link(); $header_html = $page->get_all_html_headers(); diff --git a/themes/material/layout.class.php b/themes/material/layout.class.php index 4c923456..ada06030 100644 --- a/themes/material/layout.class.php +++ b/themes/material/layout.class.php @@ -11,10 +11,10 @@ class Layout { global $config; - $theme_name = $config->get_string('theme', 'material'); - $site_name = $config->get_string('title'); + $theme_name = $config->get_string(SetupConfig::THEME, 'material'); + $site_name = $config->get_string(SetupConfig::TITLE); $data_href = get_base_href(); - $main_page = $config->get_string('main_page'); + $main_page = $config->get_string(SetupConfig::MAIN_PAGE); $contact_link = contact_link(); $site_link = make_link(); $header_html = $page->get_all_html_headers(); diff --git a/themes/warm/layout.class.php b/themes/warm/layout.class.php index 20259570..1d3017fb 100644 --- a/themes/warm/layout.class.php +++ b/themes/warm/layout.class.php @@ -11,10 +11,10 @@ class Layout { global $config; - //$theme_name = $config->get_string('theme', 'default'); - $site_name = $config->get_string('title'); + //$theme_name = $config->get_string(SetupConfig::THEME, 'default'); + $site_name = $config->get_string(SetupConfig::TITLE); $data_href = get_base_href(); - $main_page = $config->get_string('main_page'); + $main_page = $config->get_string(SetupConfig::MAIN_PAGE); $contact_link = contact_link(); $header_html = $page->get_all_html_headers();