koblog/bl-kernel/authors.class.php

37 lines
822 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 (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();
}
}