×
Create a new article
Write your page title here:
We currently have 3,189 articles on s23. Type your article name above or create one of the articles listed here!



    s23
    3,189Articles

    MediawikiExtensions/Interwiki: Difference between revisions

    Content added Content deleted
    imported>mutante
    mNo edit summary
     
    imported>mutante
    mNo edit summary
    Line 44: Line 44:
    ?>
    ?>
    </pre></nowiki>
    </pre></nowiki>

    [[Category:Wiki]]
    [[Category:Software]]
    [[Category:Mediawiki Extensions]]

    Revision as of 22:07, 31 August 2005

    This will allow users to use an <interwiki>Something</interwiki> tag, which will produce a table with all links from the 'interwiki' mysql table with the attached Something as query string. A contribution to wikilandia networking.

    
    <?php
    #  Interwiki Mediawiki extension
    # display interwiki links  using an <interwiki> tag.
    # reads from interwiki mysqltable and adds the
    # word in the interwiki tag to all URLs as query string
    # by mutante 24.04.2005
    
    $wgExtensionFunctions[] = "wfInterwikiExtension";
    
    function wfInterwikiExtension() {
    global $wgParser;
    $wgParser->setHook( "interwiki", "renderInterwiki" );
    }
    
    function renderInterwiki( $input ) {
    
    $input = mysql_escape_string($input);
    
    $count=0;
    $hd = mysql_connect("localhost", "wikiuser", "password") or die ("Unable to connect");
    mysql_select_db ("wikidb", $hd) or die ("Unable to select database");
    $res = mysql_query("SELECT * from interwiki", $hd) or die ("Unable to run query");
    $output="<table border='1'><tr><th colspan='2'>Interwiki-Links for '$input'</th></tr>";
    while ($row = mysql_fetch_assoc($res))
    {
    $prefix = $row["iw_prefix"];
    $url = $row["iw_url"];
    $url = substr($url, 0, -2);
    $uurl = $url . $input;
    $output.="<tr><td><a href=\"$uurl\">$prefix:$input</a></td></tr>";
    $count++;
    }
    $output.="<tr><td>S23-Automatic Interwiki-Link Generator - $count links generated.</td></tr></table>";
    
    return $output;
    
    }
    
    ?>
    

    </nowiki>

    Cookies help us deliver our services. By using our services, you agree to our use of cookies.
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.