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 +152 -334 trunk2.3 View file →
@@ -2,32 +2,39 @@
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.7.2
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/
11 11 */
12 +
13 +
14 +// Traduction de la description
15 +__("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.", "wp-hal");
16 +
12 17 //Récupère les constantes
13 18 require_once("constantes.php");
14 19
15 -$generalLang = preg_replace('/_.*/', '', wphal_locale);
16 -switch ($generalLang) {
17 -case 'fr':
18 -case 'es':
19 -case 'en':
20 - // Known languages...
21 - define('wphal_lang', $generalLang);
22 - break;
23 -default:
20 +
21 +if (wphal_locale == 'fr_FR') {
22 + define('wphal_lang', 'fr');
23 +} elseif (wphal_locale == 'es_ES') {
24 + define('wphal_lang', 'es');
25 +} else {
24 26 define('wphal_lang', 'en');
25 27 }
26 28
27 29 function wphal_is_curl_installed() {
28 30 $loaded_extentions = get_loaded_extensions();
29 - return (bool) (in_array('curl', $loaded_extentions));
31 + if (in_array ('curl', $loaded_extentions)) {
32 + return true;
33 + }
34 + else {
35 + return false;
36 + }
30 37 }
31 38
32 39 // Création du shortcode ('nom du shortcode', 'fonction appelée')
33 40 add_shortcode( 'cv-hal', 'wphal_cv_hal' );
@@ -32,8 +39,9 @@
32 39 // Création du shortcode ('nom du shortcode', 'fonction appelée')
33 40 add_shortcode( 'cv-hal', 'wphal_cv_hal' );
34 41 add_shortcode( 'nb-doc', 'wphal_nb_doc' );
35 42
43 +
36 44 function wphal_charger_languages() {
37 45 load_plugin_textdomain('wp-hal', false, dirname(plugin_basename(__FILE__)) . '/lang/');
38 46 }
39 47
@@ -43,13 +51,14 @@
43 51 if ( $file != plugin_basename( __FILE__ ))
44 52 return $links;
45 53
46 54 $settings_link = '<a href="admin.php?page=wp-hal.php">' . __( 'Paramètres', 'wp-hal' ) . '</a>';
55 +
47 56 array_unshift( $links, $settings_link );
57 +
48 58 return $links;
49 59 }
50 60
51 -
52 61 add_filter( 'query_vars', 'wphal_query_vars' );
53 62 function wphal_query_vars( $query_vars ) {
54 63 $query_vars[] = 'hal_page';
55 64 return $query_vars;
@@ -77,9 +86,9 @@
77 86 {
78 87 global $wpdb;
79 88 // delete all "hal namespace" transients
80 89 $sql = "
81 - DELETE
90 + DELETE
82 91 FROM {$wpdb->options}
83 92 WHERE option_name like '\_transient\_hal\_%'
84 93 OR option_name like '\_transient\_timeout\_hal\_%'
85 94 ";
@@ -101,11 +110,10 @@
101 110 }
102 111 $cache_expiration = empty(get_option('option_cache_timeout')) ? 1 * DAY_IN_SECONDS : intval(get_option('option_cache_timeout')) * MINUTE_IN_SECONDS;
103 112 if ( false === ( $value = get_transient( $transient_id ) ) ) {
104 113 $json = wphal_do_common_curl_call($url);
105 - if ($json) {
106 - set_transient($transient_id, $json, $cache_expiration);
107 - }
114 + if($json)
115 + set_transient( $transient_id, $json, $cache_expiration);
108 116 return $json;
109 117 } else{
110 118 return $value;
111 119 }
@@ -135,9 +143,8 @@
135 143
136 144 $json =wphal_do_get_data($url);
137 145 return $json->response->numFound;
138 146 }
139 -
140 147 /**
141 148 * PLUGIN SHORTCODE CV-HAL
142 149 * @param $param
143 150 * @return string
@@ -146,9 +153,9 @@
146 153 $content = '';
147 154 if ( !wphal_is_curl_installed() ) {
148 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';
149 156 } else {
150 - $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"];
151 158 $option_choix = !empty(get_option('option_choix')) ? get_option('option_choix') : [];
152 159 if(in_array('disciplines', $option_choix)){ //Lance les scripts pour le Graphique
153 160 wp_enqueue_style('wp-hal-style2');
154 161
@@ -165,25 +172,12 @@
165 172 // here we merge with shortcode parameters
166 173 extract(shortcode_atts(array(
167 174 'type' => $default_type,
168 175 'id' => $default_id,
169 - 'contact' => $default_contact,
170 - 'doctype_s' => null,
171 - 'debug' => false,
172 - 'option_groupe' => get_option('option_groupe')
176 + 'contact' => $default_contact
173 177 ),
174 178 $param
175 179 ));
176 - if ($doctype_s && !preg_match("/^[A-Z_ ]*$/", $doctype_s)) {
177 - // Control of shortcode doctype_s which must be a valid doctype or a valid expression for doctype_s
178 - // can accept: "ART OR REPORT AND NOT UNDEFINED"
179 - $doctype_s = null;
180 - }
181 - if (! in_array($option_groupe, ['paginer', 'grouper'])) {
182 - $option_groupe = 'paginer';
183 - }
184 -
185 - $content = 'Plugin is not configured correctly or shortcode parameters are not valid, please check the <a href="https://doc.hal.science/afficher-une-liste-de-publications-dans-wordpress/" target="_blank" id="wrong_params">documentation</a>';
186 180
187 181 /** @var $id : defined by extract
188 182 * @var string $type : defined by extract
189 183 * @var string $contact : defined by extract
@@ -190,44 +184,19 @@
190 184 */
191 185 if (!empty($id) && in_array($type, $possible_ids)) {
192 186 $id = wphal_verifSolr($id);
193 187
194 - // in case the type is struct we need to split in order to build facet and display it back
195 - $structIDs =[];
196 - if($type=="structId_i"){
197 - $structIDs = explode(' OR ', $id);
198 - }
199 -
200 - $facets = wphal_buildfacet($option_choix, $structIDs);
201 - $facetQuery = !empty($facets) ? 'facet.field='.implode("&facet.field=", $facets).'&facet.limit=200&facet.mincount=1&facet=true':'';
202 -
203 - $url = wphal_api . '?q=*:*&fq=' . $type . ':(' . urlencode($id) . ')';
204 - if (!empty($doctype_s) && $doctype_s != "") {
205 - $url .= '&fq=docType_s:('.$doctype_s.')';
206 - }
207 - switch ($option_groupe) {
208 - case 'grouper':
188 + if (get_option('option_groupe') == 'grouper') {
209 189 //cURL sur l'API pour récupérer les données
210 - $url .= '&group=true&group.field=docType_s&group.limit=1000';
211 - break;
212 - case 'paginer':
213 - break;
214 - default:
215 - // impossible 2 cases only
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';
191 + } elseif (get_option('option_groupe') == 'paginer') {
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';
216 193 }
217 - $url .= '&fl=docid,citationFull_s&'.$facetQuery.'&sort=' . wphal_producedDateY . '&wt=json&json.nl=arrarr';
218 194
219 195 $json = wphal_do_get_data($url);
220 - if(!isset($json->error)){
221 - $content = "";
222 - $hal_page = (get_query_var('hal_page')) ? get_query_var('hal_page') : 1;
223 - if ($debug) {
224 - $formattedJson = str_replace(["\n", ' '], ['<br />', '&nbsp;'] , json_encode($json,JSON_PRETTY_PRINT));
225 - $content .= sprintf('<div class="debug"><ul><li>Option groupe: %s</li><li>url=%s</li><li>doctype_s: %s</li><li>json result: %s</li></ul></div>',
226 - $option_groupe, $url, $doctype_s, $formattedJson );
227 - }
228 -
229 - $content .= '<div id="wphal-content">';
196 + $hal_page = (get_query_var('hal_page')) ? get_query_var('hal_page') : 1;
197 +
198 + $content = '<div id="wphal-content">';
230 199 if (is_array($option_choix) && !empty($option_choix)){
231 200 $content .= '<ul id="wphal-menu">';
232 201 $content .= '<li><a href="#publications" onclick="displayElem(\'publications\'); return false;" style="font-size:18px; text-decoration: none;">' . __('Publications', 'wp-hal') . '</a></li>';
233 202
@@ -249,12 +218,8 @@
249 218 if ($option == 'auteurs') {
250 219 $content .= '<li><a href="#auteurs" onclick="displayElem(\'wphal-auteurs\'); return false;" style="margin:1px; text-decoration: none;">' . __('Auteurs', 'wp-hal');
251 220 $content .= '</a></li>';
252 221 }
253 - if ($option == 'affiliated') {
254 - $content .= '<li><a href="#affiliated" onclick="displayElem(\'wphal-affiliated\'); return false;" style="margin:1px; text-decoration: none;">' . __('Auteurs de la structure', 'wp-hal');
255 - $content .= '</a></li>';
256 - }
257 222 if ($option == 'revues') {
258 223 $content .= '<li><a href="#revues" onclick="displayElem(\'wphal-revues\'); return false;" style="margin:1px; text-decoration: none;">' . __('Revues', 'wp-hal');
259 224 $content .= '</a></li>';
260 225 }
@@ -279,8 +244,9 @@
279 244 $content .= '</a></li>';
280 245 }
281 246 }
282 247 $content .= '</ul></li>';
248 +
283 249 $content .= '</ul><br/><hr>';
284 250 }
285 251
286 252 $content .= '<div id="meta">
@@ -290,57 +256,40 @@
290 256
291 257 <ul id="wphal-cont" style="list-style-type: none;">';
292 258
293 259 if ($contact == 'yes' && $type == 'authIdHal_s') {
294 - $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);
295 261 $jsonauthor = wphal_do_get_data($urlauthor);
296 262
297 - foreach ($jsonauthor->response->docs as $i=>$doc) {
263 + for ($i = 0; $jsonauthor->response->docs[$i] != ''; $i++) {
298 264 $content .= '<div class="wphal-infocontact" id="wphal-infocontact'.$i.'">';
299 - if ($doc->fullName_s != '') {
300 - $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>';
301 267 }
302 - if ($doc->idHal_s != '') {
303 - $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>';
304 270 }
305 - if ($doc->hasCV_bool == true){
306 - $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>';
307 273 }
308 - if (isset($doc->arxivId_s ) && is_array($doc->arxivId_s)) {
309 - $content .= '<li class="wphal-"><span>arXiv : </span><span>';
310 - foreach($doc->arxivId_s as $arxivId_s){
311 - $content .= '<a href="' . esc_url($arxivId_s) . '" target="_blank">' . substr(strrchr($arxivId_s, "/"), 1) . '</a> ,';
312 - }
313 - $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>';
314 276 }
315 - if (isset($doc->idrefId_s ) && is_array($doc->idrefId_s)) {
316 - $content .= '<li class="wphal-"><span>IdRef : </span><span>';
317 - foreach($doc->idrefId_s as $idref){
318 - $content .= '<a href="' . esc_url($idref) . '" target="_blank">' . substr(strrchr($idref, "/"), 1) . '</a> ,';
319 - }
320 - $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>';
321 279 }
322 - if (isset($doc->orcidId_s ) && $doc->orcidId_s != '') {
323 - $content .= '<li class="wphal-"><span>ORCID : </span><span>';
324 - foreach($doc->orcidId_s as $orcidId_s){
325 - $content .= '<a href="' . esc_url($orcidId_s) . '" target="_blank">' . substr(strrchr($orcidId_s, "/"), 1) . '</a> ,';
326 - }
327 - $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>';
328 282 }
329 - if (isset($doc->viafId_s ) && $doc->viafId_s != '') {
330 - $content .= '<li class="wphal-"><span>VIAF : </span><span>';
331 - foreach($doc->viafId_s as $viafId_s){
332 - $content .= '<a href="' . esc_url($viafId_s) . '" target="_blank">' . substr(strrchr($viafId_s, "/"), 1) . '</a> ,';
333 - }
334 - $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>';
335 285 }
336 - if (isset($doc->isniId_s ) && $doc->isniId_s != '') {
337 - $content .= '<li class="wphal-"><span>ISNI : </span><span>';
338 - foreach($doc->isniId_s as $isniId_s){
339 - $content .= '<a href="' . esc_url($isniId_s) . '" target="_blank">' . substr(strrchr($isniId_s, "/"), 1) . '</a> ,';
340 - }
341 - $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>';
342 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 + }
343 292 $content .= '</div>';
344 293 }
345 294 }
346 295 if (get_option('option_email') != '') {
@@ -370,13 +319,13 @@
370 319 <div class="display" id="wphal-disciplines" style="display: none;">
371 320 <h3 class="wphal-titre">' . __('Disciplines', 'wp-hal') . '</h3>';
372 321
373 322 if (wphal_locale == 'fr_FR') {
374 - $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;
375 324 } elseif (wphal_locale == 'es_ES') {
376 - $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;
377 326 } else {
378 - $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;
379 328 }
380 329
381 330 if (!is_null($facetdomain) && !empty($facetdomain)) {
382 331 $content .= '<div id="listdisci">';
@@ -400,21 +349,21 @@
400 349 }
401 350 $content .= '</div>
402 351 <div class="display" id="wphal-keywords" style="display: none;">
403 352 <h3 class="wphal-titre">' . __('Mots-clefs', 'wp-hal') . '</h3>';
404 - 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)) {
405 354 $content .= '<div id="wphal-keys">';
406 355 $r = 0;
407 356 // CSS Nuage de mots
408 357 $maxsize = 25;
409 358 $minsize = 10;
410 - /** @var int[] $keywordCounts */
411 - $keywordCounts = array_column($json->facet_counts->facet_fields->keyword_s, 1);
412 - $maxval = max($keywordCounts);
413 - $minval = min($keywordCounts);
414 - $spread = ( $maxval - $minval );
415 - $step = ( $spread > 0 ) ? ($maxsize - $minsize) / $spread : 0;
416 - $tab = [];
359 + $maxval = max(array_values($json->facet_counts->facet_fields->keyword_s[1]));
360 + $minval = min(array_values($json->facet_counts->facet_fields->keyword_s[1]));
361 + if(!is_numeric($minval)) {$minval = 0;}
362 + if(!is_numeric($maxval)) {$maxval = 0;}
363 + $spread = ($maxval - $minval);
364 + $step = ($maxsize - $minsize) / $spread;
365 + $tab = array();
417 366 foreach ($json->facet_counts->facet_fields->keyword_s as $res) {
418 367 $r = $r + 1;
419 368 if ($r > 20) {
420 369 break;
@@ -445,9 +394,9 @@
445 394 }
446 395 $content .= '</div>
447 396 <div class="display" id="wphal-auteurs" style="display: none;">
448 397 <h3 class="wphal-titre">' . __('Auteurs', 'wp-hal') . '</h3>';
449 - 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)) {
450 399 $content .= '<span id="triauteurs">';
451 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>';
452 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>';
453 402 $content .= '</span>';
@@ -493,62 +442,11 @@
493 442 $content .= '</button>';
494 443 }
495 444 }
496 445 $content .= '</div>
497 - <div class="display" id="wphal-affiliated" style="display: none;">
498 - <h3 class="wphal-titre">' . __('Auteurs de la structure', 'wp-hal') . '</h3>';
499 - $parsed_facetfield = isset($json->facet_counts->facet_fields) ? wphal_parse_affiliation_facet($json->facet_counts->facet_fields, $structIDs) : [];
500 - if (!empty($parsed_facetfield)) {
501 - $content .= '<span id="triauteurs">';
502 - $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>';
503 - $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>';
504 - $content .= '</span>';
505 - $content .= '<ul class="wphal-auteurs" style="list-style-type: none;">';
506 - $content .= '<div id="wphal-aff">';
507 - $r = 0;
508 - foreach ($parsed_facetfield as $author=>$count) {
509 - $r = $r + 1;
510 - if ($r > 10) {
511 - break;
512 - }
513 - $name = explode(wphal_delimiter, $author);
514 - if($name[1] == 0){
515 - $q = 'authLastNameFirstName_s:'.urlencode("\"".$name[2]."\"");
516 - }else{
517 - $q = "authIdPerson_i:$name[1]";
518 - }
519 - $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>';
520 - }
521 - $i = 1;
522 - $content .= '<div id="affiliateduite" style="display:none;">';
523 - foreach ($parsed_facetfield as $author=>$count) {
524 - if ($r < 10) {
525 - break;
526 - }
527 - if ($i < $r) {
528 - $i = $i + 1;
529 - } else {
530 - $name = explode(wphal_delimiter, $author);
531 - if($name[1] == 0){
532 - $q = 'authLastNameFirstName_s:'.urlencode("\"".$name[2]."\"");
533 - }else{
534 - $q = "authIdPerson_i:$name[1]";
535 - }
536 - $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>';
537 - }
538 - }
539 - $content .= '</div>';
540 - $content .= '</div>';
541 - $content .= '</ul>';
542 - if ($r > 10) {
543 - $content .= '<button type="button" style="text-decoration: none;" id="wphal-auteur" onclick="visibilite(\'affiliateduite\'); return false;" >' . __('Liste complète', 'wp-hal');
544 - $content .= '</button>';
545 - }
546 - }
547 - $content .= '</div>
548 446 <div class="display" id="wphal-revues" style="display: none;">
549 447 <h3 class="wphal-titre">' . __('Revues', 'wp-hal') . '</h3>';
550 - 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)) {
551 449 $content .= '<span id="trirevues">';
552 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>';
553 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>';
554 452 $content .= '</span>';
@@ -586,9 +484,9 @@
586 484 }
587 485 $content .= '</div>
588 486 <div class="display" id="wphal-annees" style="display: none;">
589 487 <h3 class="wphal-titre">' . __('Année de production', 'wp-hal') . '</h3>';
590 - 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)) {
591 489 $content .= '<span id="triannees">';
592 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>';
593 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>';
594 492 $content .= '</span>';
@@ -626,9 +524,9 @@
626 524 }
627 525 $content .= '</div>
628 526 <div class="display" id="wphal-insts" style="display: none;">
629 527 <h3 class="wphal-titre">' . __('Institutions', 'wp-hal') . '</h3>';
630 - 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)) {
631 529 $content .= '<span id="triinsts">';
632 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>';
633 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>';
634 532 $content .= '</span>';
@@ -666,9 +564,9 @@
666 564 }
667 565 $content .= '</div>
668 566 <div class="display" id="wphal-labs" style="display: none;">
669 567 <h3 class="wphal-titre">' . __('Laboratoires', 'wp-hal') . '</h3>';
670 - 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)) {
671 569 $content .= '<span id="trilabs">';
672 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>';
673 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>';
674 572 $content .= '</span>';
@@ -707,9 +605,9 @@
707 605 }
708 606 $content .= '</div>
709 607 <div class="display" id="wphal-depts" style="display: none;">
710 608 <h3 class="wphal-titre">' . __('Départements', 'wp-hal') . '</h3>';
711 - 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)) {
712 610 $content .= '<span id="tridept">';
713 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>';
714 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>';
715 613 $content .= '</span>';
@@ -747,9 +645,9 @@
747 645 }
748 646 $content .= '</div>
749 647 <div class="display" id="wphal-equipes" style="display: none;">
750 648 <h3 class="wphal-titre">' . __('Équipes de recherche', 'wp-hal') . '</h3>';
751 - 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)) {
752 650 $content .= '<span id="triequipe">';
753 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>';
754 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>';
755 653 $content .= '</span>';
@@ -788,20 +686,19 @@
788 686 }
789 687 }
790 688 $content .= '</div>
791 689 <div class="display" id="publications">';
792 - if(null === $json || !isset($jsontype->response)) {
793 - if ($option_groupe == 'grouper') {
794 - $doctype = file_get_contents(plugin_dir_path(__FILE__) . 'json' . DIRECTORY_SEPARATOR . 'doctype_fr.json');
690 + if (get_option('option_groupe') == 'grouper') {
691 + $doctype = file_get_contents(plugin_dir_path( __FILE__ ).'json'. DIRECTORY_SEPARATOR .'doctype_fr.json');
795 692 $jsontype = json_decode($doctype);
796 693
797 694 //LISTE DES DOCUMENTS PAR GROUPE
798 695
799 696 $content .= '<div class="counter-doc"><span class="wphal-nbtot">' . $json->grouped->docType_s->matches . ' </span>';
800 - $content .= __('documents', 'wp-hal') . '</div><br>';
697 + $content .= __('documents', 'wp-hal'). '</div><br>';
801 698 for ($i = 0; !empty($jsontype->response->result->doc[$i]); $i++) {
802 699 for ($d = 0; !empty($json->grouped->docType_s->groups[$d]); $d++) {
803 - if ($json->grouped->docType_s->groups[$d]->groupValue == $jsontype->response->result->doc[$i]->str[0]) {
700 + if ($json->grouped->docType_s->groups[$d]->groupValue == $jsontype->response->result->doc[$i]->str[0]){
804 701 $titre = $jsontype->response->result->doc[$i]->str[1];
805 702 $content .= '<div class="grp-div"><h3 class="wphal-titre-groupe">' . __($titre, 'wp-hal') . '<span class="wphal-nbmetadata" style="margin-left:10px;">' . $json->grouped->docType_s->groups[$d]->doclist->numFound . ' ' . _n('document', 'documents', $json->grouped->docType_s->groups[$d]->doclist->numFound, 'wp-hal') . '</span></h3>';
806 703 $content .= '<div class="grp-content">';
807 704 $content .= '<ul>';
@@ -813,13 +710,13 @@
813 710 break;
814 711 }
815 712 }
816 713 }
817 - } elseif ($option_groupe == 'paginer') {
714 + } elseif (get_option('option_groupe') == 'paginer') {
818 715
819 716 //LISTE DES DOCUMENTS AVEC PAGINATION
820 717 $content .= '<div class="counter-doc"><span class="wphal-nbtot">' . $json->response->numFound . ' </span>';
821 - $content .= __('documents', 'wp-hal') . '</div><br>';
718 + $content .= __('documents', 'wp-hal'). '</div><br>';
822 719
823 720 //--MODULE PAGINATION--//
824 721 $messagesParPage = 10;
825 722
@@ -838,118 +735,114 @@
838 735 }
839 736 $premiereEntree = ($pageActuelle - 1) * $messagesParPage;
840 737
841 738 $url = wphal_api . '?q=*:*&fq=' . $type . ':(' . urlencode($id) . ')&fl=docid,citationFull_s,keyword_s,bookTitle_s,producedDate_s,authFullName_s&start=' . $premiereEntree . '&rows=' . $messagesParPage . '&sort=' . wphal_producedDateY . '&wt=json';
842 - if (!empty($doctype_s) && $doctype_s != "") {
843 - $url .= '&fq=docType_s:('.$doctype_s.')';
844 - }
845 739 $json = wphal_do_get_data($url);
846 740
847 741 //--MODULE PAGINATION--//
848 - $count_results = is_array($json->response->docs) ? count($json->response->docs) : 0;
849 - if ($count_results > 0) {
850 - $content .= '<ul>';
851 - for ($i = 0; $i <= $count_results - 1; $i++) {
852 - $content .= '<li>' . $json->response->docs[$i]->citationFull_s . '</li>';
853 - }
854 - $content .= '</ul>';
742 + $count_results = count($json->response->docs);
743 + if($count_results>0) {
744 + $content .= '<ul>';
745 + for ( $i = 0; $i <= $count_results - 1; $i ++ ) {
746 + $content .= '<li>' . $json->response->docs[ $i ]->citationFull_s . '</li>';
747 + }
748 + $content .= '</ul>';
855 749 } else {
856 - $content = '<div> no results !</div>';
750 + $content = '<div> no results !</div>';
857 751 }
858 - if ($total > $messagesParPage) {
859 - $base_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'];
752 + if($total> $messagesParPage) {
753 + $base_url = ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on' ? 'https' : 'http' ) . '://' . $_SERVER['HTTP_HOST'];
860 754 $url = $base_url . $_SERVER["REQUEST_URI"];
861 - $explodedURL = explode('?', $url);
862 - $queryString = isset($explodedURL[1]) ? $explodedURL[1] : "";
755 + $explodedURL= explode('?', $url);
756 + $queryString = $explodedURL[1];
863 757 $pagedHref = $explodedURL[0];
864 - if (!empty($queryString)) {
758 + if(!empty($queryString)){
865 759 $parsedQueryString = [];
866 760 parse_str($queryString, $parsedQueryString);
867 - if (isset($parsedQueryString["hal_page"])) {
761 + if(isset($parsedQueryString["hal_page"])){
868 762 unset($parsedQueryString["hal_page"]);
869 763 }
870 764 $pagedHref .= '?';
871 - foreach ($parsedQueryString as $name => $value) {
872 - $pagedHref .= $name . '=' . $value . '&';
765 + foreach($parsedQueryString as $name => $value){
766 + $pagedHref .= $name.'='.$value.'&';
873 767 }
874 768 // we add it back..
875 769 $pagedHref .= 'hal_page=';
876 - } else {
770 + }else {
877 771 $pagedHref .= '?hal_page=';
878 772 }
879 773
880 - //--AFFICHAGE PAGINATION--//
881 - $precedents = $pageActuelle - 2;
882 - $suivants = $pageActuelle + 2;
883 - $precedent = $pageActuelle - 1;
884 - $suivant = $pageActuelle + 1;
774 + //--AFFICHAGE PAGINATION--//
775 + $precedents = $pageActuelle - 2;
776 + $suivants = $pageActuelle + 2;
777 + $precedent = $pageActuelle - 1;
778 + $suivant = $pageActuelle + 1;
885 779 $penultimate = $nombreDePages - 1;
886 780
887 781 $content .= '<ul class="wphal-pagination">';
888 - //--BOUTON PRECEDENT--//
889 - if ($pageActuelle != 1) {
890 - $content .= '<li><a href="' . $pagedHref . $precedent . '">&laquo;</a></li>';
782 + //--BOUTON PRECEDENT--//
783 + if ( $pageActuelle != 1 ) {
784 + $content .= '<li><a href="'. $pagedHref . $precedent . '">&laquo;</a></li>';
891 785 }
892 - if ($nombreDePages <= 6) {// Cas 1 : 6 pages ou moins - Pas de troncature
893 - for ($i = 1; $i <= $nombreDePages; $i++) {
894 - if ($i == $pageActuelle) {
786 + if ( $nombreDePages <= 6 ) {// Cas 1 : 6 pages ou moins - Pas de troncature
787 + for ( $i = 1; $i <= $nombreDePages; $i ++ ) {
788 + if ( $i == $pageActuelle ) {
895 789 $content .= '<li class="active"><a href="#">' . $i . '</a></li>';
896 790 } else {
897 - $content .= ' <li><a href="' . $pagedHref . $i . '">' . $i . '</a></li> ';
791 + $content .= ' <li><a href="'. $pagedHref . $i . '">' . $i . '</a></li> ';
898 792 }
899 793 }
900 - } elseif ($nombreDePages >= 7) {// Cas 2 : 7 pages ou plus - Troncature
901 - if ($pageActuelle <= 3) {// Lorsque l'on est sur les trois premières pages
902 - for ($i = 1; $i <= 4; $i++) {
903 - if ($i == $pageActuelle) {
794 + } elseif ( $nombreDePages >= 7 ) {// Cas 2 : 7 pages ou plus - Troncature
795 + if ( $pageActuelle <= 3 ) {// Lorsque l'on est sur les trois premières pages
796 + for ( $i = 1; $i <= 4; $i ++ ) {
797 + if ( $i == $pageActuelle ) {
904 798 $content .= '<li class="active"><a href="#">' . $i . '</a></li>';
905 799 } else {
906 - $content .= '<li><a href="' . $pagedHref . $i . '">' . $i . '</a></li>';
800 + $content .= '<li><a href="'. $pagedHref . $i . '">' . $i . '</a></li>';
907 801 }
908 802 }
909 803 $content .= '<li class="disabled"><a href="#">&hellip;</a></li>';
910 - $content .= '<li><a href="' . $pagedHref . $penultimate . '">' . $penultimate . '</a></li>';
911 - $content .= '<li><a href="' . $pagedHref . $nombreDePages . '">' . $nombreDePages . '</a></li>';
804 + $content .= '<li><a href="'. $pagedHref . $penultimate . '">' . $penultimate . '</a></li>';
805 + $content .= '<li><a href="'. $pagedHref . $nombreDePages . '">' . $nombreDePages . '</a></li>';
912 806 }
913 - if ($pageActuelle >= 4 && $pageActuelle <= $penultimate - 2) {//Lorsque l'on arrive sur la quatrième page
914 - $content .= '<li><a href="' . $pagedHref . '1">1</a></li>';
807 + if ( $pageActuelle >= 4 && $pageActuelle <= $penultimate - 2 ) {//Lorsque l'on arrive sur la quatrième page
808 + $content .= '<li><a href="'.$pagedHref.'1">1</a></li>';
915 809 $content .= '<li class="disabled"><a href="#">&hellip;</a></li>';
916 - $content .= '<li><a href="' . $pagedHref . $precedents . '">' . $precedents . '</a></li>';
917 - $content .= '<li><a href="' . $pagedHref . $precedent . '">' . $precedent . '</a></li>';
810 + $content .= '<li><a href="'. $pagedHref . $precedents . '">' . $precedents . '</a></li>';
811 + $content .= '<li><a href="'. $pagedHref . $precedent . '">' . $precedent . '</a></li>';
918 812 $content .= '<li class="active"><a href="#">' . $pageActuelle . '</a></li>';
919 - $content .= '<li><a href="' . $pagedHref . $suivant . '">' . $suivant . '</a></li>';
920 - $content .= '<li><a href="' . $pagedHref . $suivants . '">' . $suivants . '</a></li>';
813 + $content .= '<li><a href="'. $pagedHref . $suivant . '">' . $suivant . '</a></li>';
814 + $content .= '<li><a href="'. $pagedHref . $suivants . '">' . $suivants . '</a></li>';
921 815 $content .= '<li class="disabled"><a href="#">&hellip;</a></li>';
922 - $content .= '<li><a href="' . $pagedHref . $nombreDePages . '">' . $nombreDePages . '</a></li>';
816 + $content .= '<li><a href="'. $pagedHref . $nombreDePages . '">' . $nombreDePages . '</a></li>';
923 817 }
924 - if ($pageActuelle >= $penultimate - 1) {
925 - $content .= '<li><a href="' . $pagedHref . '1">1</a></li>';
926 - $content .= '<li><a href="' . $pagedHref . '2">2</a></li>';
818 + if ( $pageActuelle >= $penultimate - 1 ) {
819 + $content .= '<li><a href="'.$pagedHref.'1">1</a></li>';
820 + $content .= '<li><a href="'.$pagedHref.'2">2</a></li>';
927 821 $content .= '<li class="disabled"><a href="#">&hellip;</a></li>';
928 - for ($i = $penultimate - 2; $i <= $nombreDePages; $i++) {
929 - if ($i == $pageActuelle) {
822 + for ( $i = $penultimate - 2; $i <= $nombreDePages; $i ++ ) {
823 + if ( $i == $pageActuelle ) {
930 824 $content .= '<li class="active"><a href="#">' . $i . '</a></li>';
931 825 } else {
932 - $content .= '<li><a href="' . $pagedHref . $i . '">' . $i . '</a></li>';
826 + $content .= '<li><a href="'. $pagedHref . $i . '">' . $i . '</a></li>';
933 827 }
934 828 }
935 829 }
936 830 }
937 - //--BOUTON SUIVANT--//
938 - if ($pageActuelle < $nombreDePages) {
939 - $content .= '<li><a href="' . $pagedHref . $suivant . '">&raquo;</a></li>';
831 + //--BOUTON SUIVANT--//
832 + if ( $pageActuelle < $nombreDePages ) {
833 + $content .= '<li><a href="'. $pagedHref . $suivant . '">&raquo;</a></li>';
940 834 }
941 835 $content .= '</ul>';
942 - //--AFFICHAGE PAGINATION--//
836 + //--AFFICHAGE PAGINATION--//
943 837 }
944 838 }
945 - } else {
946 - $content .= '<div> empty response !</div>';
947 - }
948 - $content .= '</div>
839 + $content .= '</div>
949 840 </div>
950 841 </div>';
951 - }}
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 + }
952 845 $content .= '<div class="wphal-footer">';
953 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>';
954 847 $content .= '</div>';
955 848
@@ -1028,59 +921,8 @@
1028 921 } );
1029 922 return wp_kses($content, $allowed_html_tags);
1030 923 }
1031 924
1032 -/**
1033 - * build facet query based on the option choice
1034 - *
1035 - * @param array $option_choix
1036 - * @param array $structIDs to build prefixed facet
1037 - * @return array
1038 - */
1039 -function wphal_buildfacet($option_choix, $structIDs)
1040 -{
1041 - $facetQuery = [];
1042 - if (is_array($option_choix) && !empty($option_choix)) {
1043 - foreach ($option_choix as $option) {
1044 - if ($option == 'disciplines') {
1045 - $facetQuery[] = wphal_lang . '_domainAllCodeLabel_fs';
1046 - }
1047 - if ($option == 'mots-clefs') {
1048 - $facetQuery[] = 'keyword_s';
1049 - }
1050 - if ($option == 'auteurs') {
1051 - $facetQuery[] = 'authIdLastNameFirstName_fs';
1052 - }
1053 - if ($option == 'revues') {
1054 - $facetQuery[] = 'journalIdTitle_fs';
1055 - }
1056 - if ($option == 'annee') {
1057 - $facetQuery[] = 'producedDateY_i';
1058 - }
1059 - if ($option == 'institution') {
1060 - $facetQuery[] = 'instStructIdName_fs';
1061 - }
1062 - if ($option == 'laboratoire') {
1063 - $facetQuery[] = 'labStructIdName_fs';
1064 - }
1065 - if ($option == 'departement') {
1066 - $facetQuery[] = 'deptStructIdName_fs';
1067 - }
1068 - if ($option == 'equipe') {
1069 - $facetQuery[] = 'rteamStructIdName_fs';
1070 - }
1071 - if ($option == 'affiliated') {
1072 - $facetField = 'structHasAuthIdHalPersonid_s';
1073 - foreach($structIDs as $k => $structID){
1074 - $facetPrefix = $structID . wphal_delimiter;
1075 - $facetQuery[] = '&facet.field={!key=affiliated_' . $k . '+facet.prefix=' . urlencode($facetPrefix) . '}' . urlencode($facetField);
1076 - }
1077 - }
1078 - }
1079 - }
1080 - return $facetQuery;
1081 -}
1082 -
1083 925 function wphal_verifSolr($values){
1084 926 $verifsolr = explode(',',$values);
1085 927 $numverif = count($verifsolr);
1086 928 $solrsql = '';
@@ -1100,32 +942,8 @@
1100 942
1101 943 return $solrsql;
1102 944 }
1103 945
1104 -
1105 -/**
1106 - * parses the affiliation facet
1107 - *
1108 - * @return array
1109 - */
1110 -function wphal_parse_affiliation_facet($facet_fields, $structIDs)
1111 -{
1112 - $result=[];
1113 - foreach($structIDs as $k => $structID){
1114 - if(isset($facet_fields->{'affiliated_'.$k}) && !empty($facet_fields->{'affiliated_'.$k})){
1115 - foreach($facet_fields->{'affiliated_'.$k} as $r){
1116 - $t = explode(wphal_delimiter_join, $r[0]);
1117 - if (!isset($result[$t[1]])){
1118 - $result[$t[1]] = $r[1];
1119 - }else {
1120 - $result[$t[1]] += $r[1];
1121 - }
1122 - }
1123 - }
1124 - }
1125 - return $result;
1126 -}
1127 -
1128 946 function wphal_adding_style() {
1129 947 wp_register_style('wp-hal-style1', plugins_url('/css/style.css', __FILE__));
1130 948 wp_register_style('wp-hal-style2', plugins_url('/css/jquery.jqplot.css', __FILE__));
1131 949
@@ -1227,21 +1045,20 @@
1227 1045 $content = 'Please check the <a href="https://wordpress.org/plugins/hal/faq/" target="_blank" id="FAQ">FAQ</a> with the code : CURL';
1228 1046
1229 1047 } else {
1230 1048 $instance['idhal'] = wphal_verifSolr($instance['idhal']);
1231 - $fieldName = $instance['typetext'] == 'title_s' ? 'title_s':'citationFull_s';
1232 1049
1233 - $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';
1234 1051 $json = wphal_do_get_data($url);
1235 1052
1236 - $count_results = is_array($json->response->docs) ? count($json->response->docs) : 0;
1237 - if (isset($json->response->docs) && $count_results > 0) {
1053 + $count_results = count($json->response->docs);
1054 + if ($count_results > 0) {
1238 1055 $content = '<ul class="widhal-ul">';
1239 1056 for ($i = 0; $i < $count_results - 1; $i++) {
1240 - if ($fieldName == 'title_s') {
1057 + if ($instance['typetext'] == 'citationRef_s') {
1058 + $typetext = $json->response->docs[$i]->citationRef_s;
1059 + } else {
1241 1060 $typetext = $json->response->docs[$i]->title_s[0];
1242 - } else {
1243 - $typetext = $json->response->docs[$i]->citationFull_s;
1244 1061 }
1245 1062 $content .= '<li class="widhal-li"><a href="' . esc_url($json->response->docs[$i]->uri_s) . '" target="_blank">' . $typetext . '</a></li>';
1246 1063 }
1247 1064 $content .= '</ul>';
@@ -1322,9 +1139,9 @@
1322 1139 <p>
1323 1140 <label for="<?php echo esc_attr($this->get_field_id("typetext"));?>"><?php echo esc_html(__("Type d'affichage",'wp-hal')) .' :'?></label>
1324 1141 <select id="<?php echo esc_attr($this->get_field_id("typetext"));?>" name="<?php echo esc_attr($this->get_field_name("typetext"));?>">
1325 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>
1326 - <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>
1327 1144 </select>
1328 1145 </p>
1329 1146 <p>
1330 1147 <label for="<?php echo esc_attr($this->get_field_id("select"));?>"><?php echo esc_html(__("Type d'Id",'wp-hal') .' :')?></label>
@@ -1330,8 +1147,9 @@
1330 1147 <label for="<?php echo esc_attr($this->get_field_id("select"));?>"><?php echo esc_html(__("Type d'Id",'wp-hal') .' :')?></label>
1331 1148 <select id="<?php echo esc_attr($this->get_field_id("select"));?>" name="<?php echo esc_attr($this->get_field_name("select"));?>">
1332 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>
1333 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>
1334 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>
1335 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>
1336 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>
1337 1155 </select>
@@ -1446,8 +1264,9 @@
1446 1264 <th scope="row"><label for="option_type"><?php echo esc_html(__('Type d\'Id','wp-hal'));?></label></th>
1447 1265 <td><select name="option_type">
1448 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>
1449 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>
1450 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>
1451 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>
1452 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>
1453 1272 </select>
@@ -1460,21 +1279,20 @@
1460 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>
1461 1280 </td>
1462 1281 </tr>
1463 1282 <tr style="vertical-align:top;">
1464 - <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>
1465 1284 <?php $option_choix = get_option('option_choix'); ?>
1466 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/>
1467 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/>
1468 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/>
1469 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/>
1470 - <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/>
1471 - <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/>
1472 - <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/>
1473 - <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/>
1474 - <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/>
1475 - <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/>
1476 - <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>
1477 1295 </td>
1478 1296 </tr>
1479 1297 <tr style="vertical-align:top;">
1480 1298 <th scope="row" style="font-size: 18px;"><?php echo esc_html(__('Contact :','wp-hal'));?></th>