Introduced new function capitalizeUnderscoreString(), rewritten 'do' parameter:
authorRoland Häder <roland@mxchange.org>
Sat, 31 Jul 2010 06:06:12 +0000 (06:06 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 31 Jul 2010 06:06:12 +0000 (06:06 +0000)
- 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()

17 files changed:
inc/expression-functions.php
inc/filters.php
inc/functions.php
inc/libs/network_functions.php
templates/de/html/admin/admin_add_network.tpl
templates/de/html/admin/admin_add_network_api_translation.tpl
templates/de/html/admin/admin_add_network_params.tpl
templates/de/html/admin/admin_add_network_type.tpl
templates/de/html/admin/admin_del_network_params.tpl
templates/de/html/admin/admin_del_network_types.tpl
templates/de/html/admin/admin_del_networks.tpl
templates/de/html/admin/admin_edit_network_params.tpl
templates/de/html/admin/admin_edit_network_types.tpl
templates/de/html/admin/admin_edit_networks.tpl
templates/de/html/admin/admin_list_network_params.tpl
templates/de/html/admin/admin_list_network_types.tpl
templates/de/html/admin/admin_list_networks.tpl

index 47da9de13818aff53d7dc1bfbf76f85613678ac5..3d713acd449b006fc836781d176d82dd5f4e07da 100644 (file)
@@ -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}";
index 04ee9a451ef924347e34d2dd7f72c96471d2c432..b58a126ced7c8d5560c60d8e4721242611db15fa 100644 (file)
@@ -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)) {
index eef935d62ec923e44ad7b5cd93e7afa83fef44e2..00cfe3b84c78f40ea3a1714f1f5209f68bbf7dae 100644 (file)
@@ -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 .= '<li class="debug_list"><span class="backtrace_file">' . basename($trace['file']) . '</span>:' . $trace['line'].", <span class=\"backtrace_function\">" . $trace['function'] . '(' . count($trace['args']) . ')</span></li>';
+               $backtrace .= '<li class="debug_list"><span class="backtrace_file">' . basename($trace['file']) . '</span>:' . $trace['line'] . ', <span class="backtrace_function">' . $trace['function'] . '(' . count($trace['args']) . ')</span></li>';
        } // 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
 //-----------------------------------------------------------------------------
index b48456411f8c9a52864a54a5ddec0b6423d490af..d8fbacec8ce99412d202b9083ce45e655847bd12 100644 (file)
@@ -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
index 5a8b602501af76855dfad77a9bb9a5b0d65a8c64..c3b59abe180d061bfda7fcc0f3d90efa5929f9b8 100644 (file)
@@ -1,5 +1,5 @@
 <div align="center">
-<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_networks&amp;do=addnetwork%}" method="post">
+<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_networks&amp;do=add_network%}" method="post">
 <table border="0" cellspacing="0" cellpadding="0" class="admin_table dashed">
        <tr>
                <td class="admin_title bottom" colspan="2" align="center">
index 2a05d550522131b8adb6b4f5b29e6c150df91428..790d5a48aadeeb538acb493a8a6a4caaf09b1491 100644 (file)
@@ -1,5 +1,5 @@
 <div align="center">
-<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_network_params&amp;do=addnetworkparam&amp;network={%pipe,getRequestParameter=network%}&amp;network_type={%pipe,getRequestParameter=network_type%}%}" method="post">
+<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_network_api_translation&amp;do=add_network_api_translation&amp;network={%pipe,getRequestParameter=network%}&amp;network_type={%pipe,getRequestParameter=network_type%}%}" method="post">
 <table border="0" cellspacing="0" cellpadding="0" class="admin_table dashed">
        <tr>
                <td class="admin_title bottom" colspan="2" align="center">
index 2f34c850c0343ab8d54100ab9bae98cff8f317a2..3e498d987a5b3f4a26f1f37b1038fcf0234bf695 100644 (file)
@@ -1,5 +1,5 @@
 <div align="center">
-<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_network_params&amp;do=addnetworkparam&amp;network={%pipe,getRequestParameter=network%}%}" method="post">
+<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_network_params&amp;do=add_network_param&amp;network={%pipe,getRequestParameter=network%}%}" method="post">
 <table border="0" cellspacing="0" cellpadding="0" class="admin_table dashed">
        <tr>
                <td class="admin_title bottom" colspan="2" align="center">
index 7c01cd3ccdf2199f32eab34ca43f9ba3b4f42157..d3803a78185ff88099a3f6c1eca949b1102e7026 100644 (file)
@@ -1,5 +1,5 @@
 <div align="center">
-<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_network_types&amp;do=addnetworktype&amp;network={%pipe,getRequestParameter=network%}%}" method="post">
+<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_network_types&amp;do=add_network_type&amp;network={%pipe,getRequestParameter=network%}%}" method="post">
 <table border="0" cellspacing="0" cellpadding="0" class="admin_table dashed">
        <tr>
                <td class="admin_title bottom" colspan="2" align="center">
index deb6bdb571bc208b2215716c895a4036d75d4d04..daaf3cede4f51f445625684ac34d6700c85954fa 100644 (file)
@@ -1,5 +1,5 @@
 <div align="center">
