Fixes for IIS / windows for ComicPressMediaHandling.inc

Signed-off-by: Philip M. Hofer (Frumph) <frumph_dragon@yahoo.com>
This commit is contained in:
Philip M. Hofer (Frumph) 2009-12-04 08:35:08 -08:00
parent 7a25cca894
commit 2f96341d49
1 changed files with 11 additions and 7 deletions

View File

@ -66,7 +66,7 @@ class ComicPressMediaHandling {
// @codeCoverageIgnoreStart
function _abspath() {
return realpath(ABSPATH);
return trailingslashit($this->_resolve_regex_path(realpath(ABSPATH)));
}
// @codeCoverageIgnoreEnd
@ -74,7 +74,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,14 +93,16 @@ class ComicPressMediaHandling {
}
function _read_directory($pattern) {
$dirname = $this->_resolve_regex_path(dirname($pattern));
$resolved_pattern = $this->_resolve_regex_path($pattern);
$dirname = dirname($resolved_pattern);
$results = false;
if (is_dir($dirname)) {
$results = array();
if (($dh = opendir($dirname)) !== false) {
$filename_pattern = str_replace('#', '\#', basename($pattern));
$filename_pattern = str_replace('#', '\#', basename($resolved_pattern));
while (($file = readdir($dh)) !== false) {
$target = $dirname . '/' . $file;
// echo "<br />TARGET:<br />"; var_dump($target); echo "<br /><br />";
if (is_file($target)) {
if (preg_match("#^${filename_pattern}$#", $file) > 0) {
$results[] = $target;
@ -167,6 +169,7 @@ class ComicPressMediaHandling {
return false;
}
/**
* Get the comic path.
* @param string $type The type to retrieve.
@ -190,17 +193,18 @@ class ComicPressMediaHandling {
if (isset($globals[$type])) {
$filter = $this->_expand_filter($filter, $globals[$type], $post_to_use);
// var_dump($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) {
return $pre_handle;
}
// echo "<br />RESULTS: <br />";var_dump($results); echo "<br /><br />";
$new_results = array();
// echo "<br />ABSPATH: <br />"; var_dump($this->_abspath()); echo "<br /><br />";
foreach ($results as $result) {
$new_results[] = str_replace($this->_abspath(), '', $result);
}
// echo "<br />NEW RESULTS: <br />";var_dump($new_results); echo "<br /><br />";
if ($multi) {
return $new_results;
} else {