Jump to content

User:Pablo-flores/Placebox.php

From Wikipedia, the free encyclopedia
   
    <html>
    <head>
    <title>Placebox generator</title>
    <style>
    #coor input { width: 2em }
    </style>
    </head>
    <body>

    <?php
        require_once('ProvinceCodec.class.php');
        $pc = new ProvinceCodec;

        if(!isset($_GET['submit'])) {
    ?>

    <p>
    Search in:
    <ul>
    <li><a href="http://www.mininterior.gov.ar/municipales/">Ministry of Interior</a></li>
    <li><a href="http://www.maplandia.com/">Maplandia</a></li>
    </ul>
    </p>

    <form action="<?php echo $PHP_SELF; ?>" method="GET">
        <table>
            <tr>
                <td>Name:</td>
                <td><input type="text" name="name" /></td>
            </tr>
            <tr>
                <td>Province:</td>
                <td><input type="text" name="province" /></td>
            </tr>
            <tr>
                <td>Department:</td>
                <td><input type="text" name="department" /></td>
            </tr>
        </table>
        <table id="coor">
            <tr>
                <td>Coordinates:</td>
                <td><input type="text" name="coor1" /></td>
                <td><input type="text" name="coor2" /></td>
                <td>South</td>
                <td><input type="text" name="coor3" /></td>
                <td><input type="text" name="coor4" /></td>
                <td>West</td>
            </tr>
        </table>
        <table>
            <tr>
                <td>Population:</td>
                <td><input type="text" name="pop" style="width: 6em" /></td>
            </tr>
            <tr>
                <td>Phone code:</td>
                <td><input type="text" name="phone" style="width: 4em" /></td>
            </tr>
        </table>
        <table>
            <tr>
                <td>Postal code:</td>
                <td><input type="text" name="cpa" style="width: 4em" /></td>
            </tr>   
        </table>
        <table>
            <tr>
                <td>Municipal information id:</td>
                <td><input type="text" name="muni" style="width: 6em" /></td>
            </tr>   
        </table>
        <p><input type="submit" name="submit" value="Generate" /></p>
    </form>

    <?php

        } else {
            $name = $_GET['name'];
            $province = $_GET['province'];
            $department = $_GET['department'];
            $coor1 = $_GET['coor1'];
            $coor2 = $_GET['coor2'];
            $coor3 = $_GET['coor3'];
            $coor4 = $_GET['coor4'];
            $pop = $_GET['pop'];
            $phone = $_GET['phone'];
            $cpaL = $pc->encode($province);
            $cpa = $_GET['cpa'];
            $muni = $_GET['muni'];

            $fields = array('{{placebox-begin}}',
            "{{city-header-ar|$name}}",
            '{{placebox-begin-data}}',
            "{{city-poli-ar|[[$province Province|$province]]|$department}}",
            "{{placebox-coor|$coor1|$coor2|S|$coor3|$coor4|W}}",
            "{{placebox-pop|$pop}}",
            "{{placebox-phone-ar|$phone}}",
            "{{placebox-postal-code-ar|$cpaL|$cpa}}",
            '{{placebox-end-data}}',
            '{{placebox-end}}');

            echo "<pre>\n";
            echo implode("\n", $fields);
            echo "'''$name''' is a city in the {{subst:province|$province|Argentina}}. It has $pop inhabitants as per the {{census-ar|2001}}.\n\n";
            echo "\n\n==References==\n";
            echo "* {{ar-mi-muni|$muni}}\n\n";
            echo "{{argentina-geo-stub}}\n\n";
            echo "[[Category:Cities in $province Province]]\n";
            echo "</pre>\n";
        }
    ?>
    </body>
    </html>