diff --git a/bl-kernel/admin/views/settings-advanced.php b/bl-kernel/admin/views/settings-advanced.php index febae635..3a4bcc70 100644 --- a/bl-kernel/admin/views/settings-advanced.php +++ b/bl-kernel/admin/views/settings-advanced.php @@ -39,42 +39,6 @@ HTML::formOpen(array('class'=>'uk-form-horizontal')); 'tip'=>$L->g('Order the content by date to create a Blog or order the content by position to create a Website') )); - HTML::legend(array('value'=>$L->g('Special content'))); - - $options = array(); - foreach($dbPages->db as $key=>$fields) { - $page = buildPage($key); - $options[$key] = $page->title(); - } - HTML::formSelect(array( - 'name'=>'pageError', - 'label'=>$L->g('404 Page Not Found'), - 'options'=>$options, - 'selected'=>$Site->pageError(), - 'class'=>'uk-width-1-3 uk-form-medium', - 'tip'=>$L->g('This page is showed only when the page does not exist anymore') - )); - - HTML::formSelect(array( - 'name'=>'pageAbout', - 'label'=>$L->g('About page'), - 'options'=>$options, - 'addEmptySpace'=>true, - 'selected'=>$Site->pageAbout(), - 'class'=>'uk-width-1-3 uk-form-medium', - 'tip'=>$L->g('This page is to define a history about you or the content of your site') - )); - - HTML::formSelect(array( - 'name'=>'pageContact', - 'label'=>$L->g('Contact page'), - 'options'=>$options, - 'addEmptySpace'=>true, - 'selected'=>$Site->pageContact(), - 'class'=>'uk-width-1-3 uk-form-medium', - 'tip'=>$L->g('Page for contact information') - )); - HTML::legend(array('value'=>$L->g('Email account settings'))); HTML::formInputText(array( diff --git a/bl-kernel/dbpages.class.php b/bl-kernel/dbpages.class.php index a014025b..7ebdc266 100644 --- a/bl-kernel/dbpages.class.php +++ b/bl-kernel/dbpages.class.php @@ -239,6 +239,23 @@ class dbPages extends dbJSON return true; } + // Change a value of a page + public function setField($key, $field, $value) + { + if( $this->exists($key) ) { + settype($value, gettype($this->dbFields[$field]['value'])); + $this->db[$key][$field] = $value; + return $this->save(); + } + + return false; + } + + public function setStatus($key, $value) + { + return $this->setField($key, 'status', $value); + } + // Returns a database with published pages public function getPublishedDB() { @@ -386,16 +403,7 @@ class dbPages extends dbJSON // ----- OLD - // Set a field of the database - public function setField($key, $field, $value) - { - if( $this->exists($key) ) { - settype($value, gettype($this->dbFields[$key]['value'])); - $this->db[$key][$field] = $value; - } - return false; - } diff --git a/bl-kernel/dbsite.class.php b/bl-kernel/dbsite.class.php index 4751502a..e93d1b51 100644 --- a/bl-kernel/dbsite.class.php +++ b/bl-kernel/dbsite.class.php @@ -27,10 +27,7 @@ class dbSite extends dbJSON 'googlePlus'=> array('inFile'=>false, 'value'=>''), 'instagram'=> array('inFile'=>false, 'value'=>''), 'github'=> array('inFile'=>false, 'value'=>''), - 'orderBy'=> array('inFile'=>false, 'value'=>'date'), // date or position - 'pageError'=> array('inFile'=>false, 'value'=>'error'), - 'pageAbout'=> array('inFile'=>false, 'value'=>'about'), - 'pageContact'=> array('inFile'=>false, 'value'=>'contact') + 'orderBy'=> array('inFile'=>false, 'value'=>'date') // date or position ); function __construct() diff --git a/bl-plugins/fixedPages/languages/en_US.json b/bl-plugins/fixedPages/languages/en_US.json new file mode 100644 index 00000000..422ab2b7 --- /dev/null +++ b/bl-plugins/fixedPages/languages/en_US.json @@ -0,0 +1,7 @@ +{ + "plugin-data": + { + "name": "Fixed Pages", + "description": "Show a list of links." + } +} diff --git a/bl-plugins/specialpages/metadata.json b/bl-plugins/fixedPages/metadata.json similarity index 100% rename from bl-plugins/specialpages/metadata.json rename to bl-plugins/fixedPages/metadata.json diff --git a/bl-plugins/fixedPages/plugin.php b/bl-plugins/fixedPages/plugin.php new file mode 100644 index 00000000..d3f56589 --- /dev/null +++ b/bl-plugins/fixedPages/plugin.php @@ -0,0 +1,174 @@ +'About' + )); + + // Fields and default values for the database of this plugin + $this->dbFields = array( + 'label'=>'Fixed Pages', + 'jsondb'=>$jsondb + ); + + // Disable default Save and Cancel button + $this->formButtons = false; + } + + // Method called when a POST request is sent + public function post() + { + global $dbPages; + + // Get current jsondb value from database + // All data stored in the database is html encoded + $jsondb = $this->db['jsondb']; + $jsondb = Sanitize::htmlDecode($jsondb); + + // Convert JSON to Array + $pagesFixed = json_decode($jsondb, true); + + // Check if the user click on the button delete or add + if( isset($_POST['delete']) ) { + // Values from $_POST + $pageKey = $_POST['delete']; + + // Change the status of the page from fixed to published + $dbPages->setStatus($pageKey, 'published'); + + // Delete the link from the array + unset($pagesFixed[$pageKey]); + } + elseif( isset($_POST['add']) ) { + // Values from $_POST + $pageTitle = $_POST['newPageTitle']; + $pageKey = $_POST['newPageKey']; + + // Change the status of the page from fixed to published + $dbPages->setStatus($pageKey, 'fixed'); + + // Add the link + $pagesFixed[$pageKey] = $pageTitle; + } + + // Encode html to store the values on the database + $this->db['label'] = Sanitize::html($_POST['label']); + $this->db['jsondb'] = Sanitize::html(json_encode($pagesFixed)); + + // Save the database + return $this->save(); + } + + // Method called on plugin settings on the admin area + public function form() + { + global $Language; + global $dbPages; + + $options = array(); + foreach($dbPages->db as $key=>$fields) { + $page = buildPage($key); + if($page->published()) { + $options[$key] = $page->title(); + } + } + + $html = '
'; + $html .= ''; + $html .= ''; + $html .= ''.$Language->get('Title of the plugin for the sidebar').''; + $html .= '
'; + + $html .= '
'; + $html .= ''; + $html .= '
'; + + // NEW PAGE + $html .= ''.$Language->get('New fixed page').''; + + $html .= '
'; + $html .= ''; + $html .= ''; + $html .= '
'; + + $html .= '
'; + $html .= ''; + $html .= ''; + $html .= '
'; + + $html .= '
'; + $html .= ''; + $html .= '
'; + + // LIST OF PAGES + $html .= ''.$Language->get('Fixed pages').''; + + $jsondb = $this->getValue('jsondb', $unsanitized=false); + $pagesFixed = json_decode($jsondb, true); + foreach($pagesFixed as $pageKey=>$pageTitle) { + $html .= '
'; + $html .= ''; + $html .= ''; + $html .= '
'; + + $page = buildPage($pageKey); + if($page) { + $title = $page->title(); + } else { + $title = $Language->get('Error page deleted'); + } + + $html .= '
'; + $html .= ''; + $html .= ''; + $html .= '
'; + + $html .= '
'; + $html .= ''; + $html .= '
'; + + $html .= '
'; + } + + return $html; + } + + // Method called on the sidebar of the website + public function siteSidebar() + { + global $Language; + + // HTML for sidebar + $html = '
'; + $html .= '

'.$this->getValue('label').'

'; + $html .= '
'; + $html .= ''; + $html .= '
'; + $html .= '
'; + + return $html; + } +} \ No newline at end of file diff --git a/bl-plugins/links/plugin.php b/bl-plugins/links/plugin.php index 589e5696..f35a01ff 100644 --- a/bl-plugins/links/plugin.php +++ b/bl-plugins/links/plugin.php @@ -16,6 +16,7 @@ class pluginLinks extends Plugin { 'jsondb'=>$jsondb ); + // Disable default Save and Cancel button $this->formButtons = false; } @@ -23,16 +24,19 @@ class pluginLinks extends Plugin { public function post() { // Get current jsondb value from database - $jsondb = $this->getValue('jsondb', $unsanitized=false); + // All data stored in the database is html encoded + $jsondb = $this->db['jsondb']; + $jsondb = Sanitize::htmlDecode($jsondb); // Convert JSON to Array $links = json_decode($jsondb, true); + // Check if the user click on the button delete or add if( isset($_POST['deleteLink']) ) { // Values from $_POST $name = $_POST['deleteLink']; - // Delete the link + // Delete the link from the array unset($links[$name]); } elseif( isset($_POST['addLink']) ) { @@ -47,7 +51,7 @@ class pluginLinks extends Plugin { $links[$name] = $url; } - // Sanitize the new values and replace the current values of the database + // Encode html to store the values on the database $this->db['label'] = Sanitize::html($_POST['label']); $this->db['jsondb'] = Sanitize::html(json_encode($links)); diff --git a/bl-plugins/specialpages/languages/bg_BG.json b/bl-plugins/specialpages/languages/bg_BG.json deleted file mode 100644 index 5893d2da..00000000 --- a/bl-plugins/specialpages/languages/bg_BG.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "plugin-data": - { - "name": "Страници", - "description": "Показва списък на страниците." - }, - - "home": "Начало", - "show-home-link": "Покажи връзка към начало", - "show-children": "Покажи подменю" -} diff --git a/bl-plugins/specialpages/languages/de_CH.json b/bl-plugins/specialpages/languages/de_CH.json deleted file mode 100644 index 063b55c5..00000000 --- a/bl-plugins/specialpages/languages/de_CH.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "plugin-data": - { - "name": "Menü aller Seiten", - "description": "Anzeige eines Menüs aller Seiten in der Seitenleiste (bei Themes mit Seitenleiste)." - }, - - "home": "Hauptseite", - "show-home-link": "Hauptseite zeigen" -} diff --git a/bl-plugins/specialpages/languages/de_DE.json b/bl-plugins/specialpages/languages/de_DE.json deleted file mode 100644 index 063b55c5..00000000 --- a/bl-plugins/specialpages/languages/de_DE.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "plugin-data": - { - "name": "Menü aller Seiten", - "description": "Anzeige eines Menüs aller Seiten in der Seitenleiste (bei Themes mit Seitenleiste)." - }, - - "home": "Hauptseite", - "show-home-link": "Hauptseite zeigen" -} diff --git a/bl-plugins/specialpages/languages/en_US.json b/bl-plugins/specialpages/languages/en_US.json deleted file mode 100644 index 16b9e567..00000000 --- a/bl-plugins/specialpages/languages/en_US.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "plugin-data": - { - "name": "Special pages", - "description": "Shows a list of pages, you can define the amount of items and the order depends of settings." - } -} diff --git a/bl-plugins/specialpages/languages/es_AR.json b/bl-plugins/specialpages/languages/es_AR.json deleted file mode 100644 index 6ee99a19..00000000 --- a/bl-plugins/specialpages/languages/es_AR.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "plugin-data": - { - "name": "Listado de páginas", - "description": "Muestra las paginas en orden según la posición." - }, - - "home": "Página de inicio", - "show-home-link": "Mostrar página de inicio" -} \ No newline at end of file diff --git a/bl-plugins/specialpages/languages/fr_FR.json b/bl-plugins/specialpages/languages/fr_FR.json deleted file mode 100644 index 3efb4769..00000000 --- a/bl-plugins/specialpages/languages/fr_FR.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "plugin-data": - { - "name": "Page navigation", - "description": "Constitue un menu avec les liens des pages dans la colonne du thème." - }, - - "home": "Accueil", - "show-home-link": "Afficher le lien de la page d’accueil" -} \ No newline at end of file diff --git a/bl-plugins/specialpages/languages/ja_JP.json b/bl-plugins/specialpages/languages/ja_JP.json deleted file mode 100644 index 613663ed..00000000 --- a/bl-plugins/specialpages/languages/ja_JP.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "plugin-data": - { - "name": "Page list", - "description": "ページをリストにして表示します。" - }, - - "home": "ホーム", - "show-home-link": "ホーム・リンクを表示" -} \ No newline at end of file diff --git a/bl-plugins/specialpages/languages/nl_NL.json b/bl-plugins/specialpages/languages/nl_NL.json deleted file mode 100644 index 0183d5c7..00000000 --- a/bl-plugins/specialpages/languages/nl_NL.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "plugin-data": - { - "name": "Pagina lijst", - "description": "Laat een lijst met alle pagina's op volgorde zien." - }, - - "home": "Home", - "show-home-link": "Laat de homepage link zien" -} diff --git a/bl-plugins/specialpages/languages/pl_PL.json b/bl-plugins/specialpages/languages/pl_PL.json deleted file mode 100644 index 74a469af..00000000 --- a/bl-plugins/specialpages/languages/pl_PL.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "plugin-data": - { - "name": "Lista stron", - "description": "Wyświetla listę stron znajdujących się w witrynie." - }, - - "home": "Strona główna", - "show-home-link": "Pokaż odnośnik do strony głównek" -} \ No newline at end of file diff --git a/bl-plugins/specialpages/languages/ru_RU.json b/bl-plugins/specialpages/languages/ru_RU.json deleted file mode 100644 index ab5a8045..00000000 --- a/bl-plugins/specialpages/languages/ru_RU.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "plugin-data": - { - "name": "Список страниц", - "description": "Показывает упорядоченый список страниц." - }, - - "home": "Главная", - "show-home-link": "Показывать ссылку на главную", - "show-children": "Показывать подменю" -} diff --git a/bl-plugins/specialpages/languages/tr_TR.json b/bl-plugins/specialpages/languages/tr_TR.json deleted file mode 100644 index 8a746a7d..00000000 --- a/bl-plugins/specialpages/languages/tr_TR.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "plugin-data": - { - "name": "Sayfa listesi", - "description": "Sayfaları listeler." - }, - - "home": "Anasayfa", - "show-home-link": "Anasayfa linkini göster" -} diff --git a/bl-plugins/specialpages/languages/uk_UA.json b/bl-plugins/specialpages/languages/uk_UA.json deleted file mode 100644 index 7fc77940..00000000 --- a/bl-plugins/specialpages/languages/uk_UA.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "plugin-data": - { - "name": "Список сторінок", - "description": "Показує список сторінок по порядку." - }, - - "home": "Головна", - "show-home-link": "Показувати лінк на головну сторінку", - "show-children": "Показувати вкладені лінки" -} diff --git a/bl-plugins/specialpages/languages/zh_TW.json b/bl-plugins/specialpages/languages/zh_TW.json deleted file mode 100644 index e5a6ccb2..00000000 --- a/bl-plugins/specialpages/languages/zh_TW.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "plugin-data": - { - "name": "頁面列表", - "description": "顯示所有頁面的列表" - }, - - "home": "首頁", - "show-home-link": "顯示首頁連結" -} \ No newline at end of file diff --git a/bl-plugins/specialpages/plugin.php b/bl-plugins/specialpages/plugin.php deleted file mode 100644 index e398664a..00000000 --- a/bl-plugins/specialpages/plugin.php +++ /dev/null @@ -1,135 +0,0 @@ -dbFields = array( - 'label'=>'Pages', - 'homeLink'=>true, - 'pageAboutLabel'=>'About', - 'pageAbout'=>'' - ); - } - - public function post() - { - - } - - // Method called on the settings of the plugin on the admin area - public function form() - { - global $Language; - global $dbPages; - - $html = '
'; - $html .= ''; - $html .= ''; - $html .= '
'; - - $html .= '
'; - $html .= ''; - $html .= 'getValue('homeLink')?'checked':'').'>'; - $html .= ''; - $html .= '
'; - - $options = array(); - foreach($dbPages->db as $key=>$fields) { - $page = buildPage($key); - $options[$key] = $page->title(); - } - - HTML::formOpen(array('class'=>'uk-form-horizontal')); - - HTML::legend(array('value'=>$Language->g('About page'))); - - HTML::formInputText(array( - 'name'=>'title', - 'label'=>$Language->g('Site title'), - 'value'=>'test', - 'class'=>'uk-width-1-2 uk-form-medium', - 'tip'=>$Language->g('use-this-field-to-name-your-site') - )); - - HTML::formClose(); - - $html .= 'About page'; - - $html .= '
'; - $html .= ''; - $html .= ''; - $html .= '
'; - - $html .= '
'; - $html .= ''; - $html .= ''; - $html .= '
'; - - $html .= '
'; - $html .= ''; - $html .= 'getValue('homeLink')?'checked':'').'>'; - $html .= ''; - $html .= '
'; - - $html .= 'Contact page'; - - $html .= '
'; - $html .= ''; - $html .= ''; - $html .= '
'; - - $html .= '
'; - $html .= ''; - $html .= ''; - $html .= '
'; - - return $html; - } - - // Method called on the sidebar of the website - public function siteSidebar() - { - global $Language; - - // HTML for sidebar - $html = '
'; - $html .= '

'.$this->getValue('label').'

'; - $html .= '
'; - $html .= ''; - $html .= '
'; - $html .= '
'; - - return $html; - } -} \ No newline at end of file