PluginProbe
HAL / 2.3
HAL v2.3
trunk 1.0 1.1 1.2 1.3 1.4 1.4.2 1.4.3 1.4.4 2.0 2.0.1 2.0.10 2.0.2 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.2 2.3 2.4 2.4.1 2.4.2 2.5 All 30 releases
← All changes | wp-hal.php +56 -212 2.52.3 View file →
@@ -2,9 +2,9 @@
2 2 /**
3 3 * Plugin Name: HAL
4 4 * Plugin URI: http://www.ccsd.cnrs.fr
5 5 * Description: Crée une page qui remonte les publications d'un auteur ou d'une structure en relation avec HAL et un widget des dernières publications d'un auteur ou d'une structure.
6 - * Version: 2.5
6 + * Version: 2.3
7 7 * Author: CCSD
8 8 * Author URI: http://www.ccsd.cnrs.fr
9 9 * Text Domain: wp-hal
10 10 * Domain Path: /lang/
@@ -153,9 +153,9 @@
153 153 $content = '';
154 154 if ( !wphal_is_curl_installed() ) {
155 155 $content = 'CURL not installed, please check the <a href="https://wordpress.org/plugins/hal/faq/" target="_blank" id="curl">FAQ</a> with the code : CURL';
156 156 } else {
157 - $possible_ids = ["authIdHal_s", "structId_i", "anrProjectId_i", "europeanProjectId_i", "collCode_s"];
157 + $possible_ids = ["authIdHal_s", "structId_i", "authStructId_i", "anrProjectId_i", "europeanProjectId_i", "collCode_s"];
158 158 $option_choix = !empty(get_option('option_choix')) ? get_option('option_choix') : [];
159 159 if(in_array('disciplines', $option_choix)){ //Lance les scripts pour le Graphique
160 160 wp_enqueue_style('wp-hal-style2');
161 161
@@ -176,9 +176,8 @@
176 176 'contact' => $default_contact
177 177 ),
178 178 $param
179 179 ));
180 - $content = 'Plugin is not configured correctly or shortcode parameters are not valid, please check the <a href="https://doc.archives-ouvertes.fr/afficher-une-liste-de-publications-dans-wordpress/" target="_blank" id="wrong_params">documentation</a>';
181 180
182 181 /** @var $id : defined by extract
183 182 * @var string $type : defined by extract
184 183 * @var string $contact : defined by extract
@@ -185,26 +184,16 @@
185 184 */
186 185 if (!empty($id) && in_array($type, $possible_ids)) {
187 186 $id = wphal_verifSolr($id);
188 187
189 - // in case the type is struct we need to split in order to build facet and display it back
190 - $structIDs =[];
191 - if($type=="structId_i"){
192 - $structIDs = explode(' OR ', $id);
193 - }
194 -
195 - $facets = wphal_buildfacet($option_choix, $structIDs);
196 - $facetQuery = !empty($facets) ? 'facet.field='.implode("&facet.field=", $facets).'&facet.limit=200&facet.mincount=1&facet=true':'';
197 -
198 188 if (get_option('option_groupe') == 'grouper') {
199 189 //cURL sur l'API pour récupérer les données
200 - $url = wphal_api . '?q=*:*&fq=' . $type . ':(' . urlencode($id) . ')&group=true&group.field=docType_s&group.limit=1000&fl=docid,citationFull_s&'.$facetQuery.'&sort=' . wphal_producedDateY . '&wt=json&json.nl=arrarr';
190 + $url = wphal_api . '?q=*:*&fq=' . $type . ':(' . urlencode($id) . ')&group=true&group.field=docType_s&group.limit=1000&fl=docid,citationFull_s&facet.field=' . wphal_lang . '_domainAllCodeLabel_fs&facet.field=keyword_s&facet.field=journalIdTitle_fs&facet.field=producedDateY_i&facet.field=authIdLastNameFirstName_fs&facet.field=instStructIdName_fs&facet.field=labStructIdName_fs&facet.field=deptStructIdName_fs&facet.field=rteamStructIdName_fs&facet.mincount=1&facet=true&sort=' . wphal_producedDateY . '&wt=json&json.nl=arrarr';
201 191 } elseif (get_option('option_groupe') == 'paginer') {
202 - $url = wphal_api . '?q=*:*&fq=' . $type . ':(' . urlencode($id) . ')&fl=docid,citationFull_s&'.$facetQuery.'&sort=' . wphal_producedDateY . '&wt=json&json.nl=arrarr';
192 + $url = wphal_api . '?q=*:*&fq=' . $type . ':(' . urlencode($id) . ')&fl=docid,citationFull_s&facet.field=' . wphal_lang . '_domainAllCodeLabel_fs&facet.field=keyword_s&facet.field=journalIdTitle_fs&facet.field=producedDateY_i&facet.field=authIdLastNameFirstName_fs&facet.field=instStructIdName_fs&facet.field=labStructIdName_fs&facet.field=deptStructIdName_fs&facet.field=rteamStructIdName_fs&facet.mincount=1&facet=true&sort=' . wphal_producedDateY . '&wt=json&json.nl=arrarr';
203 193 }
204 194
205 195 $json = wphal_do_get_data($url);
206 - if(!isset($json->error)){
207 196 $hal_page = (get_query_var('hal_page')) ? get_query_var('hal_page') : 1;
208 197
209 198 $content = '<div id="wphal-content">';
210 199 if (is_array($option_choix) && !empty($option_choix)){
@@ -229,12 +218,8 @@
229 218 if ($option == 'auteurs') {
230 219 $content .= '<li><a href="#auteurs" onclick="displayElem(\'wphal-auteurs\'); return false;" style="margin:1px; text-decoration: none;">' . __('Auteurs', 'wp-hal');
231 220 $content .= '</a></li>';
232 221 }
233 - if ($option == 'affiliated') {
234 - $content .= '<li><a href="#affiliated" onclick="displayElem(\'wphal-affiliated\'); return false;" style="margin:1px; text-decoration: none;">' . __('Auteurs de la structure', 'wp-hal');
235 - $content .= '</a></li>';
236 - }
237 222 if ($option == 'revues') {
238 223 $content .= '<li><a href="#revues" onclick="displayElem(\'wphal-revues\'); return false;" style="margin:1px; text-decoration: none;">' . __('Revues', 'wp-hal');
239 224 $content .= '</a></li>';
240 225 }
@@ -271,57 +256,40 @@
271 256
272 257 <ul id="wphal-cont" style="list-style-type: none;">';
273 258
274 259 if ($contact == 'yes' && $type == 'authIdHal_s') {
275 - $urlauthor = wphal_urlauthor . '?indent=true&fq=valid_s:PREFERRED&fl=fullName_s,idHal_s,hasCV_bool,arxivId_s,idrefId_s,isniId_s,orcidId_s,viafId_s&q=idHal_s:' . urlencode($id);
260 + $urlauthor = wphal_urlauthor.'?indent=true&fq=valid_s:VALID&fl=idref_s,url_s,email_s,fullName_s,arxiv_s,idHal_s,viaf_s,isni_s,orcid_s,hasCV_bool&q=idHal_s:'.urlencode($id);
276 261 $jsonauthor = wphal_do_get_data($urlauthor);
277 262
278 - foreach ($jsonauthor->response->docs as $i=>$doc) {
263 + for ($i = 0; $jsonauthor->response->docs[$i] != ''; $i++) {
279 264 $content .= '<div class="wphal-infocontact" id="wphal-infocontact'.$i.'">';
280 - if ($doc->fullName_s != '') {
281 - $content .= '<li class="wphal-fullname"><span>Nom : </span><span>'. $doc->fullName_s .'</span></li>';
265 + if ($jsonauthor->response->docs[$i]->fullName_s != '') {
266 + $content .= '<li class="wphal-fullname"><span>Nom : </span><span>'. $jsonauthor->response->docs[$i]->fullName_s .'</span></li>';
282 267 }
283 - if ($doc->idHal_s != '') {
284 - $content .= '<li class="wphal-idhal"><span>IdHAL : </span><span>' . $doc->idHal_s . '</span></li>';
268 + if ($jsonauthor->response->docs[$i]->email_s != '') {
269 + $content .= '<li class="wphal-email"><span>Email : </span><span><a href="'.esc_url('mailto:'. $jsonauthor->response->docs[$i]->email_s) .'">' . $jsonauthor->response->docs[$i]->email_s . '</a></span></li>';
285 270 }
286 - if ($doc->hasCV_bool == true){
287 - $content .= '<li class="wphal-cvhal"><span>CV HAL : </span><a href="'.esc_url(cvhal. $doc->idHal_s).'" target="_blank">CV de '.$doc->fullName_s.'</a></li>';
271 + if ($jsonauthor->response->docs[$i]->idHal_s != '') {
272 + $content .= '<li class="wphal-idhal"><span>IdHAL : </span><span>' . $jsonauthor->response->docs[$i]->idHal_s . '</span></li>';
288 273 }
289 - if (isset($doc->arxivId_s ) && is_array($doc->arxivId_s)) {
290 - $content .= '<li class="wphal-"><span>arXiv : </span><span>';
291 - foreach($doc->arxivId_s as $arxivId_s){
292 - $content .= '<a href="' . esc_url($arxivId_s) . '" target="_blank">' . substr(strrchr($arxivId_s, "/"), 1) . '</a> ,';
293 - }
294 - $content .= '</span></li>';
274 + if ($jsonauthor->response->docs[$i]->hasCV_bool == true){
275 + $content .= '<li class="wphal-cvhal"><span>CV HAL : </span><a href="'.esc_url(cvhal. $jsonauthor->response->docs[$i]->idHal_s).'" target="_blank">CV de '.$jsonauthor->response->docs[$i]->fullName_s.'</a></li>';
295 276 }
296 - if (isset($doc->idrefId_s ) && is_array($doc->idrefId_s)) {
297 - $content .= '<li class="wphal-"><span>IdRef : </span><span>';
298 - foreach($doc->idrefId_s as $idref){
299 - $content .= '<a href="' . esc_url($idref) . '" target="_blank">' . substr(strrchr($idref, "/"), 1) . '</a> ,';
300 - }
301 - $content .= '</span></li>';
277 + if ($jsonauthor->response->docs[$i]->arxiv_s != '') {
278 + $content .= '<li class="wphal-"><span>arXiv : </span><span><a href="' . esc_url($jsonauthor->response->docs[$i]->arxiv_s) . '" target="_blank">' . substr(strrchr($jsonauthor->response->docs[$i]->arxiv_s, "/"), 1) . '</a></span></li>';
302 279 }
303 - if (isset($doc->orcidId_s ) && $doc->orcidId_s != '') {
304 - $content .= '<li class="wphal-"><span>ORCID : </span><span>';
305 - foreach($doc->orcidId_s as $orcidId_s){
306 - $content .= '<a href="' . esc_url($orcidId_s) . '" target="_blank">' . substr(strrchr($orcidId_s, "/"), 1) . '</a> ,';
307 - }
308 - $content .= '</span></li>';
280 + if ($jsonauthor->response->docs[$i]->idref_s != '') {
281 + $content .= '<li class="wphal-"><span>IdRef : </span><span><a href="' . esc_url($jsonauthor->response->docs[$i]->idref_s) . '" target="_blank">' . substr(strrchr($jsonauthor->response->docs[$i]->idref_s, "/"), 1) . '</a></span></li>';
309 282 }
310 - if (isset($doc->viafId_s ) && $doc->viafId_s != '') {
311 - $content .= '<li class="wphal-"><span>VIAF : </span><span>';
312 - foreach($doc->viafId_s as $viafId_s){
313 - $content .= '<a href="' . esc_url($viafId_s) . '" target="_blank">' . substr(strrchr($viafId_s, "/"), 1) . '</a> ,';
314 - }
315 - $content .= '</span></li>';
283 + if ($jsonauthor->response->docs[$i]->orcid_s != '') {
284 + $content .= '<li class="wphal-"><span>ORCID : </span><span><a href="' . esc_url($jsonauthor->response->docs[$i]->orcid_s) . '" target="_blank">' . substr(strrchr($jsonauthor->response->docs[$i]->orcid_s, "/"), 1) . '</a></span></li>';
316 285 }
317 - if (isset($doc->isniId_s ) && $doc->isniId_s != '') {
318 - $content .= '<li class="wphal-"><span>ISNI : </span><span>';
319 - foreach($doc->isniId_s as $isniId_s){
320 - $content .= '<a href="' . esc_url($isniId_s) . '" target="_blank">' . substr(strrchr($isniId_s, "/"), 1) . '</a> ,';
321 - }
322 - $content .= '</span></li>';
286 + if ($jsonauthor->response->docs[$i]->viaf_s != '') {
287 + $content .= '<li class="wphal-"><span>VIAF : </span><span><a href="' . esc_url($jsonauthor->response->docs[$i]->viaf_s) . '" target="_blank">' . substr(strrchr($jsonauthor->response->docs[$i]->viaf_s, "/"), 1) . '</a></span></li>';
323 288 }
289 + if ($jsonauthor->response->docs[$i]->isni_s != '') {
290 + $content .= '<li class="wphal-"><span>ISNI : </span><span><a href="' . esc_url($jsonauthor->response->docs[$i]->isni_s) . '" target="_blank">' . substr(strrchr($jsonauthor->response->docs[$i]->isni_s, "/"), 1) . '</a></span></li>';
291 + }
324 292 $content .= '</div>';
325 293 }
326 294 }
327 295 if (get_option('option_email') != '') {
@@ -351,13 +319,13 @@
351 319 <div class="display" id="wphal-disciplines" style="display: none;">
352 320 <h3 class="wphal-titre">' . __('Disciplines', 'wp-hal') . '</h3>';
353 321
354 322 if (wphal_locale == 'fr_FR') {
355 - $facetdomain = isset($json->facet_counts->facet_fields->fr_domainAllCodeLabel_fs) ? $json->facet_counts->facet_fields->fr_domainAllCodeLabel_fs:null;
323 + $facetdomain = $json->facet_counts->facet_fields->fr_domainAllCodeLabel_fs;
356 324 } elseif (wphal_locale == 'es_ES') {
357 - $facetdomain = isset($json->facet_counts->facet_fields->es_domainAllCodeLabel_fs) ? $json->facet_counts->facet_fields->es_domainAllCodeLabel_fs:null;
325 + $facetdomain = $json->facet_counts->facet_fields->es_domainAllCodeLabel_fs;
358 326 } else {
359 - $facetdomain = isset($json->facet_counts->facet_fields->en_domainAllCodeLabel_fs) ? $json->facet_counts->facet_fields->en_domainAllCodeLabel_fs:null;
327 + $facetdomain = $json->facet_counts->facet_fields->en_domainAllCodeLabel_fs;
360 328 }
361 329
362 330 if (!is_null($facetdomain) && !empty($facetdomain)) {
363 331 $content .= '<div id="listdisci">';
@@ -381,9 +349,9 @@
381 349 }
382 350 $content .= '</div>
383 351 <div class="display" id="wphal-keywords" style="display: none;">
384 352 <h3 class="wphal-titre">' . __('Mots-clefs', 'wp-hal') . '</h3>';
385 - if (isset($json->facet_counts->facet_fields->keyword_s) && !is_null($json->facet_counts->facet_fields->keyword_s) && !empty($json->facet_counts->facet_fields->keyword_s)) {
353 + if (!is_null($json->facet_counts->facet_fields->keyword_s) && !empty($json->facet_counts->facet_fields->keyword_s)) {
386 354 $content .= '<div id="wphal-keys">';
387 355 $r = 0;
388 356 // CSS Nuage de mots
389 357 $maxsize = 25;
@@ -426,9 +394,9 @@
426 394 }
427 395 $content .= '</div>
428 396 <div class="display" id="wphal-auteurs" style="display: none;">
429 397 <h3 class="wphal-titre">' . __('Auteurs', 'wp-hal') . '</h3>';
430 - if (isset($json->facet_counts->facet_fields->authIdLastNameFirstName_fs) && !is_null($json->facet_counts->facet_fields->authIdLastNameFirstName_fs) && !empty($json->facet_counts->facet_fields->authIdLastNameFirstName_fs)) {
398 + if (!is_null($json->facet_counts->facet_fields->authIdLastNameFirstName_fs) && !empty($json->facet_counts->facet_fields->authIdLastNameFirstName_fs)) {
431 399 $content .= '<span id="triauteurs">';
432 400 $content .= '<button type="button" class="trial" id="triaut" onclick="toggleSort(this, true, \'wphal-aut\', \'auteursuite\', \'triaut\'); return false;" style="font-size:16px; text-decoration: none;" >Tri Alphabétique</button>';
433 401 $content .= '<button type="button" class="trioc" id="trinbaut" onclick="toggleSort(this, false, \'wphal-aut\', \'auteursuite\', \'trinbaut\'); return false;" style="font-size:16px; text-decoration: none;">Tri Occurrence</button>';
434 402 $content .= '</span>';
@@ -474,62 +442,11 @@
474 442 $content .= '</button>';
475 443 }
476 444 }
477 445 $content .= '</div>
478 - <div class="display" id="wphal-affiliated" style="display: none;">
479 - <h3 class="wphal-titre">' . __('Auteurs de la structure', 'wp-hal') . '</h3>';
480 - $parsed_facetfield = wphal_parse_affiliation_facet($json->facet_counts->facet_fields, $structIDs);
481 - if (!empty($parsed_facetfield)) {
482 - $content .= '<span id="triauteurs">';
483 - $content .= '<button type="button" class="trial" id="triaff" onclick="toggleSort(this, true, \'wphal-aff\', \'affiliateduite\', \'triaff\'); return false;" style="font-size:16px; text-decoration: none;" >Tri Alphabétique</button>';
484 - $content .= '<button type="button" class="trioc" id="trinbaff" onclick="toggleSort(this, false, \'wphal-aff\', \'affiliateduite\', \'trinbaff\'); return false;" style="font-size:16px; text-decoration: none;">Tri Occurrence</button>';
485 - $content .= '</span>';
486 - $content .= '<ul class="wphal-auteurs" style="list-style-type: none;">';
487 - $content .= '<div id="wphal-aff">';
488 - $r = 0;
489 - foreach ($parsed_facetfield as $author=>$count) {
490 - $r = $r + 1;
491 - if ($r > 10) {
492 - break;
493 - }
494 - $name = explode(wphal_delimiter, $author);
495 - if($name[1] == 0){
496 - $q = 'authLastNameFirstName_s:'.urlencode("\"".$name[2]."\"");
497 - }else{
498 - $q = "authIdPerson_i:$name[1]";
499 - }
500 - $content .= '<li class="metadata" data-percentage="' . $count . '"><img alt="user" src=" ' . esc_url(plugin_dir_url(__FILE__) . '/img/user.svg').'" style="width:16px; margin-left:2px; margin-right:2px;"/><a href="' . esc_url(halv3 . '?q='. $q . "+AND+" . $type . ':(' . $id . ')').'" target="_blank">' . $name[2] . '</a><span class="wphal-nbmetadata">' . $count . '</span></li>';
501 - }
502 - $i = 1;
503 - $content .= '<div id="affiliateduite" style="display:none;">';
504 - foreach ($parsed_facetfield as $author=>$count) {
505 - if ($r < 10) {
506 - break;
507 - }
508 - if ($i < $r) {
509 - $i = $i + 1;
510 - } else {
511 - $name = explode(wphal_delimiter, $author);
512 - if($name[1] == 0){
513 - $q = 'authLastNameFirstName_s:'.urlencode("\"".$name[2]."\"");
514 - }else{
515 - $q = "authIdPerson_i:$name[1]";
516 - }
517 - $content .= '<li class="metadata" data-percentage="' . $count . '"><img alt="user" src=" ' . esc_url(plugin_dir_url(__FILE__) . '/img/user.svg').'" style="width:16px; margin-left:2px; margin-right:2px;"/><a href="' . esc_url(halv3 . '?q='. $q . "+AND+" . $type . ':(' . $id . ')').'" target="_blank">' . $name[2] . '</a><span class="wphal-nbmetadata">' . $count . '</span></li>';
518 - }
519 - }
520 - $content .= '</div>';
521 - $content .= '</div>';
522 - $content .= '</ul>';
523 - if ($r > 10) {
524 - $content .= '<button type="button" style="text-decoration: none;" id="wphal-auteur" onclick="visibilite(\'affiliateduite\'); return false;" >' . __('Liste complète', 'wp-hal');
525 - $content .= '</button>';
526 - }
527 - }
528 - $content .= '</div>
529 446 <div class="display" id="wphal-revues" style="display: none;">
530 447 <h3 class="wphal-titre">' . __('Revues', 'wp-hal') . '</h3>';
531 - if (isset($json->facet_counts->facet_fields->journalIdTitle_fs) && !is_null($json->facet_counts->facet_fields->journalIdTitle_fs) && !empty($json->facet_counts->facet_fields->journalIdTitle_fs)) {
448 + if (!is_null($json->facet_counts->facet_fields->journalIdTitle_fs) && !empty($json->facet_counts->facet_fields->journalIdTitle_fs)) {
532 449 $content .= '<span id="trirevues">';
533 450 $content .= '<button type="button" class="trial" id="trirev" onclick="toggleSort(this, true, \'wphal-rev\', \'revuesuite\', \'trirev\'); return false;" style="font-size:16px; text-decoration: none;" >Tri Alphabétique</button>';
534 451 $content .= '<button type="button" class="trioc" id="trinbrev" onclick="toggleSort(this, false, \'wphal-rev\', \'revuesuite\', \'trinbrev\'); return false;" style="font-size:16px; text-decoration: none;">Tri Occurrence</button>';
535 452 $content .= '</span>';
@@ -567,9 +484,9 @@
567 484 }
568 485 $content .= '</div>
569 486 <div class="display" id="wphal-annees" style="display: none;">
570 487 <h3 class="wphal-titre">' . __('Année de production', 'wp-hal') . '</h3>';
571 - if (isset($json->facet_counts->facet_fields->producedDateY_i) && !is_null($json->facet_counts->facet_fields->producedDateY_i) && !empty($json->facet_counts->facet_fields->producedDateY_i)) {
488 + if (!is_null($json->facet_counts->facet_fields->producedDateY_i) && !empty($json->facet_counts->facet_fields->producedDateY_i)) {
572 489 $content .= '<span id="triannees">';
573 490 $content .= '<button type="button" class="trial" id="trian" onclick="toggleSort(this, true, \'wphal-an\', \'anneesuite\', \'trian\'); return false;" style="font-size:16px; text-decoration: none;" >Tri Alphabétique</button>';
574 491 $content .= '<button type="button" class="trioc" id="trinban" onclick="toggleSort(this, false, \'wphal-an\', \'anneesuite\', \'trinban\'); return false;" style="font-size:16px; text-decoration: none;">Tri Occurrence</button>';
575 492 $content .= '</span>';
@@ -607,9 +524,9 @@
607 524 }
608 525 $content .= '</div>
609 526 <div class="display" id="wphal-insts" style="display: none;">
610 527 <h3 class="wphal-titre">' . __('Institutions', 'wp-hal') . '</h3>';
611 - if (isset($json->facet_counts->facet_fields->instStructIdName_fs) && !is_null($json->facet_counts->facet_fields->instStructIdName_fs) && !empty($json->facet_counts->facet_fields->instStructIdName_fs)) {
528 + if (!is_null($json->facet_counts->facet_fields->instStructIdName_fs) && !empty($json->facet_counts->facet_fields->instStructIdName_fs)) {
612 529 $content .= '<span id="triinsts">';
613 530 $content .= '<button type="button" class="trial" id="triinst" onclick="toggleSort(this, true, \'wphal-institu\', \'instsuite\', \'triinst\'); return false;" style="font-size:16px; text-decoration: none;" >Tri Alphabétique</button>';
614 531 $content .= '<button type="button" class="trioc" id="trinbinst" onclick="toggleSort(this, false, \'wphal-institu\', \'instsuite\', \'trinbinst\'); return false;" style="font-size:16px; text-decoration: none;">Tri Occurrence</button>';
615 532 $content .= '</span>';
@@ -647,9 +564,9 @@
647 564 }
648 565 $content .= '</div>
649 566 <div class="display" id="wphal-labs" style="display: none;">
650 567 <h3 class="wphal-titre">' . __('Laboratoires', 'wp-hal') . '</h3>';
651 - if (isset($json->facet_counts->facet_fields->labStructIdName_fs) && !is_null($json->facet_counts->facet_fields->labStructIdName_fs) && !empty($json->facet_counts->facet_fields->labStructIdName_fs)) {
568 + if (!is_null($json->facet_counts->facet_fields->labStructIdName_fs) && !empty($json->facet_counts->facet_fields->labStructIdName_fs)) {
652 569 $content .= '<span id="trilabs">';
653 570 $content .= '<button type="button" class="trial" id="trilab" onclick="toggleSort(this, true, \'wphal-labo\', \'labsuite\', \'trilab\'); return false;" style="font-size:16px; text-decoration: none;" >Tri Alphabétique</button>';
654 571 $content .= '<button type="button" class="trioc" id="trinblab" onclick="toggleSort(this, false, \'wphal-labo\', \'labsuite\', \'trinblab\'); return false;" style="font-size:16px; text-decoration: none;">Tri Occurrence</button>';
655 572 $content .= '</span>';
@@ -688,9 +605,9 @@
688 605 }
689 606 $content .= '</div>
690 607 <div class="display" id="wphal-depts" style="display: none;">
691 608 <h3 class="wphal-titre">' . __('Départements', 'wp-hal') . '</h3>';
692 - if (isset($json->facet_counts->facet_fields->deptStructIdName_fs) && !is_null($json->facet_counts->facet_fields->deptStructIdName_fs) && !empty($json->facet_counts->facet_fields->deptStructIdName_fs)) {
609 + if (!is_null($json->facet_counts->facet_fields->deptStructIdName_fs) && !empty($json->facet_counts->facet_fields->deptStructIdName_fs)) {
693 610 $content .= '<span id="tridept">';
694 611 $content .= '<button type="button" class="trial" id="tridept" onclick="toggleSort(this, true, \'wphal-dpt\', \'deptsuite\', \'tridept\'); return false;" style="font-size:16px; text-decoration: none;" >Tri Alphabétique</button>';
695 612 $content .= '<button type="button" class="trioc" id="trinbdept" onclick="toggleSort(this, false, \'wphal-dpt\', \'deptsuite\', \'trinbdept\'); return false;" style="font-size:16px; text-decoration: none;">Tri Occurrence</button>';
696 613 $content .= '</span>';
@@ -728,9 +645,9 @@
728 645 }
729 646 $content .= '</div>
730 647 <div class="display" id="wphal-equipes" style="display: none;">
731 648 <h3 class="wphal-titre">' . __('Équipes de recherche', 'wp-hal') . '</h3>';
732 - if (isset($json->facet_counts->facet_fields->rteamStructIdName_fs) && !is_null($json->facet_counts->facet_fields->rteamStructIdName_fs) && !empty($json->facet_counts->facet_fields->rteamStructIdName_fs)) {
649 + if (!is_null($json->facet_counts->facet_fields->rteamStructIdName_fs) && !empty($json->facet_counts->facet_fields->rteamStructIdName_fs)) {
733 650 $content .= '<span id="triequipe">';
734 651 $content .= '<button type="button" class="trial" id="triequipe" onclick="toggleSort(this, true, \'wphal-rteam\', \'equipesuite\', \'triequipe\'); return false;" style="font-size:16px;text-decoration: none;" >Tri Alphabétique</button>';
735 652 $content .= '<button type="button" class="trioc" id="trinbequipe" onclick="toggleSort(this, false, \'wphal-rteam\', \'equipesuite\', \'trinbequipe\'); return false;" style="font-size:16px; text-decoration: none;">Tri Occurrence</button>';
736 653 $content .= '</span>';
@@ -835,9 +752,9 @@
835 752 if($total> $messagesParPage) {
836 753 $base_url = ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on' ? 'https' : 'http' ) . '://' . $_SERVER['HTTP_HOST'];
837 754 $url = $base_url . $_SERVER["REQUEST_URI"];
838 755 $explodedURL= explode('?', $url);
839 - $queryString = isset($explodedURL[1])?$explodedURL[1]:"";
756 + $queryString = $explodedURL[1];
840 757 $pagedHref = $explodedURL[0];
841 758 if(!empty($queryString)){
842 759 $parsedQueryString = [];
843 760 parse_str($queryString, $parsedQueryString);
@@ -921,9 +838,11 @@
921 838 }
922 839 $content .= '</div>
923 840 </div>
924 841 </div>';
925 - }}
842 + }else{
843 + $content = 'Plugin is not configured correctly or shortcode parameters are not valid, please check the <a href="https://doc.archives-ouvertes.fr/afficher-une-liste-de-publications-dans-wordpress/" target="_blank" id="wrong_params">documentation</a>';
844 + }
926 845 $content .= '<div class="wphal-footer">';
927 846 $content .= '<p style="color:#B3B2B0">' . __("Documents récupérés de l'archive ouverte HAL", 'wp-hal') . '&nbsp;<a href="' . wphal_site . '" target="_blank"><img alt="logo" src=" ' . esc_url(plugin_dir_url(__FILE__) . 'img/logo-hal.png').'" style="width:90px;"></a></p>';
928 847 $content .= '</div>';
929 848
@@ -1002,59 +921,8 @@
1002 921 } );
1003 922 return wp_kses($content, $allowed_html_tags);
1004 923 }
1005 924
1006 -/**
1007 - * build facet query based on the option choice
1008 - *
1009 - * @param array $option_choix
1010 - * @param array $structIDs to build prefixed facet
1011 - * @return array
1012 - */
1013 -function wphal_buildfacet($option_choix, $structIDs)
1014 -{
1015 - $facetQuery = [];
1016 - if (is_array($option_choix) && !empty($option_choix)) {
1017 - foreach ($option_choix as $option) {
1018 - if ($option == 'disciplines') {
1019 - $facetQuery[] = wphal_lang . '_domainAllCodeLabel_fs';
1020 - }
1021 - if ($option == 'mots-clefs') {
1022 - $facetQuery[] = 'keyword_s';
1023 - }
1024 - if ($option == 'auteurs') {
1025 - $facetQuery[] = 'authIdLastNameFirstName_fs';
1026 - }
1027 - if ($option == 'revues') {
1028 - $facetQuery[] = 'journalIdTitle_fs';
1029 - }
1030 - if ($option == 'annee') {
1031 - $facetQuery[] = 'producedDateY_i';
1032 - }
1033 - if ($option == 'institution') {
1034 - $facetQuery[] = 'instStructIdName_fs';
1035 - }
1036 - if ($option == 'laboratoire') {
1037 - $facetQuery[] = 'labStructIdName_fs';
1038 - }
1039 - if ($option == 'departement') {
1040 - $facetQuery[] = 'deptStructIdName_fs';
1041 - }
1042 - if ($option == 'equipe') {
1043 - $facetQuery[] = 'rteamStructIdName_fs';
1044 - }
1045 - if ($option == 'affiliated') {
1046 - $facetField = 'structHasAuthIdHalPersonid_s';
1047 - foreach($structIDs as $k => $structID){
1048 - $facetPrefix = $structID . wphal_delimiter;
1049 - $facetQuery[] = '&facet.field={!key=affiliated_' . $k . '+facet.prefix=' . urlencode($facetPrefix) . '}' . urlencode($facetField);
1050 - }
1051 - }
1052 - }
1053 - }
1054 - return $facetQuery;
1055 -}
1056 -
1057 925 function wphal_verifSolr($values){
1058 926 $verifsolr = explode(',',$values);
1059 927 $numverif = count($verifsolr);
1060 928 $solrsql = '';
@@ -1074,32 +942,8 @@
1074 942
1075 943 return $solrsql;
1076 944 }
1077 945
1078 -
1079 -/**
1080 - * parses the affiliation facet
1081 - *
1082 - * @return array
1083 - */
1084 -function wphal_parse_affiliation_facet($facet_fields, $structIDs)
1085 -{
1086 - $result=[];
1087 - foreach($structIDs as $k => $structID){
1088 - if(isset($facet_fields->{'affiliated_'.$k}) && !empty($facet_fields->{'affiliated_'.$k})){
1089 - foreach($facet_fields->{'affiliated_'.$k} as $r){
1090 - $t = explode(wphal_delimiter_join, $r[0]);
1091 - if (!isset($result[$t[1]])){
1092 - $result[$t[1]] = $r[1];
1093 - }else {
1094 - $result[$t[1]] += $r[1];
1095 - }
1096 - }
1097 - }
1098 - }
1099 - return $result;
1100 -}
1101 -
1102 946 function wphal_adding_style() {
1103 947 wp_register_style('wp-hal-style1', plugins_url('/css/style.css', __FILE__));
1104 948 wp_register_style('wp-hal-style2', plugins_url('/css/jquery.jqplot.css', __FILE__));
1105 949
@@ -1201,21 +1045,20 @@
1201 1045 $content = 'Please check the <a href="https://wordpress.org/plugins/hal/faq/" target="_blank" id="FAQ">FAQ</a> with the code : CURL';
1202 1046
1203 1047 } else {
1204 1048 $instance['idhal'] = wphal_verifSolr($instance['idhal']);
1205 - $fieldName = $instance['typetext'] == 'title_s' ? 'title_s':'citationFull_s';
1206 1049
1207 - $url = wphal_api . '?q=*:*&fq=' . $instance['select'] . ':' . urlencode($instance['idhal']) . '&fl=uri_s,' . $fieldName . '&sort=' . wphal_producedDateY . '&rows=' . $instance['nbdoc'] . '&wt=json';
1050 + $url = wphal_api . '?q=*:*&fq=' . $instance['select'] . ':' . urlencode($instance['idhal']) . '&fl=uri_s,' . $instance['typetext'] . '&sort=' . wphal_producedDateY . '&rows=' . $instance['nbdoc'] . '&wt=json';
1208 1051 $json = wphal_do_get_data($url);
1209 1052
1210 - $count_results = is_array($json->response->docs) ? count($json->response->docs) : 0;
1211 - if (isset($json->response->docs) && $count_results > 0) {
1053 + $count_results = count($json->response->docs);
1054 + if ($count_results > 0) {
1212 1055 $content = '<ul class="widhal-ul">';
1213 1056 for ($i = 0; $i < $count_results - 1; $i++) {
1214 - if ($fieldName == 'title_s') {
1057 + if ($instance['typetext'] == 'citationRef_s') {
1058 + $typetext = $json->response->docs[$i]->citationRef_s;
1059 + } else {
1215 1060 $typetext = $json->response->docs[$i]->title_s[0];
1216 - } else {
1217 - $typetext = $json->response->docs[$i]->citationFull_s;
1218 1061 }
1219 1062 $content .= '<li class="widhal-li"><a href="' . esc_url($json->response->docs[$i]->uri_s) . '" target="_blank">' . $typetext . '</a></li>';
1220 1063 }
1221 1064 $content .= '</ul>';
@@ -1296,9 +1139,9 @@
1296 1139 <p>
1297 1140 <label for="<?php echo esc_attr($this->get_field_id("typetext"));?>"><?php echo esc_html(__("Type d'affichage",'wp-hal')) .' :'?></label>
1298 1141 <select id="<?php echo esc_attr($this->get_field_id("typetext"));?>" name="<?php echo esc_attr($this->get_field_name("typetext"));?>">
1299 1142 <option id="<?php echo esc_attr($this->get_field_id("Title"));?>" value="title_s" <?php echo esc_attr(($instance["typetext"] == "title_s")?'selected':''); ?>><label for="<?php echo wp_kses($this->get_field_id("Title"), []);?>"><?php echo esc_html(__("Titre", 'wp-hal'))?></label></option>
1300 - <option id="<?php echo esc_attr($this->get_field_id("Citation"));?>" value="citationFull_s" <?php echo esc_attr(($instance["typetext"] == "citationFull_s")?'selected':''); ?>><label for="<?php echo esc_attr($this->get_field_id("Citation"));?>"><?php echo esc_html(__("Citation", 'wp-hal'), [])?></label></option>
1143 + <option id="<?php echo esc_attr($this->get_field_id("Citation"));?>" value="citationRef_s" <?php echo esc_attr(($instance["typetext"] == "citationRef_s")?'selected':''); ?>><label for="<?php echo esc_attr($this->get_field_id("Citation"));?>"><?php echo esc_html(__("Citation", 'wp-hal'), [])?></label></option>
1301 1144 </select>
1302 1145 </p>
1303 1146 <p>
1304 1147 <label for="<?php echo esc_attr($this->get_field_id("select"));?>"><?php echo esc_html(__("Type d'Id",'wp-hal') .' :')?></label>
@@ -1304,8 +1147,9 @@
1304 1147 <label for="<?php echo esc_attr($this->get_field_id("select"));?>"><?php echo esc_html(__("Type d'Id",'wp-hal') .' :')?></label>
1305 1148 <select id="<?php echo esc_attr($this->get_field_id("select"));?>" name="<?php echo esc_attr($this->get_field_name("select"));?>">
1306 1149 <option id="<?php echo esc_attr($this->get_field_id("Idhal"));?>" value="authIdHal_s" <?php echo esc_attr(($instance["select"] == "authIdHal_s")?'selected':''); ?>><label for="<?php echo esc_attr($this->get_field_id("Idhal"));?>">Id Hal</label><span style="font-style: italic;"> <?php echo esc_html(__('(Exemple : laurent-capelli)','wp-hal'));?></span></option>
1307 1150 <option id="<?php echo esc_attr($this->get_field_id("StructId"));?>" value="structId_i" <?php echo esc_attr(($instance["select"] == "structId_i")?'selected':''); ?>><label for="<?php echo esc_attr($this->get_field_id("StructId"));?>">Struct Id</label><span style="font-style: italic;"> <?php echo esc_html(__('(Exemple : 413106)','wp-hal'));?></span></option>
1151 + <option id="<?php echo esc_attr($this->get_field_id("AuthorStructId"));?>" value="authStructId_i" <?php echo esc_attr(($instance["select"] == "authStructId_i")?'selected':''); ?>><label for="<?php echo esc_attr($this->get_field_id("AuthorStructId"));?>">AuthorStruct Id</label><span style="font-style: italic;"> <?php echo esc_html(__('(Exemple : 413106)','wp-hal'));?></span></option>
1308 1152 <option id="<?php echo esc_attr($this->get_field_id("Anrproject"));?>" value="anrProjectId_i" <?php echo esc_attr(($instance["select"] == "anrProjectId_i")?'selected':''); ?>><label for="<?php echo esc_attr($this->get_field_id("Anrproject"));?>">anrProject Id</label><span style="font-style: italic;"> <?php echo esc_html(__('(Exemple : 1646)','wp-hal'));?></span></option>
1309 1153 <option id="<?php echo esc_attr($this->get_field_id("Europeanproject"));?>" value="europeanProjectId_i" <?php echo esc_attr(($instance["select"] == "europeanProjectId_i")?'selected':''); ?>><label for="<?php echo esc_attr($this->get_field_id("Europeanproject"));?>">europeanProject Id</label><span style="font-style: italic;"> <?php echo esc_html(__('(Exemple : 17877)','wp-hal'));?></span></option>
1310 1154 <option id="<?php echo esc_attr($this->get_field_id("Collection"));?>" value="collCode_s" <?php echo esc_attr(($instance["select"] == "collCode_s")?'selected':''); ?>><label for="<?php echo esc_attr($this->get_field_id("Collection"));?>">Collection</label><span style="font-style: italic;"> <?php echo esc_html(__('(Exemple : TICE2014)','wp-hal'));?></span></option>
1311 1155 </select>
@@ -1420,8 +1264,9 @@
1420 1264 <th scope="row"><label for="option_type"><?php echo esc_html(__('Type d\'Id','wp-hal'));?></label></th>
1421 1265 <td><select name="option_type">
1422 1266 <option id="Idhal" value="authIdHal_s" <?php echo esc_attr(((get_option('option_type') == "authIdHal_s")?'selected':'')); ?>><label for="Idhal">Id Hal</label><span style="font-style: italic;"> <?php echo esc_html(__('(Exemple : laurent-capelli)','wp-hal'));?></span></option>
1423 1267 <option id="StructId" value="structId_i" <?php echo esc_attr(((get_option('option_type') == "structId_i")?'selected':'')); ?>><label for="StructId">Struct Id</label><span style="font-style: italic;"> <?php echo esc_html(__('(Exemple : 413106)','wp-hal'));?></span></option>
1268 + <option id="AuthorStructId" value="authStructId_i" <?php echo esc_attr(((get_option('option_type') == "authStructId_i")?'selected':'')); ?>><label for="AuthorStructId">AuthorStruct Id</label><span style="font-style: italic;"> <?php echo esc_html(__('(Exemple : 413106)','wp-hal'));?></span></option>
1424 1269 <option id="Anrproject" value="anrProjectId_i" <?php echo esc_attr(((get_option('option_type') == "anrProjectId_i")?'selected':'')); ?>><label for="Anrproject">anrProject Id</label><span style="font-style: italic;"> <?php echo esc_html(__('(Exemple : 1646)','wp-hal'));?></span></option>
1425 1270 <option id="Europeanproject" value="europeanProjectId_i" <?php echo esc_attr(((get_option('option_type') == "europeanProjectId_i")?'selected':'')); ?>><label for="Europeanproject">europeanProject Id</label><span style="font-style: italic;"> <?php echo esc_html(__('(Exemple : 17877)','wp-hal'));?></span></option>
1426 1271 <option id="Collection" value="collCode_s" <?php echo esc_attr(((get_option('option_type') == "collCode_s")?'selected':'')); ?>><label for="Collection">Collection</label><span style="font-style: italic;"> <?php echo esc_html(__('(Exemple : TICE2014)','wp-hal'));?></span></option>
1427 1272 </select>
@@ -1434,21 +1279,20 @@
1434 1279 <input type="radio" name="option_groupe" id="grouper" value="grouper" <?php echo esc_js((get_option('option_groupe') == "grouper")?'checked':''); ?>><label for="grouper"><?php echo esc_html(__('Documents groupés par type','wp-hal'));?></label><br>
1435 1280 </td>
1436 1281 </tr>
1437 1282 <tr style="vertical-align:top;">
1438 - <th scope="row"><?php echo esc_html(__('Choix des éléments menu(facette)','wp-hal'));?></th>
1283 + <th scope="row"><?php echo esc_html(__('Choix des éléments menu','wp-hal'));?></th>
1439 1284 <?php $option_choix = get_option('option_choix'); ?>
1440 1285 <td><input type="checkbox" name="option_choix[1]" id="Contact" value="contact" <?php echo esc_attr((isset($option_choix[1]) && $option_choix[1] == "contact")?'checked':''); ?>><label for="Contact"><?php echo esc_html(__('Contact','wp-hal'));?></label><br/>
1441 1286 <input type="checkbox" name="option_choix[2]" id="Disciplines" value="disciplines" <?php echo esc_attr((isset($option_choix[2]) && $option_choix[2] == "disciplines")?'checked':''); ?>><label for="Disciplines"><?php echo esc_html(__('Disciplines','wp-hal'));?></label><br/>
1442 1287 <input type="checkbox" name="option_choix[3]" id="Mots-clefs" value="mots-clefs" <?php echo esc_attr((isset($option_choix[3]) && $option_choix[3] == "mots-clefs")?'checked':''); ?>><label for="Mots-clefs"><?php echo esc_html(__('Mots-clefs','wp-hal'));?></label><br/>
1443 1288 <input type="checkbox" name="option_choix[4]" id="Auteurs" value="auteurs" <?php echo esc_attr((isset($option_choix[4]) && $option_choix[4] == "auteurs")?'checked':''); ?>><label for="Auteurs"><?php echo esc_html(__('Auteurs','wp-hal'));?></label><br/>
1444 - <input type="checkbox" name="option_choix[5]" id="Affiliated" value="affiliated" <?php echo esc_attr((isset($option_choix[5]) && $option_choix[5] == "affiliated")?'checked':''); ?>><label for="Affiliated"><?php echo esc_html(__('Auteurs de la structure','wp-hal'));?></label><br/>
1445 - <input type="checkbox" name="option_choix[6]" id="Revues" value="revues" <?php echo esc_attr((isset($option_choix[6]) && $option_choix[6] == "revues")?'checked':''); ?>><label for="Revues"><?php echo esc_html(__('Revues','wp-hal'));?></label><br/>
1446 - <input type="checkbox" name="option_choix[7]" id="Annee" value="annee" <?php echo esc_attr((isset($option_choix[7]) && $option_choix[7] == "annee")?'checked':''); ?>><label for="Annee"><?php echo esc_html(__('Année de production','wp-hal'));?></label><br/>
1447 - <input type="checkbox" name="option_choix[8]" id="Institution" value="institution" <?php echo esc_attr((isset($option_choix[8]) && $option_choix[8] == "institution")?'checked':''); ?>><label for="Institution"><?php echo esc_html(__('Institutions','wp-hal'));?></label><br/>
1448 - <input type="checkbox" name="option_choix[9]" id="Laboratoire" value="laboratoire" <?php echo esc_attr((isset($option_choix[9]) && $option_choix[9] == "laboratoire")?'checked':''); ?>><label for="Laboratoire"><?php echo esc_html(__('Laboratoires','wp-hal'));?></label><br/>
1449 - <input type="checkbox" name="option_choix[10]" id="Departement" value="departement" <?php echo esc_attr((isset($option_choix[10]) && $option_choix[10] == "departement")?'checked':''); ?>><label for="Departement"><?php echo esc_html(__('Départements','wp-hal'));?></label><br/>
1450 - <input type="checkbox" name="option_choix[11]" id="Equipe" value="equipe" <?php echo esc_attr((isset($option_choix[11]) && $option_choix[11] == "equipe")?'checked':''); ?>><label for="Equipe"><?php echo esc_html(__('Équipes de recherche','wp-hal'));?></label>
1289 + <input type="checkbox" name="option_choix[5]" id="Revues" value="revues" <?php echo esc_attr((isset($option_choix[5]) && $option_choix[5] == "revues")?'checked':''); ?>><label for="Revues"><?php echo esc_html(__('Revues','wp-hal'));?></label><br/>
1290 + <input type="checkbox" name="option_choix[6]" id="Annee" value="annee" <?php echo esc_attr((isset($option_choix[6]) && $option_choix[6] == "annee")?'checked':''); ?>><label for="Annee"><?php echo esc_html(__('Année de production','wp-hal'));?></label><br/>
1291 + <input type="checkbox" name="option_choix[7]" id="Institution" value="institution" <?php echo esc_attr((isset($option_choix[7]) && $option_choix[7] == "institution")?'checked':''); ?>><label for="Institution"><?php echo esc_html(__('Institutions','wp-hal'));?></label><br/>
1292 + <input type="checkbox" name="option_choix[8]" id="Laboratoire" value="laboratoire" <?php echo esc_attr((isset($option_choix[8]) && $option_choix[8] == "laboratoire")?'checked':''); ?>><label for="Laboratoire"><?php echo esc_html(__('Laboratoires','wp-hal'));?></label><br/>
1293 + <input type="checkbox" name="option_choix[9]" id="Departement" value="departement" <?php echo esc_attr((isset($option_choix[9]) && $option_choix[9] == "departement")?'checked':''); ?>><label for="Departement"><?php echo esc_html(__('Départements','wp-hal'));?></label><br/>
1294 + <input type="checkbox" name="option_choix[10]" id="Equipe" value="equipe" <?php echo esc_attr((isset($option_choix[10]) && $option_choix[10] == "equipe")?'checked':''); ?>><label for="Equipe"><?php echo esc_html(__('Équipes de recherche','wp-hal'));?></label>
1451 1295 </td>
1452 1296 </tr>
1453 1297 <tr style="vertical-align:top;">
1454 1298 <th scope="row" style="font-size: 18px;"><?php echo esc_html(__('Contact :','wp-hal'));?></th>