big work on text and added automatic transcript embedding

This commit is contained in:
John Bintz 2009-09-23 22:38:11 -04:00
parent c34b93a030
commit c33591d747
6 changed files with 124 additions and 10 deletions

View File

@ -18,6 +18,7 @@ class WhatDidTheySayAdmin {
'change_languages' => 'administrator'
),
'load_default_styles' => true,
'automatic_embedding' => true,
'excerpt_distance' => 30
);
@ -65,6 +66,10 @@ class WhatDidTheySayAdmin {
add_filter('posts_where', array(&$this, 'posts_where'));
add_filter('posts_join', array(&$this, 'posts_join'));
if ($options['automatic_embedding']) {
add_filter('the_content', array(&$this, 'the_content_automatic_embedding'), 15);
}
if (isset($_REQUEST['wdts'])) {
if (isset($_REQUEST['wdts']['_nonce'])) {
@ -77,6 +82,16 @@ class WhatDidTheySayAdmin {
}
}
/**
* Attempt to automatically embed transcripts in posts.
*/
function the_content_automatic_embedding($content) {
ob_start();
transcripts_display();
the_media_transcript_queue_editor();
return $content . ob_get_clean();
}
/**
* Filter for WP_Query#get_posts to add searching for transcripts.
*/
@ -198,7 +213,7 @@ class WhatDidTheySayAdmin {
* @param string $transcript The transcription text.
* @return string The processed transcription text.
*/
function the_media_transcript($transcript, $output = "") {
function the_media_transcript($transcript, $content = "") {
return array($transcript, '<div class="transcript">' . do_shortcode($transcript) . '</div>');
}
@ -207,14 +222,14 @@ class WhatDidTheySayAdmin {
* @param string $language The name of the language.
* @return string The processed language name.
*/
function the_language_name($language, $output = "") {
function the_language_name($language, $content = "") {
return array($language, '<h3 class="transcript-language">' . $language . '</h3>');
}
/**
* Handle the_matching_transcript_excerpts.
*/
function the_matching_transcript_excerpts($transcripts, $search_string = '', $output = "") {
function the_matching_transcript_excerpts($transcripts, $search_string = '', $content = "") {
ob_start();
if (!empty($search_string)) {
$language_options = new WDTSLanguageOptions();

View File

@ -4,6 +4,8 @@
<input type="hidden" name="wdts[module]" value="capabilities" />
<h3><?php _e('Capabilities', 'what-did-they-say') ?></h3>
<p><?php _e('Determine who can do what with transcripts by setting the minimum role requirements below.', 'what-did-they-say') ?></p>
<table class="widefat fixed">
<tr class="thead">
<th scope="col" class="manage-col"><?php _e('Capability', 'what-did-they-say') ?></th>

View File

@ -1,6 +1,6 @@
<?php if (current_user_can('edit_themes')) { ?>
<?php if (is_array($options)) { ?>
<h3><?php _e('Transcript Style and DisplaySettings', 'what-did-they-say') ?></h3>
<h3><?php _e('Transcript Style and Display Settings', 'what-did-they-say') ?></h3>
<form method="post">
<input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
<input type="hidden" name="wdts[module]" value="styles" />
@ -21,8 +21,10 @@
</label>
<input class="button" type="submit" value="<?php _e('Change default styles', 'what-did-they-say') ?>" />
</form>
<hr />
<p><?php _e('By default, the following styles are used by <strong>What Did They Say?!?</strong>:', 'what-did-they-say') ?></p>
<h3><?php _e('Default CSS Selectors Information', 'what-did-they-say') ?></h3>
<p><?php _e('By default, the following CSS selectors are used by <strong>What Did They Say?!?</strong>:', 'what-did-they-say') ?></p>
<dl>
<dt><code>.transcript</code></dt>
<dd><?php _e('The container for the transcript', 'what-did-they-say') ?></dd>
@ -38,8 +40,42 @@
<dd><?php _e('Action within a scene', 'what-did-they-say') ?></dd>
</dl>
<p><?php _e('To include transcript excerpts in your search results, add the following template tag to your search results Loop:', 'what-did-they-say') ?></p>
<p><code>&lt;php the_matching_transcript_excerpts() ?&gt;</code></p>
<p><?php printf(__('The first matching word in each transcript will be <strong>emphasized</strong>, and there will be <strong>%d</strong> additional characters on each side of the word.', 'what-did-they-say'), $options['excerpt_distance']) ?></p>
<h3><?php _e('Overriding Filters', 'what-did-they-say') ?></h3>
<p>
<?php _e('If you want to override how transcript HTML is structured, create hooks in your theme that implement the following filters.', 'what-did-they-say') ?>
<?php _e('All of them return the same parameters that are passed in as an array(), with the return <code>$content</code> containing the filter output.', 'what-did-they-say') ?>
</p>
<dl>
<dt><code>filter_shortcode_dialog($name, $direction, $speech, $content)</code></dt>
<dd><?php _e('Output <code>$content</code> contains the HTML for dialog blocks.', 'what-did-they-say') ?></dd>
<dt><code>filter_shortcode_scene_action($description, $content)</code></dt>
<dd><?php _e('Output <code>$content</code> contains the HTML for scene action blocks.', 'what-did-they-say') ?></dd>
<dt><code>filter_shortcode_scene_heading($description, $content)</code></dt>
<dd><?php _e('Ouptut <code>$content</code> contains the HTML for scene heading blocks.', 'what-did-they-say') ?></dd>
<dt><code>the_media_transcript($transcript, $content)</code></dt>
<dd><?php _e('Output <code>$content</code> contains the HTML for a single transcript.', 'what-did-they-say') ?></dd>
<dt><code>the_language_name($language, $content)</code></dt>
<dd><?php _e('Output <code>$content</code> contains the HTML for a language name.', 'what-did-they-say') ?></dd>
<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>
<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') ?>
</p>
<pre>
function my_theme_the_language_name($language, $content) {
return array($language, "&lt;div class='language-name'&gt;${content}&lt;/div&gt;");
}
add_filter('the_language_name', 'my_theme_the_language_name', 15);</pre>
<?php } ?>
<?php } ?>

View File

@ -0,0 +1,56 @@
<?php if (current_user_can('submit_transcriptions')) { ?>
<h3><?php _e('Introduction', 'what-did-they-say') ?></h3>
<p>
<?php _e('<strong>What Did They Say?!?</strong> gives you great control over adding and managing transcripts for your comics, videos, or audio.', 'what-did-they-say') ?>
<?php _e('Adding transcripts to your posts gives you better search engine visibility and helps disabled users enjoy your content.', 'what-did-they-say') ?>
</p>
<h3><?php _e('Getting Started', 'what-did-they-say') ?></h3>
<p>
<?php _e('<strong>What Did They Say?!?</strong> can attempt to embed excerpts into your posts automatically:', 'what-did-they-say') ?>
<form method="post">
<input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
<input type="hidden" name="wdts[module]" value="automatic-transcripts" />
<label>
<input type="checkbox"
name="wdts[automatic_embedding]"
value="yes"
<?php echo $options['automatic_embedding'] ? 'checked="checked"' : '' ?> />
<?php _e('Enable automatic transcript embedding', 'what-did-they-say') ?>
</label>
<input type="submit" class="button" value="<?php _e('Submit', 'what-did-they-say') ?>" />
</form>
</p>
<p>
<?php _e('If the above method doesn\'t work or you desire more control, you can add the following Template Tags to the appropriate location in your posts Loop:', 'what-did-they-say') ?>
</p>
<pre>
&lt;?php
if (function_exists('transcripts_display') &&
function_exists('the_media_transcript_queue_editor')) {
transcripts_display(); the_media_transcript_queue_editor();
} ?&gt;</pre>
<h3><?php _e('Search Results', 'what-did-they-say') ?></h3>
<p>
<?php _e('When someone searches your site, <strong>What Did They Say?!?</strong> will search your transcripts, too.', 'what-did-they-say') ?>
<?php _e('If you want transcript excerpts to appear in your search results, add the following Template Tag to your search results Loop:', 'what-did-they-say') ?>
</p>
<pre>
&lt;php if (function_exists('the_matching_transcript_excerpts')) {
the_matching_transcript_excerpts();
} ?&gt;</pre>
<p>
<?php
$link = '<a href="#" onclick="make_active($(\'wdts-tab-default-styles\')); return false;">' . __('Styles', 'what-did-they-say') . '</a>';
printf(__('You can set the number of characters to show in context in search results on the %s page.', 'what-did-they-say'), $link);
?>
</p>
<?php } ?>

View File

@ -1,6 +1,10 @@
<?php if (current_user_can('submit_transcriptions')) { ?>
<h3><?php _e('Shortcodes Info', 'what-did-they-say') ?></h3>
<p>
<em>(<?php _e('you can easily use these shortcodes with the appropriate buttons above all transcript editors', 'what-did-they-say') ?>)</em>
</p>
<h4><?php _e('Sample Transcript', 'what-did-they-say') ?></h4>
<pre>
[scene-heading]Ext. The Old Man's House[/scene-heading]

View File

@ -1,10 +1,11 @@
<?php
$pages = array(
'introduction' => __('Introduction', 'what-did-they-say'),
'capabilities' => __('Capabilities', 'what-did-they-say'),
'default-styles' => __('Styles', 'what-did-they-say'),
'change-languages' => __('Languages', 'what-did-they-say'),
'shortcodes-info' => __('Shortcodes Info', 'what-did-they-say'),
'misc-options' => __('Misc. Options', 'what-did-they-say'),
'shortcodes-info' => __('Shortcodes Info', 'what-did-they-say')
);
extract($this->plugin_data);