aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2017-10-22 21:04:02 +0200
committerThomas Lange <code@nerdmind.de>2017-10-22 21:04:02 +0200
commitb886b447c939db888aee84224995da58540b4503 (patch)
tree6738b1c7979eaa049a247d749a881944777326b8 /admin
parentc73c6acbf280c99fd4178577cc99a55a6e2e11cf (diff)
downloadblog-b886b447c939db888aee84224995da58540b4503.tar.gz
blog-b886b447c939db888aee84224995da58540b4503.tar.xz
blog-b886b447c939db888aee84224995da58540b4503.zip
Implemented: A full-text search functionality for posts and pages in the administration area. In addition, some markup within the "/*/index.php" files of the admin template was re-formatted.
Diffstat (limited to 'admin')
-rw-r--r--admin/page/search.php52
-rw-r--r--admin/post/search.php52
2 files changed, 104 insertions, 0 deletions
diff --git a/admin/page/search.php b/admin/page/search.php
new file mode 100644
index 0000000..c718caa
--- /dev/null
+++ b/admin/page/search.php
@@ -0,0 +1,52 @@
+<?php
+#===============================================================================
+# DEFINE: Administration
+#===============================================================================
+define('ADMINISTRATION', TRUE);
+define('AUTHENTICATION', TRUE);
+
+#===============================================================================
+# INCLUDE: Main configuration
+#===============================================================================
+require '../../core/application.php';
+
+#===============================================================================
+# IF: Handle search request
+#===============================================================================
+if($search = HTTP::GET('q')) {
+ if($pageIDs = Page\Item::getSearchResultIDs($search, $Database)) {
+ foreach($pageIDs as $pageID) {
+ try {
+ $Page = Page\Factory::build($pageID);
+ $User = User\Factory::build($Page->attr('user'));
+
+ $pages[] = generatePageItemTemplate($Page, $User);
+ }
+ catch(Page\Exception $Exception){}
+ catch(User\Exception $Exception){}
+ }
+ }
+}
+
+#===============================================================================
+# TRY: Template\Exception
+#===============================================================================
+try {
+ $SearchTemplate = Template\Factory::build('page/search');
+ $SearchTemplate->set('QUERY', $search);
+ $SearchTemplate->set('PAGES', $pages ?? []);
+
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('NAME', $Language->text('title_page_search'));
+ $MainTemplate->set('HTML', $SearchTemplate);
+
+ echo $MainTemplate;
+}
+
+#===============================================================================
+# CATCH: Template\Exception
+#===============================================================================
+catch(Template\Exception $Exception) {
+ Application::exit($Exception->getMessage());
+}
+?> \ No newline at end of file
diff --git a/admin/post/search.php b/admin/post/search.php
new file mode 100644
index 0000000..3369be2
--- /dev/null
+++ b/admin/post/search.php
@@ -0,0 +1,52 @@
+<?php
+#===============================================================================
+# DEFINE: Administration
+#===============================================================================
+define('ADMINISTRATION', TRUE);
+define('AUTHENTICATION', TRUE);
+
+#===============================================================================
+# INCLUDE: Main configuration
+#===============================================================================
+require '../../core/application.php';
+
+#===============================================================================
+# IF: Handle search request
+#===============================================================================
+if($search = HTTP::GET('q')) {
+ if($postIDs = Post\Item::getSearchResultIDs($search, [NULL, NULL, NULL], $Database)) {
+ foreach($postIDs as $postID) {
+ try {
+ $Post = Post\Factory::build($postID);
+ $User = User\Factory::build($Post->attr('user'));
+
+ $posts[] = generatePostItemTemplate($Post, $User);
+ }
+ catch(Post\Exception $Exception){}
+ catch(User\Exception $Exception){}
+ }
+ }
+}
+
+#===============================================================================
+# TRY: Template\Exception
+#===============================================================================
+try {
+ $SearchTemplate = Template\Factory::build('post/search');
+ $SearchTemplate->set('QUERY', $search);
+ $SearchTemplate->set('POSTS', $posts ?? []);
+
+ $MainTemplate = Template\Factory::build('main');
+ $MainTemplate->set('NAME', $Language->text('title_post_search'));
+ $MainTemplate->set('HTML', $SearchTemplate);
+
+ echo $MainTemplate;
+}
+
+#===============================================================================
+# CATCH: Template\Exception
+#===============================================================================
+catch(Template\Exception $Exception) {
+ Application::exit($Exception->getMessage());
+}
+?> \ No newline at end of file