summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/application.php3
-rw-r--r--core/include/page/list.php12
-rw-r--r--core/include/post/list.php12
-rw-r--r--core/include/user/list.php12
4 files changed, 36 insertions, 3 deletions
diff --git a/core/application.php b/core/application.php
index 3b1eba7..7e4f731 100644
--- a/core/application.php
+++ b/core/application.php
@@ -72,6 +72,9 @@ $configuration = [
'PAGE.DESCRIPTION_SIZE' => 200,
'POST.DESCRIPTION_SIZE' => 200,
'USER.DESCRIPTION_SIZE' => 200,
+ 'PAGE.SINGLE_REDIRECT' => FALSE,
+ 'POST.SINGLE_REDIRECT' => FALSE,
+ 'USER.SINGLE_REDIRECT' => FALSE,
'PAGE.LIST_SORT' => 'time_insert DESC',
'POST.LIST_SORT' => 'time_insert DESC',
'USER.LIST_SORT' => 'time_insert DESC',
diff --git a/core/include/page/list.php b/core/include/page/list.php
index f80c461..022478e 100644
--- a/core/include/page/list.php
+++ b/core/include/page/list.php
@@ -11,7 +11,8 @@ $Language = Application::getLanguage();
$site_size = Application::get('PAGE.LIST_SIZE');
$site_sort = Application::get('PAGE.LIST_SORT');
-$lastSite = ceil($Database->query(sprintf('SELECT COUNT(id) FROM %s', Page\Attribute::TABLE))->fetchColumn() / $site_size);
+$count = $Database->query(sprintf('SELECT COUNT(id) FROM %s', Page\Attribute::TABLE))->fetchColumn();
+$lastSite = ceil($count / $site_size);
$currentSite = HTTP::GET('site') ?? 1;
$currentSite = intval($currentSite);
@@ -21,6 +22,15 @@ if($currentSite < 1 OR ($currentSite > $lastSite AND $lastSite > 0)) {
}
#===============================================================================
+# Single redirect
+#===============================================================================
+if(Application::get('PAGE.SINGLE_REDIRECT') === TRUE AND $count === '1') {
+ $Statement = $Database->query(sprintf('SELECT id FROM %s LIMIT 1', Page\Attribute::TABLE));
+ $Page = Page\Factory::build($Statement->fetchColumn());
+ HTTP::redirect($Page->getURL());
+}
+
+#===============================================================================
# TRY: Template\Exception
#===============================================================================
try {
diff --git a/core/include/post/list.php b/core/include/post/list.php
index 4b8ea28..3ba2dba 100644
--- a/core/include/post/list.php
+++ b/core/include/post/list.php
@@ -11,7 +11,8 @@ $Language = Application::getLanguage();
$site_size = Application::get('POST.LIST_SIZE');
$site_sort = Application::get('POST.LIST_SORT');
-$lastSite = ceil($Database->query(sprintf('SELECT COUNT(id) FROM %s', Post\Attribute::TABLE))->fetchColumn() / $site_size);
+$count = $Database->query(sprintf('SELECT COUNT(id) FROM %s', Post\Attribute::TABLE))->fetchColumn();
+$lastSite = ceil($count / $site_size);
$currentSite = HTTP::GET('site') ?? 1;
$currentSite = intval($currentSite);
@@ -21,6 +22,15 @@ if($currentSite < 1 OR ($currentSite > $lastSite AND $lastSite > 0)) {
}
#===============================================================================
+# Single redirect
+#===============================================================================
+if(Application::get('POST.SINGLE_REDIRECT') === TRUE AND $count === '1') {
+ $Statement = $Database->query(sprintf('SELECT id FROM %s LIMIT 1', Post\Attribute::TABLE));
+ $Post = Post\Factory::build($Statement->fetchColumn());
+ HTTP::redirect($Post->getURL());
+}
+
+#===============================================================================
# TRY: Template\Exception
#===============================================================================
try {
diff --git a/core/include/user/list.php b/core/include/user/list.php
index 6009164..4ce9fc8 100644
--- a/core/include/user/list.php
+++ b/core/include/user/list.php
@@ -11,7 +11,8 @@ $Language = Application::getLanguage();
$site_size = Application::get('USER.LIST_SIZE');
$site_sort = Application::get('USER.LIST_SORT');
-$lastSite = ceil($Database->query(sprintf('SELECT COUNT(id) FROM %s', User\Attribute::TABLE))->fetchColumn() / $site_size);
+$count = $Database->query(sprintf('SELECT COUNT(id) FROM %s', User\Attribute::TABLE))->fetchColumn();
+$lastSite = ceil($count / $site_size);
$currentSite = HTTP::GET('site') ?? 1;
$currentSite = intval($currentSite);
@@ -21,6 +22,15 @@ if($currentSite < 1 OR ($currentSite > $lastSite AND $lastSite > 0)) {
}
#===============================================================================
+# Single redirect
+#===============================================================================
+if(Application::get('USER.SINGLE_REDIRECT') === TRUE AND $count === '1') {
+ $Statement = $Database->query(sprintf('SELECT id FROM %s LIMIT 1', User\Attribute::TABLE));
+ $User = User\Factory::build($Statement->fetchColumn());
+ HTTP::redirect($User->getURL());
+}
+
+#===============================================================================
# TRY: Template\Exception
#===============================================================================
try {