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