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

View File

@ -16,24 +16,45 @@ if ( post_password_required() ) { ?>
<?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>
<div class="commentsrsslink">[ <?php comments_rss_link('Comments RSS'); ?> ]</div>
<ol class="commentlist">
<?php
if (function_exists('comicpress_comments_callback')) {
wp_list_comments(array(
'type' => 'comment',
'reply_text' => __('Reply to %s&not;','comicpress'),
'callback' => 'comicpress_comments_callback',
'end-callback' => 'comicpress_comments_end_callback',
'avatar_size'=>64
)
);
} else {
wp_list_comments(array('type' => 'comment', 'avatar_size'=>64));
<?php if (function_exists('comicpress_comments_callback')) {
wp_list_comments(array(
'type' => 'comment',
'reply_text' => __('Reply to %s&not;','comicpress'),
'callback' => 'comicpress_comments_callback',
'end-callback' => 'comicpress_comments_end_callback',
'avatar_size'=>64
)
);
} else {
wp_list_comments(array('type' => 'comment', 'avatar_size'=>64));
}?>
</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 if ($comicpress_options['enable_numbered_pagination']) { ?>
@ -110,26 +131,7 @@ if ( post_password_required() ) { ?>
<?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 id="comment-wrapper-foot"></div>

View File

@ -64,7 +64,7 @@ function display_blog_post() {
<?php } ?>
<?php
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>
<?php }
}

View File

@ -66,7 +66,7 @@ function display_comic_post() {
</div>
<?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) { ?>
<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 }

View File

@ -264,7 +264,7 @@
<input id="static_blog" name="static_blog" type="checkbox" value="1" <?php checked(true, $comicpress_options['static_blog']); ?> />
</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>
</tr>
<tr class="alternate">

View File

@ -631,13 +631,6 @@ h3, h3 a {
margin-left: 45px;
}
.pingback .comment-content {
margin-left: 0;
}
.trackback .comment-content {
margin-left: 0;
}
.comment-author cite {
font-weight: bold;
@ -684,7 +677,6 @@ h3, h3 a {
}
.commentsrsslink {
float: right;
font-size: 11px;
}
@ -722,11 +714,27 @@ ul.children {
list-style: none;
}
.reply {
padding: 10px 0 0 0;
text-align: right;
#respond {
padding: 20px 0 0 0;
}
/* 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 */
/* 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;
}
/* Pingbacks and Trackbacks */
li.pingback div p, li.trackback div p {
margin-left: 0;
}
/* STORYLINES */

View File

@ -160,6 +160,35 @@ class ComicPressMediaHandlingTest extends PHPUnit_Framework_TestCase {
$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() {
return array(
array('', '', false),