From fc45eabca659f9e9792ca4c5a82a3cef732cec10 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Tue, 24 Jul 2018 04:59:34 -0400 Subject: Add $_SCROTT['PAGE_NAME'] variable and getter/setter The intention is for index.php to set this variable. This is the text (HTML) displayed on the button for the pad select dropdown in the nav bar. Basically the canonical name of the page we're on. --- app/class/globals.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'app/class') diff --git a/app/class/globals.php b/app/class/globals.php index c81c9a2..7120aaa 100644 --- a/app/class/globals.php +++ b/app/class/globals.php @@ -42,6 +42,13 @@ $_SCROTT[NOTICE] = array(); */ $_SCROTT['PAGE_OBJECT'] = NULL; +/* + * The page name variable is what displays in the pad select dropdown and + * is typically set to the "group / pad" of the current page or, "Dashboard", + * "Groups", "Pads", etc. on special pages. + */ +$_SCROTT['PAGE_NAME'] = ""; + /* * Get the application root path. This is an absolute path on the server. */ @@ -161,6 +168,29 @@ function getPageObj() : ?obj return $_SCROTT['PAGE_OBJECT']; } +/* + * Set the page name string. This can only be called once per + * runtime. + */ +function setPageName(string $name) : void +{ + global $_SCROTT; + + if ($_SCROTT['PAGE_NAME'] !== "") + throw new Exception("Tried to configure page name twice"); + + $_SCROTT['PAGE_NAME'] = $name; +} + +/* + * Get the page name string. + */ +function getPageName() : string +{ + global $_SCROTT; + return $_SCROTT['PAGE_NAME']; +} + /* * Save an uploaded file and impose some constraints on supplied * data. Caller can optionally pass some strings by reference to -- cgit v1.2.3