-<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_network_params&amp;network={%pipe,getRequestParameter=network%}&amp;do=removenetworkparam%}" method="post">
+<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_network_params&amp;network={%pipe,getRequestParameter=network%}&amp;do=remove_network_param%}" method="post">
 <table border="0" cellspacing="0" cellpadding="0" class="admin_table dashed">
        <tr>
                <td align="center" class="admin_title bottom" height="25" colspan="2">
index 5464fb8507ac8c56719c1e7c7dc8b6384d05a47f..a56047065110a37c393d7ae142ebdeeb9fa968cc 100644 (file)
@@ -1,5 +1,5 @@
 <div align="center">
-<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_network_types&amp;network={%pipe,getRequestParameter=network%}&amp;do=removenetworktype%}" method="post">
+<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_network_types&amp;network={%pipe,getRequestParameter=network%}&amp;do=remove_network_type%}" method="post">
 <table border="0" cellspacing="0" cellpadding="0" class="admin_table dashed">
        <tr>
                <td align="center" class="admin_title bottom" height="25" colspan="2">
index 777d10146adcb66f0c1be4494a919464cb2bc647..9c295172e7f4671d297906f0cab1cfcc33a6e45a 100644 (file)
@@ -1,5 +1,5 @@
 <div align="center">
-<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_networks&amp;do=removenetwork%}" method="post">
+<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_networks&amp;do=remove_network%}" method="post">
 <table border="0" cellspacing="0" cellpadding="0" class="admin_table dashed">
        <tr>
                <td align="center" class="admin_title bottom" height="25" colspan="4">
index e143e8cf11a6ba25dfe76b98db48e997fc49149a..b9075d47550b12a37e28df6b4f86bae8508312ab 100644 (file)
@@ -1,5 +1,5 @@
 <div align="center">
-<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_network_params&amp;network={%pipe,getRequestParameter=network%}&amp;do=changenetworkparam%}" method="post">
+<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_network_params&amp;network={%pipe,getRequestParameter=network%}&amp;do=change_network_param%}" method="post">
 <table border="0" cellspacing="0" cellpadding="0" class="admin_table dashed">
        <tr>
                <td align="center" class="admin_title bottom" height="25" colspan="2">
index 9be8be2c7cd1cfe229df01c7041356d6b062b6af..8dc65f5bd60eda371b2890705b44d794b34afd15 100644 (file)
@@ -1,5 +1,5 @@
 <div align="center">
-<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_network_types&amp;network={%pipe,getRequestParameter=network%}&amp;do=changenetworktype%}" method="post">
+<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_network_types&amp;network={%pipe,getRequestParameter=network%}&amp;do=change_network_type%}" method="post">
 <table border="0" cellspacing="0" cellpadding="0" class="admin_table dashed">
        <tr>
                <td align="center" class="admin_title bottom" height="25" colspan="2">
index 185c1c10899aa3d223277091886a8e1ff6e91c0a..ac2b81fc202be9d9e844357346e032c6e9b44580 100644 (file)
@@ -1,5 +1,5 @@
 <div align="center">
-<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_networks&amp;do=changenetwork%}" method="post">
+<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_networks&amp;do=change_network%}" method="post">
 <table border="0" cellspacing="0" cellpadding="0" class="admin_table dashed">
        <tr>
                <td align="center" class="admin_title bottom" height="25" colspan="4">
index 5281cfbbd6169294b57b130cd529691490fddc5f..151cecc2ccd97de918b5a5c96d4994b768abc0b4 100644 (file)
@@ -1,5 +1,5 @@
 <div align="center">
-<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_network_params&amp;network={%pipe,getRequestParameter=network%}&amp;do=handlerequestparams%}" method="post">
+<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_network_params&amp;network={%pipe,getRequestParameter=network%}&amp;do=handle_request_params%}" method="post">
 <table border="0" cellspacing="0" cellpadding="0" class="admin_table dashed">
        <tr>
                <td colspan="5" align="center" class="admin_title bottom">
index 0bd86adfb6242e259029922bb872fd9253c32152..ad54ee93a945897a91852e9b43b60646267631b9 100644 (file)
@@ -1,5 +1,5 @@
 <div align="center">
-<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_network_types&amp;network={%pipe,getRequestParameter=network%}&amp;do=handlenetworktype%}" method="post">
+<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_network_types&amp;network={%pipe,getRequestParameter=network%}&amp;do=handle_network_type%}" method="post">
 <table border="0" cellspacing="0" cellpadding="0" class="admin_table dashed">
        <tr>
                <td colspan="5" align="center" class="admin_title bottom">
index d2ddda4167951d35ffbb688a4aae51098996fe35..bcc2ef100fb1ecf155ceccc7b00bc03988649a73 100644 (file)
@@ -1,5 +1,5 @@
 <div align="center">
-<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_networks&amp;do=handlenetwork%}" method="post">
+<form accept-charset="utf-8" action="{%url=modules.php?module=admin&amp;what=list_networks&amp;do=handle_network%}" method="post">
 <table border="0" cellspacing="0" cellpadding="0" class="admin_table dashed">
        <tr>
                <td height="25" colspan="3" class="header_column bottom right seperator">&nbsp;</td>