Merge ff8fe8dc02aa4272ac52419cdc89c2e154a6773e into eef031c89ffd14dd575f7d966bcd8d97020af6fa

This commit is contained in:
torkel104 2017-05-05 18:29:01 +00:00 committed by GitHub
commit 1ba2c35e56
12 changed files with 80 additions and 75 deletions

23
bl-kernel/abstract/plugin.class.php Normal file → Executable file
View File

@ -21,9 +21,14 @@ class Plugin {
// (array) Plugin's information. // (array) Plugin's information.
public $metadata; public $metadata;
// (dbLanguage) Plugin's localisation.
public $language;
function __construct() function __construct()
{ {
global $Site;
$this->dbFields = array(); $this->dbFields = array();
$reflector = new ReflectionClass(get_class($this)); $reflector = new ReflectionClass(get_class($this));
@ -47,6 +52,16 @@ class Plugin {
$metadataString = file_get_contents($this->filenameMetadata); $metadataString = file_get_contents($this->filenameMetadata);
$this->metadata = json_decode($metadataString, true); $this->metadata = json_decode($metadataString, true);
// Load localisation
$tmp = new dbLanguage($Site->locale(), PATH_PLUGINS.$this->directoryName.DS.'languages'.DS);
// Set name and description from the language file.
$this->setMetadata('name',$tmp->db['plugin-data']['name']);
$this->setMetadata('description',$tmp->db['plugin-data']['description']);
// Remove name and description
unset($tmp->db['plugin-data']);
$this->language = $tmp;
// If the plugin is installed then get the database. // If the plugin is installed then get the database.
if($this->installed()) if($this->installed())
{ {
@ -218,8 +233,12 @@ class Plugin {
public function init() public function init()
{ {
// This method is used on childre classes. // This method is used on child classes.
// The user can define your own dbFields. // The user can define their own dbFields.
} }
public function L($key)
{
return $this->language->get($key);
}
} }

33
bl-kernel/boot/rules/60.plugins.php Normal file → Executable file
View File

@ -75,26 +75,27 @@ function buildPlugins()
foreach($pluginsDeclaredClasess as $pluginClass) foreach($pluginsDeclaredClasess as $pluginClass)
{ {
$Plugin = new $pluginClass; $Plugin = new $pluginClass();
// Check if the plugin is translated. // Deprecated
$languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.$Site->locale().'.json'; // // Check if the plugin is translated.
if( !Sanitize::pathFile($languageFilename) ) { // $languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.$Site->locale().'.json';
$languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.'en_US.json'; // if( !Sanitize::pathFile($languageFilename) ) {
} // $languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.'en_US.json';
// }
$database = file_get_contents($languageFilename); // $database = file_get_contents($languageFilename);
$database = json_decode($database, true); // $database = json_decode($database, true);
// Set name and description from the language file. // // Set name and description from the language file.
$Plugin->setMetadata('name',$database['plugin-data']['name']); // $Plugin->setMetadata('name',$database['plugin-data']['name']);
$Plugin->setMetadata('description',$database['plugin-data']['description']); // $Plugin->setMetadata('description',$database['plugin-data']['description']);
// Remove name and description, and add new words if there are. // // Remove name and description, and add new words if there are.
unset($database['plugin-data']); // unset($database['plugin-data']);
if(!empty($database)) { // if(!empty($database)) {
$Language->add($database); // $Language->add($database);
} // }
// Push Plugin to array all plugins installed and not installed. // Push Plugin to array all plugins installed and not installed.
$plugins['all'][$pluginClass] = $Plugin; $plugins['all'][$pluginClass] = $Plugin;

17
bl-kernel/dblanguage.class.php Normal file → Executable file
View File

@ -6,22 +6,24 @@ class dbLanguage extends dbJSON
public $db; public $db;
public $currentLocale; public $currentLocale;
function __construct($locale) function __construct( $locale, $path = null )
{ {
$path = $path ? $path : PATH_LANGUAGES;
$this->data = array(); $this->data = array();
$this->db = array(); $this->db = array();
$this->currentLocale = 'en_US'; $this->currentLocale = 'en_US';
// Default language en_US // Default language en_US
$filename = PATH_LANGUAGES.'en_US.json'; $filename = $path.'en_US.json';
if( Sanitize::pathFile($filename) ) if( Sanitize::pathFile($filename) )
{ {
$Tmp = new dbJSON($filename, false); $Tmp = new dbJSON($filename, false);
$this->db = array_merge($this->db, $Tmp->db); $this->db = $Tmp->db;
} }
// User language // User language
$filename = PATH_LANGUAGES.$locale.'.json'; $filename = $path.$locale.'.json';
if( Sanitize::pathFile($filename) && ($locale!=="en_US") ) if( Sanitize::pathFile($filename) && ($locale!=="en_US") )
{ {
$this->currentLocale = $locale; $this->currentLocale = $locale;
@ -29,8 +31,11 @@ class dbLanguage extends dbJSON
$this->db = array_merge($this->db, $Tmp->db); $this->db = array_merge($this->db, $Tmp->db);
} }
$this->data = $this->db['language-data']; if ( $this->data )
unset($this->db['language-data']); {
$this->data = $this->db['language-data'];
unset($this->db['language-data']);
}
} }
public function getCurrentLocale() public function getCurrentLocale()

6
bl-plugins/about/plugin.php Normal file → Executable file
View File

@ -12,14 +12,12 @@ class pluginAbout extends Plugin {
public function form() public function form()
{ {
global $Language;
$html = '<div>'; $html = '<div>';
$html .= '<label>'.$Language->get('Plugin label').'</label>'; $html .= '<label>'.$this->L('Plugin label').'</label>';
$html .= '<input name="label" id="jslabel" type="text" value="'.$this->getDbField('label').'">'; $html .= '<input name="label" id="jslabel" type="text" value="'.$this->getDbField('label').'">';
$html .= '</div>'; $html .= '</div>';
$html .= '<div>'; $html .= '<div>';
$html .= '<label>'.$Language->get('About').'</label>'; $html .= '<label>'.$this->L('About').'</label>';
$html .= '<textarea name="text" id="jstext">'.$this->getDbField('text').'</textarea>'; $html .= '<textarea name="text" id="jstext">'.$this->getDbField('text').'</textarea>';
$html .= '</div>'; $html .= '</div>';

10
bl-plugins/disqus/plugin.php Normal file → Executable file
View File

@ -36,29 +36,27 @@ class pluginDisqus extends Plugin {
public function form() public function form()
{ {
global $Language;
$html = '<div>'; $html = '<div>';
$html .= '<label>'.$Language->get('Disqus shortname').'</label>'; $html .= '<label>'.$this->L('Disqus shortname').'</label>';
$html .= '<input name="shortname" id="jsshortname" type="text" value="'.$this->getDbField('shortname').'">'; $html .= '<input name="shortname" id="jsshortname" type="text" value="'.$this->getDbField('shortname').'">';
$html .= '</div>'; $html .= '</div>';
$html .= '<div>'; $html .= '<div>';
$html .= '<input type="hidden" name="enablePages" value="0">'; $html .= '<input type="hidden" name="enablePages" value="0">';
$html .= '<input name="enablePages" id="jsenablePages" type="checkbox" value="1" '.($this->getDbField('enablePages')?'checked':'').'>'; $html .= '<input name="enablePages" id="jsenablePages" type="checkbox" value="1" '.($this->getDbField('enablePages')?'checked':'').'>';
$html .= '<label class="forCheckbox" for="jsenablePages">'.$Language->get('Enable Disqus on pages').'</label>'; $html .= '<label class="forCheckbox" for="jsenablePages">'.$this->L('Enable Disqus on pages').'</label>';
$html .= '</div>'; $html .= '</div>';
$html .= '<div>'; $html .= '<div>';
$html .= '<input type="hidden" name="enablePosts" value="0">'; $html .= '<input type="hidden" name="enablePosts" value="0">';
$html .= '<input name="enablePosts" id="jsenablePosts" type="checkbox" value="1" '.($this->getDbField('enablePosts')?'checked':'').'>'; $html .= '<input name="enablePosts" id="jsenablePosts" type="checkbox" value="1" '.($this->getDbField('enablePosts')?'checked':'').'>';
$html .= '<label class="forCheckbox" for="jsenablePosts">'.$Language->get('Enable Disqus on posts').'</label>'; $html .= '<label class="forCheckbox" for="jsenablePosts">'.$this->L('Enable Disqus on posts').'</label>';
$html .= '</div>'; $html .= '</div>';
$html .= '<div>'; $html .= '<div>';
$html .= '<input type="hidden" name="enableDefaultHomePage" value="0">'; $html .= '<input type="hidden" name="enableDefaultHomePage" value="0">';
$html .= '<input name="enableDefaultHomePage" id="jsenableDefaultHomePage" type="checkbox" value="1" '.($this->getDbField('enableDefaultHomePage')?'checked':'').'>'; $html .= '<input name="enableDefaultHomePage" id="jsenableDefaultHomePage" type="checkbox" value="1" '.($this->getDbField('enableDefaultHomePage')?'checked':'').'>';
$html .= '<label class="forCheckbox" for="jsenableDefaultHomePage">'.$Language->get('Enable Disqus on default home page').'</label>'; $html .= '<label class="forCheckbox" for="jsenableDefaultHomePage">'.$this->L('Enable Disqus on default home page').'</label>';
$html .= '</div>'; $html .= '</div>';
return $html; return $html;

10
bl-plugins/googletools/plugin.php Normal file → Executable file
View File

@ -13,18 +13,16 @@ class pluginGoogleTools extends Plugin {
public function form() public function form()
{ {
global $Language;
$html = '<div>'; $html = '<div>';
$html .= '<label for="jsgoogle-site-verification">'.$Language->get('Google Webmasters tools').'</label>'; $html .= '<label for="jsgoogle-site-verification">'.$this->L('Google Webmasters tools').'</label>';
$html .= '<input id="jsgoogle-site-verification" type="text" name="google-site-verification" value="'.$this->getDbField('google-site-verification').'">'; $html .= '<input id="jsgoogle-site-verification" type="text" name="google-site-verification" value="'.$this->getDbField('google-site-verification').'">';
$html .= '<div class="tip">'.$Language->get('complete-this-field-with-the-google-site-verification').'</div>'; $html .= '<div class="tip">'.$this->L('complete-this-field-with-the-google-site-verification').'</div>';
$html .= '</div>'; $html .= '</div>';
$html .= '<div>'; $html .= '<div>';
$html .= '<label for="jstracking-id">'.$Language->get('Google Analytics Tracking ID').'</label>'; $html .= '<label for="jstracking-id">'.$this->L('Google Analytics Tracking ID').'</label>';
$html .= '<input id="jstracking-id" type="text" name="tracking-id" value="'.$this->getDbField('tracking-id').'">'; $html .= '<input id="jstracking-id" type="text" name="tracking-id" value="'.$this->getDbField('tracking-id').'">';
$html .= '<div class="tip">'.$Language->get('complete-this-field-with-the-tracking-id').'</div>'; $html .= '<div class="tip">'.$this->L('complete-this-field-with-the-tracking-id').'</div>';
$html .= '</div>'; $html .= '</div>';
$html .= '<div>'; $html .= '<div>';

6
bl-plugins/latest_posts/plugin.php Normal file → Executable file
View File

@ -12,15 +12,13 @@ class pluginLatestPosts extends Plugin {
public function form() public function form()
{ {
global $Language;
$html = '<div>'; $html = '<div>';
$html .= '<label>'.$Language->get('Plugin label').'</label>'; $html .= '<label>'.$this->L('Plugin label').'</label>';
$html .= '<input name="label" id="jslabel" type="text" value="'.$this->getDbField('label').'">'; $html .= '<input name="label" id="jslabel" type="text" value="'.$this->getDbField('label').'">';
$html .= '</div>'; $html .= '</div>';
$html .= '<div>'; $html .= '<div>';
$html .= '<label>'.$Language->get('Amount of posts').'</label>'; $html .= '<label>'.$this->L('Amount of posts').'</label>';
$html .= '<input name="amount" id="jsamount" type="text" value="'.$this->getDbField('amount').'">'; $html .= '<input name="amount" id="jsamount" type="text" value="'.$this->getDbField('amount').'">';
$html .= '</div>'; $html .= '</div>';

6
bl-plugins/maintenancemode/plugin.php Normal file → Executable file
View File

@ -12,16 +12,14 @@ class pluginMaintenanceMode extends Plugin {
public function form() public function form()
{ {
global $Language;
$html = '<div>'; $html = '<div>';
$html .= '<input type="hidden" name="enable" value="0">'; $html .= '<input type="hidden" name="enable" value="0">';
$html .= '<input name="enable" id="jsenable" type="checkbox" value="1" '.($this->getDbField('enable')?'checked':'').'>'; $html .= '<input name="enable" id="jsenable" type="checkbox" value="1" '.($this->getDbField('enable')?'checked':'').'>';
$html .= '<label class="forCheckbox" for="jsenable">'.$Language->get('Enable maintenance mode').'</label>'; $html .= '<label class="forCheckbox" for="jsenable">'.$this->L('Enable maintenance mode').'</label>';
$html .= '</div>'; $html .= '</div>';
$html .= '<div>'; $html .= '<div>';
$html .= '<label>'.$Language->get('Message').'</label>'; $html .= '<label>'.$this->L('Message').'</label>';
$html .= '<input name="message" id="jsmessage" type="text" value="'.$this->getDbField('message').'">'; $html .= '<input name="message" id="jsmessage" type="text" value="'.$this->getDbField('message').'">';
$html .= '</div>'; $html .= '</div>';

9
bl-plugins/pages/plugin.php Normal file → Executable file
View File

@ -13,17 +13,15 @@ class pluginPages extends Plugin {
public function form() public function form()
{ {
global $Language;
$html = '<div>'; $html = '<div>';
$html .= '<label>'.$Language->get('Plugin label').'</label>'; $html .= '<label>'.$this->L('Plugin label').'</label>';
$html .= '<input name="label" id="jslabel" type="text" value="'.$this->getDbField('label').'">'; $html .= '<input name="label" id="jslabel" type="text" value="'.$this->getDbField('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 name="homeLink" id="jshomeLink" type="checkbox" value="1" '.($this->getDbField('homeLink')?'checked':'').'>';
$html .= '<label class="forCheckbox" for="jshomeLink">'.$Language->get('Show home link').'</label>'; $html .= '<label class="forCheckbox" for="jshomeLink">'.$this->L('Show home link').'</label>';
$html .= '</div>'; $html .= '</div>';
$html .= '<div>'; $html .= '<div>';
@ -37,7 +35,6 @@ class pluginPages extends Plugin {
public function siteSidebar() public function siteSidebar()
{ {
global $Language;
global $pagesParents; global $pagesParents;
global $Site, $Url; global $Site, $Url;
@ -55,7 +52,7 @@ class pluginPages extends Plugin {
// Show home link ? // Show home link ?
if($this->getDbField('homeLink')) { if($this->getDbField('homeLink')) {
$html .= '<li>'; $html .= '<li>';
$html .= '<a class="parent'.( ($Url->whereAmI()=='home')?' active':'').'" href="'.$Site->homeLink().'">'.$Language->get('Home').'</a>'; $html .= '<a class="parent'.( ($Url->whereAmI()=='home')?' active':'').'" href="'.$Site->homeLink().'">'.$this->L('Home').'</a>';
$html .= '</li>'; $html .= '</li>';
} }

12
bl-plugins/simplemde/plugin.php Normal file → Executable file
View File

@ -21,22 +21,20 @@ class pluginsimpleMDE extends Plugin {
public function form() public function form()
{ {
global $Language;
$html = '<div>'; $html = '<div>';
$html .= '<label>'.$Language->get('Toolbar').'</label>'; $html .= '<label>'.$this->L('Toolbar').'</label>';
$html .= '<input name="toolbar" id="jstoolbar" type="text" value="'.$this->getDbField('toolbar').'">'; $html .= '<input name="toolbar" id="jstoolbar" type="text" value="'.$this->getDbField('toolbar').'">';
$html .= '</div>'; $html .= '</div>';
$html .= '<div>'; $html .= '<div>';
$html .= '<label>'.$Language->get('Tab size').'</label>'; $html .= '<label>'.$this->L('Tab size').'</label>';
$html .= '<input name="tabSize" id="jstabSize" type="text" value="'.$this->getDbField('tabSize').'">'; $html .= '<input name="tabSize" id="jstabSize" type="text" value="'.$this->getDbField('tabSize').'">';
$html .= '</div>'; $html .= '</div>';
$html .= '<div>'; $html .= '<div>';
$html .= '<input type="hidden" name="autosave" value="0">'; $html .= '<input type="hidden" name="autosave" value="0">';
$html .= '<input name="autosave" id="jsautosave" type="checkbox" value="1" '.($this->getDbField('autosave')?'checked':'').'>'; $html .= '<input name="autosave" id="jsautosave" type="checkbox" value="1" '.($this->getDbField('autosave')?'checked':'').'>';
$html .= '<label class="forCheckbox" for="jsautosave">'.$Language->get('Autosave').'</label>'; $html .= '<label class="forCheckbox" for="jsautosave">'.$this->L('Autosave').'</label>';
$html .= '</div>'; $html .= '</div>';
$html .= '<div>'; $html .= '<div>';
@ -85,8 +83,6 @@ class pluginsimpleMDE extends Plugin {
public function adminBodyEnd() public function adminBodyEnd()
{ {
global $layout; global $layout;
global $Language;
$html = ''; $html = '';
// Load CSS and JS only on Controllers in array. // Load CSS and JS only on Controllers in array.
@ -119,7 +115,7 @@ class pluginsimpleMDE extends Plugin {
// This function is necesary on each Editor, it is used by Bludit Images v8. // This function is necesary on each Editor, it is used by Bludit Images v8.
$html .= 'function editorAddImage(filename) { $html .= 'function editorAddImage(filename) {
addContentSimpleMDE("!['.$Language->get('Image description').']("+filename+")"); addContentSimpleMDE("!['.$this->L('Image description').']("+filename+")");
}'.PHP_EOL; }'.PHP_EOL;
$html .= '$(document).ready(function() { '.PHP_EOL; $html .= '$(document).ready(function() { '.PHP_EOL;

11
bl-plugins/tags/plugin.php Normal file → Executable file
View File

@ -12,23 +12,21 @@ class pluginTags extends Plugin {
public function form() public function form()
{ {
global $Language;
$html = '<div>'; $html = '<div>';
$html .= '<label>'.$Language->get('Plugin label').'</label>'; $html .= '<label>'.$this->L('Plugin label').'</label>';
$html .= '<input name="label" id="jslabel" type="text" value="'.$this->getDbField('label').'">'; $html .= '<input name="label" id="jslabel" type="text" value="'.$this->getDbField('label').'">';
$html .= '</div>'; $html .= '</div>';
$html .= '<div>'; $html .= '<div>';
$html .= $Language->get('Sort the tag list by').': <select name="sort">'; $html .= $this->L('Sort the tag list by').': <select name="sort">';
foreach(array('alpha' => 'Alphabetical order', foreach(array('alpha' => 'Alphabetical order',
'count' => 'Number of times each tag has been used', 'count' => 'Number of times each tag has been used',
'date' => 'Date each tag was first used') as $key=>$value) { 'date' => 'Date each tag was first used') as $key=>$value) {
if ($key == $this->getDbField('sort')) { if ($key == $this->getDbField('sort')) {
$html .= '<option value="'.$key.'" selected>'.$Language->get($value).'</option>'; $html .= '<option value="'.$key.'" selected>'.$this->L($value).'</option>';
} else { } else {
$html .= '<option value="'.$key.'">'.$Language->get($value).'</option>'; $html .= '<option value="'.$key.'">'.$this->L($value).'</option>';
} }
} }
$html .= '</select>'; $html .= '</select>';
@ -39,7 +37,6 @@ class pluginTags extends Plugin {
public function siteSidebar() public function siteSidebar()
{ {
global $Language;
global $dbTags; global $dbTags;
global $Url; global $Url;

View File

@ -4,6 +4,12 @@
Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
*/ */
$( window ).on( 'load', function() {
setTimeout( function() {
$('body').removeClass('is-loading');
})
});
(function($) { (function($) {
skel.breakpoints({ skel.breakpoints({
@ -25,12 +31,6 @@
// Disable animations/transitions until the page has loaded. // Disable animations/transitions until the page has loaded.
$body.addClass('is-loading'); $body.addClass('is-loading');
$window.on('load', function() {
window.setTimeout(function() {
$body.removeClass('is-loading');
}, 100);
});
// Fix: Placeholder polyfill. // Fix: Placeholder polyfill.
$('form').placeholder(); $('form').placeholder();