2017-06-28 00:31:40 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class pluginVersion extends Plugin {
|
|
|
|
|
2020-03-14 12:02:23 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-07-02 00:24:53 +02:00
|
|
|
public function adminSidebar()
|
2017-06-28 22:27:17 +02:00
|
|
|
{
|
2018-08-05 17:54:20 +02:00
|
|
|
global $L;
|
2020-03-14 12:02:23 +01:00
|
|
|
$html = '';
|
|
|
|
if ($this->getValue('showCurrentVersion')) {
|
2020-03-21 23:00:17 +01:00
|
|
|
$html = '<a id="current-version" class="nav-link" href="'.HTML_PATH_ADMIN_ROOT.'about'.'">'.$L->get('Version').' '.(defined('BLUDIT_PRO')?'<span class="fa fa-heart" style="color: #ffc107"></span>':'').'<span class="badge badge-warning badge-pill">'.BLUDIT_VERSION.'</span></a>';
|
2020-03-14 12:02:23 +01:00
|
|
|
}
|
|
|
|
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>';
|
|
|
|
}
|
2018-03-06 23:50:31 +01:00
|
|
|
return $html;
|
2017-09-03 23:29:09 +02:00
|
|
|
}
|
|
|
|
|
2018-03-06 23:50:31 +01:00
|
|
|
public function adminBodyEnd()
|
2017-06-28 00:31:40 +02:00
|
|
|
{
|
2020-03-14 12:02:23 +01:00
|
|
|
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;
|
2017-06-28 00:31:40 +02:00
|
|
|
}
|
2020-03-21 23:00:17 +01:00
|
|
|
}
|