Extension:Include

Installation
See the source. It's trivial.

Example Usage in a wikipage


Source Code
&lt;?php /** * This adds an &lt;include/&gt; tag to MediaWiki. To install, put this script in * &quot;$IP/extensions/include.php&quot; then add this line to LocalSettings.php: * *     require_once(&quot;$IP/extensions/include.php&quot;); * * The &lt;include/&gt; tag should always include at least an 'url' attribute. * HTML escaping and &lt;pre&gt; formatting are on by default. * You may set 'noesc' attribute to turn off HTML entities escaping. * You may set 'nopre' attribute to turn off &lt;pre&gt;&lt;/pre&gt; formatting. * * EXAMPLES * *     Include a file from the local file system: *        &lt;include url=&quot;/var/www/htdocs/README&quot; /&gt; *    Include a remote file: *        &lt;include url=&quot;http://www.gogle.com/search?q=noah.org&quot; nopre noesc /&gt; *    Include a local fragment of HTML: *        &lt;include url=&quot;/var/www/htdocs/header.html&quot; nopre noesc /&gt; * * Note that external content is only refreshed when you save the wiki page that * contains the &lt;include/&gt;. Changing the external file WILL NOT update the wiki * page until the wiki page is edited and saved (not merely refreshed in the * browser). You can also instruct the server to refresh the page by using the * refresh action. See http://en.wikipedia.org/wiki/Wikipedia:Bypass_your_cache#Server_cache * You can add &lt;code&gt;&lt;/code&gt; * to the page to make it easier to clear the cache. * * This should almost certainly make you concerned about security! * * @package extensions * @version $Id$ * @copyright Copyright 2007 * @author Noah Spurrier * @license public domain -- free of any licenses and restrictions * * vi:ts=4:sw=4:expandtab:ft=php: */

$wgExtensionFunctions[] = &quot;wf_include&quot;; $wgExtensionCredits['other'][] = array (   'name' =&gt; 'include',    'author' =&gt; 'Noah Spurrier',    'url' =&gt; 'http://mediawiki.org/wiki/Extension:include',    'description' =&gt; 'This lets you include static content from the local file system or a remote URL.', );

function wf_include {   global $wgParser; $wgParser-&gt;setHook( &quot;include&quot;, &quot;render_include&quot; ); }

/** * render_include * * This is called automatically by the mediawiki parser extension system. * This does the work of loading an URL and returning the content. * $argv is an associative array of arguments passed in the &lt;include&gt; tag as * attributes. It should always include at least 'url'. You may set 'noesc' * to turn off HTML entities escaping. You may set 'nopre' to * turn off &lt;pre&gt;&lt;/pre&gt; tags. *  * @param mixed $input unused * @param mixed $argv associative array * @param mixed $parser unused * @access public * @return string */ function render_include ( $input, $argv, &amp;$parser ) {   if (!isset($argv['url'])) return &quot;ERROR: &lt;include&gt; tag is missing 'url' attribute.&quot;; // Could add this to restrict contents to a given path or DOCUMENT_ROOT //   if (is_file(realpath($argv['url'])) &amp;&amp; strlen(strstr(realpath($argv['url']), realpath($_SERVER['DOCUMENT_ROOT']))) &lt;= 0) //       return &quot;ERROR: url to local path is not under DOCUMENT_ROOT.&quot;; $output=file_get_contents($argv['url']); if ($output === False) return &quot;ERROR: &lt;include&gt; could not read the given url.&quot;; if ( ! isset($argv['noesc'])) $output = htmlentities( $output ); if ( ! isset($argv['nopre'])) $output = &quot;&lt;pre&gt;&quot;. $output. &quot;&lt;/pre&gt;&quot;; return $output; }

?&gt;