# HG changeset patch # User Matti Hamalainen # Date 1709904147 -7200 # Node ID 91698e217f8406f85d14b8c7f90c3d11cb0d911d # Parent 7b35e4eadbcc223715519c3226338f2c95224821 Import PHP utility for reformatting wizards.txt diff -r 7b35e4eadbcc -r 91698e217f84 src/reformat_wizards.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/reformat_wizards.php Fri Mar 08 15:22:27 2024 +0200 @@ -0,0 +1,77 @@ +#!/usr/bin/php + $data) + { + $score = 0; + + if (isset($data["countries"])) $score++; + if (isset($data["desc"])) $score++; + if (isset($data["homeURL"])) $score++; + + $categories[$score][$name] = $data; + } + + krsort($categories, SORT_NUMERIC); + + if (($file = @fopen($filename, "w")) === false) + return FALSE; + + fwrite($file, + "# Information about coders/wizards. Format of this file:\n". + "# name;[3-letter country code];[http://homepageURL|bat];[https?://pictureURL|image.jpg];[freeform description]\$\n\n"); + + foreach ($categories as $id => $cat) + { + if ($id == 0) + ksort($cat, SORT_STRING); + + foreach ($cat as $name => $data) + { + if ($id > 0) + { + if (isset($data["desc"]) && strlen($data["desc"]) > 0) + $str = "\n\t".wordwrap($data["desc"], 68, "\n\t", false); + else + $str = ""; + + $str .= "\n\t\$\n\n"; + } + else + { + $str = "\$\n"; + } + + fwrite($file, + $name.";". + (isset($data["countries"]) ? implode("|", $data["countries"]) : "").";". + (isset($data["homeURL"]) ? $data["homeURL"] : "").";". + (isset($data["imageURL"]) ? $data["imageURL"] : "").";".$str); + } + fwrite($file, "\n#########################################################\n\n"); + } + + fclose($file); + return TRUE; +} + + +// Prevent non-cli execution +if (php_sapi_name() != "cli" || !empty($_SERVER["REMOTE_ADDR"])) + die("You can only run this script as a commandline application.\n"); + +if (count($argv) < 2) +{ + die("Usage: ".$argv[0]." \n"); +} + +$table = mpReadWizInfoFiles(); +mpWriteWizInfoFile($argv[1], $table); + +?>