X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ftemplate-functions.php;h=344e0c43789576d4b54297520311a41392e4cd6c;hb=3c1445d229281a0c3e13e9d823236a95ef6ff2db;hp=929c99a3783b2df5dbc2bd542b20030c99bb61cd;hpb=39fbdb68ef03c3f5828b02c7676371e7b2ba5327;p=mailer.git diff --git a/inc/template-functions.php b/inc/template-functions.php index 929c99a378..344e0c4378 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -325,7 +325,7 @@ function loadTemplate ($template, $return = false, $content = array(), $compileC $ret = ''; if ((isInString('$', $GLOBALS['tpl_content'][$template])) || (isInString('{--', $GLOBALS['tpl_content'][$template])) || (isInString('{?', $GLOBALS['tpl_content'][$template])) || (isInString('{%', $GLOBALS['tpl_content'][$template]))) { // Normal HTML output? - if (isHtmlOutputMode()) { + if ((isHtmlOutputMode()) && (substr($template, 0, 3) != 'js_')) { // Add surrounding HTML comments to help finding bugs faster $ret = '' . $GLOBALS['tpl_content'][$template] . ''; @@ -573,7 +573,7 @@ function getMenuCssClasses ($data) { // Generate XHTML code for the CAPTCHA function generateCaptchaCode ($code, $type, $type, $userid) { - return 'Code ' . $code . ''; + return 'Code ' . $code . ''; } // Compiles the given HTML/mail code @@ -909,13 +909,13 @@ function createTimeSelections ($timestamp, $prefix = '', $display = '', $align = if ($asArray === true) { // Just put all data in an array for later use $OUT = array( - 'YEARS' => $Y, - 'MONTHS' => $M, - 'WEEKS' => $W, - 'DAYS' => $D, - 'HOURS' => $h, - 'MINUTES' => $m, - 'SECONDS' => $s + 'Y' => $Y, + 'M' => $M, + 'W' => $W, + 'D' => $D, + 'h' => $h, + 'm' => $m, + 's' => $s ); } else { // Generate table @@ -924,31 +924,31 @@ function createTimeSelections ($timestamp, $prefix = '', $display = '', $align = $OUT .= ''; if (isInString('Y', $display) || (empty($display))) { - $OUT .= '
{--_YEARS--}'; + $OUT .= '
{--TIME_UNIT_YEAR--}'; } // END - if if (isInString('M', $display) || (empty($display))) { - $OUT .= '
{--_MONTHS--}'; + $OUT .= '
{--TIME_UNIT_MONTH--}'; } // END - if if (isInString('W', $display) || (empty($display))) { - $OUT .= '
{--_WEEKS--}'; + $OUT .= '
{--TIME_UNIT_WEEK--}'; } // END - if if (isInString('D', $display) || (empty($display))) { - $OUT .= '
{--_DAYS--}'; + $OUT .= '
{--TIME_UNIT_DAY--}'; } // END - if if (isInString('h', $display) || (empty($display))) { - $OUT .= '
{--_HOURS--}'; + $OUT .= '
{--TIME_UNIT_HOUR--}'; } // END - if if (isInString('m', $display) || (empty($display))) { - $OUT .= '
{--_MINUTES--}'; + $OUT .= '
{--TIME_UNIT_MINUTE--}'; } // END - if if (isInString('s', $display) || (empty($display))) { - $OUT .= '
{--_SECONDS--}'; + $OUT .= '
{--TIME_UNIT_SECOND--}'; } // END - if $OUT .= ''; @@ -1419,20 +1419,20 @@ function determinePageTitle () { } // END - if // Add title from what file - $mode = ''; + $menuMode = ''; if (getModule() == 'login') { - $mode = 'member'; + $menuMode = 'member'; } elseif (getModule() == 'index') { - $mode = 'guest'; + $menuMode = 'guest'; } elseif (getModule() == 'admin') { - $mode = 'admin'; + $menuMode = 'admin'; } elseif (getModule() == 'sponsor') { - $mode = 'sponsor'; + $menuMode = 'sponsor'; } // Add middle part (always in admin area!) - if ((!empty($mode)) && ((isWhatTitleEnabled()) || ($mode == 'admin'))) { - $pageTitle .= ' {%config,trim=title_middle%} ' . getTitleFromMenu($mode, getWhat()); + if ((!empty($menuMode)) && ((isWhatTitleEnabled()) || ($menuMode == 'admin'))) { + $pageTitle .= ' {%config,trim=title_middle%} ' . getTitleFromMenu($menuMode, getWhat()); } // END - if // Add title decorations? (right) @@ -1772,6 +1772,50 @@ function translatePoolType ($type) { return sprintf("{--POOL_TYPE_%s--}", strtoupper($type)); } +// "Translates" given time unit +function translateTimeUnit ($unit) { + // Default is unknown + $message = '{%message,TIME_UNIT_UNKNOWN=' . $unit . '%}'; + + // "Detect" it + switch ($unit) { + case 'Y': // Years + $message = '{--TIME_UNIT_YEAR--}'; + break; + + case 'M': // Months + $message = '{--TIME_UNIT_MONTH--}'; + break; + + case 'W': // Weeks + $message = '{--TIME_UNIT_WEEK--}'; + break; + + case 'D': // Days + $message = '{--TIME_UNIT_DAY--}'; + break; + + case 'h': // Hours + $message = '{--TIME_UNIT_HOUR--}'; + break; + + case 'm': // Minute + $message = '{--TIME_UNIT_MINUTE--}'; + break; + + case 's': // Seconds + $message = '{--TIME_UNIT_SECOND--}'; + break; + + default: // Unknown value detected + logDebugMessage(__FUNCTION__, __LINE__, 'Unknown time unit ' . $unit . ' detected.'); + break; + } // END - switch + + // Return message + return $message; +} + // Displays given message in admin_settings_saved template function displayMessage ($message, $return = false) { // Load the template @@ -1783,7 +1827,7 @@ function generateGenderSelectionBox ($selectedGender = '') { // Start the HTML code $out = ''; + + // Add options + $out .= generateOptionList('/ARRAY/', $unitArray, $messageIds, $defaultUnit); + + // Finish HTML code + $out .= ''; + + // Return the code + return $out; +} + +// Function to add style tag (wether display:none/block) +function addStyleMenuContent ($menuMode, $mainAction, $action) { + // Do we have foo_menu_javascript enabled? + if (getConfig($menuMode . '_menu_javascript') == 'N') { + // Silently abort here, not enabled + return ''; + } // END - if + + // Is action=mainAction? + if ($action == $mainAction) { + // Add "menu open" style + return ' style="display:block"'; + } else { + return ' style="display:none"'; + } +} + +// Function to add onclick attribute +function addJavaScriptMenuContent ($menuMode, $mainAction, $action, $what) { + // Do we have foo_menu_javascript enabled? + if ((!isConfigEntrySet($menuMode . '_menu_javascript')) || (getConfig($menuMode . '_menu_javascript') == 'N')) { + // Silently abort here, not enabled + return ''; + } // END - if + + // Prepare content + $content = array( + 'menu_mode' => $menuMode, + 'main_action' => $mainAction, + 'action' => $action, + 'what' => $what + ); + + // Return template + return loadTemplate('js_' . $menuMode . '_menu_onclick', true, $content); +} + //----------------------------------------------------------------------------- // Template helper functions for EL code //----------------------------------------------------------------------------- @@ -1819,7 +1924,7 @@ function doTemplateColorSwitch ($template, $clear = false, $return = true) { // Helper function for extension registration link function doTemplateExtensionRegistrationLink ($template, $clear, $ext_name) { // Default is all non-productive - $OUT = '
{--ADMIN_EXTENSION_IS_NON_PRODUCTIVE_LINK--}
'; + $OUT = '
{--ADMIN_EXTENSION_IS_NON_PRODUCTIVE_LINK--}
'; // Is the given extension non-productive? if (isExtensionProductive($ext_name)) {