' . $data->metadata->entePubblicatore . '
Anno di riferimento:  ' . $data->metadata->annoRiferimento . '
Ultima modifica:  ' . date_i18n("d F Y", strtotime($data->metadata->dataUltimoAggiornamentoDataset)) . '
Percorso del file:  ' . $data->metadata->urlFile . '
'; } function insertHeader(){ echo ' CIG Oggetto
Dettaglio gara Data inizio
Data fine Importo
aggiudicazione (€) Importo
liquidato (€) '; } function createDetail_td($lotto, $count){ $detail = ''; return $detail; } function testData($data){ if(!ereg("^[0-9]{4}-[0-9]{2}-[0-9]{2}$", $data)){ return false; }else{ $arrayData = explode("-", $data); $Giorno = $arrayData[2]; $Mese = $arrayData[1]; $Anno = $arrayData[0]; if(!checkdate($Mese, $Giorno, $Anno)){ return false; }else{ return true; } } } function getData($data) { $d = 'n/d'; if(testData($data)){ $d = date_i18n("d/m/Y", strtotime($data)); } return $d; } function curl_file_exists($xml_url){ $ch = curl_init($xml_url); curl_setopt($ch, CURLOPT_NOBODY, true); curl_exec($ch); $retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return $retcode == 200; } function sc_anac_xml_render($xml_url, $highlight) { if ($xml_url == null) { return false; } // Individuazione della posizione del file $fileExists = false; $my_host = $_SERVER['HTTP_HOST']; //$file_host = parse_url(stripslashes($xml_url)); //Errore file non trovato $file_host = parse_url(stripslashes($xml_url), PHP_URL_HOST); if ($my_host == $file_host){ $xml_file = $_SERVER['DOCUMENT_ROOT'] . parse_url(stripslashes($xml_url), PHP_URL_PATH); $fileExists = file_exists($xml_file); if ($fileExists) { $data = new SimpleXMLElement($xml_file, NULL, TRUE); } } else { $fileExists = curl_file_exists($xml_url); if ($fileExists) { $data = new SimpleXMLElement(file_get_contents(stripslashes($xml_url))); } } if(!$fileExists){ echo '

Il file XML richiesto non è disponibile

' . ' URL: ' . $xml_url . '
'; return false; } insertAbstract($data); echo ''; insertHeader(); echo ''; $count = 0; foreach ($data->xpath('//lotto') as $lotto) { $detail = createDetail_td($lotto, $count); echo ''; $count++; } echo '
' . $lotto->cig . ' ' . ucfirst($lotto->oggetto) . '' . $detail . ' ' . getData($lotto->tempiCompletamento->dataInizio) . '
' . getData($lotto->tempiCompletamento->dataUltimazione) . '
' . number_format((double)$lotto->importoAggiudicazione, 2, ',', ' ') . ' ' . number_format((double)$lotto->importoSommeLiquidate, 2, ',', ' ') . '
'; echo '
'; return true; } // Descrizione parametri // anac_xml_render = handle // xml_url = URL completo del file XML (anche se si trova su altro server) // highlight [0/1] = Se impostato evidenzia i lotti che presentano uno sbilancio tra aggiudicato e liquidato (default 0) // items_per_page = Numero di righi per pagina (non impostato o se uguale a 0 viene mostrata la tabella completa con un campo di testo per la ricerca a testo libero - default 10) // [anac_xml_render xml_url="" highlight=<1|0> items_per_page=] function anac_xml_render_shortcode( $atts ) { wp_enqueue_style( 'anac_xml_style', plugins_url( '/anac-xml-render.css' , __FILE__ )); extract( shortcode_atts( array( 'xml_url' => '', 'highlight' => 0, 'items_per_page' => 10, ), $atts ) ); if(!sc_anac_xml_render($xml_url, $highlight)){ return false; } if($items_per_page < 1){ $items_per_page = 10; } echo ' '; } add_shortcode( 'anac_xml_render', 'anac_xml_render_shortcode' ); //****************************************************************************** function extract_xmlData($xml_file){ $data = new SimpleXMLElement($xml_file, NULL, TRUE); return '' . $data->metadata->annoRiferimento . ' ' . gmdate("d/m/Y", strtotime($data->metadata->dataUltimoAggiornamentoDataset)) . ''; } function prepareRows($path_url){ $path_file = $_SERVER['DOCUMENT_ROOT'] . parse_url(stripslashes($path_url), PHP_URL_PATH); $img1 = plugins_url( '/img/cloud-arrow-down-32.png' , __FILE__ ); $img2 = plugins_url( '/img/cloud-magnifier-32.png' , __FILE__ ); $files = array(); $handle = opendir($path_file); while (($file = readdir($handle))!==false) { $files[] = $file; } closedir($handle); sort($files); $list = ''; $index = 0; foreach($files as $file){ if(pathinfo($file, PATHINFO_EXTENSION) == 'xml'){ $list .= ' ' . get_file_name($file) . '' . extract_xmlData($path_file . '/' . $file) . ' ' . get_file_size($path_file . '/' . $file) . ' Download
Download
'; $index++; } } return $list; } function anac_xml_create_page($path_url) { if(isset($_POST['xml_url'])){ $url = $_POST['xml_url']; echo ''; echo do_shortcode( '[anac_xml_render xml_url="' . $url . '"]'); return; }else{ if(!$path_url){ return false; } echo '

Autorità Nazionale Anti Corruzione

Adempimenti Legge 190/2012 art. 1, comma 32
Pubblicazione dei file Xml per esercizio finanziario

'; echo prepareRows($path_url); echo '
documento anno data peso scarica visualizza
'; echo '
'; } } function anac_xml_file_list_shortcode( $atts ) { wp_enqueue_style( 'anac_xml_style', plugins_url( '/anac-xml-render.css' , __FILE__ )); extract( shortcode_atts( array( 'path_url' => '', ), $atts ) ); anac_xml_create_page($path_url); } add_shortcode( 'anac_xml_file_list', 'anac_xml_file_list_shortcode' ); ?>