<?
/*
   bram brambring
   http://www.brambring.nl
#
#               $Id: metatag.php,v 1.9 2004/01/10 16:19:48 pts00065 Exp $
#



Installation:
       Save this file ( fe as local/metatag.php
       Add include_once("local/metatag.php"); to the end of your local.php 

Usage:
      [[meta:name content-text]] 
            results in : <META name="name" content="content-text">

      [[equiv:what content-text]] 
            results in : <META http-equiv="what" content="content-text">

     $Log: metatag.php,v $
     Revision 1.9  2004/01/10 16:19:48  pts00065
     Refined the refresh regex.

     Revision 1.8  2004/01/10 15:58:08  pts00065
     Having a refresh open in your wiki is potentially harmfull
     Visitors might add a redirect to a dirty, or worse site.
     Now you will need to define the allowed redirects first

     Revision 1.7  2004/01/06 17:57:26  pts00065

     cleanup


     Revision 1.6  2004/01/06 14:55:44  pts00065
     Changed to inline replacements

     bram 05-01-2004
     1.0  Initial version as file


*/
# the refresh it potential harmfull, define the allowed sites here:

$AllowedRefresh['tropischetuin']="http://tropischetuin.pagina.nl";
$AllowedRefresh['egel']="http://egel.pagina.nl";
$AllowedRefresh['winkel']="http://winkel.brambring.nl";

$MetaTagName="/\\[\\[meta:([^ ]+) +([^\\]]+)\\]\\]/e";
$InlineReplacements[$MetaTagName] = '';

$MetaTagRefresh="/\\[\\[refresh:([^ \\]]+) *([0-9]*)\\]\\]/e";
$InlineReplacements[$MetaTagRefresh] = '';

function PrintMetaTags() {
  global $MetaTagName;
  global $MetaTagRefresh;
  global $Text;
  global $action;
  global $AllowedRefresh;

  if ( $action and ( $action!='browse' ) ) { return ; };
  preg_match_all($MetaTagName,$Text,$match);
  for ($i=0; $i< count($match[0]); $i++) {
    print "<META name=\"" . $match[1][$i] . "\" content=\"" . $match[2][$i] ."\">\n";
  }
  preg_match_all($MetaTagRefresh,$Text,$match);
  for ($i=0; $i< count($match[0]); $i++) {
    $target=$AllowedRefresh[$match[1][$i]];
    $time=$match[2][$i];
    if ( $target ) {
      if ( ! $time ) {
        $time=1;
       }
      print "<META http-equiv=\"refresh\" content=\"$time;url=$target\">\n";
    }
  }
}

array_push($HTMLTitleFmt,"function:PrintMetaTags")

?>