|
From: James A. <th...@us...> - 2001-11-12 11:57:28
|
Update of /cvsroot/phpbb/phpBB2/admin
In directory usw-pr-cvs1:/tmp/cvs-serv16606/admin
Modified Files:
admin_styles.php
Log Message:
Ok, I think thats the last of the theme admin stuff. Hopefully its bug free
Index: admin_styles.php
===================================================================
RCS file: /cvsroot/phpbb/phpBB2/admin/admin_styles.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** admin_styles.php 2001/11/07 14:45:07 1.6
--- admin_styles.php 2001/11/12 11:57:25 1.7
***************
*** 294,301 ****
//
! // Do names stuff here!
//
message_die(GENERAL_MESSAGE, $lang['Theme_updated'], $lang['Success']);
}
--- 294,361 ----
//
! // Check if there's a names table entry for this style
//
+ $sql = "SELECT themes_id FROM " . THEMES_NAME_TABLE . " WHERE themes_id = $style_id";
+ if(!$result = $db->sql_query($sql))
+ {
+ message_die(GENERAL_ERROR, "Could not get data from themes_name table", "Error", __LINE__, __FILE__, $sql);
+ }
+
+ if($db->sql_numrows($result) > 0)
+ {
+ $sql = "UPDATE " . THEMES_NAME_TABLE . " SET ";
+ $count = 0;
+ while(list($key, $val) = each($updated_name))
+ {
+ if($count != 0)
+ {
+ $sql .= ", ";
+ }
+
+ $sql .= "$key = '$val'";
+
+ $count++;
+ }
+
+ $sql .= " WHERE themes_id = $style_id";
+ }
+ else
+ {
+ // Nope, no names entry so we create a new one.
+ $sql = "INSERT INTO " . THEMES_NAME_TABLE . " (themes_id, ";
+ while(list($key, $val) = each($updated_name))
+ {
+ $fields[] = $key;
+ $vals[] = $val;
+ }
+ for($i = 0; $i < count($fields); $i++)
+ {
+ if($i > 0)
+ {
+ $sql .= ", ";
+ }
+ $sql .= $fields[$i];
+ }
+
+ $sql .= ") VALUES ($style_id, ";
+ for($i = 0; $i < count($vals); $i++)
+ {
+ if($i > 0)
+ {
+ $sql .= ", ";
+ }
+ $sql .= "'" . $vals[$i] . "'";
+ }
+
+ $sql .= ")";
+ }
+
+ if(!$result = $db->sql_query($sql))
+ {
+ message_die(GENERAL_ERROR, "Could not update themes name table!", "Error", __LINE__, __FILE__, $sql);
+ }
+
message_die(GENERAL_MESSAGE, $lang['Theme_updated'], $lang['Success']);
}
***************
*** 342,348 ****
}
! //
! // Do names stuff here!
//
--- 402,441 ----
}
! $style_id = $db->sql_nextid();
!
! //
! // Insert names data
//
+ $sql = "INSERT INTO " . THEMES_NAME_TABLE . " (themes_id, ";
+ while(list($key, $val) = each($updated_name))
+ {
+ $fields[] = $key;
+ $vals[] = $val;
+ }
+ for($i = 0; $i < count($fields); $i++)
+ {
+ if($i > 0)
+ {
+ $sql .= ", ";
+ }
+ $sql .= $fields[$i];
+ }
+
+ $sql .= ") VALUES ($style_id, ";
+ for($i = 0; $i < count($vals); $i++)
+ {
+ if($i > 0)
+ {
+ $sql .= ", ";
+ }
+ $sql .= "'" . $vals[$i] . "'";
+ }
+
+ $sql .= ")";
+
+ if(!$result = $db->sql_query($sql))
+ {
+ message_die(GENERAL_ERROR, "Could not insert themes name table!", "Error", __LINE__, __FILE__, $sql);
+ }
***************
*** 376,381 ****
message_die(GENERAL_ERROR, "Could not get data from themes table", "Error", __LINE__, __FILE__, $sql);
}
! $selected = $db->sql_fetchrow($result);
$s_hidden_fields = '<input type="hidden" name="style_id" value="' . $style_id . '" />';
--- 469,487 ----
message_die(GENERAL_ERROR, "Could not get data from themes table", "Error", __LINE__, __FILE__, $sql);
}
+
+ $selected_values = $db->sql_fetchrow($result);
+
+ //
+ // Fetch the Themes Name data
+ //
+ $sql = "SELECT * FROM " . THEMES_NAME_TABLE . " WHERE themes_id = $style_id";
+ if(!$result = $db->sql_query($sql))
+ {
+ message_die(GENERAL_ERROR, "Could not get data from themes name table", "Error", __LINE__, __FILE__, $sql);
+ }
! $selected_names = $db->sql_fetchrow($result);
!
! $selected = array_merge($selected_values, $selected_names);
$s_hidden_fields = '<input type="hidden" name="style_id" value="' . $style_id . '" />';
|