Kategorien
FreewarWiki:Bot/Skripts/LocateRegion.php: Unterschied zwischen den Versionen
< FreewarWiki:Bot | Skripts
Bwoebi (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „{{Scriptquelltextverwendung}} <pre> <?php $json = json_decode(file_get_contents("http://www.fwwiki.de/api.php?action=query&prop=info|revisions&titles=Koordinat…“) |
Bwoebi (Diskussion | Beiträge) K (typo) |
||
(3 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt) | |||
Zeile 6: | Zeile 6: | ||
print <<<'EOT' | print <<<'EOT' | ||
<!-- | <!-- | ||
- | Minimap-Setup — immer {{{{{Vorlage}}}|X1={obere linke Ecke}|X2={obere rechte Ecke}|Y1={untere linke Ecke}|Y2={untere rechte Ecke}}} | ||
Bitte immer automatisch mittels [[FreewarWiki:Bot/Skripts/LocateRegion.php]] generieren lassen (erfordert mindestens PHP 5.3) | |||
EOT; | EOT; | ||
Zeile 17: | Zeile 18: | ||
{ | { | ||
preg_match("#\{\{Gebietslink\|(.+?)\}\}#", $gebiete[$i], $match); | preg_match("#\{\{Gebietslink\|(.+?)\}\}#", $gebiete[$i], $match); | ||
print "-->{{ | print "\n-->{{{{{Vorlage}}}|{$match[1]}"; | ||
preg_match_all("#([0-9-]+?,[0-9-]+?)#U", $gebiete[$i], $match); | preg_match_all("#([0-9-]+?,[0-9-]+?)#U", $gebiete[$i], $match); | ||
$minY = $minX = PHP_INT_MAX; | $minY = $minX = PHP_INT_MAX; | ||
$maxY = $maxX = | $maxY = $maxX = ~PHP_INT_MAX; | ||
foreach ($match[1] as $koordpair) | foreach ($match[1] as $koordpair) | ||
{ | { | ||
Zeile 35: | Zeile 36: | ||
print "}}"; | print "}}"; | ||
print "<!--"; | |||
} | } | ||
print | print "\n--><noinclude>{{Dokumentation}}</noinclude>"; | ||
?> | |||
</pre> | </pre> |
Aktuelle Version vom 13. Januar 2015, 20:01 Uhr
<?php $json = json_decode(file_get_contents("http://www.fwwiki.de/api.php?action=query&prop=info|revisions&titles=Koordinaten%20(Liste)&rvprop=content&format=json"), true); $page = current($json['query']['pages']); print <<<'EOT' <!-- Minimap-Setup — immer {{{{{Vorlage}}}|X1={obere linke Ecke}|X2={obere rechte Ecke}|Y1={untere linke Ecke}|Y2={untere rechte Ecke}}} Bitte immer automatisch mittels [[FreewarWiki:Bot/Skripts/LocateRegion.php]] generieren lassen (erfordert mindestens PHP 5.3) EOT; $gebiete = explode("\n", $page['revisions'][0]['*']); for ($i = 1; $i < count($gebiete); $i++) { preg_match("#\{\{Gebietslink\|(.+?)\}\}#", $gebiete[$i], $match); print "\n-->{{{{{Vorlage}}}|{$match[1]}"; preg_match_all("#([0-9-]+?,[0-9-]+?)#U", $gebiete[$i], $match); $minY = $minX = PHP_INT_MAX; $maxY = $maxX = ~PHP_INT_MAX; foreach ($match[1] as $koordpair) { $koord = explode(",", $koordpair); $y = $koord[1]; $x = $koord[0]; $minY = min($minY, $y); $minX = min($minX, $x); $maxY = max($maxY, $y); $maxX = max($maxX, $x); } print "|X1=$minX|X2=$maxX|Y1=$minY|Y2=$maxY"; print "}}"; print "<!--"; } print "\n--><noinclude>{{Dokumentation}}</noinclude>"; ?>