diff options
author | Malf Furious <m@lfurio.us> | 2018-09-15 21:51:23 -0400 |
---|---|---|
committer | Malf Furious <m@lfurio.us> | 2018-09-15 21:51:23 -0400 |
commit | 323576a594f20485e25c55dd52a5356cb209479c (patch) | |
tree | 2b8ec5fca5d1cad1e2fd1d7f7f460d31a89997d0 /app/class | |
parent | d0948ac023b21404bd051b41b744b3b0f7415a31 (diff) | |
download | scrott-323576a594f20485e25c55dd52a5356cb209479c.tar.gz scrott-323576a594f20485e25c55dd52a5356cb209479c.zip |
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.
Diffstat (limited to 'app/class')
-rw-r--r-- | app/class/globals.php | 15 |
1 files changed, 15 insertions, 0 deletions
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 @@ -192,6 +192,21 @@ function getPageName() : string } /* + * 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 * be given the supplied file's original name and mime-type. |