From d4afe3b843676b9d4d2d44ef0df6816cc75dd8ce Mon Sep 17 00:00:00 2001 From: Diego Najar Date: Mon, 2 Oct 2017 22:42:18 +0200 Subject: [PATCH] Pages for Content --- .../controllers/{pages.php => content.php} | 4 +- .../{edit-page.php => edit-content.php} | 10 +- .../{new-page.php => new-content.php} | 4 +- .../admin/controllers/settings-advanced.php | 2 +- bl-kernel/admin/themes/default/index.php | 16 +- .../admin/views/{pages.php => content.php} | 6 +- bl-kernel/admin/views/dashboard.php | 24 +-- .../views/{edit-page.php => edit-content.php} | 23 ++- .../views/{new-page.php => new-content.php} | 29 ++-- bl-kernel/admin/views/settings-advanced.php | 46 +++--- bl-kernel/boot/rules/60.plugins.php | 2 +- bl-kernel/boot/rules/99.themes.php | 2 +- bl-kernel/dbpages.class.php | 138 ++++++++---------- bl-kernel/functions.php | 8 +- bl-languages/en.json | 34 +++-- bl-plugins/menu/languages/en.json | 2 +- bl-plugins/simplemde/plugin.php | 4 +- bl-plugins/tinymce/languages/en.json | 2 +- bl-plugins/tinymce/plugin.php | 4 +- 19 files changed, 184 insertions(+), 176 deletions(-) rename bl-kernel/admin/controllers/{pages.php => content.php} (94%) rename bl-kernel/admin/controllers/{edit-page.php => edit-content.php} (87%) rename bl-kernel/admin/controllers/{new-page.php => new-content.php} (92%) rename bl-kernel/admin/views/{pages.php => content.php} (90%) rename bl-kernel/admin/views/{edit-page.php => edit-content.php} (92%) rename bl-kernel/admin/views/{new-page.php => new-content.php} (90%) diff --git a/bl-kernel/admin/controllers/pages.php b/bl-kernel/admin/controllers/content.php similarity index 94% rename from bl-kernel/admin/controllers/pages.php rename to bl-kernel/admin/controllers/content.php index 6b015203..56237b91 100644 --- a/bl-kernel/admin/controllers/pages.php +++ b/bl-kernel/admin/controllers/content.php @@ -28,7 +28,7 @@ $published = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished); // Check if out of range the pageNumber if (empty($published) && $Url->pageNumber()>1) { - Redirect::page('pages'); + Redirect::page('content'); } // List of drafts pages @@ -39,4 +39,4 @@ $scheduled = $dbPages->getScheduledDB(); $static = $dbPages->getStaticDB(); // Title of the page -$layout['title'] .= ' - '.$Language->g('Manage Pages'); \ No newline at end of file +$layout['title'] .= ' - '.$Language->g('Manage content'); \ No newline at end of file diff --git a/bl-kernel/admin/controllers/edit-page.php b/bl-kernel/admin/controllers/edit-content.php similarity index 87% rename from bl-kernel/admin/controllers/edit-page.php rename to bl-kernel/admin/controllers/edit-content.php index 5c27b8e4..4294d973 100644 --- a/bl-kernel/admin/controllers/edit-page.php +++ b/bl-kernel/admin/controllers/edit-content.php @@ -20,18 +20,18 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { if( isset($_POST['delete-page']) ) { if( deletePage($_POST['key']) ) { Alert::set( $Language->g('The changes have been saved') ); - Redirect::page('pages'); + Redirect::page('content'); } } else { $key = editPage($_POST); if( $key!==false ) { Alert::set( $Language->g('The changes have been saved') ); - Redirect::page('edit-page/'.$key); + Redirect::page('edit-content/'.$key); } } - Redirect::page('pages'); + Redirect::page('content'); } // ============================================================================ @@ -41,8 +41,8 @@ $pageKey = $layout['parameters']; $page = buildPage($pageKey); if ($page===false) { Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the page: '.$pageKey); - Redirect::page('pages'); + Redirect::page('content'); } // Title of the page -$layout['title'] .= ' - '.$Language->g('Edit page').' - '.$page->title(); \ No newline at end of file +$layout['title'] .= ' - '.$Language->g('Edit content').' - '.$page->title(); \ No newline at end of file diff --git a/bl-kernel/admin/controllers/new-page.php b/bl-kernel/admin/controllers/new-content.php similarity index 92% rename from bl-kernel/admin/controllers/new-page.php rename to bl-kernel/admin/controllers/new-content.php index ce11e39a..5c16c132 100644 --- a/bl-kernel/admin/controllers/new-page.php +++ b/bl-kernel/admin/controllers/new-content.php @@ -18,7 +18,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { createPage($_POST); - Redirect::page('pages'); + Redirect::page('content'); } // ============================================================================ @@ -26,4 +26,4 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { // ============================================================================ // Title of the page -$layout['title'] .= ' - '.$Language->g('New page'); \ No newline at end of file +$layout['title'] .= ' - '.$Language->g('New content'); \ No newline at end of file diff --git a/bl-kernel/admin/controllers/settings-advanced.php b/bl-kernel/admin/controllers/settings-advanced.php index 49d1b357..7b70a5c2 100644 --- a/bl-kernel/admin/controllers/settings-advanced.php +++ b/bl-kernel/admin/controllers/settings-advanced.php @@ -32,7 +32,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { $allPublishedPages = buildAllpages(true); // Homepage select options -$homepageOptions = array(); +$homepageOptions = array(' '=>'- '.$L->g('Latest content').' -'); foreach($allPublishedPages as $key=>$page) { $parentKey = $page->parentKey(); if ($parentKey) { diff --git a/bl-kernel/admin/themes/default/index.php b/bl-kernel/admin/themes/default/index.php index 486eba75..f562db92 100644 --- a/bl-kernel/admin/themes/default/index.php +++ b/bl-kernel/admin/themes/default/index.php @@ -58,8 +58,8 @@ $(document).ready(function() {
diff --git a/bl-kernel/admin/views/pages.php b/bl-kernel/admin/views/content.php similarity index 90% rename from bl-kernel/admin/views/pages.php rename to bl-kernel/admin/views/content.php index 04df7378..4d18589b 100644 --- a/bl-kernel/admin/views/pages.php +++ b/bl-kernel/admin/views/content.php @@ -1,8 +1,8 @@ $L->g('Manage pages'), 'icon'=>'folder')); +HTML::title(array('title'=>$L->g('Manage content'), 'icon'=>'folder')); -echo ' '.$L->g('Add new page').''; +echo ' '.$L->g('Add new content').''; echo ' @@ -50,7 +50,7 @@ function table($status, $icon='arrow-circle-o-down') { $page = buildPage($pageKey); echo ''; echo ''; diff --git a/bl-kernel/admin/views/dashboard.php b/bl-kernel/admin/views/dashboard.php index 92ea58b5..da8009bc 100644 --- a/bl-kernel/admin/views/dashboard.php +++ b/bl-kernel/admin/views/dashboard.php @@ -4,13 +4,13 @@
-

