bludit/bl-kernel/tag.class.php

50 lines
976 B
PHP
Raw Normal View History

2017-12-18 23:49:53 +01:00
<?php defined('BLUDIT') or die('Bludit CMS.');
class Tag {
protected $vars;
2017-12-18 23:49:53 +01:00
function __construct($key)
{
2018-08-02 22:33:53 +02:00
global $tags;
if (isset($tags->db[$key])) {
$this->vars['name'] = $tags->db[$key]['name'];
2017-12-18 23:49:53 +01:00
$this->vars['key'] = $key;
$this->vars['permalink'] = DOMAIN_TAGS . $key;
2018-08-02 22:33:53 +02:00
$this->vars['list'] = $tags->db[$key]['list'];
2018-08-02 17:06:53 +02:00
} else {
2018-08-19 15:03:36 +02:00
$errorMessage = 'Tag not found in database by key ['.$key.']';
2018-08-02 17:06:53 +02:00
Log::set(__METHOD__.LOG_SEP.$errorMessage);
throw new Exception($errorMessage);
2017-12-18 23:49:53 +01:00
}
}
public function getValue($field)
{
if (isset($this->vars[$field])) {
return $this->vars[$field];
}
return false;
}
public function key()
{
return $this->getValue('key');
}
public function name()
{
return $this->getValue('name');
}
public function permalink()
{
return $this->getValue('permalink');
}
// Returns an array with the keys of pages linked to the tag
public function pages()
{
return $this->getValue('list');
}
}