+ return $filterData['__output'];
+}
+
+/**
+ * Helper function to determine whether current userid is set, if none is set,
+ * return a zero, else an EL code is being returned as of this function is used
+ * only in templates.
+ *
+ * @param $templateName Name of template (unused)
+ * @param $clear Wether to clear something (unused)
+ * @return $userId Wether zero or EL code snippet
+ */
+function doTemplateUserId ($templateName, $clear) {
+ // By default no userid is set
+ $userId = '0';
+
+ // Is there a user id currently set?
+ if (isCurrentUserIdSet()) {
+ // Then get the current user id
+ $userId = getCurrentUserId();
+ } // END - if
+
+ // Return it
+ return $userId;
+}
+
+// Template helper function to generate "Terms&Conditions" link (EL code again)
+function doTemplateGetTermsConditionsLink ($templateName, $clear) {
+ /*
+ * Use default link by default ;-) This link, however, will become
+ * deprecated once ext-terms is rolled out.
+ */
+ $linkCode = '{%url=modules.php?module=index&what=agb%}';
+
+ // Is ext-terms installed?
+ if (isExtensionInstalled('terms')) {
+ // Then use that link (only 'what' has changed)
+ $linkCode = '{%url=modules.php?module=index&what=terms%}';
+ } // END - if
+
+ // Return link (EL) code
+ return $linkCode;
+}
+
+// Template helper function to create selection box for "locked points mode"
+function doTemplatePointsLockedModeSelectionBox ($templateName, $clear = FALSE, $default = NULL) {
+ // Init array
+ $lockedModes = array(
+ 0 => array('mode' => 'LOCKED'),
+ 1 => array('mode' => 'UNLOCKED'),
+ );
+
+ // Handle it over to generateSelectionBoxFromArray()
+ $content = generateSelectionBoxFromArray($lockedModes, 'points_locked_mode', 'mode', '', '', '', $default);
+
+ // Return prepared content
+ return $content;
+}
+
+// Template helper function to create selection box for payment method
+function doTemplatePointsPaymentMethodSelectionBox ($templateName, $clear = FALSE, $default = NULL) {
+ // Init array
+ $paymentMethods = array(
+ 0 => array('method' => 'DIRECT'),
+ 1 => array('method' => 'REFERRAL'),
+ );
+
+ // Handle it over to generateSelectionBoxFromArray()
+ $content = generateSelectionBoxFromArray($paymentMethods, 'points_payment_method', 'method', '', '', '', $default);
+
+ // Return prepared content
+ return $content;
+}
+
+// Template helper function to create a deferrer code if URL is not empty
+function doTemplateDereferrerUrl ($templateName, $clear = FALSE, $url = NULL) {
+ // Is the URL not NULL and not empty?
+ if ((!is_null($url)) && (!empty($url))) {
+ // Set HTML with EL code
+ $url = '<a href="{%pipe,generateDereferrerUrl=' . $url . '%}" rel="external" target="_blank">{--ADMIN_TEST_URL--}</a>';
+ } // END - if
+
+ // Return URL (or content) or dashes if empty
+ return fixEmptyContentToDashes($url);
+}
+
+// Tries to anonymize some sensitive data (e.g. IP address, user agent, referrer, etc.)
+function anonymizeSensitiveData ($data) {
+ // Trim it
+ $data = trim($data);
+
+ // Is it empty?
+ if (empty($data)) {
+ // Then add three dashes
+ $data = '---';
+ } elseif (isUrlValid($data)) {
+ // Is a referrer, so is it black-listed?
+ if (isAdmin()) {
+ // Is admin, has always priority
+ $data = '[<a href="{%pipe,generateFrametesterUrl=' . $data . '%}" target="_blank">{--ADMIN_TEST_URL--}</a>]';
+ } elseif (isUrlBlacklisted($data)) {
+ // Yes, so replace it with text
+ $data = '<em>{--URL_IS_BLACKLISTED--}</em>';
+ } else {
+ // A member is viewing this referral URL
+ $data = '[<a href="{%pipe,generateDereferrerUrl=' . $data . '%}" target="_blank">{--MEMBER_TEST_URL--}</a>]';
+ }
+ } elseif (isIp4AddressValid($data)) {
+ // Is an IPv4 address
+ $ipArray = explode('.', $data);
+
+ // Only display first 2 octets
+ $data = $ipArray[0] . '.' . $ipArray[1] . '.?.?';
+ } else {
+ // Generic data
+ $data = '<em>{--DATA_IS_HIDDEN--}</em>';
+ }
+
+ // Return it (hopefully) anonymized
+ return $data;
+}
+
+/**
+ * Removes all commentd, tabs and new-line characters to compact the content
+ *
+ * @param $uncompactedContent The uncompacted content
+ * @return $compactedContent The compacted content
+ */
+function compactContent ($uncompactedContent) {
+ // First, remove all tab/new-line/revert characters
+ $compactedContent = str_replace(chr(9), '', str_replace(PHP_EOL, '', str_replace(chr(13), '', $uncompactedContent)));
+
+ // Then regex all comments like <!-- //--> away
+ preg_match_all('/<!--[\w\W]*?(\/\/){0,1}-->/', $compactedContent, $matches);
+
+ // Do we have entries?
+ if (isset($matches[0][0])) {
+ // Remove all
+ foreach ($matches[0] as $match) {
+ // Remove the match
+ $compactedContent = str_replace($match, '', $compactedContent);
+ } // END - foreach
+ } // END - if
+
+ // Set the content again
+ // @TODO Is this needed for e.g. $GLOBALS['template_content'] ? $this->setRawTemplateData($compactedContent);
+
+ // Return compacted content
+ return $compactedContent;