From 323576a594f20485e25c55dd52a5356cb209479c Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 15 Sep 2018 21:51:23 -0400 Subject: Add function oneStr() The initial intended use case for this is applying the "active" and "in active" classes to the first tab to appear in the settings modal. --- app/class/globals.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'app/class/globals.php') diff --git a/app/class/globals.php b/app/class/globals.php index 7120aaa..8ac67e1 100644 --- a/app/class/globals.php +++ b/app/class/globals.php @@ -191,6 +191,21 @@ function getPageName() : string return $_SCROTT['PAGE_NAME']; } +/* + * Produce a string, but only once. This function is useful + * when dealing with some variable collection of markup and + * you want to affect only the first one with a modifier. + * $state should be initialized to false prior to first call. + */ +function oneStr(string $str, bool &$state) : string +{ + if ($state) + return ""; + + $state = true; + return $str; +} + /* * Save an uploaded file and impose some constraints on supplied * data. Caller can optionally pass some strings by reference to -- cgit v1.2.3