add language

This commit is contained in:
John Bintz 2009-08-14 19:49:03 -04:00
parent e90da61002
commit b9170dbe32
2 changed files with 18 additions and 16 deletions

View File

@ -70,6 +70,7 @@ class WhatDidTheySayAdmin {
unset($options['languages'][$language_info['code']]); unset($options['languages'][$language_info['code']]);
break; break;
case "add": case "add":
$this->read_language_file();
if (isset($this->all_languages[$language_info['code']])) { if (isset($this->all_languages[$language_info['code']])) {
$options['languages'][$language_info['code']] = array('name' => $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']]); $updated = sprintf(__('%s added.', 'what-did-they-say'), $this->all_languages[$language_info['code']]);
@ -96,6 +97,7 @@ class WhatDidTheySayAdmin {
} }
break; break;
} }
ksort($options['languages']);
update_option('what-did-they-say-options', $options); update_option('what-did-they-say-options', $options);
return $updated; return $updated;
} }
@ -196,17 +198,6 @@ class WhatDidTheySayAdmin {
function manage_transcriptions_admin() { function manage_transcriptions_admin() {
$options = get_option('what-did-they-say-options'); $options = get_option('what-did-they-say-options');
$language_map_pairs = array();
$basic_languages = $all_languages = array();
foreach ($this->all_languages as $code => $name) {
$name = addslashes($name);
$language_map_pairs[] = "'${code}': '${name}'";
$all_languages[] = "'$code'";
if (strlen($code) == 2) {
$basic_languages[] = "'$code'";
}
}
$nonce = wp_create_nonce('what-did-they-say'); $nonce = wp_create_nonce('what-did-they-say');
$url = 'edit-comments.php?page=manage-transcriptions-wdts'; $url = 'edit-comments.php?page=manage-transcriptions-wdts';

View File

@ -52,6 +52,22 @@
</td> </td>
</tr> </tr>
<?php } ?> <?php } ?>
<tr>
<th scope="row"><?php _e('Add new:', 'what-did-they-say') ?></th>
<td colspan="4">
<form method="post">
<input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
<input type="hidden" name="wdts[action]" value="add" />
<select name="wdts[code]">
<option value="">-- select --</option>
<?php foreach ($this->all_languages as $code => $language) { ?>
<option value="<?php echo $code ?>"><?php echo $language ?></option>
<?php } ?>
</select>
<input type="submit" value="<?php _e('Add New Language', 'what-did-they-say') ?>" class="button" />
</form>
</td>
</tr>
</table> </table>
<h3><?php _e('Authorized Users', 'what-did-they-say') ?></h3> <h3><?php _e('Authorized Users', 'what-did-they-say') ?></h3>
@ -65,11 +81,6 @@
</ul> </ul>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
var basic_languages = [ <?php echo implode(",", $basic_languages) ?> ];
var all_languages = [ <?php echo implode(",", $all_languages) ?> ];
var language_map = { <?php echo implode(",\n", $language_map_pairs) ?> };
$$('form.verify').each(function(f) { $$('form.verify').each(function(f) {
Event.observe(f, 'submit', function(e) { Event.observe(f, 'submit', function(e) {
if (!confirm("<?php _e('You are about to delete this language from the available list. Continue?', 'what-did-they-say') ?>")) { if (!confirm("<?php _e('You are about to delete this language from the available list. Continue?', 'what-did-they-say') ?>")) {