bug fixes
This commit is contained in:
parent
2f31752fa8
commit
258e7304ab
|
@ -143,6 +143,9 @@ define('DIR_PERMISSIONS', 0755);
|
||||||
// Admin URI filter
|
// Admin URI filter
|
||||||
define('ADMIN_URI_FILTER', '/admin/');
|
define('ADMIN_URI_FILTER', '/admin/');
|
||||||
|
|
||||||
|
// Default language file, in this case is English
|
||||||
|
define('DEFAULT_LANGUAGE_FILE', 'en_US.json');
|
||||||
|
|
||||||
// Set internal character encoding
|
// Set internal character encoding
|
||||||
mb_internal_encoding(CHARSET);
|
mb_internal_encoding(CHARSET);
|
||||||
|
|
||||||
|
|
|
@ -54,14 +54,13 @@ function buildPlugins()
|
||||||
// List plugins directories
|
// List plugins directories
|
||||||
$list = Filesystem::listDirectories(PATH_PLUGINS);
|
$list = Filesystem::listDirectories(PATH_PLUGINS);
|
||||||
|
|
||||||
// Get declared clasess before load plugins clasess, this list doesn't have the plugins clasess.
|
// Get declared clasess BEFORE load plugins clasess
|
||||||
$currentDeclaredClasess = get_declared_classes();
|
$currentDeclaredClasess = get_declared_classes();
|
||||||
|
|
||||||
// Load each plugin clasess
|
// Load each plugin clasess
|
||||||
foreach($list as $pluginPath) {
|
foreach($list as $pluginPath) {
|
||||||
|
|
||||||
// Check if the directory has the plugin.php
|
// Check if the directory has the plugin.php
|
||||||
if(file_exists($pluginPath.DS.'plugin.php')) {
|
if (file_exists($pluginPath.DS.'plugin.php')) {
|
||||||
include($pluginPath.DS.'plugin.php');
|
include($pluginPath.DS.'plugin.php');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,38 +68,36 @@ function buildPlugins()
|
||||||
// Get plugins clasess loaded
|
// Get plugins clasess loaded
|
||||||
$pluginsDeclaredClasess = array_diff(get_declared_classes(), $currentDeclaredClasess);
|
$pluginsDeclaredClasess = array_diff(get_declared_classes(), $currentDeclaredClasess);
|
||||||
|
|
||||||
foreach($pluginsDeclaredClasess as $pluginClass)
|
foreach ($pluginsDeclaredClasess as $pluginClass) {
|
||||||
{
|
|
||||||
$Plugin = new $pluginClass;
|
$Plugin = new $pluginClass;
|
||||||
|
|
||||||
// Check if the plugin is translated.
|
// Check if the plugin is translated
|
||||||
$languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.$Site->locale().'.json';
|
$languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.$Site->locale().'.json';
|
||||||
if( !Sanitize::pathFile($languageFilename) ) {
|
if( !Sanitize::pathFile($languageFilename) ) {
|
||||||
$languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.'en_US.json';
|
$languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.DEFAULT_LANGUAGE_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$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 from the language file loaded and add new words if there are
|
||||||
|
// This function overwrite the key=>value
|
||||||
unset($database['plugin-data']);
|
unset($database['plugin-data']);
|
||||||
if(!empty($database)) {
|
if (!empty($database)) {
|
||||||
$Language->add($database);
|
$Language->add($database);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Array with plugin all plugins, installed and not installed
|
// $plugins['all'] Array with all plugins, installed and not installed
|
||||||
$plugins['all'][$pluginClass] = $Plugin;
|
$plugins['all'][$pluginClass] = $Plugin;
|
||||||
|
|
||||||
// If the plugin is installed, order by hooks.
|
// If the plugin is installed insert on the hooks
|
||||||
if($Plugin->installed()) {
|
if ($Plugin->installed()) {
|
||||||
|
foreach ($pluginsEvents as $event=>$value) {
|
||||||
foreach($pluginsEvents as $event=>$value) {
|
if (method_exists($Plugin, $event)) {
|
||||||
|
|
||||||
if(method_exists($Plugin, $event)) {
|
|
||||||
array_push($plugins[$event], $Plugin);
|
array_push($plugins[$event], $Plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,8 @@ class dbLanguage extends dbJSON
|
||||||
echo $this->get($string);
|
echo $this->get($string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add more keys=>values to the current dicionary
|
||||||
|
// Will be overwrite if exist the key with the new value
|
||||||
public function add($array)
|
public function add($array)
|
||||||
{
|
{
|
||||||
$this->db = array_merge($array, $this->db);
|
$this->db = array_merge($array, $this->db);
|
||||||
|
|
|
@ -131,7 +131,7 @@ class Theme {
|
||||||
public static function plugins($type)
|
public static function plugins($type)
|
||||||
{
|
{
|
||||||
global $plugins;
|
global $plugins;
|
||||||
foreach($plugins[$type] as $plugin) {
|
foreach ($plugins[$type] as $plugin) {
|
||||||
echo call_user_func(array($plugin, $type));
|
echo call_user_func(array($plugin, $type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,15 @@ class pluginDisqus extends Plugin {
|
||||||
|
|
||||||
public function pageEnd()
|
public function pageEnd()
|
||||||
{
|
{
|
||||||
global $page;
|
global $pages;
|
||||||
|
global $Url;
|
||||||
|
|
||||||
if( ($page->key()!='error') && ($page->allowComments()) ) {
|
$page = $pages[0];
|
||||||
|
if (empty($page)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( (!$Url->notFound()) && ($Url->whereAmI()=='page') && ($page->allowComments()) ) {
|
||||||
$html = '<div id="disqus_thread"></div>';
|
$html = '<div id="disqus_thread"></div>';
|
||||||
$html .= '<script type="text/javascript">
|
$html .= '<script type="text/javascript">
|
||||||
var disqus_config = function () {
|
var disqus_config = function () {
|
||||||
|
@ -40,8 +46,6 @@ class pluginDisqus extends Plugin {
|
||||||
(d.head || d.body).appendChild(s);
|
(d.head || d.body).appendChild(s);
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
|
|
||||||
';
|
';
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
<?php include(THEME_DIR_PHP.'head.php') ?>
|
<?php include(THEME_DIR_PHP.'head.php') ?>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<?php Theme::plugins('siteBodyBegin') ?>
|
||||||
|
|
||||||
<div id="fh5co-main">
|
<div id="fh5co-main">
|
||||||
<div class="fh5co-intro text-center">
|
<div class="fh5co-intro text-center">
|
||||||
|
@ -32,7 +33,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<?php
|
<?php
|
||||||
if($WHERE_AM_I=='page') {
|
if ($WHERE_AM_I=='page') {
|
||||||
include(THEME_DIR_PHP.'page.php');
|
include(THEME_DIR_PHP.'page.php');
|
||||||
} else {
|
} else {
|
||||||
include(THEME_DIR_PHP.'home.php');
|
include(THEME_DIR_PHP.'home.php');
|
||||||
|
@ -57,5 +58,6 @@
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
|
<?php Theme::plugins('siteBodyEnd') ?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -2,6 +2,7 @@
|
||||||
<section class="content">
|
<section class="content">
|
||||||
<?php foreach ($pages as $page): ?>
|
<?php foreach ($pages as $page): ?>
|
||||||
<article class="page">
|
<article class="page">
|
||||||
|
<?php Theme::plugins('pageBegin') ?>
|
||||||
<header>
|
<header>
|
||||||
<a href="<?php echo $page->permalink() ?>">
|
<a href="<?php echo $page->permalink() ?>">
|
||||||
<h2><?php echo $page->title() ?></h2>
|
<h2><?php echo $page->title() ?></h2>
|
||||||
|
@ -21,6 +22,7 @@
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</footer>
|
</footer>
|
||||||
|
<?php Theme::plugins('pageEnd') ?>
|
||||||
</article>
|
</article>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
</section>
|
</section>
|
|
@ -1,6 +1,7 @@
|
||||||
<!-- Section -->
|
<!-- Section -->
|
||||||
<section class="content">
|
<section class="content">
|
||||||
<article class="page">
|
<article class="page">
|
||||||
|
<?php Theme::plugins('pageBegin') ?>
|
||||||
<header>
|
<header>
|
||||||
<a href="<?php echo $page->permalink() ?>">
|
<a href="<?php echo $page->permalink() ?>">
|
||||||
<h2><?php echo $page->title() ?></h2>
|
<h2><?php echo $page->title() ?></h2>
|
||||||
|
@ -14,5 +15,6 @@
|
||||||
<footer>
|
<footer>
|
||||||
<div class="date"><i class="fa fa-clock-o"></i> <?php echo $page->date() ?></div>
|
<div class="date"><i class="fa fa-clock-o"></i> <?php echo $page->date() ?></div>
|
||||||
</footer>
|
</footer>
|
||||||
|
<?php Theme::plugins('pageEnd') ?>
|
||||||
</article>
|
</article>
|
||||||
</section>
|
</section>
|
|
@ -5,6 +5,8 @@
|
||||||
<?php include(THEME_DIR_PHP.'head.php') ?>
|
<?php include(THEME_DIR_PHP.'head.php') ?>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<?php Theme::plugins('siteBodyBegin') ?>
|
||||||
|
|
||||||
<div id="wrapper">
|
<div id="wrapper">
|
||||||
|
|
||||||
<!-- Header -->
|
<!-- Header -->
|
||||||
|
@ -58,7 +60,7 @@
|
||||||
<!-- Main -->
|
<!-- Main -->
|
||||||
<div id="main">
|
<div id="main">
|
||||||
<?php
|
<?php
|
||||||
if($WHERE_AM_I=='page') {
|
if ($WHERE_AM_I=='page') {
|
||||||
include(THEME_DIR_PHP.'page.php');
|
include(THEME_DIR_PHP.'page.php');
|
||||||
} else {
|
} else {
|
||||||
include(THEME_DIR_PHP.'home.php');
|
include(THEME_DIR_PHP.'home.php');
|
||||||
|
@ -68,9 +70,7 @@
|
||||||
|
|
||||||
<!-- Sidebar -->
|
<!-- Sidebar -->
|
||||||
<section id="sidebar">
|
<section id="sidebar">
|
||||||
<?php
|
<?php include(THEME_DIR_PHP.'sidebar.php') ?>
|
||||||
include(THEME_DIR_PHP.'sidebar.php');
|
|
||||||
?>
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -84,9 +84,8 @@
|
||||||
echo Theme::js('assets/js/ie/respond.min.js');
|
echo Theme::js('assets/js/ie/respond.min.js');
|
||||||
echo '<![endif]-->';
|
echo '<![endif]-->';
|
||||||
echo Theme::js('assets/js/main.js');
|
echo Theme::js('assets/js/main.js');
|
||||||
|
|
||||||
Theme::plugins('siteBodyEnd');
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<?php Theme::plugins('siteBodyEnd') ?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Reference in New Issue