New Hook for plugins adminSidebar

This commit is contained in:
Diego Najar 2018-07-02 00:24:53 +02:00
parent f253b833f2
commit be555b289b
25 changed files with 126 additions and 108 deletions

View File

@ -1,8 +1,12 @@
<!-- Use .flex-column to set a vertical direction -->
<ul class="nav flex-column pt-4">
<li class="nav-item mb-4">
<li class="nav-item mb-4" style="margin-left: -4px;">
<?php if (defined('BLUDIT_PRO')): ?>
<img src="<?php echo HTML_PATH_ADMIN_THEME ?>img/logo.svg" width="20" height="20" alt=""><span class="ml-2 align-middle">BLUDIT PRO
<?php else: ?>
<img src="<?php echo HTML_PATH_ADMIN_THEME ?>img/logo.svg" width="20" height="20" alt=""> BLUDIT
<?php endif; ?>
</li>
<li class="nav-item">
@ -47,6 +51,17 @@
<a class="nav-link" href="<?php echo HTML_PATH_ADMIN_ROOT.'about' ?>"><?php $L->p('About') ?></a>
</li>
<?php
if (!empty($plugins['adminSidebar'])) {
echo '<li class="nav-item"><hr></li>';
foreach ($plugins['adminSidebar'] as $pluginSidebar) {
echo '<li class="nav-item">';
echo $pluginSidebar->adminSidebar();
echo '</li>';
}
}
?>
<?php endif; ?>
<li class="nav-item mt-5">

View File

@ -11,18 +11,17 @@
<!-- CSS -->
<?php
echo Theme::bootstrapCSS();
echo Bootstrap::css(array(
'bootstrap.min.css',
'bludit.css'
));
?>
<!-- Javascript -->
<?php
echo Bootstrap::js(array(
'jquery.min.js',
'bootstrap-bundle.min.js'
));
echo Theme::jquery();
echo Theme::bootstrapJS();
?>
<!-- Plugins -->

View File

@ -1,8 +1,8 @@
<?php defined('BLUDIT') or die('Bludit CMS.');
// Bludit version
define('BLUDIT_VERSION', '2.3.4');
define('BLUDIT_CODENAME', '1-Commit');
define('BLUDIT_VERSION', '3.0.0');
define('BLUDIT_CODENAME', '');
define('BLUDIT_RELEASE_DATE', '2018-04-02');
define('BLUDIT_BUILD', '20180402');

View File

