working on admin area

This commit is contained in:
John Bintz 2009-09-22 22:30:16 -04:00
parent de7855d079
commit 9c0784ba1c
7 changed files with 289 additions and 203 deletions

View File

@ -373,12 +373,13 @@ class WhatDidTheySayAdmin {
header('HTTP/1.1 401 Unauthorized');
}
function handle_update_default_styles($info) {
function handle_update_styles($info) {
$updated = false;
if (current_user_can('edit_themes')) {
$options = get_option('what-did-they-say-options');
$options['load_default_styles'] = isset($info['default_styles']);
$options['excerpt_distance'] = !empty($info['excerpt_distance']) ? $info['excerpt_distance'] : 30;
update_option('what-did-they-say-options', $options);
$updated = __('Default styles option updated.', 'what-did-they-say');
@ -544,7 +545,10 @@ class WhatDidTheySayAdmin {
array(&$this, 'manage_admin')
);
if ($plugin_page == "manage-wdts") { $this->read_language_file(); }
if ($plugin_page == "manage-wdts") {
$this->read_language_file();
wp_enqueue_style('wdts-admin', plugin_dir_url(dirname(__FILE__)) . 'css/wdts-admin.css');
}
wp_enqueue_script('scriptaculous-effects');
}

31
classes/_capabilities.inc Normal file
View File

@ -0,0 +1,31 @@
<?php if (current_user_can('edit_users') && is_array($options)) { ?>
<form method="post">
<input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
<input type="hidden" name="wdts[module]" value="capabilities" />
<h3><?php _e('Capabilities', 'what-did-they-say') ?></h3>
<table class="widefat fixed">
<tr class="thead">
<th scope="col" class="manage-col"><?php _e('Capability', 'what-did-they-say') ?></th>
<th scope="col" class="manage-col"><?php _e('Role Needed', 'what-did-they-say') ?></th>
</tr>
<?php foreach ($this->capabilities as $key => $label) { ?>
<tr>
<th scope="col"><?php echo $label ?></th>
<td>
<select name="wdts[capabilities][<?php echo $key ?>]">
<?php wp_dropdown_roles($options['capabilities'][$key]) ?>
</select>
</td>
</tr>
<?php } ?>
<tr>
<td>&nbsp;</td>
<td>
<input class="button" type="submit" value="<?php _e('Change capabilities', 'what-did-they-say') ?>" />
</td>
</tr>
</table>
</form>
<?php } ?>

View File

@ -0,0 +1,96 @@
<?php if (current_user_can('change_languages')) { ?>
<?php if (is_array($options)) { ?>
<h3><?php _e('Languages', 'what-did-they-say') ?></h3>
<table class="widefat fixed">
<tr class="thead">
<th scope="col" class="manage-col" width="35%"><?php _e('Language', 'what-did-they-say') ?></th>
<th scope="col" class="manage-col"><?php _e('Rename?', 'what-did-they-say') ?></th>
<th scope="col" class="manage-col"><?php _e('Make default?', 'what-did-they-say') ?></th>
<th scope="col" class="manage-col"><?php _e('Delete?', 'what-did-they-say') ?></th>
</tr>
<?php foreach ($options['languages'] as $code => $info) {
$default = isset($info['default']);
$name = $info['name'];
?>
<tr>
<th scope="row">
<span><?php echo $name ?></span>
<?php if ($default) { _e('(default)', 'what-did-they-say'); } ?>
<form method="post" style="display: none">
<input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
<input type="hidden" name="wdts[code]" value="<?php echo $code ?>" />
<input type="hidden" name="wdts[action]" value="rename" />
<input type="hidden" name="wdts[module]" value="languages" />
<input type="text" name="wdts[name]" value="<?php echo $name ?>" style="width: 50%" />
<input type="submit" class="button" value="Rename" />
</form>
</th>
<td style="vertical-align: inherit">
<a class="rename button" href="#"><?php _e('Rename', 'what-did-they-say') ?></a>
</td>
<td>
<form method="post">
<input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
<input type="hidden" name="wdts[code]" value="<?php echo $code ?>" />
<input type="hidden" name="wdts[action]" value="default" />
<input type="hidden" name="wdts[module]" value="languages" />
<input
<?php echo ($default ? 'disabled="disabled"' : '') ?>
type="submit"
class="button"
value="<?php _e('Default', 'what-did-they-say') ?>" />
</form>
</td>
<td>
<form method="post" class="verify">
<input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
<input type="hidden" name="wdts[code]" value="<?php echo $code ?>" />
<input type="hidden" name="wdts[action]" value="delete" />
<input type="hidden" name="wdts[module]" value="languages" />
<input type="submit" class="button" value="<?php _e('Delete', 'what-did-they-say') ?>" />
</form>
</td>
</tr>
<?php } ?>
<tr>
<th scope="row"><?php _e('Add new:', 'what-did-they-say') ?></th>
<td colspan="3">
<form method="post">
<input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
<input type="hidden" name="wdts[action]" value="add" />
<input type="hidden" name="wdts[module]" value="languages" />
<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>
<?php } ?>
<?php } ?>
<script type="text/javascript">
$$('.verify').each(function(f) {
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') ?>")) {
Event.stop(e);
}
});
});
$$('a.rename').each(function(a) {
Event.observe(a, 'click', function(e) {
Event.stop(e);
var th = a.parentNode.parentNode.select('th')[0];
if (th) {
th.select('span')[0].hide();
th.select('form')[0].show();
}
});
});
</script>

