a bunch of ui cleanups

This commit is contained in:
John Bintz 2009-10-02 07:41:12 -04:00
parent e04a261992
commit 693a01d7e6
4 changed files with 67 additions and 30 deletions

View File

@ -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, '<h3 class="wdts-transcript-language">' . $language . '</h3>');
return array($language, '<h3 class="wdts-transcript-language">' . sprintf(apply_filters('the_transcript_format_string'), $language) . '</h3>');
}
/**
* 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[] = '<select>';
foreach ($transcripts as $code => $transcript) {
$dropdown[] = '<option value="' . $code . '"' . (($code == $default_language) ? ' selected="selected"' : '') . '>'
. get_the_language_name($code)
. '</option>';
}
$dropdown[] = '</select>';
$content = implode("", $dropdown);
}
if (is_null($language_format)) { $language_format = apply_filters('the_transcript_format_string', ''); }
return '<h3 class="wdts-transcript-language">' . sprintf($language_format, $content) . '</h3>';
}
/**
* 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');
}
/**

View File

@ -77,7 +77,10 @@
<dt><code>the_matching_transcript_excerpts($transcripts, $search_string, $content)</code></dt>
<dd><?php _e('Output <code>$content</code> contains the HTML for all the provided <code>$transcripts</code> that match <code>$search_string</code>.', 'what-did-they-say') ?></dd>
</dl>
<dt><code>the_transcript_format_string($content)</code></dt>
<dd><?php _e('Output <code>$content</code> contains the sprintf() format string for how transcript headers will be spelled. The default is <code>Transcript: %s</code>.', 'what-did-they-say') ?></dd>
</dl>
<p>
<?php _e('A filter in your theme that would change the display of langauge names would look like the following:', 'what-did-they-say') ?>

View File

@ -1,7 +1,7 @@
div.wdts-transcript {
border: solid #333 1px;
padding: 0.5em;
margin: 0.5empx;
margin: 0.5em;
background-color: #e7e7e7
}

View File

@ -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[] = '<div class="transcript-bundle">';
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[] = '<select>';
foreach($transcripts as $code => $transcript) {
$output[] = '<option value="' . $code . '"' . (($code == $default_language) ? ' selected="selected"' : '') . '>'
. get_the_language_name($code)
. '</option>';
}
$output[] = '</select>';
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[] = '<div '
. (($code == $default_language) ? 'style="display:none"' : '')
. ' class="transcript-holder ' . $code . '">' . $language_name . $transcript . '</div>';
}
$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[] = '<div '
. (($code == $default_language) ? 'style="display:none"' : '')
. ' class="transcript-holder ' . $code . '">' . $language_name . $transcript . '</div>';
}
$output[] = '</div>';
}
@ -213,8 +197,23 @@ function the_media_transcript_queue_editor() {
$new_transcript_id = md5(rand());
?>
<h3 class="wdts"><?php _e('Manage Transcripts:', 'what-did-they-say') ?></h3>
<?php include(dirname(__FILE__) . '/classes/partials/meta-box.inc') ?>
<p>[ <a id="wdts-opener-<?php echo $id = md5(rand()) ?>" href="#"><?php _e('Edit/Add Transcripts', 'what-did-they-say') ?></a> ]</p>
<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 ?>').observe('click', function(e) {
Event.stop(e);
var target = $('wdts-<?php echo $id ?>');
if (target.visible()) {
new Effect.BlindUp(target, { duration: 0.25 });
} else {
new Effect.BlindDown(target, { duration: 0.25 });
}
});
</script>
<?php }
}