diff options
| author | Appleman1234 <applemansigloo@gmail.com> | 2022-09-25 13:30:13 +1000 |
|---|---|---|
| committer | Appleman1234 <applemansigloo@gmail.com> | 2022-09-25 13:30:13 +1000 |
| commit | 2c69095a1edf7474073451285238659d0f62ce3f (patch) | |
| tree | 5dee476605402c66dc2853d0836b29f6aedae62b /templates/themes/ukko | |
| parent | e9a61e2fbbd930eaa80d6a5f33420cedc59d748c (diff) | |
PHP8.1 fixes from Rector
Diffstat (limited to 'templates/themes/ukko')
| -rw-r--r-- | templates/themes/ukko/info.php | 42 | ||||
| -rw-r--r-- | templates/themes/ukko/theme.php | 45 |
2 files changed, 24 insertions, 63 deletions
diff --git a/templates/themes/ukko/info.php b/templates/themes/ukko/info.php index 9a0a53e6..f9b27520 100644 --- a/templates/themes/ukko/info.php +++ b/templates/themes/ukko/info.php @@ -1,5 +1,5 @@ <?php - $theme = array(); + $theme = []; // Theme name $theme['name'] = 'Overboard (Ukko)'; @@ -8,39 +8,13 @@ $theme['version'] = 'v0.2'; // Theme configuration - $theme['config'] = array(); + $theme['config'] = []; - $theme['config'][] = array( - 'title' => 'Board name', - 'name' => 'title', - 'type' => 'text', - 'default' => 'Ukko' - ); - $theme['config'][] = array( - 'title' => 'Board URI', - 'name' => 'uri', - 'type' => 'text', - 'default' => '*', - 'comment' => '(ukko for example)' - ); - $theme['config'][] = array( - 'title' => 'Subtitle', - 'name' => 'subtitle', - 'type' => 'text', - 'comment' => '(%s = thread limit. for example "%s freshly bumped threads")' - ); - $theme['config'][] = array( - 'title' => 'Excluded boards', - 'name' => 'exclude', - 'type' => 'text', - 'comment' => '(space seperated)' - ); - $theme['config'][] = array( - 'title' => 'Number of threads', - 'name' => 'thread_limit', - 'type' => 'text', - 'default' => '15', - ); + $theme['config'][] = ['title' => 'Board name', 'name' => 'title', 'type' => 'text', 'default' => 'Ukko']; + $theme['config'][] = ['title' => 'Board URI', 'name' => 'uri', 'type' => 'text', 'default' => '*', 'comment' => '(ukko for example)']; + $theme['config'][] = ['title' => 'Subtitle', 'name' => 'subtitle', 'type' => 'text', 'comment' => '(%s = thread limit. for example "%s freshly bumped threads")']; + $theme['config'][] = ['title' => 'Excluded boards', 'name' => 'exclude', 'type' => 'text', 'comment' => '(space seperated)']; + $theme['config'][] = ['title' => 'Number of threads', 'name' => 'thread_limit', 'type' => 'text', 'default' => '15']; // Unique function name for building everything $theme['build_function'] = 'ukko_build'; $theme['install_callback'] = 'ukko_install'; @@ -49,7 +23,7 @@ function ukko_install($settings) { if (!file_exists($settings['uri'])) @mkdir($settings['uri'], 0777) or error("Couldn't create " . $settings['uri'] . ". Check permissions.", true); - file_write($settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', array())); + file_write($settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', [])); } } diff --git a/templates/themes/ukko/theme.php b/templates/themes/ukko/theme.php index d08b6769..4b729514 100644 --- a/templates/themes/ukko/theme.php +++ b/templates/themes/ukko/theme.php @@ -11,7 +11,7 @@ return; } - $action = generation_strategy('sb_ukko', array()); + $action = generation_strategy('sb_ukko', []); if ($action == 'delete') { file_unlink($settings['uri'] . '/index.html'); @@ -32,23 +32,18 @@ class ukko { public $settings; public function build($mod = false) { - global $config; + $apithreads = null; + global $config; $boards = listBoards(); $body = ''; - $overflow = array(); - $board = array( - 'dir' => $this->settings['uri'] . "/", - 'url' => $this->settings['uri'], - 'uri' => $this->settings['uri'], - 'name' => $this->settings['title'], - 'title' => sprintf($this->settings['subtitle'], $this->settings['thread_limit']) - ); + $overflow = []; + $board = ['dir' => $this->settings['uri'] . "/", 'url' => $this->settings['uri'], 'uri' => $this->settings['uri'], 'name' => $this->settings['title'], 'title' => sprintf($this->settings['subtitle'], $this->settings['thread_limit'])]; - $boardsforukko = array(); + $boardsforukko = []; $query = ''; foreach($boards as &$_board) { - if(in_array($_board['uri'], explode(' ', $this->settings['exclude']))) + if(in_array($_board['uri'], explode(' ', (string) $this->settings['exclude']))) continue; $query .= sprintf("SELECT *, '%s' AS `board` FROM ``posts_%s`` WHERE `thread` IS NULL UNION ALL ", $_board['uri'], $_board['uri']); array_push($boardsforukko,$_board); @@ -57,9 +52,9 @@ $query = query($query) or error(db_error()); $count = 0; - $threads = array(); + $threads = []; if ($config['api']['enabled']) { - $apithreads = array(); + $apithreads = []; } while($post = $query->fetch()) { @@ -110,13 +105,13 @@ if(floor($threads[$post['board']] / $config['threads_per_page']) > 0) { $page = floor($threads[$post['board']] / $config['threads_per_page']) + 1; } - $overflow[] = array('id' => $post['id'], 'board' => $post['board'], 'page' => $page . '.html'); + $overflow[] = ['id' => $post['id'], 'board' => $post['board'], 'page' => $page . '.html']; } $count += 1; } - $body .= '<script> var overflow = ' . json_encode($overflow) . '</script>'; + $body .= '<script> var overflow = ' . json_encode($overflow, JSON_THROW_ON_ERROR) . '</script>'; $body .= '<script type="text/javascript" src="/'.$this->settings['uri'].'/ukko.js"></script>'; // json api @@ -124,18 +119,18 @@ require_once __DIR__. '/../../../inc/api.php'; $api = new Api(); $jsonFilename = $board['dir'] . '0.json'; - $json = json_encode($api->translatePage($apithreads)); + $json = json_encode($api->translatePage($apithreads), JSON_THROW_ON_ERROR); file_write($jsonFilename, $json); - $catalog = array(); + $catalog = []; $catalog[0] = $apithreads; - $json = json_encode($api->translateCatalog($catalog)); + $json = json_encode($api->translateCatalog($catalog), JSON_THROW_ON_ERROR); $jsonFilename = $board['dir'] . 'catalog.json'; file_write($jsonFilename, $json); - $json = json_encode($api->translateCatalog($catalog, true)); + $json = json_encode($api->translateCatalog($catalog, true), JSON_THROW_ON_ERROR); $jsonFilename = $board['dir'] . 'threads.json'; file_write($jsonFilename, $json); } @@ -145,15 +140,7 @@ } $antibot->reset(); - return Element('index.html', array( - 'config' => $config, - 'board' => $board, - 'no_post_form' => $config['overboard_post_form'] ? false : true, - 'body' => $body, - 'mod' => $mod, - 'boardlist' => createBoardlist($mod), - 'boards' => $boardsforukko, - 'antibot' => $antibot ) + return Element('index.html', ['config' => $config, 'board' => $board, 'no_post_form' => $config['overboard_post_form'] ? false : true, 'body' => $body, 'mod' => $mod, 'boardlist' => createBoardlist($mod), 'boards' => $boardsforukko, 'antibot' => $antibot] ); } |
