/**
 * Tests whether there are values in the URL for the party percentage or
 * votes. If that is true, it simulates the elections system and then
 * it prints the people that would get elected.
 * @return {boolean} True if an election was simulated, false otherwise.
 *     This will be used to decide whether we will still display all the
 *     candidates or just the elected ones.
 */
function maybeDisplaySimulationResults()
{
    global $_GET;
    global $VOT_PRESENCE;
    $v = getSimulationSystemValuesFromGet();
    if ($v != null) {
        $seats = simulateDHondtSystem($v);
        echo "Cu aceste procente și o prezență generală la vot " . "de {$VOT_PRESENCE}%, aceștia ar fi europarlamentarii:";
        echo "<table cellspacing=5><tr bgcolor=\"#EEEEEE\"><td></td>" . "<td>Nume</td>";
        echo "<td></td><td></td><td></td><td></td>" . "<td>Partid</td>";
        $count = 1;
        foreach ($seats as $p => $v) {
            $idparty = substr($p, 1);
            switch ($idparty) {
                case "a":
                    $idparty = "10 AND e.idperson=3336 ";
                    break;
                case "b":
                    $idparty = "10 AND e.idperson=3335 ";
                    break;
            }
            $s = mysql_query("SELECT e.name, e.idperson, e.occupation, e.birthday, " . "p.name as pname, h4.what as wh4, " . "h1.what as wh1, h2.what as wh2, h3.what as wh3 " . "FROM euro_2009_candidates AS e " . "LEFT JOIN parties AS p ON p.id = e.idparty " . "LEFT JOIN people_history AS h1 " . "ON e.idperson = h1.idperson AND h1.what='catavencu/2008' " . "LEFT JOIN people_history AS h2 " . "ON e.idperson = h2.idperson AND h2.what='results/2008' " . "LEFT JOIN people_history AS h3 " . "ON e.idperson = h3.idperson AND h3.what='euro_parliament/2007' " . "LEFT JOIN people_history AS h4 " . "ON e.idperson = h4.idperson AND h4.what='qvorum/2009' " . "WHERE idparty={$idparty} " . "ORDER BY position ASC " . "LIMIT 0, {$seats[$p]}");
            if ($idparty != "10 AND e.idperson=3336 " && $idparty != "10 AND e.idperson=3335 ") {
                echo "<tr bgcolor=#FAFAFA>";
                echo "<td colspan=7 align=center>" . getPartyNameForId($idparty) . " - {$seats[$p]} locuri</td>";
            }
            while ($r = mysql_fetch_array($s)) {
                echo "<tr>";
                echo "<td align=right>" . $count++ . "</td>";
                $name = moveFirstNameLast(ucwords(strtolower_ro($r['name'])));
                echo "<td><a href=\"?name=" . urlencode($name) . "&cid=9&id={$r['idperson']}\">{$name}</a>";
                $age = round((time() * 1000 - $r['birthday']) / (1000 * 60 * 60 * 24 * 365));
                echo ", {$age} ani";
                $idperson = $r['idperson'];
                echo "</td>";
                echo "<td align=right>" . getIconHtml($r['wh1'], $idperson) . "</td>";
                echo "<td align=right>" . getIconHtml($r['wh2'], $idperson) . "</td>";
                echo "<td align=right>" . getIconHtml($r['wh3'], $idperson) . "</td>";
                echo "<td align=right>" . getIconHtml($r['wh4'], $idperson) . "</td>";
                //echo "<td><span class=\"small gray\">{$r['occupation']}</span></td>";
                echo "<td>{$r['pname']}</td>";
            }
        }
        echo "</table>";
        return true;
    }
    return false;
}
function getCollegeNumber($college_name)
{
    preg_match("/(d|s)(\\d+) (\\w+)/", strtolower_ro($college_name), $matches);
    return $matches[2];
}
示例#3
0
 public function setDisplayName($displayName)
 {
     $this->displayName = trim($displayName, Person::TRIM_CHARS);
     $this->displayName = ucwords(strtolower_ro($this->displayName));
 }
<?php

// Prints all the stuff that a guy did that was in the 2004-2008 senate.
// We know that the person we are talking about is $person.
$sql = "SELECT e.id, e.position, p.long_name, p.name " . "FROM euro_2009_candidates as e " . "LEFT JOIN parties as p ON p.id = e.idparty " . "WHERE e.idperson = {$person->id} ";
$se = mysql_query($sql);
$re = mysql_fetch_array($se);
echo "<div>";
echo "<a href=http://www.europarl.europa.eu/elections2009/default.htm?language=ro><img src=http://www.europarl.europa.eu/eplive/expert/photo/20090209PHT48834/th_pict_20090209PHT48834.jpg width=100 align=right border=0></a>";
// Print the party belonging during his senator years
echo "Candidează pe <a href=\"?c=alegeri+europarlamentare+2009&" . "cid=10&sid=0\">" . "lista " . ucwords($re['name']) . "</a> pe poziția <b>" . "<font color=darkred size=+1>" . $re['position'] . "</font></b>.";
echo " Vezi <a href=f/{$person->id}_euro_2009_1.pdf>" . "declarația de avere și interese</a> " . "<a href=f/{$person->id}_euro_2009_1.pdf>" . "<img src=images/icon_pdf.gif border=0></a>.";
echo "<div class=small>Candidatul ";
// Select the next and previous ID's
$s = mysql_query("SELECT id, idperson, name FROM euro_2009_candidates " . "WHERE id = " . ($re['id'] - 1) . " OR id = " . ($re['id'] + 1));
while ($r = mysql_fetch_array($s)) {
    $nume = urlencode(strtolower_ro(moveFirstNameLast($r['name'])));
    if ($r['id'] == $re['id'] - 1) {
        echo "<a href=\"?name={$nume}&cid=9&id={$r['idperson']}\">anterior</a> / ";
    }
    if ($r['id'] == $re['id'] + 1) {
        echo "<a href=\"?name={$nume}&cid=9&id={$r['idperson']}\">următor</a>";
    }
}
echo ". ";
?>
Mai multe despre alegeri
<a href="?c=alegeri+europarlamentare+2009&cid=10">aici</a>.</div>
<?php 
echo "</div>";