Comments (6)
Hi, yes is in my todoList, thanks.
from bludit.
A much better way would be to simply switch between a plugin view where you can see/edit all plugins, and then viewing only the plugins with a usable function, like 'creating backups', 'maintenance switch' and some others.
This should be easy to do don't you think?
from bludit.
Coming from https://forum.bludit.com/viewtopic.php?f=6&t=786 I wrote an "extension" to sort the plugins in the sidebar. No guarantee that it's the best way, neither that it's bug free or secure. So: use at your own risk.
First of all I relied on jQueryUI Sortable to find at http://jqueryui.com/download/ (Toggle off everything and then click on "Sortable" in "Interactions". Everything else needed will automatically be selected.)
Put jquery-ui.min.js
in /bl-kernel/admin/themes/default/js
- Create /bl-kernel/dbsidebar.class.php
<?php
class dbSidebar extends dbJSON {
function __construct() {
parent::__construct(PATH_DATABASES.'sidebar-positions.php');
}
public function getDB() {
return $this->db;
}
public function get($dirName) {
if (isset($this->db[$dirName])) {
return $this->db[$dirName];
}
return 1;
}
public function set($args)
{
$i = 1;
foreach($args as $field=>$value)
{
$this->db[Sanitize::html($field)] = $i++;
}
if( $this->save() === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
return false;
}
return true;
}
}
?>
-
/bl-kernel/init.php: add
$dbSidebar = new dbSidebar();
somewhere around//Objects
(line 184 in my file) -
/bl-kernel/helpers/theme.class.php: add
public static function sidebarSort($obj1, $obj2) {
global $dbSidebar;
if ($dbSidebar->get($obj1->directoryName) == $dbSidebar->get($obj2->directoryName)) {
return 0;
}
return ($dbSidebar->get($obj1->directoryName) < $dbSidebar->get($obj2->directoryName))? -1 : 1;
}
and change
public static function plugins($type)
{
global $plugins;
foreach($plugins[$type] as $plugin)
{
echo call_user_func(array($plugin, $type));
}
}
to
public static function plugins($type)
{
global $plugins;
if ($type == 'siteSidebar') {
usort($plugins['siteSidebar'], "Theme::sidebarSort");
}
foreach($plugins[$type] as $plugin)
{
echo call_user_func(array($plugin, $type));
}
}
-
/bl-languages/en_US.json
add
"sidebar-position": "Sidebar Positions",
somewhere (line 80 in my file) -
Create /bl-kernel/admin/controllers/plugins-sidebar.php
<?php defined('BLUDIT') or die('Bludit CMS.');
// ============================================================================
// Check role
// ============================================================================
if($Login->role()!=='admin') {
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
Redirect::page('admin', 'dashboard');
}
// ============================================================================
// Functions
// ============================================================================
function setSettings($args)
{
global $dbSidebar;
global $Language;
if($dbSidebar->set($args) ) {
Alert::set($Language->g('the-changes-have-been-saved'));
}
else {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the settings.');
}
return true;
}
// ============================================================================
// Main before POST
// ============================================================================
// ============================================================================
// POST Method
// ============================================================================
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
{
setSettings($_POST);
Redirect::page('admin', $layout['controller']);
}
// ============================================================================
// Main after POST
// ============================================================================
- Create /bl-kernel/admin/views/plugins-sidebar.php
<?php
$dbSidebar = new dbSidebar();
HTML::title(array('title'=>$L->g('Sidebar Position'), 'icon'=>'puzzle-piece'));
HTML::formOpen(array('class'=>'uk-form-horizontal'));
HTML::formInputHidden(array(
'name'=>'tokenCSRF',
'value'=>$Security->getTokenCSRF()
));
usort($plugins['siteSidebar'], "Theme::sidebarSort");
echo "\n".'<table class="uk-table">'."\n";
echo '<tbody id="sortable">'."\n";
foreach($plugins['siteSidebar'] as $Plugin) {
echo ' <tr class="uk-width-1-4"><td><span class="handle">≡</span>';
HTML::formInputHidden(array(
'name'=>$Plugin->directoryName(),
'value'=>''
));
echo $Plugin->name().'</td></tr>'."\n";
}
echo '</tbody>'."\n";
echo '</table>'."\n";
echo '<div class="uk-form-row">
<div class="uk-form-controls">
<button type="submit" class="uk-button uk-button-primary">'.$L->g('Save').'</button>
</div>
</div>';
HTML::formClose();
?>
<script src="<?php echo HTML_PATH_ADMIN_THEME_JS.'jquery-ui.min.js'; ?>"></script>
<script>
$(function() {
jQuery("#sortable").sortable({ handle: ".handle" });
});
</script>
- /bl-kernel/admin/themes/default/index.php:
- add
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'plugins-sidebar' ?>"><?php $L->p('Sidebar Position') ?></a></li>
somewhere around <!-- Offcanvas for Mobile -->
(line 70 in my file)
- add
<li <?php echo ($layout['view']=='plugins-sidebar')?'class="uk-active"':'' ?>>
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'plugins-sidebar' ?>"><?php $L->p('Sidebar Position') ?></a>
</li>
(line 136-138 in my file)
- /bl-kernel/admin/themes/default/css/default.css
append
/* ----------- SIDEBAR SORT ----------- */
#sortable .handle {
margin-right: 0.75em;
font-size: 1.3em;
cursor: grab;
}
Finished.
from bludit.
@metaskop you can make a pull request and add the plugin
from bludit.
@Turqueso Done. Now you can sort all activated plugins.
from bludit.
This request is implemented
from bludit.
Related Issues (20)
- version 3.15.0 is vulnerable to stored xss HOT 3
- Jalali/Hijri calendars
- [tag] Make adding tags more easier / faster to reach
- [tag] Provide suggestions for tags already used HOT 2
- popeye theme text width in blog posts HOT 1
- Bludit closes content page without saving HOT 1
- Usability Bug: First save redirects to content list, others move cursor up
- Usability Improvement: Store unsaved text in localstorage, improve autosave, and connection handling
- Image (security) issues (bludit 3.15) HOT 1
- Bludit 3.15: Deleting a page keeps the image folder
- Is bludit 1.6.2 download legit? HOT 1
- API Plugin, numberofitems in settings is not used
- How to filter posts by category on the home page? HOT 1
- version 3.15.0 is vulnerable to stored xss or Admin privilaged account creation. HOT 1
- Image Upload Error
- 403 error with HTML plug in
- How to customize <title></title> HOT 2
- Feature Request: Add auto-updater for Plugins/Themes/Bludit itself
- Security Vulnerabilities in Bludit - Please get in touch HOT 2
- Password length check is variable but also fix coded in \bl-kernel\functions.php
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bludit.