+ 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);
+}
+
+// Load another template and return its content
+function doTemplateLoadTemplate ($templateName, $clear = FALSE, $theTemplate, $content = array()) {
+ // Load "the" template
+ return loadTemplate($theTemplate, TRUE, $content);
+}
+
+// Output HTML code for favicon.ico, if found
+function doTemplateMetaFavIcon ($templateName, $clear = FALSE) {
+ // Default is not found
+ $out = '';
+
+ // Check all common extensions
+ foreach (array('ico', 'gif', 'png') as $extension) {
+ // Is the file there?
+ if (isFileReadable(getPath() . 'favicon.' . $extension)) {
+ // Then use this and abort
+ $out = '<link rel="shortcut icon" href="{%url=favicon.' . $extension . '%}" type="image/' . $extension . '" />';
+ break;
+ } // END - if
+ } // END - while
+
+ // Return code
+ return $out;
+}
+
+// Helper function to display referral id or hide it depending on settings
+function doTemplateDisplayReferralIdContent ($template, $clear = FALSE) {
+ // Ddisplay the refid or make it editable?
+ if (isDisplayRefidEnabled()) {
+ // Load "hide" form template
+ $out = loadTemplate('guest_register_refid_hide', TRUE);
+ } else {
+ // Load template to enter it
+ $out = loadTemplate('guest_register_refid', TRUE);
+ }
+
+ // Return code
+ return $out;
+}
+
+// "Getter" for template base path
+function getTemplateBasePath ($part) {
+ // Is there cache?
+ if (!isset($GLOBALS[__FUNCTION__][$part])) {
+ // "Build" path
+ $GLOBALS[__FUNCTION__][$part] = sprintf('%stemplates/%s/%s', getPath(), getLanguage(), $part);
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__][$part];
+}
+
+// Removes comments with @DEPRECATED
+function removeDeprecatedComment ($output) {
+ // Explode it into pieces ... ;)
+ $lines = explode(chr(10), $output);
+
+ // Walk through all
+ $return = '';
+ foreach ($lines as $line) {
+ // Is there a @DEPRECATED?
+ if (isInString('@DEPRECATED', $line)) {
+ // Ignore this line
+ continue;
+ } // END - if
+
+ // Add it
+ $return .= $line . chr(13);
+ } // END - foreach
+
+ // Returned cleaned content
+ return $return;
+}
+
+// Generates a selection box suitable for e.g. birthdays: day, month and year
+function generateDayMonthYearSelectionBox ($day, $month, $year) {
+ // This depends on selected language
+ switch (getLanguage()) {
+ case 'de': // German date format
+ $content = addSelectionBox('da', $day) . addSelectionBox('mo', $month) . addSelectionBox('ye', $year);
+ break;
+
+ default: // Default is the US date format... :)
+ $content = addSelectionBox('mo', $month) . addSelectionBox('da', $day) . addSelectionBox('ye', $year);
+ break;
+ } // END - switch
+
+ // Return content
+ return $content;
+}
+
+// Loads page header
+function loadPageHeader () {
+ // Init header
+ $GLOBALS['__page_header'] = '';
+
+ // Is the header already sent?
+ if (($GLOBALS['__header_sent'] != 1) && ($GLOBALS['__header_sent'] != 2)) {
+ // Set default HTTP status to "200 OK"
+ setHttpStatus('200 OK');
+
+ // If not in CSS mode generate the header
+ if ((!isCssOutputMode()) && (!isAjaxOutputMode()) && (!isImageOutputMode())) {
+ // Prepare the header for HTML output
+ loadHtmlHeader();
+ } // END - if
+
+ // Closing HEAD tag
+ if ($GLOBALS['__header_sent'] == '0') {
+ $GLOBALS['__header_sent'] = 1;
+ } // END - if
+ } // END - if
+
+ // Add BODY tag or not?
+ // @TODO Find a way to not use direct module comparison
+ if ((!isCssOutputMode()) && (!isRawOutputMode()) && ($GLOBALS['__header_sent'] == 1) && (getModule() != 'frametester') && (!isFramesetModeEnabled())) {
+ loadTemplate('page_body');
+ $GLOBALS['__header_sent'] = 2;
+ } // END - if
+}
+
+// Loads page footer and calls doShutdown()
+function loadPageFooter () {
+ // Init page footer
+ $GLOBALS['__page_footer'] = '';
+
+ // Footer disabled (e.g. CSS/AJAX/image output) or already sent?
+ // 1234 5 54 45 5 5 543 3 443 3 443 3 44321
+ if ((((!isset($GLOBALS['__footer_sent'])) || (($GLOBALS['__footer_sent'] != 1) && ($GLOBALS['__footer_sent'] != 2))) && (!isCssOutputMode()) && (!isAjaxOutputMode()) && (!isImageOutputMode()))) {
+ // Run the filter, sweet huh?
+ runFilterChain('page_footer');
+
+ // Load page footer
+ $GLOBALS['__page_footer'] .= loadTemplate('page_footer', TRUE);
+ } // END - if
+
+ // Footer has been reached
+ $GLOBALS['__footer_sent'] = 1;
+
+ // Shutdown
+ doShutdown();