bludit/bl-kernel/tags.class.php

39 lines
824 B
PHP
Raw Permalink Normal View History

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;
$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-05-29 19:28:11 +02:00
if (in_array($pageFields['type'], $GLOBALS['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;
$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
}