blob: dfa2a36412d49b40397797eef6a91a7c42dff41a (
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
|
<?php
#===============================================================================
# Get instances
#===============================================================================
$Database = Application::getDatabase();
$Language = Application::getLanguage();
$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){}
}
#===============================================================================
# Build document
#===============================================================================
$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;
|