allow turning off queued transcripts

This commit is contained in:
John Bintz 2009-08-18 22:33:59 -04:00
parent eec73ad64d
commit 7a643f4fef
4 changed files with 74 additions and 41 deletions

View File

@ -250,6 +250,17 @@ class WhatDidTheySay {
return $options['languages'];
}
function set_allow_transcripts_for_post($post_id, $allow = true) {
$current_transcripts = get_post_meta($post_id, "provided_transcripts", true);
$current_transcripts['_allow'] = $allow;
update_post_meta($post_id, "provided_transcripts", $current_transcripts);
}
function get_allow_transcripts_for_post($post_id) {
$current_transcripts = get_post_meta($post_id, "provided_transcripts", true);
return $current_transcripts['_allow'];
}
}
?>

View File

@ -137,12 +137,14 @@ class WhatDidTheySayAdmin {
function handle_update_queue_transcript($queue_transcript_info) {
$updated = false;
if (current_user_can('submit_transcriptions')) {
switch ($queue_transcript_info['action']) {
case 'submit_queued_transcript':
$result = $this->what_did_they_say->add_queued_transcription_to_post($queue_transcript_info['post_id'], $queue_transcript_info);
if ($result) {
$updated = __('Transcript added to queue.', 'what-did-they-say');
}
if ($what_did_they_say->get_allow_transcripts_for_post($queue_transcript_info['post_id'])) {
switch ($queue_transcript_info['action']) {
case 'submit_queued_transcript':
$result = $this->what_did_they_say->add_queued_transcription_to_post($queue_transcript_info['post_id'], $queue_transcript_info);
if ($result) {
$updated = __('Transcript added to queue.', 'what-did-they-say');
}
}
}
}
return $updated;
@ -156,8 +158,16 @@ class WhatDidTheySayAdmin {
switch ($post_transcript_info['action']) {
case "manage_post_transcripts":
foreach ($post_transcript_info['transcripts'] as $language => $transcript) {
$this->what_did_they_say->save_transcript($post_transcript_info['post_id'], $language, $transcript);
switch ($language) {
case "_allow":
$allow = true;
break;
default:
$this->what_did_they_say->save_transcript($post_transcript_info['post_id'], $language, $transcript);
break;
}
}
$this->what_did_they_say->set_allow_transcripts_for_post($post_transcript_info['post_id'], isset($post_transcript_info['allow_on_post']));
$updated = __('Transcripts updated', 'what-did-they-say');
break;
}

View File

@ -3,7 +3,13 @@
<input type="hidden" name="wdts[post_id]" value="<?php echo $post->ID ?>" />
<p>
<label>
Edit transcript for:
<input type="checkbox" name="wdts[allow_on_post]" value="yes" <?php echo ($transcripts['_allow']) ? 'checked="checked"' : '' ?> />
<?php _e('Allow new transcripts to be submitted for this post', 'what-did-they-say') ?>
</label>
</p>
<p>
<label>
<?php _e('Edit transcript for:', 'what-did-they-say') ?>
<select name="wdts[language]" id="wdts-language">
<?php foreach ($options['languages'] as $code => $info) { ?>
<option value="<?php echo $code ?>" <?php echo $info['default'] ? 'selected="selected"' : '' ?>><?php echo $info['name'] ?></option>

View File

@ -75,9 +75,11 @@ function transcripts_display($dropdown_message = null, $single_language_message
$post_transcripts = $what_did_they_say->get_transcripts($post->ID);
if (!empty($post_transcripts)) {
foreach ($post_transcripts as $code => $transcript) {
$transcript = trim($transcript);
if (!empty($transcript)) {
$transcripts[$code] = $transcript;
if (substr($code, 0, 1) != "_") {
$transcript = trim($transcript);
if (!empty($transcript)) {
$transcripts[$code] = $transcript;
}
}
}
@ -126,35 +128,39 @@ function the_media_transcript_queue_editor() {
if (current_user_can('submit_transcriptions')) { ?>
<?php if (is_array($queued_transcripts_for_user)) { ?>
<div class="queued-transcriptions">
<h3><?php _e('Your queued transcriptions', 'what-did-they-say') ?></h3>
<?php foreach ($queued_transcripts_for_user as $transcript) { ?>
<h4><?php echo $what_did_they_say->get_language_name($transcript->language) ?></h4>
<div>
<?php echo $transcript->transcript ?>
</div>
<?php } ?>
</div>
<?php } ?>
<form method="post" class="transcript-editor">
<input type="hidden" name="wdts[_nonce]" value="<?php echo wp_create_nonce('what-did-they-say') ?>" />
<input type="hidden" name="wdts[action]" value="submit_queued_transcript" />
<input type="hidden" name="wdts[post_id]" value="<?php echo $post->ID ?>" />
<h3><?php _e('Submit a new transcription:', 'what-did-they-say') ?></h3>
<label>
<?php _e('Language:', 'what-did-they-say') ?>
<select name="wdts[language]">
<?php foreach ($what_did_they_say->get_languages() as $code => $info) { ?>
<option value="<?php echo $code ?>"><?php echo $info['name'] ?></option>
<?php if (count($queued_transcripts_for_user) > 0) { ?>
<div class="queued-transcriptions">
<h3><?php _e('Your queued transcriptions', 'what-did-they-say') ?></h3>
<?php foreach ($queued_transcripts_for_user as $transcript) { ?>
<h4><?php echo $what_did_they_say->get_language_name($transcript->language) ?></h4>
<div>
<?php echo $transcript->transcript ?>
</div>
<?php } ?>
</select>
</label><br />
<label>
<?php _e('Transcription:', 'what-did-they-say') ?><br />
<textarea style="height: 200px; width: 90%" name="wdts[transcript]"></textarea>
</label>
<input type="submit" value="<?php _e('Submit New Transcription', 'what-did-they-say') ?>" />
</form>
</div>
<?php } ?>
<?php } ?>
<?php if ($what_did_they_say->get_allow_transcripts_for_post($post->ID)) { ?>
<form method="post" class="transcript-editor">
<input type="hidden" name="wdts[_nonce]" value="<?php echo wp_create_nonce('what-did-they-say') ?>" />
<input type="hidden" name="wdts[action]" value="submit_queued_transcript" />
<input type="hidden" name="wdts[post_id]" value="<?php echo $post->ID ?>" />
<h3><?php _e('Submit a new transcription:', 'what-did-they-say') ?></h3>
<label>
<?php _e('Language:', 'what-did-they-say') ?>
<select name="wdts[language]">
<?php foreach ($what_did_they_say->get_languages() as $code => $info) { ?>
<option value="<?php echo $code ?>"><?php echo $info['name'] ?></option>
<?php } ?>
</select>
</label><br />
<label>
<?php _e('Transcription:', 'what-did-they-say') ?><br />
<textarea style="height: 200px; width: 90%" name="wdts[transcript]"></textarea>
</label>
<input type="submit" value="<?php _e('Submit New Transcription', 'what-did-they-say') ?>" />
</form>
<?php } ?>
<?php }
}