basic transcription saving working

This commit is contained in:
John Bintz 2009-08-16 12:40:54 -04:00
parent f962cc2436
commit 3a0d0572d5
2 changed files with 74 additions and 48 deletions

View File

@ -84,7 +84,7 @@ class WhatDidTheySayAdmin {
function admin_notices() { function admin_notices() {
if (!empty($this->notices)) { if (!empty($this->notices)) {
echo '<div class="updated fade">'; echo '<div class="updated fade">';
echo implode("<br />", $this->notices); foreach ($this->notices as $notice) { echo "<p>" . $notice . "</p>"; }
echo '</div>'; echo '</div>';
} }
} }
@ -98,63 +98,88 @@ class WhatDidTheySayAdmin {
} }
} }
function handle_update_languages($language_info) { function handle_update_post_transcripts($post_transcript_info) {
$options = get_option('what-did-they-say-options');
$updated = false; $updated = false;
switch ($language_info['action']) { if (current_user_can('approve_transcriptions')) {
case "delete": $options = get_option('what-did-they-say-options');
$updated = sprintf(__('%s deleted.', 'what-did-they-say'), $options['languages'][$language_info['code']]['name']);
unset($options['languages'][$language_info['code']]); switch ($post_transcript_info['action']) {
break; case "manage_post_transcripts":
case "add": foreach ($post_transcript_info['transcripts'] as $language => $transcript) {
$this->read_language_file(); $this->what_did_they_say->save_transcript($post_transcript_info['post_id'], $language, $transcript);
if (isset($this->all_languages[$language_info['code']])) { }
$options['languages'][$language_info['code']] = array('name' => $this->all_languages[$language_info['code']]); $updated = __('Transcripts updated', 'what-did-they-say');
$updated = sprintf(__('%s added.', 'what-did-they-say'), $this->all_languages[$language_info['code']]); break;
} }
break; }
case "default": return $updated;
if (isset($options['languages'][$language_info['code']])) { }
foreach ($options['languages'] as $code => $info) {
if ($code == $language_info['code']) { function handle_update_languages($language_info) {
$options['languages'][$code]['default'] = true; $updated = false;
$updated = sprintf(__('%s set as default.', 'what-did-they-say'), $info['name']); if (current_user_can('change_languages')) {
} else { $options = get_option('what-did-they-say-options');
unset($options['languages'][$code]['default']); switch ($language_info['action']) {
case "delete":
$updated = sprintf(__('%s deleted.', 'what-did-they-say'), $options['languages'][$language_info['code']]['name']);
unset($options['languages'][$language_info['code']]);
break;
case "add":
$this->read_language_file();
if (isset($this->all_languages[$language_info['code']])) {
$options['languages'][$language_info['code']] = array('name' => $this->all_languages[$language_info['code']]);
$updated = sprintf(__('%s added.', 'what-did-they-say'), $this->all_languages[$language_info['code']]);
}
break;
case "default":
if (isset($options['languages'][$language_info['code']])) {
foreach ($options['languages'] as $code => $info) {
if ($code == $language_info['code']) {
$options['languages'][$code]['default'] = true;
$updated = sprintf(__('%s set as default.', 'what-did-they-say'), $info['name']);
} else {
unset($options['languages'][$code]['default']);
}
} }
} }
} break;
break; case "rename":
case "rename": if (isset($options['languages'][$language_info['code']])) {
if (isset($options['languages'][$language_info['code']])) { if (!empty($language_info['name'])) {
if (!empty($language_info['name'])) { $updated = sprintf(__('%1$s renamed to %2$s.', 'what-did-they-say'), $options['languages'][$language_info['code']]['name'], $language_info['name']);
$updated = sprintf(__('%1$s renamed to %2$s.', 'what-did-they-say'), $options['languages'][$language_info['code']]['name'], $language_info['name']); $options['languages'][$language_info['code']]['name'] = $language_info['name'];
$options['languages'][$language_info['code']]['name'] = $language_info['name']; }
} }
} break;
break; }
} if ($updated !== false) {
ksort($options['languages']); ksort($options['languages']);
update_option('what-did-they-say-options', $options); update_option('what-did-they-say-options', $options);
}
}
return $updated; return $updated;
} }
function handle_update_capabilities($capabilities_info) { function handle_update_capabilities($capabilities_info) {
$options = get_option('what-did-they-say-options');
$updated = false; $updated = false;
switch ($capabilities_info['action']) { if (current_user_can('edit_users')) {
case "capabilities": $options = get_option('what-did-they-say-options');
if (isset($capabilities_info['capabilities'])) { switch ($capabilities_info['action']) {
foreach (array_keys($this->default_options['capabilities']) as $capability) { case "capabilities":
if (isset($capabilities_info['capabilities'][$capability])) { if (isset($capabilities_info['capabilities'])) {
$options['capabilities'][$capability] = $capabilities_info['capabilities'][$capability]; foreach (array_keys($this->default_options['capabilities']) as $capability) {
if (isset($capabilities_info['capabilities'][$capability])) {
$options['capabilities'][$capability] = $capabilities_info['capabilities'][$capability];
}
} }
$updated = __('User capabilities updated', 'what-did-they-say');
} }
$updated = __('User capabilities updated', 'what-did-they-say'); break;
} }
break; if ($updated !== false) {
update_option('what-did-they-say-options', $options);
}
} }
update_option('what-did-they-say-options', $options);
return $updated; return $updated;
} }

View File

@ -1,5 +1,6 @@
<iuput type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" /> <input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
<iuput type="hidden" name="wdts[action]" value="manage_post_transcripts" /> <input type="hidden" name="wdts[action]" value="manage_post_transcripts" />
<input type="hidden" name="wdts[post_id]" value="<?php echo $post->ID ?>" />
<p> <p>
<label> <label>
Edit transcript for: Edit transcript for: