Plugins and themes compatibility

This commit is contained in:
dignajar 2016-06-19 21:45:09 -03:00
parent b5d2d44769
commit 6dacbdbd54
5 changed files with 38 additions and 16 deletions

View File

@ -170,6 +170,13 @@ class Plugin {
return $this->className; return $this->className;
} }
public function isCompatible()
{
$explode = explode(',', $this->getMetadata('compatible'));
return in_array(BLUDIT_VERSION, $explode);
}
public function directoryName() public function directoryName()
{ {
return $this->directoryName; return $this->directoryName;

View File

@ -282,14 +282,14 @@ table.statistics tr:last-child td {
/* ----------- ALERT ----------- */ /* ----------- ALERT ----------- */
#alert { #alert {
bottom: 0;
color: #ffffff; color: #ffffff;
display: none;
padding: 10px; padding: 10px;
display: none;
position: fixed; position: fixed;
text-align: center; text-align: center;
top: 0;
width: 100%;
z-index: 100; z-index: 100;
right: 0;
} }
.alert-ok { .alert-ok {

View File

@ -1,7 +1,7 @@
<?php defined('BLUDIT') or die('Bludit CMS.'); <?php defined('BLUDIT') or die('Bludit CMS.');
// Bludit version // Bludit version
define('BLUDIT_VERSION', 'Github-Version'); define('BLUDIT_VERSION', '1.3');
define('BLUDIT_CODENAME', ''); define('BLUDIT_CODENAME', '');
define('BLUDIT_RELEASE_DATE', ''); define('BLUDIT_RELEASE_DATE', '');
define('BLUDIT_BUILD', ''); define('BLUDIT_BUILD', '');
@ -115,7 +115,7 @@ define('TOKEN_EMAIL_TTL', '+15 minutes');
define('CHARSET', 'UTF-8'); define('CHARSET', 'UTF-8');
// EXTREME FRIENDLY URL, TRUE for dissmiss internet standard // EXTREME FRIENDLY URL, TRUE for dissmiss internet standard
define('EXTREME_FRIENDLY_URL', true); define('EXTREME_FRIENDLY_URL', false);
// Directory permissions // Directory permissions
define('DIR_PERMISSIONS', 0755); define('DIR_PERMISSIONS', 0755);

View File

@ -96,20 +96,24 @@ function buildPlugins()
$Language->add($database); $Language->add($database);
} }
// If the plugin is compatible with the Bludit version, add to arrays
if($Plugin->isCompatible()) {
// 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;
// If the plugin is installed, order by hooks. // If the plugin is installed, order by 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);
} }
} }
} }
} }
}
} }
// ============================================================================ // ============================================================================

View File

@ -48,9 +48,20 @@ function buildThemes()
break; break;
} }
$database = $database + $metadata; // Check if the theme is compatible
if(empty($metadata['compatible'])) {
Log::set('99.themes.php'.LOG_SEP.'Metadata error, field compatible invalid '.$themePath);
break;
}
$explode = explode(',', $metadata['compatible']);
if(!in_array(BLUDIT_VERSION, $explode)) {
Log::set('99.themes.php'.LOG_SEP.'Theme incompatible '.$themePath);
break;
}
// Theme data // Theme data
$database = $database + $metadata;
array_push($themes, $database); array_push($themes, $database);
} }
} }