| @@ -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.2 | |
| 7 | 7 | * Author: CCSD |
| 8 | 8 | * Author URI: http://www.ccsd.cnrs.fr |
| 9 | 9 | * Text Domain: wp-hal |
| 10 | 10 | * Domain Path: /lang/ |
| @@ -96,9 +96,8 @@ | ||
| 96 | 96 | $wpdb->query($sql); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | - * fetches data from cache or download data from HAL API | |
| 101 | 100 | * @param $url |
| 102 | 101 | * @return object |
| 103 | 102 | */ |
| 104 | 103 | function wphal_do_get_data($url) { |
| @@ -153,9 +152,9 @@ | ||
| 153 | 152 | $content = ''; |
| 154 | 153 | if ( !wphal_is_curl_installed() ) { |
| 155 | 154 | $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 | 155 | } else { |
| 157 | - $possible_ids = ["authIdHal_s", "structId_i", "anrProjectId_i", "europeanProjectId_i", "collCode_s"]; | |
| 156 | + $possible_ids = ["authIdHal_s", "structId_i", "authStructId_i", "authId_i", "anrProjectId_i", "europeanProjectId_i", "collCode_s"]; | |
| 158 | 157 | $option_choix = !empty(get_option('option_choix')) ? get_option('option_choix') : []; |
| 159 | 158 | if(in_array('disciplines', $option_choix)){ //Lance les scripts pour le Graphique |
| 160 | 159 | wp_enqueue_style('wp-hal-style2'); |
| 161 | 160 | |
| @@ -176,9 +175,8 @@ | ||
| 176 | 175 | 'contact' => $default_contact |
| 177 | 176 | ), |
| 178 | 177 | $param |
| 179 | 178 | )); |
| 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 | 179 | |
| 182 | 180 | /** @var $id : defined by extract |
| 183 | 181 | * @var string $type : defined by extract |
| 184 | 182 | * @var string $contact : defined by extract |
| @@ -185,26 +183,16 @@ | ||
| 185 | 183 | */ |
| 186 | 184 | if (!empty($id) && in_array($type, $possible_ids)) { |
| 187 | 185 | $id = wphal_verifSolr($id); |
| 188 | 186 | |
| 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 | 187 | if (get_option('option_groupe') == 'grouper') { |
| 199 | 188 | //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'; | |
| 189 | + $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 | 190 | } 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'; | |
| 191 | + $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 | 192 | } |
| 204 | 193 | |
| 205 | 194 | $json = wphal_do_get_data($url); |
| 206 | - if(!isset($json->error)){ | |
| 207 | 195 | $hal_page = (get_query_var('hal_page')) ? get_query_var('hal_page') : 1; |
| 208 | 196 | |
| 209 | 197 | $content = '<div id="wphal-content">'; |
| 210 | 198 | if (is_array($option_choix) && !empty($option_choix)){ |
| @@ -229,12 +217,8 @@ | ||
| 229 | 217 | if ($option == 'auteurs') { |
| 230 | 218 | $content .= '<li><a href="#auteurs" onclick="displayElem(\'wphal-auteurs\'); return false;" style="margin:1px; text-decoration: none;">' . __('Auteurs', 'wp-hal'); |
| 231 | 219 | $content .= '</a></li>'; |
| 232 | 220 | } |
| 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 | 221 | if ($option == 'revues') { |
| 238 | 222 | $content .= '<li><a href="#revues" onclick="displayElem(\'wphal-revues\'); return false;" style="margin:1px; text-decoration: none;">' . __('Revues', 'wp-hal'); |
| 239 | 223 | $content .= '</a></li>'; |
| 240 | 224 | } |
| @@ -271,57 +255,40 @@ | ||
| 271 | 255 | |
| 272 | 256 | <ul id="wphal-cont" style="list-style-type: none;">'; |
| 273 | 257 | |
| 274 | 258 | 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); | |
| 259 | + $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 | 260 | $jsonauthor = wphal_do_get_data($urlauthor); |
| 277 | 261 | |
| 278 | - foreach ($jsonauthor->response->docs as $i=>$doc) { | |
| 262 | + for ($i = 0; $jsonauthor->response->docs[$i] != ''; $i++) { | |
| 279 | 263 | $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>'; | |
| 264 | + if ($jsonauthor->response->docs[$i]->fullName_s != '') { | |
| 265 | + $content .= '<li class="wphal-fullname"><span>Nom : </span><span>'. $jsonauthor->response->docs[$i]->fullName_s .'</span></li>'; | |
| 282 | 266 | } |
| 283 | - if ($doc->idHal_s != '') { | |
| 284 | - $content .= '<li class="wphal-idhal"><span>IdHAL : </span><span>' . $doc->idHal_s . '</span></li>'; | |
| 267 | + if ($jsonauthor->response->docs[$i]->email_s != '') { | |
| 268 | + $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 | 269 | } |
| 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>'; | |
| 270 | + if ($jsonauthor->response->docs[$i]->idHal_s != '') { | |
| 271 | + $content .= '<li class="wphal-idhal"><span>IdHAL : </span><span>' . $jsonauthor->response->docs[$i]->idHal_s . '</span></li>'; | |
| 288 | 272 | } |
| 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>'; | |
| 273 | + if ($jsonauthor->response->docs[$i]->hasCV_bool == true){ | |
| 274 | + $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 | 275 | } |
| 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>'; | |
| 276 | + if ($jsonauthor->response->docs[$i]->arxiv_s != '') { | |
| 277 | + $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 | 278 | } |
| 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>'; | |
| 279 | + if ($jsonauthor->response->docs[$i]->idref_s != '') { | |
| 280 | + $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 | 281 | } |
| 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>'; | |
| 282 | + if ($jsonauthor->response->docs[$i]->orcid_s != '') { | |
| 283 | + $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 | 284 | } |
| 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>'; | |
| 285 | + if ($jsonauthor->response->docs[$i]->viaf_s != '') { | |
| 286 | + $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 | 287 | } |
| 288 | + if ($jsonauthor->response->docs[$i]->isni_s != '') { | |
| 289 | + $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>'; | |
| 290 | + } | |
| 324 | 291 | $content .= '</div>'; |
| 325 | 292 | } |
| 326 | 293 | } |
| 327 | 294 | if (get_option('option_email') != '') { |
| @@ -351,13 +318,13 @@ | ||
| 351 | 318 | <div class="display" id="wphal-disciplines" style="display: none;"> |
| 352 | 319 | <h3 class="wphal-titre">' . __('Disciplines', 'wp-hal') . '</h3>'; |
| 353 | 320 | |
| 354 | 321 | 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; | |
| 322 | + $facetdomain = $json->facet_counts->facet_fields->fr_domainAllCodeLabel_fs; | |
| 356 | 323 | } 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; | |
| 324 | + $facetdomain = $json->facet_counts->facet_fields->es_domainAllCodeLabel_fs; | |
| 358 | 325 | } else { |
| 359 | - $facetdomain = isset($json->facet_counts->facet_fields->en_domainAllCodeLabel_fs) ? $json->facet_counts->facet_fields->en_domainAllCodeLabel_fs:null; | |
| 326 | + $facetdomain = $json->facet_counts->facet_fields->en_domainAllCodeLabel_fs; | |
| 360 | 327 | } |
| 361 | 328 | |
| 362 | 329 | if (!is_null($facetdomain) && !empty($facetdomain)) { |
| 363 | 330 | $content .= '<div id="listdisci">'; |
| @@ -381,9 +348,9 @@ | ||
| 381 | 348 | } |
| 382 | 349 | $content .= '</div> |
| 383 | 350 | <div class="display" id="wphal-keywords" style="display: none;"> |
| 384 | 351 | <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)) { | |
| 352 | + if (!is_null($json->facet_counts->facet_fields->keyword_s) && !empty($json->facet_counts->facet_fields->keyword_s)) { | |
| 386 | 353 | $content .= '<div id="wphal-keys">'; |
| 387 | 354 | $r = 0; |
| 388 | 355 | // CSS Nuage de mots |
| 389 | 356 | $maxsize = 25; |
| @@ -426,9 +393,9 @@ | ||
| 426 | 393 | } |
| 427 | 394 | $content .= '</div> |
| 428 | 395 | <div class="display" id="wphal-auteurs" style="display: none;"> |
| 429 | 396 | <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)) { | |
| 397 | + if (!is_null($json->facet_counts->facet_fields->authIdLastNameFirstName_fs) && !empty($json->facet_counts->facet_fields->authIdLastNameFirstName_fs)) { | |
| 431 | 398 | $content .= '<span id="triauteurs">'; |
| 432 | 399 | $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 | 400 | $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 | 401 | $content .= '</span>'; |
| @@ -440,14 +407,9 @@ | ||
| 440 | 407 | if ($r > 10) { |
| 441 | 408 | break; |
| 442 | 409 | } |
| 443 | 410 | $name = explode(wphal_delimiter, $res[0]); |
| 444 | - if($name[0] == 0){ | |
| 445 | - $q = 'authLastNameFirstName_s:'.urlencode("\"".$name[1]."\""); | |
| 446 | - }else{ | |
| 447 | - $q = "authIdPerson_i:$name[0]"; | |
| 448 | - } | |
| 449 | - $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><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[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>'; | |
| 411 | + $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><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=authId_i:' . $name[0] . "+AND+" . $type . ':(' . $id . ')').'" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>'; | |
| 450 | 412 | } |
| 451 | 413 | $i = 1; |
| 452 | 414 | $content .= '<div id="auteursuite" style="display:none;">'; |
| 453 | 415 | foreach ($json->facet_counts->facet_fields->authIdLastNameFirstName_fs as $res) { |
| @@ -457,14 +419,9 @@ | ||
| 457 | 419 | if ($i < $r) { |
| 458 | 420 | $i = $i + 1; |
| 459 | 421 | } else { |
| 460 | 422 | $name = explode(wphal_delimiter, $res[0]); |
| 461 | - if($name[0] == 0){ | |
| 462 | - $q = 'authLastNameFirstName_s:'.urlencode("\"".$name[1]."\""); | |
| 463 | - }else{ | |
| 464 | - $q = "authIdPerson_i:$name[0]"; | |
| 465 | - } | |
| 466 | - $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><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[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>'; | |
| 423 | + $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><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=authId_i:' . $name[0] . "+AND+" . $type . ':(' . $id . ')').'" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>'; | |
| 467 | 424 | } |
| 468 | 425 | } |
| 469 | 426 | $content .= '</div>'; |
| 470 | 427 | $content .= '</div>'; |
| @@ -474,62 +431,11 @@ | ||
| 474 | 431 | $content .= '</button>'; |
| 475 | 432 | } |
| 476 | 433 | } |
| 477 | 434 | $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 | 435 | <div class="display" id="wphal-revues" style="display: none;"> |
| 530 | 436 | <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)) { | |
| 437 | + if (!is_null($json->facet_counts->facet_fields->journalIdTitle_fs) && !empty($json->facet_counts->facet_fields->journalIdTitle_fs)) { | |
| 532 | 438 | $content .= '<span id="trirevues">'; |
| 533 | 439 | $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 | 440 | $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 | 441 | $content .= '</span>'; |
| @@ -567,9 +473,9 @@ | ||
| 567 | 473 | } |
| 568 | 474 | $content .= '</div> |
| 569 | 475 | <div class="display" id="wphal-annees" style="display: none;"> |
| 570 | 476 | <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)) { | |
| 477 | + if (!is_null($json->facet_counts->facet_fields->producedDateY_i) && !empty($json->facet_counts->facet_fields->producedDateY_i)) { | |
| 572 | 478 | $content .= '<span id="triannees">'; |
| 573 | 479 | $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 | 480 | $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 | 481 | $content .= '</span>'; |
| @@ -607,9 +513,9 @@ | ||
| 607 | 513 | } |
| 608 | 514 | $content .= '</div> |
| 609 | 515 | <div class="display" id="wphal-insts" style="display: none;"> |
| 610 | 516 | <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)) { | |
| 517 | + if (!is_null($json->facet_counts->facet_fields->instStructIdName_fs) && !empty($json->facet_counts->facet_fields->instStructIdName_fs)) { | |
| 612 | 518 | $content .= '<span id="triinsts">'; |
| 613 | 519 | $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 | 520 | $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 | 521 | $content .= '</span>'; |
| @@ -647,9 +553,9 @@ | ||
| 647 | 553 | } |
| 648 | 554 | $content .= '</div> |
| 649 | 555 | <div class="display" id="wphal-labs" style="display: none;"> |
| 650 | 556 | <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)) { | |
| 557 | + if (!is_null($json->facet_counts->facet_fields->labStructIdName_fs) && !empty($json->facet_counts->facet_fields->labStructIdName_fs)) { | |
| 652 | 558 | $content .= '<span id="trilabs">'; |
| 653 | 559 | $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 | 560 | $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 | 561 | $content .= '</span>'; |
| @@ -688,9 +594,9 @@ | ||
| 688 | 594 | } |
| 689 | 595 | $content .= '</div> |
| 690 | 596 | <div class="display" id="wphal-depts" style="display: none;"> |
| 691 | 597 | <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)) { | |
| 598 | + if (!is_null($json->facet_counts->facet_fields->deptStructIdName_fs) && !empty($json->facet_counts->facet_fields->deptStructIdName_fs)) { | |
| 693 | 599 | $content .= '<span id="tridept">'; |
| 694 | 600 | $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 | 601 | $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 | 602 | $content .= '</span>'; |
| @@ -728,9 +634,9 @@ | ||
| 728 | 634 | } |
| 729 | 635 | $content .= '</div> |
| 730 | 636 | <div class="display" id="wphal-equipes" style="display: none;"> |
| 731 | 637 | <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)) { | |
| 638 | + if (!is_null($json->facet_counts->facet_fields->rteamStructIdName_fs) && !empty($json->facet_counts->facet_fields->rteamStructIdName_fs)) { | |
| 733 | 639 | $content .= '<span id="triequipe">'; |
| 734 | 640 | $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 | 641 | $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 | 642 | $content .= '</span>'; |
| @@ -832,29 +738,8 @@ | ||
| 832 | 738 | } else { |
| 833 | 739 | $content = '<div> no results !</div>'; |
| 834 | 740 | } |
| 835 | 741 | if($total> $messagesParPage) { |
| 836 | - $base_url = ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on' ? 'https' : 'http' ) . '://' . $_SERVER['HTTP_HOST']; | |
| 837 | - $url = $base_url . $_SERVER["REQUEST_URI"]; | |
| 838 | - $explodedURL= explode('?', $url); | |
| 839 | - $queryString = isset($explodedURL[1])?$explodedURL[1]:""; | |
| 840 | - $pagedHref = $explodedURL[0]; | |
| 841 | - if(!empty($queryString)){ | |
| 842 | - $parsedQueryString = []; | |
| 843 | - parse_str($queryString, $parsedQueryString); | |
| 844 | - if(isset($parsedQueryString["hal_page"])){ | |
| 845 | - unset($parsedQueryString["hal_page"]); | |
| 846 | - } | |
| 847 | - $pagedHref .= '?'; | |
| 848 | - foreach($parsedQueryString as $name => $value){ | |
| 849 | - $pagedHref .= $name.'='.$value.'&'; | |
| 850 | - } | |
| 851 | - // we add it back.. | |
| 852 | - $pagedHref .= 'hal_page='; | |
| 853 | - }else { | |
| 854 | - $pagedHref .= '?hal_page='; | |
| 855 | - } | |
| 856 | - | |
| 857 | 742 | //--AFFICHAGE PAGINATION--// |
| 858 | 743 | $precedents = $pageActuelle - 2; |
| 859 | 744 | $suivants = $pageActuelle + 2; |
| 860 | 745 | $precedent = $pageActuelle - 1; |
| @@ -863,9 +748,9 @@ | ||
| 863 | 748 | |
| 864 | 749 | $content .= '<ul class="wphal-pagination">'; |
| 865 | 750 | //--BOUTON PRECEDENT--// |
| 866 | 751 | if ( $pageActuelle != 1 ) { |
| 867 | - $content .= '<li><a href="'. $pagedHref . $precedent . '">«</a></li>'; | |
| 752 | + $content .= '<li><a href="?hal_page=' . $precedent . '">«</a></li>'; | |
| 868 | 753 | } |
| 869 | 754 | if ( $nombreDePages <= 6 ) {// Cas 1 : 6 pages ou moins - Pas de troncature |
| 870 | 755 | for ( $i = 1; $i <= $nombreDePages; $i ++ ) { |
| 871 | 756 | if ( $i == $pageActuelle ) { |
| @@ -870,9 +755,9 @@ | ||
| 870 | 755 | for ( $i = 1; $i <= $nombreDePages; $i ++ ) { |
| 871 | 756 | if ( $i == $pageActuelle ) { |
| 872 | 757 | $content .= '<li class="active"><a href="#">' . $i . '</a></li>'; |
| 873 | 758 | } else { |
| 874 | - $content .= ' <li><a href="'. $pagedHref . $i . '">' . $i . '</a></li> '; | |
| 759 | + $content .= ' <li><a href="?hal_page=' . $i . '">' . $i . '</a></li> '; | |
| 875 | 760 | } |
| 876 | 761 | } |
| 877 | 762 | } elseif ( $nombreDePages >= 7 ) {// Cas 2 : 7 pages ou plus - Troncature |
| 878 | 763 | if ( $pageActuelle <= 3 ) {// Lorsque l'on est sur les trois premières pages |
| @@ -879,35 +764,35 @@ | ||
| 879 | 764 | for ( $i = 1; $i <= 4; $i ++ ) { |
| 880 | 765 | if ( $i == $pageActuelle ) { |
| 881 | 766 | $content .= '<li class="active"><a href="#">' . $i . '</a></li>'; |
| 882 | 767 | } else { |
| 883 | - $content .= '<li><a href="'. $pagedHref . $i . '">' . $i . '</a></li>'; | |
| 768 | + $content .= '<li><a href="?hal_page=' . $i . '">' . $i . '</a></li>'; | |
| 884 | 769 | } |
| 885 | 770 | } |
| 886 | 771 | $content .= '<li class="disabled"><a href="#">…</a></li>'; |
| 887 | - $content .= '<li><a href="'. $pagedHref . $penultimate . '">' . $penultimate . '</a></li>'; | |
| 888 | - $content .= '<li><a href="'. $pagedHref . $nombreDePages . '">' . $nombreDePages . '</a></li>'; | |
| 772 | + $content .= '<li><a href="?hal_page=' . $penultimate . '">' . $penultimate . '</a></li>'; | |
| 773 | + $content .= '<li><a href="?hal_page=' . $nombreDePages . '">' . $nombreDePages . '</a></li>'; | |
| 889 | 774 | } |
| 890 | 775 | if ( $pageActuelle >= 4 && $pageActuelle <= $penultimate - 2 ) {//Lorsque l'on arrive sur la quatrième page |
| 891 | - $content .= '<li><a href="'.$pagedHref.'1">1</a></li>'; | |
| 776 | + $content .= '<li><a href="?hal_page=">1</a></li>'; | |
| 892 | 777 | $content .= '<li class="disabled"><a href="#">…</a></li>'; |
| 893 | - $content .= '<li><a href="'. $pagedHref . $precedents . '">' . $precedents . '</a></li>'; | |
| 894 | - $content .= '<li><a href="'. $pagedHref . $precedent . '">' . $precedent . '</a></li>'; | |
| 778 | + $content .= '<li><a href="?hal_page=' . $precedents . '">' . $precedents . '</a></li>'; | |
| 779 | + $content .= '<li><a href="?hal_page=' . $precedent . '">' . $precedent . '</a></li>'; | |
| 895 | 780 | $content .= '<li class="active"><a href="#">' . $pageActuelle . '</a></li>'; |
| 896 | - $content .= '<li><a href="'. $pagedHref . $suivant . '">' . $suivant . '</a></li>'; | |
| 897 | - $content .= '<li><a href="'. $pagedHref . $suivants . '">' . $suivants . '</a></li>'; | |
| 781 | + $content .= '<li><a href="?hal_page=' . $suivant . '">' . $suivant . '</a></li>'; | |
| 782 | + $content .= '<li><a href="?hal_page=' . $suivants . '">' . $suivants . '</a></li>'; | |
| 898 | 783 | $content .= '<li class="disabled"><a href="#">…</a></li>'; |
| 899 | - $content .= '<li><a href="'. $pagedHref . $nombreDePages . '">' . $nombreDePages . '</a></li>'; | |
| 784 | + $content .= '<li><a href="?hal_page=' . $nombreDePages . '">' . $nombreDePages . '</a></li>'; | |
| 900 | 785 | } |
| 901 | 786 | if ( $pageActuelle >= $penultimate - 1 ) { |
| 902 | - $content .= '<li><a href="'.$pagedHref.'1">1</a></li>'; | |
| 903 | - $content .= '<li><a href="'.$pagedHref.'2">2</a></li>'; | |
| 787 | + $content .= '<li><a href="?hal_page=1">1</a></li>'; | |
| 788 | + $content .= '<li><a href="?hal_page=2">2</a></li>'; | |
| 904 | 789 | $content .= '<li class="disabled"><a href="#">…</a></li>'; |
| 905 | 790 | for ( $i = $penultimate - 2; $i <= $nombreDePages; $i ++ ) { |
| 906 | 791 | if ( $i == $pageActuelle ) { |
| 907 | 792 | $content .= '<li class="active"><a href="#">' . $i . '</a></li>'; |
| 908 | 793 | } else { |
| 909 | - $content .= '<li><a href="'. $pagedHref . $i . '">' . $i . '</a></li>'; | |
| 794 | + $content .= '<li><a href="?hal_page=' . $i . '">' . $i . '</a></li>'; | |
| 910 | 795 | } |
| 911 | 796 | } |
| 912 | 797 | } |
| 913 | 798 | } |
| @@ -912,9 +797,9 @@ | ||
| 912 | 797 | } |
| 913 | 798 | } |
| 914 | 799 | //--BOUTON SUIVANT--// |
| 915 | 800 | if ( $pageActuelle < $nombreDePages ) { |
| 916 | - $content .= '<li><a href="'. $pagedHref . $suivant . '">»</a></li>'; | |
| 801 | + $content .= '<li><a href="?hal_page=' . $suivant . '">»</a></li>'; | |
| 917 | 802 | } |
| 918 | 803 | $content .= '</ul>'; |
| 919 | 804 | //--AFFICHAGE PAGINATION--// |
| 920 | 805 | } |
| @@ -921,11 +806,13 @@ | ||
| 921 | 806 | } |
| 922 | 807 | $content .= '</div> |
| 923 | 808 | </div> |
| 924 | 809 | </div>'; |
| 925 | - }} | |
| 810 | + }else{ | |
| 811 | + $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>'; | |
| 812 | + } | |
| 926 | 813 | $content .= '<div class="wphal-footer">'; |
| 927 | - $content .= '<p style="color:#B3B2B0">' . __("Documents récupérés de l'archive ouverte HAL", 'wp-hal') . ' <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>'; | |
| 814 | + $content .= '<p style="color:#B3B2B0">' . __("Documents récupérés de l'archive ouverte HAL", 'wp-hal') . ' <a href="' . wphal_site . '" target="_blank"><img alt="logo" src=" ' . esc_url(plugin_dir_url(__FILE__) . 'img/logo-hal.svg').'" style="width:32px;"></a></p>'; | |
| 928 | 815 | $content .= '</div>'; |
| 929 | 816 | |
| 930 | 817 | //--AFFICHAGE GRAPHIQUE DOMAINE--// |
| 931 | 818 | if (!is_null($facetdomain)) { |
| @@ -1002,59 +889,8 @@ | ||
| 1002 | 889 | } ); |
| 1003 | 890 | return wp_kses($content, $allowed_html_tags); |
| 1004 | 891 | } |
| 1005 | 892 | |
| 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 | 893 | function wphal_verifSolr($values){ |
| 1058 | 894 | $verifsolr = explode(',',$values); |
| 1059 | 895 | $numverif = count($verifsolr); |
| 1060 | 896 | $solrsql = ''; |
| @@ -1074,32 +910,8 @@ | ||
| 1074 | 910 | |
| 1075 | 911 | return $solrsql; |
| 1076 | 912 | } |
| 1077 | 913 | |
| 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 | 914 | function wphal_adding_style() { |
| 1103 | 915 | wp_register_style('wp-hal-style1', plugins_url('/css/style.css', __FILE__)); |
| 1104 | 916 | wp_register_style('wp-hal-style2', plugins_url('/css/jquery.jqplot.css', __FILE__)); |
| 1105 | 917 | |
| @@ -1201,21 +1013,20 @@ | ||
| 1201 | 1013 | $content = 'Please check the <a href="https://wordpress.org/plugins/hal/faq/" target="_blank" id="FAQ">FAQ</a> with the code : CURL'; |
| 1202 | 1014 | |
| 1203 | 1015 | } else { |
| 1204 | 1016 | $instance['idhal'] = wphal_verifSolr($instance['idhal']); |
| 1205 | - $fieldName = $instance['typetext'] == 'title_s' ? 'title_s':'citationFull_s'; | |
| 1206 | 1017 | |
| 1207 | - $url = wphal_api . '?q=*:*&fq=' . $instance['select'] . ':' . urlencode($instance['idhal']) . '&fl=uri_s,' . $fieldName . '&sort=' . wphal_producedDateY . '&rows=' . $instance['nbdoc'] . '&wt=json'; | |
| 1018 | + $url = wphal_api . '?q=*:*&fq=' . $instance['select'] . ':' . urlencode($instance['idhal']) . '&fl=uri_s,' . $instance['typetext'] . '&sort=' . wphal_producedDateY . '&rows=' . $instance['nbdoc'] . '&wt=json'; | |
| 1208 | 1019 | $json = wphal_do_get_data($url); |
| 1209 | 1020 | |
| 1210 | - $count_results = is_array($json->response->docs) ? count($json->response->docs) : 0; | |
| 1211 | - if (isset($json->response->docs) && $count_results > 0) { | |
| 1021 | + $count_results = count($json->response->docs); | |
| 1022 | + if ($count_results > 0) { | |
| 1212 | 1023 | $content = '<ul class="widhal-ul">'; |
| 1213 | 1024 | for ($i = 0; $i < $count_results - 1; $i++) { |
| 1214 | - if ($fieldName == 'title_s') { | |
| 1025 | + if ($instance['typetext'] == 'citationRef_s') { | |
| 1026 | + $typetext = $json->response->docs[$i]->citationRef_s; | |
| 1027 | + } else { | |
| 1215 | 1028 | $typetext = $json->response->docs[$i]->title_s[0]; |
| 1216 | - } else { | |
| 1217 | - $typetext = $json->response->docs[$i]->citationFull_s; | |
| 1218 | 1029 | } |
| 1219 | 1030 | $content .= '<li class="widhal-li"><a href="' . esc_url($json->response->docs[$i]->uri_s) . '" target="_blank">' . $typetext . '</a></li>'; |
| 1220 | 1031 | } |
| 1221 | 1032 | $content .= '</ul>'; |
| @@ -1296,9 +1107,9 @@ | ||
| 1296 | 1107 | <p> |
| 1297 | 1108 | <label for="<?php echo esc_attr($this->get_field_id("typetext"));?>"><?php echo esc_html(__("Type d'affichage",'wp-hal')) .' :'?></label> |
| 1298 | 1109 | <select id="<?php echo esc_attr($this->get_field_id("typetext"));?>" name="<?php echo esc_attr($this->get_field_name("typetext"));?>"> |
| 1299 | 1110 | <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> | |
| 1111 | + <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 | 1112 | </select> |
| 1302 | 1113 | </p> |
| 1303 | 1114 | <p> |
| 1304 | 1115 | <label for="<?php echo esc_attr($this->get_field_id("select"));?>"><?php echo esc_html(__("Type d'Id",'wp-hal') .' :')?></label> |
| @@ -1304,8 +1115,10 @@ | ||
| 1304 | 1115 | <label for="<?php echo esc_attr($this->get_field_id("select"));?>"><?php echo esc_html(__("Type d'Id",'wp-hal') .' :')?></label> |
| 1305 | 1116 | <select id="<?php echo esc_attr($this->get_field_id("select"));?>" name="<?php echo esc_attr($this->get_field_name("select"));?>"> |
| 1306 | 1117 | <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 | 1118 | <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> |
| 1119 | + <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> | |
| 1120 | + <option id="<?php echo esc_attr($this->get_field_id("AuthorId"));?>" value="authId_i" <?php echo esc_attr(($instance["select"] == "authId_i")?'selected':''); ?>><label for="<?php echo esc_attr($this->get_field_id("AuthorId"));?>">Author Id</label><span style="font-style: italic;"> <?php echo esc_html(__('(Exemple : 413106)','wp-hal'));?></span></option> | |
| 1308 | 1121 | <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 | 1122 | <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 | 1123 | <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 | 1124 | </select> |
| @@ -1420,8 +1233,10 @@ | ||
| 1420 | 1233 | <th scope="row"><label for="option_type"><?php echo esc_html(__('Type d\'Id','wp-hal'));?></label></th> |
| 1421 | 1234 | <td><select name="option_type"> |
| 1422 | 1235 | <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 | 1236 | <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> |
| 1237 | + <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> | |
| 1238 | + <option id="AuthorId" value="authId_i" <?php echo esc_attr(((get_option('option_type') == "authId_i")?'selected':'')); ?>><label for="AuthorId">Author Id</label><span style="font-style: italic;"> <?php echo esc_html(__('(Exemple : 413106)','wp-hal'));?></span></option> | |
| 1424 | 1239 | <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 | 1240 | <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 | 1241 | <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 | 1242 | </select> |
| @@ -1434,21 +1249,20 @@ | ||
| 1434 | 1249 | <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 | 1250 | </td> |
| 1436 | 1251 | </tr> |
| 1437 | 1252 | <tr style="vertical-align:top;"> |
| 1438 | - <th scope="row"><?php echo esc_html(__('Choix des éléments menu(facette)','wp-hal'));?></th> | |
| 1253 | + <th scope="row"><?php echo esc_html(__('Choix des éléments menu','wp-hal'));?></th> | |
| 1439 | 1254 | <?php $option_choix = get_option('option_choix'); ?> |
| 1440 | 1255 | <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 | 1256 | <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 | 1257 | <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 | 1258 | <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> | |
| 1259 | + <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/> | |
| 1260 | + <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/> | |
| 1261 | + <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/> | |
| 1262 | + <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/> | |
| 1263 | + <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/> | |
| 1264 | + <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 | 1265 | </td> |
| 1452 | 1266 | </tr> |
| 1453 | 1267 | <tr style="vertical-align:top;"> |
| 1454 | 1268 | <th scope="row" style="font-size: 18px;"><?php echo esc_html(__('Contact :','wp-hal'));?></th> |