blob: 955bb35b81461dd3e5023f456dbaa4865f061486 (
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
<?php
#===============================================================================
# Get instances
#===============================================================================
$Database = Application::getDatabase();
$Language = Application::getLanguage();
#===============================================================================
# TRY: Page\Exception
#===============================================================================
try {
if(Application::get('PAGE.SLUG_URLS')) {
$Page = Page\Factory::buildBySlug($param);
}
else {
$Page = Page\Factory::build($param);
}
$User = User\Factory::build($Page->attr('user'));
$page_data = generateItemTemplateData($Page);
$user_data = generateItemTemplateData($User);
#===============================================================================
# Add page data for previous and next page
#===============================================================================
try {
$PrevPage = Page\Factory::build($Page->getPrevID());
$page_data['PREV'] = generateItemTemplateData($PrevPage);
} catch(Page\Exception $Exception){}
try {
$NextPage = Page\Factory::build($Page->getNextID());
$page_data['NEXT'] = generateItemTemplateData($NextPage);
} catch(Page\Exception $Exception){}
#===============================================================================
# Build document
#===============================================================================
$PageTemplate = Template\Factory::build('page/main');
$PageTemplate->set('PAGE', $page_data);
$PageTemplate->set('USER', $user_data);
$MainTemplate = Template\Factory::build('main');
$MainTemplate->set('HTML', $PageTemplate);
$MainTemplate->set('HEAD', [
'NAME' => $page_data['ATTR']['NAME'],
'DESC' => description($page_data['BODY']['HTML'](), Application::get('PAGE.DESCRIPTION_SIZE')),
'PERM' => $page_data['URL'],
'OG_IMAGES' => $page_data['FILE']['LIST']
]);
# Get access to the current item data from main template
$MainTemplate->set('TYPE', 'PAGE');
$MainTemplate->set('PAGE', $page_data);
$MainTemplate->set('USER', $user_data);
echo $MainTemplate;
}
#===============================================================================
# CATCH: Page\Exception
#===============================================================================
catch(Page\Exception $Exception) {
try {
if(Application::get('PAGE.SLUG_URLS') === FALSE) {
$Page = Page\Factory::buildBySlug($param);
} else {
$Page = Page\Factory::build($param);
}
HTTP::redirect($Page->getURL());
}
catch(Page\Exception $Exception) {
Application::error404();
}
}
|