diff options
author | Thomas Lange <code@nerdmind.de> | 2017-03-10 21:46:12 +0100 |
---|---|---|
committer | Thomas Lange <code@nerdmind.de> | 2017-03-10 21:46:12 +0100 |
commit | e33c245d910e55b8cab407a03e669470509a705d (patch) | |
tree | e958504564ab47e72e0d3dcfe0b967440007b1d9 /system | |
parent | aae885b9784466ab412e4010893808867e93c213 (diff) | |
download | blog-e33c245d910e55b8cab407a03e669470509a705d.tar.gz blog-e33c245d910e55b8cab407a03e669470509a705d.tar.xz blog-e33c245d910e55b8cab407a03e669470509a705d.zip |
Several changes have been made in this commit, which together with the previous commits result in version 1.1:v1.1
+ The rules for the Apache and nginx configuration have been changed and redirects now all requests to the index.php.
+ A router class has been added which now handles all requests that arrives at the application on the index.php.
+ Short-hand functions "PAGE", "POST" and "USER" for use in templates added to get specific item data by ID.
+ More language variables have been added to the core language.
Diffstat (limited to 'system')
-rw-r--r-- | system/feed/main.php | 11 | ||||
-rw-r--r-- | system/home.php | 55 | ||||
-rw-r--r-- | system/page/list.php | 5 | ||||
-rw-r--r-- | system/page/main.php | 13 | ||||
-rw-r--r-- | system/post/list.php | 5 | ||||
-rw-r--r-- | system/post/main.php | 13 | ||||
-rw-r--r-- | system/search/main.php | 6 | ||||
-rw-r--r-- | system/user/list.php | 5 | ||||
-rw-r--r-- | system/user/main.php | 13 |
9 files changed, 95 insertions, 31 deletions
diff --git a/system/feed/main.php b/system/feed/main.php index 00ac4b8..ffb9b3a 100644 --- a/system/feed/main.php +++ b/system/feed/main.php @@ -1,8 +1,9 @@ <?php #=============================================================================== -# INCLUDE: Main configuration +# Get instances #=============================================================================== -require_once '../../core/application.php'; +$Database = Application::getDatabase(); +$Language = Application::getLanguage(); #=============================================================================== # HEADER: Content-Type for XML document @@ -13,7 +14,7 @@ HTTP::responseHeader(HTTP::HEADER_CONTENT_TYPE, HTTP::CONTENT_TYPE_XML); # TRY: Template\Exception #=============================================================================== try { - if(HTTP::GET('item') !== 'page') { + if(!isset($param) OR $param !== 'page') { $execSQL = 'SELECT id FROM %s ORDER BY '.Application::get('POST.FEED_SORT').' LIMIT '.Application::get('POST.FEED_SIZE'); $postIDs = $Database->query(sprintf($execSQL, Post\Attribute::TABLE))->fetchAll($Database::FETCH_COLUMN); @@ -34,7 +35,7 @@ try { } } - if(HTTP::GET('item') !== 'post') { + if(!isset($param) OR $param !== 'post') { $execSQL = 'SELECT id FROM %s ORDER BY '.Application::get('PAGE.FEED_SORT').' LIMIT '.Application::get('PAGE.FEED_SIZE'); $pageIDs = $Database->query(sprintf($execSQL, Page\Attribute::TABLE))->fetchAll($Database::FETCH_COLUMN); @@ -57,7 +58,7 @@ try { $FeedTemplate = Template\Factory::build('feed/main'); $FeedTemplate->set('FEED', [ - 'TYPE' => HTTP::GET('item'), + 'TYPE' => $param ?? NULL, 'LIST' => [ 'POSTS' => $posts ?? [], 'PAGES' => $pages ?? [], diff --git a/system/home.php b/system/home.php new file mode 100644 index 0000000..3d20097 --- /dev/null +++ b/system/home.php @@ -0,0 +1,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(); +} +?>
\ No newline at end of file diff --git a/system/page/list.php b/system/page/list.php index 5d07d30..7c3956e 100644 --- a/system/page/list.php +++ b/system/page/list.php @@ -1,8 +1,9 @@ <?php #=============================================================================== -# INCLUDE: Main configuration +# Get instances #=============================================================================== -require_once '../../core/application.php'; +$Database = Application::getDatabase(); +$Language = Application::getLanguage(); $site_size = Application::get('PAGE.LIST_SIZE'); $site_sort = Application::get('PAGE.LIST_SORT'); diff --git a/system/page/main.php b/system/page/main.php index cf723d2..88652fd 100644 --- a/system/page/main.php +++ b/system/page/main.php @@ -1,19 +1,20 @@ <?php #=============================================================================== -# INCLUDE: Main configuration +# Get instances #=============================================================================== -require_once '../../core/application.php'; +$Database = Application::getDatabase(); +$Language = Application::getLanguage(); #=============================================================================== # TRY: Page\Exception, User\Exception #=============================================================================== try { if(Application::get('PAGE.SLUG_URLS')) { - $Page = Page\Factory::buildBySlug(HTTP::GET('param')); + $Page = Page\Factory::buildBySlug($param); } else { - $Page = Page\Factory::build(HTTP::GET('param')); + $Page = Page\Factory::build($param); } $User = User\Factory::build($Page->attr('user')); @@ -68,9 +69,9 @@ try { catch(Page\Exception $Exception) { try { if(Application::get('PAGE.SLUG_URLS') === FALSE) { - $Page = Page\Factory::buildBySlug(HTTP::GET('param')); + $Page = Page\Factory::buildBySlug($param); } else { - $Page = Page\Factory::build(HTTP::GET('param')); + $Page = Page\Factory::build($param); } HTTP::redirect($Page->getURL()); diff --git a/system/post/list.php b/system/post/list.php index a7d6ce7..7b0630c 100644 --- a/system/post/list.php +++ b/system/post/list.php @@ -1,8 +1,9 @@ <?php #=============================================================================== -# INCLUDE: Main configuration +# Get instances #=============================================================================== -require_once '../../core/application.php'; +$Database = Application::getDatabase(); +$Language = Application::getLanguage(); $site_size = Application::get('POST.LIST_SIZE'); $site_sort = Application::get('POST.LIST_SORT'); diff --git a/system/post/main.php b/system/post/main.php index b880bb7..8411d9a 100644 --- a/system/post/main.php +++ b/system/post/main.php @@ -1,19 +1,20 @@ <?php #=============================================================================== -# INCLUDE: Main configuration +# Get instances #=============================================================================== -require_once '../../core/application.php'; +$Database = Application::getDatabase(); +$Language = Application::getLanguage(); #=============================================================================== # TRY: Post\Exception, User\Exception #=============================================================================== try { if(Application::get('POST.SLUG_URLS')) { - $Post = Post\Factory::buildBySlug(HTTP::GET('param')); + $Post = Post\Factory::buildBySlug($param); } else { - $Post = Post\Factory::build(HTTP::GET('param')); + $Post = Post\Factory::build($param); } $User = User\Factory::build($Post->attr('user')); @@ -68,9 +69,9 @@ try { catch(Post\Exception $Exception) { try { if(Application::get('POST.SLUG_URLS') === FALSE) { - $Post = Post\Factory::buildBySlug(HTTP::GET('param')); + $Post = Post\Factory::buildBySlug($param); } else { - $Post = Post\Factory::build(HTTP::GET('param')); + $Post = Post\Factory::build($param); } HTTP::redirect($Post->getURL()); diff --git a/system/search/main.php b/system/search/main.php index fe18e7e..97fe8bb 100644 --- a/system/search/main.php +++ b/system/search/main.php @@ -1,8 +1,10 @@ <?php #=============================================================================== -# INCLUDE: Main configuration +# Get instances #=============================================================================== -require_once '../../core/application.php'; +$Database = Application::getDatabase(); +$Language = Application::getLanguage(); + $SEARCH_SUCCESS = FALSE; $D_LIST = $Database->query(sprintf('SELECT DISTINCT DAY(time_insert) AS temp FROM %s ORDER BY temp', Post\Attribute::TABLE)); $M_LIST = $Database->query(sprintf('SELECT DISTINCT MONTH(time_insert) AS temp FROM %s ORDER BY temp', Post\Attribute::TABLE)); diff --git a/system/user/list.php b/system/user/list.php index 1f29473..b724fe8 100644 --- a/system/user/list.php +++ b/system/user/list.php @@ -1,8 +1,9 @@ <?php #=============================================================================== -# INCLUDE: Main configuration +# Get instances #=============================================================================== -require_once '../../core/application.php'; +$Database = Application::getDatabase(); +$Language = Application::getLanguage(); $site_size = Application::get('USER.LIST_SIZE'); $site_sort = Application::get('USER.LIST_SORT'); diff --git a/system/user/main.php b/system/user/main.php index 79f4222..7dcd6da 100644 --- a/system/user/main.php +++ b/system/user/main.php @@ -1,19 +1,20 @@ <?php #=============================================================================== -# INCLUDE: Main configuration +# Get instances #=============================================================================== -require_once '../../core/application.php'; +$Database = Application::getDatabase(); +$Language = Application::getLanguage(); #=============================================================================== # TRY: User\Exception #=============================================================================== try { if(Application::get('USER.SLUG_URLS')) { - $User = User\Factory::buildBySlug(HTTP::GET('param')); + $User = User\Factory::buildBySlug($param); } else { - $User = User\Factory::build(HTTP::GET('param')); + $User = User\Factory::build($param); } $user_data = generateUserItemData($User); @@ -83,9 +84,9 @@ try { catch(User\Exception $Exception) { try { if(Application::get('USER.SLUG_URLS') === FALSE) { - $User = User\Factory::buildBySlug(HTTP::GET('param')); + $User = User\Factory::buildBySlug($param); } else { - $User = User\Factory::build(HTTP::GET('param')); + $User = User\Factory::build($param); } HTTP::redirect($User->getURL()); |