forked from leftypol/leftypol
new banlist implementation; also includes a public banlist
This commit is contained in:
parent
906764a62f
commit
9b3fa77719
10 changed files with 424 additions and 156 deletions
33
templates/themes/public_banlist/info.php
Normal file
33
templates/themes/public_banlist/info.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
$theme = Array();
|
||||
|
||||
// Theme name
|
||||
$theme['name'] = 'Public Banlist';
|
||||
// Description (you can use Tinyboard markup here)
|
||||
$theme['description'] =
|
||||
'Shows a public list of bans, that were issued on all boards. Basically, this theme
|
||||
copies the banlist interface from moderation panel.';
|
||||
$theme['version'] = 'v0.1';
|
||||
|
||||
// Theme configuration
|
||||
$theme['config'] = Array();
|
||||
|
||||
$theme['config'][] = Array(
|
||||
'title' => 'JSON feed file',
|
||||
'name' => 'file_json',
|
||||
'type' => 'text',
|
||||
'default' => 'bans.json',
|
||||
'comment' => '(eg. "bans.json")'
|
||||
);
|
||||
|
||||
$theme['config'][] = Array(
|
||||
'title' => 'Main HTML file',
|
||||
'name' => 'file_bans',
|
||||
'type' => 'text',
|
||||
'default' => 'bans.html',
|
||||
'comment' => '(eg. "bans.html")'
|
||||
);
|
||||
|
||||
// Unique function name for building everything
|
||||
$theme['build_function'] = 'pbanlist_build';
|
||||
?>
|
56
templates/themes/public_banlist/theme.php
Normal file
56
templates/themes/public_banlist/theme.php
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
require 'info.php';
|
||||
|
||||
function pbanlist_build($action, $settings, $board) {
|
||||
// Possible values for $action:
|
||||
// - all (rebuild everything, initialization)
|
||||
// - news (news has been updated)
|
||||
// - boards (board list changed)
|
||||
// - bans (ban list changed)
|
||||
|
||||
PBanlist::build($action, $settings);
|
||||
}
|
||||
|
||||
// Wrap functions in a class so they don't interfere with normal Tinyboard operations
|
||||
class PBanlist {
|
||||
public static function build($action, $settings) {
|
||||
global $config;
|
||||
|
||||
if ($action == 'all')
|
||||
file_write($config['dir']['home'] . $settings['file_bans'], PBanlist::homepage($settings));
|
||||
|
||||
if ($action == 'all' || $action == 'bans')
|
||||
file_write($config['dir']['home'] . $settings['file_json'], PBanlist::gen_json($settings));
|
||||
}
|
||||
|
||||
public static function gen_json($settings) {
|
||||
ob_start();
|
||||
Bans::stream_json(false, false, !hasPermission($config['mod']['view_banstaff']), $mod['boards']);
|
||||
$out = ob_get_contents();
|
||||
ob_end_clean();
|
||||
return $out;
|
||||
}
|
||||
|
||||
// Build homepage
|
||||
public static function homepage($settings) {
|
||||
global $config;
|
||||
|
||||
return Element('page.html', array(
|
||||
'config' => $config,
|
||||
'mod' => false,
|
||||
'hide_dashboard_link' => true,
|
||||
'title' => _("Ban list"),
|
||||
'subtitle' => "",
|
||||
'nojavascript' => true,
|
||||
'body' => Element('mod/ban_list.html', array(
|
||||
'mod' => false,
|
||||
'boards' => "[]",
|
||||
'token' => false,
|
||||
'token_json' => false,
|
||||
'uri_json' => $config['dir']['home'] . $settings['file_json'],
|
||||
))
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
?>
|
|
@ -4,7 +4,11 @@
|
|||
function ukko_build($action, $settings) {
|
||||
$ukko = new ukko();
|
||||
$ukko->settings = $settings;
|
||||
|
||||
|
||||
if (! ($action == 'all' || $action == 'post' || $action == 'post-thread' || $action == 'post-delete')) {
|
||||
return;
|
||||
}
|
||||
|
||||
file_write($settings['uri'] . '/index.html', $ukko->build());
|
||||
file_write($settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', array()));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue