User:Fxparlant/Touchgraph
From Meta, a Wikimedia project coordination wiki
Contents |
Demo
Architecture
- fxparlant.net
- mediawiki
- index.php
- includes
- SpecialPages.php
- SpecialTouchgraph.php
- static
- touchgraph
- reloadForm.txt
- touchgraph_dtd.txt
- touchgraph_html.txt
- linksFile.xml
- BrowserLauncher.jar
- nanoxml-2.1.1.jar
- TGLinkBrowser.jar
- touchgraph
- mediawiki
Due to url rewriting on my site, the call for .jar files couldn't be in the mediawiki folder. I put it in the "static" folder.
Sources
SpecialTouchgraph.php
<?php
function wfSpecialTouchgraph(){
global $wgUser, $wgOut,$wgRequest;
$reload = $wgRequest->getVal( 'reload' );
$fname = "wfSpecialTouchgraph";
/**** Display the reload button ****/
if($wgUser->isSysop()){
$reloadForm = file_get_contents("../static/touchgraph/reloadForm.txt");
$wgOut->addHTML( $reloadForm );
}
/**** Rebuild the links File ****/
if(($wgUser->isSysop()) && ($reload=="yes")){
$strLinksFile = file_get_contents("../static/touchgraph/touchgraph_dtd.txt");
$sql = "SELECT cur_id,cur_namespace,cur_title,cur_is_redirect FROM cur WHERE cur_namespace=14 OR cur_namespace=0 ORDER BY `cur_id` DESC";
//$sql = "SELECT cur_id,cur_namespace,cur_title,cur_is_redirect FROM cur WHERE cur_namespace=14 OR cur_namespace=0 ORDER BY `cur_id` DESC";
$res = wfQuery( $sql, DB_READ, $fname );
if ( 0 == wfNumRows( $res ) ) {
$strLinksFile .=( wfMsg( "nolinkshere" ) );
return;
}
$strLinksFile .="<NODESET>\n";
while ( $row = wfFetchObject( $res ) ) {
//$strLinksFile .= $row->cur_title;
if(14==$row->cur_namespace) {
$tgvisible="true";
$tgbg="339999";
}else{
$tgvisible="false";
$tgbg="00A0F0";
}
$tgid = $row->cur_id;
$tglabel = $row->cur_title;
$t = Title::makeTitle( $row->cur_namespace, $row->cur_title );
if( $t ) {
$tgnamespace = $t ;
} else {
$tgnamespace = $tglabel;
}
$tghint = "<h2>$tglabel</h2>
<ul>
<li><a href="http://www.fxparlant.net/Category:$tglabel" target="_blank">view</a></li>
<li><a href="http://www.fxparlant.net/mediawiki/index.php?title=Category:$tglabel&action=edit">edit</a></li>
</ul>";
$strLinksFile .="
\t<NODE nodeID=\"AutoID $tgid\">
\t\t<NODE_LOCATION visible=\"$tgvisible\"/>
\t\t<NODE_LABEL label=\"$tglabel\" shape=\"2\" backColor=\"$tgbg\" textColor=\"FFFFFF\" fontSize=\"12\"/>
\t\t<NODE_URL url=\"\" urlIsLocal=\"false\" urlIsXML=\"false\"/>
\t\t<NODE_HINT hint=\"$tghint\" width=\"150\" height=\"-1\" isHTML=\"true\"/>
\t\t</NODE>\n";
}
$strLinksFile .="</NODESET>\n";
$sql="select cfrom.cur_id AS bfrom, cto.cur_id AS bto
FROM categorylinks
INNER JOIN cur AS cfrom ON (cfrom.cur_id = categorylinks.cl_from AND cfrom.cur_namespace=14)
INNER JOIN cur AS cto ON (cto.cur_title = categorylinks.cl_to AND cto.cur_namespace=14)";
$res = wfQuery( $sql, DB_READ, $fname );
if ( 0 == wfNumRows( $res ) ) {
$strLinksFile .=( wfMsg( "nolinkshere" ) );
return;
}
$strLinksFile .="<EDGESET>\n";
while ( $row = wfFetchObject( $res ) ) {
$tglfrom = $row->bto;
$tglto = $row->bfrom;
//if($tglto == 821){
$strLinksFile .="
\t<EDGE fromID=\"AutoID $tglfrom\" toID=\"AutoID $tglto\" type=\"1\" length=\"40\" visible=\"true\" color=\"A0A0A0\"/>";
//}
}
$strLinksFile .="</EDGESET>\n";
//$strLinksFile .="<EDGESET/>\n";
$strLinksFile .="<PARAMETERS>
<PARAM name=\"offsetX\" value=\"0\"/>
<PARAM name=\"rotateSB\" value=\"0\"/>
<PARAM name=\"zoomSB\" value=\"-10\"/>
<PARAM name=\"offsetY\" value=\"0\"/>
</PARAMETERS>
</TOUCHGRAPH_LB>";
$linksFile = fopen("../static/touchgraph/linksFile.xml", "w");
fwrite($linksFile,$strLinksFile);
$wgOut->addHTML( "<br/>RELOADED<br/>" );
}
/**** Display the Java Applet from Touchgraph ***/
//$dtd = file_get_contents("touchgraph/touchgraph_dtd.txt");
$tgHtml = file_get_contents("../static/touchgraph/touchgraph_html.txt");
$var1 = "hello you all!!";
$wgOut->addHTML( $tgHtml );
$wgOut->addHTML( $var1 );
$wgOut->addHTML( "<br /><a href=\"linksFile.xml\">linksFils</a><br />" );
$wgOut->addWikiText( "WikiText goes here" );
}
?>
reloadForm.txt
<form action="http://www.fxparlant.net/Special:Touchgraph"> <input type="hidden" name="reload" value="yes" /> <input type="submit" value="reload"/> </form>
touchgraph_dtd.txt
<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE TOUCHGRAPH_LB [ <!ELEMENT TOUCHGRAPH_LB (NODESET, EDGESET, PARAMETERS)> <!ELEMENT NODESET (NODE+)> <!ELEMENT EDGESET (EDGE*)> <!ELEMENT PARAMETERS (PARAM*)> <!ELEMENT NODE (NODE_LOCATION?, NODE_LABEL?, NODE_URL?, NODE_HINT?)> <!ELEMENT NODE_LABEL EMPTY> <!ELEMENT NODE_URL EMPTY> <!ELEMENT NODE_HINT EMPTY> <!ATTLIST TOUCHGRAPH_LB version CDATA #REQUIRED > <!ATTLIST NODE nodeID CDATA #REQUIRED > <!ATTLIST NODE_LOCATION visible CDATA #IMPLIED x CDATA #IMPLIED y CDATA #IMPLIED > <!ATTLIST NODE_LABEL label CDATA #REQUIRED shape CDATA #IMPLIED backColor CDATA #IMPLIED textColor CDATA #IMPLIED fontSize CDATA #IMPLIED > <!ATTLIST NODE_URL url CDATA #REQUIRED urlIsLocal CDATA #IMPLIED urlIsXML CDATA #IMPLIED > <!ATTLIST NODE_HINT hint CDATA #REQUIRED height CDATA #IMPLIED width CDATA #IMPLIED isHTML CDATA #IMPLIED > <!ELEMENT EDGE EMPTY> <!ATTLIST EDGE fromID CDATA #REQUIRED toID CDATA #REQUIRED length CDATA #IMPLIED color CDATA #IMPLIED type CDATA #IMPLIED visible CDATA #IMPLIED > <!ELEMENT PARAM EMPTY> <!ATTLIST PARAM name CDATA #REQUIRED value CDATA #REQUIRED > ]> <TOUCHGRAPH_LB version="1.20">
touchgraph_html.txt
<center>
<!--"CONVERTED_APPLET"-->
<!-- CONVERTER VERSION 1.3 -->
<SCRIPT LANGUAGE="JavaScript"><!--
var _info = navigator.userAgent; var _ns = false;
var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0);
//--></SCRIPT>
<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!--
var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0)));
//--></SCRIPT></COMMENT>
<SCRIPT LANGUAGE="JavaScript"><!--
if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 100% HEIGHT = 100% codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"><NOEMBED><XMP>');
else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.3" CODE = "com.touchgraph.linkbrowser.LinkBrowserApplet.class" ARCHIVE = "http://www.fxparlant.net/static/touchgraph/TGLinkBrowser.jar, http://www.fxparlant.net/static/touchgraph/nanoxml-2.1.1.jar, http://www.fxparlant.net/static/touchgraph/BrowserLauncher.jar" initialXmlFile = "http://www.fxparlant.net/static/touchgraph/linksFile.xml" WIDTH=500 HEIGHT=500 browser = "yes" scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED><XMP>');
//--></SCRIPT>
<APPLET CODE = "com.touchgraph.linkbrowser.LinkBrowserApplet.class" ARCHIVE = "http://www.fxparlant.net/static/touchgraph/TGLinkBrowser.jar, http://www.fxparlant.net/static/touchgraph/nanoxml-2.1.1.jar, http://www.fxparlant.net/static/touchgraph/BrowserLauncher.jar" WIDTH=500 HEIGHT=500px></XMP>
<PARAM NAME = CODE VALUE = "com.touchgraph.linkbrowser.LinkBrowserApplet.class" >
<PARAM NAME = ARCHIVE VALUE = "http://www.fxparlant.net/static/touchgraph/TGLinkBrowser.jar, http://www.fxparlant.net/static/touchgraph/nanoxml-2.1.1.jar, http://www.fxparlant.net/static/touchgraph/BrowserLauncher.jar" >
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.3">
<PARAM NAME="scriptable" VALUE="false">
<PARAM NAME = "browser" VALUE ="yes">
<param name=targetFrame value= "targetFrame">
<param name=externalFrame value= "externalFrame">
<param name=initialXmlFile value="http://www.fxparlant.net/static/touchgraph/linksFile.xml">
<!-- <param name=initialNode value=""> -->
</APPLET>
</NOEMBED></EMBED></OBJECT>
[edit] Alternate Extension
Another Touchgraph extension is available at User:IndyGreg/TouchgraphExtension.