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