123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- <?php
- /**
- * File name:
- *
- *
- * (C) Copyright 2013 Friedrich-Ebert-Stiftung (http://fes.ro)
- * Author: Tiberiu C. Turbureanu (tct@ceata.org)
- *
- * This file is part of the project funded by FES
- *
- * This is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
- require_once 'utile.php';
- // Load the list of persons
- $xml = new DOMDocument();
- $xml->load('../20131013-consilieri.xml');
- $xpath = new DOMXpath($xml);
- $persons = $xpath->query("/xml/person");
- // Load template for profiles
- $tpl = file_get_contents('../șabloane/prima.tpl');
- $psd = $pdl = $ppdd = $pc = $pnl = "";
- $fem = "";
- $psdN = $pdlN = $ppddN = $pcN = $pnlN = 0;
- $femN = 0;
- foreach($persons as $person)
- {
- $comname = $xpath->query("comname", $person)->item(0)->nodeValue;
- $surname = $xpath->query("surname", $person)->item(0)->nodeValue;
- $iname = $comname.'-'.$surname;
- $comnamep = $xpath->query("comnamep", $person)->item(0)->nodeValue;
- $surnamep = $xpath->query("surnamep", $person)->item(0)->nodeValue;
- $shortname = $comnamep.' '.$surnamep;
- $xmla = new DOMDocument();
- $xmla->load('../profile/'.$iname.'.xml');
- $xpatha = new DOMXpath($xmla);
- $party = $xpatha->query("/xml/party")->item(0)->nodeValue;
- $sex = $xpatha->query("/xml/sex")->item(0)->nodeValue;
- $image = '/imagini/01-embleme/'.$iname.'.jpg';
- $placeholder = '/imagini/naught101-ProfilePlaceholderSuit-emblema.png';
- if (!file_exists('..'.$image))
- $image = $placeholder;
- $img = '<img class="emblemă" src="'.$image.'" />';
- $ftag = $tag = $img.'<a href="/consilieri/'.$iname.'.html">'.$shortname.'</a>';
- $ftag .= ' ('.$party.')';
- $ftag = cuEtichetă("li", $ftag);
- $tag = cuEtichetă("li", $tag);
- if ($party == "PSD")
- {
- $psd .= $tag;
- $psdN++;
- }
- else if ($party == "PNL")
- {
- $pnl .= $tag;
- $pnlN++;
- }
- else if ($party == "PDL")
- {
- $pdl .= $tag;
- $pdlN++;
- }
- else if ($party == "PPDD")
- {
- $ppdd .= $tag;
- $ppddN++;
- }
- else if ($party == "PC")
- {
- $pc .= $tag;
- $pcN++;
- }
- if ($sex == "F")
- {
- $fem .= $ftag;
- $femN++;
- }
- }
- // Load template for main page
- $tpl = file_get_contents("../șabloane/prima.tpl");
- $tpl = str_replace("<!-- psd -->", $psd, $tpl);
- $tpl = str_replace("<!-- pdl -->", $pdl, $tpl);
- $tpl = str_replace("<!-- ppdd -->", $ppdd, $tpl);
- $tpl = str_replace("<!-- pc -->", $pc, $tpl);
- $tpl = str_replace("<!-- pnl -->", $pnl, $tpl);
- $tpl = str_replace("<!-- fem -->", $fem, $tpl);
- $tpl = str_replace("<!-- psdN -->", $psdN, $tpl);
- $tpl = str_replace("<!-- pdlN -->", $pdlN, $tpl);
- $tpl = str_replace("<!-- ppddN -->", $ppddN, $tpl);
- $tpl = str_replace("<!-- pcN -->", $pcN, $tpl);
- $tpl = str_replace("<!-- pnlN -->", $pnlN, $tpl);
- $tpl = str_replace("<!-- femN -->", $femN, $tpl);
- $file = fopen("../consilieri/prima.html", "w");
- fwrite($file, $tpl);
- fclose($file);
- ?>
|