summaryrefslogtreecommitdiff
path: root/templates/themes/public_banlist/theme.php
blob: f2b658392a393cc7d9e10c9e26aa780b0ad98683 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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, true, true, array());
			$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'],
				))
		        ));
		}
	};
	
?>