Embedder.php #1

  • //
  • guest/
  • matt_attaway/
  • mediawiki/
  • extensions/
  • Embedder/
  • Embedder.php
  • View
  • Commits
  • Open Download .zip Download (1 KB)
<?php
 // MediaWiki embed_webpage Extension
 // by Matt Attaway
 // Based on code from the MediaWiki embed_document extension by S.L

 $wgExtensionFunctions[] = "register_embed_webpage_handler";

 function register_embed_webpage_handler() 
 {
         global $wgParser;
         $wgParser->setHook( "embed_webpage", "embed_webpage_handler" );
 }

 function embed_webpage_handler( $input, $argv )
 {
    $allowedchars = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
                          'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
                          'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
                          'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
                          '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
                          '_', '/', '.', ':','?','=','@','&');

    if( str_replace($allowedchars, '', $input) == '' )
    {
       return "<object type=\"text/html\" data=" . $input . " style=\"width:100%;max-width:770px;height:480px;overflow:auto;border:0 none\"></object>";
    }
    else
    {
       return "<font color=#aa0000>Error: invalid character sequence between <code>&lt;embed_webpage&gt;...&lt;/embed_webpage&gt;</code> markers, allowed
are only<ul><li>a...z</li><li>A...Z</li><li>_</li><li>/</li><li>.</li><li>:</li></ul></font>";
    }
 } 
 ?>
# Change User Description Committed
#1 5922 Matt Attaway Add rudimentary mediwiki extensions.

Embedder adds the ability to embed random webpages into a wiki. It's still very rough
at this point, but it does work. I can't recommend it on a public wiki, but it
is very handy if you can trust the users.

Perforce adds the ability to convert a change number into the 'p4 changes' output,
but with links to a p4web instance. This is also very rough at this point, but does
work.

More coming soon to both of these.