From: <rav...@us...> - 2016-02-01 17:04:35
|
Revision: 9771 http://sourceforge.net/p/planeshift/code/9771 Author: ravna-ps Date: 2016-02-01 17:04:33 +0000 (Mon, 01 Feb 2016) Log Message: ----------- Added CSS table look alike support. (Used in places where multiple forms have to reside 1 table, but the forms do need to span multiple table cells.) Changed npc_details to yield valid html on the variable submenu. Escaped html variables, so special characters can be used. Changed variable name to be non editable (it was not editable to begin with). Modified Paths: -------------- www/webconsole-new/global.css www/webconsole-new/npcs/npc_details.php Modified: www/webconsole-new/global.css =================================================================== --- www/webconsole-new/global.css 2016-02-01 12:48:36 UTC (rev 9770) +++ www/webconsole-new/global.css 2016-02-01 17:04:33 UTC (rev 9771) @@ -67,6 +67,32 @@ display:block; } +.table{ + display:table; + border:1px solid; + border-spacing:1px; + padding:0.1em 0.1em 0.1em 0.1em; +} + +.tr{ + display:table-row; +} + +.td{ + display:table-cell; + border:1px solid; + padding:0.4em 0.4em 0.4em 0.4em; +} + +.th{ + display:table-cell; + font-weight:bold; + text-align: center; + border:1px solid; + padding:0.4em 0.4em 0.4em 0.4em; +} + + th{ text-transform:capitalize; } Modified: www/webconsole-new/npcs/npc_details.php =================================================================== --- www/webconsole-new/npcs/npc_details.php 2016-02-01 12:48:36 UTC (rev 9770) +++ www/webconsole-new/npcs/npc_details.php 2016-02-01 17:04:33 UTC (rev 9771) @@ -1099,7 +1099,7 @@ echo '<a href="'.$uri_string.'&sub=skills">skills</a><br/>'; echo '<a href="'.$uri_string.'&sub=traits">traits</a><br/>'; echo '<a href="'.$uri_string.'&sub=factions">Factions</a><br/>'; - echo '<a href="'.$uri_string.'&sub=variables">Variables</a><br/>'; + echo '<a href="'.$uri_string.'&sub=variables">Variables</a><br/>'; if ($row['character_type'] > 0) // don't display for players { echo '<a href="'.$uri_string.'&sub=kas">KA\'s</a><br/>'; @@ -1118,7 +1118,7 @@ case 'factions': npc_factions(); break; - case 'variables': + case 'variables': npc_variables(); break; case 'main': @@ -1257,6 +1257,11 @@ { $id = escapeSqlString($_GET['npc_id']); $variable_name = escapeSqlString($_POST['variable_name']); + if (trim($variable_name) == '') + { + echo '<p class="error">Invalid variable name.</p>'; + return; + } $query = ''; if ($_POST['commit'] == 'Remove') { @@ -1265,7 +1270,7 @@ else if($_POST['commit'] == 'Add Variable') { $variable_value = escapeSqlString($_POST['variable_value']); - $query = "INSERT INTO character_variables (character_id, name, value) VALUES ('$id', '$variable_name', '$variable_value') ON DUPLICATE KEY UPDATE value='$variable_value'"; + $query = "INSERT INTO character_variables (character_id, name, value) VALUES ('$id', '$variable_name', '$variable_value')"; } else if($_POST['commit'] == 'Edit') { @@ -1287,23 +1292,24 @@ $id = escapeSqlString($_GET['npc_id']); $query = 'SELECT name, value FROM character_variables WHERE character_id='.$id.' ORDER BY name'; $result = mysql_query2($query); - echo '<table border="1"><tr><th>Variable</th><th>Value</th><th>Actions</th></tr>'; if (sqlNumRows($result) > 0) { + echo '<div class="table">'."\n"; + echo '<div class="tr">'."\n"; + echo '<div class="th">Variable</div><div class="th">Value</div><div class="th">Actions</div>'."\n"; + echo '</div>'."\n"; while ($row = fetchSqlAssoc($result)) { - echo '<tr><td><form action="./index.php?do=npc_details&npc_id='.$id.'&sub=variables" method="post">'; - echo '<input type="text" name="variable_name" value="'.$row['name'].'" /></td>'; - echo '<td><input type="text" size="9" name="variable_value" value="'.$row['value'].'" /></td>'; - echo '<td><input type="submit" name="commit" value="Edit" /></form>'; - echo '<form action="./index.php?do=npc_details&npc_id='.$id.'&sub=variables" method="post">'; - echo '<input type="hidden" name="variable_name" value="'.$row['name'].'" /><input type="submit" name="commit" value="Remove" /></form></td></tr>'; + echo '<form class="tr" action="./index.php?do=npc_details&npc_id='.$id.'&sub=variables" method="post">'."\n"; + echo '<div class="td"><input type="hidden" name="variable_name" value="'.htmlentities($row['name']).'" />'.htmlentities($row['name']).'</div>'."\n"; + echo '<div class="td"><input type="text" size="9" name="variable_value" value="'.htmlentities($row['value']).'" /></div>'."\n"; + echo '<div class="td"><input type="submit" name="commit" value="Edit" /><br /><input type="submit" name="commit" value="Remove" /></div>'."\n"; + echo '</form>'."\n"; // ends tr } - echo '</table>'; + echo '</div>'."\n"; // ends table } else { - echo '</table>'; echo '<p class="error">NPC has no variables</p>'; } echo '<p>Add a variable to this NPC</p>'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |