get('sites', "sitename", ["siteid" => getsiteid()]); if ($echo) { echo $title; } return $title; } /** * Get the URL of the website. * @param boolean $echo default true * @return string */ function get_site_url($echo = true) { $db = getdatabase(); $url = formatsiteurl($db->get('sites', "url", ["siteid" => getsiteid()])); if ($echo) { echo $url; } return $url; } /** * Get the page title. * @param boolean $echo default true * @return string */ function get_page_title($echo = true) { $db = getdatabase(); $slug = getpageslug(); if (is_null($slug)) { $title = "404 Page Not Found"; } else { $title = $db->get("pages", "title", ["AND" => ["slug" => $slug, "siteid" => getsiteid()]]); } if ($echo) { echo $title; } return $title; } /** * Get the page title stripped of any HTML. * @param boolean $echo default true * @return string */ function get_page_clean_title($echo = true) { $title = strip_tags(get_page_title(false)); if ($echo) { echo $title; } return $title; } /** * Get the page slug for the current page. * @param boolean $echo default true * @return string */ function get_page_slug($echo = true) { if ($echo) { echo getpageslug(); } return getpageslug(); } /** * Get a valid minimal URL for a page. * @param boolean $echo default true * @param string $slug page slug, or null for current * @return string */ function get_page_clean_url($echo = true, $slug = null) { global $SETTINGS; if ($slug == null) { $slug = get_page_slug(false); } if ($SETTINGS["pretty_urls"]) { $url = formatsiteurl(get_site_url(false)) . "$slug"; } else { $url = formatsiteurl(get_site_url(false)) . "index.php?id=$slug"; } if ($echo) { echo $url; } return $url; } /** * Get a valid URL for a page. * @param boolean $echo default true * @param string $slug page slug, or null for current * @return string */ function get_page_url($echo = true, $slug = null) { global $SETTINGS; if ($slug == null) { $slug = get_page_slug(false); } $edit = ""; if (isset($_GET['edit'])) { $edit = "&edit"; } $theme = ""; if (isset($_GET['theme'])) { $theme = "&theme=" . preg_replace("/[^A-Za-z0-9]/", '', $_GET['theme']); } $template = ""; if (isset($_GET['template'])) { $template = "&template=" . preg_replace("/[^A-Za-z0-9]/", '', $_GET['template']); } $color = ""; if (isset($_GET['color'])) { $color = "&color=" . preg_replace("/[^A-Za-z0-9]/", '', $_GET['color']); } $siteid = ""; if (isset($_GET['siteid'])) { $siteid = "&siteid=" . preg_replace("/[^0-9]/", '', $_GET['siteid']); } $args = "$edit$theme$template$color$siteid"; if ($SETTINGS["pretty_urls"]) { if ($args != "") { $args = "?$args"; } $url = formatsiteurl(get_site_url(false)) . "$slug$args"; } else { $url = formatsiteurl(get_site_url(false)) . "index.php?id=$slug$args"; } if ($echo) { echo $url; } return $url; } /** * Echoes or returns the content of a component. * @param string $name component name * @param string $context page slug, or null for current * @param boolean $echo default true * @param string $default The content to return if the component is empty * @return string */ function get_component($name, $context = null, $echo = true, $default = "") { $db = getdatabase(); if ($context == null) { $context = getpageslug(); if ($context == null) { $context = "404"; } } if ($context == "404") { if ($name == "content") { if ($echo) { echo "The requested page could not be found."; } return "The requested page could not be found."; } else { return ""; } } $pageid = $db->get("pages", "pageid", ["AND" => ["slug" => $context, "siteid" => getsiteid()]]); $content = ""; if ($db->has("components", ["AND" => ["pageid" => $pageid, "name" => $name]])) { $content = $db->get("components", "content", ["AND" => ["pageid" => $pageid, "name" => $name]]); } if ($content == "") { $content = $default; } if ($content == "" && isset($_GET['edit'])) { $content = "
"; } if ($echo) { echo $content; } return $content; } /** * Check if a component is empty of content. * @param string $name component name * @param string $context page slug, or null for current * @return boolean */ function is_component_empty($name, $context = null) { $comp = get_component($name, $context, false); $comp = strip_tags($comp, "