From e33c245d910e55b8cab407a03e669470509a705d Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Fri, 10 Mar 2017 21:46:12 +0100 Subject: Several changes have been made in this commit, which together with the previous commits result in version 1.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. --- system/feed/main.php | 11 +++++----- system/home.php | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ system/page/list.php | 5 +++-- system/page/main.php | 13 ++++++------ system/post/list.php | 5 +++-- system/post/main.php | 13 ++++++------ system/search/main.php | 6 ++++-- system/user/list.php | 5 +++-- system/user/main.php | 13 ++++++------ 9 files changed, 95 insertions(+), 31 deletions(-) create mode 100644 system/home.php (limited to 'system') 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 @@ 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 @@ +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 @@ 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 @@ 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 @@ 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 @@ getURL()); -- cgit v1.2.3