summaryrefslogtreecommitdiff
path: root/templates/themes/basic/theme.php
blob: 603176cbb107aac05272354a13c1b8da6bc4d8e6 (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
<?php
	require 'info.php';
	
	function basic_build($action, $settings) {
		// Possible values for $action:
		//	- all (rebuild everything, initialization)
		//	- news (news has been updated)
		//	- boards (board list changed)
		
		Basic::build($action, $settings);
	}
	
	// Wrap functions in a class so they don't interfere with normal Tinyboard operations
	class Basic {
		public static function build($action, $settings) {
			global $config;
			
			if($action == 'all' || $action == 'news')
				file_write($config['dir']['home'] . $settings['file'], Basic::homepage($settings));
		}
		
		// Build news page
		public static function homepage($settings) {
			global $config;
			
			$settings['no_recent'] = (int) $settings['no_recent'];
			
			$query = query("SELECT * FROM `news` ORDER BY `time` DESC" . ($settings['no_recent'] ? ' LIMIT ' . $settings['no_recent'] : '')) or error(db_error());
			$news = $query->fetchAll(PDO::FETCH_ASSOC);
			
			return Element('themes/basic/index.html', Array(
					'settings' => $settings,
					'config' => $config,
					'boardlist' => createBoardlist(),
					'news' => $news
				));
			
			return $body;
		}
	};
	
?>