summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-03-31 17:15:23 +0400
committerAndrew Dolgov <[email protected]>2013-03-31 17:15:23 +0400
commita86ba0a67a83547e83335a619b1c2b5bf3355093 (patch)
tree506548ee7c29760aa45d617a5d3642fac62ac2af /classes
parentda46d21e888f428fbd51b139d6807652da364838 (diff)
implement filter drag and drop sorting
Diffstat (limited to 'classes')
-rw-r--r--classes/pref/filters.php48
1 files changed, 45 insertions, 3 deletions
diff --git a/classes/pref/filters.php b/classes/pref/filters.php
index a64333f79..6ccff51d7 100644
--- a/classes/pref/filters.php
+++ b/classes/pref/filters.php
@@ -3,11 +3,47 @@ class Pref_Filters extends Handler_Protected {
function csrf_ignore($method) {
$csrf_ignored = array("index", "getfiltertree", "edit", "newfilter", "newrule",
- "newaction");
+ "newaction", "savefilterorder");
return array_search($method, $csrf_ignored) !== false;
}
+ function filtersortreset() {
+ db_query($this->link, "UPDATE ttrss_filters2
+ SET order_id = 0 WHERE owner_uid = " . $_SESSION["uid"]);
+ return;
+ }
+
+ function savefilterorder() {
+ $data = json_decode($_POST['payload'], true);
+
+ #file_put_contents("/tmp/saveorder.json", $_POST['payload']);
+ #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true);
+
+ if (!is_array($data['items']))
+ $data['items'] = json_decode($data['items'], true);
+
+ $index = 0;
+
+ if (is_array($data) && is_array($data['items'])) {
+ foreach ($data['items'][0]['items'] as $item) {
+ $filter_id = (int) str_replace("FILTER:", "", $item['_reference']);
+
+ if ($filter_id > 0) {
+
+ db_query($this->link, "UPDATE ttrss_filters2 SET
+ order_id = $index WHERE id = '$filter_id' AND
+ owner_uid = " .$_SESSION["uid"]);
+
+ ++$index;
+ }
+ }
+ }
+
+ return;
+ }
+
+
function testFilter() {
$filter = array();
@@ -623,6 +659,10 @@ class Pref_Filters extends Handler_Protected {
print "<button dojoType=\"dijit.form.Button\" onclick=\"return editSelectedFilter()\">".
__('Edit')."</button> ";
+ print "<button dojoType=\"dijit.form.Button\" onclick=\"return resetFilterOrder()\">".
+ __('Reset sort order')."</button> ";
+
+
print "<button dojoType=\"dijit.form.Button\" onclick=\"return removeSelectedFilters()\">".
__('Remove')."</button> ";
@@ -639,14 +679,16 @@ class Pref_Filters extends Handler_Protected {
<img src='images/indicator_tiny.gif'>".
__("Loading, please wait...")."</div>";
- print "<div dojoType=\"dojo.data.ItemFileWriteStore\" jsId=\"filterStore\"
+ print "<div dojoType=\"fox.PrefFilterStore\" jsId=\"filterStore\"
url=\"backend.php?op=pref-filters&method=getfiltertree\">
</div>
<div dojoType=\"lib.CheckBoxStoreModel\" jsId=\"filterModel\" store=\"filterStore\"
- query=\"{id:'root'}\" rootId=\"root\" rootLabel=\"Feeds\"
+ query=\"{id:'root'}\" rootId=\"root\" rootLabel=\"Filters\"
childrenAttrs=\"items\" checkboxStrict=\"false\" checkboxAll=\"false\">
</div>
<div dojoType=\"fox.PrefFilterTree\" id=\"filterTree\"
+ dndController=\"dijit.tree.dndSource\"
+ betweenThreshold=\"5\"
model=\"filterModel\" openOnClick=\"true\">
<script type=\"dojo/method\" event=\"onLoad\" args=\"item\">
Element.hide(\"filterlistLoading\");