View File

@ -0,0 +1,45 @@
<?php if (current_user_can('edit_themes')) { ?>
<?php if (is_array($options)) { ?>
<h3><?php _e('Transcript Style and DisplaySettings', 'what-did-they-say') ?></h3>
<form method="post">
<input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
<input type="hidden" name="wdts[module]" value="styles" />
<label>
<?php _e('Number of excerpt context characters in search results:', 'what-did-they-say') ?>
<input type="text"
name="wdts[excerpt_distance]"
value="<?php echo $options['excerpt_distance'] ?>"
size="3" />
</label>
<label>
<?php _e('Include default CSS styles for transcripts:', 'what-did-they-say') ?>
<input type="checkbox"
name="wdts[default_styles]"
value="yes"
<?php echo ($options['load_default_styles'] ? 'checked="checked"' : '') ?> />
</label>
<input class="button" type="submit" value="<?php _e('Change default styles', 'what-did-they-say') ?>" />
</form>
<hr />
<p><?php _e('By default, the following styles are used by <strong>What Did They Say?!?</strong>:', 'what-did-they-say') ?></p>
<dl>
<dt><code>.transcript</code></dt>
<dd><?php _e('The container for the transcript', 'what-did-they-say') ?></dd>
<dt><code>.dialog</code></dt>
<dd><?php _e('Character dialog', 'what-did-they-say') ?></dd>
<dt><code>.name</code></dt>
<dd><?php _e('The character\'s name', 'what-did-they-say') ?></dd>
<dt><code>.direction</code></dt>
<dd><?php _e('The direction the characters is speaking in/from (off-stage, to another character)', 'what-did-they-say') ?></dd>
<dt><code>.scene-heading</code></dt>
<dd><?php _e('A scene heading', 'what-did-they-say') ?></dd>
<dt><code>.scene-action</code></dt>
<dd><?php _e('Action within a scene', 'what-did-they-say') ?></dd>
</dl>
<p><?php _e('To include transcript excerpts in your search results, add the following template tag to your search results Loop:', 'what-did-they-say') ?></p>
<p><code>&lt;php the_matching_transcript_excerpts() ?&gt;</code></p>
<p><?php printf(__('The first matching word in each transcript will be <strong>emphasized</strong>, and there will be <strong>%d</strong> additional characters on each side of the word.', 'what-did-they-say'), $options['excerpt_distance']) ?></p>
<?php } ?>
<?php } ?>

19
classes/_misc-options.inc Normal file
View File

@ -0,0 +1,19 @@
<?php if (current_user_can('manage_options')) { ?>
<h3><?php _e('Reset Settings to Default', 'what-did-they-say') ?></h3>
<p><?php _e('Click the button below to reset capabilities and languages to their defaults. This will not affect any transcriptions you have already created, but some transcriptions may become inaccessible if you don\'t redefine the original language.', 'what-did-they-say') ?></p>
<form method="post" id="reset-wdts">
<input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
<input type="hidden" name="wdts[module]" value="reset-options" />
<input type="submit" class="button" value="<?php _e('Reset What Did They Say?!?', 'what-did-they-say') ?>" />
</form>
<?php } ?>
<script type="text/javascript">
if ($('reset-wdts')) {
Event.observe($('reset-wdts'), 'submit', function(e) {
if (!confirm('<?php _e('Are you sure? You could leave transcriptions inaccessible.', 'what-did-they-say') ?>')) {
Event.stop(e);
}
});
}
</script>

View File

