New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Change order of plugins #198
Comments
Hi, yes is in my todoList, thanks. |
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? |
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.)
<?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;
}
}
?>
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));
}
}
<?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
// ============================================================================
<?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>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'plugins-sidebar' ?>"><?php $L->p('Sidebar Position') ?></a></li> somewhere around
<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)
/* ----------- SIDEBAR SORT ----------- */
#sortable .handle {
margin-right: 0.75em;
font-size: 1.3em;
cursor: grab;
} Finished. |
@metaskop you can make a pull request and add the plugin |
@Turqueso Done. Now you can sort all activated plugins. |
This request is implemented |
It would be nice to change the order of loaded plugins like I can do it with pages.
The text was updated successfully, but these errors were encountered: