aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-12-13 04:06:56 -0800
committerfriendica <info@friendica.com>2012-12-13 04:06:56 -0800
commit4e192b108d9ba3837ae881799b4376550a476ebf (patch)
treef63255cc0d3260e8a8bedf4aa914dcc237bb704c
parent6e363ed0c8f5a1f3e63c7f1984542ef182d79d84 (diff)
downloadvolse-hubzilla-4e192b108d9ba3837ae881799b4376550a476ebf.tar.gz
volse-hubzilla-4e192b108d9ba3837ae881799b4376550a476ebf.tar.bz2
volse-hubzilla-4e192b108d9ba3837ae881799b4376550a476ebf.zip
templatise the building of page queries so we can re-use it elsewhere
-rw-r--r--js/main.js4
-rw-r--r--mod/network.php71
-rw-r--r--view/tpl/build_query.tpl50
3 files changed, 72 insertions, 53 deletions
diff --git a/js/main.js b/js/main.js
index 18924834d..116cd5aeb 100644
--- a/js/main.js
+++ b/js/main.js
@@ -447,11 +447,11 @@ function updateConvItems(mode,data) {
if(typeof buildCmd == 'function') {
if(scroll_next) {
- network_page = next_page;
+ bParam_page = next_page;
page_load = true;
}
else {
- network_page = 1;
+ bParam_page = 1;
}
update_url = buildCmd();
}
diff --git a/mod/network.php b/mod/network.php
index c86bbc261..4fd7ad200 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -495,57 +495,26 @@ function network_content(&$a, $update = 0, $load = false) {
. "'; var profile_page = " . $a->pager['page'] . ";</script>";
- $a->page['htmlhead'] .= "<script>\r\n"
- . "var network_cmd = " . '"' . $a->get_baseurl() . '/update_network' . '"' . ";\r\n"
- . "var network_uid = " . ((local_user()) ? local_user() : 0) . ";\r\n"
- . "var network_gid = " . (($gid) ? $gid : 0) . ";\r\n"
- . "var network_cid = " . (($_GET['cid']) ? $_GET['cid'] : 0) . ";\r\n"
- . "var network_cmin = " . (($_GET['cmin']) ? $_GET['cmin'] : 0) . ";\r\n"
- . "var network_cmax = " . (($_GET['cmax']) ? $_GET['cmax'] : 99) . ";\r\n"
- . "var network_star = " . (($_GET['star']) ? $_GET['star'] : 0) . ";\r\n"
- . "var network_liked = " . (($_GET['liked']) ? $_GET['liked'] : 0) . ";\r\n"
- . "var network_conv = " . (($_GET['conv']) ? $_GET['conv'] : 0) . ";\r\n"
- . "var network_spam = " . (($_GET['spam']) ? $_GET['spam'] : 0) . ";\r\n"
- . "var network_new = " . (($nouveau) ? $nouveau : 0) . ";\r\n"
- . "var network_page = " . (($a->pager['page'] != 1) ? $a->pager['page'] : 1) . ";\r\n"
-
-
- . 'var network_search = "' . $_GET['search'] . '"' . ";\r\n"
- . 'var network_order = "' . $_GET['order'] . '"' . ";\r\n"
- . 'var network_file = "' . $_GET['file'] . '"' . ";\r\n"
- . 'var network_dend = "' . $datequery . '"' . ";\r\n"
- . 'var network_dbegin = "' . $datequery2 . '"' . ";\r\n"
-
- . 'function buildCmd() {
- var udargs = ((page_load) ? "/load" : "");
- var bCmd = network_cmd + udargs + "?f=" ;
- if(network_uid) bCmd = bCmd + "&p=" + network_uid;
- if(network_cmin != 0) bCmd = bCmd + "&cmin=" + network_cmin;
- if(network_cmax != 99) bCmd = bCmd + "&cmax=" + network_cmax;
- if(network_gid != 0) { bCmd = bCmd + "&gid=" + network_gid; } else
- if(network_cid != 0) { bCmd = bCmd + "&cid=" + network_cid; }
- if(network_star != 0) bCmd = bCmd + "&star=" + network_star;
- if(network_liked != 0) bCmd = bCmd + "&liked=" + network_liked;
- if(network_conv!= 0) bCmd = bCmd + "&conv=" + network_conv;
- if(network_spam != 0) bCmd = bCmd + "&spam=" + network_spam;
- if(network_new != 0) bCmd = bCmd + "&new=" + network_new;
- if(network_search != "") bCmd = bCmd + "&search=" + network_search;
- if(network_file != "") bCmd = bCmd + "&file=" + network_file;
- if(network_dend != "") bCmd = bCmd + "&dend=" + network_dend;
- if(network_dbegin != "") bCmd = bCmd + "&dbegin=" + network_dbegin;
- if(network_page != 1) bCmd = bCmd + "&page=" + network_page;
-
- return(bCmd);
- }'
-
- . "</script>\r\n";
-
- ;
-
-
-
-
-
+ $a->page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array(
+ '$baseurl' => z_root(),
+ '$uid' => ((local_user()) ? local_user() : '0'),
+ '$gid' => (($gid) ? $gid : '0'),
+ '$cid' => (($cid) ? $cid : '0'),
+ '$cmin' => (($cmin) ? $cmin : '0'),
+ '$cmax' => (($cmax) ? $cmax : '0'),
+ '$star' => (($star) ? $star : '0'),
+ '$liked' => (($liked) ? $liked : '0'),
+ '$conv' => (($conv) ? $conv : '0'),
+ '$spam' => (($spam) ? $spam : '0'),
+ '$nouveau' => (($nouveau) ? $nouveau : '0'),
+ '$wall' => '0',
+ '$page' => (($a->pager['page'] != 1) ? $a->pager['page'] : 1),
+ '$search' => $search,
+ '$order' => $order,
+ '$file' => $file,
+ '$dend' => $datequery,
+ '$dbegin' => $datequery2
+ ));
}
$sql_extra3 = '';
diff --git a/view/tpl/build_query.tpl b/view/tpl/build_query.tpl
new file mode 100644
index 000000000..25b370e69
--- /dev/null
+++ b/view/tpl/build_query.tpl
@@ -0,0 +1,50 @@
+<script>
+
+ var bParam_cmd = "$baseurl/update_network";
+
+ var bParam_wall = $wall;
+
+ if(bParam_wall) { bParam_cmd = "$baseurl/update_channel"; }
+
+ var bParam_uid = $uid;
+ var bParam_gid = $gid;
+ var bParam_cid = $cid;
+ var bParam_cmin = $cmin;
+ var bParam_cmax = $cmax;
+ var bParam_star = $star;
+ var bParam_liked = $liked;
+ var bParam_conv = $conv;
+ var bParam_spam = $spam;
+ var bParam_new = $nouveau;
+ var bParam_page = $page;
+
+ var bParam_search = "$search";
+ var bParam_order = "$order";
+ var bParam_file = "$file";
+ var bParam_dend = "$dend";
+ var bParam_dbegin = "$dbegin";
+
+ function buildCmd() {
+ var udargs = ((page_load) ? "/load" : "");
+ var bCmd = bParam_cmd + udargs + "?f=" ;
+ if(bParam_uid) bCmd = bCmd + "&p=" + bParam_uid;
+ if(bParam_cmin != 0) bCmd = bCmd + "&cmin=" + bParam_cmin;
+ if(bParam_cmax != 99) bCmd = bCmd + "&cmax=" + bParam_cmax;
+ if(bParam_gid != 0) { bCmd = bCmd + "&gid=" + bParam_gid; } else
+ if(bParam_cid != 0) { bCmd = bCmd + "&cid=" + bParam_cid; }
+ if(bParam_star != 0) bCmd = bCmd + "&star=" + bParam_star;
+ if(bParam_liked != 0) bCmd = bCmd + "&liked=" + bParam_liked;
+ if(bParam_conv!= 0) bCmd = bCmd + "&conv=" + bParam_conv;
+ if(bParam_spam != 0) bCmd = bCmd + "&spam=" + bParam_spam;
+ if(bParam_new != 0) bCmd = bCmd + "&new=" + bParam_new;
+ if(bParam_wall != 0) bCmd = bCmd + "&wall=" + bParam_wall;
+ if(bParam_search != "") bCmd = bCmd + "&search=" + bParam_search;
+ if(bParam_file != "") bCmd = bCmd + "&file=" + bParam_file;
+ if(bParam_dend != "") bCmd = bCmd + "&dend=" + bParam_dend;
+ if(bParam_dbegin != "") bCmd = bCmd + "&dbegin=" + bParam_dbegin;
+ if(bParam_page != 1) bCmd = bCmd + "&page=" + bParam_page;
+ return(bCmd);
+ }
+
+</script>
+