+// Wrapper function to wrap call of wordwrap()
+function wrapWords ($text) {
+ // Wrap words
+ $wrapped = wordwrap($test, getWordWrap());
+
+ // Return it
+ return $wrapped;
+}
+
+// Encodes given data into a JSON object
+function encodeJson ($data) {
+ // Encode it
+ return json_encode($data, JSON_FORCE_OBJECT);
+}
+
+// Get all extension files
+function loadAllExtensionsByTemplate () {
+ // Get all
+ $extensions = getArrayFromDirectory(
+ 'templates/' . getLanguage() . '/html/ext/',
+ 'ext_',
+ false,
+ false,
+ array(),
+ '.tpl',
+ '@(\.|\.\.)$@',
+ false
+ );
+
+ // Return them
+ return $extensions;
+}
+
+// Wrapper function to allow full float values as supported by current database layout
+function translateFullComma ($dotted) {
+ // Call inner function
+ return translateComma($dotted, TRUE, 5);
+}
+
+// Wrapper to check if the first element to be shifted is set to given value
+function shift_array (&$array, $value, $key = '0') {
+ // Is the element set and value matches?
+ assert(is_array($array));
+ assert(isset($array[$key]));
+ assert($array[$key] === $value);
+
+ // Shift it
+ array_shift($array);
+}
+
+// Wrapper for str_pad() with left padding zeros
+function padLeftZero ($str, $amount = 2) {
+ // Is str_pad() there?
+ if (!function_exists('str_pad')) {
+ // Use prependZeros()
+ return prependZeros($str, $amount);
+ } else {
+ // Pad it
+ return str_pad($str, $amount, '0', STR_PAD_LEFT);
+ }
+}
+
+// Calculates percentage
+function calculatePercentageRate ($current, $total) {
+ // Default is zero
+ $rate = '0.0';
+
+ // Is sent larger zero? (Prevents division-by-zero)
+ if ($total > 0) {
+ // Calculate it (it should be "translated" alter on)
+ $rate = ($current / $total * 100);
+ } // END - if
+
+ // The should be a .0 at the end?
+ if (strpos($rate, '.') === FALSE) {
+ // No, then add it
+ $rate .= '.0';
+ } // END - if
+
+ // Return it
+ return $rate;
+}
+
+// Checks whether an array is filled with entries
+function isFilledArray ($array) {
+ // Determine it
+ return ((is_array($array)) && (count($array) > 0));
+}
+
+// Checks whether this script runs on a developer system (called with localhost/127.0.0.1 SERVER_NAME)
+function isDeveloperSystem () {
+ // Determine it
+ return in_array(detectServerName(), array('localhost', 'daedalus', '127.0.0.1'));
+}
+
+// Checks whether given subject line has '_ref' suffix
+function ifSubjectHasReferralSuffix ($subject) {
+ // Is there cache?
+ if (!isset($GLOBALS[__FUNCTION__][$subject])) {
+ // Determine it
+ $GLOBALS[__FUNCTION__][$subject] = (substr($subject, -4, 4) == '_ref');
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__][$subject];
+}
+
+// Converts an API response to an associative array
+function convertApiResponseToArray ($responseString, $keyDelimiter, $valueDelimiter) {
+ // Explode for key delimiter
+ $keys = explode($keyDelimiter, $responseString);
+
+ // Init returned array and "walk" through all entries
+ $returned = array();
+ foreach ($keys as $keyValue) {
+ // Explode it
+ $parts = explode($valueDelimiter, $keyValue);
+
+ // Count must be 2
+ assert(count($parts) == 2);
+
+ // Then add both: 0=key, 1=value
+ $returned[sqlEscapeString($parts[0])] = sqlEscapeString($parts[1]);
+ } // END - if
+
+ // Return finished array
+ return $returned;
+}
+
+// Getter for full (generic) hash file name
+function getGenericHashFileName () {
+ // Return result
+ return sprintf('%s%s.%s%s', getPath(), getCachePath(), getFileHash(), getCacheExtension());
+}
+
+// "Compiles" the given value and sets it in given key
+function setSessionCompiled ($key, $value) {
+ // Debug message
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key[]=' . gettype($key) . ',value[]=' . gettype($value));
+
+ // Is the value not an array?
+ if (!is_array($value)) {
+ // "Compile" the value
+ $value = doFinalCompilation(compileRawCode($value));
+ } // END - if
+
+ // And set it
+ return setSession($key, $value);
+}
+