summaryrefslogtreecommitdiffstats
path: root/app/class
diff options
context:
space:
mode:
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.