2016-01-08 16:46:52 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class pluginLatestPosts extends Plugin {
|
|
|
|
|
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
$this->dbFields = array(
|
|
|
|
'label'=>'Latest posts',
|
|
|
|
'amount'=>5
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function form()
|
|
|
|
{
|
|
|
|
$html = '<div>';
|
2016-11-07 20:58:47 +01:00
|
|
|
$html .= '<label>'.$this->L('Plugin label').'</label>';
|
2016-01-08 16:46:52 +01:00
|
|
|
$html .= '<input name="label" id="jslabel" type="text" value="'.$this->getDbField('label').'">';
|
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
$html .= '<div>';
|
2016-11-07 20:58:47 +01:00
|
|
|
$html .= '<label>'.$this->L('Amount of posts').'</label>';
|
2016-01-08 16:46:52 +01:00
|
|
|
$html .= '<input name="amount" id="jsamount" type="text" value="'.$this->getDbField('amount').'">';
|
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function siteSidebar()
|
|
|
|
{
|
|
|
|
// This function is declared in 70.posts.php
|
|
|
|
$posts = buildPostsForPage(0, $this->getDbField('amount'), true, false);
|
|
|
|
|
|
|
|
$html = '<div class="plugin plugin-latest-posts">';
|
|
|
|
|
|
|
|
// Print the label if not empty.
|
|
|
|
$label = $this->getDbField('label');
|
|
|
|
if( !empty($label) ) {
|
|
|
|
$html .= '<h2 class="plugin-title">'.$label.'</h2>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$html .= '<div class="plugin-content">';
|
|
|
|
$html .= '<ul>';
|
|
|
|
|
|
|
|
foreach($posts as $Post)
|
|
|
|
{
|
|
|
|
$html .= '<li>';
|
|
|
|
$html .= '<a href="'.$Post->permalink().'">'.$Post->title().'</a>';
|
|
|
|
$html .= '</li>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$html .= '</ul>';
|
|
|
|
$html .= '</div>';
|
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
}
|