How the custom fields should look.

git-svn-id: http://svn.automattic.com/wordpress/trunk@1195 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
saxmatt 2004-04-28 02:23:46 +00:00
parent b75393f51c
commit 9616224dd1
3 changed files with 69 additions and 75 deletions

View File

@ -217,27 +217,29 @@ function list_meta($meta) {
global $post_ID; global $post_ID;
// Exit if no meta // Exit if no meta
if (!$meta) return; if (!$meta) return;
?>
<table id='meta-list' width='98%'>
print " <tr>
<table id='meta-list'> <th><?php _e('Key') ?></th>
<tr> <th><?php _e('Value') ?></th>
<th>Key</th> <th colspan='2'><?php _e('Action') ?></th>
<th>Value</th> </tr>
<th>&nbsp</th> <?php
</tr>\n";
foreach ($meta as $entry) { foreach ($meta as $entry) {
// TBD: Still need to add edit/del logic... $style = ('class="alternate"' == $style) ? '' : 'class="alternate"';
print " echo "
<tr> <tr $style>
<td>{$entry['meta_key']}</td> <td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' value='{$entry['meta_key']}' /></td>
<td>{$entry['meta_value']}</td> <td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='40'>{$entry['meta_value']}</textarea></td>
<td><a href=\"?action=deletemeta&amp;meta_id={$entry['meta_id']}&amp;post={$entry['post_id']}\">Delete</a></td> <td align='center'><input name='updatemeta' type='submit' id='updatemeta' tabindex='6' value='" . __('Update') ."' /></td>
</tr>\n"; <td align='center'><input name='deletemeta[{$entry['meta_id']}]' type='submit' id='deletemeta' tabindex='6' value='" . __('Delete') ."' /></td>
</tr>
";
} }
print " echo "
</table>\n"; </table>
";
} }
// Get a list of previously defined keys // Get a list of previously defined keys
@ -256,43 +258,37 @@ function get_meta_keys() {
function meta_form() { function meta_form() {
$keys = get_meta_keys(); $keys = get_meta_keys();
?> ?>
<h4><?php _e('Add new custom data to this post:') ?></h4> <h3><?php _e('Add new custom data to this post:') ?></h3>
<div id="postcustomkeys"> <table width="100%" cellspacing="3" cellpadding="3">
<p><?php _e('Select existing key or enter new key') ?></p> <tr>
<?php <th colspan="2"><?php _e('Key') ?></th>
if ($keys) { <th><?php _e('Value') ?></th>
?> <th></th>
<select id="metakeyselect" name="metakeyselect"> </tr>
<tr valign="top">
<td align="right"><select id="metakeyselect" name="metakeyselect">
<option value="#NONE#">- Select -</option> <option value="#NONE#">- Select -</option>
<?php <?php
foreach($keys as $key) { foreach($keys as $key) {
echo "<option value='$key'>$key</option>\n"; echo "\n\t<option value='$key'>$key</option>";
} }
?> ?>
</select> </select> or </td><td><input type="text" id="metakeyinput" name="metakeyinput" /></td>
<?php <td><textarea id="metavalue" name="metavalue" rows="3" cols="25"></textarea></td>
} // if ($keys) <td></td>
?> </tr>
<input type="text" id="metakeyinput" name="metakeyinput" />
</div>
<div id="postcustomvals">
<p><?php _e('Custom Value') ?></p>
<textarea id="metavalue" name="metavalue" rows="3" cols="25"></textarea> </table>
</div> <p class="submit"><input type="submit" id="save" name="save" value="<?php _e('Add Custom Fields &raquo;') ?>"></p>
<br style="clear: both;" />
<div id="postcustomsubmit">
<input type="submit" id="save" name="save" value="<?php _e('Add Custom') ?>">
</div>
<?php <?php
} }
function add_meta($post_ID) { function add_meta($post_ID) {
global $wpdb, $tablepostmeta; global $wpdb, $tablepostmeta;
$metakeyselect = trim($_POST['metakeyselect']); $metakeyselect = $wpdb->escape( stripslashes( trim($_POST['metakeyselect']) ) );
$metakeyinput = trim($_POST['metakeyinput']); $metakeyinput = $wpdb->escape( stripslashes( trim($_POST['metakeyinput']) ) );
$metavalue = trim($_POST['metavalue']); $metavalue = $wpdb->escape( stripslashes( trim($_POST['metavalue']) ) );
if (!empty($metavalue) && ((('#NONE#' != $metakeyselect) && !empty($metakeyselect)) || !empty($metakeyinput))) { if (!empty($metavalue) && ((('#NONE#' != $metakeyselect) && !empty($metakeyselect)) || !empty($metakeyinput))) {
// We have a key/value pair. If both the select and the // We have a key/value pair. If both the select and the

View File

@ -139,19 +139,6 @@ if ($action != 'editcomment') {
} }
} }
?> ?>
<fieldset id="postcustom">
<legend><?php _e('Post Custom') ?></legend>
<?php
if($metadata = has_meta($post_ID)) {
?>
<?php
list_meta($metadata);
?>
<?php
}
meta_form();
?>
</fieldset>
<?php echo $form_pingback ?> <?php echo $form_pingback ?>
<?php echo $form_prevstatus ?> <?php echo $form_prevstatus ?>
@ -179,11 +166,23 @@ if ('' != $pinged) {
if ($user_level > 4) { if ($user_level > 4) {
touch_time(($action == 'edit')); touch_time(($action == 'edit'));
} }
if ('edit' == $action) echo "
<p><a href='post.php?action=delete&amp;post=$post_ID' onclick=\"return confirm('" . sprintf(__("You are about to delete this post \'%s\'\\n \'Cancel\' to stop, \'OK\' to delete."), addslashes($edited_post_title)) . "')\">" . __('Delete this post') . "</a></p>";
?> ?>
<fieldset id="postcustom">
<legend><?php _e('Custom Fields') ?></legend>
<?php
if($metadata = has_meta($post_ID)) {
?>
<?php
list_meta($metadata);
?>
<?php
}
meta_form();
?>
</fieldset>
</div> </div>
</form> </form>
<?php if ('edit' == $action) echo "
<p><a class='delete' href='post.php?action=delete&amp;post=$post_ID' onclick=\"return confirm('" . sprintf(__("You are about to delete this post \'%s\'\\n \'Cancel\' to stop, \'OK\' to delete."), addslashes($edited_post_title)) . "')\">" . __('Delete this post') . "</a></p>";
?>
</div> </div>

View File

@ -329,7 +329,7 @@ textarea, input, select {
border: 1px solid #aaa; border: 1px solid #aaa;
margin: 0.25em; margin: 0.25em;
padding: 0.25em; padding: 0.25em;
width: 30em; width: 98%;
} }
#postcustom p { #postcustom p {
@ -337,28 +337,27 @@ textarea, input, select {
} }
#postcustom table { #postcustom table {
background-color: #eee;
border: 1px solid #ccc; border: 1px solid #ccc;
color: #000; margin: .5em;
margin-bottom: 1em;
padding: 0px;
width: 100%; width: 100%;
}
#postcustom table input, #postcustom table textarea {
width: 97%;
} }
#postcustom td, #postcustom th { #postcustom td, #postcustom th {
color: #000; color: #000;
margin: 1px; margin: 0.2em;
padding: 0.2em; padding: .3em;
} }
#postcustomkeys { #postcustom #updatemeta, #postcustom #deletemeta {
float: left; width: 90%;
width: 49%; margin: auto;
} }
#postcustomkeys input, #postcustom select, #postcustom textarea {
width: 95%;
}
fieldset legend a { fieldset legend a {
border-bottom: none; border-bottom: none;
} }