From a41aaa25ffabde1e6ec7f3951288569f4bd827b2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= <roland@mxchange.org> Date: Mon, 11 Jul 2011 13:06:40 +0000 Subject: [PATCH] Some fixes,re-orders and ext-surfbar actions are now XML-enabled --- inc/language/surfbar_de.php | 3 +- inc/libs/surfbar_functions.php | 2 +- inc/modules/admin/admin-inc.php | 6 +- .../admin/what-list_surfbar_actions.php | 73 ++++++++------ .../admin/admin_list_surfbar_actions_row.tpl | 2 +- .../xml/admin/admin_list_surfbar_actions.xml | 96 +++++++++++++++++++ .../xml/admin/admin_list_surfbar_urls.xml | 8 +- templates/xml/admin_list_data_template.xml | 8 +- 8 files changed, 156 insertions(+), 42 deletions(-) create mode 100644 templates/xml/admin/admin_list_surfbar_actions.xml diff --git a/inc/language/surfbar_de.php b/inc/language/surfbar_de.php index 2747189880..8ee9be6d9e 100644 --- a/inc/language/surfbar_de.php +++ b/inc/language/surfbar_de.php @@ -81,7 +81,8 @@ addMessages(array( 'ADMIN_LIST_SURFBAR_ACTIONS_TITLE' => "Mitglieder-Aktionen der Surfbar auflisten", // General admin text - 'ADMIN_SURFBAR_NO_URLS_FOUND' => "Es konnten keine URLs in der Surfbar gefunden werden.", + 'ADMIN_SURFBAR_URLS_404' => "Es konnten keine URLs in der Surfbar gefunden werden.", + 'ADMIN_SURFBAR_ACTIONS_404' => "Es konnten keine Mitgliederaktionen in der Surfbar gefunden werden.", 'ADMIN_SURFBAR_REWARD' => "Vergütung", 'ADMIN_SURFBAR_COSTS' => "Kosten", 'ADMIN_SURFBAR_PAYMENT' => "Payment", diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php index b3aea55d43..739465d07d 100644 --- a/inc/libs/surfbar_functions.php +++ b/inc/libs/surfbar_functions.php @@ -733,7 +733,7 @@ function translateSurfbarLimit ($limit) { // Translate the URL status function translateSurfbarUrlStatus ($status) { // NULL must be handled carfefully - if (is_null($status)) { + if ((is_null($status)) || (trim($status) == '')) { // Is NULL, so return other language string return '{--SURFBAR_URL_STATUS_NONE--}'; } else { diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index db9353b4ef..5a23e398d0 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -1116,7 +1116,7 @@ function adminUndeleteEntriesConfirm ($IDs, $table, $columns=array(), $filterFun } // List all given rows (callback function from XML) -function adminListEntries ($tableTemplate, $rowTemplate, $tableName, $columns, $whereColumns, $orderByColumns, $callbackColumns, $extraParameters, $noEntryMessageId) { +function adminListEntries ($tableTemplate, $rowTemplate, $noEntryMessageId, $tableName, $columns, $whereColumns, $orderByColumns, $callbackColumns, $extraParameters = array()) { // Verify that tableName and columns are not empty if (count($tableName) != 1) { // No tableName specified @@ -1184,11 +1184,11 @@ function adminListEntries ($tableTemplate, $rowTemplate, $tableName, $columns, $ } // END - if // Now handle all over to the inner function which will execute the listing - doAdminListEntries($SQL, $tableTemplate, $rowTemplate, $callbackColumns, $extraParameters, $noEntryMessageId); + doAdminListEntries($SQL, $tableTemplate, $noEntryMessageId, $rowTemplate, $callbackColumns, $extraParameters = array()); } // Do the listing of entries -function doAdminListEntries($SQL, $tableTemplate, $rowTemplate, $callbackColumns, $extraParameters, $noEntryMessageId) { +function doAdminListEntries($SQL, $tableTemplate, $noEntryMessageId, $rowTemplate, $callbackColumns, $extraParameters = array()) { // Run the SQL query $result = SQL_QUERY($SQL, __FUNCTION__, __LINE__); diff --git a/inc/modules/admin/what-list_surfbar_actions.php b/inc/modules/admin/what-list_surfbar_actions.php index ff95f1c494..c85ae51be8 100644 --- a/inc/modules/admin/what-list_surfbar_actions.php +++ b/inc/modules/admin/what-list_surfbar_actions.php @@ -43,39 +43,56 @@ if ((!defined('__SECURITY')) || (!isAdmin())) { // Add description as navigation point addYouAreHereLink('admin', __FILE__); -// Load all actions -$result = SQL_QUERY("SELECT - `actions_id`, - `actions_status`, - `actions_action`, - `actions_new_status` -FROM - `{?_MYSQL_PREFIX?}_surfbar_actions` -ORDER BY - `actions_status` ASC, - `actions_action` ASC", __FILE__, __LINE__); +// By default show the list... +$show = true; -// Entries found? -if (!SQL_HASZERONUMS($result)) { - // List all entries - $OUT = ''; - while ($content = SQL_FETCHARRAY($result)) { - // "Translate" some data - $content['actions_action'] = '{--MEMBER_SURFBAR_ACTION_' . strtoupper($content['actions_action']) . '_SUBMIT--}', ; +// Edit or delete button hit? +if (isFormSent('edit')) { + // Show entries for editing + showEntriesByXmlCallback('admin_edit_show_surfbar_actions'); - // Load row template - $OUT .= loadTemplate('admin_list_surfbar_actions_row', true, $content); - } // END - while + // Do not show the list of URLs after this template + $show = false; +} elseif (isFormSent('do_edit')) { + // Change data of entries + showEntriesByXmlCallback('admin_edit_do_surfbar_actions'); +} elseif (isFormSent('delete')) { + // Show entries for deletion + showEntriesByXmlCallback('admin_delete_show_surfbar_actions'); - // Load main template - loadTemplate('admin_list_surfbar_actions', false, $OUT); -} else { - // No entries found, very bad! - displayMessage('{--ADMIN_SURFBAR_NO_ACTIONS--}'); + // Do not show the list of URLs after this template + $show = false; +} elseif (isFormSent('do_delete')) { + // Remove entries from database + showEntriesByXmlCallback('admin_delete_do_surfbar_actions'); +} elseif (isFormSent('lock')) { + // Un-/lock selected URLs. This does not work for pending URLs + showEntriesByXmlCallback('admin_lock_show_surfbar_actions'); + + // Do not show the list of URLs after this template + $show = false; +} elseif (isFormSent('do_lock')) { + // Un-/lock selected URLs. This does not work for pending URLs + showEntriesByXmlCallback('admin_lock_do_surfbar_actions'); +} elseif (isFormSent('undelete')) { + // Undelete selected URLs. This does only work for deleted URLs... ;-) + showEntriesByXmlCallback('admin_undelete_show_surfbar_actions'); + + // Do not show the list of URLs after this template + $show = false; +} elseif (isFormSent('do_undelete')) { + // Undelete selected URLs. This does only work for deleted URLs... ;-) + showEntriesByXmlCallback('admin_undelete_do_surfbar_actions'); } -// Free result -SQL_FREERESULT($result); +// Show entries? +if ($show === false) { + // No, a form has already been show + return false; +} // END - if + +// List all URLs +showEntriesByXmlCallback('admin_list_surfbar_actions'); // [EOF] ?> diff --git a/templates/de/html/admin/admin_list_surfbar_actions_row.tpl b/templates/de/html/admin/admin_list_surfbar_actions_row.tpl index cf9d4659c1..d08d4d1c11 100644 --- a/templates/de/html/admin/admin_list_surfbar_actions_row.tpl +++ b/templates/de/html/admin/admin_list_surfbar_actions_row.tpl @@ -6,7 +6,7 @@ {%pipe,translateSurfbarUrlStatus=$content[actions_status]%} </td> <td align="center" class="bottom right {%template,ColorSwitch%}"> - $content[actions_action] + {%pipe,translateMemberSurfbarActionToSubmit=$content[actions_action]%} </td> <td align="center" class="bottom {%template,ColorSwitch%}"> {%pipe,translateSurfbarUrlStatus=$content[actions_new_status]%} diff --git a/templates/xml/admin/admin_list_surfbar_actions.xml b/templates/xml/admin/admin_list_surfbar_actions.xml new file mode 100644 index 0000000000..7e231e1520 --- /dev/null +++ b/templates/xml/admin/admin_list_surfbar_actions.xml @@ -0,0 +1,96 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- +This template provides meta data for listing actions of the surfbar in the +admin area. + +@author Roland Haeder <webmaster@mxchange.org> +@version 0.2.1-FINAL +@copyright (c) 2003 - 2009 by Roland Haeder +@copyright (c) 2009 - 2011 by Mailer Developer Team +@license GNU GPL 2.0 or any newer version +@link http://www.mxchange.org + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +MA 02110-1301 USA +//--> +<admin-list-data> + <!-- + Call-back function, the extracted data from this XML will then be re-read + from that function. The most common function this XML uses is + adminListEntries() so mostly you can leave this alone unless you have JOINs. + //--> + <callback-function type="string" value="adminListEntries" /> + <!-- + Now we need information which template should be loaded and which functions + shall be called back. So lets start with the main list template. This mostly + requires no call-back function. + //--> + <list-template type="string" value="admin_list_surfbar_actions" /> + <!-- + The template for all rows, mostly this name has a '_row' suffix and again, + no call-back function is usually required. + //--> + <list-row-template type="string" value="admin_list_surfbar_actions_row" /> + <!-- + Message id to display if no entry could be found + //--> + <no-entry-found-message type="string" value="ADMIN_SURFBAR_ACTIONS_404" /> + <!-- + The table(s) we shall grab the data from, all as list. + //--> + <data-tables> + <!-- + A single table entry, with alias and without the configurable + _MYSQL_PREFIX. You can specify the table's name or alias later on. + //--> + <data-table type="string" alias="" value="surfbar_actions" /> + <!-- + Columns to perform the SELECT statement on, with alias and name plus which table. + //--> + <select-data-from-list> + <!-- + A single entry with table name (can be left empty), value (must + always be set), alias (again can be left empty) and SQL function + (can also be left empty) which shall be applied on the column. + //--> + <select-data-from-list-entry type="string" table="" value="actions_id" alias="" function="" /> + <select-data-from-list-entry type="string" table="" value="actions_status" alias="" function="" /> + <select-data-from-list-entry type="string" table="" value="actions_action" alias="" function="" /> + <select-data-from-list-entry type="string" table="" value="actions_new_status" alias="" function="" /> + </select-data-from-list> + <!-- + And the column list to perform the WHERE statement on. + //--> + <where-select-from-list> + </where-select-from-list> + <!-- + Columns to perform the ORDER BY statement (GROUP BY is not yet supported) + //--> + <order-by-list> + <!-- + A single entry to perform the ORDER BY statement on, see above WHERE entry for details. + //--> + <order-by-list-entry type="string" table="" order="actions_status" value="ASC" /> + <order-by-list-entry type="string" table="" order="actions_action" value="ASC" /> + </order-by-list> + </data-tables> + <!-- + List all column names from the 'select-data-from-list' node here, but now + with call-back informations. The list must only contain those entries where + a call-back function shall be called for. + //--> + <column-callback-list> + </column-callback-list> +</admin-list-data> diff --git a/templates/xml/admin/admin_list_surfbar_urls.xml b/templates/xml/admin/admin_list_surfbar_urls.xml index 03391becf7..dfe1d9050c 100644 --- a/templates/xml/admin/admin_list_surfbar_urls.xml +++ b/templates/xml/admin/admin_list_surfbar_urls.xml @@ -44,6 +44,10 @@ MA 02110-1301 USA //--> <list-row-template type="string" value="admin_list_surfbar_urls_row" /> <!-- + Message id to display if no entry could be found + //--> + <no-entry-found-message type="string" value="ADMIN_SURFBAR_URLS_404" /> + <!-- The table(s) we shall grab the data from, all as list. //--> <data-tables> @@ -123,8 +127,4 @@ MA 02110-1301 USA </callback-extra-parameter-list> </column-callback-list-entry> </column-callback-list> - <!-- - Message id to display if no entry could be found - //--> - <no-entry-found-message type="string" value="ADMIN_SURFBAR_NO_URLS_FOUND" /> </admin-list-data> diff --git a/templates/xml/admin_list_data_template.xml b/templates/xml/admin_list_data_template.xml index e47c537c8f..8fc22d2a10 100644 --- a/templates/xml/admin_list_data_template.xml +++ b/templates/xml/admin_list_data_template.xml @@ -47,6 +47,10 @@ MA 02110-1301 USA //--> <list-row-template type="string" value="admin_list_foo_data_row" /> <!-- + Message id to display if no entry could be found + //--> + <no-entry-found-message type="string" value="ADMIN_FOO_404" /> + <!-- The table(s) we shall grab the data from, all as list. //--> <data-tables> @@ -176,8 +180,4 @@ MA 02110-1301 USA </callback-extra-parameter-list> </column-callback-list-entry> </column-callback-list> - <!-- - Message id to display if no entry could be found - //--> - <no-entry-found-message type="string" value="ADMIN_SURFBAR_NO_URLS_FOUND" /> </admin-list-data> -- 2.39.5