[core] named constant for nice urls

This commit is contained in:
Shish 2024-02-14 12:35:58 +00:00
parent 937cef38db
commit 4e362d816f
6 changed files with 9 additions and 8 deletions

View file

@ -405,7 +405,7 @@ class Image implements \ArrayAccess
$image_link = make_link($image_link); $image_link = make_link($image_link);
} }
$chosen = $image_link; $chosen = $image_link;
} elseif ($config->get_bool('nice_urls', false)) { } elseif ($config->get_bool(SetupConfig::NICE_URLS, false)) {
$chosen = make_link($nice); $chosen = make_link($nice);
} else { } else {
$chosen = make_link($plain); $chosen = make_link($plain);

View file

@ -33,7 +33,7 @@ class UrlsTest extends TestCase
global $config; global $config;
foreach([true, false] as $nice_urls) { foreach([true, false] as $nice_urls) {
$config->set_bool('nice_urls', $nice_urls); $config->set_bool(SetupConfig::NICE_URLS, $nice_urls);
$this->assertEquals( $this->assertEquals(
["bar", "foo"], ["bar", "foo"],
@ -55,7 +55,7 @@ class UrlsTest extends TestCase
{ {
global $config; global $config;
foreach([true, false] as $nice_urls) { foreach([true, false] as $nice_urls) {
$config->set_bool('nice_urls', $nice_urls); $config->set_bool(SetupConfig::NICE_URLS, $nice_urls);
// basic // basic
$this->assertEquals( $this->assertEquals(
@ -94,7 +94,7 @@ class UrlsTest extends TestCase
{ {
global $config; global $config;
foreach([true, false] as $nice_urls) { foreach([true, false] as $nice_urls) {
$config->set_bool('nice_urls', $nice_urls); $config->set_bool(SetupConfig::NICE_URLS, $nice_urls);
$this->assertEquals( $this->assertEquals(
$nice_urls ? "/test/post/list/bar%20foo/1" : "/test/index.php?q=post/list/bar%20foo/1", $nice_urls ? "/test/post/list/bar%20foo/1" : "/test/index.php?q=post/list/bar%20foo/1",
@ -267,7 +267,7 @@ class UrlsTest extends TestCase
public function tearDown(): void public function tearDown(): void
{ {
global $config; global $config;
$config->set_bool('nice_urls', true); $config->set_bool(SetupConfig::NICE_URLS, true);
parent::tearDown(); parent::tearDown();
} }
} }

View file

@ -55,7 +55,7 @@ function make_link(?string $page = null, ?string $query = null, ?string $fragmen
$parts = []; $parts = [];
$install_dir = get_base_href(); $install_dir = get_base_href();
if (SPEED_HAX || $config->get_bool('nice_urls', false)) { if (SPEED_HAX || $config->get_bool(SetupConfig::NICE_URLS, false)) {
$parts['path'] = "$install_dir/$page"; $parts['path'] = "$install_dir/$page";
} else { } else {
$parts['path'] = "$install_dir/index.php"; $parts['path'] = "$install_dir/index.php";

View file

@ -12,4 +12,5 @@ class SetupConfig
public const THEME = "theme"; public const THEME = "theme";
public const WORD_WRAP = "word_wrap"; public const WORD_WRAP = "word_wrap";
public const COMMENT_CAPTCHA = "comment_captcha"; public const COMMENT_CAPTCHA = "comment_captcha";
public const NICE_URLS = "nice_urls";
} }

View file

@ -369,7 +369,7 @@ class Setup extends Extension
$sb->add_text_option("contact_link", "<br>Contact URL: "); $sb->add_text_option("contact_link", "<br>Contact URL: ");
$sb->add_choice_option(SetupConfig::THEME, $themes, "<br>Theme: "); $sb->add_choice_option(SetupConfig::THEME, $themes, "<br>Theme: ");
//$sb->add_multichoice_option("testarray", array("a" => "b", "c" => "d"), "<br>Test Array: "); //$sb->add_multichoice_option("testarray", array("a" => "b", "c" => "d"), "<br>Test Array: ");
$sb->add_bool_option("nice_urls", "<br>Nice URLs: "); $sb->add_bool_option(SetupConfig::NICE_URLS, "<br>Nice URLs: ");
$sb->add_label("<span id='nicetest'>(Javascript inactive, can't test!)</span>"); $sb->add_label("<span id='nicetest'>(Javascript inactive, can't test!)</span>");
$sb = $event->panel->create_new_block("Remote API Integration"); $sb = $event->panel->create_new_block("Remote API Integration");

View file

@ -161,7 +161,7 @@ class UploadTheme extends Themelet
$title = $config->get_string(SetupConfig::TITLE); $title = $config->get_string(SetupConfig::TITLE);
$max_size = $config->get_int(UploadConfig::SIZE); $max_size = $config->get_int(UploadConfig::SIZE);
$max_kb = to_shorthand_int($max_size); $max_kb = to_shorthand_int($max_size);
$delimiter = $config->get_bool('nice_urls') ? '?' : '&amp;'; $delimiter = $config->get_bool(SetupConfig::NICE_URLS) ? '?' : '&amp;';
$js = 'javascript:( $js = 'javascript:(
function() { function() {