@ -0,0 +1,34 @@
<?php if (current_user_can('submit_transcriptions')) { ?>
<h3><?php _e('Transcript Shortcodes', 'what-did-they-say') ?></h3>
<p>
<?php _e('Transcripts can be entered either using straight HTML or by using shortcodes built for What Did They Say?!?', 'what-did-they-say') ?>
<?php _e('Using shortcodes will make your transcripts easier to style.', 'what-did-they-say') ?>
<?php _e('The default styles that come with What Did They Say?!? make your transcripts look like a screenplay.', 'what-did-they-say') ?>
</p>
<h4><?php _e('Available Shortcodes', 'what-did-they-say') ?></h4>
<h5><?php _e('[scene-heading]', 'what-did-they-say') ?></h5>
<p><?php _e('The text that indicates a new scene:', 'what-did-they-say') ?></p>
<p>
<?php _e('<code>[scene-heading]Ext. The Old Man\'s House[/scene-heading]</code> becomes:', 'what-did-they-say') ?>
<span style="text-transform: uppercase; font-weight: bold; font-family: 'Courier New'"><?php _e('Ext. The Old Man\'s House', 'what-did-they-say') ?></span>
</p>
<h5><?php _e('[scene-action]', 'what-did-they-say') ?></h5>
<p><?php _e('The text that indicates action taking place in a scene. One usually occurs underneath of a scene heading:', 'what-did-they-say') ?></p>
<p>
<?php _e('<code>[scene-action]John is walking down to the car parked in the driveway.[/scene-action]</code> becomes:', 'what-did-they-say') ?>
<span style="font-family: 'Courier New'"><?php _e('John is walking down to the car parked in the driveway.', 'what-did-they-say') ?></span>
</p>
<h5><?php _e('[dialog]', 'what-did-they-say') ?></h5>
<p><?php _e('The textfor when a character is speaking in a scene:', 'what-did-they-say') ?></p>
<p>
<?php _e('<code>[dialog name="John" direction="(towards the house)"]Hey, where are the keys?[/dialog]</code> becomes:', 'what-did-they-say') ?>
</p>
<div style="width: 300px; border: solid #333 1px; margin: 10px; text-align: center">
<div style="font-family: 'Courier New'; text-transform: uppercase"><?php _e('John', 'what-did-they-say') ?></div>
<div style="font-family: 'Courier New'; margin-bottom: 10px"><?php _e('(towards the house)', 'what-did-they-say') ?></div>
<div style="font-family: 'Courier New'"><?php _e('Hey, where are the keys?', 'what-did-they-say') ?></div>
</div>
<?php } ?>

View File

