From 9323fe2f5a42238e32af7f89c8f5fd5516ecc9b3 Mon Sep 17 00:00:00 2001 From: dignajar Date: Fri, 8 Jan 2016 17:12:17 -0300 Subject: [PATCH] Blog Filter URI added --- index.php | 1 + kernel/admin/themes/default/init.php | 5 +++-- kernel/admin/views/settings-advanced.php | 8 ++++++++ kernel/boot/admin.php | 2 +- kernel/boot/rules/70.posts.php | 8 ++++++-- kernel/boot/rules/{70.pages.php => 71.pages.php} | 11 +++++++---- kernel/boot/site.php | 2 +- kernel/dbsite.class.php | 8 ++++++++ kernel/url.class.php | 6 ++++++ languages/en_US.json | 6 +++++- themes/pure/index.php | 2 +- 11 files changed, 47 insertions(+), 12 deletions(-) rename kernel/boot/rules/{70.pages.php => 71.pages.php} (94%) diff --git a/index.php b/index.php index ed52b50e..4864db53 100644 --- a/index.php +++ b/index.php @@ -38,3 +38,4 @@ if($Url->whereAmI()==='admin') { else { require(PATH_BOOT.'site.php'); } + diff --git a/kernel/admin/themes/default/init.php b/kernel/admin/themes/default/init.php index f2fc324f..f131cc83 100644 --- a/kernel/admin/themes/default/init.php +++ b/kernel/admin/themes/default/init.php @@ -130,6 +130,7 @@ class HTML { public static function bluditQuickImages() { + global $L; $html = ''; $html .= ' @@ -153,7 +154,7 @@ if(empty($thumbnailList)) { } $html .= ' -More images +'.$L->g('More images').' '; @@ -327,7 +328,7 @@ if(empty($thumbnailList)) { $html .= ' diff --git a/kernel/admin/views/settings-advanced.php b/kernel/admin/views/settings-advanced.php index edf5fcdd..334db0f3 100644 --- a/kernel/admin/views/settings-advanced.php +++ b/kernel/admin/views/settings-advanced.php @@ -84,6 +84,14 @@ HTML::formOpen(array('class'=>'uk-form-horizontal')); 'tip'=>'' )); + HTML::formInputText(array( + 'name'=>'uriBlog', + 'label'=>$L->g('Blog'), + 'value'=>$Site->uriFilters('blog'), + 'class'=>'uk-width-1-2 uk-form-medium', + 'tip'=>'' + )); + echo '
diff --git a/kernel/boot/admin.php b/kernel/boot/admin.php index 42a7e988..fcc39779 100644 --- a/kernel/boot/admin.php +++ b/kernel/boot/admin.php @@ -42,7 +42,7 @@ else // Boot rules include(PATH_RULES.'60.plugins.php'); include(PATH_RULES.'70.posts.php'); - include(PATH_RULES.'70.pages.php'); + include(PATH_RULES.'71.pages.php'); include(PATH_RULES.'99.header.php'); include(PATH_RULES.'99.paginator.php'); include(PATH_RULES.'99.themes.php'); diff --git a/kernel/boot/rules/70.posts.php b/kernel/boot/rules/70.posts.php index 65eb7c25..e118f999 100644 --- a/kernel/boot/rules/70.posts.php +++ b/kernel/boot/rules/70.posts.php @@ -4,6 +4,8 @@ // Variables // ============================================================================ +// Array with all posts specified by a filter. +// Filter by page number, by tag, etc. $posts = array(); // ============================================================================ @@ -138,11 +140,13 @@ if( ($Url->whereAmI()==='post') && ($Url->notFound()===false) ) { $Post = buildPost( $Url->slug() ); + // The post doesn't exist. if($Post===false) { $Url->setNotFound(true); unset($Post); } + // The post is not published yet. elseif( !$Post->published() ) { $Url->setNotFound(true); @@ -166,8 +170,8 @@ else if($Url->whereAmI()==='admin') { $posts = buildPostsForPage($Url->pageNumber(), POSTS_PER_PAGE_ADMIN, false); } - // Posts for homepage - else { + // Posts for home and blog filter. + elseif( ( ($Url->whereAmI()==='home') || ($Url->whereAmI()==='blog') ) && ($Url->notFound()===false) ) { $posts = buildPostsForPage($Url->pageNumber(), $Site->postsPerPage(), true); } } diff --git a/kernel/boot/rules/70.pages.php b/kernel/boot/rules/71.pages.php similarity index 94% rename from kernel/boot/rules/70.pages.php rename to kernel/boot/rules/71.pages.php index 0a1bce7e..06d0c2bf 100644 --- a/kernel/boot/rules/70.pages.php +++ b/kernel/boot/rules/71.pages.php @@ -145,16 +145,18 @@ if( $Site->cliMode() ) { $dbPages->regenerateCli(); } -// Filter by page, then build it +// Build specific page. if( ($Url->whereAmI()==='page') && ($Url->notFound()===false) ) { $Page = buildPage( $Url->slug() ); + // The page doesn't exist. if($Page===false) { $Url->setNotFound(true); unset($Page); } + // The page is not published yet. elseif( !$Page->published() ) { $Url->setNotFound(true); @@ -162,10 +164,11 @@ if( ($Url->whereAmI()==='page') && ($Url->notFound()===false) ) } } -// Default homepage -if($Url->notFound()===false) +// Homepage +if( ($Url->whereAmI()==='home') && ($Url->notFound()===false) ) { - if( Text::isNotEmpty($Site->homepage()) && ($Url->whereAmI()==='home') ) + // The user defined as homepage a particular page. + if( Text::isNotEmpty( $Site->homepage() ) ) { $Url->setWhereAmI('page'); diff --git a/kernel/boot/site.php b/kernel/boot/site.php index 3fc79a89..08ee1316 100644 --- a/kernel/boot/site.php +++ b/kernel/boot/site.php @@ -8,7 +8,7 @@ Theme::plugins('beforeRulesLoad'); // Load rules include(PATH_RULES.'70.posts.php'); -include(PATH_RULES.'70.pages.php'); +include(PATH_RULES.'71.pages.php'); include(PATH_RULES.'99.header.php'); include(PATH_RULES.'99.paginator.php'); include(PATH_RULES.'99.themes.php'); diff --git a/kernel/dbsite.class.php b/kernel/dbsite.class.php index 41ef8d1f..25e29a3b 100644 --- a/kernel/dbsite.class.php +++ b/kernel/dbsite.class.php @@ -17,6 +17,7 @@ class dbSite extends dbJSON 'uriPage'=> array('inFile'=>false, 'value'=>'/'), 'uriPost'=> array('inFile'=>false, 'value'=>'/post/'), 'uriTag'=> array('inFile'=>false, 'value'=>'/tag/'), + 'uriBlog'=> array('inFile'=>false, 'value'=>'/blog/'), 'url'=> array('inFile'=>false, 'value'=>''), 'cliMode'=> array('inFile'=>false, 'value'=>true), 'emailFrom'=> array('inFile'=>false, 'value'=>''), @@ -67,6 +68,7 @@ class dbSite extends dbJSON $filters['post'] = $this->getField('uriPost'); $filters['page'] = $this->getField('uriPage'); $filters['tag'] = $this->getField('uriTag'); + $filters['blog'] = $this->getField('uriBlog'); if(empty($filter)) { return $filters; @@ -93,6 +95,12 @@ class dbSite extends dbJSON return $this->url().ltrim($filter, '/'); } + public function urlBlog() + { + $filter = $this->getField('uriBlog'); + return $this->url().ltrim($filter, '/'); + } + // Returns the site title. public function title() { diff --git a/kernel/url.class.php b/kernel/url.class.php index e62661f5..fc4428bd 100644 --- a/kernel/url.class.php +++ b/kernel/url.class.php @@ -67,6 +67,12 @@ class Url break; } + if($filterURI===$filters['blog']) + { + $this->whereAmI = 'blog'; + break; + } + if($filterURI===$adminFilter['admin']) { $this->whereAmI = 'admin'; diff --git a/languages/en_US.json b/languages/en_US.json index 15d8fe72..3be721da 100644 --- a/languages/en_US.json +++ b/languages/en_US.json @@ -220,5 +220,9 @@ "activate": "Activate", "deactivate": "Deactivate", - "cover-image": "Cover image" + "cover-image": "Cover image", + "blog": "Blog", + "more-images": "More images", + "double-click-on-the-image-to-add-it": "Double click on the image to add it.", + "click-here-to-cancel": "Click here to cancel." } \ No newline at end of file diff --git a/themes/pure/index.php b/themes/pure/index.php index 6a16a9b7..d831a5be 100644 --- a/themes/pure/index.php +++ b/themes/pure/index.php @@ -24,7 +24,7 @@ whereAmI()=='home') || ($Url->whereAmI()=='tag') ) + if( ($Url->whereAmI()=='home') || ($Url->whereAmI()=='tag') || ($Url->whereAmI()=='blog') ) { include(PATH_THEME_PHP.'home.php'); }