1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- /**
- * File name: ordonează-fluxul-după-dată.php
- * Sort an RSS feed by pubDate
- *
- * (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
- $persons = array();
- $xmla = new DOMDocument();
- $xmla->load('../20131013-consilieri.xml');
- $xpatha = new DOMXpath($xmla);
- $persons = $xpatha->query("/xml/person");
- foreach($persons as $person)
- {
- $comname = $xpatha->query("comname", $person)->item(0)->nodeValue;
- $surname = $xpatha->query("surname", $person)->item(0)->nodeValue;
- $rss_file = '../fluxuri/02-teste/'.$comname.'-'.$surname.'.xml';
- $xsl_file = '../stiluri/html-din-flux.xsl';
- $res_file = '../consilieri/știri/'.$comname.'-'.$surname.'.html';
- transformă($rss_file, $xsl_file, $res_file);
- $xml = new DOMDocument();
- $xml->load($res_file);
- $xpath = new DOMXpath($xml);
- $dates = $xpath->query('//td[@class="data"]');
- if ($dates->length > 0)
- {
- foreach($dates as $date)
- {
- $iso = $date->nodeValue;
- $match = "";
- $nice = trim(strftime("%e %B %Y", strtotime($iso)));
- preg_match('/[a-zA-Z]+/', $nice, $match);
- $month = $match[0];
- $month = $monthabr[$monthtrans[$month]];
- $nice = preg_replace('/[a-zA-Z]+/', $month, $nice);
- $date->nodeValue = $nice;
- }
- $xml->save($res_file);
- }
- }
- ?>
|