@ -1,212 +1,69 @@
<?php
$pages = array(
'capabilities' => __('Capabilities', 'what-did-they-say'),
'default-styles' => __('Styles', 'what-did-they-say'),
'change-languages' => __('Languages', 'what-did-they-say'),
'misc-options' => __('Misc. Options', 'what-did-they-say'),
'shortcodes-info' => __('Shortcodes Info', 'what-did-they-say')
);
?>
<div class="wrap">
<h2><?php _e('What Did They Say?!?', 'what-did-they-sahy') ?></h2>
<h2><?php _e('What Did They Say?!?', 'what-did-they-say') ?></h2>
<?php if (current_user_can('submit_transcriptions')) { ?>
<h3><?php _e('Transcript Shortcodes', 'what-did-they-say') ?></h3>
<p>
<?php _e('Transcripts can be entered either using straight HTML or by using shortcodes built for What Did They Say?!?', 'what-did-they-say') ?>
<?php _e('Using shortcodes will make your transcripts easier to style.', 'what-did-they-say') ?>
<?php _e('The default styles that come with What Did They Say?!? make your transcripts look like a screenplay.', 'what-did-they-say') ?>
</p>
<h4><?php _e('Available Shortcodes', 'what-did-they-say') ?></h4>
<h5><?php _e('[scene-heading]', 'what-did-they-say') ?></h5>
<p><?php _e('The text that indicates a new scene:', 'what-did-they-say') ?></p>
<p>
<?php _e('<code>[scene-heading]Ext. The Old Man\'s House[/scene-heading]</code> becomes:', 'what-did-they-say') ?>
<span style="text-transform: uppercase; font-weight: bold; font-family: 'Courier New'"><?php _e('Ext. The Old Man\'s House', 'what-did-they-say') ?></span>
</p>
<div id="wdts-tab-bar">
<?php foreach ($pages as $page => $title) { ?><a id="wdts-tab-<?php echo $page ?>" href="#" class="wdts-tab"><?php echo $title ?></a><?php } ?>
</div>
<h5><?php _e('[scene-action]', 'what-did-they-say') ?></h5>
<p><?php _e('The text that indicates action taking place in a scene. One usually occurs underneath of a scene heading:', 'what-did-they-say') ?></p>
<p>
<?php _e('<code>[scene-action]John is walking down to the car parked in the driveway.[/scene-action]</code> becomes:', 'what-did-they-say') ?>
<span style="font-family: 'Courier New'"><?php _e('John is walking down to the car parked in the driveway.', 'what-did-they-say') ?></span>
</p>
<h5><?php _e('[dialog]', 'what-did-they-say') ?></h5>
<p><?php _e('The textfor when a character is speaking in a scene:', 'what-did-they-say') ?></p>
<p>
<?php _e('<code>[dialog name="John" direction="(towards the house)"]Hey, where are the keys?[/dialog]</code> becomes:', 'what-did-they-say') ?>
</p>
<div style="width: 300px; border: solid #333 1px; margin: 10px; text-align: center">
<div style="font-family: 'Courier New'; text-transform: uppercase"><?php _e('John', 'what-did-they-say') ?></div>
<div style="font-family: 'Courier New'; margin-bottom: 10px"><?php _e('(towards the house)', 'what-did-they-say') ?></div>
<div style="font-family: 'Courier New'"><?php _e('Hey, where are the keys?', 'what-did-they-say') ?></div>
<div id="wdts-container">
<?php foreach ($pages as $page => $title) { ?>
<div id="wdts-page-<?php echo $page ?>" class="wdts-page" style="display:none">
<?php include("_${page}.inc") ?>
</div>
<?php } ?>
<?php if (current_user_can('edit_users') && is_array($options)) { ?>
<form method="post">
<input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
<input type="hidden" name="wdts[module]" value="capabilities" />
<h3><?php _e('Capabilities', 'what-did-they-say') ?></h3>
<table class="widefat fixed">
<tr class="thead">
<th scope="col" class="manage-col"><?php _e('Capability', 'what-did-they-say') ?></th>
<th scope="col" class="manage-col"><?php _e('Role Needed', 'what-did-they-say') ?></th>
</tr>
<?php foreach ($this->capabilities as $key => $label) { ?>
<tr>
<th scope="col"><?php echo $label ?></th>
<td>
<select name="wdts[capabilities][<?php echo $key ?>]">
<?php wp_dropdown_roles($options['capabilities'][$key]) ?>
</select>
</td>
</tr>
<?php } ?>
<tr>
<td>&nbsp;</td>
<td>
<input class="button" type="submit" value="<?php _e('Change capabilities', 'what-did-they-say') ?>" />
</td>
</tr>
</table>
</form>
<?php } ?>
<?php if (current_user_can('edit_themes')) { ?>
<?php if (is_array($options)) { ?>
<h3><?php _e('Default Styles', 'what-did-they-say') ?></h3>
<form method="post">
<input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
<input type="hidden" name="wdts[module]" value="default-styles" />
<label>
<input type="checkbox"
name="wdts[default_styles]"
value="yes"
<?php echo ($options['load_default_styles'] ? 'checked="checked"' : '') ?> /> <?php _e('Include a set of default CSS styles for transcripts.', 'what-did-they-say') ?>
</label>
<input class="button" type="submit" value="<?php _e('Change default styles', 'what-did-they-say') ?>" />
</form>
<p><?php _e('By default, the following styles are used by What Did They Say?!?:', 'what-did-they-say') ?></p>
<ul>
<li><?php _e('<strong>.transcript</strong>: The container for the transcript', 'what-did-they-say') ?></li>
<li><?php _e('<strong>.dialog</strong>: Character dialog', 'what-did-they-say') ?></li>
<li><?php _e('<strong>.name</strong>: The character\'s name', 'what-did-they-say') ?></li>
<li><?php _e('<strong>.direction</strong>: The direction the characters is speaking in/from (off-stage, to another character)', 'what-did-they-say') ?></li>
<li><?php _e('<strong>.scene-heading</strong>: A scene heading', 'what-did-they-say') ?></li>
<li><?php _e('<strong>.scene-action</strong>: Action within a scene', 'what-did-they-say') ?></li>
</ul>
<?php } ?>
<?php } ?>
<?php if (current_user_can('change_languages')) { ?>
<?php if (is_array($options)) { ?>
<h3><?php _e('Languages', 'what-did-they-say') ?></h3>
<table class="widefat fixed">
<tr class="thead">
<th scope="col" class="manage-col" width="35%"><?php _e('Language', 'what-did-they-say') ?></th>
<th scope="col" class="manage-col"><?php _e('Rename?', 'what-did-they-say') ?></th>
<th scope="col" class="manage-col"><?php _e('Make default?', 'what-did-they-say') ?></th>
<th scope="col" class="manage-col"><?php _e('Delete?', 'what-did-they-say') ?></th>
</tr>
<?php foreach ($options['languages'] as $code => $info) {
$default = isset($info['default']);
$name = $info['name'];
?>
<tr>
<th scope="row">
<span><?php echo $name ?></span>
<?php if ($default) { _e('(default)', 'what-did-they-say'); } ?>
<form method="post" style="display: none">
<input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
<input type="hidden" name="wdts[code]" value="<?php echo $code ?>" />
<input type="hidden" name="wdts[action]" value="rename" />
<input type="hidden" name="wdts[module]" value="languages" />
<input type="text" name="wdts[name]" value="<?php echo $name ?>" style="width: 50%" />
<input type="submit" class="button" value="Rename" />
</form>
</th>
<td style="vertical-align: inherit">
<a class="rename button" href="#"><?php _e('Rename', 'what-did-they-say') ?></a>
</td>
<td>
<form method="post">
<input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
<input type="hidden" name="wdts[code]" value="<?php echo $code ?>" />
<input type="hidden" name="wdts[action]" value="default" />
<input type="hidden" name="wdts[module]" value="languages" />
<input
<?php echo ($default ? 'disabled="disabled"' : '') ?>
type="submit"
class="button"
value="<?php _e('Default', 'what-did-they-say') ?>" />
</form>
</td>
<td>
<form method="post" class="verify">
<input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
<input type="hidden" name="wdts[code]" value="<?php echo $code ?>" />
<input type="hidden" name="wdts[action]" value="delete" />
<input type="hidden" name="wdts[module]" value="languages" />
<input type="submit" class="button" value="<?php _e('Delete', 'what-did-they-say') ?>" />
</form>
</td>
</tr>
<?php } ?>
<tr>
<th scope="row"><?php _e('Add new:', 'what-did-they-say') ?></th>
<td colspan="3">
<form method="post">
<input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
<input type="hidden" name="wdts[action]" value="add" />
<input type="hidden" name="wdts[module]" value="languages" />
<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>
<?php } ?>
<?php } ?>
<?php if (current_user_can('manage_options')) { ?>
<h3>Miscellaneous Options</h3>
<h3><?php _e('Reset Settings to Default', 'what-did-they-say') ?></h3>
<p><?php _e('Click the button below to reset capabilities and languages to their defaults. This will not affect any transcriptions you have already created, but some transcriptions may become inaccessible if you don\'t redefine the original language.', 'what-did-they-say') ?></p>
<form method="post" id="reset-wdts">
<input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
<input type="hidden" name="wdts[module]" value="reset-options" />
<input type="submit" class="button" value="<?php _e('Reset What Did They Say?!?', 'what-did-they-say') ?>" />
</form>
<?php } ?>
</div>
</div>
<script type="text/javascript">
$$('.verify').each(function(f) {
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') ?>")) {
Event.stop(e);
function make_active(tab) {
if (tab) {
var page = $(tab.id.replace('-tab-', '-page-'));
if (page) {
$$('.wdts-tab').each(function(t) {
(t == tab) ? t.removeClassName('inactive') : t.addClassName('inactive');
});
$$('.wdts-page').each(function(p) {
if (p == page) {
if (!p.visible()) {
new Effect.BlindDown(p, { duration: 0.25 });
}
} else {
if (p.visible()) {
new Effect.BlindUp(p, { duration: 0.25 });
}
}
});
}
}
}
$$('.wdts-tab').each(function(tab) {
tab.observe('click', function(e) {
Event.stop(e);
make_active(tab);
});
});
$$('a.rename').each(function(a) {
Event.observe(a, 'click', function(e) {
Event.stop(e);
var th = a.parentNode.parentNode.select('th')[0];
if (th) {
th.select('span')[0].hide();
th.select('form')[0].show();
}
$$('.wdts-page').each(function(page) {
page.select('form').each(function(form) {
var return_page = new Element("input", { type: 'hidden', name: 'wdts[return_page]', value: page.id });
form.insert(return_page);
});
});
if ($('reset-wdts')) {
Event.observe($('reset-wdts'), 'submit', function(e) {
if (!confirm('<?php _e('Are you sure? You could leave transcriptions inaccessible.', 'what-did-they-say') ?>')) {
Event.stop(e);
}
});
}
<?php if (isset($_POST['wdts']['return_page'])) { ?>
make_active($('<?php echo str_replace('-page-', '-tab-', $_POST['wdts']['return_page']) ?>'));
<?php } else { ?>
make_active($$('.wdts-tab')[0]);
<?php } ?>
</script>