PluginProbe
HAL / 1.2
HAL v1.2
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.2, at wp-hal.php

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