2015-08-29 07:02:09 +02:00
|
|
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
|
|
|
2018-08-03 18:59:23 +02:00
|
|
|
class Tags 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
|
|
|
}
|
|
|
|
|
2018-08-04 12:44:37 +02:00
|
|
|
function numberOfPages($key)
|
2015-12-31 19:47:34 +01:00
|
|
|
{
|
2018-08-04 12:44:37 +02:00
|
|
|
return $this->countItems($key);
|
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
|
|
|
{
|
2018-08-03 18:59:23 +02:00
|
|
|
global $pages;
|
2019-03-07 21:27:34 +01:00
|
|
|
$db = $pages->getDB($onlyKeys=false);
|
2015-08-29 07:02:09 +02:00
|
|
|
$tagsIndex = array();
|
2019-02-19 08:38:17 +01:00
|
|
|
foreach ($db as $pageKey=>$pageFields) {
|
2019-03-07 21:27:34 +01:00
|
|
|
if (in_array($pageFields['type'], DB_TAGS_TYPES)) {
|
|
|
|
$tags = $pageFields['tags'];
|
|
|
|
foreach ($tags as $tagKey=>$tagName) {
|
|
|
|
if (isset($tagsIndex[$tagKey])) {
|
|
|
|
array_push($tagsIndex[$tagKey]['list'], $pageKey);
|
|
|
|
} else {
|
|
|
|
$tagsIndex[$tagKey]['name'] = $tagName;
|
|
|
|
$tagsIndex[$tagKey]['list'] = array($pageKey);
|
|
|
|
}
|
2015-08-29 07:02:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-12 20:18:44 +02:00
|
|
|
$this->db = $tagsIndex;
|
2019-02-28 19:55:06 +01:00
|
|
|
$this->sortAlphanumeric();
|
2017-05-12 20:18:44 +02:00
|
|
|
return $this->save();
|
2015-08-29 07:02:09 +02:00
|
|
|
}
|
|
|
|
|
2016-02-26 15:42:28 +01:00
|
|
|
}
|