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