Moinmoin zusammen,
seit einigen Tagen bin ich auch stolzer Besitzer eines WP 2.0.1 mit einem Andreas09-Theme (http://fine-arts-europe.com/wordpress) und das läuft auch einwandfrei und ich bin total begeistert.
So.
Nun die grosse Frage:
Ich habe ein Plugin das mir erlaubt im Editor per ~GetWIKI(Your_Search_Term)~
den Wiki-Artikel einzubinden.
Feine Sache... funktioniert auch einwandfrei, nachdem ich die deutsche Wiki angezapft hatte!
<?php
/*
Plugin Name: GetWIKI
Version: 1.0
Plugin URI: http://saj.in/blog/techtalk/82/getwiki-plugin-for-wordpress.asp
Author: Sajin Kunhambu
Author URI: http://saj.in/
Description: Get a WIKI article anywhere on yout blog (e.g. ~GetWIKI(Your_Search_Term)~ )
*/
//Server Configuration
$host = "de.wikipedia.org";
$port = 80;
$path = "/wiki/";
//Plugin Configuration
$use_cache = true;
$cache_life = 10080;
$edit_link = false;
$retrieved_link = false;
$copy_left = "<div class=\"gfdl\">©Dieser Artikel basiert auf dem Artikel <a href=\"http://artikellink\">XYZ</a> aus der freien Enzyklopädie <a href=\"http://de.wikipedia.org\">Wikipedia</a> und steht unter der <a href=\"http://link auf lokale kopie\">GNU-Lizenz für freie Dokumentation</a>. In der Wikipedia ist eine <a href=\"http://liste der autoren_link\">Liste der Autoren</a> verfügbar.</div>";
if( !function_exists(cache_recall) || !function_exists(cache_store) ) {
// caching function not available
$use_cache = false;
}
function cleanUp( $article ) {
global $edit_link,$retrieved_link,$copy_left;
$article = str_replace("\n","",$article);
if(preg_match("/^.*(\<\!\-\- start content \-\-\>.*\<\!\-\- end content \-\-\>).*$/i",$article,$match)!=0) $article = $match[1];
$article = preg_replace("#\<\!\-\-.*\-\-\>#imseU","",$article);
$article = preg_replace("#\[\!\&\#.*\]#imseU","",$article);
if(!$retrieved_link) $article = preg_replace("#\<div\sclass=\"printfooter\".*\<\/div\>#imseU","",$article);
if(!$edit_link) $article = preg_replace("#\s*\<div\s*class=\"editsection\".*\<\/div\>\s*#imseU","",$article);
$article = str_replace("/w/","http://de.wikipedia.org/w/",$article);
$article = str_replace("/wiki/","http://de.wikipedia.org/wiki/",$article);
$article = str_replace("/skins-1.5/","http://de.wikipedia.org/skins-1.5/",$article);
$article = "<div class=\"wiki\">".$article.$copy_left."</div>";
return $article;
}
function getArticle( $title ) {
global $host,$port,$path,$use_cache,$cache_life;
if($use_cache) {
$function_string = "getArticle(".$title.")";
if($article = cache_recall($function_string,$cache_life)) return $article;
}
$out = "GET $path$title HTTP/1.0\r\nHost: $host\r\nUser-Agent: GetWiki for WordPress\r\n\r\n";
$fp = fsockopen($host, $port, $errno, $errstr, 30);
fwrite($fp, $out);
$article = "";
while (!feof($fp)) {
$article .= fgets($fp, 128);
}
if(substr($article,0,12)=="HTTP/1.0 301")
{
if(preg_match("/^.*Location\:\s(\S*).*$/im",$article,$match)!=0) {
$article = str_replace("http://de.wikipedia.org/wiki/","",$match[1]);
$article = getArticle( $article );
} else {
$article = "== WIKI Error ==";
}
}
fclose($fp);
$article = cleanUp($article);
if($use_cache) cache_store($function_string,$article);
return $article;
}
function wikify( $text ) {
$text = preg_replace(
"#\~GetWIKI\((\S*)\)\~#imseU",
"getArticle('$1')",
$text
);
return $text;
}
function wiki_css() {
echo "
<style type='text/css'>
div.wiki {
border: 1px solid silver;
background-color: #f5f5f5;
}
div.gfdl {
font-size: 80%;
}
</style>
";
}
//echo wikify("~GetWIKI(user:Sajin)~");
add_action('wp_head', 'wiki_css');
add_filter('the_content', 'wikify', 2);
add_filter('the_excerpt', 'wikify', 2);
?>
Alles anzeigen
Aber da mein Layout ziemlich schmal ist, verschiebt sich da so einiges.
Wenn man sich dies mal anschaut: http://de.wikipedia.org/wiki/Litauen
dann ist da dieses riesige Inhaltsverzeichnis; dieses Inhaltsverzeichnis wird auf/in den rechten Teil des Artikels geschoben und das sieht sehr unschön aus.
Der Artikel wird mit dieser Funktion geholt:
function cleanUp( $article ) {
global $edit_link,$retrieved_link,$copy_left;
$article = str_replace("\n","",$article);
[COLOR=Red]if(preg_match("/^.*(\<\!\-\- start content \-\-\>.*\<\!\-\- end content \-\-\>).*$/i",$article,$match)!=0) $article = $match[1];[/COLOR]
$article = preg_replace("#\<\!\-\-.*\-\-\>#imseU","",$article);
$article = preg_replace("#\[\!\&\#.*\]#imseU","",$article);
if(!$retrieved_link) $article = preg_replace("#\<div\sclass=\"printfooter\".*\<\/div\>#imseU","",$article);
if(!$edit_link) $article = preg_replace("#\s*\<div\s*class=\"editsection\".*\<\/div\>\s*#imseU","",$article);
$article = str_replace("/w/","http://de.wikipedia.org/w/",$article);
$article = str_replace("/wiki/","http://de.wikipedia.org/wiki/",$article);
$article = str_replace("/skins-1.5/","http://de.wikipedia.org/skins-1.5/",$article);
$article = "<div class=\"wiki\">".$article.$copy_left."</div>";
return $article;
}
Alles anzeigen
Das Inhaltsverzeichnis steht im Quelltext nicht am Anfang.
Wie kann ich zuerst einen Teil des Quelltextes holen, einen Teil auslassen und dann den Rest anfügen, damit ich praktisch was ausschneide?
Dafür reicht mein php-"knowhow" nicht aus...
Kann da jemand helfen, bitte?
Oder alternativ ein anderes Wiki-Plugin empfehlen, das einfacher zu verstehen ist?
mfg, cat