| @@ 4675-4697 (lines=23) @@ | ||
| 4672 | /** |
|
| 4673 | * We convert text |
|
| 4674 | */ |
|
| 4675 | function Text__finalise(&$res) { |
|
| 4676 | $text = $res['text']; |
|
| 4677 | ||
| 4678 | // Unescape any escaped characters in the text, then put back escapes for any single quotes and backslashes |
|
| 4679 | $text = stripslashes($text); |
|
| 4680 | $text = addcslashes($text, '\'\\'); |
|
| 4681 | ||
| 4682 | // TODO: This is pretty ugly & gets applied on all files not just html. I wonder if we can make this |
|
| 4683 | // non-dynamically calculated |
|
| 4684 | $code = <<<'EOC' |
|
| 4685 | (\Config::inst()->get('SSViewer', 'rewrite_hash_links') |
|
| 4686 | ? \Convert::raw2att( preg_replace("/^(\\/)+/", "/", $_SERVER['REQUEST_URI'] ) ) |
|
| 4687 | : "") |
|
| 4688 | EOC; |
|
| 4689 | // Because preg_replace replacement requires escaped slashes, addcslashes here |
|
| 4690 | $text = preg_replace( |
|
| 4691 | '/(<a[^>]+href *= *)"#/i', |
|
| 4692 | '\\1"\' . ' . addcslashes($code, '\\') . ' . \'#', |
|
| 4693 | $text |
|
| 4694 | ); |
|
| 4695 | ||
| 4696 | $res['php'] .= '$val .= \'' . $text . '\';' . PHP_EOL; |
|
| 4697 | } |
|
| 4698 | ||
| 4699 | /****************** |
|
| 4700 | * Here ends the parser itself. Below are utility methods to use the parser |
|
| @@ 1129-1151 (lines=23) @@ | ||
| 1126 | /** |
|
| 1127 | * We convert text |
|
| 1128 | */ |
|
| 1129 | function Text__finalise(&$res) { |
|
| 1130 | $text = $res['text']; |
|
| 1131 | ||
| 1132 | // Unescape any escaped characters in the text, then put back escapes for any single quotes and backslashes |
|
| 1133 | $text = stripslashes($text); |
|
| 1134 | $text = addcslashes($text, '\'\\'); |
|
| 1135 | ||
| 1136 | // TODO: This is pretty ugly & gets applied on all files not just html. I wonder if we can make this |
|
| 1137 | // non-dynamically calculated |
|
| 1138 | $code = <<<'EOC' |
|
| 1139 | (\Config::inst()->get('SSViewer', 'rewrite_hash_links') |
|
| 1140 | ? \Convert::raw2att( preg_replace("/^(\\/)+/", "/", $_SERVER['REQUEST_URI'] ) ) |
|
| 1141 | : "") |
|
| 1142 | EOC; |
|
| 1143 | // Because preg_replace replacement requires escaped slashes, addcslashes here |
|
| 1144 | $text = preg_replace( |
|
| 1145 | '/(<a[^>]+href *= *)"#/i', |
|
| 1146 | '\\1"\' . ' . addcslashes($code, '\\') . ' . \'#', |
|
| 1147 | $text |
|
| 1148 | ); |
|
| 1149 | ||
| 1150 | $res['php'] .= '$val .= \'' . $text . '\';' . PHP_EOL; |
|
| 1151 | } |
|
| 1152 | ||
| 1153 | /****************** |
|
| 1154 | * Here ends the parser itself. Below are utility methods to use the parser |
|