bludit/bl-plugins/static-pages/plugin.php

79 lines
2.1 KiB
PHP
Raw Normal View History

2017-06-20 23:56:22 +02:00
<?php
2017-09-21 21:55:19 +02:00
class pluginStaticPages extends Plugin {
2017-06-20 23:56:22 +02:00
public function init()
{
// Fields and default values for the database of this plugin
$this->dbFields = array(
2017-09-21 21:55:19 +02:00
'label'=>'Static Pages',
'homeLink'=>true
2017-06-20 23:56:22 +02:00
);
}
// Method called on the settings of the plugin on the admin area
2017-06-20 23:56:22 +02:00
public function form()
{
global $Language;
$html = '<div>';
$html .= '<label>'.$Language->get('Label').'</label>';
$html .= '<input id="jslabel" name="label" type="text" value="'.$this->getValue('label').'">';
$html .= '<span class="tip">'.$Language->get('This title is almost always used in the sidebar of the site').'</span>';
2017-06-20 23:56:22 +02:00
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$Language->get('Home link').'</label>';
$html .= '<select name="homeLink">';
$html .= '<option value="true" '.($this->getValue('showCero')?'checked':'').'>Enabled</option>';
$html .= '<option value="false" '.($this->getValue('showCero')?'checked':'').'>Disabled</option>';
2017-06-20 23:56:22 +02:00
$html .= '</select>';
$html .= '<span class="tip">'.$Language->get('Show the home link on the sidebar').'</span>';
2017-06-20 23:56:22 +02:00
$html .= '</div>';
return $html;
}
// Method called on the sidebar of the website
public function siteSidebar()
{
global $Language;
global $Url;
global $Site;
global $dbPages;
2017-12-26 17:45:02 +01:00
$pages = $dbPages->getStaticDB(true);
2017-06-20 23:56:22 +02:00
// HTML for sidebar
$html = '<div class="plugin plugin-pages">';
$html .= '<h2 class="plugin-label">'.$this->getValue('label').'</h2>';
$html .= '<div class="plugin-content">';
$html .= '<ul>';
// Show Home page link
2017-12-28 20:10:56 +01:00
if ($this->getValue('homeLink')) {
$html .= '<li>';
$html .= '<a href="'.$Site->url().'">';
$html .= $Language->get('Home page');
$html .= '</a>';
$html .= '</li>';
}
2017-06-20 23:56:22 +02:00
// Get keys of pages
2017-12-28 20:10:56 +01:00
foreach ($pages as $pageKey) {
// Create the page object from the page key
$page = buildPage($pageKey);
2017-06-20 23:56:22 +02:00
$html .= '<li>';
$html .= '<a href="'.$page->permalink().'">';
$html .= $page->title();
2017-06-20 23:56:22 +02:00
$html .= '</a>';
$html .= '</li>';
}
$html .= '</ul>';
$html .= '</div>';
$html .= '</div>';
return $html;
}
}