From c5b70935fc25128a6dced67440050775f6c0b846 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Tue, 13 Oct 2009 22:30:50 -0400 Subject: [PATCH] transcript previewing, thank you iframe --- classes/WhatDidTheySayAdmin.inc | 38 +++++++++++++++++--- classes/partials/_default-styles.inc | 4 ++- classes/partials/_sample-transcript.inc | 8 +++++ classes/partials/_shortcodes-info.inc | 5 +-- classes/partials/_show-sample-transcript.inc | 12 +++++++ classes/partials/admin.inc | 13 +++++++ 6 files changed, 70 insertions(+), 10 deletions(-) create mode 100644 classes/partials/_sample-transcript.inc create mode 100644 classes/partials/_show-sample-transcript.inc diff --git a/classes/WhatDidTheySayAdmin.inc b/classes/WhatDidTheySayAdmin.inc index 578f44d..f99f67e 100644 --- a/classes/WhatDidTheySayAdmin.inc +++ b/classes/WhatDidTheySayAdmin.inc @@ -92,8 +92,18 @@ class WhatDidTheySayAdmin { $filters = new WDTSDisplayFilters(); $reset_filter_value = true; - if (is_string($options['filters_to_use'])) { - $target = $this->get_filters_dir() . '/' . preg_replace('#[^a-z0-9_-]#', '', strtolower($options['filters_to_use'])); + $filter_to_use = false; + if (is_string($options['filters_to_use'])) { $filter_to_use = $options['filters_to_use']; } + if (current_user_can('submit_transcriptions')) { + if (isset($_REQUEST['wdts'])) { + if (isset($_REQUEST['wdts']['filter_preview'])) { + $filter_to_use = $_REQUEST['wdts']['filter_preview']; + } + } + } + + if ($filter_to_use) { + $target = $this->get_filters_dir() . '/' . preg_replace('#[^a-z0-9_-]#', '', strtolower($filter_to_use)); if (is_dir($target)) { $this->override_filter_info = array(); foreach (glob($target . '/*') as $file) { @@ -113,6 +123,7 @@ class WhatDidTheySayAdmin { } } + // short codes foreach (array( array('the_media_transcript', 2), array('the_language_name', 2), @@ -132,7 +143,6 @@ class WhatDidTheySayAdmin { } } - // short codes foreach (get_class_methods($this) as $method) { if (strpos($method, "shortcode_") === 0) { $shortcode_name = str_replace("_", "-", str_replace("shortcode_", "", $method)); @@ -167,7 +177,23 @@ class WhatDidTheySayAdmin { include('partials/_editor-script.inc'); exit(0); } - + + if (isset($_REQUEST['wdts']['filter_preview'])) { + $styles_to_include = array( + plugin_dir_url(dirname(__FILE__)) . 'css/wdts-defaults.css' + ); + + if (isset($this->override_filter_info['css'])) { + if (($path = realpath($this->override_filter_info['css'])) !== false) { + $styles_to_include[] = str_replace(realpath($this->_get_abspath()), '', $path); + } + } + + include('partials/_sample-transcript.inc'); + include('partials/_show-sample-transcript.inc'); + exit(0); + } + if (isset($_REQUEST['wdts']['_nonce'])) { if (wp_verify_nonce($_REQUEST['wdts']['_nonce'], 'what-did-they-say')) { if (($_REQUEST['wdts']['post_id'] <= 0) && ($_POST['post_ID'] > 0)) { @@ -231,7 +257,9 @@ class WhatDidTheySayAdmin { } if (isset($this->override_filter_info['css'])) { - wp_enqueue_style('wdts-override', str_replace(realpath($this->_get_abspath()), '', realpath($this->override_filter_info['css']))); + if (($path = realpath($this->override_filter_info['css'])) !== false) { + wp_enqueue_style('wdts-override', str_replace(realpath($this->_get_abspath()), '', $path)); + } } if ($options['transcript_effects']) { diff --git a/classes/partials/_default-styles.inc b/classes/partials/_default-styles.inc index 3f0d6d6..8259109 100644 --- a/classes/partials/_default-styles.inc +++ b/classes/partials/_default-styles.inc @@ -67,7 +67,7 @@ + +
diff --git a/classes/partials/_sample-transcript.inc b/classes/partials/_sample-transcript.inc new file mode 100644 index 0000000..ac01e5c --- /dev/null +++ b/classes/partials/_sample-transcript.inc @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/classes/partials/_shortcodes-info.inc b/classes/partials/_shortcodes-info.inc index 48e5bb6..057ce2a 100644 --- a/classes/partials/_shortcodes-info.inc +++ b/classes/partials/_shortcodes-info.inc @@ -1,9 +1,6 @@ diff --git a/classes/partials/_show-sample-transcript.inc b/classes/partials/_show-sample-transcript.inc new file mode 100644 index 0000000..05152a0 --- /dev/null +++ b/classes/partials/_show-sample-transcript.inc @@ -0,0 +1,12 @@ + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/classes/partials/admin.inc b/classes/partials/admin.inc index 687cd82..a901f4a 100644 --- a/classes/partials/admin.inc +++ b/classes/partials/admin.inc @@ -97,6 +97,19 @@ }); }); + var iframe_url = ''; + + var load_sample_transcript = function() { + var which = $('wdts-filters-to-use').options[$('wdts-filters-to-use').selectedIndex].value; + $('wdts-sample-transcript-holder').innerHTML = ''; + var iframe = new Element('iframe', { width: "100%", height: "200px", src: iframe_url + '?wdts[filter_preview]=' + which }); + $('wdts-sample-transcript-holder').insert(iframe); + }; + + $('wdts-filters-to-use').observe('change', load_sample_transcript); + + Event.observe(window, 'load', load_sample_transcript); + make_active($(''));