some bug fixes and ui improvements

This commit is contained in:
John Bintz 2009-10-13 18:49:21 -04:00
parent 0ba25fc5af
commit 94aac79b48
8 changed files with 148 additions and 53 deletions

View File

@ -77,6 +77,9 @@ class WhatDidTheySayAdmin {
if ($any_changes) { update_option('what-did-they-say-options', $options); }
}
// sessions
if (!session_id()) { session_start(); }
// pages
add_action('admin_menu', array(&$this, 'admin_menu'));
add_action('admin_notices', array(&$this, 'admin_notices'));
@ -178,7 +181,9 @@ class WhatDidTheySayAdmin {
}
}
$this->transcript_count = (int)$wpdb->get_var($wpdb->prepare("SELECT count($wpdb->postmeta.meta_key) FROM $wpdb->postmeta WHERE $wpdb->postmeta.meta_key = 'approved_transcripts'"));
if (is_admin()) {
$this->transcript_count = (int)$wpdb->get_var($wpdb->prepare("SELECT count($wpdb->postmeta.meta_key) FROM $wpdb->postmeta WHERE $wpdb->postmeta.meta_key = 'approved_transcripts'"));
}
}
/** Widget **/
@ -196,6 +201,15 @@ class WhatDidTheySayAdmin {
echo 'WhatDidTheySay.ajax_url = "' . addslashes($_SERVER['REQUEST_URI']) . '";';
echo 'WhatDidTheySay.nonce = "' . $nonce . '";';
echo '</script>';
if (isset($_SESSION['what-did-they-say'])) {
if (isset($_SESSION['what-did-they-say']['updated'])) {
echo '<div class="wdts-updated"><div>' . $_SESSION['what-did-they-say']['updated'] . '</div></div>';
}
}
// clear out our session variable, we only need it briefly
unset($_SESSION['what-did-they-say']);
}
/**
@ -507,6 +521,11 @@ class WhatDidTheySayAdmin {
}
if (!is_admin()) {
$_SESSION['what-did-they-say'] = array(
'action' => 'queue-transcript',
'post_id' => $info['post_id'],
'updated' => $updated
);
header('Location: ' . $_SERVER['HTTP_REFERER']);
exit(0);
} else {

View File

@ -15,15 +15,16 @@
}
?>
<?php if (!empty($transcripts_to_show)) { ?>
<h3 style="margin-top: 0.5em"><?php echo $title ?></h3>
<?php
foreach ($transcripts_to_show as $transcript) {
include('_display-queued-transcript.inc');
}
?>
<?php } ?>
<?php if (current_user_can('submit_transcriptions')) { ?>
<?php if (!empty($transcripts_to_show)) { ?>
<h3 style="margin-top: 0.5em"><?php echo $title ?></h3>
<?php
foreach ($transcripts_to_show as $transcript) {
include('_display-queued-transcript.inc');
}
?>
<?php } ?>
<div id="wdts-<?php echo $new_transcript_id ?>" style="zoom:1<?php echo (!$transcript_options->are_new_transcripts_allowed() ? ';display:none' : '') ?>">
<?php wdts_header_wrapper(__('Submit a New Transcript:', 'what-did-they-say')) ?>
<form method="post">

View File

@ -4,8 +4,10 @@
<input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
<?php } ?>
<input id="wdts-<?php echo $checkbox_id = md5(rand()) ?>" type="checkbox" name="wdts[allow_on_post]" value="yes" <?php echo ($transcript_options->are_new_transcripts_allowed()) ? 'checked="checked"' : '' ?> />
<?php _e('Allow new transcripts to be submitted for this post', 'what-did-they-say') ?>
<?php if (current_user_can('approve_transcriptions')) { ?>
<input id="wdts-<?php echo $checkbox_id = md5(rand()) ?>" type="checkbox" name="wdts[allow_on_post]" value="yes" <?php echo ($transcript_options->are_new_transcripts_allowed()) ? 'checked="checked"' : '' ?> />
<?php _e('Allow new transcripts to be submitted for this post', 'what-did-they-say') ?>
<?php } ?>
<?php $approved_editor_id = md5(rand()) ?>
@ -17,43 +19,45 @@
<?php include(dirname(__FILE__) . '/_manage-queued-transcripts.inc') ?>
<?php } ?>
<?php if (is_array($queued_transcripts) && !empty($queued_transcripts)) { ?>
<?php wdts_header_wrapper(__('Manage Queued Transcripts:', 'what-did-they-say')) ?>
<?php
foreach ($queued_transcripts as $transcript) {
$user = get_userdata($transcript['user_id']);
if (!empty($user)) { include('_display-queued-transcript.inc'); }
}
?>
<?php } ?>
<?php if (current_user_can('approve_transcriptions')) { ?>
<?php if (is_array($queued_transcripts) && !empty($queued_transcripts)) { ?>
<?php wdts_header_wrapper(__('Manage Queued Transcripts:', 'what-did-they-say')) ?>
<?php
foreach ($queued_transcripts as $transcript) {
$user = get_userdata($transcript['user_id']);
if (!empty($user)) { include('_display-queued-transcript.inc'); }
}
?>
<?php } ?>
<div id="wdts-<?php echo $approved_editor_id ?>">
<?php wdts_header_wrapper(__('Edit Approved Transcripts:', 'what-did-they-say')) ?>
<div class="wdts-transcript-editor">
<label>
<?php _e('Language:', 'what-did-they-say') ?>
<select name="wdts[language]" class="wdts-transcript-selector">
<?php foreach ($options['languages'] as $code => $info) { ?>
<option value="<?php echo $code ?>" <?php echo $info['default'] ? 'selected="selected"' : '' ?>><?php echo $info['name'] ?></option>
<?php } ?>
</select>
</label>
<div id="wdts-<?php echo $approved_editor_id ?>">
<?php wdts_header_wrapper(__('Edit Approved Transcripts:', 'what-did-they-say')) ?>
<div class="wdts-transcript-editor">
<label>
<?php _e('Language:', 'what-did-they-say') ?>
<select name="wdts[language]" class="wdts-transcript-selector">
<?php foreach ($options['languages'] as $code => $info) { ?>
<option value="<?php echo $code ?>" <?php echo $info['default'] ? 'selected="selected"' : '' ?>><?php echo $info['name'] ?></option>
<?php } ?>
</select>
</label>
<div class="wdts-button-holder"></div>
<?php foreach (array_keys($options['languages']) as $code) {
$approved_transcript_text = '';
foreach ($approved_transcripts as $transcript) {
if ($transcript['language'] == $code) { $approved_transcript_text = $transcript['transcript']; break; }
} ?>
<textarea class="edit-transcript" name="wdts[transcripts][<?php echo $code ?>]" style="display: none; width: 99%; height: 200px"><?php echo $approved_transcript_text ?></textarea>
<?php } ?>
<?php if (!is_admin()) { ?>
<input type="button" class="wdts-modify-transcript button" value="<?php _e('Update All Transcripts', 'what-did-they-say') ?>" />
<span class="wdts-update-message"></span>
<?php } ?>
<div class="wdts-button-holder"></div>
<?php foreach (array_keys($options['languages']) as $code) {
$approved_transcript_text = '';
foreach ($approved_transcripts as $transcript) {
if ($transcript['language'] == $code) { $approved_transcript_text = $transcript['transcript']; break; }
} ?>
<textarea class="edit-transcript" name="wdts[transcripts][<?php echo $code ?>]" style="display: none; width: 99%; height: 200px"><?php echo $approved_transcript_text ?></textarea>
<?php } ?>
<?php if (!is_admin()) { ?>
<input type="button" class="wdts-modify-transcript button" value="<?php _e('Update All Transcripts', 'what-did-they-say') ?>" />
<span class="wdts-update-message"></span>
<?php } ?>
</div>
<div class="wdts-embed-warning"><?php _e('Uh oh...there\'s a problem with automatic embedding. Enable &quot;Inject transcripts at level 100 instead of level 15&quot; on the What Did They Say?!? Misc. Options page.', 'what-did-they-say') ?></div>
</div>
<div class="wdts-embed-warning"><?php _e('Uh oh...there\'s a problem with automatic embedding. Enable &quot;Inject transcripts at level 100 instead of level 15&quot; on the What Did They Say?!? Misc. Options page.', 'what-did-they-say') ?></div>
</div>
<?php } ?>
<script type="text/javascript">
queued_editors_to_attach.each(function(q) {

View File

@ -90,4 +90,21 @@ h3.wdts {
font-size: 115%;
color: #770000;
font-weight: bold;
}
.wdts-updated {
width: 100%;
position: absolute;
background-color: #E4F2FD;
text-align: center;
font-weight: bold;
border-bottom: solid black 1px;
}
.wdts-updated div {
padding: 0.75em;
}
body {
overflow-x: hidden
}

View File

@ -283,7 +283,6 @@ WhatDidTheySay.setup_transcript_action_buttons = function(container, approved_ed
var post_id = container.select("input[name*=[post_id]]").shift();
var key = container.select("input[name*=[key]]").shift();
top.console.log("made it");
var submitter = new Element('button').update('Update Transcript');
submitter.observe('click', function(e) {
Event.stop(e);
@ -308,8 +307,6 @@ WhatDidTheySay.setup_transcript_action_buttons = function(container, approved_ed
}
});
top.console.log(actions_holder);
container.appendChild(submitter);
actions_holder.parentNode.removeChild(actions_holder);
@ -392,3 +389,21 @@ var WDTSInjector = Class.create({
}
}
});
Event.observe(window, 'load', function() {
$$('.wdts-updated').each(function(up) {
up.hide();
up.style.top = document.viewport.getScrollOffsets().top + "px";
new Effect.BlindDown(up, {
duration: 0.25,
afterFinish: function() {
new PeriodicalExecuter(function(pe) {
pe.stop();
new Effect.BlindUp(up, {
duration: 0.25
});
}, 3);
}
});
});
});

View File

@ -25,6 +25,7 @@
<tr><td><a href="TestCreatePost.html">TestCreatePost</a></td></tr>
<tr><td><a href="TestMetaboxApprovedTranscriptEditing.html">TestMetaboxApprovedTranscriptEditing</a></td></tr>
<tr><td><a href="TestDeletePost.html">TestDeletePost</a></td></tr>
<tr><td><a href="TestThemeEditorWorks.html">TestThemeEditorWorks</a></td></tr>
<tr><td><a href="TestDeactivate.html">TestDeactivate</a></td></tr>
</tbody></table>
</body>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://comicpress.local/" />
<title>TestThemeEditorWorks</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">TestThemeEditorWorks</td></tr>
</thead><tbody>
<tr>
<td>click</td>
<td>link=Editor</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Edit Themes</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>

View File

@ -25,12 +25,12 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
foreach (glob(dirname(__FILE__) . '/classes/*.inc') as $file) { require_once($file); }
foreach (glob(dirname(__FILE__) . '/classes/*.inc') as $__file) { require_once($__file); }
$what_did_they_say_admin = new WhatDidTheySayAdmin(&$what_did_they_say);
$what_did_they_say_admin->_parent_file = __FILE__;
$__what_did_they_say_admin = new WhatDidTheySayAdmin(&$__what_did_they_say);
$__what_did_they_say_admin->_parent_file = __FILE__;
add_action('init', array(&$what_did_they_say_admin, 'init'));
add_action('init', array(&$__what_did_they_say_admin, 'init'));
// template tags
// please, if you use any of these, wrap them in function_exists() so your site doesn't
@ -210,11 +210,11 @@ function the_media_transcript_queue_editor() {
<p>JavaScript is required to edit transcripts.</p>
</noscript>
<div id="wdts-<?php echo $id ?>" style="display:none">
<h3 class="wdts"><?php _e('Manage Transcripts:', 'what-did-they-say') ?></h3>
<?php include(dirname(__FILE__) . '/classes/partials/meta-box.inc') ?>
</div>
<script type="text/javascript">
$($('wdts-opener-<?php echo $id ?>').parentNode).show();
$('wdts-opener-<?php echo $id ?>').observe('click', function(e) {
Event.stop(e);
@ -225,6 +225,17 @@ function the_media_transcript_queue_editor() {
new Effect.BlindDown(target, { duration: 0.25 });
}
});
<?php
if (isset($_SESSION['what-did-they-say'])) {
if (isset($_SESSION['what-did-they-say']['post_id'])) {
if ($post->ID == $_SESSION['what-did-they-say']['post_id']) { ?>
$('wdts-<?php echo $id ?>').show();
$('wdts-<?php echo $id ?>').scrollIntoView();
<?php }
}
}
?>
</script>
<?php }
}