Merge f60e1bdac6eef3d665e76397ca0e61789a6b33be into bcc986fa118c755b9d9217ea7a953863cfbb31a3

This commit is contained in:
anaggh 2018-01-15 16:15:49 +00:00 committed by GitHub
commit 8e81787f40

View File

@ -1,79 +1,80 @@
<?php <?php
class pluginStaticPages extends Plugin { class pluginStaticPages extends Plugin
{
public function init() public function init()
{ {
// Fields and default values for the database of this plugin // Fields and default values for the database of this plugin
$this->dbFields = array( $this->dbFields = array(
'label'=>'Static Pages', 'label'=>'Static Pages',
'homeLink'=>true 'homeLink'=>true
); );
} }
// Method called on the settings of the plugin on the admin area // Method called on the settings of the plugin on the admin area
public function form() public function form()
{ {
global $Language; global $Language;
$html = '<div>'; $html = '<div>';
$html .= '<label>'.$Language->get('Label').'</label>'; $html .= '<label>'.$Language->get('Label').'</label>';
$html .= '<input id="jslabel" name="label" type="text" value="'.$this->getValue('label').'">'; $html .= '<input id="jslabel" name="label" type="text" value="'.$this->getValue('label').'">';
$html .= '<span class="tip">'.$Language->get('This title is almost always used in the sidebar of the site').'</span>'; $html .= '<span class="tip">'.$Language->get('This title is almost always used in the sidebar of the site').'</span>';
$html .= '</div>'; $html .= '</div>';
$html .= '<div>'; $html .= '<div>';
$html .= '<label>'.$Language->get('Home link').'</label>'; $html .= '<label>'.$Language->get('Home link').'</label>';
$html .= '<select name="homeLink">'; $html .= '<select name="homeLink">';
$html .= '<option value="true" '.($this->getValue('showCero')?'checked':'').'>Enabled</option>'; $html .= '<option value="true" '.($this->getValue('homeLink')?'selected':'').'>Enabled</option>';
$html .= '<option value="false" '.($this->getValue('showCero')?'checked':'').'>Disabled</option>'; $html .= '<option value="false" '.(!$this->getValue('homeLink')?'selected':'').'>Disabled</option>';
$html .= '</select>'; $html .= '</select>';
$html .= '<span class="tip">'.$Language->get('Show the home link on the sidebar').'</span>'; $html .= '<span class="tip">'.$Language->get('Show the home link on the sidebar').'</span>';
$html .= '</div>'; $html .= '</div>';
return $html; return $html;
} }
// Method called on the sidebar of the website // Method called on the sidebar of the website
public function siteSidebar() public function siteSidebar()
{ {
global $Language; global $Language;
global $Url; global $Url;
global $Site; global $Site;
global $dbPages; global $dbPages;
$pages = $dbPages->getStaticDB(true); $pages = $dbPages->getStaticDB(true);
// HTML for sidebar // HTML for sidebar
$html = '<div class="plugin plugin-pages">'; $html = '<div class="plugin plugin-pages">';
$html .= '<h2 class="plugin-label">'.$this->getValue('label').'</h2>'; $html .= '<h2 class="plugin-label">'.$this->getValue('label').'</h2>';
$html .= '<div class="plugin-content">'; $html .= '<div class="plugin-content">';
$html .= '<ul>'; $html .= '<ul>';
// Show Home page link // Show Home page link
if ($this->getValue('homeLink')) { if ($this->getValue('homeLink')) {
$html .= '<li>'; $html .= '<li>';
$html .= '<a href="'.$Site->url().'">'; $html .= '<a href="'.$Site->url().'">';
$html .= $Language->get('Home page'); $html .= $Language->get('Home page');
$html .= '</a>'; $html .= '</a>';
$html .= '</li>'; $html .= '</li>';
} }
// Get keys of pages // Get keys of pages
foreach ($pages as $pageKey) { foreach ($pages as $pageKey) {
// Create the page object from the page key // Create the page object from the page key
$page = buildPage($pageKey); $page = buildPage($pageKey);
$html .= '<li>'; $html .= '<li>';
$html .= '<a href="'.$page->permalink().'">'; $html .= '<a href="'.$page->permalink().'">';
$html .= $page->title(); $html .= $page->title();
$html .= '</a>'; $html .= '</a>';
$html .= '</li>'; $html .= '</li>';
} }
$html .= '</ul>'; $html .= '</ul>';
$html .= '</div>'; $html .= '</div>';
$html .= '</div>'; $html .= '</div>';
return $html; return $html;
} }
} }