bludit/bl-kernel/dbcategories.class.php

37 lines
732 B
PHP
Raw Normal View History

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-04-26 18:56:10 +02: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-04-26 18:56:10 +02:00
// Foreach post in the database
2017-05-12 20:18:44 +02:00
$db = $dbPages->getDB();
foreach($db as $pageKey=>$pageFields) {
if( !empty($pageFields['category']) ) {
$categoryKey = $pageFields['category'];
if( isset($this->db[$categoryKey]['list']) ) {
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
}