Settings for the plugin version, new version alert and show current version

This commit is contained in:
Diego Najar 2020-03-14 12:02:23 +01:00
parent d570ad6644
commit 017cbfa667

View File

@ -2,20 +2,63 @@
class pluginVersion extends Plugin {
public function init()
{
$this->dbFields = array(
'showCurrentVersion'=>true,
'newVersionAlert'=>true
);
}
public function form()
{
global $L;
$html = '<div class="alert alert-primary" role="alert">';
$html .= $this->description();
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$L->get('Show current version in the sidebar').'</label>';
$html .= '<select name="showCurrentVersion">';
$html .= '<option value="true" '.($this->getValue('showCurrentVersion')===true?'selected':'').'>'.$L->get('Enabled').'</option>';
$html .= '<option value="false" '.($this->getValue('showCurrentVersion')===false?'selected':'').'>'.$L->get('Disabled').'</option>';
$html .= '</select>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$L->get('Show alert when there is a new version in the sidebar').'</label>';
$html .= '<select name="newVersionAlert">';
$html .= '<option value="true" '.($this->getValue('newVersionAlert')===true?'selected':'').'>'.$L->get('Enabled').'</option>';
$html .= '<option value="false" '.($this->getValue('newVersionAlert')===false?'selected':'').'>'.$L->get('Disabled').'</option>';
$html .= '</select>';
$html .= '</div>';
return $html;
}
public function adminSidebar()
{
global $L;
$html = '<a id="current-version" class="nav-link" href="'.HTML_PATH_ADMIN_ROOT.'about'.'">Version '.(defined('BLUDIT_PRO')?'<span class="fa fa-heart" style="color: #ffc107"></span>':'').'<span class="badge badge-warning badge-pill">'.BLUDIT_VERSION.'</span></a>';
$html .= '<a id="new-version" style="display: none;" target="_blank" href="https://www.bludit.com">'.$L->get('New version available').' <span class="fa fa-bell" style="color: red"></span></a>';
$html = '';
if ($this->getValue('showCurrentVersion')) {
$html = '<a id="current-version" class="nav-link" href="'.HTML_PATH_ADMIN_ROOT.'about'.'">Version '.(defined('BLUDIT_PRO')?'<span class="fa fa-heart" style="color: #ffc107"></span>':'').'<span class="badge badge-warning badge-pill">'.BLUDIT_VERSION.'</span></a>';
}
if ($this->getValue('newVersionAlert')) {
$html .= '<a id="new-version" style="display: none;" target="_blank" href="https://www.bludit.com">'.$L->get('New version available').' <span class="fa fa-bell" style="color: red"></span></a>';
}
return $html;
}
public function adminBodyEnd()
{
// The follow Javascript get via AJAX the information about new versions
// The script is on /bl-plugins/version/js/version.js
$jsPath = $this->phpPath() . 'js' . DS;
$scripts = '<script>' . file_get_contents($jsPath . 'version.js') . '</script>';
return $scripts;
if ($this->getValue('newVersionAlert')) {
// The follow Javascript get via AJAX the information about new versions
// The script is on /bl-plugins/version/js/version.js
$jsPath = $this->phpPath() . 'js' . DS;
$scripts = '<script>' . file_get_contents($jsPath . 'version.js') . '</script>';
return $scripts;
}
return false;
}
}