bludit/bl-kernel/categories.class.php

43 lines
869 B
PHP
Raw Normal View History

2017-03-21 08:45:58 +01:00
<?php defined('BLUDIT') or die('Bludit CMS.');
2018-08-03 18:59:23 +02:00
class Categories 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
}
2018-08-04 12:44:37 +02:00
function numberOfPages($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
{
2018-08-03 18:59:23 +02:00
global $pages;
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
// Get pages database
$db = $pages->getDB(false);
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'])) {
if (
($db[$pageKey]['type']=='published') ||
($db[$pageKey]['type']=='sticky') ||
($db[$pageKey]['type']=='static')
) {
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
}