From 9549e33c2ce6a5d76c59bede2b098fa7457cceba Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 4 May 2017 14:22:23 +0300 Subject: move some common control-generating functions to controls.php --- include/controls.php | 302 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 302 insertions(+) create mode 100644 include/controls.php (limited to 'include/controls.php') diff --git a/include/controls.php b/include/controls.php new file mode 100644 index 000000000..0c5683082 --- /dev/null +++ b/include/controls.php @@ -0,0 +1,302 @@ +"; + foreach ($values as $v) { + if ($v == $default) + $sel = "selected=\"1\""; + else + $sel = ""; + + $v = trim($v); + + print ""; + } + print ""; +} + +function print_select_hash($id, $default, $values, $attributes = "", $name = "") { + if (!$name) $name = $id; + + print ""; +} + +function print_hidden($name, $value) { + print ""; +} + +function print_checkbox($id, $checked, $value = "", $attributes = "") { + $checked_str = $checked ? "checked" : ""; + $value_str = $value ? "value=\"$value\"" : ""; + + print ""; +} + +function print_button($type, $value, $attributes = "") { + print "

"; +} + +function print_radio($id, $default, $true_is, $values, $attributes = "") { + foreach ($values as $v) { + + if ($v == $default) + $sel = "checked"; + else + $sel = ""; + + if ($v == $true_is) { + $sel .= " value=\"1\""; + } else { + $sel .= " value=\"0\""; + } + + print " $v "; + + } +} + +function print_feed_select($id, $default_id = "", + $attributes = "", $include_all_feeds = true, + $root_id = false, $nest_level = 0) { + + if (!$root_id) { + print ""; + } +} + +function print_feed_cat_select($id, $default_id, + $attributes, $include_all_cats = true, $root_id = false, $nest_level = 0) { + + if (!$root_id) { + print ""; + } +} + +function stylesheet_tag($filename) { + $timestamp = filemtime($filename); + + return "\n"; +} + +function javascript_tag($filename) { + $query = ""; + + if (!(strpos($filename, "?") === FALSE)) { + $query = substr($filename, strpos($filename, "?")+1); + $filename = substr($filename, 0, strpos($filename, "?")); + } + + $timestamp = filemtime($filename); + + if ($query) $timestamp .= "&$query"; + + return "\n"; +} + +function format_warning($msg, $id = "") { + return "

$msg
"; +} + +function format_notice($msg, $id = "") { + return "
$msg
"; +} + +function format_error($msg, $id = "") { + return "
$msg
"; +} + +function print_notice($msg) { + return print format_notice($msg); +} + +function print_warning($msg) { + return print format_warning($msg); +} + +function print_error($msg) { + return print format_error($msg); +} + +function format_inline_player($url, $ctype) { + + $entry = ""; + + $url = htmlspecialchars($url); + + if (strpos($ctype, "audio/") === 0) { + + if ($_SESSION["hasAudio"] && (strpos($ctype, "ogg") !== false || + $_SESSION["hasMp3"])) { + + $entry .= ""; + + } else { + + $entry .= " + + "; + } + + if ($entry) $entry .= "  " . basename($url) . ""; + + return $entry; + + } + + return ""; +} -- cgit v1.2.3