2025-01-19 10:54:16 +01:00
|
|
|
<?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) {
|
2025-01-25 13:11:42 +01:00
|
|
|
if ($pageFields['type'] == "article" && $pageFields['state'] == "published") {
|
2025-01-19 10:54:16 +01:00
|
|
|
$authorName = $pageFields['username'];
|
|
|
|
if (isset($authorsIndex[$authorName])) {
|
|
|
|
array_push($authorsIndex[$authorName]['list'], $pageKey);
|
|
|
|
} else {
|
2025-01-21 21:49:52 +01:00
|
|
|
$user = new User($pageFields['username']);
|
|
|
|
$authorsIndex[$authorName]['name'] = $user->displayName();
|
2025-01-19 10:54:16 +01:00
|
|
|
$authorsIndex[$authorName]['list'] = array($pageKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->db = $authorsIndex;
|
|
|
|
$this->sortAlphanumeric();
|
|
|
|
return $this->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|