Merge branch 'master' into media-handling

This commit is contained in:
John Bintz 2009-12-04 21:04:07 -05:00
commit 8eb9ded01d
7 changed files with 102 additions and 60 deletions

View File

@ -58,6 +58,15 @@ class ComicPressMediaHandling {
return $result; return $result;
} }
function _get_regex_dirname($input) {
return dirname($this->_resolve_regex_path($input));
}
function _get_regex_filename($input) {
$input = preg_replace('#\\\(?![.])#', '/', $input);
return basename($input);
}
function _resolve_regex_path($input) { function _resolve_regex_path($input) {
$input = str_replace('\.', '.', $input); $input = str_replace('\.', '.', $input);
$input = str_replace('\\', '/', $input); $input = str_replace('\\', '/', $input);
@ -66,7 +75,7 @@ class ComicPressMediaHandling {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
function _abspath() { function _abspath() {
return realpath(ABSPATH); return trailingslashit($this->_resolve_regex_path(realpath(ABSPATH)));
} }
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
@ -74,7 +83,7 @@ class ComicPressMediaHandling {
$value = ''; $value = '';
switch (strtolower($matches[1])) { switch (strtolower($matches[1])) {
case 'wordpress': case 'wordpress':
$value = $this->_abspath(); $value = untrailingslashit($this->_abspath());
break; break;
case 'type-folder': case 'type-folder':
$value = $this->type_folder; $value = $this->type_folder;
@ -93,12 +102,12 @@ class ComicPressMediaHandling {
} }
function _read_directory($pattern) { function _read_directory($pattern) {
$dirname = $this->_resolve_regex_path(dirname($pattern)); $dirname = $this->_get_regex_dirname($pattern);
$results = false; $results = false;
if (is_dir($dirname)) { if (is_dir($dirname)) {
$results = array(); $results = array();
if (($dh = opendir($dirname)) !== false) { if (($dh = opendir($dirname)) !== false) {
$filename_pattern = str_replace('#', '\#', basename($pattern)); $filename_pattern = str_replace('#', '\#', $this->_get_regex_filename($pattern));
while (($file = readdir($dh)) !== false) { while (($file = readdir($dh)) !== false) {
$target = $dirname . '/' . $file; $target = $dirname . '/' . $file;
if (is_file($target)) { if (is_file($target)) {
@ -167,6 +176,7 @@ class ComicPressMediaHandling {
return false; return false;
} }
/** /**
* Get the comic path. * Get the comic path.
* @param string $type The type to retrieve. * @param string $type The type to retrieve.
@ -190,17 +200,14 @@ class ComicPressMediaHandling {
if (isset($globals[$type])) { if (isset($globals[$type])) {
$filter = $this->_expand_filter($filter, $globals[$type], $post_to_use); $filter = $this->_expand_filter($filter, $globals[$type], $post_to_use);
if (is_array($results = $this->_read_directory($filter))) { if (is_array($results = $this->_read_directory($filter))) {
if (($pre_handle = apply_filters('comicpress_pre_handle_comic_path_results', false, $results, $type, $post_to_use)) !== false) { if (($pre_handle = apply_filters('comicpress_pre_handle_comic_path_results', false, $results, $type, $post_to_use)) !== false) {
return $pre_handle; return $pre_handle;
} }
$new_results = array(); $new_results = array();
foreach ($results as $result) { foreach ($results as $result) {
$new_results[] = str_replace($this->_abspath(), '', $result); $new_results[] = str_replace($this->_abspath(), '', $result);
} }
if ($multi) { if ($multi) {
return $new_results; return $new_results;
} else { } else {
@ -211,3 +218,4 @@ class ComicPressMediaHandling {
return false; return false;
} }
} }

View File

@ -16,12 +16,11 @@ if ( post_password_required() ) { ?>
<?php if ( ! empty($comments_by_type['comment']) ) : ?> <?php if ( ! empty($comments_by_type['comment']) ) : ?>
<div class="commentsrsslink">[ <?php comments_rss_link('Comments RSS'); ?> ]</div>
<h3 id="comments"><?php comments_number(__('Discussion &not;','comicpress'), __('Discussion &not;','comicpress'), __('Discussion (%) &not;','comicpress') );?></h3>
<h3 id="comments"><?php comments_number(__('Discussion &not;','comicpress'), __('Discussion &not;','comicpress'), __('Discussion (%) &not;','comicpress') );?></h3>
<div class="commentsrsslink">[ <?php comments_rss_link('Comments RSS'); ?> ]</div>
<ol class="commentlist"> <ol class="commentlist">
<?php <?php if (function_exists('comicpress_comments_callback')) {
if (function_exists('comicpress_comments_callback')) {
wp_list_comments(array( wp_list_comments(array(
'type' => 'comment', 'type' => 'comment',
'reply_text' => __('Reply to %s&not;','comicpress'), 'reply_text' => __('Reply to %s&not;','comicpress'),
@ -34,6 +33,28 @@ if ( post_password_required() ) { ?>
wp_list_comments(array('type' => 'comment', 'avatar_size'=>64)); wp_list_comments(array('type' => 'comment', 'avatar_size'=>64));
}?> }?>
</ol> </ol>
<?php if ( ! empty($comments_by_type['pings']) ) : ?>
<div id="pingtrackback-wrap">
<h3 id="pingtrackback"><?php _e('Pings & Trackbacks &not;','comicpress'); ?></h3>
<ol class="commentlist">
<ul>
<?php if (function_exists('comicpress_comments_callback')) {
wp_list_comments(array(
'type' => 'pings',
'callback' => 'comicpress_comments_callback',
'end-callback' => 'comicpress_comments_end_callback',
'avatar_size'=>32
)
);
} else {
wp_list_comments(array('type' => 'pings', 'avatar_size'=>64));
}?>
</ul>
</ol>
</div>
<?php endif; ?>
<?php endif; ?> <?php endif; ?>
<?php if ($comicpress_options['enable_numbered_pagination']) { ?> <?php if ($comicpress_options['enable_numbered_pagination']) { ?>
@ -110,26 +131,7 @@ if ( post_password_required() ) { ?>
<?php endif; ?> <?php endif; ?>
<?php if ( ! empty($comments_by_type['pings']) ) : ?>
<h3 id="comments"><?php _e('Pings & Trackbacks &not;','comicpress'); ?></h3>
<ol class="commentlist">
<ul>
<?php
if (function_exists('comicpress_comments_callback')) {
wp_list_comments(array(
'type' => 'pings',
'callback' => 'comicpress_comments_callback',
'end-callback' => 'comicpress_comments_end_callback',
'avatar_size'=>32
)
);
} else {
wp_list_comments(array('type' => 'pings', 'avatar_size'=>64));
}?>
</ul>
</ol>
<?php endif; ?>
</div> </div>
<div id="comment-wrapper-foot"></div> <div id="comment-wrapper-foot"></div>

View File

@ -64,7 +64,7 @@ function display_blog_post() {
<?php } ?> <?php } ?>
<?php <?php
if ('open' == $post->comment_status) { if ('open' == $post->comment_status) {
if (comicpress_check_child_file('partials/commentlink') == false) { ?> if (comicpress_check_child_file('partials/commentlink') == false && !(is_single())) { ?>
<div class="comment-link"><?php comments_popup_link('<span class="comment-balloon comment-balloon-empty">&nbsp;</span> '.__('Comments ','comicpress'), '<span class="comment-balloon">1</span> '.__('Comment ','comicpress'), '<span class="comment-balloon">%</span> '.__('Comments ','comicpress')); ?></div> <div class="comment-link"><?php comments_popup_link('<span class="comment-balloon comment-balloon-empty">&nbsp;</span> '.__('Comments ','comicpress'), '<span class="comment-balloon">1</span> '.__('Comment ','comicpress'), '<span class="comment-balloon">%</span> '.__('Comments ','comicpress')); ?></div>
<?php } <?php }
} }

View File

@ -66,7 +66,7 @@ function display_comic_post() {
</div> </div>
<?php } ?> <?php } ?>
<?php <?php
if ('open' == $post->comment_status) { if ('open' == $post->comment_status && !$comicpress_options['static_blog'] && !(is_single())) {
if (comicpress_check_child_file('partials/commentlink') == false) { ?> if (comicpress_check_child_file('partials/commentlink') == false) { ?>
<div class="comment-link"><?php comments_popup_link('<span class="comment-balloon comment-balloon-empty">&nbsp;</span> '.__('Comments ','comicpress'), '<span class="comment-balloon">1</span> '.__('Comment ','comicpress'), '<span class="comment-balloon">%</span> '.__('Comments ','comicpress')); ?></div> <div class="comment-link"><?php comments_popup_link('<span class="comment-balloon comment-balloon-empty">&nbsp;</span> '.__('Comments ','comicpress'), '<span class="comment-balloon">1</span> '.__('Comment ','comicpress'), '<span class="comment-balloon">%</span> '.__('Comments ','comicpress')); ?></div>
<?php } <?php }

View File

@ -264,7 +264,7 @@
<input id="static_blog" name="static_blog" type="checkbox" value="1" <?php checked(true, $comicpress_options['static_blog']); ?> /> <input id="static_blog" name="static_blog" type="checkbox" value="1" <?php checked(true, $comicpress_options['static_blog']); ?> />
</td> </td>
<td> <td>
<?php _e('Blog will stay with the single pages, good to use with comments disabled in the settings.','comicpress'); ?> <?php _e('Blog will stay with the single pages, this will automatically disable any commenting ability for comic blog posts. ','comicpress'); ?>
</td> </td>
</tr> </tr>
<tr class="alternate"> <tr class="alternate">

View File

@ -631,13 +631,6 @@ h3, h3 a {
margin-left: 45px; margin-left: 45px;
} }
.pingback .comment-content {
margin-left: 0;
}
.trackback .comment-content {
margin-left: 0;
}
.comment-author cite { .comment-author cite {
font-weight: bold; font-weight: bold;
@ -684,7 +677,6 @@ h3, h3 a {
} }
.commentsrsslink { .commentsrsslink {
float: right;
font-size: 11px; font-size: 11px;
} }
@ -722,11 +714,27 @@ ul.children {
list-style: none; list-style: none;
} }
.reply { #respond {
padding: 10px 0 0 0; padding: 20px 0 0 0;
text-align: right;
} }
/* Pingbacks and Trackbacks */
#pingtrackback {
font-size: 16px;
}
.pingback .comment-content, .trackback .comment-content {
margin-left: 0;
}
.trackback .comment-author cite, .pingback .comment-author cite {
font-weight: bold;
font-style: normal;
font-size: 13px;
}
/* ARCHIVE */ /* ARCHIVE */
/* For the built-in WordPress archive pages (by month or category) as well as search result pages */ /* For the built-in WordPress archive pages (by month or category) as well as search result pages */
@ -1096,11 +1104,6 @@ ul.children {
overflow: hidden; overflow: hidden;
} }
/* Pingbacks and Trackbacks */
li.pingback div p, li.trackback div p {
margin-left: 0;
}
/* STORYLINES */ /* STORYLINES */

View File

@ -160,6 +160,35 @@ class ComicPressMediaHandlingTest extends PHPUnit_Framework_TestCase {
$this->assertEquals($expected_output, $this->cpmh->_resolve_regex_path($input)); $this->assertEquals($expected_output, $this->cpmh->_resolve_regex_path($input));
} }
function providerTestGetRegexDirname() {
return array(
array('/test/test2', '/test')
);
}
/**
* @dataProvider providerTestGetRegexDirname
*/
function testGetRegexDirname($input, $expected_output) {
$this->assertEquals($expected_output, $this->cpmh->_get_regex_dirname($input));
}
function providerTestGetRegexFilename() {
return array(
array('/test/test2', 'test2'),
array('c:\test\test2', 'test2'),
array('/test/test2\.cat', 'test2\.cat'),
array('c:\test\test2\.cat', 'test2\.cat'),
);
}
/**
* @dataProvider providerTestGetRegexFilename
*/
function testGetRegexFilename($input, $expected_output) {
$this->assertEquals($expected_output, $this->cpmh->_get_regex_filename($input));
}
function providerTestPreHandleComicPathResults() { function providerTestPreHandleComicPathResults() {
return array( return array(
array('', '', false), array('', '', false),