ported plugin drag&drop to jquery
This commit is contained in:
@ -313,46 +313,25 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) {
|
||||
$col_assoc[$sidebar . '_col'] = $sidebar;
|
||||
}
|
||||
|
||||
/* preparse Javascript-generated input */
|
||||
if (isset($_POST['SAVE']) && !empty($_POST['serendipity']['pluginorder'])) {
|
||||
$parts = explode(':', $_POST['serendipity']['pluginorder']);
|
||||
|
||||
foreach($parts AS $sidepart) {
|
||||
preg_match('@^(.+)\((.*)\)$@imsU', $sidepart, $matches);
|
||||
if (!isset($col_assoc[$matches[1]])) {
|
||||
continue;
|
||||
}
|
||||
$pluginsidelist = explode(',', $matches[2]);
|
||||
foreach($pluginsidelist AS $pluginname) {
|
||||
$pluginname = trim(urldecode(str_replace(array('s9ycid', '-'), array('', '%'), $pluginname)));
|
||||
|
||||
if (empty($pluginname)) {
|
||||
continue;
|
||||
}
|
||||
$serendipity['POST']['placement'][$pluginname] = $col_assoc[$matches[1]];
|
||||
$new_order[] = $pluginname;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($new_order)) {
|
||||
foreach($new_order AS $new_order_pos => $order_plugin) {
|
||||
serendipity_db_query("UPDATE {$serendipity['dbPrefix']}plugins SET sort_order = ". (int)$new_order_pos . " WHERE name='" . serendipity_db_escape_string($order_plugin) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['SAVE']) && isset($_POST['serendipity']['placement']) && serendipity_checkFormToken()) {
|
||||
foreach ($_POST['serendipity']['placement'] as $plugin_name => $placement) {
|
||||
if (isset($_POST['SAVE']) && serendipity_checkFormToken()) {
|
||||
$pos=0;
|
||||
foreach($_POST['serendipity']['plugin'] as $plugin) {
|
||||
serendipity_db_query("UPDATE {$serendipity['dbPrefix']}plugins
|
||||
SET
|
||||
sort_order = ". $pos . "
|
||||
WHERE
|
||||
name='" . serendipity_db_escape_string($plugin['id']) . "'");
|
||||
|
||||
serendipity_plugin_api::update_plugin_placement(
|
||||
addslashes($plugin_name),
|
||||
addslashes($placement)
|
||||
addslashes($plugin['id']),
|
||||
addslashes($plugin['placement'])
|
||||
);
|
||||
|
||||
serendipity_plugin_api::update_plugin_owner(
|
||||
addslashes($plugin_name),
|
||||
addslashes($_POST['serendipity']['ownership'][$plugin_name])
|
||||
addslashes($plugin['id']),
|
||||
addslashes($_POST['serendipity']['ownership'][$plugin['name']])
|
||||
);
|
||||
$pos++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,10 +119,39 @@
|
||||
<span class="msg_success"><span class="icon-ok-circle"></span> {$CONST.DONE}:{$CONST.SETTINGS_SAVED_AT|sprintf:"$timestamp"}</span>
|
||||
{/if}
|
||||
<h2>{$CONST.BELOW_IS_A_LIST_OF_INSTALLED_PLUGINS}</h2>
|
||||
{if $eyecandy}
|
||||
<script src="{serendipity_getFile file="dragdrop.js"}"></script>
|
||||
{if $eyecandy}
|
||||
<script src="{serendipity_getFile file="admin/jquery.sortable.js"}"></script>
|
||||
<script src="{serendipity_getFile file="admin/dragdrop.js"}"></script>
|
||||
<style>
|
||||
body.dragging, body.dragging * {
|
||||
cursor: move !important;
|
||||
}
|
||||
|
||||
.dragged {
|
||||
position: absolute;
|
||||
opacity: 0.5;
|
||||
z-index: 2000;
|
||||
}
|
||||
|
||||
.pluginmanager_container li.placeholder {
|
||||
position: relative;
|
||||
height: 50px;
|
||||
border: 1px solid black;
|
||||
}
|
||||
.pluginmanager_container li.placeholder:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
width: 0;
|
||||
height: 0;
|
||||
margin-top: -5px;
|
||||
left: -5px;
|
||||
top: -4px;
|
||||
border: 5px solid transparent;
|
||||
border-left-color: red;
|
||||
border-right: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
<span class="msg_notice"><span class="icon-info-circle"></span> {$CONST.PREFERENCE_USE_JS_WARNING}</span>
|
||||
{/if}
|
||||
<section id="pluginlist_sidebar">
|
||||
<h3>{$CONST.SIDEBAR_PLUGINS}</h3>
|
||||
|
@ -6,30 +6,11 @@
|
||||
{if !$eyecandy}
|
||||
<form action="?serendipity[adminModule]=plugins" method="post">
|
||||
{elseif !$event_only}
|
||||
{* Smarty 3 has a new auto literal option which is enabled by default.
|
||||
When the { is followed by a space it's not interpreted as smarty delimiter but literal. *}
|
||||
<script>
|
||||
function templatePluginMoverInit() {
|
||||
|
||||
{foreach $plugin_placements AS $sidebar}
|
||||
|
||||
{($is_first) ? 'var ' : ''}list = document.getElementById("{$sidebar}_col");
|
||||
DragDrop.makeListContainer(list, 'g1');
|
||||
list.onDragOver = function() { this.style["border"] = "1px solid #4d759b"; };
|
||||
list.onDragOut = function() { this.style["border"] = "none"; };
|
||||
{assign var="is_first" value=false}
|
||||
|
||||
{/foreach}
|
||||
|
||||
}
|
||||
addLoadEvent(templatePluginMoverInit);
|
||||
</script>
|
||||
|
||||
<form action="?serendipity[adminModule]=plugins" method="post" onsubmit="pluginMovergetSort(); return true">
|
||||
<form action="?serendipity[adminModule]=plugins" method="post">
|
||||
<input id="order" name="serendipity[pluginorder]" type="hidden" value="">
|
||||
{else}
|
||||
<script>addLoadEvent(pluginMoverInitEvent);</script>
|
||||
<form action="?serendipity[adminModule]=plugins" method="post" onsubmit="pluginMovergetSortEvent(); return true">
|
||||
<form action="?serendipity[adminModule]=plugins" method="post">
|
||||
<input id="eventorder" name="serendipity[pluginorder]" type="hidden" value="">
|
||||
{/if}
|
||||
{$serendipity_setFormToken}
|
||||
@ -38,9 +19,12 @@
|
||||
<div class="pluginmanager_side pluginmanager_{($event_only) ? 'event' : 'sidebar'}">
|
||||
<h4>{$plugin_placement['ptitle']}</h4>
|
||||
|
||||
<ol id="{$plugin_placement['pid']}_col" class="pluginmanager_container plainList">
|
||||
<ol id="{$plugin_placement['pid']}_col" data-placement="{$plugin_placement['pid']}" class="pluginmanager_container plainList">
|
||||
{foreach $plugin_placement['plugin_data'] as $plugin_data}
|
||||
<li id="{$plugin_data['css_key']}" class="pluginmanager_plugin pluginmanager_item_{cycle values="odd,even"}">
|
||||
<li id="{$plugin_data['css_key']}" class="pluginmanager_plugin pluginmanager_item_{cycle values="odd,even"}"=>
|
||||
<input type="hidden" name="serendipity[plugin][{$plugin_data['name']}][id]" value="{$plugin_data['name']}" />
|
||||
<input type="hidden" name="serendipity[plugin][{$plugin_data['name']}][position]" value="{$plugin_data@index}" />
|
||||
<input type="hidden" name="serendipity[plugin][{$plugin_data['name']}][placement]" value="{$plugin_placement['pid']}" />
|
||||
{if $plugin_data['is_plugin_editable']}
|
||||
<div class="form_check">
|
||||
<input id="remove_{$plugin_data['name']}" name="serendipity[plugin_to_remove][]" type="checkbox" value="{$plugin_data['name']}">
|
||||
@ -79,7 +63,7 @@
|
||||
<span class="plugin_count block_level">{$CONST.PLUGIN_AVAILABLE_COUNT|sprintf:$total}</span>
|
||||
</div>
|
||||
<div class="form_buttons">
|
||||
<input class="state_cancel" name="REMOVE" type="submit" title="{$CONST.DELETE}" value="{$CONST.REMOVE_TICKED_PLUGINS}">
|
||||
<input class="state_cancel" name="REMOVE" type="submit" title="{$CONST.REMOVE_TICKED_PLUGINS}" value="{$CONST.DELETE}">
|
||||
<input name="SAVE" type="submit" title="{$CONST.SAVE_CHANGES_TO_LAYOUT}" value="{$CONST.SAVE}">
|
||||
</div>
|
||||
</form>
|
||||
|
Reference in New Issue
Block a user