summaryrefslogtreecommitdiff
path: root/templates/themes/rand
diff options
context:
space:
mode:
authorAppleman1234 <applemansigloo@gmail.com>2022-09-25 13:30:13 +1000
committerAppleman1234 <applemansigloo@gmail.com>2022-09-25 13:30:13 +1000
commit2c69095a1edf7474073451285238659d0f62ce3f (patch)
tree5dee476605402c66dc2853d0836b29f6aedae62b /templates/themes/rand
parente9a61e2fbbd930eaa80d6a5f33420cedc59d748c (diff)
PHP8.1 fixes from Rector
Diffstat (limited to 'templates/themes/rand')
-rw-r--r--templates/themes/rand/info.php40
-rw-r--r--templates/themes/rand/theme.php28
2 files changed, 15 insertions, 53 deletions
diff --git a/templates/themes/rand/info.php b/templates/themes/rand/info.php
index c226e2e4..833c0c78 100644
--- a/templates/themes/rand/info.php
+++ b/templates/themes/rand/info.php
@@ -1,5 +1,5 @@
<?php
- $theme = array();
+ $theme = [];
// Theme name
$theme['name'] = 'Random Overboard';
@@ -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' => 'Random'
- );
- $theme['config'][] = array(
- 'title' => 'Board URI',
- 'name' => 'uri',
- 'type' => 'text',
- 'default' => '.',
- 'comment' => '(rand 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' => 'Random'];
+ $theme['config'][] = ['title' => 'Board URI', 'name' => 'uri', 'type' => 'text', 'default' => '.', 'comment' => '(rand 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'] = 'rand_build';
$theme['install_callback'] = 'rand_install';
diff --git a/templates/themes/rand/theme.php b/templates/themes/rand/theme.php
index e3814c4e..14a78b59 100644
--- a/templates/themes/rand/theme.php
+++ b/templates/themes/rand/theme.php
@@ -6,7 +6,7 @@
$rand->settings = $settings;
file_write($settings['uri'] . '/index.html', $rand->build());
- file_write($settings['uri'] . '/rand.js', Element('themes/rand/rand.js', array()));
+ file_write($settings['uri'] . '/rand.js', Element('themes/rand/rand.js', []));
}
class rand {
@@ -16,17 +16,12 @@
$boards = listBoards();
$body = '';
- $overflow = array();
- $board = array(
- 'dir' => $this->settings['uri'] . "/",
- 'url' => $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'], 'name' => $this->settings['title'], 'title' => sprintf($this->settings['subtitle'], $this->settings['thread_limit'])];
$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']);
}
@@ -34,7 +29,7 @@
$query = query($query) or error(db_error());
$count = 0;
- $threads = array();
+ $threads = [];
while($post = $query->fetch()) {
if(!isset($threads[$post['board']])) {
@@ -81,23 +76,16 @@
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'].'/rand.js"></script>';
- return Element('index.html', array(
- 'config' => $config,
- 'board' => $board,
- 'no_post_form' => true,
- 'body' => $body,
- 'mod' => $mod,
- 'boardlist' => createBoardlist($mod),
- ));
+ return Element('index.html', ['config' => $config, 'board' => $board, 'no_post_form' => true, 'body' => $body, 'mod' => $mod, 'boardlist' => createBoardlist($mod)]);
}
};