2018-03-07 12:31:08 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class pluginStaticPages extends Plugin {
|
|
|
|
|
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
// Fields and default values for the database of this plugin
|
|
|
|
$this->dbFields = array(
|
|
|
|
'label'=>'Static Pages',
|
|
|
|
'homeLink'=>true
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Method called on the settings of the plugin on the admin area
|
|
|
|
public function form()
|
|
|
|
{
|
|
|
|
global $Language;
|
|
|
|
|
2018-07-02 00:24:53 +02:00
|
|
|
$html = '<div class="alert alert-primary" role="alert">';
|
|
|
|
$html .= $this->description();
|
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
$html .= '<div>';
|
2018-03-07 12:31:08 +01:00
|
|
|
$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>';
|
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
$html .= '<div>';
|
|
|
|
$html .= '<label>'.$Language->get('Home link').'</label>';
|
|
|
|
$html .= '<select name="homeLink">';
|
|
|
|
$html .= '<option value="true" '.($this->getValue('homeLink')===true?'selected':'').'>'.$Language->get('Enabled').'</option>';
|
|
|
|
$html .= '<option value="false" '.($this->getValue('homeLink')===false?'selected':'').'>'.$Language->get('Disabled').'</option>';
|
|
|
|
$html .= '</select>';
|
2018-07-02 00:24:53 +02:00
|
|
|
$html .= '<span class="tip">'.$Language->get('show-the-home-link-on-the-sidebar').'</span>';
|
2018-03-07 12:31:08 +01:00
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Method called on the sidebar of the website
|
|
|
|
public function siteSidebar()
|
|
|
|
{
|
|
|
|
global $Language;
|
|
|
|
global $Url;
|
|
|
|
global $Site;
|
|
|
|
global $dbPages;
|
|
|
|
|
|
|
|
// HTML for sidebar
|
|
|
|
$html = '<div class="plugin plugin-static-pages">';
|
|
|
|
|
|
|
|
// Print the label if not empty
|
|
|
|
$label = $this->getValue('label');
|
|
|
|
if (!empty($label)) {
|
|
|
|
$html .= '<h2 class="plugin-label">'.$label.'</h2>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$html .= '<div class="plugin-content">';
|
|
|
|
$html .= '<ul>';
|
|
|
|
|
|
|
|
// Show Home page link
|
|
|
|
if ($this->getValue('homeLink')) {
|
|
|
|
$html .= '<li>';
|
|
|
|
$html .= '<a href="' . $Site->url() . '">' . $Language->get('Home page') . '</a>';
|
|
|
|
$html .= '</li>';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Show static pages
|
2018-03-07 18:53:40 +01:00
|
|
|
$staticPages = buildStaticPages();
|
|
|
|
foreach ($staticPages as $page) {
|
|
|
|
$html .= '<li>';
|
|
|
|
$html .= '<a href="' . $page->permalink() . '">' . $page->title() . '</a>';
|
|
|
|
$html .= '</li>';
|
2018-03-07 12:31:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$html .= '</ul>';
|
|
|
|
$html .= '</div>';
|
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
}
|