From: Roland Häder Date: Sat, 1 Dec 2012 15:05:07 +0000 (+0000) Subject: Introduced 'per-what-word-wrapping X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5ef42cb239e9225f160f5963a718f14bc70a1866;p=mailer.git Introduced 'per-what-word-wrapping --- diff --git a/inc/extensions-functions.php b/inc/extensions-functions.php index 74144af2fd..08346b041b 100644 --- a/inc/extensions-functions.php +++ b/inc/extensions-functions.php @@ -594,21 +594,20 @@ function isExtensionActive ($ext_name) { } elseif (($ext_name == 'cache') || (!isExtensionInstalled('cache'))) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'DB! ext_name=' . $ext_name); // Load from database - $result = SQL_QUERY_ESC("SELECT `ext_active` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1", + $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1", array($ext_name), __FUNCTION__, __LINE__); // Entry found? if (SQL_NUMROWS($result) == 1) { // Load entry $data = SQL_FETCHARRAY($result); + + // Set cache + setExtensionCacheRow($ext_name, $data); } // END - if // Free result SQL_FREERESULT($result); - - // Write cache array - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . '[DB]: ' . $data['ext_active']); - $GLOBALS['cache_array']['extension']['ext_active'][$ext_name] = $data['ext_active']; } else { // Extension not active! //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ': Not active!'); @@ -622,6 +621,32 @@ function isExtensionActive ($ext_name) { return ($data['ext_active'] == 'Y'); } +// Sets extension cache row +function setExtensionCacheRow ($ext_name, &$data) { + // Add all + foreach ($data as $key => $value) { + // Is key=id? + if ($key == 'id') { + $data['ext_id'] = $value; + $key == 'ext_id'; + } // END - if + + // Is key=ext_has_css? + if ($key == 'ext_has_css') { + $data['ext_css'] = $value; + $key == 'ext_css'; + } // END - if + + // Set all entries + if ($key == 'ext_name') { + $GLOBALS['cache_array']['extension']['ext_name'][$data['id']] = $value; + } else { + // Add ordinary entry + $GLOBALS['cache_array']['extension'][$key][$ext_name] = $value; + } + } // END - foreach +} + // Get version from extensions function getExtensionVersion ($ext_name, $force = FALSE) { // By default no extension is found @@ -651,7 +676,7 @@ function getExtensionVersion ($ext_name, $force = FALSE) { incrementStatsEntry('cache_hits'); } elseif ((!isCacheInstanceValid()) || (isset($GLOBALS['cache_array']['extension'])) || (!isHtmlOutputMode())) { // Load from database - $result = SQL_QUERY_ESC("SELECT `ext_version` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1", + $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1", array($ext_name), __FUNCTION__, __LINE__); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ': DB - '.SQL_NUMROWS($result).''); @@ -661,7 +686,7 @@ function getExtensionVersion ($ext_name, $force = FALSE) { $data = SQL_FETCHARRAY($result); // Set cache - $GLOBALS['cache_array']['extension']['ext_version'][$ext_name] = $data['ext_version']; + setExtensionCacheRow($ext_name, $data); } elseif (isDebugModeEnabled()) { // Not found, may happen while an extension is uninstalled logDebugMessage(__FUNCTION__, __LINE__, sprintf("Cannot find extension %s in database!", $ext_name)); @@ -904,20 +929,20 @@ function getExtensionId ($ext_name) { incrementStatsEntry('cache_hits'); } else { // Load from database - $result = SQL_QUERY_ESC("SELECT `id` AS `ext_id` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1", + $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1", array($ext_name), __FUNCTION__, __LINE__); // Is the entry there? if (SQL_NUMROWS($result) == 1) { // Get the extension's id from database $data = SQL_FETCHARRAY($result); + + // Set cache + setExtensionCacheRow($ext_name, $data); } // END - if // Free result SQL_FREERESULT($result); - - // Cache it - $GLOBALS['cache_array']['extension']['ext_id'][$ext_name] = $data['ext_id']; } // Return value diff --git a/inc/extensions/ext-other.php b/inc/extensions/ext-other.php index 4e6a3faf36..2a4b79b89d 100644 --- a/inc/extensions/ext-other.php +++ b/inc/extensions/ext-other.php @@ -41,10 +41,10 @@ if (!defined('__SECURITY')) { } // END - if // Version number -setThisExtensionVersion('0.2.8'); +setThisExtensionVersion('0.2.9'); // Version history array (add more with , '0.0.1' and so on) -setExtensionVersionHistory(array('0.0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8')); +setExtensionVersionHistory(array('0.0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9')); // Keep this extension always active! setExtensionAlwaysActive('Y'); @@ -248,6 +248,13 @@ switch (getExtensionMode()) { // Update notes (these will be set as task text!) setExtensionUpdateNotes("mailid_error_redirect bzw. alle ENUMs haben gross geschriebene Werte."); break; + + case '0.2.9': // SQL queries for v0.2.9 + addConfigAddSql('word_wrap', 'TINYINT(3) NOT NULL DEFAULT 15'); + + // Update notes (these will be set as task text!) + setExtensionUpdateNotes("Anzahl Zeichen für wordwrap()-Aufruf hinzugefügt."); + break; } // END - switch break; diff --git a/inc/extensions/ext-sql_patches.php b/inc/extensions/ext-sql_patches.php index 169365ac92..0bf2a50359 100644 --- a/inc/extensions/ext-sql_patches.php +++ b/inc/extensions/ext-sql_patches.php @@ -268,7 +268,7 @@ IN ( break; case '0.2.1': // SQL queries for v0.2.1 - addConfigAddSql('css_php', "ENUM('DIRECT','FILE') NOT NULL DEFAULT 'FILE'"); + addConfigAddSql('css_php', "ENUM('DIRECT','FILE','INLINE') NOT NULL DEFAULT 'FILE'"); // Update notes (these will be set as task text!) setExtensionUpdateNotes("Ausgabe der CSS-Dateien entweder per css.php oder sie sind direkt eingebunden."); diff --git a/inc/handler.php b/inc/handler.php index 5f6223f5c3..40aecad99e 100644 --- a/inc/handler.php +++ b/inc/handler.php @@ -43,8 +43,9 @@ if (!defined('__SECURITY')) { // Error handler function function __errorHandler ($errno, $errstr, $errfile, $errline) { // Construct message - $message = sprintf("errno=%s,errstr=%s,errfile=%s,errline=%s", + $message = sprintf("errno=%s(0x%s),errstr=%s,errfile=%s,errline=%s", $errno, + getHexErrorCode($errno), $errstr, basename($errfile), $errline diff --git a/inc/language/holiday_de.php b/inc/language/holiday_de.php index 63fde0edd3..2d39e30197 100644 --- a/inc/language/holiday_de.php +++ b/inc/language/holiday_de.php @@ -44,7 +44,7 @@ if (!defined('__SECURITY')) { addMessages(array( // Admin strings 'ADMIN_TASK_TYPE_HOLIDAY_REQUEST' => "Urlaubsanfrage", - 'ADMIN_HOLIDAY_NOTHING_FOUND' => "Niemand hat Urlaub beantragt.", + 'ADMIN_LIST_HOLIDAY_404' => "Niemand hat Urlaub beantragt.", 'ADMIN_HOLIDAY_TSTART' => "Anfang", 'ADMIN_HOLIDAY_TEND' => "Ende", 'ADMIN_HOLIDAY_COMMENTS' => "Kommentar", diff --git a/inc/language/other_de.php b/inc/language/other_de.php index cbecbe7e72..808873b76e 100644 --- a/inc/language/other_de.php +++ b/inc/language/other_de.php @@ -80,6 +80,8 @@ addMessages(array( 'ADMIN_CONFIG_DISPLAY_DEBUG_SQLS' => "Sollen die SQL-Abfragen für Administratoren zu Debug-Zwecken angezeigt werden?. Das Einschalten dieser Einstellung kann enorme Performanceverluste bedeuten.", 'ADMIN_CONFIG_INTERNAL_STATS_TITLE' => "Interne Statistik-Einstellungen", 'ADMIN_CONFIG_INTERNAL_STATS_ENABLED' => "Sollen die internen Statistiken eingeschaltet sein? Das Abschalten dieser Statistiken kann etwas Performance bringen, ist aber für Performancemessungen vorraussetzend.", + 'ADMIN_CONFIG_WORD_WRAP' => "Allgemeiner Zeilenumbruch", + 'ADMIN_CONFIG_OTHER_NOTICE' => "Hinweise: Der allgemeine Zeilenumbruch (in Zeichen angegeben) gilt als Fallback-Einstellung falls der für die Erweiterung spezielle Konfigurationseintrag fehlen sollte. Für Details, siehe Funktion getWordWrap() im Script inc/wrapper-functions.php.", )); // [EOF] diff --git a/inc/loader/load-extension.php b/inc/loader/load-extension.php index 8452a87aa2..bc5932f252 100644 --- a/inc/loader/load-extension.php +++ b/inc/loader/load-extension.php @@ -139,7 +139,8 @@ if (($GLOBALS['cache_instance']->loadCacheFile('extension')) && ($GLOBALS['cache // Add more if ext-sql_patches is recent enougth $add = ''; if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) { - $add = ',`ext_has_css` AS `ext_css`'; + // Old naming + $add = ', `ext_has_css` AS `ext_css`'; } // END - if // Query for all extensions diff --git a/inc/modules/admin/what-config_other.php b/inc/modules/admin/what-config_other.php index 81aac69a10..78688741e5 100644 --- a/inc/modules/admin/what-config_other.php +++ b/inc/modules/admin/what-config_other.php @@ -67,7 +67,7 @@ if (isFormSent('save_config')) { if (!isPostRequestElementSet('reject_url')) { unsetPostRequestElement('ok'); } } // END - if -if (isFormSent()) { +if (isFormSent('save_config')) { // Update stamps directly adminSaveSettingsFromPostData(); } else { diff --git a/inc/modules/admin/what-extensions.php b/inc/modules/admin/what-extensions.php index c787c6bb35..36abfe44a3 100644 --- a/inc/modules/admin/what-extensions.php +++ b/inc/modules/admin/what-extensions.php @@ -281,29 +281,29 @@ switch ($do) { case 'overview': // List all registered extensions if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) { // Load extension data with CSS informations - $result = SQL_QUERY("SELECT - `id` AS `ext_id`, + $result = SQL_QUERY('SELECT + `ext_id`, `ext_name`, `ext_active`, - `ext_has_css` AS `ext_css`, + `ext_css`, `ext_version` FROM `{?_MYSQL_PREFIX?}_extensions` -".$where." +' . $where . ' ORDER BY - `ext_name` ASC", __FILE__, __LINE__); + `ext_name` ASC', __FILE__, __LINE__); } else { // Load extension data without CSS informations - $result = SQL_QUERY("SELECT - `id` AS `ext_id`, + $result = SQL_QUERY('SELECT + `ext_id`, `ext_name`, `ext_active`, `ext_version` FROM `{?_MYSQL_PREFIX?}_extensions` -".$where." +' . $where . ' ORDER BY - `ext_name` ASC", __FILE__, __LINE__); + `ext_name` ASC', __FILE__, __LINE__); } // Are there some entries? diff --git a/inc/modules/admin/what-list_holiday.php b/inc/modules/admin/what-list_holiday.php index e3899b351c..da009cb1fe 100644 --- a/inc/modules/admin/what-list_holiday.php +++ b/inc/modules/admin/what-list_holiday.php @@ -45,15 +45,21 @@ addYouAreHereLink('admin', __FILE__); // Start listing holiday requests $result = SQL_QUERY("SELECT - h.id, h.userid, h.holiday_start, h.holiday_end, h.comments, d.status, d.last_online + h.`id`, + h.`userid`, + h.`holiday_start`, + h.`holiday_end`, + h.`comments`, + d.`status`, + d.`last_online` FROM - `{?_MYSQL_PREFIX?}_user_holidays` AS h + `{?_MYSQL_PREFIX?}_user_holidays` AS `h` LEFT JOIN - `{?_MYSQL_PREFIX?}_user_data` AS d + `{?_MYSQL_PREFIX?}_user_data` AS `d` ON - h.userid=d.userid + h.`userid`=d.`userid` ORDER BY - h.userid ASC", __FILE__, __LINE__); + h.`userid` ASC", __FILE__, __LINE__); if (!SQL_HASZERONUMS($result)) { // List all holiday requests @@ -65,7 +71,6 @@ if (!SQL_HASZERONUMS($result)) { 'userid' => $content['userid'], 'start' => generateDateTime($content['holiday_start'], 3), 'end' => generateDateTime($content['holiday_end'], 3), - 'comments' => wordwrap($content['comments'], 15), 'status' => $content['status'], 'last_online' => generateDateTime($content['last_online'], 3), ); @@ -81,7 +86,7 @@ if (!SQL_HASZERONUMS($result)) { loadTemplate('admin_list_holiday', FALSE, $OUT); } else { // No holiday requests found - displayMessage('{--ADMIN_HOLIDAY_NOTHING_FOUND--}'); + displayMessage('{--ADMIN_LIST_HOLIDAY_404--}'); } // [EOF] diff --git a/inc/modules/admin/what-list_transfer.php b/inc/modules/admin/what-list_transfer.php index a83f0ea0ec..e0ecf14f53 100644 --- a/inc/modules/admin/what-list_transfer.php +++ b/inc/modules/admin/what-list_transfer.php @@ -63,7 +63,6 @@ if (!SQL_HASZERONUMS($result)) { while ($content = SQL_FETCHARRAY($result)) { // Prepare data for the row template $content['time_trans'] = generateDateTime($content['time_trans'], 3); - $content['reason'] = wordwrap($content['reason'], 15); // Load row template add points and switch color $OUT .= loadTemplate('admin_list_transfer_row', TRUE, $content); diff --git a/inc/stylesheet.php b/inc/stylesheet.php index bb2bb16c6c..7e46cc0af0 100644 --- a/inc/stylesheet.php +++ b/inc/stylesheet.php @@ -66,7 +66,7 @@ if ($currentTheme != getSession('mailer_theme')) { } // END - if // Output CSS files or content or link to css.php ? -if ((isCssOutputMode()) || (getConfig('css_php') == 'DIRECT')) { +if ((isCssOutputMode()) || (getCssPhp() == 'DIRECT')) { // Load CSS files $stylesList = merge_array($stylesList, getExtensionCssFiles()); @@ -80,7 +80,7 @@ if ((isCssOutputMode()) || (getConfig('css_php') == 'DIRECT')) { // Do include only existing files and whose are not empty if ((isFileReadable($FQFN)) && (filesize($FQFN) > 0)) { - switch (getConfig('css_php')) { + switch (getCssPhp()) { case 'DIRECT': // Just link them (unsupported) $GLOBALS['__page_header'] .= ''; break; @@ -90,12 +90,12 @@ if ((isCssOutputMode()) || (getConfig('css_php') == 'DIRECT')) { break; default: // Invalid mode! - reportBug(__FILE__, __LINE__, sprintf("Invalid css_php value %s detected.", getConfig('css_php'))); + reportBug(__FILE__, __LINE__, sprintf("Invalid css_php value %s detected.", getCssPhp())); break; } // END - switch } // END - if } // END - foreach -} elseif ((isHtmlOutputMode()) || (getConfig('css_php') == 'INLINE')) { +} elseif ((isHtmlOutputMode()) || (getCssPhp() == 'INLINE')) { // Load CSS files $stylesList = merge_array($stylesList, getExtensionCssFiles()); diff --git a/inc/template-functions.php b/inc/template-functions.php index fe01016b23..c57e2c52e2 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -467,7 +467,7 @@ function loadEmailTemplate ($template, $content = array(), $userid = NULL, $load // Is content an array? if (is_array($content)) { // Add expiration to array - if ((isExtensionInstalled('autopurge')) && (getAutoPurge() == '0')) { + if ((isExtensionInstalled('autopurge')) && (isConfigEntrySet('auto_purge')) && (getAutoPurge() == '0')) { // Will never expire! $content['expiration'] = '{--MAIL_WILL_NEVER_EXPIRE--}'; } elseif ((isExtensionInstalled('autopurge')) && (isConfigEntrySet('auto_purge'))) { diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index f2fc6b72be..5c8db1d70d 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -2546,6 +2546,42 @@ function getPointsRemoveAccount () { return $GLOBALS[__FUNCTION__]; } +// Getter for 'css_php' +function getCssPhp () { + // Is the cache entry set? + if (!isset($GLOBALS[__FUNCTION__])) { + // No, so determine it + $GLOBALS[__FUNCTION__] = getConfig('css_php'); + } // END - if + + // Return cached entry + return $GLOBALS[__FUNCTION__]; +} + +// Getter for 'word_wrap' +function getWordWrap () { + // Is the cache entry set? + if (!isset($GLOBALS[__FUNCTION__])) { + // Construct config entry name + $configEntry = getMenuModeFromModule() . '_word_wrap_' . getWhat(); + + // Is a special config entry found or ext-sql_patches updated? + if (isConfigEntrySet($configEntry)) { + // A special config entry has been found, then use it + $GLOBALS[__FUNCTION__] = getConfig($configEntry); + } elseif (isExtensionInstalledAndNewer('other', '0.2.9')) { + // No special config entry found, then use it as "fall-back" + $GLOBALS[__FUNCTION__] = getConfig('word_wrap'); + } else { + // No, use default (15 characters) + $GLOBALS[__FUNCTION__] = 15; + } + } // END - if + + // Return cached entry + return $GLOBALS[__FUNCTION__]; +} + // Checks whether proxy configuration is used function isProxyUsed () { // Is there cache? @@ -3171,5 +3207,14 @@ function SQL_DEBUG_ENABLED () { return $GLOBALS[__FUNCTION__]; } +// Wrapper function to wrap call of wordwrap() +function wrapWords ($text) { + // Wrap words + $wrapped = wordwrap($test, getWordWrap()); + + // Return it + return $wrapped; +} + // [EOF] ?> diff --git a/install/tables.sql b/install/tables.sql index 6f177fc674..7b1b3cb83a 100644 --- a/install/tables.sql +++ b/install/tables.sql @@ -189,7 +189,7 @@ CREATE TABLE `{?_MYSQL_PREFIX?}_task_system` ( DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_extensions`; CREATE TABLE `{?_MYSQL_PREFIX?}_extensions` ( - `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, + `ext_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, `ext_name` VARCHAR(255) NOT NULL DEFAULT '', `ext_active` ENUM('Y','N') NOT NULL DEFAULT 'N', `ext_version` VARCHAR(255) NOT NULL DEFAULT 'INVALID', diff --git a/templates/de/html/admin/admin_config_other.tpl b/templates/de/html/admin/admin_config_other.tpl index 96059b36e0..129afd3e2f 100644 --- a/templates/de/html/admin/admin_config_other.tpl +++ b/templates/de/html/admin/admin_config_other.tpl @@ -154,15 +154,24 @@ - + {--ADMIN_CONFIG_MAILID_REDIRECT--} - + {--ADMIN_CONFIG_MAILID_REDIRECT_INDEX--}
{--ADMIN_CONFIG_MAILID_REDIRECT_REJECT--} + + + {--ADMIN_CONFIG_WORD_WRAP--}: + + + + + + {--ADMIN_CONFIG_SENDING_TITLE--} @@ -296,3 +305,7 @@ {%form_close%} + +
+ {--ADMIN_CONFIG_OTHER_NOTICE--} +
diff --git a/templates/de/html/admin/admin_list_holiday_row.tpl b/templates/de/html/admin/admin_list_holiday_row.tpl index 2945811982..d5c678b8d8 100644 --- a/templates/de/html/admin/admin_list_holiday_row.tpl +++ b/templates/de/html/admin/admin_list_holiday_row.tpl @@ -12,7 +12,7 @@ $content[end] -
{%pipe,fixEmptyContentToDashes=$content[comments]%}
+
{%pipe,wrapWords,fixEmptyContentToDashes=$content[comments]%}
{%user,status,translateUserStatus=$content[userid]%} diff --git a/templates/de/html/admin/admin_list_transfer_row.tpl b/templates/de/html/admin/admin_list_transfer_row.tpl index dc69e81bc0..faf82ccb71 100644 --- a/templates/de/html/admin/admin_list_transfer_row.tpl +++ b/templates/de/html/admin/admin_list_transfer_row.tpl @@ -12,7 +12,7 @@ {%pipe,generateUserProfileLink=$content[to_userid]%} - $content[reason] + {%pipe,wrapWords=$content[reason]%} {%pipe,translateComma=$content[points]%}