mostly filebased Content Presentation System
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 line
2.5KB

  1. <?php
  2. class freaParsedown extends Parsedown {
  3. function get_BlockTypes() {
  4. return $this->BlockTypes;
  5. }
  6. function deactivate_ol() {
  7. $ol_triggers= array(
  8. "0",
  9. "1",
  10. "2",
  11. "3",
  12. "4",
  13. "5",
  14. "6",
  15. "7",
  16. "8",
  17. "9"
  18. );
  19. foreach ($ol_triggers as $key) {
  20. unset($this->BlockTypes[$key]);
  21. }
  22. }
  23. function add_language_to_link_target($href) {
  24. $f3 = \Base::instance();
  25. $data = [];
  26. $base = substr($href,0,strpos($href,'?') ? : strlen($href));
  27. $query = parse_url($href,PHP_URL_QUERY);
  28. $fragment = parse_url($href,PHP_URL_FRAGMENT);
  29. if (null !== $query) {
  30. parse_str($query,$data);
  31. }
  32. if ($f3->get('LANG') != $f3->get('default_lang')) {
  33. if (!array_key_exists('lang',$data)) {
  34. $data['lang'] = $f3->get('LANG');
  35. }
  36. }
  37. $new = $base;
  38. if (count($data) > 0) {
  39. $new .= "?" . http_build_query($data);
  40. }
  41. if ($fragment) {
  42. $new .= "#" . $fragment;
  43. }
  44. return $new;
  45. }
  46. protected function inlineEmailTag($Excerpt)
  47. {
  48. $Link = parent::inlineEmailTag($Excerpt);
  49. if (isset($Link)) {
  50. $Link['element']['attributes'] += ['data-link-text' => $Link['element']['text']];
  51. }
  52. return $Link;
  53. }
  54. protected function inlineLink($Excerpt)
  55. {
  56. $Link = parent::inlineLink($Excerpt);
  57. if (isset($Link)) {
  58. $Link['element']['attributes'] += ['data-link-text' => $Link['element']['text']];
  59. $url=&$Link['element']['attributes']['href'];
  60. if (strpos($url,':') === FALSE) {
  61. $url = $this->add_language_to_link_target($url);
  62. }
  63. $Link['extent'] = $Link['extent'];
  64. }
  65. return $Link;
  66. }
  67. protected function inlineUrl($Excerpt)
  68. {
  69. $Link = parent::inlineUrl($Excerpt);
  70. if (isset($Link)) {
  71. $Link['element']['attributes'] += ['data-link-text' => $Link['element']['text']];
  72. }
  73. return $Link;
  74. }
  75. protected function inlineUrlTag($Excerpt)
  76. {
  77. $Link = parent::inlineUrlTag($Excerpt);
  78. if (isset($Link)) {
  79. $Link['element']['attributes'] += ['data-link-text' => $Link['element']['text']];
  80. }
  81. return $Link;
  82. }
  83. }