PluginProbe
HAL / 2.0.7
HAL v2.0.7
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 +1143 -1346 2.22.0.7 View file →
@@ -1,1346 +1,1143 @@
1 -<?php
2 -/**
3 - * Plugin Name: HAL
4 - * Plugin URI: http://www.ccsd.cnrs.fr
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.2
7 - * Author: CCSD
8 - * Author URI: http://www.ccsd.cnrs.fr
9 - * Text Domain: wp-hal
10 - * Domain Path: /lang/
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 -
17 -//Récupère les constantes
18 -require_once("constantes.php");
19 -
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 {
26 - define('wphal_lang', 'en');
27 -}
28 -
29 -function wphal_is_curl_installed() {
30 - $loaded_extentions = get_loaded_extensions();
31 - if (in_array ('curl', $loaded_extentions)) {
32 - return true;
33 - }
34 - else {
35 - return false;
36 - }
37 -}
38 -
39 -// Création du shortcode ('nom du shortcode', 'fonction appelée')
40 -add_shortcode( 'cv-hal', 'wphal_cv_hal' );
41 -add_shortcode( 'nb-doc', 'wphal_nb_doc' );
42 -
43 -
44 -function wphal_charger_languages() {
45 - load_plugin_textdomain('wp-hal', false, dirname(plugin_basename(__FILE__)) . '/lang/');
46 -}
47 -
48 -add_action('plugins_loaded', 'wphal_charger_languages');
49 -
50 -function wphal_action_links( $links, $file ) {
51 - if ( $file != plugin_basename( __FILE__ ))
52 - return $links;
53 -
54 - $settings_link = '<a href="admin.php?page=wp-hal.php">' . __( 'Paramètres', 'wp-hal' ) . '</a>';
55 -
56 - array_unshift( $links, $settings_link );
57 -
58 - return $links;
59 -}
60 -
61 -add_filter( 'query_vars', 'wphal_query_vars' );
62 -function wphal_query_vars( $query_vars ) {
63 - $query_vars[] = 'hal_page';
64 - return $query_vars;
65 -}
66 -
67 -add_filter( 'plugin_action_links', 'wphal_action_links',10,2);
68 -/**
69 - * @param $url
70 - * @return object
71 - */
72 -function wphal_do_common_curl_call($url) {
73 - $response = wp_remote_get($url, [
74 - 'timeout'=>20,
75 - 'user-agent'=>"HAL Plugin Wordpress " . wphal_version,
76 - 'headers' => ['Content-type'=> 'application/json']
77 - ]);
78 - // we could ve parsed the response but if in general if no results then we get empty content
79 - $body = wp_remote_retrieve_body($response);
80 - // Récupération du résultat JSON
81 - $json = json_decode($body);
82 - return $json;
83 -}
84 -
85 -function wphal_clear_transients()
86 -{
87 - global $wpdb;
88 - // delete all "hal namespace" transients
89 - $sql = "
90 - DELETE
91 - FROM {$wpdb->options}
92 - WHERE option_name like '\_transient\_hal\_%'
93 - OR option_name like '\_transient\_timeout\_hal\_%'
94 - ";
95 -
96 - $wpdb->query($sql);
97 -}
98 -
99 -/**
100 - * @param $url
101 - * @return object
102 - */
103 -function wphal_do_get_data($url) {
104 - $transient_id = 'hal_'.md5($url);
105 - if(!empty(get_option('option_erase_cache'))){
106 - // we reset cache transient for hal namespace
107 - wphal_clear_transients();
108 - update_option('option_erase_cache', '');
109 - }
110 - $cache_expiration = empty(get_option('option_cache_timeout')) ? 1 * DAY_IN_SECONDS : intval(get_option('option_cache_timeout')) * MINUTE_IN_SECONDS;
111 - if ( false === ( $value = get_transient( $transient_id ) ) ) {
112 - $json = wphal_do_common_curl_call($url);
113 - if($json)
114 - set_transient( $transient_id, $json, $cache_expiration);
115 - return $json;
116 - } else{
117 - return $value;
118 - }
119 -}
120 -
121 -/**
122 - * PLUGIN SHORTCODE ND-DOC
123 - * @param $param
124 - * @return int
125 -*/
126 -function wphal_nb_doc($param)
127 -{
128 - $idhal = wphal_verifSolr(get_option('option_idhal'));
129 - extract(shortcode_atts(array(
130 - 'type' => get_option('option_type'),
131 - 'id' => $idhal
132 - ),
133 - $param
134 - ));
135 - /**
136 - * @var $id : defined by extract
137 - * @var string $type : defined by extract
138 - */
139 - $id = wphal_verifSolr($id);
140 -
141 - $url = wphal_api . '?q=*:*&fq=' . $type . ':(' . urlencode($id) . ')&rows=0&wt=json';
142 -
143 - $json =wphal_do_get_data($url);
144 - return $json->response->numFound;
145 -}
146 -/**
147 - * PLUGIN SHORTCODE CV-HAL
148 - * @param $param
149 - * @return string
150 - */
151 -function wphal_cv_hal($param){
152 - $content = '';
153 - if ( !wphal_is_curl_installed() ) {
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';
155 - } else {
156 - $possible_ids = ["authIdHal_s", "structId_i", "authStructId_i", "authId_i", "anrProjectId_i", "europeanProjectId_i", "collCode_s"];
157 - $option_choix = !empty(get_option('option_choix')) ? get_option('option_choix') : [];
158 - if(in_array('disciplines', $option_choix)){ //Lance les scripts pour le Graphique
159 - wp_enqueue_style('wp-hal-style2');
160 -
161 - wp_enqueue_script('wp-hal-script1');
162 - wp_enqueue_script('wp-hal-script2');
163 - wp_enqueue_script('wp-hal-script3');
164 - }
165 - $facetdomain = null;
166 -
167 - // those parameters are configured from plusing settings
168 - $default_id = wphal_verifSolr(get_option('option_idhal'));
169 - $default_type = get_option('option_type');
170 - $default_contact = get_option('option_infocontact');
171 - // here we merge with shortcode parameters
172 - extract(shortcode_atts(array(
173 - 'type' => $default_type,
174 - 'id' => $default_id,
175 - 'contact' => $default_contact
176 - ),
177 - $param
178 - ));
179 -
180 - /** @var $id : defined by extract
181 - * @var string $type : defined by extract
182 - * @var string $contact : defined by extract
183 - */
184 - if (!empty($id) && in_array($type, $possible_ids)) {
185 - $id = wphal_verifSolr($id);
186 -
187 - if (get_option('option_groupe') == 'grouper') {
188 - //cURL sur l'API pour récupérer les données
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';
190 - } elseif (get_option('option_groupe') == 'paginer') {
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';
192 - }
193 -
194 - $json = wphal_do_get_data($url);
195 - $hal_page = (get_query_var('hal_page')) ? get_query_var('hal_page') : 1;
196 -
197 - $content = '<div id="wphal-content">';
198 - if (is_array($option_choix) && !empty($option_choix)){
199 - $content .= '<ul id="wphal-menu">';
200 - $content .= '<li><a href="#publications" onclick="displayElem(\'publications\'); return false;" style="font-size:18px; text-decoration: none;">' . __('Publications', 'wp-hal') . '</a></li>';
201 -
202 - $content .= '<li><a href="#filtres" onclick="return false;" style="font-size:18px; text-decoration: none; cursor:default;">' . __('Filtres', 'wp-hal') . '</a>';
203 - $content .= '<ul id="wphal-filtres">';
204 - foreach ($option_choix as $option) {
205 - if ($option == 'contact') {
206 - $content .= '<li><a href="#contact" onclick="displayElem(\'wphal-contact\'); return false;" style="margin:1px; text-decoration: none;">' . __('Contact', 'wp-hal');
207 - $content .= '</a></li>';
208 - }
209 - if ($option == 'disciplines') {
210 - $content .= '<li><a href="#disciplines" onclick="displayElem(\'wphal-disciplines\'); return false;" style="margin:1px; text-decoration: none;">' . __('Disciplines', 'wp-hal');
211 - $content .= '</a></li>';
212 - }
213 - if ($option == 'mots-clefs') {
214 - $content .= '<li><a href="#keywords" onclick="displayElem(\'wphal-keywords\'); return false;" style="margin:1px; text-decoration: none;">' . __('Mots-clefs', 'wp-hal');
215 - $content .= '</a></li>';
216 - }
217 - if ($option == 'auteurs') {
218 - $content .= '<li><a href="#auteurs" onclick="displayElem(\'wphal-auteurs\'); return false;" style="margin:1px; text-decoration: none;">' . __('Auteurs', 'wp-hal');
219 - $content .= '</a></li>';
220 - }
221 - if ($option == 'revues') {
222 - $content .= '<li><a href="#revues" onclick="displayElem(\'wphal-revues\'); return false;" style="margin:1px; text-decoration: none;">' . __('Revues', 'wp-hal');
223 - $content .= '</a></li>';
224 - }
225 - if ($option == 'annee') {
226 - $content .= '<li><a href="#annees" onclick="displayElem(\'wphal-annees\'); return false;" style="margin:1px; text-decoration: none;">' . __('Année de production', 'wp-hal');
227 - $content .= '</a></li>';
228 - }
229 - if ($option == 'institution') {
230 - $content .= '<li><a href="#insts" onclick="displayElem(\'wphal-insts\'); return false;" style="margin:1px; text-decoration: none;">' . __('Institutions', 'wp-hal');
231 - $content .= '</a></li>';
232 - }
233 - if ($option == 'laboratoire') {
234 - $content .= '<li><a href="#labs" onclick="displayElem(\'wphal-labs\'); return false;" style="margin:1px; text-decoration: none;">' . __('Laboratoires', 'wp-hal');
235 - $content .= '</a></li>';
236 - }
237 - if ($option == 'departement') {
238 - $content .= '<li><a href="#depts" onclick="displayElem(\'wphal-depts\'); return false;" style="margin:1px; text-decoration: none;">' . __('Départements', 'wp-hal');
239 - $content .= '</a></li>';
240 - }
241 - if ($option == 'equipe') {
242 - $content .= '<li><a href="#equipes" onclick="displayElem(\'wphal-equipes\'); return false;" style="margin:1px; text-decoration: none;">' . __('Équipes de recherche', 'wp-hal');
243 - $content .= '</a></li>';
244 - }
245 - }
246 - $content .= '</ul></li>';
247 -
248 - $content .= '</ul><br/><hr>';
249 - }
250 -
251 - $content .= '<div id="meta">
252 - <div class="display" id="wphal-contact" style="display: none;">
253 - <h3 class="wphal-titre">' . __('Contact', 'wp-hal');
254 - $content .= '</h3>
255 -
256 - <ul id="wphal-cont" style="list-style-type: none;">';
257 -
258 - if ($contact == 'yes' && $type == 'authIdHal_s') {
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);
260 - $jsonauthor = wphal_do_get_data($urlauthor);
261 -
262 - for ($i = 0; $jsonauthor->response->docs[$i] != ''; $i++) {
263 - $content .= '<div class="wphal-infocontact" id="wphal-infocontact'.$i.'">';
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>';
266 - }
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>';
269 - }
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>';
272 - }
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>';
275 - }
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>';
278 - }
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>';
281 - }
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>';
284 - }
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>';
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 - }
291 - $content .= '</div>';
292 - }
293 - }
294 - if (get_option('option_email') != '') {
295 - $content .= '<li><img alt="mail" src=" ' . esc_url(plugin_dir_url(__FILE__) . 'img/mail.svg').' " style=" width:16px; margin-left:2px; margin-right:2px;"/><a href="'.esc_url('mailto:' . get_option('option_email')) . '" target="_blank">' . get_option('option_email') . '</a></li>';
296 - }
297 - if (get_option('option_tel') != '') {
298 - $content .= '<li><img alt="phone" src=" ' . esc_url(plugin_dir_url(__FILE__) . 'img/phone.svg'). '" style="width:16px; margin-left:2px; margin-right:2px;"/>' . get_option('option_tel') . '</li>';
299 - }
300 - if (get_option('option_social0') != '') {
301 - $content .= '<li><a href="'.esc_url('http://www.facebook.com/' . get_option('option_social0')) . '" target="_blank"><img
302 - alt="Facebook" src=" ' . esc_url(plugin_dir_url(__FILE__) . 'img/facebook.svg').'" style="width:32px; margin:4px;"/></a></li>';
303 - }
304 - if (get_option('option_social1') != '') {
305 - $content .= '<li><a href="'.esc_url('http://www.twitter.com/' . get_option('option_social1')) . '" target="_blank"><img
306 - alt="Twitter" src=" ' . esc_url(plugin_dir_url(__FILE__) . 'img/twitter.svg').'" style="width:32px; margin:4px;"/></a></li>';
307 - }
308 - if (get_option('option_social2') != '') {
309 - $content .= '<li><a href="'.esc_url('https://plus.google.com/u/0/+' . get_option('option_social2')) . '" target="_blank"><img
310 - alt="Google+" src=" ' . esc_url(plugin_dir_url(__FILE__) . 'img/google-plus.svg').'" style="width:32px; margin:4px;"/></a></li>';
311 - }
312 - if (get_option('option_social3') != '') {
313 - $content .= '<li><a href="'.esc_url('https://www.linkedin.com/in/' . get_option('option_social3')) . '" target="_blank"><img
314 - alt="LinkedIn" src=" ' . esc_url(plugin_dir_url(__FILE__) . 'img/linkedin.svg').'" style="width:32px; margin:4px;"/></a></li>';
315 - }
316 - $content .= '</ul>
317 - </div>
318 - <div class="display" id="wphal-disciplines" style="display: none;">
319 - <h3 class="wphal-titre">' . __('Disciplines', 'wp-hal') . '</h3>';
320 -
321 - if (wphal_locale == 'fr_FR') {
322 - $facetdomain = $json->facet_counts->facet_fields->fr_domainAllCodeLabel_fs;
323 - } elseif (wphal_locale == 'es_ES') {
324 - $facetdomain = $json->facet_counts->facet_fields->es_domainAllCodeLabel_fs;
325 - } else {
326 - $facetdomain = $json->facet_counts->facet_fields->en_domainAllCodeLabel_fs;
327 - }
328 -
329 - if (!is_null($facetdomain) && !empty($facetdomain)) {
330 - $content .= '<div id="listdisci">';
331 - $content .= '<span id="tridisciplines">';
332 - $content .= '<button type="button" class="trial" id="tridisci" onclick="toggleSort(this, true, \'wphal-discipline\', \'wphal-discipline\', \'tridisci\'); return false;" style="font-size:16px; text-decoration: none;" >Tri Alphabétique</button>';
333 - $content .= '<button type="button" class="trioc" id="trinbdisci" onclick="toggleSort(this, false, \'wphal-discipline\', \'wphal-discipline\', \'trinbdisci\'); return false;" style="font-size:16px; text-decoration: none;">Tri Occurrence</button>';
334 - $content .= '</span>';
335 - $content .= '<ul id="wphal-discipline" class="wphal-discipline">';
336 - foreach ($facetdomain as $res) {
337 - $name = explode(wphal_delimiter, $res[0]);
338 - $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . esc_url(halv3 . '?q=domainAllCode_s:' . urlencode($name[0]) . "+AND+" . $type . ':(' . $id . ')').'" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
339 - }
340 - $content .= '</ul>';
341 - $content .= '</div>';
342 -
343 - $content .= '<div id="wphal-graph" style="display:none;">';
344 - $content .= '<div id="wphal-piedisci"></div>';
345 - $content .= '</div>';
346 - $content .= '<button type="button" style="text-decoration: none;" id="wphal-disci" onclick="visibilitedisci(\'listdisci\',\'wphal-graph\',\'tridisciplines\'); return false;" >' . __('Graphique', 'wp-hal');
347 - $content .= '</button>';
348 - }
349 - $content .= '</div>
350 - <div class="display" id="wphal-keywords" style="display: none;">
351 - <h3 class="wphal-titre">' . __('Mots-clefs', 'wp-hal') . '</h3>';
352 - if (!is_null($json->facet_counts->facet_fields->keyword_s) && !empty($json->facet_counts->facet_fields->keyword_s)) {
353 - $content .= '<div id="wphal-keys">';
354 - $r = 0;
355 - // CSS Nuage de mots
356 - $maxsize = 25;
357 - $minsize = 10;
358 - $maxval = max(array_values($json->facet_counts->facet_fields->keyword_s[1]));
359 - $minval = min(array_values($json->facet_counts->facet_fields->keyword_s[1]));
360 - if(!is_numeric($minval)) {$minval = 0;}
361 - if(!is_numeric($maxval)) {$maxval = 0;}
362 - $spread = ($maxval - $minval);
363 - $step = ($maxsize - $minsize) / $spread;
364 - $tab = array();
365 - foreach ($json->facet_counts->facet_fields->keyword_s as $res) {
366 - $r = $r + 1;
367 - if ($r > 20) {
368 - break;
369 - }
370 - $tab[] = $res;
371 - }
372 - asort($tab); // Tri du tableau par ordre alphabétique
373 - foreach ($tab as $res) {
374 - $size = round($minsize + (($res[1] - $minval) * $step));
375 - $content .= '<a style="display: inline-block; font-size:' . $size . 'px" href="' . esc_url(halv3 . '?q=keyword_s:' . urlencode('"' . $res[0] . '"') . "+AND+" . $type . ':(' . $id . ')').'" target="_blank">' . $res[0] . '</a>&nbsp;';
376 - }
377 - $content .= '</div>';
378 - $content .= '<div id="keysuite" style="display:none;">';
379 - $content .= '<span id="trikeywords">';
380 - $content .= '<button type="button" class="trial" id="trikey" onclick="toggleSort(this, true, \'wphal-keyw\', \'wphal-keyword\', \'trikey\'); return false;" style="font-size:16px; text-decoration: none;" >Tri Alphabétique</button>';
381 - $content .= '<button type="button" class="trioc" id="trinbkey" onclick="toggleSort(this, false, \'wphal-keyw\', \'wphal-keyword\', \'trinbkey\'); return false;" style="font-size:16px; text-decoration: none;">Tri Occurrence</button>';
382 - $content .= '</span>';
383 - $content .= '<ul class="wphal-keyword">';
384 - $content .= '<div id="wphal-keyw">';
385 - foreach ($json->facet_counts->facet_fields->keyword_s as $res) {
386 - $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . esc_url(halv3 . '?q=keyword_s:' . urlencode('"' . $res[0] . '"') . "+AND+" . $type . ':(' . $id . ')').'" target="_blank">' . $res[0] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
387 - }
388 - $content .= '</div>';
389 - $content .= '</ul>';
390 - $content .= '</div>';
391 - $content .= '<button type="button" style="text-decoration: none;" id="wphal-key" onclick="visibilitekey(\'wphal-keys\',\'keysuite\', \'trikeywords\'); return false;" >' . __('Liste complète', 'wp-hal');
392 - $content .= '</button>';
393 - }
394 - $content .= '</div>
395 - <div class="display" id="wphal-auteurs" style="display: none;">
396 - <h3 class="wphal-titre">' . __('Auteurs', 'wp-hal') . '</h3>';
397 - if (!is_null($json->facet_counts->facet_fields->authIdLastNameFirstName_fs) && !empty($json->facet_counts->facet_fields->authIdLastNameFirstName_fs)) {
398 - $content .= '<span id="triauteurs">';
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>';
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>';
401 - $content .= '</span>';
402 - $content .= '<ul class="wphal-auteurs" style="list-style-type: none;">';
403 - $content .= '<div id="wphal-aut">';
404 - $r = 0;
405 - foreach ($json->facet_counts->facet_fields->authIdLastNameFirstName_fs as $res) {
406 - $r = $r + 1;
407 - if ($r > 10) {
408 - break;
409 - }
410 - $name = explode(wphal_delimiter, $res[0]);
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>';
412 - }
413 - $i = 1;
414 - $content .= '<div id="auteursuite" style="display:none;">';
415 - foreach ($json->facet_counts->facet_fields->authIdLastNameFirstName_fs as $res) {
416 - if ($r < 10) {
417 - break;
418 - }
419 - if ($i < $r) {
420 - $i = $i + 1;
421 - } else {
422 - $name = explode(wphal_delimiter, $res[0]);
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>';
424 - }
425 - }
426 - $content .= '</div>';
427 - $content .= '</div>';
428 - $content .= '</ul>';
429 - if ($r > 10) {
430 - $content .= '<button type="button" style="text-decoration: none;" id="wphal-auteur" onclick="visibilite(\'auteursuite\'); return false;" >' . __('Liste complète', 'wp-hal');
431 - $content .= '</button>';
432 - }
433 - }
434 - $content .= '</div>
435 - <div class="display" id="wphal-revues" style="display: none;">
436 - <h3 class="wphal-titre">' . __('Revues', 'wp-hal') . '</h3>';
437 - if (!is_null($json->facet_counts->facet_fields->journalIdTitle_fs) && !empty($json->facet_counts->facet_fields->journalIdTitle_fs)) {
438 - $content .= '<span id="trirevues">';
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>';
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>';
441 - $content .= '</span>';
442 - $content .= '<ul class="wphal-revues">';
443 - $content .= '<div id="wphal-rev">';
444 - $r = 0;
445 - foreach ($json->facet_counts->facet_fields->journalIdTitle_fs as $res) {
446 - $r = $r + 1;
447 - if ($r > 10) {
448 - break;
449 - }
450 - $name = explode(wphal_delimiter, $res[0]);
451 - $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . esc_url(halv3 . '?q=journalId_i:' . urlencode($name[0]) . "+AND+" . $type . ':(' . $id . ')').'" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
452 - }
453 - $i = 1;
454 - $content .= '<div id="revuesuite" style="display:none;">';
455 - foreach ($json->facet_counts->facet_fields->journalIdTitle_fs as $res) {
456 - if ($r < 10) {
457 - break;
458 - }
459 - if ($i < $r) {
460 - $i = $i + 1;
461 - } else {
462 - $name = explode(wphal_delimiter, $res[0]);
463 - $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . esc_url(halv3 . '?q=journalId_i:' . urlencode($name[0]) . "+AND+" . $type . ':(' . $id . ')').'" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
464 - }
465 - }
466 - $content .= '</div>';
467 - $content .= '</div>';
468 - $content .= '</ul>';
469 - if ($r > 10) {
470 - $content .= '<button type="button" style="text-decoration: none;" id="wphal-revue" onclick="visibiliterevues(\'revuesuite\'); return false;" >' . __('Liste complète', 'wp-hal');
471 - $content .= '</button>';
472 - }
473 - }
474 - $content .= '</div>
475 - <div class="display" id="wphal-annees" style="display: none;">
476 - <h3 class="wphal-titre">' . __('Année de production', 'wp-hal') . '</h3>';
477 - if (!is_null($json->facet_counts->facet_fields->producedDateY_i) && !empty($json->facet_counts->facet_fields->producedDateY_i)) {
478 - $content .= '<span id="triannees">';
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>';
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>';
481 - $content .= '</span>';
482 - $content .= '<ul class="wphal-annees">';
483 - $content .= '<div id="wphal-an">';
484 -
485 - rsort($json->facet_counts->facet_fields->producedDateY_i);
486 - $r = 0;
487 - foreach ($json->facet_counts->facet_fields->producedDateY_i as $res) {
488 - $r = $r + 1;
489 - if ($r > 10) {
490 - break;
491 - }
492 - $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . esc_url(halv3 . '?q=producedDateY_i:' . urlencode($res[0]) . "+AND+" . $type . ':(' . $id . ')').'" target="_blank">' . $res[0] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
493 - }
494 - $i = 1;
495 - $content .= '<div id="anneesuite" style="display:none;">';
496 - foreach ($json->facet_counts->facet_fields->producedDateY_i as $res) {
497 - if ($r < 10) {
498 - break;
499 - }
500 - if ($i < $r) {
501 - $i = $i + 1;
502 - } else {
503 - $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . esc_url(halv3 . '?q=producedDateY_i:' . urlencode($res[0]) . "+AND+" . $type . ':(' . $id . ')').'" target="_blank">' . $res[0] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
504 - }
505 - }
506 - $content .= '</div>';
507 - $content .= '</div>';
508 - $content .= '</ul>';
509 - if ($r > 10) {
510 - $content .= '<button type="button" style="text-decoration: none;" id="wphal-annee" onclick="visibiliteannee(\'anneesuite\'); return false;" >' . __('Liste complète', 'wp-hal');
511 - $content .= '</button>';
512 - }
513 - }
514 - $content .= '</div>
515 - <div class="display" id="wphal-insts" style="display: none;">
516 - <h3 class="wphal-titre">' . __('Institutions', 'wp-hal') . '</h3>';
517 - if (!is_null($json->facet_counts->facet_fields->instStructIdName_fs) && !empty($json->facet_counts->facet_fields->instStructIdName_fs)) {
518 - $content .= '<span id="triinsts">';
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>';
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>';
521 - $content .= '</span>';
522 - $content .= '<ul class="wphal-insts">';
523 - $content .= '<div id="wphal-institu">';
524 - $r = 0;
525 - foreach ($json->facet_counts->facet_fields->instStructIdName_fs as $res) {
526 - $r = $r + 1;
527 - if ($r > 10) {
528 - break;
529 - }
530 - $name = explode(wphal_delimiter, $res[0]);
531 - $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . esc_url(halv3 . '?q=instStructId_i:' . urlencode($name[0]) . "+AND+" . $type . ':(' . $id . ')').'" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
532 - }
533 - $i = 1;
534 - $content .= '<div id="instsuite" style="display:none;">';
535 - foreach ($json->facet_counts->facet_fields->instStructIdName_fs as $res) {
536 - if ($r < 10) {
537 - break;
538 - }
539 - if ($i < $r) {
540 - $i = $i + 1;
541 - } else {
542 - $name = explode(wphal_delimiter, $res[0]);
543 - $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . esc_url(halv3 . '?q=instStructId_i:' . urlencode($name[0]) . "+AND+" . $type . ':(' . $id . ')').'" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
544 - }
545 - }
546 - $content .= '</div>';
547 - $content .= '</div>';
548 - $content .= '</ul>';
549 - if ($r > 10) {
550 - $content .= '<button type="button" style="text-decoration: none;" id="wphal-inst" onclick="visibiliteinst(\'instsuite\'); return false;" >' . __('Liste complète', 'wp-hal');
551 - $content .= '</button>';
552 - }
553 - }
554 - $content .= '</div>
555 - <div class="display" id="wphal-labs" style="display: none;">
556 - <h3 class="wphal-titre">' . __('Laboratoires', 'wp-hal') . '</h3>';
557 - if (!is_null($json->facet_counts->facet_fields->labStructIdName_fs) && !empty($json->facet_counts->facet_fields->labStructIdName_fs)) {
558 - $content .= '<span id="trilabs">';
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>';
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>';
561 - $content .= '</span>';
562 - $content .= '<ul class="wphal-labs">';
563 - $content .= '<div id="wphal-labo">';
564 -
565 - $r = 0;
566 - foreach ($json->facet_counts->facet_fields->labStructIdName_fs as $res) {
567 - $r = $r + 1;
568 - if ($r > 10) {
569 - break;
570 - }
571 - $name = explode(wphal_delimiter, $res[0]);
572 - $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . esc_url(halv3 . '?q=labStructId_i:' . urlencode($name[0]) . "+AND+" . $type . ':(' . $id . ')').'" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
573 - }
574 - $i = 1;
575 - $content .= '<div id="labsuite" style="display:none;">';
576 - foreach ($json->facet_counts->facet_fields->labStructIdName_fs as $res) {
577 - if ($r < 10) {
578 - break;
579 - }
580 - if ($i < $r) {
581 - $i = $i + 1;
582 - } else {
583 - $name = explode(wphal_delimiter, $res[0]);
584 - $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . esc_url(halv3 . '?q=labStructId_i:' . urlencode($name[0]) . "+AND+" . $type . ':(' . $id . ')').'" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
585 - }
586 - }
587 - $content .= '</div>';
588 - $content .= '</div>';
589 - $content .= '</ul>';
590 - if ($r > 10) {
591 - $content .= '<button type="button" style="text-decoration: none;" id="wphal-lab" onclick="visibilitelab(\'labsuite\'); return false;" >' . __('Liste complète', 'wp-hal');
592 - $content .= '</button>';
593 - }
594 - }
595 - $content .= '</div>
596 - <div class="display" id="wphal-depts" style="display: none;">
597 - <h3 class="wphal-titre">' . __('Départements', 'wp-hal') . '</h3>';
598 - if (!is_null($json->facet_counts->facet_fields->deptStructIdName_fs) && !empty($json->facet_counts->facet_fields->deptStructIdName_fs)) {
599 - $content .= '<span id="tridept">';
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>';
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>';
602 - $content .= '</span>';
603 - $content .= '<ul class="wphal-depts">';
604 - $content .= '<div id="wphal-dpt">';
605 - $r = 0;
606 - foreach ($json->facet_counts->facet_fields->deptStructIdName_fs as $res) {
607 - $r = $r + 1;
608 - if ($r > 10) {
609 - break;
610 - }
611 - $name = explode(wphal_delimiter, $res[0]);
612 - $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . esc_url(halv3 . '?q=deptStructId_i:' . urlencode($name[0]) . "+AND+" . $type . ':(' . $id . ')').'" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
613 - }
614 - $i = 1;
615 - $content .= '<div id="deptsuite" style="display:none;">';
616 - foreach ($json->facet_counts->facet_fields->deptStructIdName_fs as $res) {
617 - if ($r < 10) {
618 - break;
619 - }
620 - if ($i < $r) {
621 - $i = $i + 1;
622 - } else {
623 - $name = explode(wphal_delimiter, $res[0]);
624 - $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . esc_url(halv3 . '?q=deptStructId_i:' . urlencode($name[0]) . "+AND+" . $type . ':(' . $id . ')').'" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
625 - }
626 - }
627 - $content .= '</div>';
628 - $content .= '</div>';
629 - $content .= '</ul>';
630 - if ($r > 10) {
631 - $content .= '<button type="button" style="text-decoration: none;" id="wphal-dept" onclick="visibilitedept(\'deptsuite\'); return false;" >' . __('Liste complète', 'wp-hal');
632 - $content .= '</button>';
633 - }
634 - }
635 - $content .= '</div>
636 - <div class="display" id="wphal-equipes" style="display: none;">
637 - <h3 class="wphal-titre">' . __('Équipes de recherche', 'wp-hal') . '</h3>';
638 - if (!is_null($json->facet_counts->facet_fields->rteamStructIdName_fs) && !empty($json->facet_counts->facet_fields->rteamStructIdName_fs)) {
639 - $content .= '<span id="triequipe">';
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>';
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>';
642 - $content .= '</span>';
643 - $content .= '<ul class="wphal-equipes">';
644 - $content .= '<div id="wphal-rteam">';
645 -
646 - $r = 0;
647 - $name=[];
648 - foreach ($json->facet_counts->facet_fields->rteamStructIdName_fs as $res) {
649 - $r = $r + 1;
650 - if ($r > 10) {
651 - break;
652 - }
653 - $name = explode(wphal_delimiter, $res[0]);
654 - $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . esc_url(halv3 . '?q=rteamStructId_i:' . urlencode($name[0]) . "+AND+" . $type . ':(' . $id . ')').'" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
655 - }
656 - $i = 1;
657 - $content .= '<div id="equipesuite" style="display:none;">';
658 - foreach ($json->facet_counts->facet_fields->rteamStructIdName_fs as $res) {
659 - if ($r < 10) {
660 - break;
661 - }
662 - if ($i < $r) {
663 - $i = $i + 1;
664 - } else {
665 - $name = explode(wphal_delimiter, $res[0]);
666 - $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . esc_url(halv3 . '?q=rteamStructId_i:' . urlencode($name[0]) . "+AND+" . $type . ':(' . $id . ')').'" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
667 - }
668 - }
669 - $content .= '</div>';
670 - $content .= '</div>';
671 - $content .= '</ul>';
672 - if ($r > 10) {
673 - $content .= '<button type="button" style="text-decoration: none;" id="wphal-equipe" onclick="visibiliteequipe(\'equipesuite\'); return false;" >' . __('Liste complète', 'wp-hal');
674 - $content .= '</button>';
675 - }
676 - }
677 - $content .= '</div>
678 - <div class="display" id="publications">';
679 - if (get_option('option_groupe') == 'grouper') {
680 - $doctype = file_get_contents(plugin_dir_path( __FILE__ ).'json'. DIRECTORY_SEPARATOR .'doctype_fr.json');
681 - $jsontype = json_decode($doctype);
682 -
683 -//LISTE DES DOCUMENTS PAR GROUPE
684 -
685 - $content .= '<div class="counter-doc"><span class="wphal-nbtot">' . $json->grouped->docType_s->matches . ' </span>';
686 - $content .= __('documents', 'wp-hal'). '</div><br>';
687 - for ($i = 0; !empty($jsontype->response->result->doc[$i]); $i++) {
688 - for ($d = 0; !empty($json->grouped->docType_s->groups[$d]); $d++) {
689 - if ($json->grouped->docType_s->groups[$d]->groupValue == $jsontype->response->result->doc[$i]->str[0]){
690 - $titre = $jsontype->response->result->doc[$i]->str[1];
691 - $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>';
692 - $content .= '<div class="grp-content">';
693 - $content .= '<ul>';
694 - foreach ($json->grouped->docType_s->groups[$d]->doclist->docs as $result) {
695 - $content .= '<li>' . $result->citationFull_s . '</li>';
696 - }
697 - $content .= '</ul></div>';
698 - $content .= '</div><br>';
699 - break;
700 - }
701 - }
702 - }
703 - } elseif (get_option('option_groupe') == 'paginer') {
704 -
705 -//LISTE DES DOCUMENTS AVEC PAGINATION
706 - $content .= '<div class="counter-doc"><span class="wphal-nbtot">' . $json->response->numFound . ' </span>';
707 - $content .= __('documents', 'wp-hal'). '</div><br>';
708 -
709 -//--MODULE PAGINATION--//
710 - $messagesParPage = 10;
711 -
712 - $total = $json->response->numFound;
713 -
714 - $nombreDePages = ceil($total / $messagesParPage);
715 -
716 - if (isset($hal_page)) {
717 - $pageActuelle = intval($hal_page);
718 -
719 - if ($pageActuelle > $nombreDePages) {
720 - $pageActuelle = $nombreDePages;
721 - }
722 - } else {
723 - $pageActuelle = 1;
724 - }
725 - $premiereEntree = ($pageActuelle - 1) * $messagesParPage;
726 -
727 - $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';
728 - $json = wphal_do_get_data($url);
729 -
730 -//--MODULE PAGINATION--//
731 - $count_results = count($json->response->docs);
732 - if($count_results>0) {
733 - $content .= '<ul>';
734 - for ( $i = 0; $i <= $count_results - 1; $i ++ ) {
735 - $content .= '<li>' . $json->response->docs[ $i ]->citationFull_s . '</li>';
736 - }
737 - $content .= '</ul>';
738 - } else {
739 - $content = '<div> no results !</div>';
740 - }
741 - if($total> $messagesParPage) {
742 - //--AFFICHAGE PAGINATION--//
743 - $precedents = $pageActuelle - 2;
744 - $suivants = $pageActuelle + 2;
745 - $precedent = $pageActuelle - 1;
746 - $suivant = $pageActuelle + 1;
747 - $penultimate = $nombreDePages - 1;
748 -
749 - $content .= '<ul class="wphal-pagination">';
750 - //--BOUTON PRECEDENT--//
751 - if ( $pageActuelle != 1 ) {
752 - $content .= '<li><a href="?hal_page=' . $precedent . '">&laquo;</a></li>';
753 - }
754 - if ( $nombreDePages <= 6 ) {// Cas 1 : 6 pages ou moins - Pas de troncature
755 - for ( $i = 1; $i <= $nombreDePages; $i ++ ) {
756 - if ( $i == $pageActuelle ) {
757 - $content .= '<li class="active"><a href="#">' . $i . '</a></li>';
758 - } else {
759 - $content .= ' <li><a href="?hal_page=' . $i . '">' . $i . '</a></li> ';
760 - }
761 - }
762 - } elseif ( $nombreDePages >= 7 ) {// Cas 2 : 7 pages ou plus - Troncature
763 - if ( $pageActuelle <= 3 ) {// Lorsque l'on est sur les trois premières pages
764 - for ( $i = 1; $i <= 4; $i ++ ) {
765 - if ( $i == $pageActuelle ) {
766 - $content .= '<li class="active"><a href="#">' . $i . '</a></li>';
767 - } else {
768 - $content .= '<li><a href="?hal_page=' . $i . '">' . $i . '</a></li>';
769 - }
770 - }
771 - $content .= '<li class="disabled"><a href="#">&hellip;</a></li>';
772 - $content .= '<li><a href="?hal_page=' . $penultimate . '">' . $penultimate . '</a></li>';
773 - $content .= '<li><a href="?hal_page=' . $nombreDePages . '">' . $nombreDePages . '</a></li>';
774 - }
775 - if ( $pageActuelle >= 4 && $pageActuelle <= $penultimate - 2 ) {//Lorsque l'on arrive sur la quatrième page
776 - $content .= '<li><a href="?hal_page=">1</a></li>';
777 - $content .= '<li class="disabled"><a href="#">&hellip;</a></li>';
778 - $content .= '<li><a href="?hal_page=' . $precedents . '">' . $precedents . '</a></li>';
779 - $content .= '<li><a href="?hal_page=' . $precedent . '">' . $precedent . '</a></li>';
780 - $content .= '<li class="active"><a href="#">' . $pageActuelle . '</a></li>';
781 - $content .= '<li><a href="?hal_page=' . $suivant . '">' . $suivant . '</a></li>';
782 - $content .= '<li><a href="?hal_page=' . $suivants . '">' . $suivants . '</a></li>';
783 - $content .= '<li class="disabled"><a href="#">&hellip;</a></li>';
784 - $content .= '<li><a href="?hal_page=' . $nombreDePages . '">' . $nombreDePages . '</a></li>';
785 - }
786 - if ( $pageActuelle >= $penultimate - 1 ) {
787 - $content .= '<li><a href="?hal_page=1">1</a></li>';
788 - $content .= '<li><a href="?hal_page=2">2</a></li>';
789 - $content .= '<li class="disabled"><a href="#">&hellip;</a></li>';
790 - for ( $i = $penultimate - 2; $i <= $nombreDePages; $i ++ ) {
791 - if ( $i == $pageActuelle ) {
792 - $content .= '<li class="active"><a href="#">' . $i . '</a></li>';
793 - } else {
794 - $content .= '<li><a href="?hal_page=' . $i . '">' . $i . '</a></li>';
795 - }
796 - }
797 - }
798 - }
799 - //--BOUTON SUIVANT--//
800 - if ( $pageActuelle < $nombreDePages ) {
801 - $content .= '<li><a href="?hal_page=' . $suivant . '">&raquo;</a></li>';
802 - }
803 - $content .= '</ul>';
804 - //--AFFICHAGE PAGINATION--//
805 - }
806 - }
807 - $content .= '</div>
808 - </div>
809 -</div>';
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 - }
813 - $content .= '<div class="wphal-footer">';
814 - $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.svg').'" style="width:32px;"></a></p>';
815 - $content .= '</div>';
816 -
817 -//--AFFICHAGE GRAPHIQUE DOMAINE--//
818 - if (!is_null($facetdomain)) {
819 - foreach ($facetdomain as $res) {
820 - $name = explode(wphal_delimiter, $res[0])[1];
821 - $value = $res[1];
822 - $array[] = array($name, $value);
823 - }
824 - wp_localize_script('wp-hal-script4', 'WPWallSettings', $array);
825 - }
826 - $translation = array('liste' => __('Liste', 'wp-hal'), 'compl' => __('Liste complète', 'wp-hal'), 'princ' => __('Liste principale', 'wp-hal'), 'graph' => __('Graphique', 'wp-hal'), 'nuage' => __('Nuage de mots', 'wp-hal'));
827 - wp_localize_script('wp-hal-script4', 'translate', $translation);
828 - }
829 - // tags other that those will be stripped
830 - $allowed_html_tags = array(
831 - 'div' => array(
832 - 'class' => array(),
833 - 'id' => array(),
834 - 'style' => array(),
835 - ),
836 - "span"=> array(
837 - 'class' => array(),
838 - 'id' => array(),
839 - 'style' => array(),
840 - ),
841 - "img"=> array(
842 - 'alt' => array(),
843 - 'src' => array(),
844 - 'style' => array(),
845 -
846 - ),
847 - 'p' => array(
848 - 'style' => array(),
849 - 'id' => array(),
850 - ),
851 - 'h3' => array(
852 - 'id' => array(),
853 - 'class' => array(),
854 - 'style' => array()
855 - ),
856 - 'a' => array(
857 - 'href' => array(),
858 - 'target' => array(),
859 - 'title' => array(),
860 - 'id' => array(),
861 - 'class' => array(),
862 - 'style' => array(),
863 - 'onclick' => array(),
864 - ),
865 - 'ul' => array(
866 - 'class' => array(),
867 - 'id' => array(),
868 - 'style' => array(),
869 - ),
870 - 'li' => array(
871 - 'class' => array(),
872 - 'id' => array(),
873 - 'data-percentage' => array()
874 - ),
875 - 'button' => array(
876 - 'class' => array(),
877 - 'id' => array(),
878 - 'type' => array(),
879 - 'style' => array(),
880 - 'onclick' => array()
881 - )
882 - ,'br' => array()
883 - ,'hr' => array()
884 - ,'i' => array(),
885 - );
886 - add_filter( 'safe_style_css', function( $styles ) {
887 - $styles[] = 'display';
888 - return $styles;
889 - } );
890 - return wp_kses($content, $allowed_html_tags);
891 -}
892 -
893 -function wphal_verifSolr($values){
894 - $verifsolr = explode(',',$values);
895 - $numverif = count($verifsolr);
896 - $solrsql = '';
897 - if ($numverif<1024){
898 - $solrsql = str_replace(',',' OR ',$values);
899 - } else {
900 - $listsolrsql = explode(',',$values);
901 - for($i=0;$i<1024;$i++){
902 - if ($i == 0){
903 - $solrsql = $listsolrsql[$i];
904 - } else {
905 - $solrsql .= ' OR ';
906 - $solrsql .= $listsolrsql[$i];
907 - }
908 - }
909 - }
910 -
911 - return $solrsql;
912 -}
913 -
914 -function wphal_adding_style() {
915 - wp_register_style('wp-hal-style1', plugins_url('/css/style.css', __FILE__));
916 - wp_register_style('wp-hal-style2', plugins_url('/css/jquery.jqplot.css', __FILE__));
917 -
918 - wp_enqueue_style('wp-hal-style1');
919 -}
920 -
921 -function wphal_adding_script() {
922 - wp_register_script('wp-hal-script1',plugins_url('/js/jquery.jqplot.js', __FILE__));
923 - wp_register_script('wp-hal-script2',plugins_url('/js/jqplot.highlighter.js', __FILE__));
924 - wp_register_script('wp-hal-script3',plugins_url('/js/jqplot.pieRenderer.js', __FILE__));
925 - wp_register_script('wp-hal-script4',plugins_url('/js/cv-hal.js', __FILE__));
926 -
927 -
928 - wp_enqueue_script("jquery");
929 - wp_enqueue_script('wp-hal-script4', false, array(), false, true);
930 -}
931 -
932 -/**
933 - * Récupère les fichiers css et js
934 - */
935 -if ( wphal_is_curl_installed() ) {
936 - add_action('wp_enqueue_scripts', 'wphal_adding_style');
937 - add_action('wp_enqueue_scripts', 'wphal_adding_script');
938 -}
939 -
940 -/**
941 - * Charge lorsque le plugin est désactivé
942 - */
943 -register_deactivation_hook( __FILE__, 'wphal_reset_option' );
944 -
945 -/**
946 - * Ajoute le widget wphal à l'initialisation des widgets
947 - */
948 -add_action('widgets_init','wphal_init');
949 -
950 -/**
951 - * Ajoute le menu à l'initialisation du menu admin
952 - */
953 -add_action( 'admin_menu', 'wphal_menu' );
954 -
955 -/**
956 - * Fonction de création du menu
957 - */
958 -function wphal_menu() {
959 - add_menu_page( 'Options', 'Hal', 'manage_options', 'wp-hal.php', 'wphal_option' , '', 21);
960 -
961 - add_action( 'admin_init', 'wphal_register_settings' );
962 -}
963 -
964 -
965 -/**
966 - * Initialise le nouveau widget
967 - */
968 -function wphal_init(){
969 - register_widget("wphal_widget");
970 -}
971 -
972 -/***********************************************************************************************************************
973 - * PLUGIN WIDGET
974 - **********************************************************************************************************************/
975 -
976 -/**
977 - * Classe du widget wphal
978 - */
979 -
980 -class wphal_widget extends WP_widget{
981 - /**
982 - * Défini les propriétés du widget
983 - */
984 - function __construct(){
985 - $options = array(
986 - "classname" => "wphal-publications",
987 - "description" => __("Afficher les dernières publications d'un auteur ou d'une structure.", 'wp-hal')
988 - );
989 -
990 - parent::__construct(
991 - 'hal-publications',
992 - __("Publications HAL", 'wp-hal'),
993 - $options
994 - );
995 - }
996 -
997 - /**
998 - * Crée le widget
999 - * @param $args
1000 - * @param $instance
1001 - */
1002 - function widget($args, $instance){
1003 - if(isset($instance['idhal']) && !empty($instance['idhal'])) {
1004 - $content = '';
1005 - extract($args);
1006 - /**
1007 - * @var $before_widget : defined by extract
1008 - * @var $before_title : defined by extract
1009 - * @var $after_title : defined by extract
1010 - * @var $after_widget : defined by extract
1011 - */
1012 - if (!wphal_is_curl_installed()) {
1013 - $content = 'Please check the <a href="https://wordpress.org/plugins/hal/faq/" target="_blank" id="FAQ">FAQ</a> with the code : CURL';
1014 -
1015 - } else {
1016 - $instance['idhal'] = wphal_verifSolr($instance['idhal']);
1017 -
1018 - $url = wphal_api . '?q=*:*&fq=' . $instance['select'] . ':' . urlencode($instance['idhal']) . '&fl=uri_s,' . $instance['typetext'] . '&sort=' . wphal_producedDateY . '&rows=' . $instance['nbdoc'] . '&wt=json';
1019 - $json = wphal_do_get_data($url);
1020 -
1021 - $count_results = count($json->response->docs);
1022 - if ($count_results > 0) {
1023 - $content = '<ul class="widhal-ul">';
1024 - for ($i = 0; $i < $count_results - 1; $i++) {
1025 - if ($instance['typetext'] == 'citationRef_s') {
1026 - $typetext = $json->response->docs[$i]->citationRef_s;
1027 - } else {
1028 - $typetext = $json->response->docs[$i]->title_s[0];
1029 - }
1030 - $content .= '<li class="widhal-li"><a href="' . esc_url($json->response->docs[$i]->uri_s) . '" target="_blank">' . $typetext . '</a></li>';
1031 - }
1032 - $content .= '</ul>';
1033 - } else {
1034 - $content = '<div> no results !</div>';
1035 - }
1036 - }
1037 - // tags other that those will be stripped
1038 - $allowed_html_tags = array(
1039 - 'div' => array(
1040 - 'class' => array(),
1041 - 'id' => array(),
1042 - ),
1043 - 'h2' => array(),
1044 - 'section' => array(),
1045 - 'a' => array(
1046 - 'href' => array(),
1047 - 'target' => array(),
1048 - 'title' => array(),
1049 - 'id' => array(),
1050 - 'class' => array(),
1051 - ),
1052 - 'ul' => array(
1053 - 'class' => array(),
1054 - 'id' => array(),
1055 - ),
1056 - 'li' => array(
1057 - 'class' => array(),
1058 - 'id' => array(),
1059 - )
1060 - );
1061 - $widget_block = $before_widget;
1062 - $widget_block .= $before_title . $instance['titre'] . $after_title;
1063 - $widget_block .= $content;
1064 - $widget_block .= $after_widget;
1065 - echo wp_kses($widget_block, $allowed_html_tags);
1066 - }
1067 - }
1068 -
1069 - /**
1070 - * Sauvegarde des données
1071 - * @param $new
1072 - * @param $old
1073 - */
1074 - function update($new, $old){
1075 - //the id must be provided
1076 - if(isset($new['idhal']) && !empty($new['idhal'])) {
1077 - $new['idhal'] = wphal_sanitize_username($new['idhal']);
1078 - $new['nbdoc'] = wphal_sanitize_id($new['nbdoc']);
1079 - return $new;
1080 - }else
1081 - return false;
1082 - }
1083 -
1084 - /**
1085 - * Formulaire du widget
1086 - * @param $instance
1087 - */
1088 - function form($instance){
1089 -
1090 - $defaut = array(
1091 - 'titre' => __("Publications Hal", 'wp-hal'),
1092 - 'select' => "authIdHal_s",
1093 - 'typetext' => "title_s",
1094 - 'idhal' => "",
1095 - 'nbdoc' => 5
1096 - );
1097 - $instance = wp_parse_args($instance,$defaut);
1098 - ?>
1099 - <p>
1100 - <label for="<?php echo esc_attr($this->get_field_id("titre"));?>"><?php echo esc_html(__('Titre','wp-hal')) .' :'?></label>
1101 - <input value="<?php echo esc_js($instance['titre']);?>" name="<?php echo esc_attr($this->get_field_name("titre"));?>" id="<?php echo esc_attr($this->get_field_id("titre"));?>" class="widefat" type="text"/>
1102 - </p>
1103 - <p>
1104 - <label for="<?php echo esc_attr($this->get_field_id("nbdoc"));?>"><?php echo esc_html(__("Nombre de documents affichés",'wp-hal')) .' :'?></label>
1105 - <input class="tiny-text" id="<?php echo esc_attr($this->get_field_id("nbdoc"));?>" name="<?php echo esc_attr($this->get_field_name("nbdoc"));?>" type="number" step="1" min="1" max="10" value="<?php echo esc_js($instance['nbdoc']);?>" size="3">
1106 - </p>
1107 - <p>
1108 - <label for="<?php echo esc_attr($this->get_field_id("typetext"));?>"><?php echo esc_html(__("Type d'affichage",'wp-hal')) .' :'?></label>
1109 - <select id="<?php echo esc_attr($this->get_field_id("typetext"));?>" name="<?php echo esc_attr($this->get_field_name("typetext"));?>">
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>
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>
1112 - </select>
1113 - </p>
1114 - <p>
1115 - <label for="<?php echo esc_attr($this->get_field_id("select"));?>"><?php echo esc_html(__("Type d'Id",'wp-hal') .' :')?></label>
1116 - <select id="<?php echo esc_attr($this->get_field_id("select"));?>" name="<?php echo esc_attr($this->get_field_name("select"));?>">
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>
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>
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>
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>
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>
1124 - </select>
1125 - </p>
1126 - <p>
1127 - <label for="<?php echo esc_attr($this->get_field_id("idhal"));?>"><?php echo esc_html(__("Id",'wp-hal')) .' :'?></label>
1128 - <input value="<?php echo esc_js($instance['idhal']);?>" name="<?php echo esc_attr($this->get_field_name("idhal"));?>" id="<?php echo esc_attr($this->get_field_id("idhal"));?>" type="text"/>
1129 - </p>
1130 - <?php
1131 - }
1132 -}
1133 -
1134 -
1135 -function wphal_sanitize_id( $input ){
1136 - if(is_numeric($input)){
1137 - return $input;
1138 - }
1139 -}
1140 -
1141 -function wphal_sanitize_username($input)
1142 -{
1143 - $allowed = array(".", "-", "_"); // you can add here more value, you want to allow.
1144 - if(ctype_alnum(str_replace($allowed, '', $input ))) {
1145 - return $input;
1146 - }
1147 -}
1148 -
1149 -function wphal_sanitize_phone( $input ){
1150 - $phone_num = $input;
1151 - $phone_num = preg_replace('/[^0-9]/', '', $phone_num);
1152 - if(strlen($phone_num) === 10) {
1153 - //Phone is 10 characters in length
1154 - return $input;
1155 - }
1156 -}
1157 -
1158 -
1159 -function wphal_register_settings() {
1160 - register_setting( 'wphal_option', 'option_choix' );
1161 - register_setting( 'wphal_option', 'option_type' );
1162 - register_setting( 'wphal_option', 'option_groupe' );
1163 - register_setting( 'wphal_option', 'option_idhal' , array(
1164 - 'type' => 'string',
1165 - 'sanitize_callback' => 'wphal_sanitize_username',
1166 - 'default' => NULL,
1167 - ));
1168 - register_setting( 'wphal_option', 'option_lang' );
1169 - register_setting( 'wphal_option', 'option_infocontact' );
1170 - register_setting( 'wphal_option', 'option_email' , array(
1171 - 'type' => 'string',
1172 - 'sanitize_callback' => 'sanitize_email',
1173 - 'default' => NULL,
1174 - ));
1175 - register_setting( 'wphal_option', 'option_tel' , array(
1176 - 'type' => 'string',
1177 - 'sanitize_callback' => 'wphal_sanitize_phone',
1178 - 'default' => NULL,
1179 - ));
1180 - register_setting( 'wphal_option', 'option_social0' , array(
1181 - 'type' => 'string',
1182 - 'sanitize_callback' => 'wphal_sanitize_username',
1183 - 'default' => NULL,
1184 - ));
1185 - register_setting( 'wphal_option', 'option_social1' , array(
1186 - 'type' => 'string',
1187 - 'sanitize_callback' => 'wphal_sanitize_username',
1188 - 'default' => NULL,
1189 - ));
1190 - register_setting( 'wphal_option', 'option_social2' , array(
1191 - 'type' => 'string',
1192 - 'sanitize_callback' => 'wphal_sanitize_username',
1193 - 'default' => NULL,
1194 - ));
1195 - register_setting( 'wphal_option', 'option_social3' , array(
1196 - 'type' => 'string',
1197 - 'sanitize_callback' => 'wphal_sanitize_username',
1198 - 'default' => NULL,
1199 - ));
1200 - register_setting( 'wphal_option', 'option_cache_timeout' , array(
1201 - 'type' => 'string',
1202 - 'sanitize_callback' => 'wphal_sanitize_id',
1203 - 'default' => NULL,
1204 - ));
1205 - register_setting( 'wphal_option', 'option_erase_cache' );
1206 -}
1207 -
1208 -/**
1209 - * Crée le menu d'option du plugin
1210 - */
1211 -function wphal_option() {
1212 -
1213 - if (get_option('option_type')==''){
1214 - update_option('option_type', 'authIdHal_s');
1215 - }
1216 - if (get_option('option_groupe')==''){
1217 - update_option('option_groupe', 'paginer');
1218 - }
1219 - ?>
1220 - <div class="wrap">
1221 - <h2><?php echo esc_html(__('Plugin HAL','wp-hal'));?></h2>
1222 - <form method="post" enctype="multipart/form-data" action="options.php">
1223 - <div id="poststuff">
1224 - <div id="post-body" class="metabox-holder columns-2">
1225 - <div id="post-body-content">
1226 - <?php settings_fields( 'wphal_option' ); ?>
1227 - <?php do_settings_sections( 'wphal_option' ); ?>
1228 - <table class="form-table">
1229 - <tr style="vertical-align:top;">
1230 - <th scope="row" style="font-size: 18px;"><?php echo esc_html(__('Paramètre de la page :','wp-hal'));?></th>
1231 - </tr>
1232 - <tr style="vertical-align:top;">
1233 - <th scope="row"><label for="option_type"><?php echo esc_html(__('Type d\'Id','wp-hal'));?></label></th>
1234 - <td><select name="option_type">
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>
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>
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>
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>
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>
1242 - </select>
1243 - <input type="text" name="option_idhal" id="option_idhal" value="<?php echo esc_js(get_option('option_idhal')); ?>"/>
1244 - </td>
1245 - </tr>
1246 - <tr style="vertical-align:top;">
1247 - <th scope="row"><?php echo esc_html(__('Affichage des documents','wp-hal'));?></th>
1248 - <td><input type="radio" name="option_groupe" id="paginer" value="paginer" <?php echo esc_attr((get_option('option_groupe') == "paginer")?'checked':''); ?>><label for="paginer"><?php echo esc_html(__('Documents avec pagination','wp-hal'));?></label><br>
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>
1250 - </td>
1251 - </tr>
1252 - <tr style="vertical-align:top;">
1253 - <th scope="row"><?php echo esc_html(__('Choix des éléments menu','wp-hal'));?></th>
1254 - <?php $option_choix = get_option('option_choix'); ?>
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/>
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/>
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/>
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/>
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>
1265 - </td>
1266 - </tr>
1267 - <tr style="vertical-align:top;">
1268 - <th scope="row" style="font-size: 18px;"><?php echo esc_html(__('Contact :','wp-hal'));?></th>
1269 - </tr>
1270 - <tr>
1271 - <th scope="row"><?php echo esc_html(__("Afficher les informations d'un chercheur ayant un IdHal ?",'wp-hal'));?></th>
1272 - <td><input type="radio" name="option_infocontact" id="wphal-yes" value="yes" <?php echo esc_attr((get_option('option_infocontact') == "yes")?'checked':''); ?>><label for="wphal-yes"><?php echo esc_html(__("Oui",'wp-hal'))?></label><br>
1273 - <input type="radio" name="option_infocontact" id="wphal-no" value="no" <?php echo esc_attr((get_option('option_infocontact') == "no")?'checked':''); ?>><label for="wphal-no"><?php echo esc_html(__("Non",'wp-hal'))?></label><br>
1274 - </td>
1275 - </tr>
1276 - <tr>
1277 - <th scope="row"><label for="option_cache_timeout"><?php echo esc_html(__('Expiration cache (minutes)','wp-hal'));?></label></th>
1278 - <td><input type="number" min="1440" style="width:300px;" placeholder="Default(1 day) : 1440" name="option_cache_timeout" id="option_cache_timeout" value="<?php echo esc_js(get_option('option_cache_timeout')); ?>"/><img alt="cache" src="<?php echo esc_url(plugin_dir_url( __FILE__ ).'img/clock.svg'); ?>" style="vertical-align:middle; width:32px; margin-left:2px; margin-right:2px;"/></td>
1279 - </tr>
1280 - <tr>
1281 - <th scope="row"><label for="option_erase_cache"><?php echo esc_html(__('Reinitialiser le cache','wp-hal'));?></label></th>
1282 - <td><input type="checkbox" name="option_erase_cache" id="option_erase_cache" value="1"/><img alt="option_erase_cache" src="<?php echo esc_url(plugin_dir_url( __FILE__ )."img/groom.svg"); ?>" style="vertical-align:middle; width:32px; margin-left:2px; margin-right:2px;"/></td>
1283 - </tr>
1284 - <tr>
1285 - <th scope="row"><label for="option_email"><?php echo esc_html(__('Email','wp-hal'));?></label></th>
1286 - <td><input type="text" style="width:300px;" placeholder="Exemple : hi@mail.com" name="option_email" id="option_email" value="<?php echo esc_js(get_option('option_email')); ?>"/><img alt="email" src="<?php echo esc_url(plugin_dir_url( __FILE__ )."img/mail.svg"); ?>" style="vertical-align:middle; width:32px; margin-left:2px; margin-right:2px;"/></td>
1287 - </tr>
1288 - <tr>
1289 - <th scope="row"><label for="option_tel"><?php echo esc_html(__('Téléphone','wp-hal'));?></label></th>
1290 - <td><input type="text" style="width:300px;" placeholder="Exemple : 06-01-02-03-04" name="option_tel" id="option_tel" value="<?php echo esc_js(get_option('option_tel'));?>"/><img alt="phone" src="<?php echo esc_url(plugin_dir_url( __FILE__ )."img/phone.svg"); ?>" style="vertical-align:middle; width:32px; margin-left:2px; margin-right:2px;"/></td>
1291 - </tr>
1292 - <tr>
1293 - <th><label for="option_social0">Facebook (http://www.facebook.com/)</label></th>
1294 - <td><input type="text" style="width:300px;" placeholder="Exemple : fa.book" name="option_social0" id="option_social0" value="<?php echo esc_js(get_option('option_social0')); ?>"/><img alt="facebook" src="<?php echo esc_url(plugin_dir_url( __FILE__ )."img/facebook.svg"); ?>" style="vertical-align:middle; width:32px; margin-left:2px; margin-right:2px;"/></td>
1295 - </tr>
1296 - <tr>
1297 - <th><label for="option_social1">Twitter (http://www.twitter.com/)</label></th>
1298 - <td><input type="text" style="width:300px;" placeholder="Exemple : tweet_heure" name="option_social1" id="option_social1" value="<?php echo esc_js(get_option('option_social1')); ?>"/><img alt="twitter" src="<?php echo esc_url(plugin_dir_url( __FILE__ )."img/twitter.svg"); ?>" style="vertical-align:middle; width:32px; margin-left:2px; margin-right:2px;"/></td>
1299 - </tr>
1300 - <tr>
1301 - <th><label for="option_social2">Google + (https://plus.google.com/u/0/+)</label></th>
1302 - <td><input type="text" style="width:300px;" placeholder="Exemple : goo.plus" name="option_social2" id="option_social2" value="<?php echo esc_js(get_option('option_social2')); ?>"/><img alt="google" src="<?php echo esc_url(plugin_dir_url( __FILE__ )."img/google-plus.svg"); ?>" style="vertical-align:middle; width:32px; margin-left:2px; margin-right:2px;"/></td>
1303 - </tr>
1304 - <tr>
1305 - <th><label for="option_social3">LinkedIn (https://www.linkedin.com/in/)</label></th>
1306 - <td><input type="text" style="width:300px;" placeholder="Exemple : link.dine" name="option_social3" id="option_social3" value="<?php echo esc_js(get_option('option_social3')); ?>"/><img alt="linkedin" src="<?php echo esc_url(plugin_dir_url( __FILE__ )."img/linkedin.svg"); ?>" style="vertical-align:middle; width:32px; margin-left:2px; margin-right:2px;"/></td>
1307 - </tr>
1308 - </table>
1309 - <?php
1310 - submit_button(__('Enregistrer','wp-hal'), 'primary large', 'submit', true); ?>
1311 - </div>
1312 - <div id="postbox-container-1" class="postbox-container">
1313 -
1314 - </div>
1315 - </div>
1316 - <br class="clear"><br/>
1317 - </div>
1318 - </form>
1319 -
1320 - </div>
1321 -
1322 -<?php
1323 -}
1324 -
1325 -
1326 -/**
1327 - * Reset les données Hal
1328 - */
1329 -function wphal_reset_option() {
1330 - delete_option('option_choix');
1331 - delete_option('option_type');
1332 - delete_option('option_groupe');
1333 - delete_option('option_idhal');
1334 - delete_option('option_lang');
1335 - delete_option('option_infocontact');
1336 - delete_option('option_email');
1337 - delete_option('option_tel');
1338 - delete_option('option_social0');
1339 - delete_option('option_social1');
1340 - delete_option('option_social2');
1341 - delete_option('option_social3');
1342 - delete_option('option_cache_timeout');
1343 - delete_option('option_erase_cache');
1344 -}
1345 -
1346 -?>
1 +<?php
2 +/**
3 + * Plugin Name: HAL
4 + * Plugin URI: http://www.ccsd.cnrs.fr
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.0.7
7 + * Author: Baptiste Blondelle
8 + * Author URI: http://www.ccsd.cnrs.fr
9 + * Text Domain: wp-hal
10 + * Domain Path: /lang/
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 +
17 +//Récupère les constantes
18 +require_once("constantes.php");
19 +
20 +
21 +if (locale == 'fr_FR') {
22 + define('lang', 'fr');
23 +} elseif (locale == 'es_ES') {
24 + define('lang', 'es');
25 +} else {
26 + define('lang', 'en');
27 +}
28 +
29 +// Création du shortcode ('nom du shortcode', 'fonction appelée')
30 +add_shortcode( 'cv-hal', 'cv_hal' );
31 +add_shortcode( 'nb-doc', 'nb_doc' );
32 +
33 +
34 +function charger_languages() {
35 + load_plugin_textdomain('wp-hal', false, dirname(plugin_basename(__FILE__)) . '/lang/');
36 +}
37 +
38 +add_action('plugins_loaded', 'charger_languages');
39 +
40 +function hal_plugin_action_links( $links, $file ) {
41 + if ( $file != plugin_basename( __FILE__ ))
42 + return $links;
43 +
44 + $settings_link = '<a href="admin.php?page=wp-hal.php">' . __( 'Paramètres', 'wp-hal' ) . '</a>';
45 +
46 + array_unshift( $links, $settings_link );
47 +
48 + return $links;
49 +}
50 +
51 +
52 +add_filter( 'plugin_action_links', 'hal_plugin_action_links',10,2);
53 +
54 +
55 +/***********************************************************************************************************************
56 + * PLUGIN SHORTCODE ND-DOC
57 + **********************************************************************************************************************/
58 +function nb_doc($param)
59 +{
60 + $idhal = verifSolr(get_option('option_idhal'));
61 + extract(shortcode_atts(array(
62 + 'type' => get_option('option_type'),
63 + 'id' => $idhal
64 + ),
65 + $param
66 + ));
67 + $id = verifSolr($id);
68 +
69 + $url = api . '?q=*:*&fq=' . $type . ':(' . urlencode($id) . ')&rows=0&wt=json';
70 + $ch = curl_init($url);
71 + // Options
72 + $options = array(
73 + CURLOPT_RETURNTRANSFER => true,
74 + CURLOPT_HTTPHEADER => array('Content-type: application/json'),
75 + CURLOPT_TIMEOUT => 10,
76 + CURLOPT_USERAGENT => "HAL Plugin Wordpress " . version
77 + );
78 +
79 + // Bind des options et de l'objet cURL que l'on va utiliser
80 + curl_setopt_array($ch, $options);
81 + // Récupération du résultat JSON
82 + $json = json_decode(curl_exec($ch));
83 + curl_close($ch);
84 +
85 + return $json->response->numFound;
86 +}
87 +/***********************************************************************************************************************
88 + * PLUGIN SHORTCODE CV-HAL
89 + **********************************************************************************************************************/
90 +function cv_hal($param){
91 + if ( !function_exists('curl_init' ) ) {
92 + echo 'Please check the';?> <a href="https://wordpress.org/plugins/hal/faq/" target="_blank" id="curl">FAQ</a><?php echo ' with the code : CURL';
93 + } else {
94 +
95 + if(in_array('disciplines', get_option('option_choix'))){ //Lance les scripts pour le Graphique
96 + wp_enqueue_style('wp-hal-style2');
97 +
98 + wp_enqueue_script('wp-hal-script1');
99 + wp_enqueue_script('wp-hal-script2');
100 + wp_enqueue_script('wp-hal-script3');
101 + }
102 +
103 + if (get_option('option_idhal') != '') {
104 + $idhal = verifSolr(get_option('option_idhal'));
105 + extract(shortcode_atts(array(
106 + 'type' => get_option('option_type'),
107 + 'id' => $idhal,
108 + 'contact' => get_option('option_infocontact')
109 + ),
110 + $param
111 + ));
112 + $id = verifSolr($id);
113 +
114 + if (get_option('option_groupe') == 'grouper') {
115 + //cURL sur l'API pour récupérer les données
116 + $url = api . '?q=*:*&fq=' . $type . ':(' . urlencode($id) . ')&group=true&group.field=docType_s&group.limit=1000&fl=docid,citationFull_s&facet.field=' . 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=' . producedDateY . '&wt=json&json.nl=arrarr';
117 + } elseif (get_option('option_groupe') == 'paginer') {
118 + $url = api . '?q=*:*&fq=' . $type . ':(' . urlencode($id) . ')&fl=docid,citationFull_s&facet.field=' . 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=' . producedDateY . '&wt=json&json.nl=arrarr';
119 + }
120 +
121 + $ch = curl_init($url);
122 + // Options
123 + $options = array(
124 + CURLOPT_RETURNTRANSFER => true,
125 + CURLOPT_HTTPHEADER => array('Content-type: application/json'),
126 + CURLOPT_TIMEOUT => 10,
127 + CURLOPT_USERAGENT => "HAL Plugin Wordpress " . version
128 + );
129 +
130 + // Bind des options et de l'objet cURL que l'on va utiliser
131 + curl_setopt_array($ch, $options);
132 + // Récupération du résultat JSON
133 + $json = json_decode(curl_exec($ch));
134 + curl_close($ch);
135 +
136 + $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
137 +
138 + $content = '<div id="wphal-content">
139 + <ul id="wphal-menu">';
140 + $content .= '<li><a href="#publications" onclick="displayElem(\'publications\'); return false;" style="font-size:18px; text-decoration: none;">' . __('Publications', 'wp-hal') . '</a></li>';
141 + if (is_array(get_option('option_choix'))) {
142 + $content .= '<li><a href="#filtres" onclick="return false;" style="font-size:18px; text-decoration: none; cursor:default;">' . __('Filtres', 'wp-hal') . '</a>';
143 + $content .= '<ul id="wphal-filtres">';
144 + foreach (get_option('option_choix') as $option) {
145 + if ($option == 'contact') {
146 + $content .= '<li><a href="#contact" onclick="displayElem(\'wphal-contact\'); return false;" style="margin:1px; text-decoration: none;">' . __('Contact', 'wp-hal');
147 + $content .= '</a></li>';
148 + }
149 + if ($option == 'disciplines') {
150 + $content .= '<li><a href="#disciplines" onclick="displayElem(\'wphal-disciplines\'); return false;" style="margin:1px; text-decoration: none;">' . __('Disciplines', 'wp-hal');
151 + $content .= '</a></li>';
152 + }
153 + if ($option == 'mots-clefs') {
154 + $content .= '<li><a href="#keywords" onclick="displayElem(\'wphal-keywords\'); return false;" style="margin:1px; text-decoration: none;">' . __('Mots-clefs', 'wp-hal');
155 + $content .= '</a></li>';
156 + }
157 + if ($option == 'auteurs') {
158 + $content .= '<li><a href="#auteurs" onclick="displayElem(\'wphal-auteurs\'); return false;" style="margin:1px; text-decoration: none;">' . __('Auteurs', 'wp-hal');
159 + $content .= '</a></li>';
160 + }
161 + if ($option == 'revues') {
162 + $content .= '<li><a href="#revues" onclick="displayElem(\'wphal-revues\'); return false;" style="margin:1px; text-decoration: none;">' . __('Revues', 'wp-hal');
163 + $content .= '</a></li>';
164 + }
165 + if ($option == 'annee') {
166 + $content .= '<li><a href="#annees" onclick="displayElem(\'wphal-annees\'); return false;" style="margin:1px; text-decoration: none;">' . __('Année de production', 'wp-hal');
167 + $content .= '</a></li>';
168 + }
169 + if ($option == 'institution') {
170 + $content .= '<li><a href="#insts" onclick="displayElem(\'wphal-insts\'); return false;" style="margin:1px; text-decoration: none;">' . __('Institutions', 'wp-hal');
171 + $content .= '</a></li>';
172 + }
173 + if ($option == 'laboratoire') {
174 + $content .= '<li><a href="#labs" onclick="displayElem(\'wphal-labs\'); return false;" style="margin:1px; text-decoration: none;">' . __('Laboratoires', 'wp-hal');
175 + $content .= '</a></li>';
176 + }
177 + if ($option == 'departement') {
178 + $content .= '<li><a href="#depts" onclick="displayElem(\'wphal-depts\'); return false;" style="margin:1px; text-decoration: none;">' . __('Départements', 'wp-hal');
179 + $content .= '</a></li>';
180 + }
181 + if ($option == 'equipe') {
182 + $content .= '<li><a href="#equipes" onclick="displayElem(\'wphal-equipes\'); return false;" style="margin:1px; text-decoration: none;">' . __('Équipes de recherche', 'wp-hal');
183 + $content .= '</a></li>';
184 + }
185 + }
186 + $content .= '</ul></li>';
187 + }
188 + $content .= '</ul><br/><hr>';
189 +
190 + $content .= '<div id="meta">
191 + <div class="display" id="wphal-contact" style="display: none;">
192 + <h3 class="wphal-titre">' . __('Contact', 'wp-hal');
193 + $content .= '</h3>
194 +
195 + <ul id="wphal-cont" style="list-style-type: none;">';
196 +
197 + if ($contact == 'yes' && $type == 'authIdHal_s') {
198 + $urlauthor = 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);
199 + $ch = curl_init($urlauthor);
200 + // Options
201 + $options = array(
202 + CURLOPT_RETURNTRANSFER => true,
203 + CURLOPT_HTTPHEADER => array('Content-type: application/json'),
204 + CURLOPT_TIMEOUT => 10,
205 + CURLOPT_USERAGENT => "HAL Plugin Wordpress " . version
206 + );
207 +
208 + // Bind des options et de l'objet cURL que l'on va utiliser
209 + curl_setopt_array($ch, $options);
210 + // Récupération du résultat JSON
211 + $jsonauthor = json_decode(curl_exec($ch));
212 + curl_close($ch);
213 +
214 + for ($i = 0; $jsonauthor->response->docs[$i] != ''; $i++) {
215 + $content .= '<div class="wphal-infocontact" id="wphal-infocontact'.$i.'">';
216 + if ($jsonauthor->response->docs[$i]->fullName_s != '') {
217 + $content .= '<li class="wphal-fullname"><span>Nom : </span><span>'. $jsonauthor->response->docs[$i]->fullName_s .'</span></li>';
218 + }
219 + if ($jsonauthor->response->docs[$i]->email_s != '') {
220 + $content .= '<li class="wphal-email"><span>Email : </span><span><a href="mailto:'. $jsonauthor->response->docs[$i]->email_s .'">' . $jsonauthor->response->docs[$i]->email_s . '</a></span></li>';
221 + }
222 + if ($jsonauthor->response->docs[$i]->idHal_s != '') {
223 + $content .= '<li class="wphal-idhal"><span>IdHAL : </span><span>' . $jsonauthor->response->docs[$i]->idHal_s . '</span></li>';
224 + }
225 + if ($jsonauthor->response->docs[$i]->hasCV_bool == true){
226 + $content .= '<li class="wphal-cvhal"><span>CV HAL : </span><a href="'.cvhal. $jsonauthor->response->docs[$i]->idHal_s.'" target="_blank">CV de '.$jsonauthor->response->docs[$i]->fullName_s.'</a></li>';
227 + }
228 + if ($jsonauthor->response->docs[$i]->arxiv_s != '') {
229 + $content .= '<li class="wphal-"><span>arXiv : </span><span><a href="' . $jsonauthor->response->docs[$i]->arxiv_s . '" target="_blank">' . substr(strrchr($jsonauthor->response->docs[$i]->arxiv_s, "/"), 1) . '</a></span></li>';
230 + }
231 + if ($jsonauthor->response->docs[$i]->idref_s != '') {
232 + $content .= '<li class="wphal-"><span>IdRef : </span><span><a href="' . $jsonauthor->response->docs[$i]->idref_s . '" target="_blank">' . substr(strrchr($jsonauthor->response->docs[$i]->idref_s, "/"), 1) . '</a></span></li>';
233 + }
234 + if ($jsonauthor->response->docs[$i]->orcid_s != '') {
235 + $content .= '<li class="wphal-"><span>ORCID : </span><span><a href="' . $jsonauthor->response->docs[$i]->orcid_s . '" target="_blank">' . substr(strrchr($jsonauthor->response->docs[$i]->orcid_s, "/"), 1) . '</a></span></li>';
236 + }
237 + if ($jsonauthor->response->docs[$i]->viaf_s != '') {
238 + $content .= '<li class="wphal-"><span>VIAF : </span><span><a href="' . $jsonauthor->response->docs[$i]->viaf_s . '" target="_blank">' . substr(strrchr($jsonauthor->response->docs[$i]->viaf_s, "/"), 1) . '</a></span></li>';
239 + }
240 + if ($jsonauthor->response->docs[$i]->isni_s != '') {
241 + $content .= '<li class="wphal-"><span>ISNI : </span><span><a href="' . $jsonauthor->response->docs[$i]->isni_s . '" target="_blank">' . substr(strrchr($jsonauthor->response->docs[$i]->isni_s, "/"), 1) . '</a></span></li>';
242 + }
243 + $content .= '</div>';
244 + }
245 + }
246 + if (get_option('option_email') != '') {
247 + $content .= '<li><img alt="mail" src=" ' . plugin_dir_url(__FILE__) . 'img/mail.svg" style=" width:16px; margin-left:2px; margin-right:2px;"/><a href="mailto:' . get_option('option_email') . '" target="_blank">' . get_option('option_email') . '</a></li>';
248 + }
249 + if (get_option('option_tel') != '') {
250 + $content .= '<li><img alt="phone" src=" ' . plugin_dir_url(__FILE__) . 'img/phone.svg" style="width:16px; margin-left:2px; margin-right:2px;"/>' . get_option('option_tel') . '</li>';
251 + }
252 + if (get_option('option_social0') != '') {
253 + $content .= '<li><a href="http://www.facebook.com/' . get_option('option_social0') . '" target="_blank"><img src=" ' . plugin_dir_url(__FILE__) . 'img/facebook.svg" style="width:32px; margin:4px;"/></a></li>';
254 + }
255 + if (get_option('option_social1') != '') {
256 + $content .= '<li><a href="http://www.twitter.com/' . get_option('option_social1') . '" target="_blank"><img src=" ' . plugin_dir_url(__FILE__) . 'img/twitter.svg" style="width:32px; margin:4px;"/></a></li>';
257 + }
258 + if (get_option('option_social2') != '') {
259 + $content .= '<li><a href="https://plus.google.com/u/0/+' . get_option('option_social2') . '" target="_blank"><img src=" ' . plugin_dir_url(__FILE__) . 'img/google-plus.svg" style="width:32px; margin:4px;"/></a></li>';
260 + }
261 + if (get_option('option_social3') != '') {
262 + $content .= '<li><a href="https://www.linkedin.com/in/' . get_option('option_social3') . '" target="_blank"><img src=" ' . plugin_dir_url(__FILE__) . 'img/linkedin.svg" style="width:32px; margin:4px;"/></a></li>';
263 + }
264 + $content .= '</ul>
265 + </div>
266 + <div class="display" id="wphal-disciplines" style="display: none;">
267 + <h3 class="wphal-titre">' . __('Disciplines', 'wp-hal') . '</h3>';
268 +
269 + if (locale == 'fr_FR') {
270 + $facetdomain = $json->facet_counts->facet_fields->fr_domainAllCodeLabel_fs;
271 + } elseif (locale == 'es_ES') {
272 + $facetdomain = $json->facet_counts->facet_fields->es_domainAllCodeLabel_fs;
273 + } else {
274 + $facetdomain = $json->facet_counts->facet_fields->en_domainAllCodeLabel_fs;
275 + }
276 +
277 + if (!is_null($facetdomain) && !empty($facetdomain)) {
278 + $content .= '<div id="listdisci">';
279 + $content .= '<span id="tridisciplines">';
280 + $content .= '<button type="button" class="trial" href="" id="tridisci" onclick="toggleSort(this, true, \'wphal-discipline\', \'wphal-discipline\', \'tridisci\'); return false;" style="font-size:16px; text-decoration: none;" >Tri Alphabétique</button>';
281 + $content .= '<button type="button" class="trioc" href="" id="trinbdisci" onclick="toggleSort(this, false, \'wphal-discipline\', \'wphal-discipline\', \'trinbdisci\'); return false;" style="font-size:16px; text-decoration: none;">Tri Occurrence</button>';
282 + $content .= '</span>';
283 + $content .= '<ul id="wphal-discipline" class="wphal-discipline">';
284 + foreach ($facetdomain as $res) {
285 + $name = explode(delimiter, $res[0]);
286 + $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . halv3 . '?q=domainAllCode_s:' . urlencode($name[0]) . "+AND+" . $type . ':(' . $id . ')" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
287 + }
288 + $content .= '</ul>';
289 + $content .= '</div>';
290 +
291 + $content .= '<div id="wphal-graph" style="display:none;">';
292 + $content .= '<div id="wphal-piedisci"></div>';
293 + $content .= '</div>';
294 + $content .= '<button type="button" href="" style="text-decoration: none;" id="wphal-disci" onclick="visibilitedisci(\'listdisci\',\'wphal-graph\',\'tridisciplines\'); return false;" >' . __('Graphique', 'wp-hal');
295 + $content .= '</button>';
296 + }
297 + $content .= '</div>
298 + <div class="display" id="wphal-keywords" style="display: none;">
299 + <h3 class="wphal-titre">' . __('Mots-clefs', 'wp-hal') . '</h3>';
300 + if (!is_null($json->facet_counts->facet_fields->keyword_s) && !empty($json->facet_counts->facet_fields->keyword_s)) {
301 + $content .= '<div id="wphal-keys">';
302 + $r = 0;
303 + // CSS Nuage de mots
304 + $maxsize = 25;
305 + $minsize = 10;
306 + $maxval = max(array_values($json->facet_counts->facet_fields->keyword_s[1]));
307 + $minval = min(array_values($json->facet_counts->facet_fields->keyword_s[1]));
308 + $spread = ($maxval - $minval);
309 + $step = ($maxsize - $minsize) / $spread;
310 + $tab = array();
311 + foreach ($json->facet_counts->facet_fields->keyword_s as $res) {
312 + $r = $r + 1;
313 + if ($r > 20) {
314 + break;
315 + }
316 + $tab[] = $res;
317 + }
318 + asort($tab); // Tri du tableau par ordre alphabétique
319 + foreach ($tab as $res) {
320 + $size = round($minsize + (($res[1] - $minval) * $step));
321 + $content .= '<a style="display: inline-block; font-size:' . $size . 'px" href="' . halv3 . '?q=keyword_s:' . urlencode('"' . $res[0] . '"') . "+AND+" . $type . ':(' . $id . ')" target="_blank">' . $res[0] . '</a>&nbsp;';
322 + }
323 + $content .= '</div>';
324 + $content .= '<div id="keysuite" style="display:none;">';
325 + $content .= '<span id="trikeywords">';
326 + $content .= '<button type="button" class="trial" href="" id="trikey" onclick="toggleSort(this, true, \'wphal-keyw\', \'wphal-keyword\', \'trikey\'); return false;" style="font-size:16px; text-decoration: none;" >Tri Alphabétique</button>';
327 + $content .= '<button type="button" class="trioc" href="" id="trinbkey" onclick="toggleSort(this, false, \'wphal-keyw\', \'wphal-keyword\', \'trinbkey\'); return false;" style="font-size:16px; text-decoration: none;">Tri Occurrence</button>';
328 + $content .= '</span>';
329 + $content .= '<ul class="wphal-keyword">';
330 + $content .= '<div id="wphal-keyw">';
331 + foreach ($json->facet_counts->facet_fields->keyword_s as $res) {
332 + $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . halv3 . '?q=keyword_s:' . urlencode('"' . $res[0] . '"') . "+AND+" . $type . ':(' . $id . ')" target="_blank">' . $res[0] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
333 + }
334 + $content .= '</div>';
335 + $content .= '</ul>';
336 + $content .= '</div>';
337 + $content .= '<button type="button" href="" style="text-decoration: none;" id="wphal-key" onclick="visibilitekey(\'wphal-keys\',\'keysuite\', \'trikeywords\'); return false;" >' . __('Liste complète', 'wp-hal');
338 + $content .= '</button>';
339 + }
340 + $content .= '</div>
341 + <div class="display" id="wphal-auteurs" style="display: none;">
342 + <h3 class="wphal-titre">' . __('Auteurs', 'wp-hal') . '</h3>';
343 + if (!is_null($json->facet_counts->facet_fields->authIdLastNameFirstName_fs) && !empty($json->facet_counts->facet_fields->authIdLastNameFirstName_fs)) {
344 + $content .= '<span id="triauteurs">';
345 + $content .= '<button type="button" class="trial" href="" id="triaut" onclick="toggleSort(this, true, \'wphal-aut\', \'auteursuite\', \'triaut\'); return false;" style="font-size:16px; text-decoration: none;" >Tri Alphabétique</button>';
346 + $content .= '<button type="button" class="trioc" href="" id="trinbaut" onclick="toggleSort(this, false, \'wphal-aut\', \'auteursuite\', \'trinbaut\'); return false;" style="font-size:16px; text-decoration: none;">Tri Occurrence</button>';
347 + $content .= '</span>';
348 + $content .= '<ul class="wphal-auteurs" style="list-style-type: none;">';
349 + $content .= '<div id="wphal-aut">';
350 + $r = 0;
351 + foreach ($json->facet_counts->facet_fields->authIdLastNameFirstName_fs as $res) {
352 + $r = $r + 1;
353 + if ($r > 10) {
354 + break;
355 + }
356 + $name = explode(delimiter, $res[0]);
357 + $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><img alt="user" src=" ' . plugin_dir_url(__FILE__) . '/img/user.svg" style="width:16px; margin-left:2px; margin-right:2px;"/><a href="' . halv3 . '?q=authId_i:' . $name[0] . "+AND+" . $type . ':(' . $id . ')" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
358 + }
359 + $i = 1;
360 + $content .= '<div id="auteursuite" style="display:none;">';
361 + foreach ($json->facet_counts->facet_fields->authIdLastNameFirstName_fs as $res) {
362 + if ($r < 10) {
363 + break;
364 + }
365 + if ($i < $r) {
366 + $i = $i + 1;
367 + } else {
368 + $name = explode(delimiter, $res[0]);
369 + $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><img alt="user" src=" ' . plugin_dir_url(__FILE__) . '/img/user.svg" style="width:16px; margin-left:2px; margin-right:2px;"/><a href="' . halv3 . '?q=authId_i:' . $name[0] . "+AND+" . $type . ':(' . $id . ')" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
370 + }
371 + }
372 + $content .= '</div>';
373 + $content .= '</div>';
374 + $content .= '</ul>';
375 + if ($r > 10) {
376 + $content .= '<button type="button" href="" style="text-decoration: none;" id="wphal-auteur" onclick="visibilite(\'auteursuite\'); return false;" >' . __('Liste complète', 'wp-hal');
377 + $content .= '</button>';
378 + }
379 + }
380 + $content .= '</div>
381 + <div class="display" id="wphal-revues" style="display: none;">
382 + <h3 class="wphal-titre">' . __('Revues', 'wp-hal') . '</h3>';
383 + if (!is_null($json->facet_counts->facet_fields->journalIdTitle_fs) && !empty($json->facet_counts->facet_fields->journalIdTitle_fs)) {
384 + $content .= '<span id="trirevues">';
385 + $content .= '<button type="button" class="trial" href="" id="trirev" onclick="toggleSort(this, true, \'wphal-rev\', \'revuesuite\', \'trirev\'); return false;" style="font-size:16px; text-decoration: none;" >Tri Alphabétique</button>';
386 + $content .= '<button type="button" class="trioc" href="" id="trinbrev" onclick="toggleSort(this, false, \'wphal-rev\', \'revuesuite\', \'trinbrev\'); return false;" style="font-size:16px; text-decoration: none;">Tri Occurrence</button>';
387 + $content .= '</span>';
388 + $content .= '<ul class="wphal-revues">';
389 + $content .= '<div id="wphal-rev">';
390 + $r = 0;
391 + foreach ($json->facet_counts->facet_fields->journalIdTitle_fs as $res) {
392 + $r = $r + 1;
393 + if ($r > 10) {
394 + break;
395 + }
396 + $name = explode(delimiter, $res[0]);
397 + $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . halv3 . '?q=journalId_i:' . urlencode($name[0]) . "+AND+" . $type . ':(' . $id . ')" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
398 + }
399 + $i = 1;
400 + $content .= '<div id="revuesuite" style="display:none;">';
401 + foreach ($json->facet_counts->facet_fields->journalIdTitle_fs as $res) {
402 + if ($r < 10) {
403 + break;
404 + }
405 + if ($i < $r) {
406 + $i = $i + 1;
407 + } else {
408 + $name = explode(delimiter, $res[0]);
409 + $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . halv3 . '?q=journalId_i:' . urlencode($name[0]) . "+AND+" . $type . ':(' . $id . ')" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
410 + }
411 + }
412 + $content .= '</div>';
413 + $content .= '</div>';
414 + $content .= '</ul>';
415 + if ($r > 10) {
416 + $content .= '<button type="button" href="" style="text-decoration: none;" id="wphal-revue" onclick="visibiliterevues(\'revuesuite\'); return false;" >' . __('Liste complète', 'wp-hal');
417 + $content .= '</button>';
418 + }
419 + }
420 + $content .= '</div>
421 + <div class="display" id="wphal-annees" style="display: none;">
422 + <h3 class="wphal-titre">' . __('Année de production', 'wp-hal') . '</h3>';
423 + if (!is_null($json->facet_counts->facet_fields->producedDateY_i) && !empty($json->facet_counts->facet_fields->producedDateY_i)) {
424 + $content .= '<span id="triannees">';
425 + $content .= '<button type="button" class="trial" href="" id="trian" onclick="toggleSort(this, true, \'wphal-an\', \'anneesuite\', \'trian\'); return false;" style="font-size:16px; text-decoration: none;" >Tri Alphabétique</button>';
426 + $content .= '<button type="button" class="trioc" href="" id="trinban" onclick="toggleSort(this, false, \'wphal-an\', \'anneesuite\', \'trinban\'); return false;" style="font-size:16px; text-decoration: none;">Tri Occurrence</button>';
427 + $content .= '</span>';
428 + $content .= '<ul class="wphal-annees">';
429 + $content .= '<div id="wphal-an">';
430 +
431 + rsort($json->facet_counts->facet_fields->producedDateY_i);
432 + $r = 0;
433 + foreach ($json->facet_counts->facet_fields->producedDateY_i as $res) {
434 + $r = $r + 1;
435 + if ($r > 10) {
436 + break;
437 + }
438 + $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . halv3 . '?q=producedDateY_i:' . urlencode($res[0]) . "+AND+" . $type . ':(' . $id . ')" target="_blank">' . $res[0] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
439 + }
440 + $i = 1;
441 + $content .= '<div id="anneesuite" style="display:none;">';
442 + foreach ($json->facet_counts->facet_fields->producedDateY_i as $res) {
443 + if ($r < 10) {
444 + break;
445 + }
446 + if ($i < $r) {
447 + $i = $i + 1;
448 + } else {
449 + $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . halv3 . '?q=producedDateY_i:' . urlencode($res[0]) . "+AND+" . $type . ':(' . $id . ')" target="_blank">' . $res[0] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
450 + }
451 + }
452 + $content .= '</div>';
453 + $content .= '</div>';
454 + $content .= '</ul>';
455 + if ($r > 10) {
456 + $content .= '<button type="button" href="" style="text-decoration: none;" id="wphal-annee" onclick="visibiliteannee(\'anneesuite\'); return false;" >' . __('Liste complète', 'wp-hal');
457 + $content .= '</button>';
458 + }
459 + }
460 + $content .= '</div>
461 + <div class="display" id="wphal-insts" style="display: none;">
462 + <h3 class="wphal-titre">' . __('Institutions', 'wp-hal') . '</h3>';
463 + if (!is_null($json->facet_counts->facet_fields->instStructIdName_fs) && !empty($json->facet_counts->facet_fields->instStructIdName_fs)) {
464 + $content .= '<span id="triinsts">';
465 + $content .= '<button type="button" class="trial" href="" id="triinst" onclick="toggleSort(this, true, \'wphal-institu\', \'instsuite\', \'triinst\'); return false;" style="font-size:16px; text-decoration: none;" >Tri Alphabétique</button>';
466 + $content .= '<button type="button" class="trioc" href="" id="trinbinst" onclick="toggleSort(this, false, \'wphal-institu\', \'instsuite\', \'trinbinst\'); return false;" style="font-size:16px; text-decoration: none;">Tri Occurrence</button>';
467 + $content .= '</span>';
468 + $content .= '<ul class="wphal-insts">';
469 + $content .= '<div id="wphal-institu">';
470 + $r = 0;
471 + foreach ($json->facet_counts->facet_fields->instStructIdName_fs as $res) {
472 + $r = $r + 1;
473 + if ($r > 10) {
474 + break;
475 + }
476 + $name = explode(delimiter, $res[0]);
477 + $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . halv3 . '?q=instStructId_i:' . urlencode($name[0]) . "+AND+" . $type . ':(' . $id . ')" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
478 + }
479 + $i = 1;
480 + $content .= '<div id="instsuite" style="display:none;">';
481 + foreach ($json->facet_counts->facet_fields->instStructIdName_fs as $res) {
482 + if ($r < 10) {
483 + break;
484 + }
485 + if ($i < $r) {
486 + $i = $i + 1;
487 + } else {
488 + $name = explode(delimiter, $res[0]);
489 + $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . halv3 . '?q=instStructId_i:' . urlencode($name[0]) . "+AND+" . $type . ':(' . $id . ')" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
490 + }
491 + }
492 + $content .= '</div>';
493 + $content .= '</div>';
494 + $content .= '</ul>';
495 + if ($r > 10) {
496 + $content .= '<button type="button" href="" style="text-decoration: none;" id="wphal-inst" onclick="visibiliteinst(\'instsuite\'); return false;" >' . __('Liste complète', 'wp-hal');
497 + $content .= '</button>';
498 + }
499 + }
500 + $content .= '</div>
501 + <div class="display" id="wphal-labs" style="display: none;">
502 + <h3 class="wphal-titre">' . __('Laboratoires', 'wp-hal') . '</h3>';
503 + if (!is_null($json->facet_counts->facet_fields->labStructIdName_fs) && !empty($json->facet_counts->facet_fields->labStructIdName_fs)) {
504 + $content .= '<span id="trilabs">';
505 + $content .= '<button type="button" class="trial" href="" id="trilab" onclick="toggleSort(this, true, \'wphal-labo\', \'labsuite\', \'trilab\'); return false;" style="font-size:16px; text-decoration: none;" >Tri Alphabétique</button>';
506 + $content .= '<button type="button" class="trioc" href="" id="trinblab" onclick="toggleSort(this, false, \'wphal-labo\', \'labsuite\', \'trinblab\'); return false;" style="font-size:16px; text-decoration: none;">Tri Occurrence</button>';
507 + $content .= '</span>';
508 + $content .= '<ul class="wphal-labs">';
509 + $content .= '<div id="wphal-labo">';
510 +
511 + $r = 0;
512 + foreach ($json->facet_counts->facet_fields->labStructIdName_fs as $res) {
513 + $r = $r + 1;
514 + if ($r > 10) {
515 + break;
516 + }
517 + $name = explode(delimiter, $res[0]);
518 + $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . halv3 . '?q=labStructId_i:' . urlencode($name[0]) . "+AND+" . $type . ':(' . $id . ')" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
519 + }
520 + $i = 1;
521 + $content .= '<div id="labsuite" style="display:none;">';
522 + foreach ($json->facet_counts->facet_fields->labStructIdName_fs as $res) {
523 + if ($r < 10) {
524 + break;
525 + }
526 + if ($i < $r) {
527 + $i = $i + 1;
528 + } else {
529 + $name = explode(delimiter, $res[0]);
530 + $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . halv3 . '?q=labStructId_i:' . urlencode($name[0]) . "+AND+" . $type . ':(' . $id . ')" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
531 + }
532 + }
533 + $content .= '</div>';
534 + $content .= '</div>';
535 + $content .= '</ul>';
536 + if ($r > 10) {
537 + $content .= '<button type="button" href="" style="text-decoration: none;" id="wphal-lab" onclick="visibilitelab(\'labsuite\'); return false;" >' . __('Liste complète', 'wp-hal');
538 + $content .= '</button>';
539 + }
540 + }
541 + $content .= '</div>
542 + <div class="display" id="wphal-depts" style="display: none;">
543 + <h3 class="wphal-titre">' . __('Départements', 'wp-hal') . '</h3>';
544 + if (!is_null($json->facet_counts->facet_fields->deptStructIdName_fs) && !empty($json->facet_counts->facet_fields->deptStructIdName_fs)) {
545 + $content .= '<span id="tridept">';
546 + $content .= '<button type="button" class="trial" href="" id="tridept" onclick="toggleSort(this, true, \'wphal-dpt\', \'deptsuite\', \'tridept\'); return false;" style="font-size:16px; text-decoration: none;" >Tri Alphabétique</button>';
547 + $content .= '<button type="button" class="trioc" href="" id="trinbdept" onclick="toggleSort(this, false, \'wphal-dpt\', \'deptsuite\', \'trinbdept\'); return false;" style="font-size:16px; text-decoration: none;">Tri Occurrence</button>';
548 + $content .= '</span>';
549 + $content .= '<ul class="wphal-depts">';
550 + $content .= '<div id="wphal-dpt">';
551 + $r = 0;
552 + foreach ($json->facet_counts->facet_fields->deptStructIdName_fs as $res) {
553 + $r = $r + 1;
554 + if ($r > 10) {
555 + break;
556 + }
557 + $name = explode(delimiter, $res[0]);
558 + $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . halv3 . '?q=deptStructId_i:' . urlencode($name[0]) . "+AND+" . $type . ':(' . $id . ')" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
559 + }
560 + $i = 1;
561 + $content .= '<div id="deptsuite" style="display:none;">';
562 + foreach ($json->facet_counts->facet_fields->deptStructIdName_fs as $res) {
563 + if ($r < 10) {
564 + break;
565 + }
566 + if ($i < $r) {
567 + $i = $i + 1;
568 + } else {
569 + $name = explode(delimiter, $res[0]);
570 + $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . halv3 . '?q=deptStructId_i:' . urlencode($name[0]) . "+AND+" . $type . ':(' . $id . ')" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
571 + }
572 + }
573 + $content .= '</div>';
574 + $content .= '</div>';
575 + $content .= '</ul>';
576 + if ($r > 10) {
577 + $content .= '<button type="button" href="" style="text-decoration: none;" id="wphal-dept" onclick="visibilitedept(\'deptsuite\'); return false;" >' . __('Liste complète', 'wp-hal');
578 + $content .= '</button>';
579 + }
580 + }
581 + $content .= '</div>
582 + <div class="display" id="wphal-equipes" style="display: none;">
583 + <h3 class="wphal-titre">' . __('Équipes de recherche', 'wp-hal') . '</h3>';
584 + if (!is_null($json->facet_counts->facet_fields->rteamStructIdName_fs) && !empty($json->facet_counts->facet_fields->rteamStructIdName_fs)) {
585 + $content .= '<span id="triequipe">';
586 + $content .= '<button type="button" class="trial" href="" id="triequipe" onclick="toggleSort(this, true, \'wphal-rteam\', \'equipesuite\', \'triequipe\'); return false;" style="font-size:16px;text-decoration: none;" >Tri Alphabétique</button>';
587 + $content .= '<button type="button" class="trioc" href="" id="trinbequipe" onclick="toggleSort(this, false, \'wphal-rteam\', \'equipesuite\', \'trinbequipe\'); return false;" style="font-size:16px; text-decoration: none;">Tri Occurrence</button>';
588 + $content .= '</span>';
589 + $content .= '<ul class="wphal-equipes">';
590 + $content .= '<div id="wphal-rteam">';
591 +
592 + $r = 0;
593 + foreach ($json->facet_counts->facet_fields->rteamStructIdName_fs as $res) {
594 + $r = $r + 1;
595 + if ($r > 10) {
596 + break;
597 + }
598 + $name = explode(delimiter, $res[0]);
599 + $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . halv3 . '?q=rteamStructId_i:' . urlencode($name[0]) . "+AND+" . $type . ':(' . $id . ')" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
600 + }
601 + $i = 1;
602 + $content .= '<div id="equipesuite" style="display:none;">';
603 + foreach ($json->facet_counts->facet_fields->rteamStructIdName_fs as $res) {
604 + if ($r < 10) {
605 + break;
606 + }
607 + if ($i < $r) {
608 + $i = $i + 1;
609 + } else {
610 + $content .= '<li class="metadata" data-percentage="' . $res[1] . '"><a href="' . halv3 . '?q=rteamStructId_i:' . urlencode($name[0]) . "+AND+" . $type . ':(' . $id . ')" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
611 + }
612 + }
613 + $content .= '</div>';
614 + $content .= '</div>';
615 + $content .= '</ul>';
616 + if ($r > 10) {
617 + $content .= '<button type="button" href="" style="text-decoration: none;" id="wphal-equipe" onclick="visibiliteequipe(\'equipesuite\'); return false;" >' . __('Liste complète', 'wp-hal');
618 + $content .= '</button>';
619 + }
620 + }
621 + $content .= '</div>
622 + <div class="display" id="publications">';
623 + if (get_option('option_groupe') == 'grouper') {
624 + $doctype = file_get_contents(plugin_dir_path( __FILE__ ).'json'. DIRECTORY_SEPARATOR .'doctype_'.lang.'.json');
625 + $jsontype = json_decode($doctype);
626 +
627 +//LISTE DES DOCUMENTS PAR GROUPE
628 +
629 + $content .= '<div class="counter-doc"><span class="wphal-nbtot">' . $json->grouped->docType_s->matches . ' </span>';
630 + $content .= __('documents', 'wp-hal'). '</div><br>';
631 + for ($i = 0; $jsontype->response->result->doc[$i] != null; $i++) {
632 + for ($d = 0; $json->grouped->docType_s->groups[$d] != null; $d++) {
633 + if ($json->grouped->docType_s->groups[$d]->groupValue == $jsontype->response->result->doc[$i]->str[0]){
634 + $titre = $jsontype->response->result->doc[$i]->str[1];
635 + $content .= '<div class="grp-div"><h3 class="wphal-titre-groupe">' . $titre . '<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>';
636 + $content .= '<div class="grp-content">';
637 + $content .= '<ul>';
638 + foreach ($json->grouped->docType_s->groups[$d]->doclist->docs as $result) {
639 + $content .= '<li>' . $result->citationFull_s . '</li>';
640 + }
641 + $content .= '</ul></div>';
642 + $content .= '</div><br>';
643 + break;
644 + }
645 + }
646 + }
647 + } elseif (get_option('option_groupe') == 'paginer') {
648 +
649 +//LISTE DES DOCUMENTS AVEC PAGINATION
650 + $content .= '<div class="counter-doc"><span class="wphal-nbtot">' . $json->response->numFound . ' </span>';
651 + $content .= __('documents', 'wp-hal'). '</div><br>';
652 +
653 +//--MODULE PAGINATION--//
654 + $messagesParPage = 10;
655 +
656 + $total = $json->response->numFound;
657 +
658 + $nombreDePages = ceil($total / $messagesParPage);
659 +
660 + if (isset($paged)) {
661 + $pageActuelle = intval($paged);
662 +
663 + if ($pageActuelle > $nombreDePages) {
664 + $pageActuelle = $nombreDePages;
665 + }
666 + } else {
667 + $pageActuelle = 1;
668 + }
669 + $premiereEntree = ($pageActuelle - 1) * $messagesParPage;
670 +
671 + $url = api . '?q=*:*&fq=' . $type . ':(' . urlencode($id) . ')&fl=docid,citationFull_s,keyword_s,bookTitle_s,producedDate_s,authFullName_s&start=' . $premiereEntree . '&rows=' . $messagesParPage . '&sort=' . producedDateY . '&wt=json';
672 + $ch = curl_init($url);
673 +// Options
674 + $options = array(
675 + CURLOPT_RETURNTRANSFER => true,
676 + CURLOPT_HTTPHEADER => array('Content-type: application/json'),
677 + CURLOPT_TIMEOUT => 10,
678 + CURLOPT_USERAGENT => "HAL Plugin Wordpress " . version
679 + );
680 +
681 +// Bind des options et de l'objet cURL que l'on va utiliser
682 + curl_setopt_array($ch, $options);
683 +// Récupération du résultat JSON
684 + $json = json_decode(curl_exec($ch));
685 + curl_close($ch);
686 +
687 +//--MODULE PAGINATION--//
688 +
689 + $content .= '<ul>';
690 + for ($i = 0; $json->response->docs[$i] != ''; $i++) {
691 + $content .= '<li>' . $json->response->docs[$i]->citationFull_s . '</li>';
692 + }
693 + $content .= '</ul>';
694 +
695 +//--AFFICHAGE PAGINATION--//
696 + $precedents = $pageActuelle - 2;
697 + $suivants = $pageActuelle + 2;
698 + $precedent = $pageActuelle - 1;
699 + $suivant = $pageActuelle + 1;
700 + $penultimate = $nombreDePages - 1;
701 +
702 + $content .= '<ul class="wphal-pagination">';
703 +//--BOUTON PRECEDENT--//
704 + if ($pageActuelle == 1) {
705 + $content .= '<li class="disabled"><a href="#">&laquo;</a></li>';
706 + } else {
707 + $content .= '<li><a href="?paged=' . $precedent . '">&laquo;</a></li>';
708 + }
709 + if ($nombreDePages <= 6) {// Cas 1 : 6 pages ou moins - Pas de troncature
710 + for ($i = 1; $i <= $nombreDePages; $i++) {
711 + if ($i == $pageActuelle) {
712 + $content .= '<li class="active"><a href="#">' . $i . '</a></li>';
713 + } else {
714 + $content .= ' <li><a href="?paged=' . $i . '">' . $i . '</a></li> ';
715 + }
716 + }
717 + } elseif ($nombreDePages >= 7) {// Cas 2 : 7 pages ou plus - Troncature
718 + if ($pageActuelle <= 3) {// Lorsque l'on est sur les trois premières pages
719 + for ($i = 1; $i <= 4; $i++) {
720 + if ($i == $pageActuelle) {
721 + $content .= '<li class="active"><a href="#">' . $i . '</a></li>';
722 + } else {
723 + $content .= '<li><a href="?paged=' . $i . '">' . $i . '</a></li>';
724 + }
725 + }
726 + $content .= '<li class="disabled"><a href="#">&hellip;</a></li>';
727 + $content .= '<li><a href="?paged=' . $penultimate . '">' . $penultimate . '</a></li>';
728 + $content .= '<li><a href="?paged=' . $nombreDePages . '">' . $nombreDePages . '</a></li>';
729 + }
730 + if ($pageActuelle >= 4 && $pageActuelle <= $penultimate - 2) {//Lorsque l'on arrive sur la quatrième page
731 + $content .= '<li><a href="?paged=">1</a></li>';
732 + $content .= '<li class="disabled"><a href="#">&hellip;</a></li>';
733 + $content .= '<li><a href="?paged=' . $precedents . '">' . $precedents . '</a></li>';
734 + $content .= '<li><a href="?paged=' . $precedent . '">' . $precedent . '</a></li>';
735 + $content .= '<li class="active"><a href="#">' . $pageActuelle . '</a></li>';
736 + $content .= '<li><a href="?paged=' . $suivant . '">' . $suivant . '</a></li>';
737 + $content .= '<li><a href="?paged=' . $suivants . '">' . $suivants . '</a></li>';
738 + $content .= '<li class="disabled"><a href="#">&hellip;</a></li>';
739 + $content .= '<li><a href="?paged=' . $nombreDePages . '">' . $nombreDePages . '</a></li>';
740 + }
741 + if ($pageActuelle >= $penultimate - 1) {
742 + $content .= '<li><a href="?paged=1">1</a></li>';
743 + $content .= '<li><a href="?paged=2">2</a></li>';
744 + $content .= '<li class="disabled"><a href="#">&hellip;</a></li>';
745 + for ($i = $penultimate - 2; $i <= $nombreDePages; $i++) {
746 + if ($i == $pageActuelle) {
747 + $content .= '<li class="active"><a href="#">' . $i . '</a></li>';
748 + } else {
749 + $content .= '<li><a href="?paged=' . $i . '">' . $i . '</a></li>';
750 + }
751 + }
752 + }
753 + }
754 +//--BOUTON SUIVANT--//
755 + if ($pageActuelle < $nombreDePages) {
756 + $content .= '<li><a href="?paged=' . $suivant . '">&raquo;</a></li>';
757 + } else {
758 + $content .= '<li class="disabled"><a href="#">&raquo;</a></li>';
759 + }
760 + $content .= '</ul>';
761 +//--AFFICHAGE PAGINATION--//
762 + }
763 + $content .= '</div>
764 + </div>
765 +</div>';
766 + }
767 + $content .= '<div class="wphal-footer">';
768 + $content .= '<p style="color:#B3B2B0">' . __("Documents récupérés de l'archive ouverte HAL", 'wp-hal') . '&nbsp;<a href="' . site . '" target="_blank"><img alt="logo" src=" ' . plugin_dir_url(__FILE__) . 'img/logo-hal.svg" style="width:32px;"></a></p>';
769 + $content .= '</div>';
770 +
771 +//--AFFICHAGE GRAPHIQUE DOMAINE--//
772 + if (!is_null($facetdomain)) {
773 + foreach ($facetdomain as $res) {
774 + $name = explode(delimiter, $res[0])[1];
775 + $value = $res[1];
776 + $array[] = array($name, $value);
777 + }
778 + }
779 + wp_localize_script('wp-hal-script4', 'WPWallSettings', json_encode($array));
780 + $translation = array('liste' => __('Liste', 'wp-hal'), 'compl' => __('Liste complète', 'wp-hal'), 'princ' => __('Liste principale', 'wp-hal'), 'graph' => __('Graphique', 'wp-hal'), 'nuage' => __('Nuage de mots', 'wp-hal'));
781 + wp_localize_script('wp-hal-script4', 'translate', $translation);
782 + }
783 + return $content;
784 +}
785 +
786 +function verifSolr($values){
787 + $verifsolr = explode(',',$values);
788 + $numverif = count($verifsolr);
789 + $solrsql = '';
790 + if ($numverif<1024){
791 + $solrsql = str_replace(',',' OR ',$values);
792 + } else {
793 + $listsolrsql = explode(',',$values);
794 + for($i=0;$i<1024;$i++){
795 + if ($i == 0){
796 + $solrsql = $listsolrsql[$i];
797 + } else {
798 + $solrsql .= ' OR ';
799 + $solrsql .= $listsolrsql[$i];
800 + }
801 + }
802 + }
803 +
804 + return $solrsql;
805 +}
806 +
807 +function wp_adding_style() {
808 + wp_register_style('wp-hal-style1', plugins_url('/css/style.css', __FILE__));
809 + wp_register_style('wp-hal-style2', plugins_url('/css/jquery.jqplot.css', __FILE__));
810 +
811 + wp_enqueue_style('wp-hal-style1');
812 +}
813 +
814 +function wp_adding_script() {
815 + wp_register_script('wp-hal-script1',plugins_url('/js/jquery.jqplot.js', __FILE__));
816 + wp_register_script('wp-hal-script2',plugins_url('/js/jqplot.highlighter.js', __FILE__));
817 + wp_register_script('wp-hal-script3',plugins_url('/js/jqplot.pieRenderer.js', __FILE__));
818 + wp_register_script('wp-hal-script4',plugins_url('/js/cv-hal.js', __FILE__));
819 +
820 +
821 + wp_enqueue_script("jquery");
822 + wp_enqueue_script('wp-hal-script4', false, array(), false, true);
823 +}
824 +
825 +/**
826 + * Récupère les fichiers css et js
827 + */
828 +if ( function_exists('curl_init' ) ) {
829 + add_action('wp_enqueue_scripts', 'wp_adding_style');
830 + add_action('wp_enqueue_scripts', 'wp_adding_script');
831 +}
832 +
833 +/**
834 + * Charge lorsque le plugin est désactivé
835 + */
836 +register_deactivation_hook( __FILE__, 'reset_option' );
837 +
838 +/**
839 + * Ajoute le widget wphal à l'initialisation des widgets
840 + */
841 +add_action('widgets_init','wphal_init');
842 +
843 +/**
844 + * Ajoute le menu à l'initialisation du menu admin
845 + */
846 +add_action( 'admin_menu', 'wphal_menu' );
847 +
848 +/**
849 + * Fonction de création du menu
850 + */
851 +function wphal_menu() {
852 + add_menu_page( 'Options', 'Hal', 'manage_options', 'wp-hal.php', 'wphal_option' , '', 21);
853 +
854 + add_action( 'admin_init', 'register_settings' );
855 +}
856 +
857 +
858 +/**
859 + * Initialise le nouveau widget
860 + */
861 +function wphal_init(){
862 + register_widget("wphal_widget");
863 +}
864 +
865 +/***********************************************************************************************************************
866 + * PLUGIN WIDGET
867 + **********************************************************************************************************************/
868 +
869 +/**
870 + * Classe du widget wphal
871 + */
872 +
873 +class wphal_widget extends WP_widget{
874 +
875 +
876 + /**
877 + * Défini les propriétés du widget
878 + */
879 + function wphal_widget(){
880 + $options = array(
881 + "classname" => "wphal-publications",
882 + "description" => __("Afficher les dernières publications d'un auteur ou d'une structure.", 'wp-hal')
883 + );
884 +
885 + parent::__construct(
886 + 'hal-publications',
887 + __("Publications récentes", 'wp-hal'),
888 + $options
889 + );
890 + }
891 +
892 + /**
893 + * Crée le widget
894 + * @param $args
895 + * @param $instance
896 + */
897 + function widget($args, $instance){
898 + if ( !function_exists('curl_init' ) ) {
899 + $content = 'Please check the <a href="https://wordpress.org/plugins/hal/faq/" target="_blank" id="FAQ">FAQ</a> with the code : CURL';
900 + extract($args);
901 + echo $before_widget;
902 + echo $before_title . $instance['titre'] . $after_title;
903 + echo $content;
904 + echo $after_widget;
905 + } else {
906 + $instance['idhal'] = verifSolr($instance['idhal']);
907 +
908 + $url = api . '?q=*:*&fq=' . $instance['select'] . ':' . urlencode($instance['idhal']) . '&fl=uri_s,'. $instance['typetext'] .'&sort=' . producedDateY . '&rows=' . $instance['nbdoc'] . '&wt=json';
909 +
910 + $ch = curl_init($url);
911 + // Options
912 + $options = array(
913 + CURLOPT_RETURNTRANSFER => true,
914 + CURLOPT_HTTPHEADER => array('Content-type: application/json'),
915 + CURLOPT_TIMEOUT => 10,
916 + CURLOPT_USERAGENT => "HAL Plugin Wordpress " . version
917 + );
918 +
919 + // Bind des options et de l'objet cURL que l'on va utiliser
920 + curl_setopt_array($ch, $options);
921 + // Récupération du résultat JSON
922 + $json = json_decode(curl_exec($ch));
923 + curl_close($ch);
924 +
925 + $content = '<ul class="widhal-ul">';
926 + for ($i = 0; $i < $instance['nbdoc']; $i++) {
927 + if ($instance['typetext']=='citationRef_s') {
928 + $typetext = $json->response->docs[$i]->citationRef_s;
929 + } else {
930 + $typetext = $json->response->docs[$i]->title_s[0];
931 + }
932 + $content .= '<li class="widhal-li"><a href="' . $json->response->docs[$i]->uri_s . '" target="_blank">' . $typetext . '</a></li>';
933 + }
934 + $content .= '</ul>';
935 +
936 + extract($args);
937 + echo $before_widget;
938 + echo $before_title . $instance['titre'] . $after_title;
939 + echo $content;
940 + echo $after_widget;
941 + }
942 + }
943 +
944 + /**
945 + * Sauvegarde des données
946 + * @param $new
947 + * @param $old
948 + */
949 + function update($new, $old){
950 + return $new;
951 + }
952 +
953 + /**
954 + * Formulaire du widget
955 + * @param $instance
956 + */
957 + function form($instance){
958 +
959 + $defaut = array(
960 + 'titre' => __("Publications récentes", 'wp-hal'),
961 + 'select' => "authIdHal_s",
962 + 'typetext' => "title_s",
963 + 'nbdoc' => 5
964 + );
965 + $instance = wp_parse_args($instance,$defaut);
966 + ?>
967 + <p>
968 + <label for="<?php echo $this->get_field_id("titre");?>"><?php echo __('Titre','wp-hal') .' :'?></label>
969 + <input value="<?php echo $instance['titre'];?>" name="<?php echo $this->get_field_name("titre");?>" id="<?php echo $this->get_field_id("titre");?>" class="widefat" type="text"/>
970 + </p>
971 + <p>
972 + <label for="<?php echo $this->get_field_id("nbdoc");?>"><?php echo __("Nombre de documents affichés",'wp-hal') .' :'?></label>
973 + <input class="tiny-text" id="<?php echo $this->get_field_id("nbdoc");?>" name="<?php echo $this->get_field_name("nbdoc");?>" type="number" step="1" min="1" max="10" value="<?php echo $instance['nbdoc'];?>" size="3">
974 + </p>
975 + <p>
976 + <label for="<?php echo $this->get_field_id("typetext");?>"><?php echo __("Type d'affichage",'wp-hal') .' :'?></label>
977 + <select id="<?php echo $this->get_field_id("typetext");?>" name="<?php echo $this->get_field_name("typetext");?>">
978 + <option id="<?php echo $this->get_field_id("Title");?>" value="title_s" <?php echo ($instance["typetext"] == "title_s")?'selected':''; ?>><label for="<?php echo $this->get_field_id("Title");?>"><?php echo __("Titre", 'wp-hal')?></label></option>
979 + <option id="<?php echo $this->get_field_id("Citation");?>" value="citationRef_s" <?php echo ($instance["typetext"] == "citationRef_s")?'selected':''; ?>><label for="<?php echo $this->get_field_id("Citation");?>"><?php echo __("Citation", 'wp-hal')?></label></option>
980 + </select>
981 + </p>
982 + <p>
983 + <label for="<?php echo $this->get_field_id("select");?>"><?php echo __("Type d'Id",'wp-hal') .' :'?></label>
984 + <select id="<?php echo $this->get_field_id("select");?>" name="<?php echo $this->get_field_name("select");?>">
985 + <option id="<?php echo $this->get_field_id("Idhal");?>" value="authIdHal_s" <?php echo ($instance["select"] == "authIdHal_s")?'selected':''; ?>><label for="<?php echo $this->get_field_id("Idhal");?>">Id Hal</label><span style="font-style: italic;"> <?php echo __('(Exemple : laurent-capelli)','wp-hal');?></span></option>
986 + <option id="<?php echo $this->get_field_id("StructId");?>" value="structId_i" <?php echo ($instance["select"] == "structId_i")?'selected':''; ?>><label for="<?php echo $this->get_field_id("StructId");?>">Struct Id</label><span style="font-style: italic;"> <?php echo __('(Exemple : 413106)','wp-hal');?></span></option>
987 + <option id="<?php echo $this->get_field_id("AuthorStructId");?>" value="authStructId_i" <?php echo ($instance["select"] == "authStructId_i")?'selected':''; ?>><label for="<?php echo $this->get_field_id("AuthorStructId");?>">AuthorStruct Id</label><span style="font-style: italic;"> <?php echo __('(Exemple : 413106)','wp-hal');?></span></option>
988 + <option id="<?php echo $this->get_field_id("AuthorId");?>" value="authId_i" <?php echo ($instance["select"] == "authId_i")?'selected':''; ?>><label for="<?php echo $this->get_field_id("AuthorId");?>">Author Id</label><span style="font-style: italic;"> <?php echo __('(Exemple : 413106)','wp-hal');?></span></option>
989 + <option id="<?php echo $this->get_field_id("Anrproject");?>" value="anrProjectId_i" <?php echo ($instance["select"] == "anrProjectId_i")?'selected':''; ?>><label for="<?php echo $this->get_field_id("Anrproject");?>">anrProject Id</label><span style="font-style: italic;"> <?php echo __('(Exemple : 1646)','wp-hal');?></span></option>
990 + <option id="<?php echo $this->get_field_id("Europeanproject");?>" value="europeanProjectId_i" <?php echo ($instance["select"] == "europeanProjectId_i")?'selected':''; ?>><label for="<?php echo $this->get_field_id("Europeanproject");?>">europeanProject Id</label><span style="font-style: italic;"> <?php echo __('(Exemple : 17877)','wp-hal');?></span></option>
991 + <option id="<?php echo $this->get_field_id("Collection");?>" value="collCode_s" <?php echo ($instance["select"] == "collCode_s")?'selected':''; ?>><label for="<?php echo $this->get_field_id("Collection");?>">Collection</label><span style="font-style: italic;"> <?php echo __('(Exemple : TICE2014)','wp-hal');?></span></option>
992 + </select>
993 + </p>
994 + <p>
995 + <label for="<?php echo $this->get_field_id("idhal");?>"><?php echo __("Id",'wp-hal') .' :'?></label>
996 + <input value="<?php echo $instance['idhal'];?>" name="<?php echo $this->get_field_name("idhal");?>" id="<?php echo $this->get_field_id("idhal");?>" type="text"/>
997 + </p>
998 + <?php
999 + }
1000 +}
1001 +
1002 +
1003 +function register_settings() {
1004 + register_setting( 'wphal_option', 'option_choix' );
1005 + register_setting( 'wphal_option', 'option_type' );
1006 + register_setting( 'wphal_option', 'option_groupe' );
1007 + register_setting( 'wphal_option', 'option_idhal' );
1008 + register_setting( 'wphal_option', 'option_lang' );
1009 + register_setting( 'wphal_option', 'option_infocontact' );
1010 + register_setting( 'wphal_option', 'option_email' );
1011 + register_setting( 'wphal_option', 'option_tel' );
1012 + register_setting( 'wphal_option', 'option_social0' );
1013 + register_setting( 'wphal_option', 'option_social1' );
1014 + register_setting( 'wphal_option', 'option_social2' );
1015 + register_setting( 'wphal_option', 'option_social3' );
1016 +}
1017 +
1018 +/**
1019 + * Crée le menu d'option du plugin
1020 + */
1021 +function wphal_option() {
1022 +
1023 + if (get_option('option_type')==''){
1024 + update_option('option_type', 'authIdHal_s');
1025 + }
1026 + if (get_option('option_groupe')==''){
1027 + update_option('option_groupe', 'paginer');
1028 + }
1029 + ?>
1030 + <div class="wrap">
1031 + <h2><?php echo __('Plugin HAL','wp-hal');?></h2>
1032 + <form method="post" enctype="multipart/form-data" action="options.php">
1033 + <div id="poststuff">
1034 + <div id="post-body" class="metabox-holder columns-2">
1035 + <div id="post-body-content">
1036 + <?php settings_fields( 'wphal_option' ); ?>
1037 + <?php do_settings_sections( 'wphal_option' ); ?>
1038 + <table class="form-table">
1039 + <tr valign="top">
1040 + <th scope="row" style="font-size: 18px;"><?php echo __('Paramètre de la page :','wp-hal');?></th>
1041 + </tr>
1042 + <tr valign="top">
1043 + <th scope="row"><?php echo __('Type d\'Id','wp-hal');?></th>
1044 + <td><select name="option_type">
1045 + <option id="Idhal" value="authIdHal_s" <?php echo (get_option('option_type') == "authIdHal_s")?'selected':''; ?>><label for="Idhal">Id Hal</label><span style="font-style: italic;"> <?php echo __('(Exemple : laurent-capelli)','wp-hal');?></span></option>
1046 + <option id="StructId" value="structId_i" <?php echo (get_option('option_type') == "structId_i")?'selected':''; ?>><label for="StructId">Struct Id</label><span style="font-style: italic;"> <?php echo __('(Exemple : 413106)','wp-hal');?></span></option>
1047 + <option id="AuthorStructId" value="authStructId_i" <?php echo (get_option('option_type') == "authStructId_i")?'selected':''; ?>><label for="AuthorStructId">AuthorStruct Id</label><span style="font-style: italic;"> <?php echo __('(Exemple : 413106)','wp-hal');?></span></option>
1048 + <option id="AuthorId" value="authId_i" <?php echo (get_option('option_type') == "authId_i")?'selected':''; ?>><label for="AuthorId">Author Id</label><span style="font-style: italic;"> <?php echo __('(Exemple : 413106)','wp-hal');?></span></option>
1049 + <option id="Anrproject" value="anrProjectId_i" <?php echo (get_option('option_type') == "anrProjectId_i")?'selected':''; ?>><label for="Anrproject">anrProject Id</label><span style="font-style: italic;"> <?php echo __('(Exemple : 1646)','wp-hal');?></span></option>
1050 + <option id="Europeanproject" value="europeanProjectId_i" <?php echo (get_option('option_type') == "europeanProjectId_i")?'selected':''; ?>><label for="Europeanproject">europeanProject Id</label><span style="font-style: italic;"> <?php echo __('(Exemple : 17877)','wp-hal');?></span></option>
1051 + <option id="Collection" value="collCode_s" <?php echo (get_option('option_type') == "collCode_s")?'selected':''; ?>><label for="Collection">Collection</label><span style="font-style: italic;"> <?php echo __('(Exemple : TICE2014)','wp-hal');?></span></option>
1052 + </select>
1053 + <input type="text" name="option_idhal" id="option_idhal" value="<?php echo get_option('option_idhal'); ?>"/>
1054 + </td>
1055 + </tr>
1056 + <tr valign="top">
1057 + <th scope="row"><?php echo __('Affichage des documents','wp-hal');?></th>
1058 + <td><input type="radio" name="option_groupe" id="paginer" value="paginer" <?php echo (get_option('option_groupe') == "paginer")?'checked':''; ?>><label for="paginer"><?php echo __('Documents avec pagination','wp-hal');?></label><br>
1059 + <input type="radio" name="option_groupe" id="grouper" value="grouper" <?php echo (get_option('option_groupe') == "grouper")?'checked':''; ?>><label for="grouper"><?php echo __('Documents groupés par type','wp-hal');?></label><br>
1060 + </td>
1061 + </tr>
1062 + <tr valign="top">
1063 + <th scope="row"><?php echo __('Choix des éléments menu','wp-hal');?></th>
1064 + <td><input type="checkbox" name="option_choix[1]" id="Contact" value="contact" <?php echo (get_option('option_choix')[1] == "contact")?'checked':''; ?>><label for="Contact"><?php echo __('Contact','wp-hal');?></label><br/>
1065 + <input type="checkbox" name="option_choix[2]" id="Disciplines" value="disciplines" <?php echo (get_option('option_choix')[2] == "disciplines")?'checked':''; ?>><label for="Disciplines"><?php echo __('Disciplines','wp-hal');?></label><br/>
1066 + <input type="checkbox" name="option_choix[3]" id="Mots-clefs" value="mots-clefs" <?php echo (get_option('option_choix')[3] == "mots-clefs")?'checked':''; ?>><label for="Mots-clefs"><?php echo __('Mots-clefs','wp-hal');?></label><br/>
1067 + <input type="checkbox" name="option_choix[4]" id="Auteurs" value="auteurs" <?php echo (get_option('option_choix')[4] == "auteurs")?'checked':''; ?>><label for="Auteurs"><?php echo __('Auteurs','wp-hal');?></label><br/>
1068 + <input type="checkbox" name="option_choix[5]" id="Revues" value="revues" <?php echo (get_option('option_choix')[5] == "revues")?'checked':''; ?>><label for="Revues"><?php echo __('Revues','wp-hal');?></label><br/>
1069 + <input type="checkbox" name="option_choix[6]" id="Annee" value="annee" <?php echo (get_option('option_choix')[6] == "annee")?'checked':''; ?>><label for="Annee"><?php echo __('Année de production','wp-hal');?></label><br/>
1070 + <input type="checkbox" name="option_choix[7]" id="Institution" value="institution" <?php echo (get_option('option_choix')[7] == "institution")?'checked':''; ?>><label for="Institution"><?php echo __('Institutions','wp-hal');?></label><br/>
1071 + <input type="checkbox" name="option_choix[8]" id="Laboratoire" value="laboratoire" <?php echo (get_option('option_choix')[8] == "laboratoire")?'checked':''; ?>><label for="Laboratoire"><?php echo __('Laboratoires','wp-hal');?></label><br/>
1072 + <input type="checkbox" name="option_choix[9]" id="Departement" value="departement" <?php echo (get_option('option_choix')[9] == "departement")?'checked':''; ?>><label for="Departement"><?php echo __('Départements','wp-hal');?></label><br/>
1073 + <input type="checkbox" name="option_choix[10]" id="Equipe" value="equipe" <?php echo (get_option('option_choix')[10] == "equipe")?'checked':''; ?>><label for="Equipe"><?php echo __('Équipes de recherche','wp-hal');?></label>
1074 + </td>
1075 + </tr>
1076 + <tr valign="top">
1077 + <th scope="row" style="font-size: 18px;"><?php echo __('Contact :','wp-hal');?></th>
1078 + </tr>
1079 + <tr>
1080 + <th scope="row"><?php echo __("Afficher les informations d'un chercheur ayant un IdHal ?",'wp-hal');?></th>
1081 + <td><input type="radio" name="option_infocontact" id="wphal-yes" value="yes" <?php echo (get_option('option_infocontact') == "yes")?'checked':''; ?>><label for="wphal-yes"><?php echo __("Oui",'wp-hal')?></label><br>
1082 + <input type="radio" name="option_infocontact" id="wphal-no" value="no" <?php echo (get_option('option_infocontact') == "no")?'checked':''; ?>><label for="wphal-no"><?php echo __("Non",'wp-hal')?></label><br>
1083 + </td>
1084 + <tr>
1085 + <th scope="row"><?php echo __('Email','wp-hal');?></th>
1086 + <td><input type="text" style="width:300px;" placeholder="Exemple : hi@mail.com" name="option_email" id="option_email" value="<?php echo get_option('option_email'); ?>"/><img alt="email" src="<?php echo plugin_dir_url( __FILE__ ) ?>img/mail.svg" style="vertical-align:middle; width:32px; margin-left:2px; margin-right:2px;"/></td>
1087 + </tr>
1088 + <tr>
1089 + <th scope="row"><?php echo __('Téléphone','wp-hal');?></th>
1090 + <td><input type="text" style="width:300px;" placeholder="Exemple : 06-01-02-03-04" name="option_tel" id="option_tel" value="<?php echo get_option('option_tel');?>"/><img alt="phone" src="<?php echo plugin_dir_url( __FILE__ ) ?>img/phone.svg" style="vertical-align:middle; width:32px; margin-left:2px; margin-right:2px;"/></td>
1091 + </tr>
1092 + <tr>
1093 + <th>Facebook (http://www.facebook.com/)</th>
1094 + <td><input type="text" style="width:300px;" placeholder="Exemple : fa.book" name="option_social0" id="option_social0" value="<?php echo get_option('option_social0'); ?>"/><img alt="facebook" src="<?php echo plugin_dir_url( __FILE__ ) ?>img/facebook.svg" style="vertical-align:middle; width:32px; margin-left:2px; margin-right:2px;"/></td>
1095 + </tr>
1096 + <tr>
1097 + <th>Twitter (http://www.twitter.com/)</th>
1098 + <td><input type="text" style="width:300px;" placeholder="Exemple : tweet_heure" name="option_social1" id="option_social1" value="<?php echo get_option('option_social1'); ?>"/><img alt="twitter" src="<?php echo plugin_dir_url( __FILE__ ) ?>img/twitter.svg" style="vertical-align:middle; width:32px; margin-left:2px; margin-right:2px;"/></td>
1099 + </tr>
1100 + <tr>
1101 + <th>Google + (https://plus.google.com/u/0/+)</th>
1102 + <td><input type="text" style="width:300px;" placeholder="Exemple : goo.plus" name="option_social2" id="option_social2" value="<?php echo get_option('option_social2'); ?>"/><img alt="google" src="<?php echo plugin_dir_url( __FILE__ ) ?>img/google-plus.svg" style="vertical-align:middle; width:32px; margin-left:2px; margin-right:2px;"/></td>
1103 + </tr>
1104 + <tr>
1105 + <th>LinkedIn (https://www.linkedin.com/in/)</th>
1106 + <td><input type="text" style="width:300px;" placeholder="Exemple : link.dine" name="option_social3" id="option_social3" value="<?php echo get_option('option_social3'); ?>"/><img alt="linkedin" src="<?php echo plugin_dir_url( __FILE__ ) ?>img/linkedin.svg" style="vertical-align:middle; width:32px; margin-left:2px; margin-right:2px;"/></td>
1107 + </tr>
1108 + </table>
1109 + <?php
1110 + submit_button(__('Enregistrer','wp-hal'), 'primary large', 'submit', true); ?>
1111 + </div>
1112 + <div id="postbox-container-1" class="postbox-container">
1113 +
1114 + </div>
1115 + </div>
1116 + <br class="clear"><br/>
1117 + </div>
1118 + </form>
1119 +
1120 + </div>
1121 +
1122 +<?php
1123 +}
1124 +
1125 +
1126 +/**
1127 + * Reset les données Hal
1128 + */
1129 +function reset_option() {
1130 + delete_option('option_choix');
1131 + delete_option('option_type');
1132 + delete_option('option_groupe');
1133 + delete_option('option_idhal');
1134 + delete_option('option_lang');
1135 + delete_option('option_infocontact');
1136 + delete_option('option_email');
1137 + delete_option('option_tel');
1138 + delete_option('option_social0');
1139 + delete_option('option_social1');
1140 + delete_option('option_social2');
1141 + delete_option('option_social3');
1142 +}
1143 +?>