@ -45,7 +45,7 @@ class bluditAjax {
ajaxRequest.abort();
}
console.log("[INFO] Bludit AJAX: userLogged(): running");
console.log("[INFO] [BLUDIT AJAX] [userLogged()] Checking if the user is logged.");
ajaxRequest = $.ajax({
type: "POST",
@ -56,20 +56,16 @@ class bluditAjax {
});
ajaxRequest.done(function (response, textStatus, jqXHR) {
console.log("[INFO] Bludit AJAX: userLogged(): done handler");
console.log("[INFO] [BLUDIT AJAX] [userLogged()] The user is logged.");
});
ajaxRequest.fail(function (jqXHR, textStatus, errorThrown) {
// The fail is produced by admin.php when the user is not logged the ajax request is not possible and returns 401
console.log("[INFO] Bludit AJAX: userLogged(): fail handler");
console.log("[INFO] [BLUDIT AJAX] [userLogged()] The user is NOT logged.");
if (jqXHR.status==401) {
callBack("Your are not more logged, Bludit can't save your settings and content.");
}
});
ajaxRequest.always(function () {
console.log("[INFO] Bludit AJAX: userLogged(): always handler");
});
}
generateSlug(text, parentKey, currentKey, callBack) {

View File

@ -83,10 +83,7 @@ class Login {
public function verifyUser($username, $password)
{
$username = Sanitize::html($username);
$password = Sanitize::html($password);
$username = trim($username);
$password = trim($password);
if (empty($username) || empty($password)) {
Log::set(__METHOD__.LOG_SEP.'Username or password empty. Username: '.$username);

View File

@ -2,6 +2,6 @@
"plugin-data":
{
"name": "About",
"description": "Show a small description about your site or about yourself."
"description": "Show a small description of your site or about yourself."
}
}

View File

@ -14,7 +14,11 @@ class pluginAbout extends Plugin {
{
global $Language;
$html = '<div>';
$html = '<div class="alert alert-primary" role="alert">';
$html .= $this->description();
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$Language->get('Label').'</label>';
$html .= '<input name="label" type="text" value="'.$this->getValue('label').'">';
$html .= '<span class="tip">'.$Language->get('This title is almost always used in the sidebar of the site').'</span>';

View File

@ -56,14 +56,17 @@ class pluginBackup extends Plugin {
return false;
}
public function adminSidebar()
{
$backups = $this->backupList();
return '<a class="nav-link" href="'.HTML_PATH_ADMIN_ROOT.'configure-plugin/'.$this->className().'">Backup <span class="badge badge-primary badge-pill">'.count($backups).'</span></a>';
}
public function form()
{
global $Language;
$backups = Filesystem::listDirectories($this->workspace(), '*', true);
if ($this->zip) {
$backups = Filesystem::listFiles($this->workspace(), '*', 'zip', true);
}
$backups = $this->backupList();
$html = '';
if (empty($backups)) {
@ -95,6 +98,16 @@ class pluginBackup extends Plugin {
return $html;
}
public function backupList()
{
if ($this->zip) {
$backups = Filesystem::listFiles($this->workspace(), '*', 'zip', true);
} else {
$backups = Filesystem::listDirectories($this->workspace(), '*', true);
}
return $backups;
}
public function createBackup()
{
// Current backup directory

View File

@ -16,7 +16,11 @@ class pluginCategories extends Plugin {
{
global $Language;
$html = '<div>';
$html = '<div class="alert alert-primary" role="alert">';
$html .= $this->description();
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$Language->get('Label').'</label>';
$html .= '<input name="label" type="text" value="'.$this->getValue('label').'">';
$html .= '<span class="tip">'.$Language->get('This title is almost always used in the sidebar of the site').'</span>';

View File

@ -15,7 +15,11 @@ class pluginDisqus extends Plugin {
{
global $Language;
$html = '<div>';
$html = '<div class="alert alert-primary" role="alert">';
$html .= $this->description();
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$Language->get('disqus-shortname').'</label>';
$html .= '<input name="shortname" id="jsshortname" type="text" value="'.$this->getValue('shortname').'">';
$html .= '</div>';
@ -48,11 +52,11 @@ class pluginDisqus extends Plugin {
return false;
}
if ( !$Url->notFound() &&
if ( !$Url->notFound() &&
( $Url->whereAmI()=='page' &&
(($this->getDbField('enablePosts') && $Page->status()=='published') ||
(($this->getDbField('enablePosts') && $Page->status()=='published') ||
($this->getDbField('enablePages') && $Page->status()=='static'))
) &&
) &&
$page->allowComments() ) {
$html = '<div id="disqus_thread"></div>';
$html .= '<script type="text/javascript">

View File

@ -15,20 +15,24 @@ class pluginHTMLCode extends Plugin {
{
global $Language;
$html = '<div>';
$html .= '<label>Theme Head</label>';
$html = '<div class="alert alert-primary" role="alert">';
$html .= $this->description();
$html .= '</div>';
$html .= '<div>';
$html .= '<label>Site Head</label>';
$html .= '<textarea name="head" id="jshead">'.$this->getValue('head').'</textarea>';
$html .= '<span class="tip">'.$Language->get('insert-code-in-the-theme-inside-the-tag-head').'</span>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>Theme Header</label>';
$html .= '<label>Site Header</label>';
$html .= '<textarea name="header" id="jsheader">'.$this->getValue('header').'</textarea>';
$html .= '<span class="tip">'.$Language->get('insert-code-in-the-theme-at-the-top').'</span>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>Theme Footer</label>';
$html .= '<label>Site Footer</label>';
$html .= '<textarea name="footer" id="jsfooter">'.$this->getValue('footer').'</textarea>';
$html .= '<span class="tip">'.$Language->get('insert-code-in-the-theme-at-the-bottom').'</span>';
$html .= '</div>';

View File

@ -5,7 +5,7 @@ class pluginMaintenanceMode extends Plugin {
public function init()
{
$this->dbFields = array(
'enable'=>true,
'enable'=>false,
'message'=>'Temporarily down for maintenance.'
);
}
@ -14,7 +14,11 @@ class pluginMaintenanceMode extends Plugin {
{
global $Language;
$html = '<div>';
$html = '<div class="alert alert-primary" role="alert">';
$html .= $this->description();
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$Language->get('Enable maintenance mode').'</label>';
$html .= '<select name="enable">';
$html .= '<option value="true" '.($this->getValue('enable')===true?'selected':'').'>Enabled</option>';

View File

@ -17,7 +17,11 @@ class pluginNavigation extends Plugin {
{
global $Language;
$html = '<div>';
$html = '<div class="alert alert-primary" role="alert">';
$html .= $this->description();
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$Language->get('Label').'</label>';
$html .= '<input id="jslabel" name="label" type="text" value="'.$this->getValue('label').'">';
$html .= '<span class="tip">'.$Language->get('This title is almost always used in the sidebar of the site').'</span>';
@ -29,6 +33,7 @@ class pluginNavigation extends Plugin {
$html .= '<option value="true" '.($this->getValue('homeLink')===true?'selected':'').'>'.$Language->get('Enabled').'</option>';
$html .= '<option value="false" '.($this->getValue('homeLink')===false?'selected':'').'>'.$Language->get('Disabled').'</option>';
$html .= '</select>';
$html .= '<span class="tip">'.$Language->get('Show the home link on the sidebar').'</span>';
$html .= '</div>';
if (ORDER_BY=='date') {

View File

@ -14,7 +14,11 @@ class pluginOpenGraph extends Plugin {
{
global $Language;
$html = '<div>';
$html = '<div class="alert alert-primary" role="alert">';
$html .= $this->description();
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$Language->get('Default image').'</label>';
$html .= '<input id="jsdefaultImage" name="defaultImage" type="text" value="'.$this->getValue('defaultImage').'" placeholder="https://">';
$html .= '<span class="tip">Set a default image for the content without pictures.</span>';

View File

@ -15,7 +15,11 @@ class pluginRSS extends Plugin {
{
global $Language;
$html = '<div>';
$html = '<div class="alert alert-primary" role="alert">';
$html .= $this->description();
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$Language->get('RSS URL').'</label>';
$html .= '<a href="'.Theme::rssUrl().'">'.Theme::rssUrl().'</a>';
$html .= '</div>';
@ -114,7 +118,7 @@ class pluginRSS extends Plugin {
public function beforeAll()
{
$webhook = 'rss.xml';
if( $this->webhook($webhook) ) {
if ($this->webhook($webhook)) {
// Send XML header
header('Content-type: text/xml');
$doc = new DOMDocument();
@ -127,7 +131,7 @@ class pluginRSS extends Plugin {
// Print the XML
echo $doc->saveXML();
// Stop Bludit running
// Stop Bludit execution
exit(0);
}
}

View File

@ -16,7 +16,11 @@ class pluginStaticPages extends Plugin {
{
global $Language;
$html = '<div>';
$html = '<div class="alert alert-primary" role="alert">';
$html .= $this->description();
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$Language->get('Label').'</label>';
$html .= '<input id="jslabel" name="label" type="text" value="'.$this->getValue('label').'">';
$html .= '<span class="tip">'.$Language->get('This title is almost always used in the sidebar of the site').'</span>';
@ -27,8 +31,8 @@ class pluginStaticPages extends Plugin {
$html .= '<select name="homeLink">';
$html .= '<option value="true" '.($this->getValue('homeLink')===true?'selected':'').'>'.$Language->get('Enabled').'</option>';
$html .= '<option value="false" '.($this->getValue('homeLink')===false?'selected':'').'>'.$Language->get('Disabled').'</option>';
$html .= '<span class="tip">'.$Language->get('show-the-home-link-on-the-sidebar').'</span>';
$html .= '</select>';
$html .= '<span class="tip">'.$Language->get('show-the-home-link-on-the-sidebar').'</span>';
$html .= '</div>';
return $html;

View File

@ -13,7 +13,11 @@ class pluginTags extends Plugin {
{
global $Language;
$html = '<div>';
$html = '<div class="alert alert-primary" role="alert">';
$html .= $this->description();
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$Language->get('Label').'</label>';
$html .= '<input id="jslabel" name="label" type="text" value="'.$this->getValue('label').'">';
$html .= '<span class="tip">'.$Language->get('This title is almost always used in the sidebar of the site').'</span>';

View File

@ -14,26 +14,15 @@ class pluginTwitterCards extends Plugin {
{
global $Language;
$html = '<div>';
$html = '<div class="alert alert-primary" role="alert">';
$html .= $this->description();
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$Language->get('Default image').'</label>';
$html .= '<input id="jsdefaultImage" name="defaultImage" type="text" value="'.$this->getValue('defaultImage').'" placeholder="https://">';
$html .= '</div>';
/*
$html = '<div>';
$html .= '<label>'.$Language->get('Default image').'</label>';
$html .= '<select name="defaultImage">';
$images = Filesystem::listFiles(PATH_UPLOADS);
foreach ($images as $image) {
$base = basename($image);
$html .= '<option value="'.$base.'" '.(($this->getValue('defaultImage')==$base)?'selected':'').'>'.$base.'</option>';
}
$html .= '</select>';
$html .= '</div>';
*/
return $html;
}

View File

@ -1,21 +1,21 @@
function getLatestVersion() {
$("#current-version").show();
console.log("[INFO] [PLUGIN VERSION] Getting list of versions of Bludit.");
$.ajax({
url: "https://version.bludit.com",
method: "GET",
dataType: 'json',
success: function(json) {
// Constant BLUDIT_BUILD is defined on functions.js
// Constant BLUDIT_BUILD is defined on variables.js
if (json.stable.build > BLUDIT_BUILD) {
$("#current-version").hide();
$("#new-version").show();
}
},
error: function(json) {
console.log("Error when try to get the version.");
console.log("[WARN] [PLUGIN VERSION] There is some issue to get the version status.");
}
});
}

View File

@ -2,6 +2,6 @@
"plugin-data":
{
"name": "Version",
"description": "Show the current version on the bottom-right of the admin panel, and check periodically for new Bludit releases."
"description": "Show the current version on the sidebar of the admin panel, and check periodically for new Bludit releases."
}
}

View File

@ -2,6 +2,6 @@
"plugin-data":
{
"name": "Versión",
"description": "Muestra la versión actual en la parte inferior derecha del panel de administración y comprueba periódicamente si hay nuevas versiones de Bludit."
"description": "Muestra la versión actual en la barra del panel de administración y comprueba periódicamente si hay nuevas versiones de Bludit."
}
}

View File

@ -2,53 +2,18 @@
class pluginVersion extends Plugin {
public function adminHead()
{
$html = '<style>
#plugin-version {
display: block;
position: fixed;
bottom: 0;
right: 0;
background: #eee;
padding: 2px 10px;
font-size: 0.9em;
color: #555;
}
#plugin-version a {
color: #777;
margin-left: 8px;
}
#new-version,
#current-version {
display: none;
}
</style>';
return $html;
}
public function adminBodyBegin()
public function adminSidebar()
{
global $Language;
$html = '<div id="plugin-version">';
$html .= '<div id="new-version"><a target="_blank" href="https://www.bludit.com"><i class="fa fa-download" aria-hidden="true"></i> '.$Language->get('New version available').'</a></div>';
if (defined('BLUDIT_PRO')) {
$html .= '<div id="current-version">Bludit PRO v'.BLUDIT_VERSION.'</div>';
} else {
$html .= '<div id="current-version">Bludit v'.BLUDIT_VERSION.'<a target="_blank" href="https://pro.bludit.com">'.$Language->get('Upgrade to Bludit PRO').'</a></div>';
}
$html .= '</div>';
$html .= '</div>';
$html = '<a id="current-version" class="nav-link" href="'.HTML_PATH_ADMIN_ROOT.'about'.'">Version '.(defined('BLUDIT_PRO')?'<span class="oi oi-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">'.$Language->get('New version available').' <span class="oi oi-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;

View File

@ -617,13 +617,13 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
<link rel="shortcut icon" type="image/x-icon" href="bl-kernel/admin/themes/booty/img/favicon.png?version=<?php echo time() ?>">
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="bl-kernel/admin/themes/booty/css/bootstrap.min.css?version=<?php echo time() ?>">
<link rel="stylesheet" type="text/css" href="bl-kernel/css/bootstrap.min.css?version=<?php echo time() ?>">
<link rel="stylesheet" type="text/css" href="bl-kernel/admin/themes/booty/css/bludit.css?version=<?php echo time() ?>">
<!-- Javascript -->
<script charset="utf-8" src="bl-kernel/admin/themes/booty/js/jquery.min.js?version=<?php echo time() ?>"></script>
<script charset="utf-8" src="bl-kernel/admin/themes/booty/js/bootstrap-bundle.min.js?version=<?php echo time() ?>"></script>
<script charset="utf-8" src="bl-kernel/admin/themes/booty/js/jstz.min.js?version=<?php echo time() ?>"></script>
<script charset="utf-8" src="bl-kernel/js/jquery.min.js?version=<?php echo time() ?>"></script>
<script charset="utf-8" src="bl-kernel/js/bootstrap-bundle.min.js?version=<?php echo time() ?>"></script>
<script charset="utf-8" src="bl-kernel/js/jstz.min.js?version=<?php echo time() ?>"></script>
</head>
<body class="login">
<div class="container">

View File

@ -1,5 +1,8 @@
Things to do:
- Installer
-- Check password lenght
- settings->advanced->Predefined pages->Page not found
-- Search and select a page