2015-08-29 07:02:09 +02:00
|
|
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
|
|
|
2017-05-12 20:18:44 +02:00
|
|
|
class dbTags extends dbList
|
2015-08-29 07:02:09 +02:00
|
|
|
{
|
|
|
|
function __construct()
|
|
|
|
{
|
2017-05-12 20:18:44 +02:00
|
|
|
parent::__construct(DB_TAGS);
|
2015-08-29 07:02:09 +02:00
|
|
|
}
|
|
|
|
|
2017-05-12 20:18:44 +02:00
|
|
|
function countPagesByTag($tagKey)
|
2015-12-31 19:47:34 +01:00
|
|
|
{
|
2017-05-12 20:18:44 +02:00
|
|
|
return $this->countItems($tagKey);
|
2015-12-31 19:47:34 +01:00
|
|
|
}
|
|
|
|
|
2017-05-12 20:18:44 +02:00
|
|
|
public function reindex()
|
2015-08-30 01:26:46 +02:00
|
|
|
{
|
2017-05-12 20:18:44 +02:00
|
|
|
global $dbPages;
|
2015-08-30 01:26:46 +02:00
|
|
|
|
2017-05-12 20:18:44 +02:00
|
|
|
$db = $dbPages->getDB();
|
2015-08-29 07:02:09 +02:00
|
|
|
$tagsIndex = array();
|
|
|
|
|
2017-05-12 20:18:44 +02:00
|
|
|
foreach($db as $pageKey=>$pageFields) {
|
|
|
|
$tags = $pageFields['tags'];
|
|
|
|
foreach($tags as $tagKey=>$tagName) {
|
2015-09-18 05:24:10 +02:00
|
|
|
if( isset($tagsIndex[$tagKey]) ) {
|
2017-05-12 20:18:44 +02:00
|
|
|
array_push($tagsIndex[$tagKey]['list'], $pageKey);
|
2015-09-18 05:24:10 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$tagsIndex[$tagKey]['name'] = $tagName;
|
2017-05-12 20:18:44 +02:00
|
|
|
$tagsIndex[$tagKey]['list'] = array($pageKey);
|
2015-08-29 07:02:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-12 20:18:44 +02:00
|
|
|
$this->db = $tagsIndex;
|
|
|
|
return $this->save();
|
2015-08-29 07:02:09 +02:00
|
|
|
}
|
|
|
|
|
2016-02-26 15:42:28 +01:00
|
|
|
}
|