From 98b92ea5ba992a63304091fa1b57f477befffc22 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 29 Jul 2010 23:20:57 +0000 Subject: [PATCH] Generic function accepts eights (!) but optional parameter $callback, ext-network continued: - The generic function generateOptionList() does now accept an optional eights parameter $callback. This is already used in ext-network to 'translate' values from column translation_name and can be any valid call-back function passed to call_user_func_array(). - Extension ext-network does now have very basic API array index translations - TODOs.txt updated --- DOCS/TODOs.txt | 9 +++++---- inc/extensions/ext-network.php | 10 ++++++++++ inc/language/network_de.php | 11 ++++++++++ inc/libs/network_functions.php | 9 +++++++-- .../what-list_network_api_translation.php | 1 - inc/mysql-manager.php | 20 ++++++++++++++++++- .../de/html/admin/admin_add_network_type.tpl | 2 +- 7 files changed, 53 insertions(+), 9 deletions(-) diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 0a0fe07f24..87b0400e2e 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -172,10 +172,10 @@ ./inc/modules/order.php:76: // @TODO Unused: 2,4 ./inc/monthly/monthly_bonus.php:69: // @TODO Rewrite this to a filter ./inc/mysql-manager.php:1173: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1420: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() -./inc/mysql-manager.php:1518: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1885: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1929:// @TODO Fix inconsistency between last_module and getWhat() +./inc/mysql-manager.php:1428: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() +./inc/mysql-manager.php:1536: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1903: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1947:// @TODO Fix inconsistency between last_module and getWhat() ./inc/mysql-manager.php:370: // @TODO Try to rewrite this to one or more functions ./inc/mysql-manager.php:46:// @TODO Can we cache this? ./inc/reset/reset_beg.php:51:// @TODO This should be converted in a daily beg rallye @@ -228,6 +228,7 @@ ### ### DEPRECATION FOLLOWS: ### ### ./inc/modules/admin/admin-inc.php:439:// @DEPRECATED ./inc/modules/admin/what-list_network_array_translation.php:2:// @DEPRECATED +./inc/modules/admin/what-list_network_translations.php:2:// @DEPRECATED ./templates/de/html/admin/admin_add_banner.tpl:1: ./templates/de/html/admin/admin_add_network_array_translation.tpl:1: ./templates/de/html/admin/admin_admin_add.tpl:1: diff --git a/inc/extensions/ext-network.php b/inc/extensions/ext-network.php index 76cade97fa..34929498f9 100644 --- a/inc/extensions/ext-network.php +++ b/inc/extensions/ext-network.php @@ -213,6 +213,16 @@ PRIMARY KEY (`network_reload_id`) ) TYPE={?_TABLE_TYPE?} COMMENT='Reload locks'"); // Insert API response array translations, these will be used for calling the right filter function + addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_network_translations` (`network_translation_name`) VALUES ('id')"); + addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_network_translations` (`network_translation_name`) VALUES ('name')"); + addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_network_translations` (`network_translation_name`) VALUES ('alternate_text')"); + addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_network_translations` (`network_translation_name`) VALUES ('reload')"); + addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_network_translations` (`network_translation_name`) VALUES ('remain')"); + addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_network_translations` (`network_translation_name`) VALUES ('reward')"); + addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_network_translations` (`network_translation_name`) VALUES ('banner_id')"); + addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_network_translations` (`network_translation_name`) VALUES ('size')"); + addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_network_translations` (`network_translation_name`) VALUES ('text')"); + addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_network_translations` (`network_translation_name`) VALUES ('minimum_stay')"); // Insert error code types // - Affiliate id or interface password wrong diff --git a/inc/language/network_de.php b/inc/language/network_de.php index ed5faca215..28ea78c5a1 100644 --- a/inc/language/network_de.php +++ b/inc/language/network_de.php @@ -206,6 +206,17 @@ addMessages(array( 'ADMIN_NETWORK_REQUESTS_DEPLETED_ERROR_CODE' => "API-Abfragen erschöpft", 'ADMIN_NETWORK_REQUEST_PARAMETER_INCOMPLETE_ERROR_CODE' => "API-Abfrageparameter nicht komplett", 'ADMIN_NETWORK_SITE_ID_NOT_ALLOWED_TYPE_ERROR_CODE' => "Seiten-Id nicht freigegeben", + // Text-represations of column translate_name + 'ADMIN_NETWORK_TRANSLATE_ALTERNATE_TEXT_NAME' => "Alternativer Bildtext", + 'ADMIN_NETWORK_TRANSLATE_BANNER_ID_NAME' => "Banner-Id", + 'ADMIN_NETWORK_TRANSLATE_ID_NAME' => "Kampagnen-Id", + 'ADMIN_NETWORK_TRANSLATE_MINIMUM_STAY_NAME' => "Mindestauffenthalt", + 'ADMIN_NETWORK_TRANSLATE_NAME_NAME' => "Kampagnen-Name", + 'ADMIN_NETWORK_TRANSLATE_RELOAD_NAME' => "Reloadzeit", + 'ADMIN_NETWORK_TRANSLATE_REMAIN_NAME' => "Mindestanzahl restlicher Klicks", + 'ADMIN_NETWORK_TRANSLATE_REWARD_NAME' => "Mindestvergütung", + 'ADMIN_NETWORK_TRANSLATE_SIZE_NAME' => "Bannerformat", + 'ADMIN_NETWORK_TRANSLATE_TEXT_NAME' => "Werbetext", )); // [EOF] diff --git a/inc/libs/network_functions.php b/inc/libs/network_functions.php index de034d1382..228fb83982 100644 --- a/inc/libs/network_functions.php +++ b/inc/libs/network_functions.php @@ -567,7 +567,7 @@ function generateNetworkTranslationOptions ($default = '') { '', '', $GLOBALS['network_translation_disabled'], - 'ADMIN_NETWORK_TRANSLATION_' + 'translateNetworkTranslationName' ); } // END - if @@ -575,6 +575,12 @@ function generateNetworkTranslationOptions ($default = '') { return $GLOBALS['network_translation'][$default]; } +// Translates 'translate_name' for e.g. templates +function translateNetworkTranslationName ($name) { + // Get the message id + return getMessage('ADMIN_NETWORK_TRANSLATE_' . strtoupper($name) . '_NAME'); +} + //------------------------------------------------------------------------------ // Call-back functions //------------------------------------------------------------------------------ @@ -1126,7 +1132,6 @@ function doExpressionNetwork ($data) { // Return it return $code; } - // [EOF] ?> diff --git a/inc/modules/admin/what-list_network_api_translation.php b/inc/modules/admin/what-list_network_api_translation.php index 4a338dfcaf..3f3fa689a4 100644 --- a/inc/modules/admin/what-list_network_api_translation.php +++ b/inc/modules/admin/what-list_network_api_translation.php @@ -124,7 +124,6 @@ ORDER BY // Add options list for network type $networkData['translation_index'] = (SQL_NUMROWS($result) + 1); - $networkData['type_options'] = generateNetworkTypeOptions(getRequestParameter('network_type_id')); // Free result SQL_FREERESULT($result); diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 33bbd3fd13..665dc6946b 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -1379,7 +1379,7 @@ function getAdminDefaultAcl ($adminId) { } // Generates an option list from various parameters -function generateOptionList ($table, $id, $name, $default='', $special='', $where='', $disabled=array()) { +function generateOptionList ($table, $id, $name, $default = '', $special = '', $where = '', $disabled = array(), $callback = '') { $ret = ''; if ($table == '/ARRAY/') { // Selection from array @@ -1394,6 +1394,14 @@ function generateOptionList ($table, $id, $name, $default='', $special='', $wher // Disabled! $ret .= ' disabled="disabled"'; } + + // Is the call-back function set? + if (!empty($callback)) { + // Call it + $name[$idx] = call_user_func_array($callback, array($name[$idx])); + } // END - if + + // Finish option tag $ret .= '>' . $name[$idx] . ''; } // END - foreach } else { @@ -1428,7 +1436,17 @@ function generateOptionList ($table, $id, $name, $default='', $special='', $wher // Disabled! $ret .= ' disabled="disabled"'; } + + // Add it, if set if (!empty($add)) $add = ' ('.$add.')'; + + // Is the call-back function set? + if (!empty($callback)) { + // Call it + $title = call_user_func_array($callback, array($title)); + } // END - if + + // Finish option list $ret .= '>' . $title . $add . ''; } // END - while } else { diff --git a/templates/de/html/admin/admin_add_network_type.tpl b/templates/de/html/admin/admin_add_network_type.tpl index 7464c028bd..7c01cd3ccd 100644 --- a/templates/de/html/admin/admin_add_network_type.tpl +++ b/templates/de/html/admin/admin_add_network_type.tpl @@ -13,7 +13,7 @@ {--ADMIN_NETWORK_TYPES_HANDLE--}: -- 2.39.5