(pages): allow to show pages by author

This commit is contained in:
Kazhnuz 2025-01-19 11:22:30 +01:00
parent 6b8420b10e
commit 79ff2bc74d
4 changed files with 27 additions and 1 deletions

View file

@ -66,6 +66,7 @@ define('DB_PAGES', PATH_DATABASES . 'pages.php');
define('DB_SITE', PATH_DATABASES . 'site.php');
define('DB_CATEGORIES', PATH_DATABASES . 'categories.php');
define('DB_TAGS', PATH_DATABASES . 'tags.php');
define('DB_AUTHORS', PATH_DATABASES . 'authors.php');
define('DB_SYSLOG', PATH_DATABASES . 'syslog.php');
define('DB_USERS', PATH_DATABASES . 'users.php');
define('DB_SECURITY', PATH_DATABASES . 'security.php');
@ -88,6 +89,7 @@ include(PATH_ABSTRACT . 'plugin.class.php');
include(PATH_KERNEL . 'pages.class.php');
include(PATH_KERNEL . 'users.class.php');
include(PATH_KERNEL . 'tags.class.php');
include(PATH_KERNEL . 'authors.class.php');
include(PATH_KERNEL . 'language.class.php');
include(PATH_KERNEL . 'site.class.php');
include(PATH_KERNEL . 'categories.class.php');
@ -126,6 +128,7 @@ include(PATH_HELPERS . 'cookie.class.php');
$pages = new Pages();
$users = new Users();
$tags = new Tags();
$authors = new Authors();
$categories = new Categories();
$site = new Site();
$url = new Url();
@ -191,6 +194,9 @@ define('TAG_URI_FILTER', $url->filters('tag'));
// Category URI filter
define('CATEGORY_URI_FILTER', $url->filters('category'));
// Author URI filter
define('AUTHOR_URI_FILTER', $url->filters('author'));
// Page URI filter
define('PAGE_URI_FILTER', $url->filters('page'));
@ -247,6 +253,7 @@ define('DOMAIN_ADMIN', DOMAIN_BASE . ADMIN_URI_FILTER . '/');
define('DOMAIN_TAGS', Text::addSlashes(DOMAIN_BASE . TAG_URI_FILTER, false, true));
define('DOMAIN_CATEGORIES', Text::addSlashes(DOMAIN_BASE . CATEGORY_URI_FILTER, false, true));
define('DOMAIN_PAGES', Text::addSlashes(DOMAIN_BASE . PAGE_URI_FILTER, false, true));
define('DOMAIN_AUTHORS', Text::addSlashes(DOMAIN_BASE . AUTHOR_URI_FILTER, false, true));
$ADMIN_CONTROLLER = '';
$ADMIN_VIEW = '';

View file

@ -71,6 +71,10 @@ elseif ($url->whereAmI()==='tag') {
elseif ($url->whereAmI()==='category') {
$content = buildPagesByCategory();
}
// Build content by author
elseif ($url->whereAmI()==='author') {
$content = buildPagesByAuthor();
}
// Build content for the homepage
elseif ( ($url->whereAmI()==='home') || ($url->whereAmI()==='blog') ) {
$content = buildPagesForHome();

View file

@ -92,16 +92,26 @@ function buildPagesByTag()
return buildPagesFor('tag', false, $tagKey);
}
// This function is only used from the rule 69.pages.php, DO NOT use this function!
function buildPagesByAuthor()
{
global $url;
$authorKey = $url->slug();
return buildPagesFor('author', false, false, $authorKey);
}
// This function is only used from the rule 69.pages.php, DO NOT use this function!
// Generate the global variables $content / $content, defined on 69.pages.php
// This function is use for buildPagesForHome(), buildPagesByCategory(), buildPagesByTag()
function buildPagesFor($for, $categoryKey = false, $tagKey = false)
function buildPagesFor($for, $categoryKey = false, $tagKey = false, $authorKey = false)
{
global $pages;
global $categories;
global $tags;
global $site;
global $url;
global $authors;
// Get the page number from URL
$pageNumber = $url->pageNumber();
@ -122,6 +132,9 @@ function buildPagesFor($for, $categoryKey = false, $tagKey = false)
} elseif ($for == 'tag') {
$numberOfItems = $site->itemsPerPage();
$list = $tags->getList($tagKey, $pageNumber, $numberOfItems);
} elseif ($for == 'author') {
$numberOfItems = $site->itemsPerPage();
$list = $authors->getList($authorKey, $pageNumber, $numberOfItems);
}
// There are not items, invalid tag, invalid category, out of range, etc...

View file

@ -19,6 +19,7 @@ class Site extends dbJSON
'uriTag' => '/tag/',
'uriCategory' => '/category/',
'uriBlog' => '/blog/',
'uriAuthor' => '/author/',
'url' => '',
'emailFrom' => '',
'dateFormat' => 'F j, Y',
@ -99,6 +100,7 @@ class Site extends dbJSON
$filters['page'] = $this->getField('uriPage');
$filters['tag'] = $this->getField('uriTag');
$filters['category'] = $this->getField('uriCategory');
$filters['author'] = $this->getField('uriAuthor');
if ($this->getField('uriBlog')) {
$filters['blog'] = $this->getField('uriBlog');