From 497a1ac3b57fe296d70e5039b318f34a8e742783 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Thu, 10 Sep 2009 21:20:01 -0400 Subject: [PATCH] working on metabox --- classes/WDTSTranscriptOptions.php | 4 +- classes/WhatDidTheySayAdmin.php | 68 +++++++++++++++---------------- classes/meta-box.inc | 20 ++++----- what-did-they-say.php | 15 +++++-- 4 files changed, 57 insertions(+), 50 deletions(-) diff --git a/classes/WDTSTranscriptOptions.php b/classes/WDTSTranscriptOptions.php index 109389b..eb9ca55 100644 --- a/classes/WDTSTranscriptOptions.php +++ b/classes/WDTSTranscriptOptions.php @@ -20,9 +20,9 @@ class WDTSTranscriptOptions { * See if the indicated post is accepting new transcripts. * @return boolean True if the post is acceptin new transcripts. */ - function get_allow_transcripts() { + function are_new_transcripts_allowed() { $options = $this->_get_transcript_options(); - return issset($options['allow_transcripts']) ? $options['allow_transcripts'] : false; + return isset($options['allow_transcripts']) ? $options['allow_transcripts'] : false; } function _get_transcript_options() { diff --git a/classes/WhatDidTheySayAdmin.php b/classes/WhatDidTheySayAdmin.php index b16b497..477d6f2 100644 --- a/classes/WhatDidTheySayAdmin.php +++ b/classes/WhatDidTheySayAdmin.php @@ -194,43 +194,39 @@ class WhatDidTheySayAdmin { * @param array $info The part of the $_POST array for What Did They Say?!? * @return string|false A string if a message is to be displayed, or false if no message. */ - function handle_update_post_transcripts($info) { + function handle_update_manage_post_transcripts($info) { $updated = false; if (current_user_can('approve_transcriptions')) { $options = get_option('what-did-they-say-options'); - switch ($info['action']) { - case "manage_post_transcripts": - foreach ($info['transcripts'] as $language => $transcript) { - switch ($language) { - case "_allow": - $allow = true; - break; - default: - $this->what_did_they_say->save_transcript($info['post_id'], $language, $transcript); - break; - } - } + $approved_transcript_manager = new WDTSApprovedTranscript($info['post_id']); - $this->what_did_they_say->set_allow_transcripts_for_post($info['post_id'], isset($info['allow_on_post'])); - - $queued_transcriptions = $this->what_did_they_say->get_queued_transcriptions_for_post($info['post_id']); - if (is_array($queued_transcriptions)) { - $transcriptions_to_delete = array(); - - foreach ($queued_transcriptions as $transcription) { $transcriptions_to_delete[$transcription->id] = true; } - if (isset($post_transcript_info['queue'])) { - foreach ($post_transcript_info['queue'] as $id => $keep) { unset($transcriptions_to_delete[$id]); } - } - - foreach (array_keys($transcriptions_to_delete) as $id) { - $this->what_did_they_say->delete_queued_transcription($id); - } - } - - $updated = __('Transcripts updated.', 'what-did-they-say'); - break; + foreach ($info['transcripts'] as $language => $transcript) { + $approved_transcript_manager->save_transcript(array( + 'language' => $language, + 'transcript' => $transcript + )); } + + $transcript_options = new WDTSTranscriptOptions($info['post_id']); + $transcript_options->set_allow_transcripts(isset($info['allow_on_post'])); + + $queued_transcriptions = $this->what_did_they_say->get_queued_transcriptions_for_post($info['post_id']); + if (is_array($queued_transcriptions)) { + $transcriptions_to_delete = array(); + + foreach ($queued_transcriptions as $transcription) { $transcriptions_to_delete[$transcription->id] = true; } + if (isset($post_transcript_info['queue'])) { + foreach ($post_transcript_info['queue'] as $id => $keep) { unset($transcriptions_to_delete[$id]); } + } + + foreach (array_keys($transcriptions_to_delete) as $id) { + $this->what_did_they_say->delete_queued_transcription($id); + } + } + + $updated = __('Transcripts updated.', 'what-did-they-say'); + break; } return $updated; } @@ -422,9 +418,13 @@ class WhatDidTheySayAdmin { $options = get_option('what-did-they-say-options'); - $transcripts = $this->what_did_they_say->get_transcripts($post->ID); - $queued_transcriptions = $this->what_did_they_say->get_queued_transcriptions_for_post($post->ID); - + foreach (array('Approved', 'Queued') as $name) { + $var_name = strtolower($name); + $class_name = "WDTS${name}Transcript"; + ${"${var_name}_transcript_manager"} = new $class_name($post->ID); + ${"${var_name}_transcripts"} = ${"${var_name}_transcript_manager"}->get_transcripts(); + } + $nonce = wp_create_nonce('what-did-they-say'); include(dirname(__FILE__) . '/meta-box.inc'); } diff --git a/classes/meta-box.inc b/classes/meta-box.inc index ba43c70..46f55a6 100644 --- a/classes/meta-box.inc +++ b/classes/meta-box.inc @@ -1,5 +1,5 @@ - +

- +

- user_id); + user_id); if (!empty($user)) { ?>
- - + +

%s in %s:', 'what-did-they-say'), $user->display_name, - $this->what_did_they_say->get_language_name($transcription->language) + $this->what_did_they_say->get_language_name($transcript->language) ) ?>

-
transcript ?>
- +
transcript ?>
+
Approve Delete @@ -44,7 +44,7 @@ - +