2017-05-27 19:46:46 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class pluginCategories extends Plugin {
|
|
|
|
|
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
// Fields and default values for the database of this plugin
|
|
|
|
$this->dbFields = array(
|
2017-06-05 18:52:13 +02:00
|
|
|
'label'=>'Categories',
|
2017-09-29 19:07:02 +02:00
|
|
|
'hideCero'=>true
|
2017-05-27 19:46:46 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Method called on the settings of the plugin on the admin area
|
|
|
|
public function form()
|
|
|
|
{
|
|
|
|
global $Language;
|
|
|
|
|
|
|
|
$html = '<div>';
|
|
|
|
$html .= '<label>'.$Language->get('Label').'</label>';
|
2017-06-18 22:44:07 +02:00
|
|
|
$html .= '<input 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-05-27 19:46:46 +02:00
|
|
|
$html .= '</div>';
|
|
|
|
|
2017-06-05 18:52:13 +02:00
|
|
|
$html .= '<div>';
|
2017-09-29 19:07:02 +02:00
|
|
|
$html .= '<label>'.$Language->get('Hide Categories without content').'</label>';
|
|
|
|
$html .= '<select name="hideCero">';
|
|
|
|
$html .= '<option value="true" '.($this->getValue('hideCero')===true?'selected':'').'>'.$Language->get('Enabled').'</option>';
|
|
|
|
$html .= '<option value="false" '.($this->getValue('hideCero')===false?'selected':'').'>'.$Language->get('Disabled').'</option>';
|
2017-06-18 22:44:07 +02:00
|
|
|
$html .= '</select>';
|
2017-06-05 18:52:13 +02:00
|
|
|
$html .= '</div>';
|
|
|
|
|
2017-05-27 19:46:46 +02:00
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Method called on the sidebar of the website
|
|
|
|
public function siteSidebar()
|
|
|
|
{
|
|
|
|
global $Language;
|
|
|
|
global $dbCategories;
|
|
|
|
|
|
|
|
// HTML for sidebar
|
|
|
|
$html = '<div class="plugin plugin-categories">';
|
|
|
|
$html .= '<h2 class="plugin-label">'.$this->getValue('label').'</h2>';
|
|
|
|
$html .= '<div class="plugin-content">';
|
|
|
|
$html .= '<ul>';
|
|
|
|
|
|
|
|
// By default the database of categories are alphanumeric sorted
|
2017-09-29 19:07:02 +02:00
|
|
|
foreach ($dbCategories->db as $key=>$fields) {
|
2017-06-05 18:52:13 +02:00
|
|
|
$count = count($fields['list']);
|
2017-09-29 19:07:02 +02:00
|
|
|
if (!$this->getValue('hideCero') || $count>0) {
|
2017-06-05 18:52:13 +02:00
|
|
|
$html .= '<li>';
|
2017-06-09 20:30:13 +02:00
|
|
|
$html .= '<a href="'.DOMAIN_CATEGORIES.$key.'">';
|
2017-06-05 18:52:13 +02:00
|
|
|
$html .= $fields['name'];
|
|
|
|
$html .= ' ('.count($fields['list']).')';
|
|
|
|
$html .= '</a>';
|
|
|
|
$html .= '</li>';
|
|
|
|
}
|
2017-05-27 19:46:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$html .= '</ul>';
|
|
|
|
$html .= '</div>';
|
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
}
|