New plugins and plugins updated for v2.0
This commit is contained in:
parent
3df2370b12
commit
7d51652efc
|
@ -65,6 +65,8 @@ class dbList extends dbJSON
|
||||||
|
|
||||||
$this->db[$key]['name'] = $name;
|
$this->db[$key]['name'] = $name;
|
||||||
$this->db[$key]['list'] = array();
|
$this->db[$key]['list'] = array();
|
||||||
|
|
||||||
|
$this->sortAlphanumeric();
|
||||||
$this->save();
|
$this->save();
|
||||||
|
|
||||||
return $key;
|
return $key;
|
||||||
|
@ -93,10 +95,18 @@ class dbList extends dbJSON
|
||||||
unset( $this->db[$oldKey] );
|
unset( $this->db[$oldKey] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->sortAlphanumeric();
|
||||||
$this->save();
|
$this->save();
|
||||||
return $newKey;
|
return $newKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort the categories by "Natural order"
|
||||||
|
private function sortAlphanumeric()
|
||||||
|
{
|
||||||
|
// Sort key alphanumeric strings, a01, a10, b10, c02
|
||||||
|
return ksort($this->db);
|
||||||
|
}
|
||||||
|
|
||||||
// Returns the name associated to the key, FALSE if the key doesn't exist
|
// Returns the name associated to the key, FALSE if the key doesn't exist
|
||||||
public function getName($key)
|
public function getName($key)
|
||||||
{
|
{
|
||||||
|
@ -108,18 +118,13 @@ class dbList extends dbJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns an array with key=>name of the list
|
// Returns an array with key=>name of the list
|
||||||
public function getKeyNameArray($sortAlphanumeric=true)
|
public function getKeyNameArray()
|
||||||
{
|
{
|
||||||
$tmp = array();
|
$tmp = array();
|
||||||
foreach($this->db as $key=>$fields) {
|
foreach($this->db as $key=>$fields) {
|
||||||
$tmp[$key] = $fields['name'];
|
$tmp[$key] = $fields['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort alphanumeric strings, a01, a10, a11, a20
|
|
||||||
if($sortAlphanumeric) {
|
|
||||||
natcasesort($tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,26 @@ class Plugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setDb($args)
|
||||||
|
{
|
||||||
|
foreach($this->dbFields as $key=>$value) {
|
||||||
|
if( isset($args[$key]) ) {
|
||||||
|
$value = Sanitize::html( $args[$key] );
|
||||||
|
settype($value, gettype($this->dbFields[$key]));
|
||||||
|
$this->db[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function save()
|
||||||
|
{
|
||||||
|
$tmp = new dbJSON($this->filenameDb);
|
||||||
|
$tmp->db = $this->db;
|
||||||
|
$tmp->save();
|
||||||
|
}
|
||||||
|
|
||||||
public function htmlPath()
|
public function htmlPath()
|
||||||
{
|
{
|
||||||
return HTML_PATH_PLUGINS.$this->directoryName.'/';
|
return HTML_PATH_PLUGINS.$this->directoryName.'/';
|
||||||
|
@ -86,6 +106,22 @@ class Plugin {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns the value of the field from the database
|
||||||
|
// (string) $field
|
||||||
|
// (boolean) $html, TRUE returns the value sanitized, FALSE unsanitized
|
||||||
|
public function getValue($field, $html=true)
|
||||||
|
{
|
||||||
|
if( isset($this->db[$field]) ) {
|
||||||
|
if($html) {
|
||||||
|
return $this->db[$field];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return Sanitize::htmlDecode($this->db[$field]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDbField($key, $html=true)
|
public function getDbField($key, $html=true)
|
||||||
{
|
{
|
||||||
if(isset($this->db[$key])) {
|
if(isset($this->db[$key])) {
|
||||||
|
@ -103,33 +139,6 @@ class Plugin {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setDb($args)
|
|
||||||
{
|
|
||||||
$tmp = $this->db;
|
|
||||||
|
|
||||||
foreach($this->dbFields as $key=>$value)
|
|
||||||
{
|
|
||||||
if(isset($args[$key]))
|
|
||||||
{
|
|
||||||
// Sanitize value
|
|
||||||
$tmpValue = Sanitize::html( $args[$key] );
|
|
||||||
|
|
||||||
// Set type
|
|
||||||
settype($tmpValue, gettype($value));
|
|
||||||
|
|
||||||
// Set value
|
|
||||||
$tmp[$key] = $tmpValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->db = $tmp;
|
|
||||||
|
|
||||||
// Save db on file
|
|
||||||
$Tmp = new dbJSON($this->filenameDb);
|
|
||||||
$Tmp->db = $tmp;
|
|
||||||
$Tmp->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function name()
|
public function name()
|
||||||
{
|
{
|
||||||
return $this->getMetadata('name');
|
return $this->getMetadata('name');
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
if($Login->role()!=='admin') {
|
if($Login->role()!=='admin') {
|
||||||
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
||||||
Redirect::page('admin', 'dashboard');
|
Redirect::page('dashboard');
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
@ -16,24 +16,20 @@ if($Login->role()!=='admin') {
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Main before POST
|
// Main before POST
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
$_Plugin = false;
|
$plugin = false;
|
||||||
$pluginClassName = $layout['parameters'];
|
$pluginClassName = $layout['parameters'];
|
||||||
|
|
||||||
foreach($plugins['all'] as $P)
|
// Check if the plugin exists
|
||||||
{
|
if( isset($plugins['all'][$pluginClassName]) ) {
|
||||||
if($P->className()==$pluginClassName) {
|
$plugin = $plugins['all'][$pluginClassName];
|
||||||
$_Plugin = $P;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
// Check if the plugin exists.
|
Redirect::page('plugins');
|
||||||
if($_Plugin===false) {
|
|
||||||
Redirect::page('admin', 'plugins');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the plugin has the method form()
|
// Check if the plugin has the method form()
|
||||||
if(!method_exists($_Plugin, 'form')) {
|
if( !method_exists($plugin, 'form') ) {
|
||||||
Redirect::page('admin', 'plugins');
|
Redirect::page('plugins');
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
@ -42,11 +38,16 @@ if(!method_exists($_Plugin, 'form')) {
|
||||||
|
|
||||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||||
{
|
{
|
||||||
$_Plugin->setDb($_POST);
|
$plugin->setDb($_POST);
|
||||||
|
|
||||||
Theme::plugins('afterFormSave');
|
// Add to syslog
|
||||||
|
$Syslog->add(array(
|
||||||
|
'dictionaryKey'=>'plugin-configured',
|
||||||
|
'notes'=>$plugin->name()
|
||||||
|
));
|
||||||
|
|
||||||
Alert::set($Language->g('the-changes-have-been-saved'));
|
// Create an alert
|
||||||
|
Alert::set( $Language->g('The changes have been saved') );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
|
@ -112,4 +112,4 @@ if( !$dbPages->exists($layout['parameters']) ) {
|
||||||
Redirect::page('pages');
|
Redirect::page('pages');
|
||||||
}
|
}
|
||||||
|
|
||||||
$page = $pagesKey[$layout['parameters']];
|
$page = $pagesByKey[$layout['parameters']];
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
if($Login->role()!=='admin') {
|
if($Login->role()!=='admin') {
|
||||||
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
||||||
Redirect::page('admin', 'dashboard');
|
Redirect::page('dashboard');
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
@ -33,4 +33,4 @@ foreach($plugins['all'] as $P)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Redirect::page('admin', 'plugins');
|
Redirect::page('plugins');
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
if($Login->role()!=='admin') {
|
if($Login->role()!=='admin') {
|
||||||
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
||||||
Redirect::page('admin', 'dashboard');
|
Redirect::page('dashboard');
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
if($Login->role()!=='admin') {
|
if($Login->role()!=='admin') {
|
||||||
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
|
||||||
Redirect::page('admin', 'dashboard');
|
Redirect::page('dashboard');
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
@ -29,4 +29,4 @@ $pluginClassName = $layout['parameters'];
|
||||||
$Plugin = new $pluginClassName;
|
$Plugin = new $pluginClassName;
|
||||||
$Plugin->uninstall();
|
$Plugin->uninstall();
|
||||||
|
|
||||||
Redirect::page('admin', 'plugins');
|
Redirect::page('plugins');
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
HTML::title(array('title'=>$_Plugin->name(), 'icon'=>'puzzle-piece'));
|
HTML::title(array('title'=>$plugin->name(), 'icon'=>'puzzle-piece'));
|
||||||
|
|
||||||
HTML::formOpen(array('id'=>'jsformplugin'));
|
HTML::formOpen(array('id'=>'jsformplugin'));
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ HTML::formOpen(array('id'=>'jsformplugin'));
|
||||||
));
|
));
|
||||||
|
|
||||||
// Print the plugin form
|
// Print the plugin form
|
||||||
echo $_Plugin->form();
|
echo $plugin->form();
|
||||||
|
|
||||||
// Form buttons
|
// Form buttons
|
||||||
echo '<div class="uk-form-row uk-margin-bottom">
|
echo '<div class="uk-form-row uk-margin-bottom">
|
||||||
|
|
|
@ -136,7 +136,7 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
||||||
$options = array();
|
$options = array();
|
||||||
$parents = $dbPages->getParents(true);
|
$parents = $dbPages->getParents(true);
|
||||||
foreach( $parents as $key=>$fields ) {
|
foreach( $parents as $key=>$fields ) {
|
||||||
$options[$key] = $pagesKey[$key]->title();
|
$options[$key] = $pagesByKey[$key]->title();
|
||||||
}
|
}
|
||||||
|
|
||||||
HTML::formSelect(array(
|
HTML::formSelect(array(
|
||||||
|
|
|
@ -23,7 +23,6 @@ $plugins = array(
|
||||||
'adminSidebar'=>array(),
|
'adminSidebar'=>array(),
|
||||||
|
|
||||||
'beforeRulesLoad'=>array(),
|
'beforeRulesLoad'=>array(),
|
||||||
'afterFormSave'=>array(),
|
|
||||||
|
|
||||||
'afterPageCreate'=>array(),
|
'afterPageCreate'=>array(),
|
||||||
'afterPageModify'=>array(),
|
'afterPageModify'=>array(),
|
||||||
|
|
|
@ -17,7 +17,7 @@ $page = false;
|
||||||
//$pageParents = array();
|
//$pageParents = array();
|
||||||
|
|
||||||
// Array with all published pages, the array is a key=>Page-object
|
// Array with all published pages, the array is a key=>Page-object
|
||||||
$pagesKey = array();
|
$pagesByKey = array();
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Main
|
// Main
|
||||||
|
|
|
@ -117,7 +117,7 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false)
|
||||||
global $dbCategories;
|
global $dbCategories;
|
||||||
global $Site;
|
global $Site;
|
||||||
global $Url;
|
global $Url;
|
||||||
global $pagesKey;
|
global $pagesByKey;
|
||||||
global $pages;
|
global $pages;
|
||||||
|
|
||||||
// Get the page number from URL
|
// Get the page number from URL
|
||||||
|
@ -150,12 +150,12 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false)
|
||||||
}
|
}
|
||||||
|
|
||||||
$pages = array(); // global variable
|
$pages = array(); // global variable
|
||||||
$pagesKey = array(); // global variable
|
$pagesByKey = array(); // global variable
|
||||||
foreach($list as $pageKey=>$fields) {
|
foreach($list as $pageKey=>$fields) {
|
||||||
$page = buildPage($pageKey);
|
$page = buildPage($pageKey);
|
||||||
if($page!==false) {
|
if($page!==false) {
|
||||||
// $pagesKey
|
// $pagesByKey
|
||||||
$pagesKey[$pageKey] = $page;
|
$pagesByKey[$pageKey] = $page;
|
||||||
// $pages
|
// $pages
|
||||||
array_push($pages, $page);
|
array_push($pages, $page);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
"author": "Bludit",
|
"author": "Bludit",
|
||||||
"email": "",
|
"email": "",
|
||||||
"website": "https://plugins.bludit.com",
|
"website": "https://plugins.bludit.com",
|
||||||
"version": "1.5.2",
|
"version": "2.0",
|
||||||
"releaseDate": "2016-05-28",
|
"releaseDate": "2017-05-26",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"compatible": "1.5.2",
|
"compatible": "2.0",
|
||||||
"notes": ""
|
"notes": ""
|
||||||
}
|
}
|
|
@ -15,12 +15,13 @@ class pluginAbout extends Plugin {
|
||||||
global $Language;
|
global $Language;
|
||||||
|
|
||||||
$html = '<div>';
|
$html = '<div>';
|
||||||
$html .= '<label>'.$Language->get('Plugin label').'</label>';
|
$html .= '<label>'.$Language->get('Label').'</label>';
|
||||||
$html .= '<input name="label" id="jslabel" type="text" value="'.$this->getDbField('label').'">';
|
$html .= '<input id="jslabel" name="label" type="text" value="'.$this->getValue('label').'">';
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
|
|
||||||
$html .= '<div>';
|
$html .= '<div>';
|
||||||
$html .= '<label>'.$Language->get('About').'</label>';
|
$html .= '<label>'.$Language->get('About').'</label>';
|
||||||
$html .= '<textarea name="text" id="jstext">'.$this->getDbField('text').'</textarea>';
|
$html .= '<textarea name="text" id="jstext">'.$this->getValue('text').'</textarea>';
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
|
@ -29,12 +30,12 @@ class pluginAbout extends Plugin {
|
||||||
public function siteSidebar()
|
public function siteSidebar()
|
||||||
{
|
{
|
||||||
$html = '<div class="plugin plugin-about">';
|
$html = '<div class="plugin plugin-about">';
|
||||||
$html .= '<h2>'.$this->getDbField('label').'</h2>';
|
$html .= '<h2 class="plugin-label">'.$this->getValue('label').'</h2>';
|
||||||
$html .= '<div class="plugin-content">';
|
$html .= '<div class="plugin-content">';
|
||||||
$html .= html_entity_decode(nl2br($this->getDbField('text')));
|
$html .= html_entity_decode(nl2br($this->getValue('text')));
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"plugin-data":
|
||||||
|
{
|
||||||
|
"name": "Categories",
|
||||||
|
"description": "Shows all categories."
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"author": "Bludit",
|
||||||
|
"email": "",
|
||||||
|
"website": "https://plugins.bludit.com",
|
||||||
|
"version": "2.0",
|
||||||
|
"releaseDate": "2017-05-26",
|
||||||
|
"license": "MIT",
|
||||||
|
"compatible": "2.0",
|
||||||
|
"notes": ""
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class pluginCategories extends Plugin {
|
||||||
|
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
// Fields and default values for the database of this plugin
|
||||||
|
$this->dbFields = array(
|
||||||
|
'label'=>'Categories'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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>';
|
||||||
|
$html .= '<input id="jslabel" name="label" type="text" value="'.$this->getValue('label').'">';
|
||||||
|
$html .= '</div>';
|
||||||
|
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method called on the sidebar of the website
|
||||||
|
public function siteSidebar()
|
||||||
|
{
|
||||||
|
global $Language;
|
||||||
|
global $dbCategories;
|
||||||
|
global $Url;
|
||||||
|
|
||||||
|
// URL base filter for categories
|
||||||
|
$filter = $Url->filters('category');
|
||||||
|
|
||||||
|
// 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
|
||||||
|
foreach( $dbCategories->db as $key=>$fields ) {
|
||||||
|
$html .= '<li>';
|
||||||
|
$html .= '<a href="'.DOMAIN_BASE.$filter.'/'.$key.'">';
|
||||||
|
$html .= $fields['name'];
|
||||||
|
$html .= ' ('.count($fields['list']).')';
|
||||||
|
$html .= '</a>';
|
||||||
|
$html .= '</li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$html .= '</ul>';
|
||||||
|
$html .= '</div>';
|
||||||
|
$html .= '</div>';
|
||||||
|
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"plugin-data":
|
||||||
|
{
|
||||||
|
"name": "Menu",
|
||||||
|
"description": "Show a menu organized by categories and pages."
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"author": "Bludit",
|
||||||
|
"email": "",
|
||||||
|
"website": "https://plugins.bludit.com",
|
||||||
|
"version": "2.0",
|
||||||
|
"releaseDate": "2017-05-26",
|
||||||
|
"license": "MIT",
|
||||||
|
"compatible": "2.0",
|
||||||
|
"notes": ""
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class pluginMenu extends Plugin {
|
||||||
|
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
// Fields and default values for the database of this plugin
|
||||||
|
$this->dbFields = array(
|
||||||
|
'label'=>'Menu'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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>';
|
||||||
|
$html .= '<input id="jslabel" name="label" type="text" value="'.$this->getValue('label').'">';
|
||||||
|
$html .= '</div>';
|
||||||
|
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method called on the sidebar of the website
|
||||||
|
public function siteSidebar()
|
||||||
|
{
|
||||||
|
global $Language;
|
||||||
|
global $dbCategories;
|
||||||
|
global $Url;
|
||||||
|
global $pagesByKey;
|
||||||
|
|
||||||
|
// HTML for sidebar
|
||||||
|
$html = '<div class="plugin plugin-menu">';
|
||||||
|
$html .= '<h2 class="plugin-label">'.$this->getValue('label').'</h2>';
|
||||||
|
$html .= '<div class="plugin-content">';
|
||||||
|
$html .= '<ul class="menu">';
|
||||||
|
|
||||||
|
// By default the database of categories are alphanumeric sorted
|
||||||
|
foreach( $dbCategories->db as $key=>$fields ) {
|
||||||
|
$pageList = $fields['list'];
|
||||||
|
if( count($pageList) > 0 ) {
|
||||||
|
$html .= '<li>';
|
||||||
|
$html .= '<span class="category-name">'.$fields['name'].'</span>';
|
||||||
|
$html .= '<ul class="submenu">';
|
||||||
|
foreach( $pageList as $pageKey ) {
|
||||||
|
$page = $pagesByKey[$pageKey];
|
||||||
|
$html .= '<li>';
|
||||||
|
$html .= '<a href="'.$page->permalink().'" class="page-title">';
|
||||||
|
$html .= $page->title();
|
||||||
|
$html .= '</a>';
|
||||||
|
$html .= '</li>';
|
||||||
|
}
|
||||||
|
$html .= '</ul>';
|
||||||
|
$html .= '</a>';
|
||||||
|
$html .= '</li>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$html .= '</ul>';
|
||||||
|
$html .= '</div>';
|
||||||
|
$html .= '</div>';
|
||||||
|
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,103 +4,68 @@ class pluginPages extends Plugin {
|
||||||
|
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
|
// Fields and default values for the database of this plugin
|
||||||
$this->dbFields = array(
|
$this->dbFields = array(
|
||||||
'homeLink'=>1,
|
'label'=>'Pages',
|
||||||
'children'=>1,
|
'homeLink'=>true,
|
||||||
'label'=>'Pages'
|
'children'=>true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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('Plugin label').'</label>';
|
$html .= '<label>'.$Language->get('Label').'</label>';
|
||||||
$html .= '<input name="label" id="jslabel" type="text" value="'.$this->getDbField('label').'">';
|
$html .= '<input id="jslabel" name="label" type="text" value="'.$this->getValue('label').'">';
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
|
|
||||||
$html .= '<div>';
|
$html .= '<div>';
|
||||||
$html .= '<input type="hidden" name="homeLink" value="0">';
|
$html .= '<input type="hidden" name="homeLink" value="0">';
|
||||||
$html .= '<input name="homeLink" id="jshomeLink" type="checkbox" value="1" '.($this->getDbField('homeLink')?'checked':'').'>';
|
$html .= '<input id="jshomeLink" name="homeLink" type="checkbox" value="true" '.($this->getValue('homeLink')?'checked':'').'>';
|
||||||
$html .= '<label class="forCheckbox" for="jshomeLink">'.$Language->get('Show home link').'</label>';
|
$html .= '<label class="forCheckbox" for="jshomeLink">'.$Language->get('Show home link').'</label>';
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
|
|
||||||
$html .= '<div>';
|
$html .= '<div>';
|
||||||
$html .= '<input type="hidden" name="children" value="0">';
|
$html .= '<input type="hidden" name="children" value="0">';
|
||||||
$html .= '<input name="children" id="children" type="checkbox" value="1" '.($this->getDbField('children')?'checked':'').'>';
|
$html .= '<input id="jschildren" name="children" type="checkbox" value="true" '.($this->getValue('children')?'checked':'').'>';
|
||||||
$html .= '<label class="forCheckbox" for="jschildren">'.$Language->get('Show children').'</label>';
|
$html .= '<label class="forCheckbox" for="jschildren">'.$Language->get('Show children').'</label>';
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Method called on the sidebar of the website
|
||||||
public function siteSidebar()
|
public function siteSidebar()
|
||||||
{
|
{
|
||||||
global $Language;
|
global $Language;
|
||||||
global $pagesParents;
|
global $pages;
|
||||||
global $Site, $Url;
|
global $Url;
|
||||||
|
|
||||||
|
// URL base filter for categories
|
||||||
|
$filter = $Url->filters('page');
|
||||||
|
|
||||||
|
// HTML for sidebar
|
||||||
$html = '<div class="plugin plugin-pages">';
|
$html = '<div class="plugin plugin-pages">';
|
||||||
|
$html .= '<h2 class="plugin-label">'.$this->getValue('label').'</h2>';
|
||||||
// Print the label if not empty.
|
|
||||||
$label = $this->getDbField('label');
|
|
||||||
if( !empty($label) ) {
|
|
||||||
$html .= '<h2>'.$label.'</h2>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$html .= '<div class="plugin-content">';
|
$html .= '<div class="plugin-content">';
|
||||||
$html .= '<ul class="parents">';
|
$html .= '<ul>';
|
||||||
|
|
||||||
// Show home link ?
|
// By default the database of categories are alphanumeric sorted
|
||||||
if($this->getDbField('homeLink')) {
|
foreach( $pages as $page ) {
|
||||||
$html .= '<li>';
|
$html .= '<li>';
|
||||||
$html .= '<a class="parent'.( ($Url->whereAmI()=='home')?' active':'').'" href="'.$Site->homeLink().'">'.$Language->get('Home').'</a>';
|
$html .= '<a href="'.DOMAIN_BASE.$filter.'/'.$page->key().'">';
|
||||||
|
$html .= $page->title();
|
||||||
|
$html .= '</a>';
|
||||||
$html .= '</li>';
|
$html .= '</li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$parents = $pagesParents[NO_PARENT_CHAR];
|
|
||||||
foreach($parents as $parent)
|
|
||||||
{
|
|
||||||
// Check if the parent is published
|
|
||||||
if( $parent->published() )
|
|
||||||
{
|
|
||||||
// Print the parent
|
|
||||||
$html .= '<li class="parent">';
|
|
||||||
$html .= '<a class="parent'.( ($parent->key()==$Url->slug())?' active':'').'" href="'.$parent->permalink().'">'.$parent->title().'</a>';
|
|
||||||
|
|
||||||
// Show children elements?
|
|
||||||
if($this->getDbField('children')) {
|
|
||||||
|
|
||||||
// Check if the parent has children
|
|
||||||
if(isset($pagesParents[$parent->key()]))
|
|
||||||
{
|
|
||||||
$children = $pagesParents[$parent->key()];
|
|
||||||
|
|
||||||
// Print children
|
|
||||||
$html .= '<ul class="children">';
|
|
||||||
foreach($children as $child)
|
|
||||||
{
|
|
||||||
// Check if the child is published
|
|
||||||
if( $child->published() )
|
|
||||||
{
|
|
||||||
$html .= '<li class="child">';
|
|
||||||
$html .= '<a class="'.( ($child->key()==$Url->slug())?' active':'').'" href="'.$child->permalink().'">'.$child->title().'</a>';
|
|
||||||
$html .= '</li>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$html .= '</ul>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$html .= '</li>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$html .= '</ul>';
|
$html .= '</ul>';
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
|
||||||
|
/* Plugins
|
||||||
|
------------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
div.plugin {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
div.plugin h2.plugin-label {
|
||||||
|
border-bottom: solid 3px #f56a6a;
|
||||||
|
display: inline-block;
|
||||||
|
margin: 0 0 2em 0;
|
||||||
|
padding: 0 0.75em 0.5em 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.plugin ul {
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.plugin ul li {
|
||||||
|
border-top: solid 1px rgba(210, 215, 217, 0.75);
|
||||||
|
margin: 0.5em 0 0 0;
|
||||||
|
padding: 0.5em 0 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.plugin a {
|
||||||
|
border-bottom: 0;
|
||||||
|
color: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
display: block;
|
||||||
|
font-size: 1.1em;
|
||||||
|
padding: 0.625em 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Plugin Menu
|
||||||
|
------------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
div.plugin-menu ul.menu {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.plugin-menu ul.submenu li {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.plugin-menu span.category-name {
|
||||||
|
color: #3d4449 !important;
|
||||||
|
opacity: 1.0;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.plugin-menu a.page-title {
|
||||||
|
padding: 0;
|
||||||
|
}
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
echo Theme::css('assets/css/main.css');
|
echo Theme::css('assets/css/main.css');
|
||||||
echo '<noscript>'.Theme::css('assets/css/noscript.css').'</noscript>';
|
echo '<noscript>'.Theme::css('assets/css/noscript.css').'</noscript>';
|
||||||
|
echo Theme::css('assets/css/bludit.css');
|
||||||
|
|
||||||
// Load plugins with the hook siteHead
|
// Load plugins with the hook siteHead
|
||||||
Theme::plugins('siteHead');
|
Theme::plugins('siteHead');
|
||||||
|
|
|
@ -1,75 +1,4 @@
|
||||||
<!-- Menu -->
|
<?php Theme::plugins('siteSidebar') ?>
|
||||||
<nav id="menu">
|
|
||||||
<header class="major">
|
|
||||||
<h2>Menu</h2>
|
|
||||||
</header>
|
|
||||||
<ul>
|
|
||||||
<li><a href="index.html">Homepage</a></li>
|
|
||||||
<li><a href="generic.html">Generic</a></li>
|
|
||||||
<li><a href="elements.html">Elements</a></li>
|
|
||||||
<li>
|
|
||||||
<span class="opener">Submenu</span>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#">Lorem Dolor</a></li>
|
|
||||||
<li><a href="#">Ipsum Adipiscing</a></li>
|
|
||||||
<li><a href="#">Tempus Magna</a></li>
|
|
||||||
<li><a href="#">Feugiat Veroeros</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<li><a href="#">Etiam Dolore</a></li>
|
|
||||||
<li><a href="#">Adipiscing</a></li>
|
|
||||||
<li>
|
|
||||||
<span class="opener">Another Submenu</span>
|
|
||||||
<ul>
|
|
||||||
<li><a href="#">Lorem Dolor</a></li>
|
|
||||||
<li><a href="#">Ipsum Adipiscing</a></li>
|
|
||||||
<li><a href="#">Tempus Magna</a></li>
|
|
||||||
<li><a href="#">Feugiat Veroeros</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<li><a href="#">Maximus Erat</a></li>
|
|
||||||
<li><a href="#">Sapien Mauris</a></li>
|
|
||||||
<li><a href="#">Amet Lacinia</a></li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<!-- Section -->
|
|
||||||
<section>
|
|
||||||
<header class="major">
|
|
||||||
<h2>Ante interdum</h2>
|
|
||||||
</header>
|
|
||||||
<div class="mini-posts">
|
|
||||||
<article>
|
|
||||||
<a href="#" class="image"><img src="images/pic07.jpg" alt="" /></a>
|
|
||||||
<p>Aenean ornare velit lacus, ac varius enim lorem ullamcorper dolore aliquam.</p>
|
|
||||||
</article>
|
|
||||||
<article>
|
|
||||||
<a href="#" class="image"><img src="images/pic08.jpg" alt="" /></a>
|
|
||||||
<p>Aenean ornare velit lacus, ac varius enim lorem ullamcorper dolore aliquam.</p>
|
|
||||||
</article>
|
|
||||||
<article>
|
|
||||||
<a href="#" class="image"><img src="images/pic09.jpg" alt="" /></a>
|
|
||||||
<p>Aenean ornare velit lacus, ac varius enim lorem ullamcorper dolore aliquam.</p>
|
|
||||||
</article>
|
|
||||||
</div>
|
|
||||||
<ul class="actions">
|
|
||||||
<li><a href="#" class="button">More</a></li>
|
|
||||||
</ul>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<!-- Section -->
|
|
||||||
<section>
|
|
||||||
<header class="major">
|
|
||||||
<h2>Get in touch</h2>
|
|
||||||
</header>
|
|
||||||
<p>Sed varius enim lorem ullamcorper dolore aliquam aenean ornare velit lacus, ac varius enim lorem ullamcorper dolore. Proin sed aliquam facilisis ante interdum. Sed nulla amet lorem feugiat tempus aliquam.</p>
|
|
||||||
<ul class="contact">
|
|
||||||
<li class="fa-envelope-o"><a href="#">information@untitled.tld</a></li>
|
|
||||||
<li class="fa-phone">(000) 000-0000</li>
|
|
||||||
<li class="fa-home">1234 Somewhere Road #8254<br />
|
|
||||||
Nashville, TN 00000-0000</li>
|
|
||||||
</ul>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<!-- Footer -->
|
<!-- Footer -->
|
||||||
<footer id="footer">
|
<footer id="footer">
|
||||||
|
|
Loading…
Reference in New Issue