bludit/bl-kernel/tags.class.php

41 lines
760 B
PHP
Raw 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;
2015-08-30 01:26:46 +02:00
2017-06-23 00:41:00 +02:00
// Get a database with published pages
2018-08-03 18:59:23 +02:00
$db = $pages->getPublishedDB(false);
2017-06-23 00:41:00 +02:00
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
}