start work on ui for editing filters
This commit is contained in:
parent
84e2381f02
commit
ee7a1cdf1c
|
@ -206,7 +206,8 @@ function comicpress_load_options() {
|
||||||
|
|
||||||
'enable_comment_count_in_rss' => false,
|
'enable_comment_count_in_rss' => false,
|
||||||
'enable_scroll_to_top' => false,
|
'enable_scroll_to_top' => false,
|
||||||
'enable_page_load_info' => false
|
'enable_page_load_info' => false,
|
||||||
|
'comic_filename_filters' => array()
|
||||||
|
|
||||||
) as $field => $value) {
|
) as $field => $value) {
|
||||||
$comicpress_options[$field] = $value;
|
$comicpress_options[$field] = $value;
|
||||||
|
|
|
@ -160,6 +160,76 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$cpmh = new ComicPressMediaHandling();
|
||||||
|
|
||||||
|
$filters = $comicpress_options['comic_filename_filters'];
|
||||||
|
if (!isset($filters['default'])) {
|
||||||
|
$filters['default'] = $cpmh->default_filter;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th scope="row"><label><?php _e('Comic Filename Filters', 'comicpress'); ?></label></th>
|
||||||
|
<td colspan="2">
|
||||||
|
<p>
|
||||||
|
<em>For advanced users.</em> Specify the filters used to find the filename.
|
||||||
|
</p>
|
||||||
|
<div id="comicpress-comic-filename-filters-holder">
|
||||||
|
</div>
|
||||||
|
<a href="#" id="add-new-filter"><?php _e('Add new filter', 'comicpress') ?></a>
|
||||||
|
<script type="text/javascript">
|
||||||
|
(function($) {
|
||||||
|
var filter_data = [];
|
||||||
|
<?php foreach ($filters as $name => $filter) { ?>
|
||||||
|
filter_data.push({name:'<?php echo esc_js($name) ?>', filter:'<?php echo esc_js($filter) ?>'});
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
var build_row = function(data) {
|
||||||
|
var key = (new Date()).getTime();
|
||||||
|
var row = $('<div>\
|
||||||
|
<label>\
|
||||||
|
<strong>Key:</strong>\
|
||||||
|
<input type="text" size="15" name="comic_filename_filters[' + key + '][name]" value="' + data.name + '" />\
|
||||||
|
</label>\
|
||||||
|
<label>\
|
||||||
|
<strong>Filter:</strong>\
|
||||||
|
<input type="text" size="60" name="comic_filename_filters[' + key + '][name]" value="' + data.filter + '" />\
|
||||||
|
</label>\
|
||||||
|
<a href="#">Remove</a>\
|
||||||
|
</div>');
|
||||||
|
$('a', row).click(function() {
|
||||||
|
if (confirm('<?php _e('Are you sure?', 'comicpress') ?>')) {
|
||||||
|
$(this).parent().remove();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
return row;
|
||||||
|
};
|
||||||
|
|
||||||
|
$('#add-new-filter').click(function() {
|
||||||
|
$('#comicpress-comic-filename-filters-holder').append(build_row({name:'new_filter',filter:'%wordpress%'}));
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$.each(filter_data, function(index, f) {
|
||||||
|
$('#comicpress-comic-filename-filters-holder').append(build_row(f));
|
||||||
|
});
|
||||||
|
}(jQuery))
|
||||||
|
</script>
|
||||||
|
<p>
|
||||||
|
Available parameters:
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li><strong>%wordpress%</strong>: The WordPress root folder</li>
|
||||||
|
<li><strong>%type-folder%</strong>: The folder for the requested filetype (comic, rss, archive, or mini)</li>
|
||||||
|
<li><strong>%date-(format)%</strong>: The formatting to use for the requested date as per the <a href="http://php.net/date">date()</a> function <em>(ex: %date-Ymd% is <?php echo date('Ymd') ?>)</em></li>
|
||||||
|
<li><strong>%upload-path%</strong>: The value of the upload_path option, which is the destination upload directory for WPMU installs.</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -221,3 +221,20 @@ div.show .cpadmin-footer img{
|
||||||
min-width: 80px;
|
min-width: 80px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Comic Filters **/
|
||||||
|
|
||||||
|
#comicpress-comic-filename-filters-holder div {
|
||||||
|
border: solid #ddd 1px;
|
||||||
|
padding: 3px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
#comicpress-comic-filename-filters-holder label {
|
||||||
|
float: left;
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
#comicpress-comic-filename-filters-holder input {
|
||||||
|
margin: 0 10px;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
|
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
<link rel="selenium.base" href="http://comicpress.local/" />
|
||||||
|
<title>TestComicFilenameFilters</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<table cellpadding="1" cellspacing="1" border="1">
|
||||||
|
<thead>
|
||||||
|
<tr><td rowspan="1" colspan="3">TestComicFilenameFilters</td></tr>
|
||||||
|
</thead><tbody>
|
||||||
|
<tr>
|
||||||
|
<td>clickAndWait</td>
|
||||||
|
<td>link=ComicPress Options</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>click</td>
|
||||||
|
<td>//div[@id='comicpress-tab-config']/span</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>storeXpathCount</td>
|
||||||
|
<td>//div[@id="comicpress-comic-filename-filters-holder"]/div</td>
|
||||||
|
<td>filter_count</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>echo</td>
|
||||||
|
<td>${filter_count}</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>click</td>
|
||||||
|
<td>add-new-filter</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>storeXpathCount</td>
|
||||||
|
<td>//div[@id="comicpress-comic-filename-filters-holder"]/div</td>
|
||||||
|
<td>new_filter_count</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>assertEval</td>
|
||||||
|
<td>(${new_filter_count}) == (${filter_count} + 1)</td>
|
||||||
|
<td>true</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>click</td>
|
||||||
|
<td>//div[@id='comicpress-comic-filename-filters-holder']/div[2]/a</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>assertConfirmation</td>
|
||||||
|
<td>Are you sure?</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>storeXpathCount</td>
|
||||||
|
<td>//div[@id="comicpress-comic-filename-filters-holder"]/div</td>
|
||||||
|
<td>new_filter_count</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>assertEval</td>
|
||||||
|
<td>(${new_filter_count}) == (${filter_count})</td>
|
||||||
|
<td>true</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</tbody></table>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue