From c12ed95806fa5986cad2ae90fb1650c4140fa62f Mon Sep 17 00:00:00 2001 From: John Bintz Date: Mon, 26 Oct 2009 19:29:46 -0400 Subject: [PATCH] break out transcript approval into separate test --- classes/WhatDidTheySayAdmin.inc | 23 +++- test/WhatDidTheySayAdminTest.php | 32 +++++ what-did-they-say.pot | 220 +++++++++++++++++++++---------- 3 files changed, 199 insertions(+), 76 deletions(-) diff --git a/classes/WhatDidTheySayAdmin.inc b/classes/WhatDidTheySayAdmin.inc index 8c43336..f8b37e4 100644 --- a/classes/WhatDidTheySayAdmin.inc +++ b/classes/WhatDidTheySayAdmin.inc @@ -762,6 +762,20 @@ class WhatDidTheySayAdmin { } } + /** + * Approve a transcript. + */ + function _approve_transcript($post_id, $key) { + $approved_transcript_manager = new WDTSApprovedTranscript($post_id); + $queued_transcript_manager = new WDTSQueuedTranscript($post_id); + + if (($transcript = $queued_transcript_manager->delete_transcript_by_key($key)) !== false) { + $approved_transcript_manager->save_transcript($transcript); + return true; + } + return false; + } + /** * Handle transcript approval. */ @@ -769,14 +783,9 @@ class WhatDidTheySayAdmin { $this->is_ajax = true; if (current_user_can('approve_transcriptions')) { - $approved_transcript_manager = new WDTSApprovedTranscript($info['post_id']); - $queued_transcript_manager = new WDTSQueuedTranscript($info['post_id']); - - if (($transcript = $queued_transcript_manager->delete_transcript_by_key($info['key'])) !== false) { - $approved_transcript_manager->save_transcript($transcript); - return; + if (!$this->_approve_transcript($info['post_id'], $info['key'])) { + header('HTTP/1.1 500 Internal Server Error'); } - header('HTTP/1.1 500 Internal Server Error'); return; } header('HTTP/1.1 401 Unauthorized'); diff --git a/test/WhatDidTheySayAdminTest.php b/test/WhatDidTheySayAdminTest.php index 3f15af7..8566854 100644 --- a/test/WhatDidTheySayAdminTest.php +++ b/test/WhatDidTheySayAdminTest.php @@ -172,6 +172,38 @@ class WhatDidTheySayAdminTest extends PHPUnit_Framework_TestCase { $this->assertEquals($expected_result, $admin->_clean_child($nodes)); } + + function testApproveTranscript() { + wp_insert_post(array('ID' => 1)); + update_post_meta(1, "queued_transcripts", array( + array( + 'language' => 'en', + 'transcript' => 'This is a test transcript', + 'user_id' => 5, + 'key' => 1 + ) + )); + + $admin = new WhatDidTheySayAdmin(); + + $this->assertTrue($admin->_approve_transcript(1, 1)); + + $this->assertEquals( + array( + array( + 'language' => 'en', + 'transcript' => 'This is a test transcript', + 'user_id' => 5, + 'key' => 0 + ) + ), + get_post_meta(1, "approved_transcripts", true) + ); + + $this->assertEquals( + array(), get_post_meta(1, "queued_transcripts", true) + ); + } } ?> \ No newline at end of file diff --git a/what-did-they-say.pot b/what-did-they-say.pot index a723a7b..a4acf60 100644 --- a/what-did-they-say.pot +++ b/what-did-they-say.pot @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: what-did-they-say 0.9.2\n" +"Project-Id-Version: what-did-they-say 0.9.3\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-10-14 22:03-0400\n" +"POT-Creation-Date: 2009-10-25 23:07-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -16,11 +16,16 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: what-did-they-say.php:218 +#: transcript-filters/comicpress/ComicPressTranscriptBasic.inc:33 +#: transcript-filters/comicpress/ComicPressTranscriptBasic.inc:34 +msgid "Transcript" +msgstr "" + +#: what-did-they-say.php:220 msgid "Edit/Add Transcripts" msgstr "" -#: what-did-they-say.php:221 +#: what-did-they-say.php:223 #, php-format msgid "%d queued" msgstr "" @@ -81,16 +86,20 @@ msgstr "" msgid "Edit Approved Transcripts:" msgstr "" -#: classes/partials/meta-box.inc:37 +#: classes/partials/meta-box.inc:37 classes/partials/import-transcripts.inc:23 #: classes/partials/_manage-queued-transcripts.inc:35 msgid "Language:" msgstr "" -#: classes/partials/meta-box.inc:54 +#: classes/partials/meta-box.inc:53 +msgid "User to credit: " +msgstr "" + +#: classes/partials/meta-box.inc:66 msgid "Update All Transcripts" msgstr "" -#: classes/partials/meta-box.inc:58 +#: classes/partials/meta-box.inc:70 msgid "" "Uh oh...there's a problem with automatic embedding. Enable "Inject " "transcripts at level 100 instead of level 15" on the What Did They " @@ -203,133 +212,137 @@ msgid "" msgstr "" #: classes/partials/_default-styles.inc:44 +msgid "Give credit to the transcriber on approved transcripts." +msgstr "" + +#: classes/partials/_default-styles.inc:52 msgid "" "Allow HTML in transcripts. If disabled, only short codes are allowed, which " "is recommended. Script, style, and link tags are " "always filtered out." msgstr "" -#: classes/partials/_default-styles.inc:47 +#: classes/partials/_default-styles.inc:55 msgid "By default, transcripts should start hidden on these types of pages:" msgstr "" -#: classes/partials/_default-styles.inc:55 +#: classes/partials/_default-styles.inc:63 msgid "On the home page" msgstr "" -#: classes/partials/_default-styles.inc:63 +#: classes/partials/_default-styles.inc:71 msgid "On individual post pages" msgstr "" -#: classes/partials/_default-styles.inc:69 +#: classes/partials/_default-styles.inc:77 msgid "Use the selected transcript filter set:" msgstr "" -#: classes/partials/_default-styles.inc:71 +#: classes/partials/_default-styles.inc:79 #: classes/partials/_change-languages.inc:19 msgid "(default)" msgstr "" -#: classes/partials/_default-styles.inc:82 +#: classes/partials/_default-styles.inc:90 msgid "" "(Hint: Use the above to preview your filters and style while you work on " "them! The previewer always includes the default stylesheet.)" msgstr "" -#: classes/partials/_default-styles.inc:84 +#: classes/partials/_default-styles.inc:92 msgid "Change default styles" msgstr "" -#: classes/partials/_default-styles.inc:87 +#: classes/partials/_default-styles.inc:95 msgid "Transcript Line Breaks" msgstr "" -#: classes/partials/_default-styles.inc:89 +#: classes/partials/_default-styles.inc:97 msgid "" "If you're using short codes or HTML to construct your transcripts, you don't " "need to enable transcript line breaks." msgstr "" -#: classes/partials/_default-styles.inc:91 +#: classes/partials/_default-styles.inc:99 msgid "Default CSS Selectors Information" msgstr "" -#: classes/partials/_default-styles.inc:93 +#: classes/partials/_default-styles.inc:101 msgid "" "By default, the following CSS selectors are used by What Did They " "Say?!?:" msgstr "" -#: classes/partials/_default-styles.inc:96 +#: classes/partials/_default-styles.inc:104 msgid "The container for the transcript" msgstr "" -#: classes/partials/_default-styles.inc:98 +#: classes/partials/_default-styles.inc:106 msgid "Character dialog" msgstr "" -#: classes/partials/_default-styles.inc:100 +#: classes/partials/_default-styles.inc:108 msgid "The character's name" msgstr "" -#: classes/partials/_default-styles.inc:102 +#: classes/partials/_default-styles.inc:110 msgid "" "The direction the characters is speaking in/from (off-stage, to another " "character)" msgstr "" -#: classes/partials/_default-styles.inc:104 +#: classes/partials/_default-styles.inc:112 msgid "A scene heading" msgstr "" -#: classes/partials/_default-styles.inc:106 +#: classes/partials/_default-styles.inc:114 msgid "Action within a scene" msgstr "" -#: classes/partials/_default-styles.inc:109 +#: classes/partials/_default-styles.inc:117 msgid "Overriding Filters" msgstr "" -#: classes/partials/_default-styles.inc:112 +#: classes/partials/_default-styles.inc:120 msgid "" "If you want to override how transcript HTML is structured, create hooks in " "your theme that implement the following filters." msgstr "" -#: classes/partials/_default-styles.inc:113 +#: classes/partials/_default-styles.inc:121 msgid "" "All of them return the same parameters that are passed in as an array(), " "with the return $content containing the filter output." msgstr "" -#: classes/partials/_default-styles.inc:118 +#: classes/partials/_default-styles.inc:126 msgid "Output $content contains the HTML for dialog blocks." msgstr "" -#: classes/partials/_default-styles.inc:121 +#: classes/partials/_default-styles.inc:129 msgid "Output $content contains the HTML for scene action blocks." msgstr "" -#: classes/partials/_default-styles.inc:124 +#: classes/partials/_default-styles.inc:132 msgid "" "Ouptut $content contains the HTML for scene heading blocks." msgstr "" -#: classes/partials/_default-styles.inc:127 +#: classes/partials/_default-styles.inc:135 msgid "Output $content contains the HTML for a single transcript." msgstr "" -#: classes/partials/_default-styles.inc:130 +#: classes/partials/_default-styles.inc:138 msgid "Output $content contains the HTML for a language name." msgstr "" -#: classes/partials/_default-styles.inc:133 +#: classes/partials/_default-styles.inc:141 msgid "" "Output $content contains the HTML for all the provided " "$transcripts that match $search_string." msgstr "" -#: classes/partials/_default-styles.inc:136 +#: classes/partials/_default-styles.inc:144 #, php-format msgid "" "Output $content contains the sprintf() format string for how " @@ -337,14 +350,14 @@ msgid "" "code>." msgstr "" -#: classes/partials/_default-styles.inc:139 +#: classes/partials/_default-styles.inc:147 msgid "" "Output $content contains three elements: a container (.wdts-" "transcript-opener), and an opener & closer in the container (.wdts-" "opener and .wdts-container)." msgstr "" -#: classes/partials/_default-styles.inc:143 +#: classes/partials/_default-styles.inc:151 msgid "" "A filter in your theme that would change the display of langauge names would " "look like the following:" @@ -446,6 +459,65 @@ msgid "" "the %s page." msgstr "" +#: classes/partials/import-transcripts.inc:4 +#: classes/WhatDidTheySayAdmin.inc:329 classes/WhatDidTheySayAdmin.inc:330 +msgid "Import Transcripts" +msgstr "" + +#: classes/partials/import-transcripts.inc:6 +msgid "" +"Import transcripts from your current setup into What Did They Say?!?" +"" +msgstr "" + +#: classes/partials/import-transcripts.inc:7 +msgid "" +"Currently, the import supports pulling transcripts from the "" +"transcript" metadata field." +msgstr "" + +#: classes/partials/import-transcripts.inc:8 +msgid "" +"This field is used by some webcomic themes to store and display transcripts." +msgstr "" + +#: classes/partials/import-transcripts.inc:12 +msgid "You have no legacy transcripts!" +msgstr "" + +#: classes/partials/import-transcripts.inc:16 +#, php-format +msgid "" +"You have %d legacy transcripts.What Did They Say?!?" +msgstr "" + +#: classes/partials/import-transcripts.inc:17 +msgid "Make sure you've backed up your database first!" +msgstr "" + +#: classes/partials/import-transcripts.inc:18 +msgid "" +"This will also overwrite any WDTS? transcripts that are already in " +"the chosen language for each modified post!" +msgstr "" + +#: classes/partials/import-transcripts.inc:32 +msgid "Import transcripts" +msgstr "" + +#: classes/partials/import-transcripts.inc:51 +msgid "imported..." +msgstr "" + +#: classes/partials/import-transcripts.inc:66 +msgid "There was a problem during import!" +msgstr "" + +#: classes/partials/import-transcripts.inc:73 +msgid "Import complete! Total number imported:" +msgstr "" + #: classes/partials/_change-languages.inc:3 classes/partials/admin.inc:7 msgid "Languages" msgstr "" @@ -508,7 +580,7 @@ msgid "Misc. Options" msgstr "" #: classes/partials/admin.inc:15 classes/partials/admin.inc:51 -#: classes/WhatDidTheySayAdmin.inc:311 classes/WhatDidTheySayAdmin.inc:312 +#: classes/WhatDidTheySayAdmin.inc:319 classes/WhatDidTheySayAdmin.inc:320 msgid "What Did They Say?!?" msgstr "" @@ -785,33 +857,33 @@ msgstr "" msgid "Hey, where are the keys?" msgstr "" -#: classes/WhatDidTheySayAdmin.inc:66 +#: classes/WhatDidTheySayAdmin.inc:64 msgid "Submit transcriptions to a post" msgstr "" -#: classes/WhatDidTheySayAdmin.inc:67 +#: classes/WhatDidTheySayAdmin.inc:65 msgid "Approve transcriptions to a post" msgstr "" -#: classes/WhatDidTheySayAdmin.inc:68 +#: classes/WhatDidTheySayAdmin.inc:66 msgid "Change the available languages" msgstr "" -#: classes/WhatDidTheySayAdmin.inc:177 +#: classes/WhatDidTheySayAdmin.inc:185 msgid "What Did They Say?!? Transcript" msgstr "" -#: classes/WhatDidTheySayAdmin.inc:177 +#: classes/WhatDidTheySayAdmin.inc:185 msgid "Show the transcript for the current post." msgstr "" -#: classes/WhatDidTheySayAdmin.inc:326 +#: classes/WhatDidTheySayAdmin.inc:345 msgid "" "Welcome to What Did They Say?!? To get started, read the " "Introduction, and then How It Works." msgstr "" -#: classes/WhatDidTheySayAdmin.inc:328 +#: classes/WhatDidTheySayAdmin.inc:347 msgid "" "Is What Did They Say?!? working out for you? Let John know " "via email (@JohnBintz)." msgstr "" -#: classes/WhatDidTheySayAdmin.inc:349 +#: classes/WhatDidTheySayAdmin.inc:372 msgid "Manage Transcripts" msgstr "" -#: classes/WhatDidTheySayAdmin.inc:393 -msgid "Trans" +#: classes/WhatDidTheySayAdmin.inc:416 +msgid "" +"   " msgstr "" -#: classes/WhatDidTheySayAdmin.inc:406 -#, php-format -msgid "%s queued" +#: classes/WhatDidTheySayAdmin.inc:426 +msgid "Queued" msgstr "" -#: classes/WhatDidTheySayAdmin.inc:599 +#: classes/WhatDidTheySayAdmin.inc:426 +msgid "Approved" +msgstr "" + +#: classes/WhatDidTheySayAdmin.inc:664 msgid "Transcript added to queue." msgstr "" -#: classes/WhatDidTheySayAdmin.inc:601 +#: classes/WhatDidTheySayAdmin.inc:666 msgid "Transcript not added to queue." msgstr "" -#: classes/WhatDidTheySayAdmin.inc:677 +#: classes/WhatDidTheySayAdmin.inc:753 msgid "Transcripts updated." msgstr "" -#: classes/WhatDidTheySayAdmin.inc:746 +#: classes/WhatDidTheySayAdmin.inc:822 msgid "Default styles option updated." msgstr "" -#: classes/WhatDidTheySayAdmin.inc:762 +#: classes/WhatDidTheySayAdmin.inc:838 msgid "Insertion level updated." msgstr "" -#: classes/WhatDidTheySayAdmin.inc:780 +#: classes/WhatDidTheySayAdmin.inc:856 #, php-format msgid "%s deleted." msgstr "" -#: classes/WhatDidTheySayAdmin.inc:782 +#: classes/WhatDidTheySayAdmin.inc:858 msgid "Language not deleted!" msgstr "" -#: classes/WhatDidTheySayAdmin.inc:789 +#: classes/WhatDidTheySayAdmin.inc:865 #, php-format msgid "%s added." msgstr "" -#: classes/WhatDidTheySayAdmin.inc:791 +#: classes/WhatDidTheySayAdmin.inc:867 msgid "Language not added!" msgstr "" -#: classes/WhatDidTheySayAdmin.inc:797 +#: classes/WhatDidTheySayAdmin.inc:873 #, php-format msgid "%s set as default." msgstr "" -#: classes/WhatDidTheySayAdmin.inc:799 +#: classes/WhatDidTheySayAdmin.inc:875 msgid "Language not set as default!" msgstr "" -#: classes/WhatDidTheySayAdmin.inc:805 +#: classes/WhatDidTheySayAdmin.inc:881 #, php-format msgid "%1$s renamed to %2$s." msgstr "" -#: classes/WhatDidTheySayAdmin.inc:807 +#: classes/WhatDidTheySayAdmin.inc:883 msgid "Language not renamed!" msgstr "" -#: classes/WhatDidTheySayAdmin.inc:830 +#: classes/WhatDidTheySayAdmin.inc:906 msgid "User capabilities updated." msgstr "" -#: classes/WhatDidTheySayAdmin.inc:867 +#: classes/WhatDidTheySayAdmin.inc:931 msgid "Per-user permissions updated." msgstr "" -#: classes/WhatDidTheySayAdmin.inc:882 +#: classes/WhatDidTheySayAdmin.inc:960 msgid "What Did They Say?!? options reset." msgstr "" -#: classes/WhatDidTheySayAdmin.inc:901 +#: classes/WhatDidTheySayAdmin.inc:979 msgid "What Did They Say?!? core options changed." msgstr "" -#: classes/WDTSDisplayFilters.inc:52 +#: classes/WDTSDisplayFilters.inc:27 +#, php-format +msgid "Written by %1$s %2$s" +msgstr "" + +#: classes/WDTSDisplayFilters.inc:69 #, php-format msgid "Transcript: %s" msgstr "" -#: classes/WDTSDisplayFilters.inc:81 +#: classes/WDTSDisplayFilters.inc:98 #, php-format msgid "%s transcript excerpt:" msgstr ""