ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 if (!function_exists('codepointToUtf8'))
17 {
18  // From include/normal/UtfNormalUtil.php
19  function codepointToUtf8( $codepoint ) {
20  if($codepoint < 0x80) return chr($codepoint);
21  if($codepoint < 0x800) return chr($codepoint >> 6 & 0x3f | 0xc0) .
22  chr($codepoint & 0x3f | 0x80);
23  if($codepoint < 0x10000) return chr($codepoint >> 12 & 0x0f | 0xe0) .
24  chr($codepoint >> 6 & 0x3f | 0x80) .
25  chr($codepoint & 0x3f | 0x80);
26  if($codepoint < 0x110000) return chr($codepoint >> 18 & 0x07 | 0xf0) .
27  chr($codepoint >> 12 & 0x3f | 0x80) .
28  chr($codepoint >> 6 & 0x3f | 0x80) .
29  chr($codepoint & 0x3f | 0x80);
30 
31  echo "Asked for code outside of range ($codepoint)\n";
32  die( -1 );
33  }
34 }
35 
36 // From includes/normal/UtfNormal.php
37 define( 'UTF8_REPLACEMENT', "\xef\xbf\xbd" /*codepointToUtf8( UNICODE_REPLACEMENT )*/ );
38 
44 function wfUrlProtocols() {
45  global $wgUrlProtocols;
46 
47  $wgUrlProtocols = array(
48  'http://',
49  'https://',
50  'ftp://',
51  'irc://',
52  'gopher://',
53  'telnet://', // Well if we're going to support the above.. -ævar
54  'nntp://', // @bug 3808 RFC 1738
55  'worldwind://',
56  'mailto:',
57  'news:'
58  );
59 
60 
61  // Support old-style $wgUrlProtocols strings, for backwards compatibility
62  // with LocalSettings files from 1.5
63  if ( is_array( $wgUrlProtocols ) ) {
64  $protocols = array();
65  foreach ($wgUrlProtocols as $protocol)
66  $protocols[] = preg_quote( $protocol, '/' );
67 
68  return implode( '|', $protocols );
69  } else {
70  return $wgUrlProtocols;
71  }
72 }
73 
74 include_once("./Services/Utilities/classes/Parser.php");
75 include_once("./Services/Utilities/classes/Sanitizer.php");
76 
78 {
79  function getSkin() { return $this;}
80 
81  // from Linker.php
82  function makeExternalLink( $url, $text, $escape = true, $linktype = '', $ns = null )
83  {
84  //$style = $this->getExternalLinkAttributes( $url, $text, 'external ' . $linktype );
85  //global $wgNoFollowLinks, $wgNoFollowNsExceptions;
86  //if( $wgNoFollowLinks && !(isset($ns) && in_array($ns, $wgNoFollowNsExceptions)) ) {
87  // $style .= ' rel="nofollow"';
88  //}
89  $url = htmlspecialchars( $url );
90  if( $escape ) {
91  $text = htmlspecialchars( $text );
92  }
93 
94  // handle images
95  $urlpath = parse_url($url, PHP_URL_PATH);
96  $pi = pathinfo($urlpath);
97  if (in_array(strtolower($pi["extension"]), array("jpg", "jpeg", "gif", "png")))
98  {
99  return '<img src="'.$url.'" border="0" />';
100  }
101  else
102  {
103  return '<a href="'.$url.'" target="_blank">'.$text.'</a>';
104  }
105  //return '<a href="'.$url.'"'.$style.'>'.$text.'</a>';
106  }
107 
108  function markNoConversion($text, $noParse=false) {return $text;}
109 
110  function addExternalLink() {}
111 
112  public function getNamespace() { return null;}
113 }
114 
115 $GLOBALS["wgContLang"] = new ilMWFakery();
116 
118 {
119  function __construct()
120  {
122  $this->mOptions = new ilMWFakery();
123  $this->mTitle = new ilMWFakery();
124  $this->mOutput = new ilMWFakery();
125  }
126 
127  function maybeMakeExternalImage( $url ) { return false;}
128 }
129 
130 ?>