diff --git a/bl-kernel/abstract/dblist.class.php b/bl-kernel/abstract/dblist.class.php
index f0cfb3b2..88d06ae2 100644
--- a/bl-kernel/abstract/dblist.class.php
+++ b/bl-kernel/abstract/dblist.class.php
@@ -46,7 +46,7 @@ class dbList extends dbJSON
// The first page number is 1, so the real is 0
$realPageNumber = $pageNumber - 1;
- $chunks = array_chunk($list, $realPageNumber);
+ $chunks = array_chunk($list, $amountOfItems);
if (isset($chunks[$realPageNumber])) {
return $chunks[$realPageNumber];
}
diff --git a/bl-kernel/admin/views/edit-content.php b/bl-kernel/admin/views/edit-content.php
index 71b74ec6..7aa8af22 100644
--- a/bl-kernel/admin/views/edit-content.php
+++ b/bl-kernel/admin/views/edit-content.php
@@ -165,13 +165,20 @@
));
// Parent
- $parentTMP = buildPage($page->parent());
+ try {
+ $parentKey = $page->parent();
+ $parent = new PageX($parentKey);
+ $parentOption = $parent->title();
+ } catch (Exception $e) {
+ $parentOption = '';
+ }
+
echo Bootstrap::formInputText(array(
'name'=>'parentTMP',
'label'=>$L->g('Parent'),
'placeholder'=>'',
'tip'=>'Start typing a page title to see a list of suggestions.',
- 'value'=>($parentTMP?$parentTMP->title():'')
+ 'value'=>$parentOption
));
// Position
diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php
index 0ee3fdc5..8cf25480 100644
--- a/bl-kernel/boot/init.php
+++ b/bl-kernel/boot/init.php
@@ -85,7 +85,6 @@ include(PATH_KERNEL.'dblanguage.class.php');
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.'pagex.class.php');
include(PATH_KERNEL.'category.class.php');
include(PATH_KERNEL.'tag.class.php');
diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php
index bbfc311c..29f3b283 100644
--- a/bl-kernel/functions.php
+++ b/bl-kernel/functions.php
@@ -1,74 +1,5 @@
isValid()) {
- Log::set(__METHOD__.LOG_SEP.'Error occurred when trying build the page from file with key: '.$key);
- return false;
- }
-
- // Get the database from dbPages
- $db = $dbPages->getPageDB($key);
- if (!$db) {
- Log::set(__METHOD__.LOG_SEP.'Error occurred when trying build the page from database with key: '.$key);
- return false;
- }
-
- // Foreach field from database set on the object
- foreach ($db as $field=>$value) {
- $page->setField($field, $value);
- }
-
- // Parse Markdown
- $contentRaw = $page->contentRaw();
- $content = Text::pre2htmlentities($contentRaw); // Parse pre code with htmlentities
- $parsedown = new Parsedown();
- $content = $parsedown->text($content); // Parse Markdown
- $content = Text::imgRel2Abs($content, DOMAIN_UPLOADS); // Parse img src relative to absolute (with domain)
- $page->setField('content', $content, true);
-
- // Pagebrake
- $explode = explode(PAGE_BREAK, $content);
- $page->setField('contentBreak', $explode[0], true);
- $page->setField('readMore', !empty($explode[1]), true);
-
- // Date format
- $pageDate = $page->date();
- $page->setField('dateRaw', $pageDate, true);
-
- $pageDateFormated = $page->dateRaw( $site->dateFormat() );
- $page->setField('date', $pageDateFormated, true);
-
- // Generate and set the User object
- $username = $page->username();
- $page->setField('user', $dbUsers->getUser($username));
-
- // Category
- $categoryKey = $page->categoryKey();
- $page->setField('categoryMap', $dbCategories->getMap($categoryKey));
-
- // Get the keys of the child
- $page->setField('childrenKeys', $dbPages->getChildren($key));
-
- // Set previous and next page key
- $page->setField('previousKey', $dbPages->previousPageKey($key));
- $page->setField('nextKey', $dbPages->nextPageKey($key));
-
- return $page;
-}
-
// Re-index database of categories
// If you create/edit/remove a page is necessary regenerate the database of categories
function reindexCategories() {
@@ -203,11 +134,11 @@ function buildStaticPages() {
global $dbPages;
$list = array();
- $staticPages = $dbPages->getStaticDB();
- foreach ($staticPages as $staticPageKey) {
+ $pagesKey = $dbPages->getStaticDB();
+ foreach ($pagesKey as $pageKey) {
try {
- $staticPage = new PageX($staticPageKey);
- array_push($list, $staticPage);
+ $page = new PageX($pageKey);
+ array_push($list, $page);
} catch (Exception $e) {
// continue
}
@@ -224,86 +155,17 @@ function buildParentPages() {
$list = array();
$pagesKey = $dbPages->getPublishedDB();
foreach ($pagesKey as $pageKey) {
- $page = buildPage($pageKey);
- if ($page->isParent()) {
+ try {
+ $page = new PageX($pageKey);
array_push($list, $page);
+ } catch (Exception $e) {
+ // continue
}
}
return $list;
}
-// DEPRECATED
-// Generate the global variable $pagesByParent, defined on 69.pages.php
-function buildPagesByParent($publishedPages=true, $staticPages=true) {
- global $dbPages;
- global $pagesByParent;
- global $pagesByParentByKey;
-
- $onlyKeys = true;
- $keys = array();
- if ($publishedPages) {
- $keys = array_merge($keys, $dbPages->getPublishedDB($onlyKeys));
- }
-
- foreach ($keys as $pageKey) {
- $page = buildPage($pageKey);
- if ($page!==false) {
- $parentKey = $page->parentKey();
- // FALSE if the page is parent
- if ($parentKey===false) {
- array_push($pagesByParent[PARENT], $page);
- $pagesByParentByKey[PARENT][$page->key()] = $page;
- } else {
- if (!isset($pagesByParent[$parentKey])) {
- $pagesByParent[$parentKey] = array();
- }
- array_push($pagesByParent[$parentKey], $page);
- $pagesByParentByKey[$parentKey][$page->key()] = $page;
- }
- }
- }
-}
-
-// DEPRECATED
-// Returns an Array with all pages existing on the system
-/*
- array(
- pageKey1 => Page object,
- pageKey2 => Page object,
- ...
- pageKeyN => Page object,
- )
-*/
-function buildAllpages($publishedPages=true, $staticPages=true, $draftPages=true, $scheduledPages=true) {
- global $dbPages;
-
- // Get DB
- $onlyKeys = true;
- $keys = array();
- if ($publishedPages) {
- $keys = array_merge($keys, $dbPages->getPublishedDB($onlyKeys));
- }
- if ($staticPages) {
- $keys = array_merge($keys, $dbPages->getStaticDB($onlyKeys));
- }
- if ($draftPages) {
- $keys = array_merge($keys, $dbPages->getDraftDB($onlyKeys));
- }
- if ($scheduledPages) {
- $keys = array_merge($keys, $dbPages->getScheduledDB($onlyKeys));
- }
-
- $tmp = array();
- foreach ($keys as $pageKey) {
- $page = buildPage($pageKey);
- if ($page!==false) {
- $tmp[$page->key()] = $page;
- }
- }
- return $tmp;
-}
-
// Returns the Plugin-Object if is enabled and installed, FALSE otherwise
function getPlugin($pluginClassName) {
global $plugins;
@@ -472,12 +334,16 @@ 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'])) {
- $page = buildPage($args['key']);
- if (empty($args['title'])) {
- $args['title'] = $page->title();
- }
- if (empty($args['content'])) {
- $args['content'] = $page->contentRaw();
+ try {
+ $page = new PageX($args['key']);
+ if (empty($args['title'])) {
+ $args['title'] = $page->title();
+ }
+ if (empty($args['content'])) {
+ $args['content'] = $page->contentRaw();
+ }
+ } catch (Exception $e) {
+ // continue
}
}
diff --git a/bl-kernel/helpers/paginator.class.php b/bl-kernel/helpers/paginator.class.php
index cecf099b..e64e0de3 100644
--- a/bl-kernel/helpers/paginator.class.php
+++ b/bl-kernel/helpers/paginator.class.php
@@ -79,7 +79,7 @@ class Paginator {
}
// Returns the absolute URL for the previous page
- public static function prevPageUrl()
+ public static function previousPageUrl()
{
return self::numberUrl( self::prevPage() );
}
@@ -93,13 +93,13 @@ class Paginator {
$filter = trim($url->activeFilter(), '/');
if(empty($filter)) {
- $url = $domain.'/'.$url->slug();
+ $uri = $domain.'/'.$url->slug();
}
else {
- $url = $domain.'/'.$filter.'/'.$url->slug();
+ $uri = $domain.'/'.$filter.'/'.$url->slug();
}
- return $url.'?page='.$pageNumber;
+ return $uri.'?page='.$pageNumber;
}
public static function html($textPrevPage=false, $textNextPage=false, $showPageNumber=false)
@@ -131,7 +131,7 @@ class Paginator {
}
$html .= '
';
- $html .= ''.$textNextPage.'';
+ $html .= ''.$textNextPage.'';
$html .= '';
}
diff --git a/bl-kernel/page.class.php b/bl-kernel/page.class.php
deleted file mode 100644
index c105db78..00000000
--- a/bl-kernel/page.class.php
+++ /dev/null
@@ -1,598 +0,0 @@
-vars = false;
-
- if ($this->build($key)) {
- $this->vars['key'] = $key;
- }
- }
-
- // Parse the content from the file index.txt
- private function build($key)
- {
- $filePath = PATH_PAGES.$key.DS.FILENAME;
-
- // Check if the file exists
- if (!Sanitize::pathFile($filePath)) {
- return false;
- }
-
- $tmp = 0;
- $file = file($filePath);
- foreach ($file as $lineNumber=>$line) {
- // Split the line in 2 parts, limiter by :
- $parts = explode(':', $line, 2);
-
- $field = $parts[0]; // title, date, slug
- $value = isset($parts[1])?$parts[1]:false; // value of title, value of date
-
- // Remove all characters except letters and dash - from field
- $field = preg_replace('/[^A-Za-z\-]/', '', $field);
-
- // Field to lowercase
- $field = Text::lowercase($field);
-
- // Check if the current line start the content of the page
- // We have two breakers, the word content or 3 dash ---
- if ($field==='content') {
- $tmp = $lineNumber;
- $styleTypeUsed = 'Content:';
- break;
- }
-
- if ($field==='---') {
- $tmp = $lineNumber;
- $styleTypeUsed = '---';
- break;
- }
-
- if (!empty($field) && !empty($value)) {
- // Remove missing dashs -
- $field = preg_replace('/[^A-Za-z]/', '', $field);
-
- // Remove <-- and -->
- $value = preg_replace('/<\-\-/', '', $value);
- $value = preg_replace('/\-\->/', '', $value);
-
- // Remove empty spaces on borders
- $value = trim($value);
-
- // Position accepts only integers
- if ($field=='position') {
- $value = preg_replace('/[^0-9]/', '', $value);
- }
-
- // Sanitize all fields, except the content
- $this->vars[$field] = Sanitize::html($value);
- }
- }
-
- // Process the content
- if ($tmp!==0) {
- // Get all lines starting from "Content:" or "---"
- $content = array_slice($file, $tmp);
-
- // Remove "Content:" or "---" and keep next characters if there are
- $content[0] = substr($content[0], strpos($content[0], $styleTypeUsed) + strlen($styleTypeUsed));
-
- $content[0] = ltrim($content[0]);
-
- // Join lines in one variable, this is RAW content from file
- $this->vars['contentRaw'] = implode($content);
- }
-
- return true;
- }
-
- // Returns TRUE if the content is loaded correctly, FALSE otherwise
- public function isValid()
- {
- return $this->vars!==false;
- }
-
- // DEPRACTED
- // Returns the value from the $field, FALSE if the field doesn't exist
- public function getField($field)
- {
- if(isset($this->vars[$field])) {
- return $this->vars[$field];
- }
-
- return false;
- }
-
- public function getValue($field)
- {
- if(isset($this->vars[$field])) {
- return $this->vars[$field];
- }
-
- return false;
- }
-
- public function getDB()
- {
- return $this->vars;
- }
-
- // Set a field with a value
- public function setField($field, $value, $overwrite=true)
- {
- if($overwrite || empty($this->vars[$field])) {
- $this->vars[$field] = $value;
- }
-
- return true;
- }
-
- // Returns the content
- // This content is markdown parser
- // (boolean) $fullContent, TRUE returns all content, if FALSE returns the first part of the content
- // (boolean) $noSanitize, TRUE returns the content without sanitized
- public function content($fullContent=true, $noSanitize=true)
- {
- // This content is not sanitized.
- $content = $this->getValue('content');
-
- if(!$fullContent) {
- return $this->contentBreak();
- }
-
- if($noSanitize) {
- return $content;
- }
-
- return Sanitize::html($content);
- }
-
- public function contentBreak()
- {
- return $this->getValue('contentBreak');
- }
-
- // Returns the raw content
- // This content is not markdown parser
- // (boolean) $sanitize, TRUE returns the content sanitized
- public function contentRaw($sanitize=false)
- {
- // This content is not sanitized.
- $content = $this->getValue('contentRaw');
- if ($sanitize) {
- return Sanitize::html($content);
- }
- return $content;
- }
-
- // Returns the date according to locale settings and format settings
- public function date()
- {
- return $this->getValue('date');
- }
-
- // Returns the date according to locale settings and format as database stored
- // (string) $format, you can specify the date format
- public function dateRaw($format=false)
- {
- $date = $this->getValue('dateRaw');
-
- if($format) {
- return Date::format($date, DB_DATE_FORMAT, $format);
- }
-
- return $date;
- }
-
- // Returns the date according to locale settings and format settings
- public function dateModified()
- {
- return $this->getValue('dateModified');
- }
-
- // Returns the permalink
- // (boolean) $absolute, TRUE returns the page link with the DOMAIN, FALSE without the DOMAIN
- public function permalink($absolute=true)
- {
- // Get the key of the page
- $key = $this->getValue('key');
-
- if($absolute) {
- return DOMAIN_PAGES.$key;
- }
-
- return HTML_PATH_ROOT.PAGE_URI_FILTER.$key;
- }
-
- // Returns the previous page key
- public function previousKey()
- {
- return $this->getValue('previousKey');
- }
-
- // Returns the next page key
- public function nextKey()
- {
- return $this->getValue('nextKey');
- }
-
- // Returns the category name
- public function category()
- {
- return $this->categoryMap('name');
- }
-
- // Returns the category name
- public function categoryTemplate()
- {
- return $this->categoryMap('template');
- }
-
- // Returns the category key
- public function categoryKey()
- {
- return $this->getValue('category');
- }
-
- // Returns the category permalink
- public function categoryPermalink()
- {
- return DOMAIN_CATEGORIES.$this->categoryKey();
- }
-
- // Returns the field from the array
- // categoryMap = array( 'name'=>'', 'list'=>array() )
- public function categoryMap($field)
- {
- $map = $this->getValue('categoryMap');
-
- if($field=='key') {
- return $this->categoryKey();
- }
- elseif($field=='name') {
- return $map['name'];
- }
- elseif($field=='list') {
- return $map['list'];
- }
-
- return false;
- }
-
- // Returns the user object
- // (boolean) $field, TRUE returns the value of the field, FALSE returns the object
- public function user($field=false)
- {
- // Get the user object.
- $User = $this->getValue('user');
-
- if($field) {
- return $User->getField($field);
- }
-
- return $User;
- }
-
- // Returns the username who created the post/page
- public function username()
- {
- return $this->getValue('username');
- }
-
- public function template()
- {
- return $this->getValue('template');
- }
-
- // Returns the description field
- public function description()
- {
- return $this->getValue('description');
- }
-
- // Returns the tags separated by comma
- // (boolean) $returnsArray, TRUE to get the tags as an array, FALSE to get the tags separeted by comma
- public function tags($returnsArray=false)
- {
- $tags = $this->getValue('tags');
-
- if($returnsArray) {
- if($tags==false) {
- return array();
- }
- return $tags;
- }
- else {
- if($tags==false) {
- return false;
- }
- // Return string with tags separeted by comma.
- return implode(', ', $tags);
- }
- }
-
- public function json($returnsArray=false)
- {
- $tmp['key'] = $this->key();
- $tmp['title'] = $this->title();
- $tmp['content'] = $this->content(); // Markdown parsed
- $tmp['contentRaw'] = $this->contentRaw(true); // No Markdown parsed
- $tmp['description'] = $this->description();
- $tmp['date'] = $this->dateRaw();
- $tmp['dateUTC'] = Date::convertToUTC($this->dateRaw(), DB_DATE_FORMAT, DB_DATE_FORMAT);
- $tmp['permalink'] = $this->permalink(true);
- $tmp['coverImage'] = $this->coverImage(true);
- $tmp['coverImageFilename'] = $this->coverImage(false);
-
- if ($returnsArray) {
- return $tmp;
- }
-
- return json_encode($tmp);
- }
-
- // Returns the file name, FALSE there isn't a cover image setted
- // If the user defined an External Cover Image the complete URL is going to be returned
- // (boolean) $absolute, TRUE returns the absolute path and file name, FALSE just the file name
- public function coverImage($absolute=true)
- {
- $fileName = $this->getValue('coverImage');
- if (empty($fileName)) {
- return false;
- }
-
- // Check if external cover image, is a valid URL
- if (filter_var($fileName, FILTER_VALIDATE_URL)) {
- return $fileName;
- }
-
- if ($absolute) {
- return DOMAIN_UPLOADS.$fileName;
- }
-
- return $fileName;
- }
-
- // Returns the absolute URL of the thumbnail of the cover image, FALSE if the page doen't have cover image
- public function thumbCoverImage()
- {
- $coverImageFilename = $this->coverImage(false);
- if ($coverImageFilename==false) {
- return false;
- }
- return DOMAIN_UPLOADS_THUMBNAILS.$coverImageFilename;
- }
-
- // Returns TRUE if the content has the text splited
- public function readMore()
- {
- return $this->getValue('readMore');
- }
-
- public function uuid()
- {
- return $this->getValue('uuid');
- }
-
- // Returns the field key
- public function key()
- {
- return $this->getValue('key');
- }
-
- // (boolean) Returns TRUE if the page is published, FALSE otherwise
- public function published()
- {
- return ($this->getValue('status')==='published');
- }
-
- // (boolean) Returns TRUE if the page is scheduled, FALSE otherwise
- public function scheduled()
- {
- return ($this->getValue('status')==='scheduled');
- }
-
- // (boolean) Returns TRUE if the page is draft, FALSE otherwise
- public function draft()
- {
- return ($this->getValue('status')=='draft');
- }
-
- // (boolean) Returns TRUE if the page is sticky, FALSE otherwise
- public function sticky()
- {
- return ($this->getValue('status')=='sticky');
- }
-
- // (boolean) Returns TRUE if the page is static, FALSE otherwise
- public function isStatic()
- {
- return ($this->getValue('status')=='static');
- }
-
- // (string) Returns status of the page
- public function status()
- {
- return $this->getValue('status');
- }
-
- // (string) Returns type of the page
- public function type()
- {
- return $this->status();
- }
-
- // Returns the title field
- public function title()
- {
- return $this->getValue('title');
- }
-
- // Returns TRUE if the page has enabled the comments, FALSE otherwise
- public function allowComments()
- {
- return $this->getValue('allowComments');
- }
-
- // Returns the page position
- public function position()
- {
- return $this->getValue('position');
- }
-
- // Returns the page noindex
- public function noindex()
- {
- return $this->getValue('noindex');
- }
-
- // Returns the page nofollow
- public function nofollow()
- {
- return $this->getValue('nofollow');
- }
-
- // Returns the page noarchive
- public function noarchive()
- {
- return $this->getValue('noarchive');
- }
-
- // Returns the page slug
- public function slug()
- {
- $explode = explode('/', $this->getValue('key'));
-
- // Check if the page have a parent.
- if (!empty($explode[1])) {
- return $explode[1];
- }
-
- return $explode[0];
- }
-
- // Returns the parent key, if the page doesn't have a parent returns FALSE
- public function parent()
- {
- return $this->parentKey();
- }
-
- // Returns the parent key, if the page doesn't have a parent returns FALSE
- public function parentKey()
- {
- $explode = explode('/', $this->getValue('key'));
- if (isset($explode[1])) {
- return $explode[0];
- }
- return false;
- }
-
- // Returns TRUE if the page is a parent, has or not children
- public function isParent()
- {
- return $this->parentKey()===false;
- }
-
- // Returns the parent method output, if the page doesn't have a parent returns FALSE
- public function parentMethod($method)
- {
- $parentKey = $this->parentKey();
- if ($parentKey) {
- $page = buildPage($parentKey);
- return $page->{$method}();
- }
-
- return false;
- }
-
- // Returns TRUE if the page is a child, FALSE otherwise
- public function isChild()
- {
- return $this->parentKey()!==false;
- }
-
- // Returns TRUE if the page has children
- public function hasChildren()
- {
- $childrenKeys = $this->childrenKeys();
- return !empty($childrenKeys);
- }
-
- // Returns an array with all children's keys
- public function childrenKeys()
- {
- return $this->getValue('childrenKeys');
- }
-
- // Returns an array with all children as Page-Object
- public function children()
- {
- $list = array();
- $childrenKeys = $this->getValue('childrenKeys');
- foreach ($childrenKeys as $childKey) {
- $child = buildPage($childKey);
- array_push($list, $child);
- }
-
- return $list;
- }
-
- // Returns the amount of minutes takes to read the page
- public function readingTime() {
- global $Language;
-
- $words = $this->content(true);
- $words = strip_tags($words);
- $words = str_word_count($words);
- $average = $words / 200;
- $minutes = round($average);
-
- if ($minutes>0) {
- return $minutes.' '.$Language->get('minutes');
- }
-
- return '~1 '.$Language->get('minute');
- }
-
- // Returns relative time (e.g. "1 minute ago")
- // Based on http://stackoverflow.com/a/18602474
- // Modified for Bludit
- // $complete = false : short version
- // $complete = true : full version
- public function relativeTime($complete = false) {
- $current = new DateTime;
- $past = new DateTime($this->getValue('date'));
- $elapsed = $current->diff($past);
-
- $elapsed->w = floor($elapsed->d / 7);
- $elapsed->d -= $elapsed->w * 7;
-
- $string = array(
- 'y' => 'year',
- 'm' => 'month',
- 'w' => 'week',
- 'd' => 'day',
- 'h' => 'hour',
- 'i' => 'minute',
- 's' => 'second',
- );
-
- foreach($string as $key => &$value) {
- if($elapsed->$key) {
- $value = $elapsed->$key . ' ' . $value . ($elapsed->$key > 1 ? 's' : ' ');
- } else {
- unset($string[$key]);
- }
- }
-
- if(!$complete) {
- $string = array_slice($string, 0 , 1);
- }
-
- return $string ? implode(', ', $string) . ' ago' : 'Just now';
- }
-}
diff --git a/bl-kernel/pagex.class.php b/bl-kernel/pagex.class.php
index 4f1f74a0..857a027a 100644
--- a/bl-kernel/pagex.class.php
+++ b/bl-kernel/pagex.class.php
@@ -427,8 +427,12 @@ class PageX {
{
$parentKey = $this->parentKey();
if ($parentKey) {
- $page = buildPage($parentKey);
- return $page->{$method}();
+ try {
+ $page = new PageX($parentKey);
+ return $page->{$method}();
+ } catch (Exception $e) {
+ // Continoue
+ }
}
return false;
@@ -462,8 +466,12 @@ class PageX {
$list = array();
$childrenKeys = $dbPages->getChildren($this->key());
foreach ($childrenKeys as $childKey) {
- $child = buildPage($childKey);
- array_push($list, $child);
+ try {
+ $child = new PageX($childKey);
+ array_push($list, $child);
+ } catch (Exception $e) {
+ // Continue
+ }
}
return $list;
diff --git a/bl-plugins/api/plugin.php b/bl-plugins/api/plugin.php
index 7269a62d..68f32b20 100644
--- a/bl-plugins/api/plugin.php
+++ b/bl-plugins/api/plugin.php
@@ -250,9 +250,13 @@ class pluginAPI extends Plugin {
// Get keys of pages
foreach ($list as $pageKey) {
- // Create the page object from the page key
- $page = buildPage($pageKey);
- array_push($tmp['data'], $page->json( $returnsArray=true ));
+ try {
+ // Create the page object from the page key
+ $page = new PageX($pageKey);
+ array_push($tmp['data'], $page->json( $returnsArray=true ));
+ } catch (Exception $e) {
+ // Continue
+ }
}
return $tmp;
@@ -260,21 +264,19 @@ class pluginAPI extends Plugin {
private function getPage($key)
{
- // Generate the object Page
- $page = buildPage($key);
-
- if (!$page) {
+ try {
+ $page = new PageX($key);
+ return array(
+ 'status'=>'0',
+ 'message'=>'Page filtered by key: '.$key,
+ 'data'=>$page->json( $returnsArray=true )
+ );
+ } catch (Exception $e) {
return array(
'status'=>'1',
'message'=>'Page not found.'
);
}
-
- return array(
- 'status'=>'0',
- 'message'=>'Page filtered by key: '.$key,
- 'data'=>$page->json( $returnsArray=true )
- );
}
private function createPage($args)
diff --git a/bl-plugins/navigation/plugin.php b/bl-plugins/navigation/plugin.php
index 609d8d55..0f73ea26 100644
--- a/bl-plugins/navigation/plugin.php
+++ b/bl-plugins/navigation/plugin.php
@@ -104,10 +104,14 @@ class pluginNavigation extends Plugin {
$publishedPages = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);
foreach ($publishedPages as $pageKey) {
- $page = buildPage($pageKey);
- $html .= '';
- $html .= '' . $page->title() . '';
- $html .= '';
+ try {
+ $page = new PageX($pageKey);
+ $html .= '';
+ $html .= '' . $page->title() . '';
+ $html .= '';
+ } catch (Exception $e) {
+ // Continue
+ }
}
}
diff --git a/bl-plugins/rss/plugin.php b/bl-plugins/rss/plugin.php
index 3c6017ff..2ba4bc95 100644
--- a/bl-plugins/rss/plugin.php
+++ b/bl-plugins/rss/plugin.php
@@ -60,15 +60,19 @@ class pluginRSS extends Plugin {
// Get keys of pages
foreach($list as $pageKey) {
- // Create the page object from the page key
- $page = buildPage($pageKey);
- $xml .= '- ';
- $xml .= ''.$page->title().'';
- $xml .= ''.$page->permalink().'';
- $xml .= ''.Sanitize::html($page->contentBreak()).'';
- $xml .= ''.$page->dateRaw('r').'';
- $xml .= ''.$page->uuid().'';
- $xml .= '
';
+ try {
+ // Create the page object from the page key
+ $page = new PageX($pageKey);
+ $xml .= '- ';
+ $xml .= ''.$page->title().'';
+ $xml .= ''.$page->permalink().'';
+ $xml .= ''.Sanitize::html($page->contentBreak()).'';
+ $xml .= ''.$page->dateRaw('r').'';
+ $xml .= ''.$page->uuid().'';
+ $xml .= '
';
+ } catch (Exception $e) {
+ // Continue
+ }
}
$xml .= '';
diff --git a/bl-plugins/sitemap/plugin.php b/bl-plugins/sitemap/plugin.php
index baf853c4..6bd5f828 100644
--- a/bl-plugins/sitemap/plugin.php
+++ b/bl-plugins/sitemap/plugin.php
@@ -39,14 +39,17 @@ class pluginSitemap extends Plugin {
$list = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);
foreach($list as $pageKey) {
- // Create the page object from the page key
- $page = buildPage($pageKey);
-
- $xml .= '';
- $xml .= ''.$page->permalink().'';
- $xml .= ''.$page->dateRaw(SITEMAP_DATE_FORMAT).'';
- $xml .= 'daily';
- $xml .= '';
+ try {
+ // Create the page object from the page key
+ $page = new PageX($pageKey);
+ $xml .= '';
+ $xml .= ''.$page->permalink().'';
+ $xml .= ''.$page->dateRaw(SITEMAP_DATE_FORMAT).'';
+ $xml .= 'daily';
+ $xml .= '';
+ } catch (Exception $e) {
+ // Continue
+ }
}
$xml .= '';
diff --git a/bl-themes/alternative/php/home.php b/bl-themes/alternative/php/home.php
index c5e53cbc..6e6521e0 100644
--- a/bl-themes/alternative/php/home.php
+++ b/bl-themes/alternative/php/home.php
@@ -50,7 +50,7 @@
- get('Previous'); ?>
+ get('Previous'); ?>
diff --git a/bl-themes/blogx/php/home.php b/bl-themes/blogx/php/home.php
index cbe5fce7..1772c8ad 100644
--- a/bl-themes/blogx/php/home.php
+++ b/bl-themes/blogx/php/home.php
@@ -46,7 +46,7 @@
- get('Previous'); ?>
+ get('Previous'); ?>