From 07af932574589f4906be5ebf6733fdb95f30e9a2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 12 Sep 2010 12:42:57 +0000 Subject: [PATCH] Functions renamed --- DOCS/TODOs.txt | 2 +- inc/expression-functions.php | 2 +- inc/filter-functions.php | 2 +- inc/filters.php | 8 +-- inc/language/de.php | 4 +- inc/language/update_de.php | 4 +- inc/loader/load_cache-revision.php | 2 +- inc/modules/admin/what-updates.php | 4 +- inc/revision-functions.php | 58 ++++++++++++++----- inc/stylesheet.php | 2 +- inc/versions.php | 6 +- inc/wrapper-functions.php | 4 +- .../de/html/admin/admin_update_download.tpl | 4 +- templates/de/html/copyright.tpl | 2 +- templates/de/html/copyright_backlink.tpl | 2 +- templates/de/html/theme/theme_one.tpl | 2 +- 16 files changed, 67 insertions(+), 41 deletions(-) diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 4c7bffd8cd..75ebe55aff 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -185,7 +185,7 @@ ./inc/mysql-manager.php:44:// @TODO Can we cache this? ./inc/reset/reset_beg.php:49:// @TODO This should be converted in a daily beg rallye ./inc/reset/reset_birthday.php:89: // @TODO 4 is hard-coded here, should we move it out in config? -./inc/revision-functions.php:151:// @TODO Please describe this function +./inc/revision-functions.php:169:// @TODO This function does also set and get in 'cache_array' ./inc/template-functions.php:1139: // @TODO This can be easily moved out after the merge from EL branch to this is complete ./inc/template-functions.php:1172: // @TODO Add a little more infos here ./inc/template-functions.php:1460:// @TODO Lame description for this function diff --git a/inc/expression-functions.php b/inc/expression-functions.php index 0c76f8f37f..b3ee099725 100644 --- a/inc/expression-functions.php +++ b/inc/expression-functions.php @@ -151,7 +151,7 @@ function doExpressionExt ($data) { } // END - if // Generate replacer - $replacer = sprintf("&ext=%s&ver=%s&rev={?CURR_SVN_REVISION?}", $data['matches'][4][$data['key']], $replacer); + $replacer = sprintf("&ext=%s&ver=%s&rev={?CURRENT_REPOSITORY_REVISION?}", $data['matches'][4][$data['key']], $replacer); // Replace it and insert parameter for GET request $code = replaceExpressionCode($data, $replacer); diff --git a/inc/filter-functions.php b/inc/filter-functions.php index f944978b24..d91d5d6ea6 100644 --- a/inc/filter-functions.php +++ b/inc/filter-functions.php @@ -104,7 +104,7 @@ ORDER BY registerFilter('init', 'INIT_EXTENSIONS'); registerFilter('init', 'SET_CURRENT_DATE'); registerFilter('init', 'INIT_RANDOM_NUMBER'); - registerFilter('init', 'CHECK_SVN_REVISION'); + registerFilter('init', 'CHECK_REPOSITORY_REVISION'); registerFilter('init', 'RUN_DAILY_RESET'); registerFilter('init', 'TRIGGER_SENDING_POOL'); registerFilter('init', 'DETERMINE_USERNAME'); diff --git a/inc/filters.php b/inc/filters.php index 164acb9225..de7de41c6d 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -710,15 +710,15 @@ function FILTER_TRIGGER_SENDING_POOL () { } // Filter for checking and updating SVN revision -function FILTER_CHECK_SVN_REVISION () { +function FILTER_CHECK_REPOSITORY_REVISION () { // Only execute this filter if installed and all config entries are there if ((!isInstalled()) || (!isConfigEntrySet('patch_level'))) return; // Check for patch level differences between databases and current hard-coded - if ((getCurrSvnRevision() > getConfig('patch_level')) || (getConfig('patch_level') == 'CURR_SVN_REVISION') || (getConfig('patch_ctime') == 'UNIX_TIMES')) { + if ((getCurrentRepositoryRevision() > getConfig('patch_level')) || (getConfig('patch_level') == 'CURRENT_REPOSITORY_REVISION') || (getConfig('patch_ctime') == 'UNIX_TIMES')) { // Update database and CONFIG array - updateConfiguration(array('patch_level', 'patch_ctime'), array(getCurrSvnRevision(), 'UNIX_TIMESTAMP()')); - setConfigEntry('patch_level', getCurrSvnRevision()); + updateConfiguration(array('patch_level', 'patch_ctime'), array(getCurrentRepositoryRevision(), 'UNIX_TIMESTAMP()')); + setConfigEntry('patch_level', getCurrentRepositoryRevision()); setConfigEntry('patch_ctime', time()); } // END - if } diff --git a/inc/language/de.php b/inc/language/de.php index e2ee800036..ee533f45cb 100644 --- a/inc/language/de.php +++ b/inc/language/de.php @@ -834,7 +834,7 @@ addMessages(array( 'ADMIN_THEMES_UPDATED' => "Themes wurden aktualisiert.", 'ADMIN_THEMES_DELETED' => "Themes wurden gelöscht.", 'ADMIN_THEME_IMPORTED' => "Theme %s wurde importiert.", - 'CURR_THEME_IS' => "Aktuelles Design:", + 'CURRENT_THEME_IS' => "Aktuelles Design:", 'ADMIN_NO_THEME_INSTALLED_WARNING' => "Kein Design installiert.", 'CHANGE_THEME' => "Design ändern", 'ADMIN_SET_AS_NEW_THEME' => "Dieses Theme als Standart-Theme setzen", @@ -878,7 +878,7 @@ addMessages(array( 'ADMIN_ENTER_SUB_REASON' => "Grund des Abzuges", 'ADMIN_SUB_POINTS_FROM_ALL' => "Allen Mitgliedern {?POINTS?} abziehen", 'ADMIN_DOWNLOAD_SVN' => "SVN-Version herunterladen", - 'ADMIN_SVN_REPOSITORY' => "SVN-Repository", + 'ADMIN_REPOSITORY' => "SVN-Repository", 'ADMIN_DOWNLOAD_NOW' => "Jetzt downloaden.", 'ADMIN_MEMBER_STATS_TITLE' => "Einstellungen an der Mitglieder-Statistik", 'ADMIN_MEMBER_STATS_LIMIT' => "Anzahl Mailbuchungen pro Seite (Nicht verwendet!)", diff --git a/inc/language/update_de.php b/inc/language/update_de.php index ab8ffae1d0..0100437c01 100644 --- a/inc/language/update_de.php +++ b/inc/language/update_de.php @@ -43,13 +43,13 @@ if (!defined('__SECURITY')) { // Installation/setup addMessages(array( 'ADMIN_NEW_VERSION_AVAILABLE' => "Neue Version verfügbar.", - 'ADMIN_NO_UPDATES_AVAILABLE' => "Derzeit ist keine neuere Version als {?FULL_VERSION?} r{?CURR_SVN_REVISION?} verfügbar.", + 'ADMIN_NO_UPDATES_AVAILABLE' => "Derzeit ist keine neuere Version als {?FULL_VERSION?} r{?CURRENT_REPOSITORY_REVISION?} verfügbar.", 'ADMIN_YOUR_VERSION_IS' => "Installierte Version", 'ADMIN_ONLINE_VERSION_IS' => "Verfügbare Version", 'ADMIN_UPDATE_CREATE_TIME' => "Update wurde erstellt", 'ADMIN_DOWNLOAD_NEW_VERSION' => "Jetzt neue Version herunterladen.", 'ADMIN_CANNOT_CHECK_VERSION' => "Konnte Versionsnummer nicht abgleichen! (Fehlende Internet-Verbindung? Server ist down?)", - 'ADMIN_LOCAL_REVISION_IS_NEWER_THAN_UPDATE' => "Die auf Ihrem installierte Revision {?CURR_SVN_REVISION?} ist neuer als die auf dem Server. Dies sollte nicht vorkommen, bitte melden Sie dies im Forum oder Bug-Tracker.", + 'ADMIN_LOCAL_REVISION_IS_NEWER_THAN_UPDATE' => "Die auf Ihrem installierte Revision {?CURRENT_REPOSITORY_REVISION?} ist neuer als die auf dem Server. Dies sollte nicht vorkommen, bitte melden Sie dies im Forum oder Bug-Tracker.", )); // [EOF] diff --git a/inc/loader/load_cache-revision.php b/inc/loader/load_cache-revision.php index 29d8950b3e..d15d410c30 100644 --- a/inc/loader/load_cache-revision.php +++ b/inc/loader/load_cache-revision.php @@ -49,7 +49,7 @@ if ($GLOBALS['cache_instance']->loadCacheFile('revision')) { $GLOBALS['cache_instance']->init(); // add the new RevInfos in and saves it to the cache - $GLOBALS['cache_instance']->addRow(getArrayFromActualVersion()); + $GLOBALS['cache_instance']->addRow(getArrayFromRepositoryData()); // Close the cache $GLOBALS['cache_instance']->finalize(); diff --git a/inc/modules/admin/what-updates.php b/inc/modules/admin/what-updates.php index 5d702805a0..9ea426a407 100644 --- a/inc/modules/admin/what-updates.php +++ b/inc/modules/admin/what-updates.php @@ -89,13 +89,13 @@ if (empty($response[0]) && empty($response[1]) && empty($response[2]) && empty($ if (empty($ONLINE['version'])) { // Disconnected? loadTemplate('admin_settings_unsaved', false, '{--ADMIN_CANNOT_CHECK_VERSION--} (' . $ONLINE['code'] . ')'); -} elseif (($ONLINE['version'] != getFullVersion()) || ($ONLINE['revision'] > getCurrSvnRevision())) { +} elseif (($ONLINE['version'] != getFullVersion()) || ($ONLINE['revision'] > getCurrentRepositoryRevision())) { // New full-version available (all previous released patches are included in this version!) $ONLINE['changed'] = generateDateTime($ONLINE['changed'], 2); // Load template loadTemplate('admin_update_download', false, $ONLINE); -} elseif ($ONLINE['revision'] < getCurrSvnRevision()) { +} elseif ($ONLINE['revision'] < getCurrentRepositoryRevision()) { // Installed revision is newer than on server loadTemplate('admin_settings_saved', false, '{--ADMIN_LOCAL_REVISION_IS_NEWER_THAN_UPDATE--}'); } else { diff --git a/inc/revision-functions.php b/inc/revision-functions.php index 37ed37f415..ff8fd97206 100644 --- a/inc/revision-functions.php +++ b/inc/revision-functions.php @@ -40,8 +40,25 @@ if (!defined('__SECURITY')) { die(); } // END - if +// Initializes repository data +function initRepositoryData () { + // Default data values or array indexes if numerical + $GLOBALS['default_repository_data'] = array( + // Main author of this script + 'Author' => 'quix0r', + // No default value for current file name + 'File' => 11, + // No default value for revision number + 'Revision' => 10, + // No default value for date + 'Date' => 9, + // Default branch + 'Tag' => 8 + ); +} + // "Getter" for revision/version data -function getActualVersion ($type = 'Revision') { +function getRepositoryData ($type = 'Revision') { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ret[' . $type . '] - ENTRY!'); // Default is an invalid value to find bugs... :-) $ret = 'INVALID'; @@ -89,7 +106,7 @@ function getActualVersion ($type = 'Revision') { } // END - foreach // Return found value - $ret = getActualVersion($type); + $ret = getRepositoryData($type); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ret[' . $type . ']=' . $ret); } } @@ -98,10 +115,10 @@ function getActualVersion ($type = 'Revision') { // Has it been updated? if ($new === true) { // Write it - writeToFile($FQFN, implode("\n", getArrayFromActualVersion())); + writeToFile($FQFN, implode("\n", getArrayFromRepositoryData())); // ... and call recursive - $ret = getActualVersion($type); + $ret = getRepositoryData($type); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ret[' . $type . ']=' . $ret); } // END - if } @@ -112,7 +129,7 @@ function getActualVersion ($type = 'Revision') { } // Repares an array we are looking for -// The returned Array is needed twice (in getArrayFromActualVersion() and in getActualVersion() in the old .revision-fallback) so I puted it in an extra function to not polute the global namespace +// The returned Array is needed twice (in getArrayFromRepositoryData() and in getRepositoryData() in the old .revision-fallback) so I puted it in an extra function to not polute the global namespace function getSearchFor () { // Add Revision, Date, Tag and Author $searchFor = array('File', 'Revision', 'Date', 'Tag', 'Author'); @@ -148,8 +165,9 @@ function extractRevisionInfoFromFile ($FQFN, $search) { return extractRevisionInfoFromData($fileData, $search); } -// @TODO Please describe this function -function getArrayFromActualVersion () { +// Gets an array back for current repository data. +// @TODO This function does also set and get in 'cache_array' +function getArrayFromRepositoryData () { // Init array $GLOBALS['cache_array']['revision'] = array(); @@ -189,9 +207,9 @@ function getArrayFromActualVersion () { // at least 3 keyword-Tags are needed for propper values if ($GLOBALS['revision_res'] && $GLOBALS['revision_res'] >= 3 - && isset($GLOBALS['cache_array']['revision']['Revision'][0]) && $GLOBALS['cache_array']['revision']['Revision'][0] != '' - && isset($GLOBALS['cache_array']['revision']['Date'][0]) && $GLOBALS['cache_array']['revision']['Date'][0] != '' - && isset($GLOBALS['cache_array']['revision']['Tag'][0]) && $GLOBALS['cache_array']['revision']['Tag'][0] != '') { + && isset($GLOBALS['cache_array']['revision']['Revision'][0]) && !empty($GLOBALS['cache_array']['revision']['Revision'][0]) + && isset($GLOBALS['cache_array']['revision']['Date'][0]) && !empty($GLOBALS['cache_array']['revision']['Date'][0]) + && isset($GLOBALS['cache_array']['revision']['Tag'][0]) && !empty($GLOBALS['cache_array']['revision']['Tag'][0])) { // Prepare content witch need special treadment // Prepare timestamp for date @@ -210,16 +228,24 @@ function getArrayFromActualVersion () { // Invalid request reply? if (!isset($version[11])) { // Cannot continue here - debug_report_bug(__FUNCTION__, __LINE__, 'Invalid response from check-updates3.php, count should be 10+, is ' . count($version)); + debug_report_bug(__FUNCTION__, __LINE__, 'Invalid response from check-updates3.php, count should be at least 11, is ' . count($version)); } // END - if // Prepare content // Only sets not setted or not proper values to the Online-Server-Fallback-Solution - if (!isset($GLOBALS['cache_array']['revision']['File'][0]) || $GLOBALS['cache_array']['revision']['File'][0] == '') $GLOBALS['cache_array']['revision']['File'][0] = trim($version[11]); - if (!isset($GLOBALS['cache_array']['revision']['Revision'][0]) || $GLOBALS['cache_array']['revision']['Revision'][0] == '') $GLOBALS['cache_array']['revision']['Revision'][0] = trim($version[10]); - if (!isset($GLOBALS['cache_array']['revision']['Date'][0]) || $GLOBALS['cache_array']['revision']['Date'][0] == '') $GLOBALS['cache_array']['revision']['Date'][0] = trim($version[9]); - if (!isset($GLOBALS['cache_array']['revision']['Tag'][0]) || $GLOBALS['cache_array']['revision']['Tag'][0] == '') $GLOBALS['cache_array']['revision']['Tag'][0] = trim($version[8]); - if (!isset($GLOBALS['cache_array']['revision']['Author'][0]) || $GLOBALS['cache_array']['revision']['Author'][0] == '') $GLOBALS['cache_array']['revision']['Author'][0] = 'quix0r'; + foreach (getSearchFor() as $entry) { + // Is it not set or empty? + if ((!isset($GLOBALS['cache_array']['revision'][$entry][0])) || (empty($GLOBALS['cache_array']['revision']['File'][0]))) { + // Is default data entry nummerical? + if (is_numeric($GLOBALS['default_repository_data'][$entry])) { + // Use entry from $version + $GLOBALS['cache_array']['revision'][$entry][0] = trim($version[$GLOBALS['default_repository_data'][$entry]]); + } else { + // Non-numeric -> use it directly + $GLOBALS['cache_array']['revision'][$entry][0] = $GLOBALS['default_repository_data'][$entry]; + } + } // END - if + } // END - if } // Temporary remove [0] from array diff --git a/inc/stylesheet.php b/inc/stylesheet.php index cd60159cc5..9658652f39 100644 --- a/inc/stylesheet.php +++ b/inc/stylesheet.php @@ -114,7 +114,7 @@ if ((isCssOutputMode()) || (getConfig('css_php') == 'DIRECT')) { $OUT .= '?theme=' . $newTheme . '&installing=1'; } else { // Add SVN revision to bypass caching problems - $OUT .= '?rev=' . getCurrSvnRevision(); + $OUT .= '?rev=' . getCurrentRepositoryRevision(); } // Close tag diff --git a/inc/versions.php b/inc/versions.php index 404e6fe79b..abc4cc7b8c 100644 --- a/inc/versions.php +++ b/inc/versions.php @@ -41,11 +41,11 @@ if (!defined('__SECURITY')) { } // END - if // If you understand regular expressions ^^^ you may know how I versionize... ;-) -setConfigEntry('FULL_VERSION', getActualVersion('Tag')); +setConfigEntry('FULL_VERSION', getRepositoryData('Tag')); // Current SVN revision and date -setConfigEntry('CURR_SVN_REVISION', getActualVersion('Revision')); -setConfigEntry('CURR_SVN_DATE' , getActualVersion('Date')); +setConfigEntry('CURRENT_REPOSITORY_REVISION', getRepositoryData('Revision')); +setConfigEntry('CURRENT_REPOSITORY_DATE' , getRepositoryData('Date')); // [EOF] ?> diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 23faa7a6a4..b42874ee8a 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -1493,11 +1493,11 @@ function getTitle () { } // "Getter" for curr_svn_revision -function getCurrSvnRevision () { +function getCurrentRepositoryRevision () { // Do we have cache? if (!isset($GLOBALS[__FUNCTION__])) { // Determine it - $GLOBALS[__FUNCTION__] = getConfig('CURR_SVN_REVISION'); + $GLOBALS[__FUNCTION__] = getConfig('CURRENT_REPOSITORY_REVISION'); } // END - if // Return cache diff --git a/templates/de/html/admin/admin_update_download.tpl b/templates/de/html/admin/admin_update_download.tpl index 1533c887c3..d9baa6f477 100644 --- a/templates/de/html/admin/admin_update_download.tpl +++ b/templates/de/html/admin/admin_update_download.tpl @@ -7,7 +7,7 @@
{--ADMIN_YOUR_VERSION_IS--}:
-
v{?FULL_VERSION?} R{?CURR_SVN_REVISION?}
+
v{?FULL_VERSION?} R{?CURRENT_REPOSITORY_REVISION?}
@@ -27,7 +27,7 @@
{--ADMIN_DOWNLOAD_SVN--}:
- {--ADMIN_DOWNLOAD_NOW--} + {--ADMIN_DOWNLOAD_NOW--}
diff --git a/templates/de/html/copyright.tpl b/templates/de/html/copyright.tpl index 6727b6747a..89c86e42d0 100644 --- a/templates/de/html/copyright.tpl +++ b/templates/de/html/copyright.tpl @@ -2,7 +2,7 @@