ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilMWParserAdapter.php
Go to the documentation of this file.
1 <?php
2 
3 if (!function_exists("wfProfileIn")) {
4  function wfProfileIn($dummy)
5  {
6  }
7 }
8 if (!function_exists("wfProfileOut")) {
9  function wfProfileOut($dummy)
10  {
11  }
12 }
13 
14 include_once("./include/Unicode/UtfNormalUtil.php");
15 
16 // From include/Unicode/UtfNormal.php
17 if (!defined('UTF8_REPLACEMENT')) {
18  define('UTF8_REPLACEMENT', "\xef\xbf\xbd" /*codepointToUtf8( UNICODE_REPLACEMENT )*/);
19 }
20 
26 function wfUrlProtocols()
27 {
28  global $wgUrlProtocols;
29 
30  $wgUrlProtocols = array(
31  'http://',
32  'https://',
33  'ftp://',
34  'irc://',
35  'gopher://',
36  'telnet://', // Well if we're going to support the above.. -ævar
37  'nntp://', // @bug 3808 RFC 1738
38  'worldwind://',
39  'mailto:',
40  'news:'
41  );
42 
43 
44  // Support old-style $wgUrlProtocols strings, for backwards compatibility
45  // with LocalSettings files from 1.5
46  if (is_array($wgUrlProtocols)) {
47  $protocols = array();
48  foreach ($wgUrlProtocols as $protocol) {
49  $protocols[] = preg_quote($protocol, '/');
50  }
51 
52  return implode('|', $protocols);
53  } else {
54  return $wgUrlProtocols;
55  }
56 }
57 
58 include_once("./Services/Utilities/classes/Parser.php");
59 include_once("./Services/Utilities/classes/Sanitizer.php");
60 
62 {
63  public function getSkin()
64  {
65  return $this;
66  }
67 
68  // from Linker.php
69  public function makeExternalLink($url, $text, $escape = true, $linktype = '', $ns = null)
70  {
71  //$style = $this->getExternalLinkAttributes( $url, $text, 'external ' . $linktype );
72  //global $wgNoFollowLinks, $wgNoFollowNsExceptions;
73  //if( $wgNoFollowLinks && !(isset($ns) && in_array($ns, $wgNoFollowNsExceptions)) ) {
74  // $style .= ' rel="nofollow"';
75  //}
76  $url = htmlspecialchars($url);
77  if ($escape) {
78  $text = htmlspecialchars($text);
79  }
80 
81  // handle images
82  $urlpath = parse_url($url, PHP_URL_PATH);
83  $pi = pathinfo($urlpath);
84  if (in_array(strtolower($pi["extension"]), array("jpg", "jpeg", "gif", "png"))) {
85  return '<img src="' . $url . '" border="0" />';
86  } else {
87  return '<a href="' . $url . '" target="_blank" rel="noopener">' . $text . '</a>';
88  }
89  //return '<a href="'.$url.'"'.$style.'>'.$text.'</a>';
90  }
91 
92  public function markNoConversion($text, $noParse = false)
93  {
94  return $text;
95  }
96 
97  public function addExternalLink()
98  {
99  }
100 
101  public function getNamespace()
102  {
103  return null;
104  }
105 }
106 
107 $GLOBALS["wgContLang"] = new ilMWFakery();
108 
110 {
111  public function __construct()
112  {
114  $this->mOptions = new ilMWFakery();
115  $this->mTitle = new ilMWFakery();
116  $this->mOutput = new ilMWFakery();
117  }
118 
119  public function maybeMakeExternalImage($url)
120  {
121  return false;
122  }
123 }
markNoConversion($text, $noParse=false)
makeExternalLink($url, $text, $escape=true, $linktype='', $ns=null)
$GLOBALS["wgContLang"]
__construct(Container $dic, ilPlugin $plugin)
$url
if(!defined('UTF8_REPLACEMENT')) wfUrlProtocols()
Returns a regular expression of url protocols.