rename function to check if the plugin is enabled

This commit is contained in:
Diego Najar 2021-09-25 20:29:31 +02:00
parent ccb9123ac0
commit f529cd26cb
7 changed files with 25 additions and 18 deletions

View file

@ -262,9 +262,12 @@ class Plugin {
return true; return true;
} }
// Returns TRUE if the plugin is installed /**
// This function just check if the database of the plugin is created * Returns True if the plugin is installed
public function installed() *
* @return boolean
*/
public function installed(): bool
{ {
return file_exists($this->filenameDb); return file_exists($this->filenameDb);
} }

View file

@ -18,7 +18,7 @@ $plugin = false;
$pluginClassName = $layout['parameters']; $pluginClassName = $layout['parameters'];
// Check if the plugin is installed/activated // Check if the plugin is installed/activated
if (pluginActivated($pluginClassName)) { if (isPluginActive($pluginClassName)) {
$plugin = $plugins['all'][$pluginClassName]; $plugin = $plugins['all'][$pluginClassName];
} else { } else {
Redirect::page('plugins'); Redirect::page('plugins');

View file

@ -3,6 +3,6 @@
// Init scripts for the theme // Init scripts for the theme
// This theme use the API to work // This theme use the API to work
if (!pluginActivated('pluginAPI')) { if (!isPluginActive('pluginAPI')) {
activatePlugin('pluginAPI'); activatePlugin('pluginAPI');
} }

View file

@ -877,21 +877,25 @@ function buildParentPages() {
function getPlugin($pluginClassName) { function getPlugin($pluginClassName) {
global $plugins; global $plugins;
if (pluginActivated($pluginClassName)) { if (isPluginActive($pluginClassName)) {
return $plugins['all'][$pluginClassName]; return $plugins['all'][$pluginClassName];
} }
return false; return false;
} }
// Check if the plugin is activated / installed /**
// Returns TRUE if the plugin is activated / installed, FALSE otherwise * Returns True if the plugin is installed
function pluginActivated($pluginClassName) { *
global $plugins; * @param string $pluginClassName Plugin class name
* @return boolean
*/
function isPluginActive(string $pluginClassName): bool {
global $plugins;
if (isset($plugins['all'][$pluginClassName])) { if (isset($plugins['all'][$pluginClassName])) {
return $plugins['all'][$pluginClassName]->installed(); return $plugins['all'][$pluginClassName]->installed();
} }
return false; return false;
} }

View file

@ -244,7 +244,7 @@ class HTML {
public static function rssUrl() public static function rssUrl()
{ {
if (pluginActivated('pluginRSS')) { if (isPluginActive('pluginRSS')) {
return DOMAIN_BASE.'rss.xml'; return DOMAIN_BASE.'rss.xml';
} }
return false; return false;
@ -252,7 +252,7 @@ class HTML {
public static function sitemapUrl() public static function sitemapUrl()
{ {
if (pluginActivated('pluginSitemap')) { if (isPluginActive('pluginSitemap')) {
return DOMAIN_BASE.'sitemap.xml'; return DOMAIN_BASE.'sitemap.xml';
} }
return false; return false;

View file

@ -10,7 +10,7 @@
<?php endif ?> <?php endif ?>
<!-- Custom search form if the plugin "search" is enabled --> <!-- Custom search form if the plugin "search" is enabled -->
<?php if (pluginActivated('pluginSearch')): ?> <?php if (isPluginActive('pluginSearch')): ?>
<div class="form-inline d-block"> <div class="form-inline d-block">
<input id="search-input" class="form-control mr-sm-2" type="search" placeholder="<?php $language->p('Search') ?>" aria-label="Search"> <input id="search-input" class="form-control mr-sm-2" type="search" placeholder="<?php $language->p('Search') ?>" aria-label="Search">
<button class="btn btn-outline-primary my-2 my-sm-0" type="button" onClick="searchNow()"><?php $language->p('Search') ?></button> <button class="btn btn-outline-primary my-2 my-sm-0" type="button" onClick="searchNow()"><?php $language->p('Search') ?></button>

View file

@ -25,7 +25,7 @@
<div class="col-lg-8 mx-auto"> <div class="col-lg-8 mx-auto">
<!-- Search input --> <!-- Search input -->
<?php if (pluginActivated('pluginSearch')): ?> <?php if (isPluginActive('pluginSearch')): ?>
<form class="d-flex mb-4"> <form class="d-flex mb-4">
<input id="search-input" class="form-control me-2" type="search" placeholder="Search" aria-label="Search"> <input id="search-input" class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-primary" type="button" onClick="searchNow()">Search</button> <button class="btn btn-outline-primary" type="button" onClick="searchNow()">Search</button>