bludit/bl-plugins/pages/plugin.php

71 lines
1.9 KiB
PHP
Raw Normal View History

2015-07-07 06:24:51 +02:00
<?php
class pluginPages extends Plugin {
public function init()
{
// Fields and default values for the database of this plugin
2015-07-07 06:24:51 +02:00
$this->dbFields = array(
'label'=>'Pages',
'homeLink'=>true,
'children'=>true
2015-07-07 06:24:51 +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>';
$html .= '<label>'.$Language->get('Label').'</label>';
$html .= '<input id="jslabel" name="label" type="text" value="'.$this->getValue('label').'">';
2015-08-01 18:28:47 +02:00
$html .= '</div>';
$html .= '<div>';
$html .= '<input type="hidden" name="homeLink" value="0">';
$html .= '<input id="jshomeLink" name="homeLink" type="checkbox" value="true" '.($this->getValue('homeLink')?'checked':'').'>';
2015-07-14 04:16:28 +02:00
$html .= '<label class="forCheckbox" for="jshomeLink">'.$Language->get('Show home link').'</label>';
2015-08-01 18:28:47 +02:00
$html .= '</div>';
2016-11-08 22:56:41 +01:00
$html .= '<div>';
$html .= '<input type="hidden" name="children" value="0">';
$html .= '<input id="jschildren" name="children" type="checkbox" value="true" '.($this->getValue('children')?'checked':'').'>';
$html .= '<label class="forCheckbox" for="jschildren">'.$Language->get('Show children').'</label>';
2016-11-08 22:56:41 +01:00
$html .= '</div>';
2015-07-14 04:16:28 +02:00
return $html;
}
// 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;
global $pages;
global $Url;
2015-09-08 02:51:48 +02:00
// URL base filter for categories
$filter = $Url->filters('page');
2015-09-08 02:51:48 +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">';
$html .= '<ul>';
2015-07-07 06:24:51 +02:00
// By default the database of categories are alphanumeric sorted
foreach( $pages as $page ) {
2015-09-20 23:46:50 +02:00
$html .= '<li>';
$html .= '<a href="'.DOMAIN_BASE.$filter.'/'.$page->key().'">';
$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;
}
}