PluginProbe
HAL / 2.1.1
HAL v2.1.1
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
hal / trunk / wp-hal.php

wp-hal.php in HAL 2.1.1, at trunk/wp-hal.php

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