diff --git a/bl-kernel/admin/views/edit-category.php b/bl-kernel/admin/views/edit-category.php
index 6a382ebf..7a5ea5b8 100644
--- a/bl-kernel/admin/views/edit-category.php
+++ b/bl-kernel/admin/views/edit-category.php
@@ -38,6 +38,16 @@ echo Bootstrap::formOpen(array('id'=>'jsform'));
'tip'=>''
));
+ echo Bootstrap::formTextareaBlock(array(
+ 'name'=>'description',
+ 'label'=>$L->g('Category description'),
+ 'value'=>isset($categoryMap['description'])?$categoryMap['description']:'',
+ 'class'=>'',
+ 'placeholder'=>'',
+ 'tip'=>'',
+ 'rows'=>3
+ ));
+
echo Bootstrap::formInputTextBlock(array(
'name'=>'template',
'label'=>$L->g('Category template'),
diff --git a/bl-kernel/admin/views/edit-content.php b/bl-kernel/admin/views/edit-content.php
index 71859665..2d943e05 100644
--- a/bl-kernel/admin/views/edit-content.php
+++ b/bl-kernel/admin/views/edit-content.php
@@ -177,7 +177,7 @@
// Parent
try {
$parentKey = $page->parent();
- $parent = new PageX($parentKey);
+ $parent = new Page($parentKey);
$parentOption = $parent->title();
} catch (Exception $e) {
$parentOption = '';
diff --git a/bl-kernel/category.class.php b/bl-kernel/category.class.php
index 2a09d95b..f8c8246d 100644
--- a/bl-kernel/category.class.php
+++ b/bl-kernel/category.class.php
@@ -7,23 +7,18 @@ class Category {
function __construct($key)
{
global $dbCategories;
-
if (isset($dbCategories->db[$key])) {
$this->vars['name'] = $dbCategories->db[$key]['name'];
$this->vars['template'] = $dbCategories->db[$key]['template'];
+ $this->vars['description'] = $dbCategories->db[$key]['description'];
$this->vars['key'] = $key;
$this->vars['permalink'] = DOMAIN_CATEGORIES . $key;
$this->vars['list'] = $dbCategories->db[$key]['list'];
+ } else {
+ $errorMessage = 'Category not found in database by key ['.$key.']';
+ Log::set(__METHOD__.LOG_SEP.$errorMessage);
+ throw new Exception($errorMessage);
}
- 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)
@@ -54,6 +49,11 @@ class Category {
return $this->getValue('template');
}
+ public function description()
+ {
+ return $this->getValue('description');
+ }
+
// Returns an array with the keys of pages linked to the category
public function pages()
{
diff --git a/bl-kernel/dbcategories.class.php b/bl-kernel/dbcategories.class.php
index dda63912..8cc9a41a 100644
--- a/bl-kernel/dbcategories.class.php
+++ b/bl-kernel/dbcategories.class.php
@@ -23,7 +23,6 @@ class dbCategories extends dbList
// Get a database with published pages
$db = $dbPages->getPublishedDB(false);
-
foreach ($db as $pageKey=>$pageFields) {
if (!empty($pageFields['category'])) {
$categoryKey = $pageFields['category'];
diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php
index 853ea88c..950d36c2 100644
--- a/bl-kernel/functions.php
+++ b/bl-kernel/functions.php
@@ -22,9 +22,9 @@ function buildErrorPage() {
try {
$pageNotFoundKey = $site->pageNotFound();
- $pageNotFound = New PageX($pageNotFoundKey);
+ $pageNotFound = New Page($pageNotFoundKey);
} catch (Exception $e) {
- $pageNotFound = New PageX(false);
+ $pageNotFound = New Page(false);
$pageNotFound->setField('title', $language->get('page-not-found'));
$pageNotFound->setField('content', $language->get('page-not-found-content'));
$pageNotFound->setField('username', 'admin');
@@ -41,7 +41,7 @@ function buildThePage() {
try {
$pageKey = $url->slug();
- $page = New PageX($pageKey);
+ $page = New Page($pageKey);
} catch (Exception $e) {
$url->setNotFound();
return false;
@@ -118,7 +118,7 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false) {
$content = array();
foreach ($list as $pageKey) {
try {
- $page = new PageX($pageKey);
+ $page = new Page($pageKey);
array_push($content, $page);
} catch (Exception $e) {
// continue
@@ -136,7 +136,7 @@ function buildStaticPages() {
$pagesKey = $dbPages->getStaticDB();
foreach ($pagesKey as $pageKey) {
try {
- $page = new PageX($pageKey);
+ $page = new Page($pageKey);
array_push($list, $page);
} catch (Exception $e) {
// continue
@@ -146,6 +146,16 @@ function buildStaticPages() {
return $list;
}
+// Returns the Page-Object if exists, FALSE otherwise
+function buildPage($pageKey) {
+ try {
+ $page = new Page($pageKey);
+ return $page;
+ } catch (Exception $e) {
+ return false;
+ }
+}
+
// Returns an array with all the parent pages as Page-Object
// The pages are order by the settings on the system
function buildParentPages() {
@@ -155,7 +165,7 @@ function buildParentPages() {
$pagesKey = $dbPages->getPublishedDB();
foreach ($pagesKey as $pageKey) {
try {
- $page = new PageX($pageKey);
+ $page = new Page($pageKey);
array_push($list, $page);
} catch (Exception $e) {
// continue
@@ -335,7 +345,7 @@ function editPage($args) {
// Title and content need to be here because from inside the dbPages is not visible
if (empty($args['title']) || empty($args['content'])) {
try {
- $page = new PageX($args['key']);
+ $page = new Page($args['key']);
if (empty($args['title'])) {
$args['title'] = $page->title();
}
@@ -750,11 +760,12 @@ function getCategories() {
// Returns the object category if the category exists, FALSE otherwise
function getCategory($key) {
- $category = new Category($key);
- if (!$category->isValid()) {
+ try {
+ $category = new Category($key);
+ return $category;
+ } catch (Exception $e) {
return false;
}
- return $category;
}
// Returns an array with all the tags
@@ -770,6 +781,16 @@ function getTags() {
return $list;
}
+// Returns the object tag if the tag exists, FALSE otherwise
+function getTag($key) {
+ try {
+ $tag = new Tag($key);
+ return $tag;
+ } catch (Exception $e) {
+ return false;
+ }
+}
+
function activateTheme($themeDirectory) {
global $site;
global $syslog;
diff --git a/bl-kernel/helpers/theme.class.php b/bl-kernel/helpers/theme.class.php
index 8fd7cbad..cc71ea77 100644
--- a/bl-kernel/helpers/theme.class.php
+++ b/bl-kernel/helpers/theme.class.php
@@ -75,18 +75,25 @@ class Theme {
$format = $site->titleFormatPages();
$format = Text::replace('{{page-title}}', $page->title(), $format);
$format = Text::replace('{{page-description}}', $page->description(), $format);
- }
- elseif ($WHERE_AM_I=='tag') {
- $tagKey = $url->slug();
- $tagName = $dbTags->getName($tagKey);
- $format = $site->titleFormatTag();
- $format = Text::replace('{{tag-name}}', $tagName, $format);
- }
- elseif ($WHERE_AM_I=='category') {
- $categoryKey = $url->slug();
- $categoryName = $dbCategories->getName($categoryKey);
- $format = $site->titleFormatCategory();
- $format = Text::replace('{{category-name}}', $categoryName, $format);
+ } elseif ($WHERE_AM_I=='tag') {
+ try {
+ $tagKey = $url->slug();
+ $tag = new Tag($tagKey);
+ $format = $site->titleFormatTag();
+ $format = Text::replace('{{tag-name}}', $tag->name(), $format);
+ } catch (Exception $e) {
+ // Tag doesn't exist
+ }
+
+ } elseif ($WHERE_AM_I=='category') {
+ try {
+ $categoryKey = $url->slug();
+ $category = new Category($categoryKey);
+ $format = $site->titleFormatCategory();
+ $format = Text::replace('{{category-name}}', $category->name(), $format);
+ } catch (Exception $e) {
+ // Category doesn't exist
+ }
} else {
$format = $site->titleFormatHomepage();
}
@@ -106,8 +113,16 @@ class Theme {
$description = $site->description();
- if( $WHERE_AM_I=='page' ) {
+ if ($WHERE_AM_I=='page') {
$description = $page->description();
+ } elseif ($WHERE_AM_I=='category') {
+ try {
+ $categoryKey = $url->slug();
+ $category = new Category($categoryKey);
+ $description = $category->description();
+ } catch (Exception $e) {
+ // description from the site
+ }
}
return '
'.PHP_EOL;
diff --git a/bl-kernel/pagex.class.php b/bl-kernel/pagex.class.php
index e77687e9..3ffee1fd 100644
--- a/bl-kernel/pagex.class.php
+++ b/bl-kernel/pagex.class.php
@@ -1,6 +1,6 @@
parentKey();
if ($parentKey) {
try {
- $page = new PageX($parentKey);
+ $page = new Page($parentKey);
return $page->{$method}();
} catch (Exception $e) {
// Continoue
@@ -472,7 +472,7 @@ class PageX {
$childrenKeys = $dbPages->getChildren($this->key());
foreach ($childrenKeys as $childKey) {
try {
- $child = new PageX($childKey);
+ $child = new Page($childKey);
array_push($list, $child);
} catch (Exception $e) {
// Continue
diff --git a/bl-kernel/tag.class.php b/bl-kernel/tag.class.php
index 4a9a9526..5d9f148d 100644
--- a/bl-kernel/tag.class.php
+++ b/bl-kernel/tag.class.php
@@ -7,22 +7,18 @@ class Tag {
function __construct($key)
{
global $dbTags;
-
if (isset($dbTags->db[$key])) {
$this->vars['name'] = $dbTags->db[$key]['name'];
+ $this->vars['template'] = $dbTags->db[$key]['template'];
+ $this->vars['description'] = $dbTags->db[$key]['description'];
$this->vars['key'] = $key;
$this->vars['permalink'] = DOMAIN_TAGS . $key;
$this->vars['list'] = $dbTags->db[$key]['list'];
+ } else {
+ $errorMessage = 'Category not found in database by key ['.$key.']';
+ Log::set(__METHOD__.LOG_SEP.$errorMessage);
+ throw new Exception($errorMessage);
}
- 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)
@@ -48,6 +44,16 @@ class Tag {
return $this->getValue('permalink');
}
+ public function template()
+ {
+ return $this->getValue('template');
+ }
+
+ public function description()
+ {
+ return $this->getValue('description');
+ }
+
// Returns an array with the keys of pages linked to the tag
public function pages()
{
diff --git a/bl-plugins/api/plugin.php b/bl-plugins/api/plugin.php
index 68f32b20..06f9ce96 100644
--- a/bl-plugins/api/plugin.php
+++ b/bl-plugins/api/plugin.php
@@ -252,7 +252,7 @@ class pluginAPI extends Plugin {
foreach ($list as $pageKey) {
try {
// Create the page object from the page key
- $page = new PageX($pageKey);
+ $page = new Page($pageKey);
array_push($tmp['data'], $page->json( $returnsArray=true ));
} catch (Exception $e) {
// Continue
@@ -265,7 +265,7 @@ class pluginAPI extends Plugin {
private function getPage($key)
{
try {
- $page = new PageX($key);
+ $page = new Page($key);
return array(
'status'=>'0',
'message'=>'Page filtered by key: '.$key,
diff --git a/bl-plugins/navigation/plugin.php b/bl-plugins/navigation/plugin.php
index 0f73ea26..457687c7 100644
--- a/bl-plugins/navigation/plugin.php
+++ b/bl-plugins/navigation/plugin.php
@@ -105,7 +105,7 @@ class pluginNavigation extends Plugin {
foreach ($publishedPages as $pageKey) {
try {
- $page = new PageX($pageKey);
+ $page = new Page($pageKey);
$html .= '
';
$html .= '' . $page->title() . '';
$html .= '';
diff --git a/bl-plugins/rss/plugin.php b/bl-plugins/rss/plugin.php
index 2ba4bc95..864ca870 100644
--- a/bl-plugins/rss/plugin.php
+++ b/bl-plugins/rss/plugin.php
@@ -62,7 +62,7 @@ class pluginRSS extends Plugin {
foreach($list as $pageKey) {
try {
// Create the page object from the page key
- $page = new PageX($pageKey);
+ $page = new Page($pageKey);
$xml .= '
- ';
$xml .= ''.$page->title().'';
$xml .= ''.$page->permalink().'';
diff --git a/bl-plugins/sitemap/plugin.php b/bl-plugins/sitemap/plugin.php
index 6bd5f828..7a3d42e0 100644
--- a/bl-plugins/sitemap/plugin.php
+++ b/bl-plugins/sitemap/plugin.php
@@ -41,7 +41,7 @@ class pluginSitemap extends Plugin {
foreach($list as $pageKey) {
try {
// Create the page object from the page key
- $page = new PageX($pageKey);
+ $page = new Page($pageKey);
$xml .= '';
$xml .= ''.$page->permalink().'';
$xml .= ''.$page->dateRaw(SITEMAP_DATE_FORMAT).'';