}
// 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)) {
$content = '';
// Query for all networks
- $result = SQL_QUERY("SELECT
+ $result = SQL_QUERY('SELECT
`network_id`, `network_short_name`, `network_title`
FROM
`{?_MYSQL_PREFIX?}_network_data`
ORDER BY
- `network_short_name` ASC", __FUNCTION__, __LINE__);
+ `network_short_name` ASC', __FUNCTION__, __LINE__);
// Do we have entries?
- if (SQL_NUMROWS($result) > 0) {
+ if (!SQL_HASZERONUMS($result)) {
// List all entries
$rows = array();
while ($row = SQL_FETCHARRAY($result)) {
), __FUNCTION__, __LINE__);
// Do we have entries?
- if (SQL_NUMROWS($result) > 0) {
+ if (!SQL_HASZERONUMS($result)) {
// List all entries
$rows = array();
while ($row = SQL_FETCHARRAY($result)) {
$content = '';
// Query all types of this network
- $result = SQL_QUERY("SELECT
+ $result = SQL_QUERY('SELECT
t.`network_type_id`, t.`network_type_handle`, d.`network_title`
FROM
`{?_MYSQL_PREFIX?}_network_types` AS t
t.`network_id`=d.`network_id`
ORDER BY
d.`network_short_name` ASC,
- t.`network_type_handle` ASC", __FUNCTION__, __LINE__);
+ t.`network_type_handle` ASC', __FUNCTION__, __LINE__);
// Do we have entries?
- if (SQL_NUMROWS($result) > 0) {
+ if (!SQL_HASZERONUMS($result)) {
// List all entries
$rows = array();
while ($row = SQL_FETCHARRAY($result)) {
sprintf(
"WHERE `network_id`=%s",
bigintval(getRequestParameter('network'))
- )
+ ),
+ '',
+ 'translateNetworkTypeHandler'
);
} // END - if
}
// Generator (somewhat getter) for (return) array translation
-function generateNetworkArrayTranslationOptions ($default) {
+function generateNetworkTranslationOptions ($default = '') {
// Is it cached?
- if (!isset($GLOBALS['network_array_translation'][$default])) {
+ if (!isset($GLOBALS['network_translation'][$default])) {
// Generate and cache it
- $GLOBALS['network_array_translation'][$default] = generateOptionList(
+ $GLOBALS['network_translation'][$default] = generateOptionList(
'network_translations',
- 'network_translation',
- 'network_translation',
+ 'network_translation_id',
+ 'network_translation_name',
$default,
'',
- sprintf("WHERE `network_type_id`=%s",
- bigintval(getRequestParameter('network_type'))
- ),
- $GLOBALS['network_array_translation_disabled'],
- 'ADMIN_NETWORK_ARRAY_TRANSLATION_'
+ '',
+ $GLOBALS['network_translation_disabled'],
+ 'translateNetworkTranslationName'
);
} // END - if
// Return content
- return $GLOBALS['network_array_translation'][$default];
+ return $GLOBALS['network_translation'][$default];
+}
+
+// Generates an option list of request types
+function generateNetworkRequestTypeOptions ($default = '') {
+ // Do we have cache?
+ if (!isset($GLOBALS['network_request_type'][$default])) {
+ // Generate the list
+ $GLOBALS['network_request_type'][$default] = generateOptionList(
+ '/ARRAY/',
+ array(
+ 'GET',
+ 'POST'
+ ),
+ array(
+ '{--ADMIN_NETWORK_REQUEST_TYPE_GET--}',
+ '{--ADMIN_NETWORK_REQUEST_TYPE_POST--}'
+ ),
+ $default
+ );
+ } // END - if
+
+ // Return cache
+ return $GLOBALS['network_request_type'][$default];
+}
+
+// Translates 'translate_name' for e.g. templates
+function translateNetworkTranslationName ($name) {
+ // Get the message id
+ return getMessage('ADMIN_NETWORK_TRANSLATE_' . strtoupper($name) . '_NAME');
+}
+
+// Translates the network type handler (e.g. banner, paidmail) for templates
+function translateNetworkTypeHandler ($type) {
+ // Get the message id
+ return getMessage('ADMIN_NETWORK_TYPES_' . strtoupper($type) . '');
+}
+
+// Translates request type
+function translateNetworkRequestType ($name) {
+ // Get the message id
+ return getMessage('ADMIN_NETWORK_REQUEST_TYPE_' . strtoupper($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
unsetPostRequestParameter('ok');
// Add the whole request to database
- SQL_QUERY("INSERT INTO
+ SQL_QUERY('INSERT INTO
`{?_MYSQL_PREFIX?}_network_data`
(
- `" . implode('`,`', array_keys(postRequestArray())) . "`
+ `' . implode('`,`', array_keys(postRequestArray())) . "`
) VALUES (
'" . implode("','", array_values(postRequestArray())) . "'
)", __FUNCTION__, __LINE__);
}
// Displays selected networks for editing
-function doAdminNetworkProcessHandlenetworkForm () {
+function doAdminNetworkProcessHandleNetworkForm () {
// Do we have selections?
- if (countPostSelection() > 0) {
+ if (ifPostContainsSelections()) {
// Something has been selected, so start displaying one by one
- $SW = 2; $OUT = '';
+ $OUT = '';
foreach (postRequestParameter('sel') as $id => $sel) {
// Is this selected?
if ($sel == 1) {
// Do we have found the network?
if (count($networkData) > 0) {
- // Add color
- $networkData['sw'] = $SW;
-
if (isFormSent('edit')) {
- // Make selection box for network_request_type
- $networkData['network_request_type'] = generateOptionList(
- '/ARRAY/',
- array(
- 'GET',
- 'POST'
- ),
- array(
- getMessage('ADMIN_NETWORK_REQUEST_TYPE_GET'),
- getMessage('ADMIN_NETWORK_REQUEST_TYPE_POST')
- ),
- $networkData['network_request_type']
- );
-
// Add row template for editing
$OUT .= loadTemplate('admin_edit_networks_row', true, $networkData);
} elseif (isFormSent('del')) {
- // Translate the request type
- $networkData['network_request_type'] = '{--ADMIN_NETWORK_REQUEST_TYPE_' . $networkData['network_request_type'] . '--}';
-
// Add row template for deleting
$OUT .= loadTemplate('admin_del_networks_row', true, $networkData);
} else {
// Problem!
debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
}
-
- // Switch colors
- $SW = 3 - $SW;
} // END - if
} // END - if
} // END - foreach
}
// Handle network type form
-function doAdminNetworkProcessHandlenetworktypeForm () {
+function doAdminNetworkProcessHandleNetworkTypeForm () {
// Do we have selections?
- if (countPostSelection() > 0) {
+ if (ifPostContainsSelections()) {
// Load network data
$networkData = getNetworkDataById(getRequestParameter('network'));
// Something has been selected, so start displaying one by one
- $SW = 2; $OUT = '';
+ $OUT = '';
foreach (postRequestParameter('sel') as $id => $sel) {
// Is this selected?
if ($sel == 1) {
// Do we have found the network?
if (count($networkTypeData) > 0) {
- // Add color
- $networkTypeData['sw'] = $SW;
-
if (isFormSent('edit')) {
// Add row template for deleting
$OUT .= loadTemplate('admin_edit_network_types_row', true, $networkTypeData);
} elseif (isFormSent('del')) {
- // Fix empty banner URL
- if (trim($networkTypeData['network_type_banner_url']) == '') $networkTypeData['network_type_banner_url'] = '---';
-
// Add row template for deleting
$OUT .= loadTemplate('admin_del_network_types_row', true, $networkTypeData);
} else {
// Problem!
debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
}
-
- // Switch colors
- $SW = 3 - $SW;
} // END - if
} // END - if
} // END - foreach
// If we have no rows, we don't need to display the edit form
if (!empty($OUT)) {
- // Prepare content for template
- $content = array(
- 'rows' => $OUT,
- 'network_data' => getNetworkDataById(getRequestParameter('network'))
- );
-
// Output main template
if (isFormSent('edit')) {
- loadTemplate('admin_edit_network_types', false, $content);
+ loadTemplate('admin_edit_network_types', false, $OUT);
} elseif (isFormSent('del')) {
- loadTemplate('admin_del_network_types', false, $content);
+ loadTemplate('admin_del_network_types', false, $OUT);
} else {
// Problem!
debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
}
// Handle network request parameter form
-function doAdminNetworkProcessHandlerequestparamsForm () {
+function doAdminNetworkProcessHandleRequestParamsForm () {
// Do we have selections?
- if (countPostSelection() > 0) {
+ if (ifPostContainsSelections()) {
// Init cache array
$GLOBALS['network_params_disabled'] = array();
$networkData = getNetworkDataById(getRequestParameter('network'));
// Something has been selected, so start displaying one by one
- $SW = 2; $OUT = '';
+ $OUT = '';
foreach (postRequestParameter('sel') as $id => $sel) {
// Is this selected?
if ($sel == 1) {
// Do we have found the network?
if (count($networkRequestData) > 0) {
- // Add color
- $networkRequestData['sw'] = $SW;
-
if (isFormSent('edit')) {
- // Add options list for network type
- $networkRequestData['type_options'] = generateNetworkTypeOptions($networkRequestData['network_type_id']);
-
- // Add options list for request key
- $networkRequestData['key_options'] = generateNetworkRequestKeyOptions($networkRequestData['request_param_key']);
-
// Add row template for deleting
$OUT .= loadTemplate('admin_edit_network_params_row', true, $networkRequestData);
} elseif (isFormSent('del')) {
- // Fix empty banner URL
- if (trim($networkRequestData['request_param_default']) == '') $networkRequestData['request_param_default'] = '---';
-
// Get type data
$networkRequestData['network_type_data'] = getNetworkTypeDataById($networkRequestData['network_type_id']);
// Problem!
debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
}
-
- // Switch colors
- $SW = 3 - $SW;
} // END - if
} // END - if
} // END - foreach
// If we have no rows, we don't need to display the edit form
if (!empty($OUT)) {
- // Prepare content for template
- $content = array(
- 'rows' => $OUT,
- 'network_data' => getNetworkDataById(getRequestParameter('network'))
- );
-
// Output main template
if (isFormSent('edit')) {
- loadTemplate('admin_edit_network_params', false, $content);
+ loadTemplate('admin_edit_network_params', false, $OUT);
} elseif (isFormSent('del')) {
- loadTemplate('admin_del_network_params', false, $content);
+ loadTemplate('admin_del_network_params', false, $OUT);
} else {
// Problem!
debug_report_bug(__FUNCTION__, __LINE__, 'Cannot detect edit/del.');
}
// Changes given networks
-function doAdminNetworkProcessChangenetworkForm () {
+function doAdminNetworkProcessChangeNetworkForm () {
// Do we have selections?
- if (countPostSelection() > 0) {
+ if (ifPostContainsSelections()) {
// By default nothing is updated
$updated = 0;
}
// Removes given networks
-function doAdminNetworkProcessRemovenetworkForm () {
+function doAdminNetworkProcessRemoveNetworkForm () {
// Do we have selections?
- if (countPostSelection() > 0) {
+ if (ifPostContainsSelections()) {
// By default nothing is removed
$removed = 0;
}
// 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
}
// Changes given network type handlers
-function doAdminNetworkProcessChangenetworktypeForm () {
+function doAdminNetworkProcessChangeNetworkTypeForm () {
// Do we have selections?
- if (countPostSelection() > 0) {
+ if (ifPostContainsSelections()) {
// By default nothing is updated
$updated = 0;
}
// Changes given network request parameters
-function doAdminNetworkProcessChangenetworkparamForm () {
+function doAdminNetworkProcessChangeNetworkParamForm () {
// Do we have selections?
- if (countPostSelection() > 0) {
+ if (ifPostContainsSelections()) {
// By default nothing is updated
$updated = 0;
}
// Removes given network type handlers
-function doAdminNetworkProcessRemovenetworktypeForm () {
+function doAdminNetworkProcessRemoveNetworkTypeForm () {
// Do we have selections?
- if (countPostSelection() > 0) {
+ if (ifPostContainsSelections()) {
// By default nothing is removed
$removed = 0;
}
// Removes given network request parameters
-function doAdminNetworkProcessRemovenetworkparamForm () {
+function doAdminNetworkProcessRemoveNetworkParamForm () {
// Do we have selections?
- if (countPostSelection() > 0) {
+ if (ifPostContainsSelections()) {
// By default nothing is removed
$removed = 0;
}
// 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
} // END - if
// Add the whole request to database
- SQL_QUERY("INSERT INTO
+ SQL_QUERY('INSERT INTO
`{?_MYSQL_PREFIX?}_network_request_params`
(
- `" . implode('`,`', array_keys(postRequestArray())) . "`
+ `' . implode('`,`', array_keys(postRequestArray())) . "`
) VALUES (
'" . implode("','", array_values(postRequestArray())) . "'
)", __FUNCTION__, __LINE__);
// Return it
return $code;
}
-
// [EOF]
?>