blob: 3d20097d43ce93c05f47e46dc91d9d6fec7451cf (
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
|
<?php
#===============================================================================
# Get instances
#===============================================================================
$Database = Application::getDatabase();
$Language = Application::getLanguage();
#===============================================================================
# TRY: Template\Exception
#===============================================================================
try {
$execSQL = 'SELECT id FROM %s ORDER BY '.Application::get('POST.LIST_SORT').' LIMIT '.Application::get('POST.LIST_SIZE');
$Statement = $Database->query(sprintf($execSQL, Post\Attribute::TABLE));
$postIDs = $Statement->fetchAll($Database::FETCH_COLUMN);
foreach($postIDs as $postID) {
try {
$Post = Post\Factory::build($postID);
$User = User\Factory::build($Post->attr('user'));
$ItemTemplate = generatePostItemTemplate($Post, $User);
$posts[] = $ItemTemplate;
}
catch(Post\Exception $Exception){}
catch(User\Exception $Exception){}
}
$HomeTemplate = Template\Factory::build('home');
$HomeTemplate->set('PAGINATION', [
'HTML' => generatePostNaviTemplate(1)
]);
$HomeTemplate->set('LIST', [
'POSTS' => $posts ?? []
]);
$MainTemplate = Template\Factory::build('main');
$MainTemplate->set('HTML', $HomeTemplate);
$MainTemplate->set('HEAD', [
'NAME' => Application::get('BLOGMETA.HOME'),
'DESC' => Application::get('BLOGMETA.NAME').' – '.Application::get('BLOGMETA.DESC'),
'PERM' => Application::getURL()
]);
echo $MainTemplate;
}
#===============================================================================
# CATCH: Template\Exception
#===============================================================================
catch(Template\Exception $Exception) {
$Exception->defaultHandler();
}
?>
|