Introduced 'per-what-word-wrapping
authorRoland Häder <roland@mxchange.org>
Sat, 1 Dec 2012 15:05:07 +0000 (15:05 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 1 Dec 2012 15:05:07 +0000 (15:05 +0000)
18 files changed:
inc/extensions-functions.php
inc/extensions/ext-other.php
inc/extensions/ext-sql_patches.php
inc/handler.php
inc/language/holiday_de.php
inc/language/other_de.php
inc/loader/load-extension.php
inc/modules/admin/what-config_other.php
inc/modules/admin/what-extensions.php
inc/modules/admin/what-list_holiday.php
inc/modules/admin/what-list_transfer.php
inc/stylesheet.php
inc/template-functions.php
inc/wrapper-functions.php
install/tables.sql
templates/de/html/admin/admin_config_other.tpl
templates/de/html/admin/admin_list_holiday_row.tpl
templates/de/html/admin/admin_list_transfer_row.tpl

index 74144af..08346b0 100644 (file)
@@ -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
index 4e6a3fa..2a4b79b 100644 (file)
@@ -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("<strong>mailid_error_redirect</strong> 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&uuml;r <strong>wordwrap()</strong>-Aufruf hinzugef&uuml;gt.");
+                               break;
                } // END - switch
                break;
 
index 169365a..0bf2a50 100644 (file)
@@ -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.");
index 5f6223f..40aecad 100644 (file)
@@ -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
index 63fde0e..2d39e30 100644 (file)
@@ -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",
index cbecbe7..808873b 100644 (file)
@@ -80,6 +80,8 @@ addMessages(array(
        'ADMIN_CONFIG_DISPLAY_DEBUG_SQLS' => "Sollen die SQL-Abfragen f&uuml;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&uuml;r Performancemessungen vorraussetzend.",
+       'ADMIN_CONFIG_WORD_WRAP' => "Allgemeiner Zeilenumbruch",
+       'ADMIN_CONFIG_OTHER_NOTICE' => "<strong>Hinweise:</strong> Der allgemeine Zeilenumbruch (in Zeichen angegeben) gilt als Fallback-Einstellung falls der f&uuml;r die Erweiterung spezielle Konfigurationseintrag fehlen sollte. F&uuml;r Details, siehe Funktion <strong>getWordWrap()</strong> im Script <strong>inc/wrapper-functions.php</strong>.",
 ));
 
 // [EOF]
index 8452a87..bc5932f 100644 (file)
@@ -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
index 81aac69..7868874 100644 (file)
@@ -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 {
index c787c6b..36abfe4 100644 (file)
@@ -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?
index e3899b3..da009cb 100644 (file)
@@ -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]
index a83f0ea..e0ecf14 100644 (file)
@@ -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);
index bb2bb16..7e46cc0 100644 (file)
@@ -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'] .= '<link rel="stylesheet" type="text/css" href="{%url=theme/' . getCurrentTheme() . '/' . $value . '%}" />';
                                        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());
 
index fe01016..c57e2c5 100644 (file)
@@ -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'))) {
index f2fc6b7..5c8db1d 100644 (file)
@@ -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]
 ?>
index 6f177fc..7b1b3cb 100644 (file)
@@ -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',
index 96059b3..129afd3 100644 (file)
        </tr>
 
        <tr>
-               <td class="bottom" align="right">
+               <td align="right">
                        {--ADMIN_CONFIG_MAILID_REDIRECT--}
                </td>
-               <td class="bottom">
+               <td>
                        <input type="radio" class="form_field" name="mailid_error_redirect" value="INDEX"$content[mailid_error_redirect_index] /> {--ADMIN_CONFIG_MAILID_REDIRECT_INDEX--}<br />
                        <input type="radio" class="form_field" name="mailid_error_redirect" value="REJECT"$content[mailid_error_redirect_reject] /> {--ADMIN_CONFIG_MAILID_REDIRECT_REJECT--}
                </td>
        </tr>
 
        <tr>
+               <td class="bottom" align="right">
+                       {--ADMIN_CONFIG_WORD_WRAP--}:
+               </td>
+               <td class="bottom">
+                       <input type="text" class="form_field" name="word_wrap" size="3" maxlength="3" value="{?word_wrap?}" />
+               </td>
+       </tr>
+
+       <tr>
                <td colspan="2" align="center" class="table_header bottom">
                        <strong>{--ADMIN_CONFIG_SENDING_TITLE--}</strong>
                </td>
 </table>
 {%form_close%}
 </div>
+
+<div class="notice">
+       {--ADMIN_CONFIG_OTHER_NOTICE--}
+</div>
index 2945811..d5c678b 100644 (file)
@@ -12,7 +12,7 @@
                $content[end]
        </td>
        <td class="{%template,ColorSwitch%} bottom right" align="center">
-               <pre>{%pipe,fixEmptyContentToDashes=$content[comments]%}</pre>
+               <pre>{%pipe,wrapWords,fixEmptyContentToDashes=$content[comments]%}</pre>
        </td>
        <td class="{%template,ColorSwitch%} bottom right" align="center">
                {%user,status,translateUserStatus=$content[userid]%}
index dc69e81..faf82cc 100644 (file)
@@ -12,7 +12,7 @@
                {%pipe,generateUserProfileLink=$content[to_userid]%}
        </td>
        <td class="{%template,ColorSwitch%} bottom right">
-               $content[reason]
+               {%pipe,wrapWords=$content[reason]%}
        </td>
        <td class="{%template,ColorSwitch%} bottom" align="center">
                {%pipe,translateComma=$content[points]%}