From 693a01d7e6c93d4429106abaed08a2de67514702 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 2 Oct 2009 07:41:12 -0400 Subject: [PATCH] a bunch of ui cleanups --- classes/WhatDidTheySayAdmin.inc | 37 ++++++++++++++++++- classes/partials/_default-styles.inc | 5 ++- css/wdts-defaults.css | 2 +- what-did-they-say.php | 53 ++++++++++++++-------------- 4 files changed, 67 insertions(+), 30 deletions(-) diff --git a/classes/WhatDidTheySayAdmin.inc b/classes/WhatDidTheySayAdmin.inc index d6b5249..272cb74 100644 --- a/classes/WhatDidTheySayAdmin.inc +++ b/classes/WhatDidTheySayAdmin.inc @@ -71,6 +71,8 @@ class WhatDidTheySayAdmin { add_filter('the_media_transcript', array(&$this, 'the_media_transcript'), 10, 2); add_filter('the_language_name', array(&$this, 'the_language_name'), 10, 2); add_filter('the_matching_transcript_excerpts', array(&$this, 'the_matching_transcript_excerpts'), 10, 3); + add_filter('the_multiple_transcript_language_name', array(&$this, 'the_multiple_transcript_language_name'), 10, 3); + add_filter('the_transcript_format_string', array(&$this, 'the_transcript_format_string'), 10); add_filter('template_redirect', array(&$this, 'template_redirect')); @@ -250,7 +252,40 @@ class WhatDidTheySayAdmin { * @return string The processed language name. */ function the_language_name($language, $content = "") { - return array($language, '

' . $language . '

'); + return array($language, '

' . sprintf(apply_filters('the_transcript_format_string'), $language) . '

'); + } + + /** + * Handle showing the header above a bundle of live transcripts. + */ + function the_multiple_transcript_language_name($language_format, $transcripts, $content) { + if (count($transcripts) == 1) { + $content = get_the_language_name(reset(array_keys($transcripts))); + } else { + $dropdown = array(); + + $dropdown[] = ''; + + $content = implode("", $dropdown); + } + + if (is_null($language_format)) { $language_format = apply_filters('the_transcript_format_string', ''); } + + return '

' . sprintf($language_format, $content) . '

'; + + } + + /** + * The format string used to display ither a single or multiple language transcript header. + */ + function the_transcript_format_string($content) { + return __('Transcript: %s', 'what-did-they-say'); } /** diff --git a/classes/partials/_default-styles.inc b/classes/partials/_default-styles.inc index f7c97a5..16321be 100644 --- a/classes/partials/_default-styles.inc +++ b/classes/partials/_default-styles.inc @@ -77,7 +77,10 @@
the_matching_transcript_excerpts($transcripts, $search_string, $content)
$content contains the HTML for all the provided $transcripts that match $search_string.', 'what-did-they-say') ?>
- + +
the_transcript_format_string($content)
+
$content contains the sprintf() format string for how transcript headers will be spelled. The default is Transcript: %s.', 'what-did-they-say') ?>
+

diff --git a/css/wdts-defaults.css b/css/wdts-defaults.css index 5bd82a6..6d6c6a9 100644 --- a/css/wdts-defaults.css +++ b/css/wdts-defaults.css @@ -1,7 +1,7 @@ div.wdts-transcript { border: solid #333 1px; padding: 0.5em; - margin: 0.5empx; + margin: 0.5em; background-color: #e7e7e7 } diff --git a/what-did-they-say.php b/what-did-they-say.php index cf5a282..c5d1357 100644 --- a/what-did-they-say.php +++ b/what-did-they-say.php @@ -122,12 +122,9 @@ function the_language_name($language = null) { * @param string $dropdown_message If set, the text that appears to the left of the language dropdown. * @param string $single_language_message If set, the text that appears when only one transcript exists for this post. */ -function transcripts_display($dropdown_message = null, $single_language_message = null) { +function transcripts_display($language_format = null) { global $post; - if (is_null($dropdown_message)) { $dropdown_message = __('Select a language:', 'what-did-they-say'); } - if (is_null($single_language_message)) { $single_language_message = __('%s transcript:', 'what-did-they-say'); } - $output = array(); $transcripts = array(); @@ -150,28 +147,15 @@ function transcripts_display($dropdown_message = null, $single_language_message $default_language = $language_options->get_default_language(); $output[] = '

'; - - if (count($transcripts) == 1) { - list($code, $transcript) = each($transcripts); - $output[] = end(apply_filters('the_language_name', get_the_language_name($code))); - $output[] = end(apply_filters('the_media_transcript', $transcript)); - } else { - $output[] = $dropdown_message; - $output[] = ''; - foreach ($transcripts as $code => $transcript) { - $language_name = end(apply_filters('the_language_name', get_the_language_name($code))); - $transcript = end(apply_filters('the_media_transcript', $transcript)); - $output[] = '
' . $language_name . $transcript . '
'; - } + $output[] = apply_filters('the_multiple_transcript_language_name', $language_format, $transcripts, ''); + + foreach ($transcripts as $code => $transcript) { + $transcript = end(apply_filters('the_media_transcript', $transcript)); + + $output[] = '
' . $language_name . $transcript . '
'; } $output[] = '
'; } @@ -213,8 +197,23 @@ function the_media_transcript_queue_editor() { $new_transcript_id = md5(rand()); ?> -

- +

[ ]

+ +