Fix select box static pages plugin
This commit is contained in:
parent
b740e660b8
commit
f60e1bdac6
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user