X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ftemplate-functions.php;h=3f9be64120d0f51792cb888ea666c47d55be6261;hb=refs%2Fheads%2F0.2.1-FINAL;hp=d4bd6354fa62f3d7c80f39cbfb730bdb743c35b8;hpb=82c5c7d37ee00f628b4fdd445f7fc453523ed1dd;p=mailer.git diff --git a/inc/template-functions.php b/inc/template-functions.php index d4bd6354fa..3f9be64120 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -11,7 +11,7 @@ * Kurzbeschreibung : Template-Funktionen * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * - * Copyright (c) 2009 - 2015 by Mailer Developer Team * + * Copyright (c) 2009 - 2016 by Mailer Developer Team * * For more information visit: http://mxchange.org * * * * This program is free software; you can redistribute it and/or modify * @@ -78,16 +78,16 @@ function initTemplateColorSwitch ($template) { $GLOBALS['color_switch'][$template] = 2; } -// "Getter" for color switch code -function getColorSwitchCode ($template) { +// "Renders" color switch code +function renderColorSwitchCode ($template) { // Prepare the code - $code = "{DQUOTE} . doTemplateColorSwitch('" . $template . "', FALSE, FALSE) . {DQUOTE}"; + $code = sprintf("{DQUOTE} . doTemplateColorSwitch('%s', FALSE, FALSE) . {DQUOTE}", $template); // And return it return $code; } -// Output HTML code directly or 'render' it. You addionally switch the new-line character off +// Output HTML code directly or 'render' it. You can addionally switch the new-line character off function outputHtml ($htmlCode = NULL, $newLine = TRUE) { // Init output if (!isset($GLOBALS['__output'])) { @@ -238,7 +238,7 @@ function doFinalCompilation ($code, $insertComments = TRUE, $enableCodes = TRUE) // Compile all out while (((isInString('{--', $code)) || (isInString('{DQUOTE}', $code)) || (isInString('{?', $code)) || (isInString('{%', $code) !== FALSE)) && ($totalCompilations < 7)) { // Init common variables - $content = array(); + $content = []; $newContent = ''; // Compile it @@ -293,7 +293,7 @@ function outputRawCode ($htmlCode) { } // Load a template file and return it's content (only it's name; do not use ' or ") -function loadTemplate ($template, $return = FALSE, $content = array(), $compileCode = TRUE) { +function loadTemplate ($template, $return = FALSE, $content = [], $compileCode = TRUE) { // @TODO Remove these sanity checks if all is fine if (!is_bool($return)) { // $return has to be boolean @@ -351,7 +351,7 @@ function loadTemplate ($template, $return = FALSE, $content = array(), $compileC // Prepare eval() command //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Reached!'); - $GLOBALS['template_eval']['html'][$template] = '$templateContent = "' . getColorSwitchCode($template) . compileCode(escapeQuotes($code), TRUE, $compileCode) . '";'; + $GLOBALS['template_eval']['html'][$template] = '$templateContent = "' . renderColorSwitchCode($template) . compileCode(escapeQuotes($code), TRUE, $compileCode) . '";'; } elseif (substr($template, 0, 3) == 'js_') { // JavaScripts don't like entities, dollar signs and timings //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Reached!'); @@ -369,7 +369,7 @@ function loadTemplate ($template, $return = FALSE, $content = array(), $compileC // Add surrounding HTML comments to help finding bugs faster $templateContent = '' . $GLOBALS['template_content']['html'][$template] . ''; //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Reached!'); - $GLOBALS['template_eval']['html'][$template] = '$templateContent = "' . getColorSwitchCode($template) . compileRawCode(escapeQuotes($templateContent), TRUE, $compileCode) . '";'; + $GLOBALS['template_eval']['html'][$template] = '$templateContent = "' . renderColorSwitchCode($template) . compileRawCode(escapeQuotes($templateContent), TRUE, $compileCode) . '";'; } elseif (isAjaxOutputMode()) { // AJAX (JSON content) //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Reached!'); @@ -381,16 +381,19 @@ function loadTemplate ($template, $return = FALSE, $content = array(), $compileC } // END - if } elseif ((isAdmin()) || ((isInstalling()) && (!isInstalled()))) { // Only admins shall see this warning or when installation mode is active - $templateContent = '
+ $templateContent = sprintf('
{--TEMPLATE_404--}
- (' . $template . ') + (%s)
{--TEMPLATE_CONTENT--}: -
' . print_r($content, TRUE) . '
-
'; +
%s
+
', + $template, + print_r($content, TRUE) + ); } else { // No file! $GLOBALS['template_eval']['html'][$template] = '404'; @@ -477,7 +480,7 @@ function detectExtraTemplatePath ($prefix, $template) { } // Loads an email template and compiles it -function loadEmailTemplate ($template, $content = array(), $userid = NULL, $loadUserData = TRUE) { +function loadEmailTemplate ($template, $content = [], $userid = NULL, $loadUserData = TRUE) { // Make sure all template names are lowercase! $template = strtolower($template); @@ -533,13 +536,16 @@ function loadEmailTemplate ($template, $content = array(), $userid = NULL, $load $GLOBALS['template_eval']['email'][$template] = '$templateContent = decodeEntities("' . compileRawCode(escapeQuotes($GLOBALS['template_content']['email'][$template])) . '");'; } elseif (!empty($template)) { // Template file not found - $templateContent = '
- {--TEMPLATE_404--}: ' . $template . ' + $templateContent = sprintf('
+ {--TEMPLATE_404--}: %s
{--TEMPLATE_CONTENT--}: -
' . print_r($content, TRUE) . '
-
'; +
%s
+
', + $template, + print_r($content, TRUE) + ); // Don't cache this, as there is no template to cache $GLOBALS['template_eval']['email'][$template] = '404'; @@ -685,7 +691,7 @@ function compileRawCode ($code, $full = TRUE, $compileCode = TRUE) { // Are some matches found? if ((isFilledArray($matches)) && (isFilledArray($matches[0]))) { // Replace all matches - $matchesFound = array(); + $matchesFound = []; foreach ($matches[0] as $key => $match) { // Fuzzy look has failed by default $fuzzyFound = FALSE; @@ -780,7 +786,7 @@ function compileRawCode ($code, $full = TRUE, $compileCode = TRUE) { } // -function addSelectionBox ($type, $default, $prefix = '', $id = NULL, $class = 'form_select') { +function addSelectionBox ($type, $default, $prefix = '', $id = NULL, $class = 'form_select', $allSteps = FALSE) { $OUT = ''; if ($type == 'yn') { @@ -880,7 +886,16 @@ function addSelectionBox ($type, $default, $prefix = '', $id = NULL, $class = 'f case 'mi': // Minutes case 'se': // Seconds - for ($idx = 0; $idx <= 59; $idx+=5) { + // Default is 5 minutes/seconds step + $step = 5; + + // All steps? + if ($allSteps === TRUE) { + // Then all steps + $step = 1; + } // END - if + + for ($idx = 0; $idx <= 59; $idx += $step) { $padded = padLeftZero($idx, 2); $OUT .= '