bludit/plugins/tags/plugin.php

53 lines
1.0 KiB
PHP
Raw Normal View History

2015-08-29 07:02:09 +02:00
<?php
class pluginTags extends Plugin {
public function init()
{
$this->dbFields = array(
'label'=>'Tags'
);
}
public function form()
{
global $Language;
$html = '<div>';
$html .= '<label>'.$Language->get('Plugin label').'</label>';
2015-08-29 07:02:09 +02:00
$html .= '<input name="label" id="jslabel" type="text" value="'.$this->getDbField('label').'">';
$html .= '</div>';
return $html;
}
public function siteSidebar()
{
global $Language;
global $dbTags;
2015-08-29 20:07:47 +02:00
global $Url;
2015-08-29 07:02:09 +02:00
2015-08-30 01:26:46 +02:00
$db = $dbTags->db['postsIndex'];
2015-09-08 02:51:48 +02:00
$filter = $Url->filters('tag');
2015-08-30 01:26:46 +02:00
2015-08-29 07:02:09 +02:00
$html = '<div class="plugin plugin-tags">';
$html .= '<h2>'.$this->getDbField('label').'</h2>';
$html .= '<div class="plugin-content">';
$html .= '<ul>';
foreach($db as $tagKey=>$fields)
{
$count = $dbTags->countPostsByTag($tagKey);
// Print the parent
2015-08-30 01:26:46 +02:00
$html .= '<li><a href="'.HTML_PATH_ROOT.$filter.'/'.$tagKey.'">'.$fields['name'].' ('.$count.')</a></li>';
2015-08-29 07:02:09 +02:00
}
$html .= '</ul>';
$html .= '</div>';
$html .= '</div>';
return $html;
}
}