2015-07-07 06:24:51 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class pluginPages extends Plugin {
|
|
|
|
|
|
|
|
public function init()
|
|
|
|
{
|
2017-05-27 19:46:46 +02:00
|
|
|
// Fields and default values for the database of this plugin
|
2015-07-07 06:24:51 +02:00
|
|
|
$this->dbFields = array(
|
2017-05-27 19:46:46 +02:00
|
|
|
'label'=>'Pages',
|
|
|
|
'homeLink'=>true,
|
2017-05-29 23:56:07 +02:00
|
|
|
'amountOfItems'=>5
|
2015-07-07 06:24:51 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-05-27 19:46:46 +02:00
|
|
|
// Method called on the settings of the plugin on the admin area
|
2015-07-14 04:16:28 +02:00
|
|
|
public function form()
|
|
|
|
{
|
|
|
|
global $Language;
|
|
|
|
|
|
|
|
$html = '<div>';
|
2017-05-27 19:46:46 +02:00
|
|
|
$html .= '<label>'.$Language->get('Label').'</label>';
|
|
|
|
$html .= '<input id="jslabel" name="label" type="text" value="'.$this->getValue('label').'">';
|
2017-06-18 22:44:07 +02:00
|
|
|
$html .= '<span class="tip">'.$Language->get('Title of the plugin for the sidebar').'</span>';
|
2015-08-01 18:28:47 +02:00
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
$html .= '<div>';
|
2017-06-18 22:44:07 +02:00
|
|
|
$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>';
|
|
|
|
$html .= '</select>';
|
|
|
|
$html .= '<span class="tip">'.$Language->get('Show the home link on the sidebar').'</span>';
|
2015-08-01 18:28:47 +02:00
|
|
|
$html .= '</div>';
|
2017-05-27 19:46:46 +02:00
|
|
|
|
2016-11-08 22:56:41 +01:00
|
|
|
$html .= '<div>';
|
2017-06-18 22:44:07 +02:00
|
|
|
$html .= '<label>'.$Language->get('Amount of items').'</label>';
|
|
|
|
$html .= '<input id="jsamountOfItems" name="amountOfItems" type="text" value="'.$this->getValue('amountOfItems').'">';
|
2016-11-08 22:56:41 +01:00
|
|
|
$html .= '</div>';
|
2015-07-14 04:16:28 +02:00
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
2017-05-27 19:46:46 +02:00
|
|
|
// Method called on the sidebar of the website
|
2015-08-07 04:13:55 +02:00
|
|
|
public function siteSidebar()
|
2015-07-07 06:24:51 +02:00
|
|
|
{
|
|
|
|
global $Language;
|
2017-05-27 19:46:46 +02:00
|
|
|
global $Url;
|
2017-05-31 20:17:21 +02:00
|
|
|
global $Site;
|
|
|
|
global $dbPages;
|
2015-09-08 02:51:48 +02:00
|
|
|
|
2017-05-29 23:56:07 +02:00
|
|
|
// Amount of pages to show
|
|
|
|
$amountOfItems = $this->getValue('amountOfItems');
|
|
|
|
|
2017-05-31 20:17:21 +02:00
|
|
|
// Page number the first one
|
|
|
|
$pageNumber = 1;
|
|
|
|
|
|
|
|
// Only published pages
|
|
|
|
$onlyPublished = true;
|
|
|
|
|
|
|
|
// Get the list of pages
|
|
|
|
$pages = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished, true);
|
2017-05-29 23:56:07 +02:00
|
|
|
|
2017-05-27 19:46:46 +02:00
|
|
|
// HTML for sidebar
|
|
|
|
$html = '<div class="plugin plugin-pages">';
|
|
|
|
$html .= '<h2 class="plugin-label">'.$this->getValue('label').'</h2>';
|
2015-07-07 06:24:51 +02:00
|
|
|
$html .= '<div class="plugin-content">';
|
2017-05-27 19:46:46 +02:00
|
|
|
$html .= '<ul>';
|
2015-07-07 06:24:51 +02:00
|
|
|
|
2017-05-29 23:56:07 +02:00
|
|
|
// Show Home page link
|
|
|
|
if( $this->getValue('homeLink') ) {
|
|
|
|
$html .= '<li>';
|
2017-05-31 20:17:21 +02:00
|
|
|
$html .= '<a href="'.$Site->url().'">';
|
2017-05-29 23:56:07 +02:00
|
|
|
$html .= $Language->get('Home page');
|
|
|
|
$html .= '</a>';
|
|
|
|
$html .= '</li>';
|
|
|
|
}
|
|
|
|
|
2017-06-04 21:08:31 +02:00
|
|
|
// Get keys of pages
|
|
|
|
$keys = array_keys($pages);
|
|
|
|
foreach($keys as $pageKey) {
|
2017-05-31 20:17:21 +02:00
|
|
|
// Create the page object from the page key
|
|
|
|
$page = buildPage($pageKey);
|
2015-09-20 23:46:50 +02:00
|
|
|
$html .= '<li>';
|
2017-05-31 20:17:21 +02:00
|
|
|
$html .= '<a href="'.$page->permalink().'">';
|
2017-05-27 19:46:46 +02:00
|
|
|
$html .= $page->title();
|
|
|
|
$html .= '</a>';
|
2015-09-20 23:46:50 +02:00
|
|
|
$html .= '</li>';
|
2015-07-14 04:16:28 +02:00
|
|
|
}
|
|
|
|
|
2016-09-28 01:49:58 +02:00
|
|
|
$html .= '</ul>';
|
2015-07-07 06:24:51 +02:00
|
|
|
$html .= '</div>';
|
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
2017-05-27 19:46:46 +02:00
|
|
|
}
|