* Kurzbeschreibung : Neue Kategorien hinzufuegen und bestehende *
* editieren / loeschen *
* -------------------------------------------------------------------- *
- * *
+ * $Revision:: $ *
+ * $Date:: $ *
+ * $Tag:: 0.2.1-FINAL $ *
+ * $Author:: $ *
+ * Needs to be in all Files and every File needs "svn propset *
+ * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
* -------------------------------------------------------------------- *
* Copyright (c) 2003 - 2008 by Roland Haeder *
* For more information visit: http://www.mxchange.org *
// Some security stuff...
if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
- $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+ $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
require($INC);
}
// Add description as navigation point
-ADD_DESCR("admin", __FILE__);
+ADD_DESCR('admin', __FILE__);
// Init variable to avoid a notice
-$CATS = "";
+$CATS = '';
if (REQUEST_ISSET_POST(('add'))) {
// Add a new category
SQL_FREERESULT($result);
// Display message
- LOAD_TEMPLATE("admin_settings_saved", false, $content);
+ LOAD_TEMPLATE('admin_settings_saved', false, $content);
} elseif ((IS_FORM_SENT()) && (REQUEST_ISSET_POST(('id'))) && (is_array(REQUEST_POST('id')))) {
// Change or delete categories...
- $TEXT = "";
+ $TEXT = '';
foreach (REQUEST_POST('id') as $id => $cat) {
// Secure ID
$id = bigintval($id);
if (isset($TEXT)) {
// Display message
- LOAD_TEMPLATE("admin_settings_saved", false, $TEXT);
+ LOAD_TEMPLATE('admin_settings_saved', false, $TEXT);
}
} elseif ((REQUEST_ISSET_POST('del')) && (SELECTION_COUNT(REQUEST_POST('sel')) > 0)) {
// Delete categories
- $SW = 2; $OUT = "";
+ $OUT = ''; $SW = 2;
foreach (REQUEST_POST('sel') as $id => $value) {
// Load data of category
$result = SQL_QUERY_ESC("SELECT cat FROM `{!_MYSQL_PREFIX!}_cats` WHERE id=%s LIMIT 1",
LOAD_TEMPLATE("admin_del_cats");
} elseif ((REQUEST_ISSET_POST('edit')) && (SELECTION_COUNT(REQUEST_POST('sel')) > 0)) {
// Edit categories
- $SW = 2; $OUT = "";
+ $OUT = ''; $SW = 2;
foreach (REQUEST_POST('sel') as $id => $value)
{
// Load data from the category
// Load main template
LOAD_TEMPLATE("admin_edit_cats");
-}
- else
-{
+} else {
+ // Init variable here
+ $CATS = '';
+
// Load all categories
$result = SQL_QUERY("SELECT id, cat, visible, sort FROM `{!_MYSQL_PREFIX!}_cats` ORDER BY `sort`", __FILE__, __LINE__);
- if (SQL_NUMROWS($result) > 0)
- {
+ if (SQL_NUMROWS($result) > 0) {
+ // Init variables
+ $OUT = ''; $SW = 2;
+
// List already existing categories for editing
- $SW = 2; $OUT = ""; $CATS = "";
- while (list($id, $cat, $visible, $sort) = SQL_FETCHROW($result))
- {
+ while ($content = SQL_FETCHARRAY($result)) {
// Prepare data for the row template
- $content = array(
- 'sw' => $SW,
- 'id' => $id,
- 'cat' => $cat,
- 'vis' => TRANSLATE_YESNO($visible),
- 'sort' => $sort,
- );
+ $content['sw'] = $SW;
+ $content['vis'] = TRANSLATE_YESNO($content['visible']);
// Put cat descriptions into variable for the selection box
- if (strlen($cat) > 20) $cat = substr($cat, 0, 17)."...";
- $CATS .= " <option value=\"".$sort."\">".$cat."</option>\n";
+ if (strlen($content['cat']) > 20) $content['cat'] = substr($content['cat'], 0, 17)."...";
+ $CATS .= " <option value=\"".$content['sort']."\">".$content['cat']."</option>\n";
// Load row template and switch color
$OUT .= LOAD_TEMPLATE("admin_config_cats_row", true, $content);
// Free memory
SQL_FREERESULT($result);
+
+ // @TODO Rewrite this constant
define('__CAT_ROWS', $OUT);
// Load main template
LOAD_TEMPLATE("admin_config_cats");
}
+ // @TODO Rewrite this constant
define('CATS', $CATS);
// Form to add a new category