2009-08-12 23:51:23 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class WhatDidTheySayAdmin {
|
2009-08-13 16:37:33 +00:00
|
|
|
var $default_languages = array(
|
2009-08-13 17:12:10 +00:00
|
|
|
array('code' => 'en', 'default' => true),
|
|
|
|
'fr',
|
|
|
|
'es',
|
|
|
|
'it',
|
|
|
|
'de'
|
2009-08-13 16:37:33 +00:00
|
|
|
);
|
|
|
|
|
2009-08-13 17:12:10 +00:00
|
|
|
var $language_file;
|
|
|
|
var $all_languages = array();
|
|
|
|
|
2009-08-12 23:51:23 +00:00
|
|
|
function WhatDidTheySayAdmin() {
|
2009-08-13 17:12:10 +00:00
|
|
|
$this->language_file = dirname(__FILE__) . '/../data/lsr-language.txt';
|
2009-08-12 23:51:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function init($what_did_they_say) {
|
|
|
|
$this->what_did_they_say = $what_did_they_say;
|
|
|
|
|
|
|
|
add_action('admin_menu', array(&$this, 'admin_menu'));
|
|
|
|
|
|
|
|
if (isset($_POST['wdts'])) {
|
|
|
|
if (isset($_POST['wdts']['_nonce'])) {
|
|
|
|
if (wp_verify_nonce('what-did-they-say', $_POST['wdts']['_nonce'])) {
|
|
|
|
$this->handle_update($_POST['wdts']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-08-13 16:37:33 +00:00
|
|
|
|
2009-08-13 17:12:10 +00:00
|
|
|
function handle_update_languages($language_info) {
|
|
|
|
$languages = array();
|
|
|
|
foreach ($language_info as $code => $info) {
|
|
|
|
if (isset($this->all_languages[$code])) {
|
|
|
|
$language = $code;
|
|
|
|
if (isset($info['default'])) { $language = array('code' => $code, 'default' => true); }
|
|
|
|
$languages[] = $language;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
update_option('what-did-they-say-languages', $languages);
|
|
|
|
}
|
|
|
|
|
|
|
|
function read_language_file() {
|
|
|
|
if (file_exists($this->language_file)) {
|
|
|
|
foreach (file($this->language_file, FILE_IGNORE_NEW_LINES) as $language) {
|
|
|
|
list($code, $date_added, $name, $additional) = explode("\t", $language);
|
|
|
|
$this->all_languages[$code] = $name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->all_languages;
|
|
|
|
}
|
|
|
|
|
2009-08-13 16:37:33 +00:00
|
|
|
function install() {
|
|
|
|
$languages = get_option('what-did-they-say-languages');
|
|
|
|
if (empty($languages)) {
|
|
|
|
update_option('what-did-they-say-languages', $this->default_languages);
|
|
|
|
}
|
|
|
|
}
|
2009-08-12 23:51:23 +00:00
|
|
|
|
|
|
|
function admin_menu() {
|
|
|
|
add_submenu_page(
|
|
|
|
'edit-comments.php',
|
|
|
|
__('Manage Transcriptions', 'what-did-they-say'),
|
|
|
|
__('Transcripts', 'what-did-they-say'),
|
|
|
|
'edit_posts',
|
|
|
|
'manage-transcriptions-wdts',
|
|
|
|
array(&$this, 'manage_transcriptions_admin')
|
|
|
|
);
|
|
|
|
|
|
|
|
if (current_user_can('edit_posts')) {
|
|
|
|
add_meta_box(
|
|
|
|
'manage-transcriptions',
|
|
|
|
__('Manage Transcriptions', 'what-did-they-say'),
|
|
|
|
array(&$this, 'manage_transcriptions_meta_box'),
|
|
|
|
'post',
|
|
|
|
'normal',
|
|
|
|
'low'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function manage_transcriptions_admin() {
|
2009-08-13 16:37:33 +00:00
|
|
|
$languages = get_option('what-did-they-say-languages');
|
2009-08-12 23:51:23 +00:00
|
|
|
|
2009-08-13 16:37:33 +00:00
|
|
|
include(dirname(__FILE__) . '/admin.inc');
|
2009-08-12 23:51:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function manage_transcriptions_meta_box() {
|
2009-08-13 16:37:33 +00:00
|
|
|
global $post;
|
2009-08-12 23:51:23 +00:00
|
|
|
|
2009-08-13 16:37:33 +00:00
|
|
|
var_dump($post->ID);
|
2009-08-12 23:51:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function handle_update($info) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|