what-did-they-say/classes/WhatDidTheySay.php

75 lines
2.2 KiB
PHP
Raw Normal View History

2009-08-09 16:39:52 +00:00
<?php
/**
* WhatDidTheySay manages transcriptions that are attached as metadata
* individual posts. Transcriptions can be updated, deleted, and moved to
* other posts as necessary.
*/
class WhatDidTheySay {
2009-08-19 23:58:24 +00:00
/**
* Constructor.
*/
function WhatDidTheySay() {}
2009-08-19 23:58:24 +00:00
/**
* Get the default transcript language for this blog.
* @return string The language code representing the default language.
*/
2009-08-16 18:14:07 +00:00
function get_default_language() {
$language = false;
$options = get_option('what-did-they-say-options');
foreach ($options['languages'] as $code => $info) {
if (is_null($language)) { $language = $code; }
if ($info['default']) { $language = $code; break; }
}
return $language;
}
2009-08-19 23:58:24 +00:00
/**
* Get the name of a language from the language code.
* @param string $language The language code to search for.
* @return string|false The name of the language as defined in the options, or false if the language was not found.
*/
2009-08-16 18:14:07 +00:00
function get_language_name($language) {
$options = get_option('what-did-they-say-options');
if (isset($options['languages'][$language])) {
return $options['languages'][$language]['name'];
} else {
return false;
}
}
2009-08-19 23:58:24 +00:00
/**
* Get all available languages.
* @return array An array of languages.
*/
2009-08-16 20:54:11 +00:00
function get_languages() {
$options = get_option('what-did-they-say-options');
return $options['languages'];
}
2009-08-19 02:33:59 +00:00
2009-08-19 23:58:24 +00:00
/**
* Set whether or not the indicated post can accept new queued transcriptions.
* @param int $post_id The post ID to affect.
* @param boolean $allow True if the post can accept new queued transcriptions.
*/
2009-08-19 02:33:59 +00:00
function set_allow_transcripts_for_post($post_id, $allow = true) {
$current_transcripts = get_post_meta($post_id, "provided_transcripts", true);
$current_transcripts['_allow'] = $allow;
update_post_meta($post_id, "provided_transcripts", $current_transcripts);
}
2009-08-19 23:58:24 +00:00
/**
* See if the indicated post is accepting new transcripts.
* @return boolean True if the post is acceptin new transcripts.
*/
2009-08-19 02:33:59 +00:00
function get_allow_transcripts_for_post($post_id) {
$current_transcripts = get_post_meta($post_id, "provided_transcripts", true);
return $current_transcripts['_allow'];
}
2009-08-09 16:39:52 +00:00
}
?>