allow differents types of pages to the tag database

This commit is contained in:
Diego Najar 2019-03-07 21:27:34 +01:00
parent 1295d219ab
commit 185ae09393
2 changed files with 13 additions and 11 deletions

View File

@ -92,6 +92,9 @@ define('SESSION_GC_MAXLIFETIME', 3600);
// The value 0 means until the browser is closed
define('SESSION_COOKIE_LIFE_TIME', 0);
// Tags, type of pages included in the tag database
define('DB_TAGS_TYPES', array('published','static','sticky'));
// Alert notification dissappear in X seconds
$GLOBALS['ALERT_DISSAPEAR_IN'] = 3; // Seconds
@ -100,4 +103,3 @@ $GLOBALS['MEDIA_MANAGER_NUMBER_OF_FILES'] = 5;
// Sort the image by date
$GLOBALS['MEDIA_MANAGER_SORT_BY_DATE'] = true;

View File

@ -15,18 +15,18 @@ class Tags extends dbList {
public function reindex()
{
global $pages;
// Get a database with published pages
$db = $pages->getDB(false);
$db = $pages->getDB($onlyKeys=false);
$tagsIndex = array();
foreach ($db as $pageKey=>$pageFields) {
$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);
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);
}
}
}
}