function InsertJournals($content, $uri, $item, $ArtTitle) { //rivista-statistica //Work = Nome Senza Estensione //Exp = Nome Con _ver1 $Work = $item; $Exp = $Work . "_ver1"; $get = CreateResource($uri, $item, $Work, $Exp, $ArtTitle); if ($get != null) { return; } $content = mb_convert_encoding($content, 'HTML-ENTITIES', "UTF-8"); $doc = new DOMDocument(); $doc->loadHTML($content); $xpath = new DOMXPath($doc); //Titolo dell'articolo $title = $doc->getElementsByTagName('h3')->item(0); if ($title != NULL) { CreateTitle($Exp, $item, $title->nodeValue, 0, strlen($title->nodeValue), $title->getAttribute('id'), $uri); } //Autori articolo $aut = $xpath->query("//em[@id='div1_div2_div2_div3_div3_em1']")->item(0); $autTarget = $aut->getAttribute('id'); $aut = explode(",", $aut->nodeValue); $start = 0; foreach ($aut as $node) { $var = trim($node); CreateAuthors($Exp, $item, $var, $start, $start + strlen($var), $autTarget, $uri); $start += strlen($var) + 2; } //Abstract $astratto = $xpath->query("//p[@id='div1_div2_div2_div3_div4_div1_p1']")->item(0); if ($astratto != null) { CreateRethoric($Exp, $item, "sro:Abstract", "Questo è l' astratto dell'articolo.", 0, strlen($astratto->nodeValue), $astratto->getAttribute('id'), $uri); } else { $astratto = $xpath->query("//div[@id='div1_div2_div2_div3_div4_div1']")->item(0); CreateRethoric($Exp, $item, "sro:Abstract", "Questo è l' astratto dell'articolo.", 0, strlen($astratto->nodeValue), $astratto->getAttribute('id'), $uri); } //URL $url = $xpath->query("//a[@id='div1_div2_div2_div3_div6_a1']")->item(0); CreateUrl($Exp, $item, Normalize($url->nodeValue), 0, strlen(Normalize($url->nodeValue)), $url->getAttribute('id'), $uri, "Questo testo rappresenta l' indirizzo:" . $url->getAttribute('href')); $url = $xpath->query("//a[@id='div1_div2_div2_div3_p4_a1']")->item(0); CreateUrl($Exp, $item, Normalize($url->nodeValue), 0, strlen(Normalize($url->nodeValue)), $url->getAttribute('id'), $uri, "Questo testo rappresenta l' indirizzo:" . $url->getAttribute('href')); //Anno di pubblicazione dell'articolo $target = $xpath->query("//p[@id='div1_div2_div2_div3_p3']")->item(0); $AllStr = $target; $publicationYear = substr($AllStr->nodeValue, -18, -14); CreatePublicationYear($Exp, $item, $publicationYear, strlen($AllStr->nodeValue) - 18, strlen($AllStr->nodeValue) - 14, $target->getAttribute('id'), $uri); //DOI dell'articolo $target = $xpath->query("//a[@id='div1_div2_div2_div3_a1']")->item(0); $doi = $target->nodeValue; CreateDoi($Exp, $item, $doi, 0, strlen($doi), $target->getAttribute('id'), $uri); //Citazioni dell'articolo $cities = $xpath->query("//div[@id='div1_div2_div2_div3_div7_div1']/p"); $i = 1; foreach ($cities as $cite) { $citExp = $Exp . "_cited" . $i; $citazione = Normalize($cite->nodeValue); $parentesi = strpos($citazione, ')'); if (!is_numeric(substr($citazione, $parentesi - 1, 1))) { $parentesi -= 1; } //caso (2004b) $year = substr($citazione, $parentesi - 4, 4); if (!is_numeric($year)) { $year = substr($citazione, $parentesi - 5, 4); } //caso (2004 b) AMPIAMENTE MIGLIORABILE, FATTO AL VOLO $intera = trim(substr($citazione, $parentesi + 3, strlen($citazione))); $endtitlevirgola = strpos($intera, ','); $endtitlepunto = strpos($intera, '.'); if ($endtitlevirgola < $endtitlepunto) { $title = substr($intera, 0, $endtitlevirgola); } else { $title = substr($intera, 0, $endtitlepunto); } $fineautore = strpos($citazione, '('); //D. J. DONNELL, A. BUJA, W. STUETZLE (1994). if ($fineautore) { $fineautore = $fineautore - 2; $autori = substr($citazione, 0, $fineautore + 1); $arrayautori = explode(",", $autori); $start = 0; foreach ($arrayautori as $node) { //PROVARE: per la posizione senza usare start cerca $node nella stringa totale e poi sottrai la pos - strlen $node $var = trim($node); $len = strlen($var); if (strpos($var, 'Ö') > 0 || strpos($var, 'É') > 0 || strpos($var, 'Ú') > 0) { //decremento di uno perchè la pos con questi caratteri risulta +1 $len = $len - 1; } CreateAuthors($citExp, $item, $var, $start, $start + $len, $cite->getAttribute('id'), $uri); $start += $len + 2; } } if ($title != NULL) { CreateCities($title, $citExp, $Exp, $item, $citazione, $cite->getAttribute('id'), 0, strlen($citazione), $uri); CreateTitle($citExp, $item, $title, strpos($citazione, $title), strlen($title) + strpos($citazione, $title), $cite->getAttribute('id'), $uri); CreatePublicationYear($citExp, $item, $year, $parentesi - 4, $parentesi, $cite->getAttribute('id'), $uri); } $i++; } }
function CreateNewAnnotation($obj) { global $mainExp, $item, $mURL; $Exp = $mainExp; try { $mE = $obj->subject->value; if ($mE == "cited") { $Exp . "_cited" . GetCiteIndex($obj->subject->value); } else { if (strpos(substr($mE, -8), "cited") !== false) { $cit = substr($mE, strrpos($mE, "_")); $Exp .= "_" . $cit; } } } catch (Exception $ex) { } switch ($obj->predicate->value) { case "http://purl.org/dc/terms/title": CreateTitle($Exp, $item, Normalize(html_entity_decode($obj->object->value)), $obj->start->value, $obj->end->value, $obj->id->value, $mURL, Normalize(html_entity_decode($obj->bLabel->value))); break; case "http://purl.org/dc/terms/creator": print CreateAuthors($Exp, $item, Normalize(html_entity_decode($obj->key->value)), $obj->start->value, $obj->end->value, $obj->id->value, $mURL, Normalize(html_entity_decode($obj->bLabel->value))); break; case "http://prismstandard.org/namespaces/basic/2.0/doi": CreateDoi($Exp, $item, Normalize(html_entity_decode($obj->object->value)), $obj->start->value, $obj->end->value, $obj->id->value, $mURL, Normalize(html_entity_decode($obj->bLabel->value))); break; case "http://purl.org/spar/fabio/hasPublicationYear": CreatePublicationYear($Exp, $item, Normalize(html_entity_decode($obj->object->value)), $obj->start->value, $obj->end->value, $obj->id->value, $mURL, Normalize(html_entity_decode($obj->bLabel->value))); break; case "http://purl.org/spar/fabio/hasURL": CreateUrl($Exp, $item, Normalize(html_entity_decode($obj->object->value)), $obj->start->value, $obj->end->value, $obj->id->value, $mURL, Normalize(html_entity_decode($obj->bLabel->value))); break; case "http://purl.org/spar/cito/cites": $citExpression = $Exp . "_cited" . GetCiteIndex($obj->subject->value); CreateCities("", $citExpression, $Exp, $item, Normalize(html_entity_decode($obj->key->value)), $obj->id->value, $obj->start->value, $obj->end->value, $mURL, Normalize(html_entity_decode($obj->bLabel->value))); break; case "http://schema.org/comment": CreateComment($Exp, $item, Normalize(html_entity_decode($obj->object->value)), $obj->start->value, $obj->end->value, $obj->id->value, $mURL); break; case "http://www.ontologydesignpatterns.org/cp/owl/semiotics.owl#denotes": CreateRethoric($Exp, $item, DecodeRethoric($obj->object->value), Normalize(html_entity_decode($obj->bLabel->value)), $obj->start->value, $obj->end->value, $obj->id->value, $mURL); break; } }