Browse Source

Define excluded boards as array to simplify code

pull/40/head
discomrade 3 years ago
parent
commit
0f02110b1c
  1. 6
      templates/themes/catalog/theme.php
  2. 6
      templates/themes/overboards/overboards.php
  3. 6
      templates/themes/overboards/theme.php

6
templates/themes/catalog/theme.php

@ -34,8 +34,7 @@
} }
if(isset($settings['has_overboard']) && $settings['has_overboard']) { if(isset($settings['has_overboard']) && $settings['has_overboard']) {
foreach ($overboards_config as &$overboard) { foreach ($overboards_config as &$overboard) {
$exclusions = explode(' ', $overboard['exclude']); $included_boards = array_diff(listBoards(true), $overboard['exclude']);
$included_boards = array_diff(listBoards(true), $exclusions);
$action = generation_strategy("sb_catalog", array($overboard)); $action = generation_strategy("sb_catalog", array($overboard));
if ($action == 'delete') { if ($action == 'delete') {
file_unlink($config['dir']['home'] . $overboard . '/catalog.html'); file_unlink($config['dir']['home'] . $overboard . '/catalog.html');
@ -61,8 +60,7 @@
if(isset($settings['has_overboard']) && $settings['has_overboard']) { if(isset($settings['has_overboard']) && $settings['has_overboard']) {
foreach ($overboards_config as &$overboard) { foreach ($overboards_config as &$overboard) {
if ($overboard['uri'] == $board) { if ($overboard['uri'] == $board) {
$exclusions = explode(' ', $overboard['exclude']); $included_boards = array_diff(listBoards(true), $overboard['exclude']);
$included_boards = array_diff(listBoards(true), $exclusions);
$b->buildOverboardCatalog($board, $settings, $included_boards); $b->buildOverboardCatalog($board, $settings, $included_boards);
} }
} }

6
templates/themes/overboards/overboards.php

@ -2,7 +2,7 @@
/* /*
* When adding a new board, rebuild this theme. If necessary, reconfigure the catalog theme. * When adding a new board, rebuild this theme. If necessary, reconfigure the catalog theme.
* Exclude list is space-separated (e.g. 'exclude' => 'b games music' ) * Exclude list is a PHP array e.g. 'exclude' => array('b', 'games', 'music')
*/ */
$thread_limit = 30; $thread_limit = 30;
@ -12,14 +12,14 @@
'title' => 'Overboard', 'title' => 'Overboard',
'uri' => 'overboard', 'uri' => 'overboard',
'subtitle' => '30 most recently bumped threads', 'subtitle' => '30 most recently bumped threads',
'exclude' => '', 'exclude' => array(),
'thread_limit' => $thread_limit, 'thread_limit' => $thread_limit,
), ),
array( array(
'title' => 'SFW Overboard', 'title' => 'SFW Overboard',
'uri' => 'sfwoverboard', 'uri' => 'sfwoverboard',
'subtitle' => '30 most recently bumped threads from work-safe boards', 'subtitle' => '30 most recently bumped threads from work-safe boards',
'exclude' => 'b', 'exclude' => array('b'),
'thread_limit' => $thread_limit, 'thread_limit' => $thread_limit,
), ),
); );

6
templates/themes/overboards/theme.php

@ -39,8 +39,8 @@
*/ */
class overboards { class overboards {
private $settings; private $settings;
//TODO review if appropriate uses of pass by ref (&$)
function __construct(&$settings) { function __construct($settings) {
$this->settings = $this->parseSettings($settings); $this->settings = $this->parseSettings($settings);
} }
@ -54,7 +54,6 @@
error('Invalid configuration parameters.', true); error('Invalid configuration parameters.', true);
} }
$overboard['exclude'] = explode(' ', $overboard['exclude']);
$overboard['thread_limit'] = intval($overboard['thread_limit']); $overboard['thread_limit'] = intval($overboard['thread_limit']);
if ($overboard['thread_limit'] < 1) if ($overboard['thread_limit'] < 1)
@ -230,3 +229,4 @@
} }
} }

Loading…
Cancel
Save