2017-03-21 08:45:58 +01:00
|
|
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
|
|
|
2017-05-12 20:18:44 +02:00
|
|
|
class dbCategories extends dbList
|
2017-03-21 08:45:58 +01:00
|
|
|
{
|
|
|
|
function __construct()
|
|
|
|
{
|
2017-05-12 20:18:44 +02:00
|
|
|
parent::__construct(DB_CATEGORIES);
|
2017-03-21 08:45:58 +01:00
|
|
|
}
|
|
|
|
|
2017-05-12 20:18:44 +02:00
|
|
|
function countPagesByCategory($key)
|
2017-03-21 08:45:58 +01:00
|
|
|
{
|
2017-05-12 20:18:44 +02:00
|
|
|
return $this->countItems($key);
|
2017-03-21 08:45:58 +01:00
|
|
|
}
|
|
|
|
|
2017-05-12 20:18:44 +02:00
|
|
|
public function reindex()
|
2017-03-26 20:51:32 +02:00
|
|
|
{
|
2017-05-12 20:18:44 +02:00
|
|
|
global $dbPages;
|
2017-04-17 12:49:03 +02:00
|
|
|
|
2017-05-12 20:18:44 +02:00
|
|
|
// Foreach category
|
2017-12-26 17:45:02 +01:00
|
|
|
foreach ($this->db as $key=>$value) {
|
2017-05-12 20:18:44 +02:00
|
|
|
$this->db[$key]['list'] = array();
|
2017-04-26 18:56:10 +02:00
|
|
|
}
|
2017-03-26 20:51:32 +02:00
|
|
|
|
2017-06-23 00:41:00 +02:00
|
|
|
// Get a database with published pages
|
2017-12-26 17:45:02 +01:00
|
|
|
$db = $dbPages->getPublishedDB(false);
|
2017-06-23 00:41:00 +02:00
|
|
|
|
2017-12-26 17:45:02 +01:00
|
|
|
foreach ($db as $pageKey=>$pageFields) {
|
|
|
|
if (!empty($pageFields['category'])) {
|
2017-05-12 20:18:44 +02:00
|
|
|
$categoryKey = $pageFields['category'];
|
2017-12-26 17:45:02 +01:00
|
|
|
if (isset($this->db[$categoryKey]['list'])) {
|
2017-05-12 20:18:44 +02:00
|
|
|
array_push($this->db[$categoryKey]['list'], $pageKey);
|
2017-04-26 18:56:10 +02:00
|
|
|
}
|
2017-04-17 13:23:43 +02:00
|
|
|
}
|
2017-03-26 20:51:32 +02:00
|
|
|
}
|
|
|
|
|
2017-04-17 12:49:03 +02:00
|
|
|
return $this->save();
|
|
|
|
}
|
2017-03-21 08:45:58 +01:00
|
|
|
}
|