koblog/bl-kernel/authors.class.php

38 lines
894 B
PHP
Raw Normal View History

<?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 ($pageFields['type'] == "article" && $pageFields['state'] == "published") {
$authorName = $pageFields['username'];
if (isset($authorsIndex[$authorName])) {
array_push($authorsIndex[$authorName]['list'], $pageKey);
} else {
$user = new User($pageFields['username']);
$authorsIndex[$authorName]['name'] = $user->displayName();
$authorsIndex[$authorName]['list'] = array($pageKey);
}
}
}
$this->db = $authorsIndex;
$this->sortAlphanumeric();
return $this->save();
}
}