p('New page') ?>

-

p('Create a new page for your site') ?>

+

p('New content') ?>

+

p('Create new content for your site') ?>

-

p('Manage pages') ?>

-

p('Edit or delete pages from your site') ?>

+

p('Manage content') ?>

+

p('Edit or delete content from your site') ?>

@@ -19,7 +19,7 @@

p('New category') ?>

-

p('Create a new category to organize your pages') ?>

+

p('Create a new category to organize your content') ?>

@@ -99,18 +99,18 @@
-

p('Scheduled pages') ?>

+

p('Scheduled content') ?>

- ' + ' .($page->title()?$page->title():''.$Language->g('Empty title').' ') .'
- + @@ -138,18 +138,18 @@
-

p('Drafts') ?>

+

p('Draft content') ?>

    getDraftDB(); if( empty($draftPages) ) { - echo '
  • '.$Language->g('There are no draft pages').'
  • '; + echo '
  • '.$Language->g('There are no draft content').'
  • '; } else { $keys = array_keys($draftPages); foreach($keys as $key) { $page = buildPage($key); - echo '
  • '.($page->title()?$page->title():'['.$Language->g('Empty title').'] ').'
  • '; + echo '
  • '.($page->title()?$page->title():'['.$Language->g('Empty title').'] ').'
  • '; } } ?> diff --git a/bl-kernel/admin/views/edit-page.php b/bl-kernel/admin/views/edit-content.php similarity index 92% rename from bl-kernel/admin/views/edit-page.php rename to bl-kernel/admin/views/edit-content.php index e1c9ce88..105cbb7e 100644 --- a/bl-kernel/admin/views/edit-page.php +++ b/bl-kernel/admin/views/edit-content.php @@ -1,6 +1,6 @@ $L->g('Edit page'), 'icon'=>'file-text-o')); +HTML::title(array('title'=>$L->g('Edit content'), 'icon'=>'file-text-o')); HTML::formOpen(array('class'=>'uk-form-stacked')); @@ -47,7 +47,7 @@ echo '
    '; if(count($page->children())===0) { echo ' '; - echo ' '.$L->g('Cancel').''; + echo ' '.$L->g('Cancel').''; } echo '
    '; @@ -154,14 +154,16 @@ echo '
    '; 'name'=>'date', 'value'=>$page->dateRaw(), 'class'=>'uk-width-1-1 uk-form-medium', - 'tip'=>$L->g('To schedule the page select the date and time'), + 'tip'=>$L->g('To schedule the content select the date and time'), 'label'=>$L->g('Date') )); + echo '
    '; + // Parent input // Check if the page has children if(count($page->children())==0) { - $options = array(); + $options = array(' '=>'- '.$L->g('No parent').' -'); $parentsList = $dbPages->getParents(); $parentsKey = array_keys($parentsList); foreach($parentsKey as $pageKey) { @@ -176,20 +178,23 @@ echo '
    '; 'class'=>'uk-width-1-1 uk-form-medium', 'options'=>$options, 'selected'=>$page->parentKey(), - 'tip'=>'', - 'addEmptySpace'=>true + 'tip'=>'' )); } + echo '
    '; + // Position input HTML::formInputText(array( 'name'=>'position', 'value'=>$page->position(), 'class'=>'uk-width-1-1 uk-form-medium', 'label'=>$L->g('Position'), - 'tip'=>$L->g('This field is used when you order the pages by position') + 'tip'=>$L->g('This field is used when you order the content by position') )); + echo '
    '; + // External Coverimage HTML::formInputText(array( 'name'=>'externalCoverImage', @@ -199,12 +204,14 @@ echo '
    '; 'tip'=>$L->g('Full image URL') )); + echo '
    '; + // Slug input HTML::formInputText(array( 'name'=>'slug', 'value'=>$page->slug(), 'class'=>'uk-width-1-1 uk-form-medium', - 'tip'=>$L->g('URL associated with the page'), + 'tip'=>$L->g('URL associated with the content'), 'label'=>$L->g('Friendly URL') )); diff --git a/bl-kernel/admin/views/new-page.php b/bl-kernel/admin/views/new-content.php similarity index 90% rename from bl-kernel/admin/views/new-page.php rename to bl-kernel/admin/views/new-content.php index 315e7cb3..06a6c341 100644 --- a/bl-kernel/admin/views/new-page.php +++ b/bl-kernel/admin/views/new-content.php @@ -1,6 +1,6 @@ $L->g('New page'), 'icon'=>'file-text-o')); +HTML::title(array('title'=>$L->g('New content'), 'icon'=>'file-text-o')); HTML::formOpen(array('class'=>'uk-form-stacked')); @@ -35,7 +35,7 @@ echo '
    '; echo '
    - '.$L->g('Cancel').' + '.$L->g('Cancel').'
    '; echo '
    '; @@ -132,12 +132,14 @@ echo '
    '; 'name'=>'date', 'value'=>Date::current(DB_DATE_FORMAT), 'class'=>'uk-width-1-1 uk-form-medium', - 'tip'=>$L->g('To schedule the page select the date and time'), + 'tip'=>$L->g('To schedule the content select the date and time'), 'label'=>$L->g('Date') )); + echo '
    '; + // Parent input - $options = array(); + $options = array(' '=>'- '.$L->g('No parent').' -'); $parentsList = $dbPages->getParents(); $parentsKey = array_keys($parentsList); foreach($parentsKey as $pageKey) { @@ -151,34 +153,41 @@ echo '
    '; 'class'=>'uk-width-1-1 uk-form-medium', 'options'=>$options, 'selected'=>'', - 'tip'=>'', - 'addEmptySpace'=>true + 'tip'=>'' )); + echo '
    '; + // Position input HTML::formInputText(array( 'name'=>'position', - 'value'=>'1', + 'type'=>'number', + 'value'=>$dbPages->nextPositionNumber(), 'class'=>'uk-width-1-1 uk-form-medium', 'label'=>$L->g('Position'), - 'tip'=>$L->g('This field is used when you order the pages by position') + 'tip'=>$L->g('This field is used when you order the content by position') )); + echo '
    '; + // External Coverimage HTML::formInputText(array( 'name'=>'externalCoverImage', 'value'=>'', 'class'=>'uk-width-1-1 uk-form-medium', 'label'=>$L->g('External Cover Image'), - 'tip'=>$L->g('Full image URL') + 'tip'=>$L->g('Full image URL'), + 'placeholder'=>"https://" )); + echo '
    '; + // Slug input HTML::formInputText(array( 'name'=>'slug', 'value'=>'', 'class'=>'uk-width-1-1 uk-form-medium', - 'tip'=>$L->g('URL associated with the page'), + 'tip'=>$L->g('URL associated with the content'), 'label'=>$L->g('Friendly URL') )); diff --git a/bl-kernel/admin/views/settings-advanced.php b/bl-kernel/admin/views/settings-advanced.php index 5da7a3da..b6dbf4d1 100644 --- a/bl-kernel/admin/views/settings-advanced.php +++ b/bl-kernel/admin/views/settings-advanced.php @@ -9,23 +9,24 @@ HTML::formOpen(array('class'=>'uk-form-horizontal')); 'value'=>$Security->getTokenCSRF() )); - HTML::legend(array('value'=>$L->g('General'), 'class'=>'first-child')); + HTML::legend(array('value'=>$L->g('Content'))); HTML::formSelect(array( 'name'=>'itemsPerPage', 'label'=>$L->g('Items per page'), - 'options'=>array('1'=>'1','2'=>'2','3'=>'3','4'=>'4','5'=>'5','6'=>'6','7'=>'7','8'=>'8', '-1'=>'All pages'), + 'options'=>array('1'=>'1','2'=>'2','3'=>'3','4'=>'4','5'=>'5','6'=>'6','7'=>'7','8'=>'8', '-1'=>$L->g('All pages')), 'selected'=>$Site->itemsPerPage(), 'class'=>'uk-width-1-3 uk-form-medium', 'tip'=>$L->g('Number of items to show per page') )); - HTML::formInputText(array( - 'name'=>'url', - 'label'=>$L->g('Site URL'), - 'value'=>$Site->url(), - 'class'=>'uk-width-1-2 uk-form-medium', - 'tip'=>$L->g('full-url-of-your-site') + HTML::formSelect(array( + 'name'=>'orderBy', + 'label'=>$L->g('Order content by'), + 'options'=>array('date'=>$L->g('Date'),'position'=>$L->g('Position')), + 'selected'=>$Site->orderBy(), + 'class'=>'uk-width-1-3 uk-form-medium', + 'tip'=>$L->g('order-the-content-by-date-to-build-a-blog') )); HTML::legend(array('value'=>$L->g('Predefined pages'))); @@ -36,29 +37,17 @@ HTML::formOpen(array('class'=>'uk-form-horizontal')); 'options'=>$homepageOptions, 'selected'=>$Site->homepage(), 'class'=>'uk-width-1-3 uk-form-medium', - 'tip'=>$L->g('Returning page for the main page'), - 'addEmptySpace'=>true + 'tip'=>$L->g('Returning page for the main page') )); + $homepageOptions[' '] = '- '.$L->g('Default message').' -'; HTML::formSelect(array( 'name'=>'pageNotFound', 'label'=>$L->g('Page not found'), 'options'=>$homepageOptions, 'selected'=>$Site->pageNotFound(), 'class'=>'uk-width-1-3 uk-form-medium', - 'tip'=>$L->g('Returning page when the page doesnt exist'), - 'addEmptySpace'=>true - )); - - HTML::legend(array('value'=>$L->g('Website or Blog'))); - - HTML::formSelect(array( - 'name'=>'orderBy', - 'label'=>$L->g('Order content By'), - 'options'=>array('date'=>$L->g('Date'),'position'=>$L->g('Position')), - 'selected'=>$Site->orderBy(), - 'class'=>'uk-width-1-3 uk-form-medium', - 'tip'=>$L->g('Order the content by position to build a Website') + 'tip'=>$L->g('Returning page when the page doesnt exist') )); HTML::legend(array('value'=>$L->g('Email account settings'))); @@ -71,6 +60,17 @@ HTML::formOpen(array('class'=>'uk-form-horizontal')); 'tip'=>$L->g('Emails will be sent from this address') )); + HTML::legend(array('value'=>$L->g('Site URL'))); + + HTML::formInputText(array( + 'name'=>'url', + 'label'=>'', + 'value'=>$Site->url(), + 'class'=>'uk-width-1-2 uk-form-medium', + 'tip'=>$L->g('full-url-of-your-site'), + 'placeholder'=>'https://' + )); + HTML::legend(array('value'=>$L->g('URL Filters'))); HTML::formInputText(array( diff --git a/bl-kernel/boot/rules/60.plugins.php b/bl-kernel/boot/rules/60.plugins.php index 73ea21c6..6e2041b4 100644 --- a/bl-kernel/boot/rules/60.plugins.php +++ b/bl-kernel/boot/rules/60.plugins.php @@ -72,7 +72,7 @@ function buildPlugins() $Plugin = new $pluginClass; // Check if the plugin is translated - $languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.$Site->locale().'.json'; + $languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.$Site->language().'.json'; if( !Sanitize::pathFile($languageFilename) ) { $languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.DEFAULT_LANGUAGE_FILE; } diff --git a/bl-kernel/boot/rules/99.themes.php b/bl-kernel/boot/rules/99.themes.php index 91ec6a49..5297549a 100644 --- a/bl-kernel/boot/rules/99.themes.php +++ b/bl-kernel/boot/rules/99.themes.php @@ -18,7 +18,7 @@ function buildThemes() foreach($themesPaths as $themePath) { // Check if the theme is translated. - $languageFilename = $themePath.DS.'languages'.DS.$Site->locale().'.json'; + $languageFilename = $themePath.DS.'languages'.DS.$Site->language().'.json'; if( !Sanitize::pathFile($languageFilename) ) { $languageFilename = $themePath.DS.'languages'.DS.DEFAULT_LANGUAGE_FILE; } diff --git a/bl-kernel/dbpages.class.php b/bl-kernel/dbpages.class.php index b8413a87..dcd71606 100644 --- a/bl-kernel/dbpages.class.php +++ b/bl-kernel/dbpages.class.php @@ -10,7 +10,8 @@ class dbPages extends dbJSON 'description'=> array('inFile'=>false, 'value'=>''), 'username'=> array('inFile'=>false, 'value'=>''), 'tags'=> array('inFile'=>false, 'value'=>array()), - 'status'=> array('inFile'=>false, 'value'=>'published'), // published, draft, scheduled + 'status'=> array('inFile'=>false, 'value'=>'published'), // published, static, draft, scheduled + 'type'=> array('inFile'=>false, 'value'=>'post'), // post, page 'date'=> array('inFile'=>false, 'value'=>''), 'dateModified'=> array('inFile'=>false, 'value'=>''), 'position'=> array('inFile'=>false, 'value'=>0), @@ -66,19 +67,21 @@ class dbPages extends dbJSON // Generate UUID $args['uuid'] = $this->generateUUID(); - // Date - $currentDate = Date::current(DB_DATE_FORMAT); - // Validate date if ( !Valid::date($args['date'], DB_DATE_FORMAT) ) { - $args['date'] = $currentDate; + $args['date'] = Date::current(DB_DATE_FORMAT); } // Schedule page - if ( ($args['date']>$currentDate) && ($args['status']=='published') ) { + if ( ($args['date']>Date::current(DB_DATE_FORMAT)) && ($args['status']=='published') ) { $args['status'] = 'scheduled'; } + // Set type + if ($args['status']=='static') { + $args['type'] = 'page'; + } + foreach ($this->dbFields as $field=>$options) { $value = $args[$field]; @@ -143,7 +146,11 @@ class dbPages extends dbJSON } } else { // By default is the current value - $value = $this->db[$args['key']][$field]; + if (isset($this->db[$args['key']][$field])) { + $value = $this->db[$args['key']][$field]; + } else { + $value = $options['value']; + } } $args[$field] = $value; @@ -158,20 +165,17 @@ class dbPages extends dbJSON $args['date'] = $this->db[$args['key']]['date']; } - // Date - $currentDate = Date::current(DB_DATE_FORMAT); - // Modified date $args['dateModified'] = Date::current(DB_DATE_FORMAT); - // Validate date - if ( !Valid::date($args['date'], DB_DATE_FORMAT) ) { - $args['date'] = $currentDate; + // Schedule page + if ( ($args['date']>Date::current(DB_DATE_FORMAT)) && ($args['status']=='published') ) { + $args['status'] = 'scheduled'; } - // Schedule page - if ( ($args['date']>$currentDate) && ($args['status']=='published') ) { - $args['status'] = 'scheduled'; + // Set type + if ($args['status']=='static') { + $args['type'] = 'page'; } foreach ($this->dbFields as $field=>$options) { @@ -227,17 +231,12 @@ class dbPages extends dbJSON public function delete($key) { // Page doesn't exist in database - if(!$this->exists($key)) { + if (!$this->exists($key)) { Log::set(__METHOD__.LOG_SEP.'The page does not exist. Key: '.$key); } - // Delete the index.txt file - if( Filesystem::rmfile(PATH_PAGES.$key.DS.FILENAME) === false ) { - Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the file '.FILENAME); - } - - // Delete the directory - if( Filesystem::rmdir(PATH_PAGES.$key) === false ) { + // Delete directory and files + if (Filesystem::deleteRecursive(PATH_PAGES.$key) === false) { Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the directory '.PATH_PAGES.$key); } @@ -245,14 +244,14 @@ class dbPages extends dbJSON unset($this->db[$key]); // Save the database. - if( $this->save() === false ) { + if ($this->save()===false) { Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.'); } return true; } - // Change a value of a page + // Change a field's value public function setField($key, $field, $value) { if( $this->exists($key) ) { @@ -263,12 +262,7 @@ class dbPages extends dbJSON return false; } -/* DEPRECATED - public function setStatus($key, $value) - { - return $this->setField($key, 'status', $value); - } -*/ + // Returns a database with published pages public function getPublishedDB() { @@ -281,7 +275,8 @@ class dbPages extends dbJSON return $tmp; } - // (array) Returns a database with the static pages + // Returns an array with a list of keys/database of static pages + // By default the static pages are sort by position public function getStaticDB() { $tmp = $this->db; @@ -294,11 +289,11 @@ class dbPages extends dbJSON return $tmp; } - // Returns a database with drafts pages + // Returns an array with a list of keys/database of draft pages public function getDraftDB() { $tmp = $this->db; - foreach($tmp as $key=>$fields) { + foreach ($tmp as $key=>$fields) { if($fields['status']!='draft') { unset($tmp[$key]); } @@ -306,7 +301,7 @@ class dbPages extends dbJSON return $tmp; } - // Returns a database with drafts pages + // Returns an array with a list of keys/database of scheduled pages public function getScheduledDB() { $tmp = $this->db; @@ -318,16 +313,28 @@ class dbPages extends dbJSON return $tmp; } - // Return an array with the database for a page, FALSE otherwise. + // Return an array with the database for a page, FALSE otherwise public function getPageDB($key) { - if( $this->exists($key) ) { + if ($this->exists($key)) { return $this->db[$key]; } return false; } + // Returns the next number of the bigger position + public function nextPositionNumber() + { + $tmp = 1; + foreach ($this->db as $key=>$fields) { + if ($fields['position']>$tmp) { + $tmp = $fields['position']; + } + } + return ++$tmp; + } + // Returns an array with a list of pages, FALSE if out of range // The database is sorted by date or by position // (int) $pageNumber, the page number @@ -337,7 +344,7 @@ class dbPages extends dbJSON { $db = $this->db; - if( $onlyPublished ) { + if ($onlyPublished) { $db = $this->getPublishedDB(); } @@ -353,7 +360,7 @@ class dbPages extends dbJSON $end = (int) min( ($init + $amountOfItems - 1), $total ); $outrange = $init<0 ? true : $init>$end; - if(!$outrange) { + if (!$outrange) { return array_slice($db, $init, $amountOfItems, true); } @@ -394,11 +401,10 @@ class dbPages extends dbJSON public function sortBy() { - if( ORDER_BY=='date' ) { + if (ORDER_BY=='date') { return $this->sortByDate(true); - } else { - return $this->sortByPosition(false); } + return $this->sortByPosition(false); } // Sort pages by position @@ -406,17 +412,18 @@ class dbPages extends dbJSON { if($HighToLow) { uasort($this->db, array($this, 'sortByPositionHighToLow')); - } - else { + } else { uasort($this->db, array($this, 'sortByPositionLowToHigh')); } return true; } - private function sortByPositionLowToHigh($a, $b) { + private function sortByPositionLowToHigh($a, $b) + { return $a['position']>$b['position']; } - private function sortByPositionHighToLow($a, $b) { + private function sortByPositionHighToLow($a, $b) + { return $a['position']<$b['position']; } @@ -425,17 +432,18 @@ class dbPages extends dbJSON { if($HighToLow) { uasort($this->db, array($this, 'sortByDateHighToLow')); - } - else { + } else { uasort($this->db, array($this, 'sortByDateLowToHigh')); } return true; } - private function sortByDateLowToHigh($a, $b) { + private function sortByDateLowToHigh($a, $b) + { return $a['date']>$b['date']; } - private function sortByDateHighToLow($a, $b) { + private function sortByDateHighToLow($a, $b) + { return $a['date']<$b['date']; } @@ -626,34 +634,6 @@ class dbPages extends dbJSON return Text::firstCharUp($field).': '.$value; } -/* DEPRECATED - public function getDBFields() - { - return $this->dbFields; - } -*/ - -/* DEPRECATED - public function parentKeyList() - { - return $this->parentKeyList; - } -*/ - -/* DEPRECATED - public function parentKeyExists($key) - { - return isset( $this->parentKeyList[$key] ); - } -*/ - -/* DEPRECATED - public function addParentKey($key) - { - $this->parentKeyList[$key] = $key; - } -*/ - // Returns the database public function getDB() { diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php index 29e9f8e3..d3d3c750 100644 --- a/bl-kernel/functions.php +++ b/bl-kernel/functions.php @@ -328,11 +328,11 @@ function createPage($args) { // Add to syslog $Syslog->add(array( - 'dictionaryKey'=>'new-page-created', + 'dictionaryKey'=>'new-content-created', 'notes'=>$args['title'] )); - Alert::set( $Language->g('new-page-created') ); + Alert::set( $Language->g('new-content-created') ); return $key; } @@ -391,7 +391,7 @@ function editPage($args) { // Add to syslog $Syslog->add(array( - 'dictionaryKey'=>'page-edited', + 'dictionaryKey'=>'content-edited', 'notes'=>$args['title'] )); @@ -418,7 +418,7 @@ function deletePage($key) { // Add to syslog $Syslog->add(array( - 'dictionaryKey'=>'page-deleted', + 'dictionaryKey'=>'content-deleted', 'notes'=>$key )); diff --git a/bl-languages/en.json b/bl-languages/en.json index 811f5d75..4d1cb319 100644 --- a/bl-languages/en.json +++ b/bl-languages/en.json @@ -43,7 +43,7 @@ "new-category": "New category", "you-do-not-have-sufficient-permissions": "You do not have sufficient permissions", "add-a-new-user": "Add a new user", - "url-associated-with-the-page": "URL associated with the page.", + "url-associated-with-the-content": "URL associated with the content.", "language-and-timezone": "Language and timezone", "change-your-language-and-region-settings": "Change your language and region settings.", "notifications": "Notifications", @@ -93,7 +93,7 @@ "username": "Username", "first-name": "First name", "last-name": "Last name", - "to-schedule-the-page-select-the-date-and-time": "To schedule the page select the date and time.", + "to-schedule-the-content-select-the-date-and-time": "To schedule the content select the date and time, the status has to be set to \"Published\".", "email": "Email", "role": "Role", "registered": "Registered", @@ -149,16 +149,16 @@ "number-of-items-to-show-per-page": "Number of items to show per page.", "website-or-blog": "Website or Blog", "scheduled-pages": "Scheduled pages", - "there-are-no-scheduled-pages": "There are no scheduled pages", - "there-are-no-draft-pages": "There are no draft pages", - "order-content-by": "Order content By", + "there-are-no-scheduled-pages": "There are no scheduled pages.", + "there-are-no-draft-pages": "There are no draft pages.", + "order-content-by": "Order content by", "edit-or-delete-content-from-your-site": "Edit or delete content from your site", - "order-the-content-by-position-to-build-a-website": "Order the content by position to build a Website or order the content by date to build a Blog.", + "order-the-content-by-date-to-build-a-blog": "Order the content by date to build a Blog or order the content by position to build a Website.", "page-not-found-content": "Hey! looks like the page doesn't exist.", "page-not-found": "Page not found", "predefined-pages": "Predefined pages", - "returning-page-when-the-page-doesnt-exist": "Returning page when the page doesn't exist, leave it blank if you want to returns a default message.", - "returning-page-for-the-main-page": "Returning page for the main page, leave it blank if you want to show all the pages on the main page.", + "returning-page-when-the-page-doesnt-exist": "Returning page when the page doesn't exist, by default returns a default message.", + "returning-page-for-the-main-page": "Returning page for the main page, by default shows the latest content order by date or position.", "full-url-of-your-site": "Full URL of your site. Complete with the protocol HTTP or HTTPS (only if you have enabled SSL on your server).", "with-the-locales-you-can-set-the-regional-user-interface": "With the locales, you can set the regional user interface, such as the dates in your language. The locales need to be installed on your system.", "bludit-installer": "Bludit Installer", @@ -211,7 +211,6 @@ "create-a-new-category-to-organize-your-pages": "Create a new category to organize your pages", "edit-or-delete-pages-from-your-site": "Edit or delete pages from your site", "add-new-page": "Add new page", - "this-field-is-used-when-you-order-the-pages-by-position": "This field is used when you order the pages by position.", "about-your-site-or-yourself": "About your site or yourself", "homepage": "Homepage", "disabled": "Disabled", @@ -223,11 +222,24 @@ "page-edited": "Page edited", "the-password-and-confirmation-password-do-not-match": "The password and confirmation password do not match", "scheduled-content": "Scheduled content", - "there-are-no-scheduled-content": "There are no scheduled content", + "there-are-no-scheduled-content": "There are no scheduled content.", "new-content-created": "New content created", "content-edited": "Content edited", "content-deleted": "Contente deleted", "undefined": "Undefined", "create-new-content-for-your-site": "Create new content for your site", - "there-are-no-draft-content": "There are no draft content" + "there-are-no-draft-content": "There are no draft content.", + "order-the-pages-by-date-to-build-a-blog": "Order the pages by date to build a Blog or order the pages by position to build a Website.", + "order-items-by": "Order items by", + "all-pages": "All pages", + "dynamic": "Dynamic", + "type": "Type", + "draft-content": "Draft content", + "post": "Post", + "page": "Page", + "default": "Default", + "latest-content": "Latest content", + "default-message": "Default message", + "no-parent": "No parent", + "have-you-seen-my-ball": "Have you seen my ball?" } \ No newline at end of file diff --git a/bl-plugins/menu/languages/en.json b/bl-plugins/menu/languages/en.json index eb82ee39..9be381d8 100644 --- a/bl-plugins/menu/languages/en.json +++ b/bl-plugins/menu/languages/en.json @@ -2,6 +2,6 @@ "plugin-data": { "name": "Menu", - "description": "Shows a menu on the sidebar, organized by categories and pages." + "description": "Shows a menu on the sidebar and the content organized by categories." } } \ No newline at end of file diff --git a/bl-plugins/simplemde/plugin.php b/bl-plugins/simplemde/plugin.php index 8eb0dcc2..5aaf7445 100644 --- a/bl-plugins/simplemde/plugin.php +++ b/bl-plugins/simplemde/plugin.php @@ -3,8 +3,8 @@ class pluginsimpleMDE extends Plugin { private $loadOnController = array( - 'new-page', - 'edit-page' + 'new-content', + 'edit-content' ); public function init() diff --git a/bl-plugins/tinymce/languages/en.json b/bl-plugins/tinymce/languages/en.json index 62d8e4d7..7c8e887a 100644 --- a/bl-plugins/tinymce/languages/en.json +++ b/bl-plugins/tinymce/languages/en.json @@ -2,6 +2,6 @@ "plugin-data": { "name": "TinyMCE", - "description": "HTML Editor for formatting content. This plugin needs a license, there are free and paid.
    Read more about on Tinymce." + "description": "HTML Editor for formatting content. This plugin needs a license, there are free and paid.
    Read more about it on Tinymce." } } \ No newline at end of file diff --git a/bl-plugins/tinymce/plugin.php b/bl-plugins/tinymce/plugin.php index 2d3281e5..91ab49c0 100644 --- a/bl-plugins/tinymce/plugin.php +++ b/bl-plugins/tinymce/plugin.php @@ -3,8 +3,8 @@ class pluginTinymce extends Plugin { private $loadOnController = array( - 'new-page', - 'edit-page' + 'new-content', + 'edit-content' ); public function adminHead()
p('Pages') ?>p('Content') ?> count() ?>