PluginProbe
HAL / 1.1
HAL v1.1
trunk 1.0 1.1 1.2 1.3 1.4 1.4.2 1.4.3 1.4.4 2.0 2.0.1 2.0.10 2.0.2 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.2 2.3 2.4 2.4.1 2.4.2 2.5 All 30 releases
hal / wp-hal.php

wp-hal.php in HAL 1.1, at wp-hal.php

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