Nextrek
@ 1349
Nextrek / legal-map / ajax / openArticle.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
<?php require_once("SimpleXMLExtended.php"); function appendHTML($parentDom, $parentEl, $source) { $tmpDoc = new DOMDocument(); $tmpDoc->loadHTML($source); foreach ($tmpDoc->getElementsByTagName('body')->item(0)->childNodes as $node) { $node2 = $parentDom->importNode($node, true); $parentEl->appendChild($node2); } } $pathArticoli = dirname(__FILE__).'/../articoli/'; $requestedFile = $pathArticoli.$_REQUEST['html']; if (file_exists($requestedFile)) { $d = new DOMDocument; $mock = new DOMDocument; $d->loadHTML(file_get_contents($requestedFile)); $body = $d->getElementsByTagName('body')->item(0); $document_id = str_replace('.htm', '', str_replace('/','-', str_replace($pathArticoli, '', $requestedFile))); // Aggiunge fragment 'confronta_versioni.html' if (strpos($requestedFile, '_O') !== FALSE) { // Cerca revisioni $pattern = str_replace('_O.htm', '_*_O.htm',$requestedFile); $listaFileVersioni = array_reverse(glob($pattern)); if (count($listaFileVersioni)>0) { $container = $mock->createElement('div'); $source = file_get_contents(dirname(__FILE__).'/templates/confronta_versioni.html'); $parts = split('[*]', $pattern); $versioni = array(); foreach($listaFileVersioni as $f) { $versioni[] = array( 'value' => str_replace($pathArticoli, '', $f), 'text' => str_replace($parts[1], '', str_replace($parts[0], '', $f)) ); } $source = str_replace('$versioni$', json_encode($versioni), $source); $source = str_replace('$id$', $document_id, $source); appendHTML($mock, $container, $source); $mock->appendChild( $container ); } } $articolo = $mock->createElement('div'); $articolo->setAttribute('id', $document_id.'-output'); $mock->appendChild($articolo); foreach ($body->childNodes as $child){ $articolo->appendChild($mock->importNode($child, true)); } //modifica path delle immagini (puntandole alla cartella corretta) $imgs = $mock->getElementsByTagName('img'); foreach ($imgs as $img) { $src = $img->getAttribute("src"); $folder = split("/", $_REQUEST["html"])[0]; $src = "articoli/".$folder."/".$src; $img->setAttribute("src", $src); } echo $mock->saveHTML(); if (isset($_REQUEST["popup"])) { $xmlRoot; if (file_exists(dirname(__FILE__)."/../itinerari/".$_COOKIE["lm-session"].".xml")) { $xmlRoot = simplexml_load_file(dirname(__FILE__)."/../itinerari/".$_COOKIE["lm-session"].".xml", 'SimpleXMLExtended'); $articoloNodo = $xmlRoot->xpath('//articolo[@articoloId="'.$_REQUEST["padreArt"].'"]')[0]; $articoloPopup = $articoloNodo->addChild("articolopopup"); $intestazione = $articoloPopup->addChild("intestazione"); $intestazione->addCData($d->getElementsByTagName('title')->item(0)->textContent); $xmlRoot->saveXML(dirname(__FILE__)."/../itinerari/".$_COOKIE["lm-session"].".xml"); } } } else { header($_SERVER['SERVER_PROTOCOL'] . ' 404 File Not Found', true, 404); echo "<b>File Not Found</b>"; } ?> |
Commits for Nextrek/legal-map/ajax/openArticle.php
Revision | Author | Commited | Message |
---|---|---|---|
794 Diff | DRuega | Tue 06 Oct, 2015 00:07:21 +0000 | Prima interpretazione del "Diff" |
793 Diff | DRuega | Mon 05 Oct, 2015 21:45:40 +0000 | Primo pezzo di “Confronta con versioni precedenti”. |
788 Diff | FSallustio | Tue 29 Sep, 2015 09:41:39 +0000 | |
787 Diff | FSallustio | Tue 29 Sep, 2015 09:14:29 +0000 | |
782 Diff | FSallustio | Thu 24 Sep, 2015 16:12:59 +0000 | |
758 Diff | FSallustio | Thu 17 Sep, 2015 15:10:13 +0000 | |
757 | FSallustio | Thu 17 Sep, 2015 10:52:50 +0000 |