Skip to content

Commit

Permalink
BUGFIX Respecting SSViewer::$options["rewriteHashlinks"] in SSViewer:…
Browse files Browse the repository at this point in the history
…:process()
  • Loading branch information
chillu committed Oct 18, 2011
1 parent fbe8b7b commit bdd6391
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions core/SSViewer.php
Expand Up @@ -371,16 +371,18 @@ public function process($item) {
array_pop(SSViewer::$topLevel);

if(isset($_GET['debug_profile'])) Profiler::unmark("SSViewer::process", " for $template");

// If we have our crazy base tag, then fix # links referencing the current page.
if(strpos($output, '<base') !== false) {
if(SSViewer::$options['rewriteHashlinks'] === 'php') {
$thisURLRelativeToBase = "<?php echo strip_tags(\$_SERVER['REQUEST_URI']); ?>";
} else {
$thisURLRelativeToBase = strip_tags($_SERVER['REQUEST_URI']);
if(SSViewer::$options['rewriteHashlinks']) {
if(strpos($output, '<base') !== false) {
if(SSViewer::$options['rewriteHashlinks'] === 'php') {
$thisURLRelativeToBase = "<?php echo strip_tags(\$_SERVER['REQUEST_URI']); ?>";
} else {
$thisURLRelativeToBase = strip_tags($_SERVER['REQUEST_URI']);
}
$output = preg_replace('/(<a[^>]+href *= *)"#/i', '\\1"' . $thisURLRelativeToBase . '#', $output);
}
$output = preg_replace('/(<a[^>+]href *= *)"#/i', '\\1"' . $thisURLRelativeToBase . '#', $output);
}
}

return $output;
}
Expand Down

0 comments on commit bdd6391

Please sign in to comment.