'https://bludit.com',
'Donate'=>'https://paypal.me/bludit'
));
// Fields and default values for the database of this plugin
$this->dbFields = array(
'label'=>'Links',
'jsondb'=>$jsondb
);
$this->formButtons = false;
}
// Method called when a POST request is sent
public function post()
{
// Get current jsondb value from database
$jsondb = $this->getValue('jsondb', $unsanitized=false);
// Convert JSON to Array
$links = json_decode($jsondb, true);
if( isset($_POST['deleteLink']) ) {
// Values from $_POST
$name = $_POST['deleteLink'];
// Delete the link
unset($links[$name]);
}
elseif( isset($_POST['addLink']) ) {
// Values from $_POST
$name = $_POST['linkName'];
$url = $_POST['linkURL'];
// Check empty string
if( empty($name) ) { return false; }
// Add the link
$links[$name] = $url;
}
// Sanitize the new values and replace the current values of the database
$this->db['label'] = Sanitize::html($_POST['label']);
$this->db['jsondb'] = Sanitize::html(json_encode($links));
// Save the database
return $this->save();
}
// Method called on plugin settings on the admin area
public function form()
{
global $Language;
$html = '
';
$html .= '';
$html .= '';
$html .= ''.$Language->get('Title of the plugin for the sidebar').'';
$html .= '
';
$html .= '
';
$html .= '';
$html .= '
';
// New link, when the user click on save button this call the method post()
// and the new link is added to the database
$html .= '';
$html .= '
';
$html .= '';
$html .= '';
$html .= '
';
$html .= '
';
$html .= '';
$html .= '';
$html .= '
';
$html .= '
';
$html .= '';
$html .= '
';
$html .= '';
// Get the JSON DB, getValue() with the option unsanitized HTML code
$jsondb = $this->getValue('jsondb', $unsanitized=false);
$links = json_decode($jsondb, true);
foreach($links as $name=>$url) {
$html .= '
';
$html .= '';
$html .= '';
$html .= '
';
$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 .= '
';
// Get the JSON DB, getValue() with the option unsanitized HTML code
$jsondb = $this->getValue('jsondb', false);
$links = json_decode($jsondb);
// By default the database of categories are alphanumeric sorted
foreach( $links as $name=>$url ) {
$html .= '