'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 .= '';
$html .= '
';
$html .= '';
$html .= '';
$html .= '
';
$html .= '
';
$html .= '';
$html .= '';
$html .= '
';
$html .= '
';
$html .= '';
$html .= '
';
// LIST OF PAGES
$html .= '';
$jsondb = $this->getValue('jsondb', $unsanitized=false);
$pagesFixed = json_decode($jsondb, true);
foreach($pagesFixed as $pageKey=>$pageTitle) {
$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 .= '
';
// Get the JSON DB, getValue() with the option unsanitized HTML code
$jsondb = $this->getValue('jsondb', false);
$pagesFixed = json_decode($jsondb);
// By default the database of categories are alphanumeric sorted
foreach($pagesFixed as $key=>$title) {
$html .= '