• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/Utilities/classes/class.ilMWParserAdapter.php

Go to the documentation of this file.
00001 <?php
00002 
00003 if (!function_exists("wfProfileIn"))
00004 {
00005         function wfProfileIn($dummy)
00006         {
00007         }
00008 }
00009 if (!function_exists("wfProfileOut"))
00010 {
00011         function wfProfileOut($dummy)
00012         {
00013         }
00014 }
00015 
00016 // From include/normal/UtfNormalUtil.php
00017 function codepointToUtf8( $codepoint ) {
00018         if($codepoint <         0x80) return chr($codepoint);
00019         if($codepoint <    0x800) return chr($codepoint >>      6 & 0x3f | 0xc0) .
00020                                                                          chr($codepoint           & 0x3f | 0x80);
00021         if($codepoint <  0x10000) return chr($codepoint >> 12 & 0x0f | 0xe0) .
00022                                                                          chr($codepoint >>      6 & 0x3f | 0x80) .
00023                                                                          chr($codepoint           & 0x3f | 0x80);
00024         if($codepoint < 0x110000) return chr($codepoint >> 18 & 0x07 | 0xf0) .
00025                                                                          chr($codepoint >> 12 & 0x3f | 0x80) .
00026                                                                          chr($codepoint >>      6 & 0x3f | 0x80) .
00027                                                                          chr($codepoint           & 0x3f | 0x80);
00028 
00029         echo "Asked for code outside of range ($codepoint)\n";
00030         die( -1 );
00031 }
00032 
00033 // From includes/normal/UtfNormal.php
00034 define( 'UTF8_REPLACEMENT', "\xef\xbf\xbd" /*codepointToUtf8( UNICODE_REPLACEMENT )*/ );
00035 
00041 function wfUrlProtocols() {
00042         global $wgUrlProtocols;
00043         
00044         $wgUrlProtocols = array(
00045                 'http://',
00046                 'https://',
00047                 'ftp://',
00048                 'irc://',
00049                 'gopher://',
00050                 'telnet://', // Well if we're going to support the above.. -ævar
00051                 'nntp://', // @bug 3808 RFC 1738
00052                 'worldwind://',
00053                 'mailto:',
00054                 'news:'
00055                 );
00056 
00057 
00058         // Support old-style $wgUrlProtocols strings, for backwards compatibility
00059         // with LocalSettings files from 1.5
00060         if ( is_array( $wgUrlProtocols ) ) {
00061                 $protocols = array();
00062                 foreach ($wgUrlProtocols as $protocol)
00063                         $protocols[] = preg_quote( $protocol, '/' );
00064 
00065                 return implode( '|', $protocols );
00066         } else {
00067                 return $wgUrlProtocols;
00068         }
00069 }
00070 
00071 include_once("./Services/Utilities/classes/Parser.php");
00072 include_once("./Services/Utilities/classes/Sanitizer.php");
00073 
00074 class ilMWFakery
00075 {
00076         function getSkin() { return $this;}
00077         
00078         // from Linker.php
00079         function makeExternalLink( $url, $text, $escape = true, $linktype = '', $ns = null )
00080         {
00081                 //$style = $this->getExternalLinkAttributes( $url, $text, 'external ' . $linktype );
00082                 //global $wgNoFollowLinks, $wgNoFollowNsExceptions;
00083                 //if( $wgNoFollowLinks && !(isset($ns) && in_array($ns, $wgNoFollowNsExceptions)) ) {
00084                 //      $style .= ' rel="nofollow"';
00085                 //}
00086                 $url = htmlspecialchars( $url );
00087                 if( $escape ) {
00088                         $text = htmlspecialchars( $text );
00089                 }
00090                 
00091                 // handle images
00092                 $urlpath = parse_url($url, PHP_URL_PATH);
00093                 $pi = pathinfo($urlpath);
00094                 if (in_array(strtolower($pi["extension"]), array("jpg", "jpeg", "gif", "png")))
00095                 {
00096                         return '<img src="'.$url.'" border="0" />';
00097                 }
00098                 else
00099                 {
00100                         return '<a href="'.$url.'" target="_blank">'.$text.'</a>';
00101                 }
00102                 //return '<a href="'.$url.'"'.$style.'>'.$text.'</a>';
00103         }
00104         
00105         function markNoConversion($text, $noParse=false) {return $text;}
00106         
00107         function addExternalLink() {}
00108         
00109         public function getNamespace() { return null;}
00110 }
00111 
00112 $GLOBALS["wgContLang"] = new ilMWFakery();
00113 
00114 class ilMWParserAdapter extends Parser
00115 {
00116         function __construct()
00117         {
00118                 parent::__construct();
00119                 $this->mOptions = new ilMWFakery();
00120                 $this->mTitle = new ilMWFakery();
00121                 $this->mOutput = new ilMWFakery();
00122         }
00123         
00124         function maybeMakeExternalImage( $url ) { return false;}
00125 }
00126 
00127 ?>

Generated on Fri Dec 13 2013 17:57:02 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1