From dbeadb0d6f12c62c1fe7ab160b1fda3223f80511 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 15 Dec 2017 01:12:11 +0100 Subject: [PATCH] Arteleku Updated 2017 --- djatoka.log | 0 includes/Autoridades.inc | 90 +++++ includes/theme.inc | 170 +++++++++ islandora_arteleku.info | 6 + islandora_arteleku.module | 470 ++++++++++++++++++++++++ tools/loc.php | 48 +++ tools/wikidata.php | 110 ++++++ transforms/mods_to_dc_multilingual.xslt | 401 ++++++++++++++++++++ 8 files changed, 1295 insertions(+) create mode 100755 djatoka.log create mode 100755 includes/Autoridades.inc create mode 100644 includes/theme.inc create mode 100755 islandora_arteleku.info create mode 100755 islandora_arteleku.module create mode 100755 tools/loc.php create mode 100755 tools/wikidata.php create mode 100644 transforms/mods_to_dc_multilingual.xslt diff --git a/djatoka.log b/djatoka.log new file mode 100755 index 0000000..e69de29 diff --git a/includes/Autoridades.inc b/includes/Autoridades.inc new file mode 100755 index 0000000..54cb4a2 --- /dev/null +++ b/includes/Autoridades.inc @@ -0,0 +1,90 @@ + CSS_THEME, + )); + } + + /** + * Includes the given javascript files from this module. + * + * @param type $files + */ + public static function addJS($files = array()) { + self::addFiles('drupal_add_js', PATH_XML_FORM_ELEMENTS_JS, $files); + } + + /** + * Includes the given css files from this module. + * + * @param type $files + */ + public static function addCSS($files = array()) { + self::addFiles('drupal_add_css', PATH_XML_FORM_ELEMENTS_CSS, $files, array( + 'group' => CSS_THEME, + )); + } + + /** + * Adds files using the given $method, $path and $files. + * + * @param string $function + * The function to call to add the given files. + * @param string $path + * The path where the files are located. + * @param array $files + * The file(s) to be added. + */ + private static function addFiles($function, $path, $files = array(), $additional_argument = NULL) { + // Convert string to array. + $files = (array)$files; + foreach ($files as $file) { + $function($path . $file, $additional_argument); + } + } +} diff --git a/includes/theme.inc b/includes/theme.inc new file mode 100644 index 0000000..a19ec29 --- /dev/null +++ b/includes/theme.inc @@ -0,0 +1,170 @@ +mods)){return;} + + $mods = $variables['mods']->mods; // -> Objeto MODS con el array en mods. + $lang = $language_content->language; + $ret = array(); + + foreach($mods as $element => $content): + if (empty($mods[$element])){continue;} + $l_item = _islandora_get_localized($content); + //$ret['_' . $element] = $l_item; + + $ret[$element] = theme("modselement__{$element}", array('element' => $l_item)); //array_reduce($l_item, '_islandora_arteleku_reduce_mods_array'); + + endforeach; + + return $ret; + +} + +function theme_modselement($variables){ + $r = ""; + $item = $variables['element']; + if (!is_array($item)){ + $r = $item; + }else if(isset($item['value'])){ + $r = $item['value']; + }else{ + $r = array_reduce($item, '_islandora_arteleku_reduce_mods_array'); + } + + if(!empty($result)){ + return $result . ' - ' . $r; + } + return $r; + +} + +function theme_modselement__tableOfContents($variables){ + $r = ""; + $item = $variables['element']; + if (!is_array($item)){ + $r = $item; + }else if(isset($item['value'])){ + $r = $item['value']; + }else{ + $r = array_reduce($item, '_islandora_arteleku_reduce_mods_array'); + } + $t=""; + if(!empty($r)){ + $r_split = explode(" ; ", $r); + if(count($r_split)){ + $t = ''; + } + } + + if(!empty($result)){ + return $result . ' - ' . $t; + } + + + return $t; + +} + +function theme_modselement__name($variables){ + if(empty($variables)){return;} + + $items = $variables['element']; + //dpm($items); + $ret = array(); + foreach($items as $item){ + isset($item['@valueURI']) ? $uri = $item['@valueURI'] : $uri = ""; + isset($item['namePart']['value']) ? $name = $item['namePart']['value'] : $name = ""; + $ret[] = l($name, "islandora/search/mods_name_personal_namePart_ms%3A%28\"".$name."\"%29"); + //$ret[] = l($name, $uri); + } + return '"; + +} + +function theme_modselement__titleInfo($variables){ + if(empty($variables)){return;} + $items = $variables['element']; + $ret = array(); + foreach($items as $item){ + if($item!=""): + if(isset($item['@type'])){continue;} + isset($item['title']['value']) ? $title = $item['title']['value'] : $title = ""; + isset($item['subTitle']['value']) ? $title .= ' - ' . $item['subTitle']['value'] : $title .= ""; + $ret[] = $title; + endif; + } + $t = join(' - ', $ret); + ($t == "") ? $t = t('(none)') : $t=$t; + return $t; + +} + + +function theme_modselement__part($variables){ + if(empty($variables)){return;} + $items = $variables['element']; + $inTitle = $variables['title']; + $ret = array(); + + foreach($items as $item){ + $t = ""; + if(isset($item['detail']) && $inTitle){ + if(!isset($item['detail']['@type'])){continue;} + if($item['detail']['@type'] != 'issue'){continue;} + $ar = _islandora_get_localized($item['detail']); + isset($item['detail']['@type']) ? $tipo = t($item['detail']['@type']) . ' ' : $tipo = ''; + if (is_array($ar)): + $t = $tipo . array_reduce($ar, '_islandora_arteleku_reduce_mods_array'); + else : + $t = $tipo . $ar; + endif; + }else if (!$inTitle){ + $t = array_reduce($item, '_islandora_arteleku_reduce_mods_array'); + } + $ret[] = $t; + } + $t = join(' - ', $ret); + ($t == "" && !$inTitle) ? $t = t('(none)') : $t=$t; + return $t; + +} + +function _islandora_arteleku_reduce_mods_array($result, $item){ + + $r = ""; + + if (!is_array($item)){ + $r = $item; + }else if(isset($item['value'])){ + $r = $item['value']; + }else{ + $r = array_reduce($item, '_islandora_arteleku_reduce_mods_array'); + } + + if(!empty($result)){ + return $result . ' - ' . $r; + } + return $r; + +} + +function _islandora_get_localized($item) +{ + global $language_content; + $lang = $language_content->language; + if (isset($item[$lang])){return $item[$lang];} + if (isset($item['und'])){return $item['und'];} + + $allKeys = array_keys($item); + return $item[$allKeys[0]]; + +} + + + + diff --git a/islandora_arteleku.info b/islandora_arteleku.info new file mode 100755 index 0000000..168ef6d --- /dev/null +++ b/islandora_arteleku.info @@ -0,0 +1,6 @@ +name = "Islandora Arteleku" +description = "Tools for addapt Islandora 7.x Arteleku Artxibo" +dependencies[] = islandora +package = Islandora +core = 7.x +version = 7.x-1.2 diff --git a/islandora_arteleku.module b/islandora_arteleku.module new file mode 100755 index 0000000..224e7b8 --- /dev/null +++ b/islandora_arteleku.module @@ -0,0 +1,470 @@ + t('Autoridades'), + '#type' => 'textfield', + '#default_value' => 'nada', + '#size' => 60, + //'#autocomplete_path' => 'autoridades/autocomplete', + //'#options' => array('test'=>'33'), + ); + $form['wikidata'] = array( + '#title' => t('Autoridades Wikidata'), + '#type' => 'textfield', + '#autocomplete_path' => 'autoridades/wikidata/autocomplete', + ); + $form['relators'] = array( + '#title' => t('Relators Library of Congress'), + '#type' => 'textfield', + '#autocomplete_path' => 'autoridades/loc/relators', + ); + + /*$form['submit'] = array( + '#type' => 'submit', + '#value' => 'Save', + );*/ + return $form; +} + +function islandora_arteleku_element_info() { + return array( + 'autoridades_new' => array( + '#type' => 'textfield', + '#title' => t('ejemplos de tipos'), + '#default_value' => 'test', + ), + ); +} + +//function islandora_arteleku_form_alter(&$form, &$form_state, $form_id) { dpm(print_r($form_id)); } + +function islandora_arteleku_menu() { + $items=array(); + $items['autoridades/autocomplete'] = array( + 'page callback' => '_islandora_arteleku_autocomplete', + 'access callback' => TRUE, + 'type' => MENU_CALLBACK + ); + $items['autoridades/wikidata/autocomplete'] = array( + 'page callback' => '_islandora_arteleku_wikidata_autocomplete', + 'access arguments' => array('autoridades de wikidata'), + 'type' => MENU_CALLBACK + ); + $items['autoridades/loc/relators'] = array( + 'page callback' => '_islandora_arteleku_loc_relators', + 'access arguments' => array('loc relators'), + 'type' => MENU_CALLBACK + ); + $items['genero/autocomplete'] = array( + 'page callback' => '_islandora_arteleku_marc_genre_autocomplete', + 'access callback' => TRUE, + 'type' => MENU_CALLBACK, + ); + $items['topic/autocomplete'] = array( + 'page callback' => '_islandora_arteleku_topic_autocomplete', + 'access callback' => TRUE, + 'type' => MENU_CALLBACK, + ); + $items['relator/autocomplete'] = array( + 'page callback' => '_islandora_arteleku_relator_autocomplete', + 'access callback' => TRUE, + 'type' => MENU_CALLBACK, + ); + + return $items; +} + +function _islandora_arteleku_relator_autocomplete($s) { + $matches = array(); + $vid = 3; + $result = db_select('taxonomy_term_data', 't') + -> fields('t', array('tid', 'name')) + -> condition('vid', $vid, '=') + -> condition('name', '%%'.$s.'%%', 'LIKE') + -> execute(); + + + foreach ($result as $term) { + $t = taxonomy_term_load($term->tid); + $matches[$term->name] = $term->name; + //dpm(print_r($t,TRUE)); + /*if (isset($t->field_topic_code["und"])): + $matches[$t->field_topic_code["und"][0]["value"]] = $term->name; + endif;*/ + } + + drupal_json_output($matches); +} + + +function _islandora_arteleku_topic_autocomplete($s) { + $matches = array(); + + $vid = 5; // topic list taxonomy + $result = db_select('taxonomy_term_data', 't') + -> fields('t', array('tid', 'name')) + -> condition('vid', $vid, '=') + -> condition('name', '%%'.$s.'%%', 'LIKE') + -> execute(); + + + foreach ($result as $term) { + $t = taxonomy_term_load($term->tid); + //$matches[$term->name] = $term->name; + //dpm(print_r($t,TRUE)); + if (isset($t->field_topic_code["und"])): + $matches[$t->field_topic_code["und"][0]["value"]] = $term->name; + endif; + } + + drupal_json_output($matches); +} + +function _islandora_arteleku_marc_genre_autocomplete($s) { + $matches = array(); + + $vid = 4; // marc genre list taxonomy + $result = db_select('taxonomy_term_data', 't') + -> fields('t', array('tid', 'name')) + -> condition('vid', $vid, '=') + -> condition('name', '%%'.$s.'%%', 'LIKE') + -> execute(); + + + foreach ($result as $term) { + $t = taxonomy_term_load($term->tid); + //dpm(print_r($t,TRUE)); + if (isset($t->field_genre_code["und"])) : + $matches[$t->field_genre_code["und"][0]["value"]] = $term->name; + endif; + } + + drupal_json_output($matches); +} + +function islandora_arteleku_genre_validate($field) { + $vid = 4; + $id_marcgt = $field["#value"]; + // query de busqueda del marcgt para ver si existe en la taxonomy + /*if (!existe_taxonomy($vid,$field["#value"])) { + form_set_error("autoridades",t("{$field["#value"]} no es un genero válido")); + }*/ + +} + +function _islandora_arteleku_autocomplete($string) { + + $matches = array(); + + // Buscamos en el propio vocabulario + //vocabulary id + $vid = 2; + $result = db_select('taxonomy_term_data', 't') + -> fields('t', array('tid', 'name')) + -> condition('vid', $vid, '=') + -> condition('name', '%%'.$string.'%%', 'LIKE') + //-> range(0, 10) + -> execute(); + + foreach ($result as $term) { + $matches[$term->name] = check_plain($term -> name); + } + + // Buscamos en sus sinonimos + $result = db_select('field_data_synonyms_synonyms','s') + -> fields('s',array('entity_id','synonyms_synonyms_value')) + -> condition('synonyms_synonyms_value','%%'.$string.'%%','LIKE') + //-> range(0, 10) + -> execute(); + + foreach($result as $syn) { + $t = taxonomy_term_load($syn->entity_id); + //print_r($syn,TRUE); + //$matches[$syn->synonyms_synonyms_value] = check_plain($syn->synonyms_synonyms_value); + $matches[$t->name."[{$syn->synonyms_synonyms_value}]"] = check_plain($syn->synonyms_synonyms_value); + //$matches[$syn->synonyms_synonyms_value] = check_plain($t->name); + } + + drupal_json_output($matches); +} + +function islandora_arteleku_autoridades_validate($field) { + $vid = 2; + $authority = explode("[",$field["#value"]); + if (!existe_taxonomy($vid,$authority[0])) { + form_set_error("autoridades",t("$authority[0] no es una autoridad válida")); + } +} + +function islandora_arteleku_autoridades_submit($node,$form,$form_state) { + watchdog("submit authority",print_r($form,TRUE)); +} + +function islandora_arteleku_topic_validate($field) { + $vid = 5; + if (!existe_taxonomy($vid,$field["#value"]["topic_text"])) { + form_set_error('topic validate',t("{$field["#value"]["topic_text"]} no es una temática válida.
Crea la temática antes de editar el documento. Crear tematica",array("@url" => url('admin/structure/taxonomy/tem_ticas/add')))); + } +} + +function islandora_arteleku_relator_validate($field) { + $vid = 3; + if (!existe_taxonomy($vid,$field["#value"])) { + form_set_error('relator validate',t("{$field["#value"]} no es un rol válido.
Crea el rol antes de editar el documento. Crear rol",array("@url" => url('admin/structure/taxonomy/marcrelators/add')))); + } +} + +function islandora_arteleku_term_validate($field,$vid) { + if (!existe_taxonomy($vid,$field["#value"])) { + form_set_error(NULL,t("{$field["#value"]} no es válido")); + } +} + +function existe_taxonomy($vid,$value) { + if ($value=="") { return true; } /* En el caso que sea un valor en blanco y no haya que validarlo */ + else if (isset($value)) { + $result = db_select('taxonomy_term_data', 't') + -> fields('t', array('tid', 'name')) + -> condition('vid', $vid, '=') + -> condition('name', $value, 'LIKE') + -> execute() + -> fetchAll(); + if (count($result)>0) { return true; } + else { return false; } + } +} + +function _islandora_arteleku_loc_relators($string) { + $relators = array(); + $r = new lOC(); + $it = $r->getRelators()->getIterator(); + foreach ($it as $item): + if (isset($item[""][0]["value"])) : $relators[$item[""][0]["value"]] = check_plain($item[""][0]["value"]); endif; + endforeach; + drupal_json_output($relators); +} + +function _islandora_arteleku_wikidata_autocomplete($string) { + $matches = array(); + + $wd = new wikiData(); + $it = $wd->searchEntities($string)->getIterator(); + foreach ($it as $item) : + $matches[$item['id']] = check_plain($item['label']); + endforeach; + + drupal_json_output($matches); +} + +/** + * Theme + */ +function islandora_arteleku_theme($existing, $type, $theme, $path) { + $t = array( + 'autoridades' => array( + 'render element' => 'element', + 'file' => 'includes/Autoridades.inc', + ), + 'mods_object' => array( + 'variables' => array('mods' => NULL), + 'file' => 'includes/theme.inc', + ), + 'modselement' => array( + 'variables' => array('element' => NULL), + 'file' => 'includes/theme.inc', + ), + 'modselement__name' => array( + 'variables' => array('element' => NULL), + 'file' => 'includes/theme.inc', + ), + 'modselement__titleInfo' => array( + 'variables' => array('element' => NULL), + 'file' => 'includes/theme.inc', + ), + 'modselement__part' => array( + 'variables' => array('element' => NULL, 'title' => FALSE), + 'file' => 'includes/theme.inc', + ), + 'modselement__tableOfContents' => array( + 'variables' => array('element' => NULL), + 'file' => 'includes/theme.inc', + ) + ); + + return $t; +} + +/** + * This hook allows modules to register XSLT transformations. + * + * @return array + * An associative array mapping a shortened name to the full path of the + * transformation. + */ +function islandora_arteleku_xml_form_builder_get_transforms() { + return array( + 'mods_to_dc_multilingual.xslt' => 'sites/all/modules/islandora_arteleku/transforms/mods_to_dc_multilingual.xslt', + ); +} + +function islandora_arteleku_form_submit($node,$form,$form_state) { + watchdog("islandora_arteleu","Form Submit.."); + form_set_error("sjsjsj"); + dpm(print_r($form,TRUE)); +} + + +function islandora_arteleku_islandora_sp_pdf_islandora_object_alter($object, &$context) { + watchdog("islandora_arteleku","Islandora Object Alter.."); + error_log("islandora object alter"); + dpm("alter object"); +} + +function islandora_audio_preprocess_islandora_basic_collection_collection(array &$variables) { + $variables['parent_collections'] = islandora_get_parents_from_rels_ext($islandora_object); +} + +function islandora_arteleku_islandora_object_modified($object) { +//function islandora_arteleku_islandora_sp_pdf_islandora_object_modified($object) { + //dpm(t("El objeto ha sido editado correctamente")); + error_log("MODIFIED"); + watchdog("islandora_arteleku","Modificacion del objecto $object->id"); + if (!$object) { dpm(t('No hay objecto a actualizar')); } + $pid = $object->id; + $mods = $object['MODS']; + + $mods_doc = new DomDocument(); + global $base_url; + if (!empty($mods->content) && $mods_doc->loadXML($mods->content)) : + //dpm(t("Cargamos el XML")); + $n_list = $mods_doc->getElementsByTagNameNS('http://www.loc.gov/mods/v3','name'); + foreach ($n_list as $n) { + + //dpm(t("Existe name")); + $name = "sin_nombre"; + $np_list = $n->getElementsByTagNameNS('http://www.loc.gov/mods/v3','namePart'); + //foreach ($np_list as $np) { $name = $np->nodeValue; } + + //Limpiamos el valor del synonimo si es el caso y actualizamos el nodeValue + foreach ($np_list as $np) { $name = explode("[",$np->nodeValue); } + $name = $name[0]; + $np->nodeValue = $name; + + $result = db_select('taxonomy_term_data', 't') + -> fields('t', array('tid', 'name')) + -> condition('vid', 2, '=') + -> condition('name', $name, 'LIKE') + -> execute(); + foreach ($result as $r) { $valueURI = $r->tid; } + //dpm(t("El value uri es {$valueURI}")); + $n->setAttribute('valueURI',"http://artxibo.arteleku.net/taxonomy/term/{$valueURI}"); + + // El ValueURI de RoleTerm para identificarlo en las taxonomias de islandora + $r_list = $n->getElementsByTagNameNS('http://www.loc.gov/mods/v3','role'); + foreach ($r_list as $rl) { + $rt = $rl->getElementsByTagNameNS('http://www.loc.gov/mods/v3','roleTerm'); + foreach ($rt as $r): + $role_name=$r->nodeValue; + $result = db_select('taxonomy_term_data','t') + -> fields('t',array('tid','name')) + -> condition('vid',3,'=') + -> condition('name',$role_name,'LIKE') + -> execute(); + foreach ($result as $r) { $valueURI = $r->tid; } + $r->setAttribute('valueURI',"http:/artxibo.arteleku.net/taxonomy/term/{$valueURI}"); + endforeach; + } + } + + $string = $mods_doc->saveXML(); + $mods->setContentFromString($string); + $object->ingestDatastream($mods); + else : + //dpm(t("No he encontrado un xml valido")); + endif; +} + +function islandora_arteleku_islandora_object_ingested($object) { +//function islandora_arteleku_islandora_sp_pdf_islandora_object_ingested($object) { + watchdog("islandora_arteleku","Ingesta del objecto $object->id"); + if (!$object) { dpm(t('No hay objecto a actualizar')); } + $pid = $object->id; + $mods = $object['MODS']; + + $mods_doc = new DomDocument(); + global $base_url; + if (!empty($mods->content) && $mods_doc->loadXML($mods->content)) : + $loc = $mods_doc->createElement("location"); + $url = $mods_doc->createElement("url",$base_url.'/islandora/object/'.$pid); + $loc->appendChild($url); + + + $m_list = $mods_doc->getElementsByTagNameNS('http://www.loc.gov/mods/v3', 'mods'); + foreach ($m_list as $n) : + $n->appendChild($loc); + endforeach; + + // Creamos los URIs a los namePart + $n_list = $mods_doc->getElementsByTagNameNS('http://www.loc.gov/mods/v3','name'); + foreach ($n_list as $n) { + + $name = "sin_nombre"; + $np_list = $n->getElementsByTagNameNS('http://www.loc.gov/mods/v3','namePart'); + + //Limpiamos el valor del synonimo si es el caso y actualizamos el nodeValue + foreach ($np_list as $np) { $name = explode("[",$np->nodeValue); } + $name = $name[0]; + $np->nodeValue = $name; + + $result = db_select('taxonomy_term_data', 't') + -> fields('t', array('tid', 'name')) + -> condition('vid', 2, '=') + -> condition('name', $name, 'LIKE') + -> execute(); + foreach ($result as $r) { $valueURI = $r->tid; } + $n->setAttribute('valueURI',"http://artxibo.arteleku.net/taxonomy/term/{$valueURI}"); + + // El ValueURI de RoleTerm para identificarlo en las taxonomias de islandora + $r_list = $n->getElementsByTagNameNS('http://www.loc.gov/mods/v3','roleTerm'); + foreach ($r_list as $r) { + //dpm($r); + $role_name = $r->nodeValue; + $result = db_select('taxonomy_term_data','t') + -> fields('t',array('tid','name')) + -> condition('vid',3,'=') + -> condition('name',$role_name,'LIKE') + -> execute(); + foreach ($result as $v) { $valueURI = $v->tid; } + $r->setAttribute('valueURI',"http:/artxibo.arteleku.net/taxonomy/term/{$valueURI}"); + } + } + + + + $string = $mods_doc->saveXML(); + $mods->setContentFromString($string); + $object->ingestDatastream($mods); + else : + dpm(t("No existe un XML válido")); + endif; +} + + + +?> diff --git a/tools/loc.php b/tools/loc.php new file mode 100755 index 0000000..b742226 --- /dev/null +++ b/tools/loc.php @@ -0,0 +1,48 @@ +url); + + $json = curl_exec($ch); + + $results = json_decode($json,true); + + return new arrayObject($results); + //return new arrayObject($results[""]); + } +} + + +if (isset($argv)) : + if (isset($argv[1])) $query = $argv[1]; else $query="audiolab"; + $l = new lOC(); + //print_entities($l,$query); + print_relators($l->getRelators()); +endif; + + +function print_relators($r) { + $it = $r->getIterator(); + foreach ($it as $rs): + //print_r(array_keys($rs)); + //print_r($rs[""][0]); + if (isset($rs[""][0])): + print $rs[""][0]["value"]."\n"; + endif; + endforeach; +} + + +?> diff --git a/tools/wikidata.php b/tools/wikidata.php new file mode 100755 index 0000000..5b7e12e --- /dev/null +++ b/tools/wikidata.php @@ -0,0 +1,110 @@ + 'wbsearchentities', + 'search' => $query, + 'language' => $this->language, + 'format' => 'json', + 'limit' => $this->limit, + 'type' => $this->type, + 'continue' => $continue + ); + + curl_setopt($ch,CURLOPT_POSTFIELDS,$data); + $json = curl_exec($ch); + + $results = json_decode($json,true); + + if (isset($results['search-continue'])) { + $offset = $results['search-continue']; + $r0 = new arrayObject($results['search']); + $r = array_merge((array) $r0, (array) $this->searchEntities($query,$continue=$offset)); + } else { + $r = new arrayObject($results['search']); + } + + return new arrayObject($r); + } + + function getEntities($ids) { + $ch = curl_init(); + curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); + curl_setopt($ch,CURLOPT_POST,1); + curl_setopt($ch,CURLOPT_URL,'https://en.wikidata.org/w/api.php'); + + // get id + // ?action=wbgetentities&ids=Q42 + $data = array( + 'action' => 'wbgetentities', + 'format' => 'json', + 'ids' => $ids, + 'props' => 'aliases|info' + ); + + curl_setopt($ch,CURLOPT_POSTFIELDS,$data); + $json = curl_exec($ch); + + $results = json_decode($json,true); + + return new arrayObject($results['entities']); + } +} + + +if (isset($argv)) : + if (isset($argv[1])) $query = $argv[1]; else $query="audiolab"; + $wd = new wikiData(); + print_entities($wd,$query); +endif; + + +function print_entities($wd,$query) { + $it = $wd->searchEntities($query)->getIterator(); + foreach ($it as $item) : + print $item['id']." | ".$item['label']."\n"; + //var_dump($wd->getEntities($item['id'])); + $ite = $wd->getEntities($item['id'])->getIterator(); + foreach ($ite as $entity) : + print $entity['id']."|".$entity['modified']."|\n"; + //check de los alias es,en,eu + if(isset($entity['aliases']['es'])) : + print "CASTELLANO\n"; + $aliases = new arrayObject($entity['aliases']['es']); + foreach ($aliases as $alias): + print $alias['value']."\n"; + endforeach; + endif; + if(isset($entity['aliases']['en'])) : + print "ENGLISH\n"; + $aliases = new arrayObject($entity['aliases']['en']); + foreach ($aliases as $alias): + print $alias['value']."\n"; + endforeach; + endif; + if(isset($entity['aliases']['eu'])) : + print "EUSKERA\n"; + $aliases = new arrayObject($entity['aliases']['eu']); + foreach ($aliases as $alias): + print $alias['value']."\n"; + endforeach; + endif; + endforeach; + print "\n"; + endforeach; +} + + +?> diff --git a/transforms/mods_to_dc_multilingual.xslt b/transforms/mods_to_dc_multilingual.xslt new file mode 100644 index 0000000..9e37c39 --- /dev/null +++ b/transforms/mods_to_dc_multilingual.xslt @@ -0,0 +1,401 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- + + + + + -- + + + + + + + + + + + + + + + + + + + + + + + + -- + + + + + + + + + + + + + + + - + + + + + + + + + -- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Collection + + + DataSet + + + Service + + + Software + + + Image + + + InteractiveResource + + + MovingImage + + + PhysicalObject + + + Sound + + + StillImage + + + Text + + + Text + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- + + + + + + + + + + + -- + + + + + + + + + + + + + + + + + + + + + + , + + + + , + + + + + ( + + ) + + + ( + + ) + + + + + + + + + - + + + + + - + + + + + + + + + + + +