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',
|
2017-06-22 00:21:08 +02:00
|
|
|
'homeLink'=>true
|
2017-06-20 23:56:22 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-06-22 00:21:08 +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>';
|
2017-06-22 00:21:08 +02:00
|
|
|
$html .= '<input id="jslabel" name="label" type="text" value="'.$this->getValue('label').'">';
|
2017-09-09 00:33:14 +02:00
|
|
|
$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>';
|
2017-06-22 00:21:08 +02:00
|
|
|
$html .= '<label>'.$Language->get('Home link').'</label>';
|
|
|
|
$html .= '<select name="homeLink">';
|
2018-01-15 17:21:14 +01:00
|
|
|
$html .= '<option value="true" '.($this->getValue('homeLink')?'checked':'').'>Enabled</option>';
|
|
|
|
$html .= '<option value="false" '.($this->getValue('homeLink')?'checked':'').'>Disabled</option>';
|
2017-06-20 23:56:22 +02:00
|
|
|
$html .= '</select>';
|
2017-06-22 00:21:08 +02:00
|
|
|
$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;
|
2017-06-22 00:21:08 +02:00
|
|
|
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>';
|
|
|
|
|
2017-06-22 00:21:08 +02:00
|
|
|
// Show Home page link
|
2017-12-28 20:10:56 +01:00
|
|
|
if ($this->getValue('homeLink')) {
|
2017-06-22 00:21:08 +02:00
|
|
|
$html .= '<li>';
|
|
|
|
$html .= '<a href="'.$Site->url().'">';
|
|
|
|
$html .= $Language->get('Home page');
|
|
|
|
$html .= '</a>';
|
|
|
|
$html .= '</li>';
|
|
|
|
}
|
2017-06-20 23:56:22 +02:00
|
|
|
|
2017-06-22 00:21:08 +02:00
|
|
|
// Get keys of pages
|
2017-12-28 20:10:56 +01:00
|
|
|
foreach ($pages as $pageKey) {
|
2017-06-22 00:21:08 +02:00
|
|
|
// Create the page object from the page key
|
|
|
|
$page = buildPage($pageKey);
|
2017-06-20 23:56:22 +02:00
|
|
|
$html .= '<li>';
|
2017-06-22 00:21:08 +02:00
|
|
|
$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;
|
|
|
|
}
|
2018-01-15 17:21:14 +01:00
|
|
|
}
|