2015-07-07 01:24:51 -03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class pluginPages extends Plugin {
|
|
|
|
|
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
$this->dbFields = array(
|
2016-06-04 22:31:07 -03:00
|
|
|
'homeLink'=>1,
|
2016-11-23 19:59:02 +03:00
|
|
|
'children'=>1,
|
2015-08-01 13:28:47 -03:00
|
|
|
'label'=>'Pages'
|
2015-07-07 01:24:51 -03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-07-13 23:16:28 -03:00
|
|
|
public function form()
|
|
|
|
{
|
|
|
|
global $Language;
|
|
|
|
|
|
|
|
$html = '<div>';
|
2015-09-22 19:41:10 -03:00
|
|
|
$html .= '<label>'.$Language->get('Plugin label').'</label>';
|
2015-08-01 13:28:47 -03:00
|
|
|
$html .= '<input name="label" id="jslabel" type="text" value="'.$this->getDbField('label').'">';
|
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
$html .= '<div>';
|
2016-06-04 22:31:07 -03:00
|
|
|
$html .= '<input type="hidden" name="homeLink" value="0">';
|
|
|
|
$html .= '<input name="homeLink" id="jshomeLink" type="checkbox" value="1" '.($this->getDbField('homeLink')?'checked':'').'>';
|
2015-07-13 23:16:28 -03:00
|
|
|
$html .= '<label class="forCheckbox" for="jshomeLink">'.$Language->get('Show home link').'</label>';
|
2015-08-01 13:28:47 -03:00
|
|
|
$html .= '</div>';
|
2016-11-09 00:56:41 +03:00
|
|
|
|
|
|
|
$html .= '<div>';
|
2016-11-23 19:59:02 +03:00
|
|
|
$html .= '<input type="hidden" name="children" value="0">';
|
|
|
|
$html .= '<input name="children" id="children" type="checkbox" value="1" '.($this->getDbField('children')?'checked':'').'>';
|
|
|
|
$html .= '<label class="forCheckbox" for="jschildren">'.$Language->get('Show children').'</label>';
|
2016-11-09 00:56:41 +03:00
|
|
|
$html .= '</div>';
|
2015-07-13 23:16:28 -03:00
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
2015-08-06 23:13:55 -03:00
|
|
|
public function siteSidebar()
|
2015-07-07 01:24:51 -03:00
|
|
|
{
|
|
|
|
global $Language;
|
|
|
|
global $pagesParents;
|
2015-09-08 19:40:25 +02:00
|
|
|
global $Site, $Url;
|
2015-09-09 23:33:31 -03:00
|
|
|
|
2015-07-07 01:24:51 -03:00
|
|
|
$html = '<div class="plugin plugin-pages">';
|
2015-09-07 21:51:48 -03:00
|
|
|
|
2015-09-20 18:46:50 -03:00
|
|
|
// Print the label if not empty.
|
2015-09-07 21:51:48 -03:00
|
|
|
$label = $this->getDbField('label');
|
|
|
|
if( !empty($label) ) {
|
|
|
|
$html .= '<h2>'.$label.'</h2>';
|
|
|
|
}
|
|
|
|
|
2015-07-07 01:24:51 -03:00
|
|
|
$html .= '<div class="plugin-content">';
|
2016-07-25 20:40:51 -03:00
|
|
|
$html .= '<ul class="parents">';
|
2015-07-07 01:24:51 -03:00
|
|
|
|
2015-09-20 18:46:50 -03:00
|
|
|
// Show home link ?
|
2015-07-13 23:16:28 -03:00
|
|
|
if($this->getDbField('homeLink')) {
|
2015-09-20 18:46:50 -03:00
|
|
|
$html .= '<li>';
|
|
|
|
$html .= '<a class="parent'.( ($Url->whereAmI()=='home')?' active':'').'" href="'.$Site->homeLink().'">'.$Language->get('Home').'</a>';
|
|
|
|
$html .= '</li>';
|
2015-07-13 23:16:28 -03:00
|
|
|
}
|
|
|
|
|
2015-09-20 18:46:50 -03:00
|
|
|
$parents = $pagesParents[NO_PARENT_CHAR];
|
2015-07-07 01:24:51 -03:00
|
|
|
foreach($parents as $parent)
|
|
|
|
{
|
2015-11-14 13:47:26 -03:00
|
|
|
// Check if the parent is published
|
|
|
|
if( $parent->published() )
|
2015-07-07 01:24:51 -03:00
|
|
|
{
|
2015-11-14 13:47:26 -03:00
|
|
|
// Print the parent
|
2016-07-25 20:40:51 -03:00
|
|
|
$html .= '<li class="parent">';
|
|
|
|
$html .= '<a class="parent'.( ($parent->key()==$Url->slug())?' active':'').'" href="'.$parent->permalink().'">'.$parent->title().'</a>';
|
2015-07-07 01:24:51 -03:00
|
|
|
|
2016-11-09 00:56:41 +03:00
|
|
|
// Show children elements?
|
2016-11-23 19:59:02 +03:00
|
|
|
if($this->getDbField('children')) {
|
2015-11-14 13:47:26 -03:00
|
|
|
|
2016-11-09 00:56:41 +03:00
|
|
|
// Check if the parent has children
|
|
|
|
if(isset($pagesParents[$parent->key()]))
|
2015-11-14 13:47:26 -03:00
|
|
|
{
|
2016-11-09 00:56:41 +03:00
|
|
|
$children = $pagesParents[$parent->key()];
|
|
|
|
|
|
|
|
// Print children
|
|
|
|
$html .= '<ul class="children">';
|
|
|
|
foreach($children as $child)
|
2015-11-14 13:47:26 -03:00
|
|
|
{
|
2016-11-09 00:56:41 +03:00
|
|
|
// Check if the child is published
|
|
|
|
if( $child->published() )
|
|
|
|
{
|
|
|
|
$html .= '<li class="child">';
|
|
|
|
$html .= '<a class="'.( ($child->key()==$Url->slug())?' active':'').'" href="'.$child->permalink().'">'.$child->title().'</a>';
|
|
|
|
$html .= '</li>';
|
|
|
|
}
|
2015-11-14 13:47:26 -03:00
|
|
|
}
|
2016-11-09 00:56:41 +03:00
|
|
|
$html .= '</ul>';
|
2015-11-14 13:47:26 -03:00
|
|
|
}
|
2016-11-09 00:56:41 +03:00
|
|
|
}
|
2016-09-27 20:49:58 -03:00
|
|
|
|
|
|
|
$html .= '</li>';
|
2015-07-07 01:24:51 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-27 20:49:58 -03:00
|
|
|
$html .= '</ul>';
|
2015-07-07 01:24:51 -03:00
|
|
|
$html .= '</div>';
|
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
2016-11-09 00:56:41 +03:00
|
|
|
}
|