summaryrefslogtreecommitdiff
path: root/lib/functions.php
diff options
context:
space:
mode:
authorNicolas BERNSTEIN <alexis211@gmail.com>2011-09-17 19:36:41 +0200
committerNicolas BERNSTEIN <alexis211@gmail.com>2011-09-17 19:36:41 +0200
commit8d9321225140a3db0b72796d4d0236d6cacfeb8a (patch)
tree766e25ed98b86ed4cbf6d0517d9daaecc5ce3c18 /lib/functions.php
parentb6b341d949437c913fcce3d1a7c302945f67b22b (diff)
downloadBits-8d9321225140a3db0b72796d4d0236d6cacfeb8a.tar.gz
Bits-8d9321225140a3db0b72796d4d0236d6cacfeb8a.zip
Started working on a study program.
Diffstat (limited to 'lib/functions.php')
-rw-r--r--lib/functions.php61
1 files changed, 61 insertions, 0 deletions
diff --git a/lib/functions.php b/lib/functions.php
index 549ed3b..6190818 100644
--- a/lib/functions.php
+++ b/lib/functions.php
@@ -50,3 +50,64 @@ function assert_error($a, $e, $t = "") {
die();
}
}
+
+
+// **** DISPLAY FILTERS *******
+
+function get_filter($name) {
+ global $filters, $fdefaults;
+ if (!isset($filters[$name])) return "";
+ $v = (isset($_GET[$name]) ? $_GET[$name] : "");
+ if (!isset($filters[$name][$v])) return $fdefaults[$name];
+ return $v;
+}
+
+function filter_html_entry($name, $entry) {
+ global $filters, $filters_defaults, $url;
+ if (!isset($filters[$name])) return "";
+ if (!isset($filters[$name][$entry])) return "";
+ $rurl = array("p=".$url, $name . "=" . $entry);
+ foreach ($filters as $filter => $n) {
+ if ($filter != $name) {
+ $rurl[] = ($filter . "=" . get_filter($filter));
+ }
+ }
+ return '<a href="index.php?' . implode("&", $rurl) . '">' . $filters[$name][$entry] . '</a>';
+}
+
+function filter_html($name) {
+ global $filters, $filters_defaults;
+ if (!isset($filters[$name])) return "";
+ $r = array();
+ foreach ($filters[$name] as $v => $t) {
+ if (get_filter($name) == $v) {
+ $r[] = "<b>" . $t . "</b>";
+ } else {
+ $r[] = filter_html_entry($name, $v);
+ }
+ }
+ return implode(", ", $r);
+}
+
+function filters_html() {
+ global $filters;
+ $r = array();
+ foreach ($filters as $k => $filter) {
+ $r[$k] = filter_html($k);
+ }
+ return $r;
+}
+
+function filters_html_full() {
+ global $filters_names;
+ $r = array();
+ foreach (filters_html() as $f => $h) {
+ $r[] = $f . " (" . $h . ")";
+ }
+ return implode(", ", $r);
+}
+
+$ord_ways = array (
+ "ASC" => "ascending",
+ "DESC" => "descending"
+);