summaryrefslogtreecommitdiffstats
path: root/app/class
diff options
context:
space:
mode:
authorMalf Furious <m@lfurio.us>2018-09-15 21:51:23 -0400
committerMalf Furious <m@lfurio.us>2018-09-15 21:51:23 -0400
commit323576a594f20485e25c55dd52a5356cb209479c (patch)
tree2b8ec5fca5d1cad1e2fd1d7f7f460d31a89997d0 /app/class
parentd0948ac023b21404bd051b41b744b3b0f7415a31 (diff)
downloadscrott-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.php15
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.