setOpt('active_auto_urls',1); # Activation de la reconnaissance d'url $this->setOpt('active_macros',1); # Activation des macros «««..»»» $this->setOpt('active_wikiwords',0); # Activation des mots wiki $this->setOpt('active_blockattr',1); # Activation des attributs de blocs °°..°° $this->setOpt('active_auto_img',0); # Activation des images automatiques dans les liens [] $this->setOpt('active_urls',1); # Activation des liens [] $this->setOpt('words_pattern','((?setOpt('mail_pattern','/^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/'); $this->setOpt('url_pattern','/^(?registerFunction('macro:flash',array($this,'wikiFlash')); $this->registerFunction('macro:importpage',array($this,'importPage')); $this->registerFunction('macro:importitem',array($this,'importItem')); $this->registerFunction('macro:includephp',array($this,'includephp')); $this->registerFunction('macro:pageclass',array($this,'pageclass')); $this->registerFunction('macro:pagetitle',array($this,'pagetitle')); $this->registerFunction('macro:ww',array($this,'wikiwikiWords')); $this->registerFunction('macro:flickrlist',array($this,'flickrlist')); $this->registerFunction('macro:flickralbum',array($this,'flickralbum')); $this->registerFunction('macro:galerie',array($this,'galerie')); } function parseWikiWord($str,&$tag,&$attr,&$type) { $tag = 'span'; $attr = ' class="wiki" onclick="wLink(this);" title="'.$str.'"'; return $str; } function parseMacro($str,&$tag,&$attr,&$type) { $data = $this->__splitTagsAttr($str); if (count($data) == 1) { $item = trim($str); $content = $str; } elseif (count($data) > 1) { $item = $data[0]; $content = trim($data[1]); } $tag = 'span'; $attr = ' class="wiki" onclick="wLink(this);" title="'.$content.'"'; $str = $item; return $str; } function __parseLink($str,&$tag,&$attr,&$type) { $n_str = $this->__inlineWalk($str,array('acronym','img')); $data = $this->__splitTagsAttr($n_str); $no_image = false; if (count($data) == 1) { $url = trim($str); $content = $str; $lang = ''; $title = ''; $class = ''; } elseif (count($data) > 1) { $url = trim($data[1]); $content = $data[0]; $lang = (!empty($data[2])) ? $this->protectAttr($data[2],true) : ''; $title = (!empty($data[3])) ? $data[3] : ''; $no_image = (!empty($data[4])) ? (boolean) $data[4] : false; $class = (!empty($data[5])) ? $data[5] : ''; } # Remplacement si URL spéciale $this->__specialUrls($url,$content,$lang,$title); # On vire les   dans l'url $url = str_replace(' ',' ',$url); if (ereg('^(.+)[.](gif|jpg|jpeg|png)$', $url) && !$no_image && $this->getOpt('active_auto_img')) { # On ajoute les dimensions de l'image si locale # Idée de Stephanie $img_size = NULL; if (!ereg('[a-zA-Z]+://', $url)) { if (ereg('^/',$url)) { $path_img = $_SERVER['DOCUMENT_ROOT'] . $url; } else { $path_img = $url; } $img_size = @getimagesize($path_img); } $attr = ' src="'.$this->protectAttr($this->protectUrls($url)).'"'. $attr .= (count($data) > 1) ? ' alt="'.$this->protectAttr($content).'"' : ' alt=""'; $attr .= ($lang) ? ' lang="'.$lang.'"' : ''; $attr .= ($title) ? ' title="'.$this->protectAttr($title).'"' : ''; $attr .= ($class) ? ' class="'.$this->protectAttr($class).'"' : ''; $attr .= (is_array($img_size)) ? ' '.$img_size[3] : ''; $tag = 'img'; $type = 'close'; return NULL; } else { if ($this->getOpt('active_antispam') && preg_match('/^mailto:/',$url)) { $url = 'mailto:'.$this->__antiSpam(substr($url,7)); } $attr = ' href="'.$this->protectAttr($this->protectUrls($url)).'"'; $attr .= ($lang) ? ' hreflang="'.$lang.'"' : ''; $attr .= ($title) ? ' title="'.$this->protectAttr($title).'"' : ''; $attr .= ($class && $this->iscurrenturl($url)) ? ' class="'.$this->protectAttr($class.' cur').'"' : ($this->iscurrenturl($url)) ? ' class="cur"':($class) ? ' class="'.$this->protectAttr($class).'"':''; $attr .= ($this->iscurrenturl($url)) ? ' selected="selected"':''; //~ $attr .= ' test="'.$this->protectAttr('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']).'"'; //~ $attr .= ' test="'.$this->protectAttr(substr($_SERVER['REQUEST_URI'],strpos($_SERVER['REQUEST_URI'], "/")+1)).'"'; return $content; } } function iscurrenturl($url) { if($url==$_SERVER['REQUEST_URI'])return true; else if($url==substr($_SERVER['REQUEST_URI'],strpos($_SERVER['REQUEST_URI'], "/") +1))return true; else if($url=="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'])return true; else return false; } function __specialUrls() { $res['#^google://(.*)$#'] = 'http://www.google.com/search?q=$1&start=0&start=0'; $res['#^wikipedia://(.*)$#'] = 'http://fr.wikipedia.org/wiki/$1'; $res['#^wiki://(.*)$#'] = './?$1'; return $res; } function InsertLinks ( $Text ) { $Result = preg_replace( $Expr, "$0", $Text ); return $Result; } function wikiFlash($s,$args) { if ((list($src,$w,$h) = explode("|",preg_replace('/^flash (.+?) ([0-9]+?)x([0-9]+?)$/','$1|$2|$3',$args))) !== false) { return ''. ''. ''. ''; } return null; } function importPage($s,$args) //importe le contenu d'une page à l'intérieur de la page courante { if (($src = preg_replace('/^importpage (.+?)$/','$1',$args)) !== false) { $tmp.=""; if ( $fd = fopen( $src, "r") ) { while ($line=fgets($fd,1000)) { $tmp.=$line; } fclose ($fd); } //$tmp=str_replace( 'images/', $src.'images/', $tmp ); return $tmp; } return null; } function importItem($s,$args) //importe le contenu d'un item l'intérieur de la page courante { if (($src = preg_replace('/^importitem (.+?)$/','$1',$args)) !== false) { $tmp.=""; $tmp.='
'; $tmp.=get_item($src); $tmp.="
"; //$tmp=str_replace( 'images/', $src.'images/', $tmp ); return $tmp; } return null; } function includephp($s,$args) //inclut un script php à l'intérieur de la page courante { if (($src = preg_replace('/^includephp (.+?)$/','$1',$args)) !== false) { //$tmp.=""; include($src); //$tmp=str_replace( 'images/', $src.'images/', $tmp ); return $tmp; } return null; } function wikiwikiWords($s,$args) { if (($src = preg_replace('/^ww (.+?)$/','$1',$args)) !== false) { return ''.$src.''; } return null; } function pageclass($s,$args) //définit une class globale de la page courante { global $PAGECLASS; if (($src = preg_replace('/^pageclass (.+?)$/','$1',$args)) !== false) { $PAGECLASS= " - ".$src; } return null; } function pagetitle($s,$args) //définit un titre global de la page courante { global $PAGETITLE; if (($src = preg_replace('/^pagetitle (.+?)$/','$1',$args)) !== false) { $PAGETITLE= " - ".$src; } return null; } function flickrlist($s,$args) { if (($src = preg_replace('/^flickrlist (.+?)$/','$1',$args)) !== false) { list($id,$tags,$type,$class)=explode(" ", $src); $url="http://api.flickr.com/services/feeds/photos_public.gne?format=rss_200&lang=fr-fr"; if(!empty($id))$url.="&id=$id"; if(!empty($tags))$url.="&tags=$tags"; if(empty($type))$type.="_s"; $string=@implode('',@file($url)); $xml = @simplexml_load_string($string); //~ print_r($xml); foreach($xml->channel->item as $item) { preg_match("/.*\"(http[^\"]*.jpg)\".*/",$item->description,$m); $jpg_m=$m[1]; $jpg_s=ereg_replace("_m",$type,$jpg_m); $ret .= "
  • ".$item->title."
  • \n"; } return "
    \n
    "; } return null; } function flickralbum($s,$args) { if (($src = preg_replace('/^flickralbum (.+?)$/','$1',$args)) !== false) { list($id,$set,$type,$class)=explode(" ", $src); $url="http://api.flickr.com/services/feeds/photoset.gne?format=rss_200&lang=fr-fr"; if(!empty($id))$url.="&nsid=$id"; if(!empty($set))$url.="&set=$set"; if(empty($type))$type.="_s"; $string=@implode('',@file($url)); $xml=xml2array($string); //~ $xml = @simplexml_load_string($string); foreach($xml["rss"]["channel"]["item"] as $item) { preg_match("/.*\"(http[^\"]*.jpg)\".*/",$item["description"],$m); $jpg_m=$m[1]; $jpg_s=ereg_replace("_m",$type,$jpg_m); $title =utf8_decode(utf8_ensure($item["title"]))." - ".str_replace("

    ", "", str_replace("

    ", "", $item["media:description"])); $ret .= "
  • ".$item["title"]."
  • \n"; } return "
    \n
    ".""; } return null; } function galerie($s,$args) { if (($src = preg_replace('/^galerie (.+?)$/','$1',$args)) !== false) { //~ list($id,$tags,$type,$class)=explode(" ", $src); $url=$src; $string=@implode('',@file($url)); $xml = @simplexml_load_string($string); //~ print_r($xml); //~ foreach($xml->channel->item as $item) foreach($xml->entry as $item) { //~ print_r($item); preg_match("/.*\"(http[^\"]*.jpg)\".*/",$item->content,$m); $jpg=$m[1]; $ret .= "".$item->title."
    \n"; $ret .= "".$item->title."
    \n"; } return "
    \n".$ret."\n
    "; } return null; } } ### Macros function importPage($s,$args) //importe le contenu d'une page à l'intérieur de la page courante { if (($src = preg_replace('/^importpage (.+?)$/','$1',$args)) !== false) { if ( $fd = fopen( $src, "r") ) { $tmp.="
    "; while ($line=fgets($fd,1000)) { $tmp.=$line; } fclose ($fd); } //$tmp=str_replace( 'images/', $src.'images/', $tmp ); $tmp.="
    "; $tmp=strip_tags ( $tmp, "