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