diff --git a/lib/themefunctions.php b/lib/themefunctions.php index 9cf4ccb..e8a3cd3 100644 --- a/lib/themefunctions.php +++ b/lib/themefunctions.php @@ -18,9 +18,8 @@ function get_site_name($echo = true) { $title = $db->get('sites', "sitename", ["siteid" => getsiteid()]); if ($echo) { echo $title; - } else { - return $title; } + return $title; } /** @@ -33,9 +32,8 @@ function get_site_url($echo = true) { $url = formatsiteurl($db->get('sites', "url", ["siteid" => getsiteid()])); if ($echo) { echo $url; - } else { - return $url; } + return $url; } /** @@ -48,9 +46,8 @@ function get_page_title($echo = true) { $title = $db->get("pages", "title", ["AND" => ["slug" => getpageslug(), "siteid" => getsiteid()]]); if ($echo) { echo $title; - } else { - return $title; } + return $title; } /** @@ -62,9 +59,8 @@ function get_page_clean_title($echo = true) { $title = strip_tags(get_page_title(false)); if ($echo) { echo $title; - } else { - return $title; } + return $title; } /** @@ -75,9 +71,8 @@ function get_page_clean_title($echo = true) { function get_page_slug($echo = true) { if ($echo) { echo getpageslug(); - } else { - return getpageslug(); } + return getpageslug(); } /** @@ -97,9 +92,8 @@ function get_page_clean_url($echo = true, $slug = null) { } if ($echo) { echo $url; - } else { - return $url; } + return $url; } /** @@ -143,9 +137,8 @@ function get_page_url($echo = true, $slug = null) { } if ($echo) { echo $url; - } else { - return $url; } + return $url; } /** @@ -174,9 +167,8 @@ function get_component($name, $context = null, $echo = true, $default = "") { } if ($echo) { echo $content; - } else { - return $content; } + return $content; } /** @@ -270,9 +262,8 @@ function get_escaped_json($json, $echo = true) { $text = htmlspecialchars(json_encode($json), ENT_QUOTES, 'UTF-8'); if ($echo) { echo $text; - } else { - return $text; } + return $text; } /** @@ -290,9 +281,8 @@ function get_url_or_slug($str, $echo = true) { } if ($echo) { echo $url; - } else { - return $url; } + return $url; } /** @@ -316,9 +306,8 @@ function get_file_url($file, $echo = true) { if ($echo) { echo $url; - } else { - return $url; } + return $url; } /** @@ -362,9 +351,8 @@ function get_setting($key, $echo = false) { } if ($echo) { echo $value; - } else { - return $value; } + return $value; } /** @@ -382,9 +370,8 @@ function get_theme_url($echo = true) { } if ($echo) { echo $url; - } else { - return $url; } + return $url; } /** @@ -407,9 +394,8 @@ function get_theme_color_url($echo = true) { $url = get_theme_url(false) . "/colors/" . $site["color"]; if ($echo) { echo $url; - } else { - return $url; } + return $url; } /** @@ -480,9 +466,8 @@ function get_fontawesome_js($echo = true) { $url = "assets/fontawesome-all.min.js"; if ($echo) { echo $url; - } else { - return $url; } + return $url; } /** @@ -494,9 +479,8 @@ function get_fontawesome_css($echo = true) { $url = "assets/css/fontawesome-all.min.css"; if ($echo) { echo $url; - } else { - return $url; } + return $url; } /** @@ -601,3 +585,64 @@ function get_socialmedia_urls() { } return $urls; } + +define("SPECIAL_TYPE_NONE", 0); +define("SPECIAL_TYPE_PHONE", 1); +define("SPECIAL_TYPE_EMAIL", 2); +define("SPECIAL_TYPE_LINEBREAKS", 3); +define("SPECIAL_TYPE_ADDRESS", 4); +/** + * Take $text, format it according to $type, + * replace [[CONTENT]] in $template with it, + * and replace [[TITLE]] with $title (or the unchanged $text if $title is null) + * + * $type may be one of the following: + *
[[VAR]]