diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php index f7fc78aa..ff6fe20e 100644 --- a/bl-kernel/boot/init.php +++ b/bl-kernel/boot/init.php @@ -87,6 +87,8 @@ include(PATH_KERNEL.'dbsite.class.php'); include(PATH_KERNEL.'dbcategories.class.php'); include(PATH_KERNEL.'dbsyslog.class.php'); include(PATH_KERNEL.'page.class.php'); +include(PATH_KERNEL.'category.class.php'); +include(PATH_KERNEL.'tag.class.php'); include(PATH_KERNEL.'user.class.php'); include(PATH_KERNEL.'url.class.php'); include(PATH_KERNEL.'login.class.php'); diff --git a/bl-kernel/category.class.php b/bl-kernel/category.class.php new file mode 100644 index 00000000..87dca557 --- /dev/null +++ b/bl-kernel/category.class.php @@ -0,0 +1,56 @@ +db[$key])) { + $this->vars['name'] = $dbCategories->db[$key]['name']; + $this->vars['key'] = $key; + $this->vars['permalink'] = DOMAIN_CATEGORIES . $key; + $this->vars['list'] = $dbCategories->db[$key]['list']; + } + else { + $this->vars = false; + } + } + + // Returns TRUE if the category is valid/exists, FALSE otherwise + public function isValid() + { + return $this->vars!==false; + } + + 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 category + public function pages() + { + return $this->getValue('list'); + } +} \ No newline at end of file diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php index 4ba40d42..3d07b8ed 100644 --- a/bl-kernel/functions.php +++ b/bl-kernel/functions.php @@ -705,6 +705,41 @@ function deleteCategory($categoryKey) { return true; } +// Returns an array with all the categories +// By default, the database of categories is alphanumeric sorted +function getCategories() { + global $dbCategories; + + $list = array(); + foreach ($dbCategories->db as $key=>$fields) { + $category = new Category($key); + array_push($list, $category); + } + return $list; +} + +// Returns the object category if the category exists, FALSE otherwise +function getCategory($key) { + $category = new Category($key); + if (!$category->isValid()) { + return false; + } + return $category; +} + +// Returns an array with all the tags +// By default, the database of tags is alphanumeric sorted +function getTags() { + global $dbTags; + + $list = array(); + foreach ($dbTags->db as $key=>$fields) { + $tag = new Tag($key); + array_push($list, $tag); + } + return $list; +} + function activateTheme($themeDirectory) { global $Site; global $Syslog; diff --git a/bl-kernel/tag.class.php b/bl-kernel/tag.class.php new file mode 100644 index 00000000..4a9a9526 --- /dev/null +++ b/bl-kernel/tag.class.php @@ -0,0 +1,56 @@ +db[$key])) { + $this->vars['name'] = $dbTags->db[$key]['name']; + $this->vars['key'] = $key; + $this->vars['permalink'] = DOMAIN_TAGS . $key; + $this->vars['list'] = $dbTags->db[$key]['list']; + } + else { + $this->vars = false; + } + } + + // Returns TRUE if the tag is valid/exists, FALSE otherwise + public function isValid() + { + return $this->vars!==false; + } + + 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'); + } +} \ No newline at end of file