From 95e7ebcc079858e287ea182a03cd372df0d0934f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 31 Jul 2010 06:06:12 +0000 Subject: [PATCH] Introduced new function capitalizeUnderscoreString(), rewritten 'do' parameter: - Introduced new function capitalizeUnderscoreString(), this function does first convert all dashes (-) into underscores (_) and then capitalizes all strings parts. This function is self-cached to speedup things - All ext-network templates rewritten which has a 'do' parameter, this parameter identifies the form which should be processed by doNetworkProccessForm() --- inc/expression-functions.php | 4 +-- inc/filters.php | 2 +- inc/functions.php | 27 ++++++++++++++++++- inc/libs/network_functions.php | 26 +++++++++--------- templates/de/html/admin/admin_add_network.tpl | 2 +- .../admin_add_network_api_translation.tpl | 2 +- .../html/admin/admin_add_network_params.tpl | 2 +- .../de/html/admin/admin_add_network_type.tpl | 2 +- .../html/admin/admin_del_network_params.tpl | 2 +- .../de/html/admin/admin_del_network_types.tpl | 2 +- .../de/html/admin/admin_del_networks.tpl | 2 +- .../html/admin/admin_edit_network_params.tpl | 2 +- .../html/admin/admin_edit_network_types.tpl | 2 +- .../de/html/admin/admin_edit_networks.tpl | 2 +- .../html/admin/admin_list_network_params.tpl | 2 +- .../html/admin/admin_list_network_types.tpl | 2 +- .../de/html/admin/admin_list_networks.tpl | 2 +- 17 files changed, 55 insertions(+), 30 deletions(-) diff --git a/inc/expression-functions.php b/inc/expression-functions.php index 47da9de138..3d713acd44 100644 --- a/inc/expression-functions.php +++ b/inc/expression-functions.php @@ -65,7 +65,7 @@ function isExpressionFunctionAvaiable ($data) { // Add non-empty parts if (!empty($piece)) { // Add it - $functionName .= ucfirst(strtolower($piece)); + $functionName .= capitalizeUnderscoreString($piece); } // END - if } // END - foreach @@ -146,7 +146,7 @@ function doExpressionExt ($data) { // Is the extension installed? if (isExtensionInstalled($data['matches'][4][$data['key']])) { // Construct call-back function name - $functionName = 'getExtension' . ucfirst(strtolower($data['callback'])); + $functionName = 'getExtension' . capitalizeUnderscoreString($data['callback']); // Construct call of the function $replacer = "{DQUOTE} . call_user_func_array('" . $functionName . "', array('" . $data['matches'][4][$data['key']] . "', true)) . {DQUOTE}"; diff --git a/inc/filters.php b/inc/filters.php index 04ee9a451e..b58a126ced 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -502,7 +502,7 @@ function FILTER_COMPILE_EXPRESSION_CODE ($code) { } // END - if // Construct call-back function name for the command - $commandFunction = 'doExpression' . ucfirst(strtolower($cmd)); + $commandFunction = 'doExpression' . capitalizeUnderscoreString($cmd); // Is this function there? if (function_exists($commandFunction)) { diff --git a/inc/functions.php b/inc/functions.php index eef935d62e..00cfe3b84c 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1402,7 +1402,7 @@ function debug_get_printable_backtrace () { if (!isset($trace['file'])) $trace['file'] = __FUNCTION__; if (!isset($trace['line'])) $trace['line'] = __LINE__; if (!isset($trace['args'])) $trace['args'] = array(); - $backtrace .= '
  • ' . basename($trace['file']) . ':' . $trace['line'].", " . $trace['function'] . '(' . count($trace['args']) . ')
  • '; + $backtrace .= '
  • ' . basename($trace['file']) . ':' . $trace['line'] . ', ' . $trace['function'] . '(' . count($trace['args']) . ')
  • '; } // END - foreach // Close it @@ -2393,6 +2393,31 @@ function makeDatabaseUserId ($userid) { return $userid; } +// Capitalizes a string with underscores, e.g.: some_foo_string will become SomeFooString +// Note: This function is cached +function capitalizeUnderscoreString ($str) { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__][$str])) { + // Init target string + $capitalized = ''; + + // Explode it with the underscore, but rewrite dashes to underscore before + $strArray = explode('_', str_replace('-', '_', $str)); + + // "Walk" through all elements and make them lower-case but first upper-case + foreach ($strArray as $part) { + // Capitalize the string part + $capitalized .= ucfirst(strtolower($part)); + } // END - foreach + + // Store the converted string in cache array + $GLOBALS[__FUNCTION__][$str] = $capitalized; + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__][$str]; +} + //----------------------------------------------------------------------------- // Automatically re-created functions, all taken from user comments on www.php.net //----------------------------------------------------------------------------- diff --git a/inc/libs/network_functions.php b/inc/libs/network_functions.php index b48456411f..d8fbacec8c 100644 --- a/inc/libs/network_functions.php +++ b/inc/libs/network_functions.php @@ -81,7 +81,7 @@ function doAdminNetworkProcessForm () { } // Create function name - $functionName = sprintf("doAdminNetworkProcess%sForm", ucfirst(strtolower(getRequestParameter('do')))); + $functionName = sprintf("doAdminNetworkProcess%sForm", capitalizeUnderscoreString(getRequestParameter('do'))); // Is the function valid? if (!function_exists($functionName)) { @@ -623,7 +623,7 @@ function translateNetworkRequestType ($name) { //------------------------------------------------------------------------------ // Callback function to add new network -function doAdminNetworkProcessAddnetworkForm () { +function doAdminNetworkProcessAddNetworkForm () { // We can say here, the form is sent, so check if the network is already added if (isNetworkNameValid(postRequestParameter('network_short_name'))) { // Already there @@ -657,7 +657,7 @@ function doAdminNetworkProcessAddnetworkForm () { } // Displays selected networks for editing -function doAdminNetworkProcessHandlenetworkForm () { +function doAdminNetworkProcessHandleNetworkForm () { // Do we have selections? if (ifPostContainsSelections()) { // Something has been selected, so start displaying one by one @@ -706,7 +706,7 @@ function doAdminNetworkProcessHandlenetworkForm () { } // Handle network type form -function doAdminNetworkProcessHandlenetworktypeForm () { +function doAdminNetworkProcessHandleNetworkTypeForm () { // Do we have selections? if (ifPostContainsSelections()) { // Load network data @@ -758,7 +758,7 @@ function doAdminNetworkProcessHandlenetworktypeForm () { } // Handle network request parameter form -function doAdminNetworkProcessHandlerequestparamsForm () { +function doAdminNetworkProcessHandleRequestParamsForm () { // Do we have selections? if (ifPostContainsSelections()) { // Init cache array @@ -816,7 +816,7 @@ function doAdminNetworkProcessHandlerequestparamsForm () { } // Changes given networks -function doAdminNetworkProcessChangenetworkForm () { +function doAdminNetworkProcessChangeNetworkForm () { // Do we have selections? if (ifPostContainsSelections()) { // By default nothing is updated @@ -861,7 +861,7 @@ function doAdminNetworkProcessChangenetworkForm () { } // Removes given networks -function doAdminNetworkProcessRemovenetworkForm () { +function doAdminNetworkProcessRemoveNetworkForm () { // Do we have selections? if (ifPostContainsSelections()) { // By default nothing is removed @@ -888,7 +888,7 @@ function doAdminNetworkProcessRemovenetworkForm () { } // Add a network type handler if not yet found -function doAdminNetworkProcessAddnetworktypeForm () { +function doAdminNetworkProcessAddNetworkTypeForm () { // Is the network type handle already used with given network? if (isNetworkTypeHandleValid(postRequestParameter('network_type_handle'), getRequestParameter('network'))) { // Already added @@ -930,7 +930,7 @@ function doAdminNetworkProcessAddnetworktypeForm () { } // Changes given network type handlers -function doAdminNetworkProcessChangenetworktypeForm () { +function doAdminNetworkProcessChangeNetworkTypeForm () { // Do we have selections? if (ifPostContainsSelections()) { // By default nothing is updated @@ -981,7 +981,7 @@ function doAdminNetworkProcessChangenetworktypeForm () { } // Changes given network request parameters -function doAdminNetworkProcessChangenetworkparamForm () { +function doAdminNetworkProcessChangeNetworkParamForm () { // Do we have selections? if (ifPostContainsSelections()) { // By default nothing is updated @@ -1032,7 +1032,7 @@ function doAdminNetworkProcessChangenetworkparamForm () { } // Removes given network type handlers -function doAdminNetworkProcessRemovenetworktypeForm () { +function doAdminNetworkProcessRemoveNetworkTypeForm () { // Do we have selections? if (ifPostContainsSelections()) { // By default nothing is removed @@ -1059,7 +1059,7 @@ function doAdminNetworkProcessRemovenetworktypeForm () { } // Removes given network request parameters -function doAdminNetworkProcessRemovenetworkparamForm () { +function doAdminNetworkProcessRemoveNetworkParamForm () { // Do we have selections? if (ifPostContainsSelections()) { // By default nothing is removed @@ -1086,7 +1086,7 @@ function doAdminNetworkProcessRemovenetworkparamForm () { } // Adds a request parameter to given network and type -function doAdminNetworkProcessAddnetworkparamForm () { +function doAdminNetworkProcessAddNetworkParamForm () { // Is the request parameter already used with given network? if (isNetworkRequestParameterValid(postRequestParameter('request_param_key'), postRequestParameter('network_type_id'), getRequestParameter('network'))) { // Already added diff --git a/templates/de/html/admin/admin_add_network.tpl b/templates/de/html/admin/admin_add_network.tpl index 5a8b602501..c3b59abe18 100644 --- a/templates/de/html/admin/admin_add_network.tpl +++ b/templates/de/html/admin/admin_add_network.tpl @@ -1,5 +1,5 @@
    -
    +
    diff --git a/templates/de/html/admin/admin_add_network_api_translation.tpl b/templates/de/html/admin/admin_add_network_api_translation.tpl index 2a05d55052..790d5a48aa 100644 --- a/templates/de/html/admin/admin_add_network_api_translation.tpl +++ b/templates/de/html/admin/admin_add_network_api_translation.tpl @@ -1,5 +1,5 @@
    - +
    diff --git a/templates/de/html/admin/admin_add_network_params.tpl b/templates/de/html/admin/admin_add_network_params.tpl index 2f34c850c0..3e498d987a 100644 --- a/templates/de/html/admin/admin_add_network_params.tpl +++ b/templates/de/html/admin/admin_add_network_params.tpl @@ -1,5 +1,5 @@
    - +
    diff --git a/templates/de/html/admin/admin_add_network_type.tpl b/templates/de/html/admin/admin_add_network_type.tpl index 7c01cd3ccd..d3803a7818 100644 --- a/templates/de/html/admin/admin_add_network_type.tpl +++ b/templates/de/html/admin/admin_add_network_type.tpl @@ -1,5 +1,5 @@
    - +
    diff --git a/templates/de/html/admin/admin_del_network_params.tpl b/templates/de/html/admin/admin_del_network_params.tpl index deb6bdb571..daaf3cede4 100644 --- a/templates/de/html/admin/admin_del_network_params.tpl +++ b/templates/de/html/admin/admin_del_network_params.tpl @@ -1,5 +1,5 @@
    - +
    diff --git a/templates/de/html/admin/admin_del_network_types.tpl b/templates/de/html/admin/admin_del_network_types.tpl index 5464fb8507..a560470651 100644 --- a/templates/de/html/admin/admin_del_network_types.tpl +++ b/templates/de/html/admin/admin_del_network_types.tpl @@ -1,5 +1,5 @@
    - +
    diff --git a/templates/de/html/admin/admin_del_networks.tpl b/templates/de/html/admin/admin_del_networks.tpl index 777d10146a..9c295172e7 100644 --- a/templates/de/html/admin/admin_del_networks.tpl +++ b/templates/de/html/admin/admin_del_networks.tpl @@ -1,5 +1,5 @@
    - +
    diff --git a/templates/de/html/admin/admin_edit_network_params.tpl b/templates/de/html/admin/admin_edit_network_params.tpl index e143e8cf11..b9075d4755 100644 --- a/templates/de/html/admin/admin_edit_network_params.tpl +++ b/templates/de/html/admin/admin_edit_network_params.tpl @@ -1,5 +1,5 @@
    - +
    diff --git a/templates/de/html/admin/admin_edit_network_types.tpl b/templates/de/html/admin/admin_edit_network_types.tpl index 9be8be2c7c..8dc65f5bd6 100644 --- a/templates/de/html/admin/admin_edit_network_types.tpl +++ b/templates/de/html/admin/admin_edit_network_types.tpl @@ -1,5 +1,5 @@
    - +
    diff --git a/templates/de/html/admin/admin_edit_networks.tpl b/templates/de/html/admin/admin_edit_networks.tpl index 185c1c1089..ac2b81fc20 100644 --- a/templates/de/html/admin/admin_edit_networks.tpl +++ b/templates/de/html/admin/admin_edit_networks.tpl @@ -1,5 +1,5 @@
    - +
    diff --git a/templates/de/html/admin/admin_list_network_params.tpl b/templates/de/html/admin/admin_list_network_params.tpl index 5281cfbbd6..151cecc2cc 100644 --- a/templates/de/html/admin/admin_list_network_params.tpl +++ b/templates/de/html/admin/admin_list_network_params.tpl @@ -1,5 +1,5 @@
    - +
    diff --git a/templates/de/html/admin/admin_list_network_types.tpl b/templates/de/html/admin/admin_list_network_types.tpl index 0bd86adfb6..ad54ee93a9 100644 --- a/templates/de/html/admin/admin_list_network_types.tpl +++ b/templates/de/html/admin/admin_list_network_types.tpl @@ -1,5 +1,5 @@
    - +
    diff --git a/templates/de/html/admin/admin_list_networks.tpl b/templates/de/html/admin/admin_list_networks.tpl index d2ddda4167..bcc2ef100f 100644 --- a/templates/de/html/admin/admin_list_networks.tpl +++ b/templates/de/html/admin/admin_list_networks.tpl @@ -1,5 +1,5 @@
    - + -- 2.39.5