🗃️ add an author database for pages
This commit is contained in:
parent
2326bdf770
commit
6b8420b10e
3 changed files with 49 additions and 0 deletions
37
bl-kernel/authors.class.php
Normal file
37
bl-kernel/authors.class.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php defined('KOBLOG') or die('Koblog CMS.');
|
||||
|
||||
class Authors extends dbList {
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct(DB_AUTHORS);
|
||||
}
|
||||
|
||||
function numberOfPages($key)
|
||||
{
|
||||
return $this->countItems($key);
|
||||
}
|
||||
|
||||
public function reindex()
|
||||
{
|
||||
global $pages;
|
||||
$db = $pages->getDB($onlyKeys=false);
|
||||
$authorsIndex = array();
|
||||
foreach ($db as $pageKey=>$pageFields) {
|
||||
if (in_array($pageFields['type'], $GLOBALS['DB_TAGS_TYPES'])) {
|
||||
$authorName = $pageFields['username'];
|
||||
if (isset($authorsIndex[$authorName])) {
|
||||
array_push($authorsIndex[$authorName]['list'], $pageKey);
|
||||
} else {
|
||||
$authorsIndex[$authorName]['name'] = $authorName;
|
||||
$authorsIndex[$authorName]['list'] = array($pageKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->db = $authorsIndex;
|
||||
$this->sortAlphanumeric();
|
||||
return $this->save();
|
||||
}
|
||||
|
||||
}
|
|
@ -16,6 +16,14 @@ function reindexTags()
|
|||
return $tags->reindex();
|
||||
}
|
||||
|
||||
// Re-index database of authors
|
||||
// If you create/edit/remove a page is necessary regenerate the database of authors
|
||||
function reindexAuthors()
|
||||
{
|
||||
global $authors;
|
||||
return $authors->reindex();
|
||||
}
|
||||
|
||||
// Generate the page 404 Not found
|
||||
function buildErrorPage()
|
||||
{
|
||||
|
@ -341,6 +349,7 @@ function createPage($args)
|
|||
|
||||
reindexCategories();
|
||||
reindexTags();
|
||||
reindexAuthors();
|
||||
|
||||
// Add to syslog
|
||||
$syslog->add(array(
|
||||
|
@ -392,6 +401,7 @@ function editPage($args)
|
|||
|
||||
reindexCategories();
|
||||
reindexTags();
|
||||
reindexAuthors();
|
||||
|
||||
// Add to syslog
|
||||
$syslog->add(array(
|
||||
|
@ -417,6 +427,7 @@ function deletePage($key)
|
|||
|
||||
reindexCategories();
|
||||
reindexTags();
|
||||
reindexAuthors();
|
||||
|
||||
// Add to syslog
|
||||
$syslog->add(array(
|
||||
|
|
|
@ -154,6 +154,7 @@ EOF;
|
|||
Theme::plugins('afterPageCreate');
|
||||
reindexCategories();
|
||||
reindexTags();
|
||||
reindexAuthors();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue