From ef346ff4beccbe18796f03e945dd31e962440323 Mon Sep 17 00:00:00 2001 From: Garvin Hicking Date: Sun, 3 Aug 2008 11:33:39 +0000 Subject: [PATCH] Allow sequencing widget to disable/enable each sequence entry. --- docs/NEWS | 4 +++ include/admin/plugins.inc.php | 18 ++++++++++ include/functions_plugins_admin.inc.php | 46 +++++++++++++++++++------ 3 files changed, 57 insertions(+), 11 deletions(-) diff --git a/docs/NEWS b/docs/NEWS index c7572b3b..356f2d01 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -3,6 +3,10 @@ Version 1.4 () ------------------------------------------------------------------------ + * Allow 'sequence' widget to enable/disable each config item, + if the property "checkable" is added to the introspect method. + (garvinhicking) + * Do not show title of entries marked as public/private when viewed without permissions. Patch thanks to Anthem diff --git a/include/admin/plugins.inc.php b/include/admin/plugins.inc.php index bdbe2f3d..a1e281d6 100644 --- a/include/admin/plugins.inc.php +++ b/include/admin/plugins.inc.php @@ -89,6 +89,24 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) { if ($validate === true) { // echo $config_item . " validated: $validate
\n"; + + if (!empty($_POST['serendipity']['plugin']['override'][$config_item])) { + $value = $_POST['serendipity']['plugin']['override'][$config_item]; + } + + if (is_array($_POST['serendipity']['plugin']['activate'][$config_item])) { + $values = explode(',', $value); + $out_values = array(); + foreach($values AS $out_value) { + if (!isset($_POST['serendipity']['plugin']['activate'][$config_item][$out_value])) { + continue; + } + + $out_values[] = $out_value; + } + $value = implode(',', $out_values); + } + $plugin->set_config($config_item, $value); } else { $save_errors[] = $validate; diff --git a/include/functions_plugins_admin.inc.php b/include/functions_plugins_admin.inc.php index ecc3c2aa..fc85ca53 100644 --- a/include/functions_plugins_admin.inc.php +++ b/include/functions_plugins_admin.inc.php @@ -666,13 +666,15 @@ EOS; } $cname = $cbag->get('name'); $cdesc = $cbag->get('description'); + $checkable = $cbag->get('checkable'); + /** Unordered array of values */ $items = $cbag->get('values'); if (!is_array($items)) { $items = null; } /** Array specifying order to use values in $items */ $order = null; if ($value) { - $order = explode(',', $value); + $store_order = $order = explode(',', $value); } $uparrow_img = serendipity_getTemplateFile('admin/img/uparrow.png'); $downarrow_img = serendipity_getTemplateFile('admin/img/downarrow.png'); @@ -773,6 +775,11 @@ EOS; print '
  • ' . "\n"; // Make a handle with ID 'g$id' print '
    ' . "\n"; + + if ($checkable) { + print ' ' . "\n"; + } + // Add the item contents print ' '.$items[$id]['display'].'' . "\n"; if (isset($items[$id]['img'])) { @@ -785,7 +792,7 @@ EOS; print " \n"; } else { print << + @@ -796,7 +803,7 @@ EOS; print " \n"; } else { print << + @@ -815,18 +822,35 @@ EOS; // Print the Javascript to drag-n-drop the list print << + function sort_${config_item}_Sequence() { + //var seq = DragDrop.serData('${config_item}_group', null); + var seq = DragDrop.serData(null, '${config_item}'); + var start = seq.indexOf("("); + var end = seq.indexOf(")"); + seq = seq.slice((start + 1), end); + checkable_seq = seq.split(","); + out_seq = ''; + for (i in checkable_seq) { + if (document.getElementById('activate_' + checkable_seq[i]) && !document.getElementById('activate_' + checkable_seq[i]).checked) { + continue; + } else { + if (out_seq != '') { + out_seq += ','; + } + + out_seq += checkable_seq[i]; + } + } + var order = document.getElementById("${config_item}_value"); + order.value = out_seq; + } + function init_${config_item}_Sequence() { var lst = document.getElementById("${config_item}"); DragDrop.makeListContainer(lst, '${config_item}_group'); - lst.onDragOut = function() { - //var seq = DragDrop.serData('${config_item}_group', null); - var seq = DragDrop.serData(null, '${config_item}'); - var start = seq.indexOf("("); - var end = seq.indexOf(")"); - seq = seq.slice((start + 1), end); - var order = document.getElementById("${config_item}_value"); - order.value = seq; + lst.onDragOut = function() { + sort_${config_item}_Sequence(); }; } addLoadEvent(init_${config_item}_Sequence);