PluginProbe
HAL / 2.0
HAL v2.0
trunk 1.0 1.1 1.2 1.3 1.4 1.4.2 1.4.3 1.4.4 2.0 2.0.1 2.0.10 2.0.2 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.2 2.3 2.4 2.4.1 2.4.2 2.5 All 30 releases
← All changes | wp-hal.php +100 -11 1.4.42.0 View file →
@@ -2,9 +2,9 @@
2 2 /**
3 3 * Plugin Name: HAL
4 4 * Plugin URI: http://www.ccsd.cnrs.fr
5 5 * Description: Crée une page qui remonte les publications d'un auteur ou d'une structure en relation avec HAL et un widget des dernières publications d'un auteur ou d'une structure.
6 - * Version: 1.4.4
6 + * Version: 2.0
7 7 * Author: Baptiste Blondelle
8 8 * Author URI: http://www.ccsd.cnrs.fr
9 9 * Text Domain: wp-hal
10 10 * Domain Path: /lang/
@@ -27,8 +27,9 @@
27 27 }
28 28
29 29 // Création du shortcode ('nom du shortcode', 'fonction appelée')
30 30 add_shortcode( 'cv-hal', 'cv_hal' );
31 +add_shortcode( 'nb-doc', 'nb_doc' );
31 32
32 33
33 34 function charger_languages() {
34 35 load_plugin_textdomain('wp-hal', false, dirname(plugin_basename(__FILE__)) . '/lang/');
@@ -51,10 +52,42 @@
51 52 add_filter( 'plugin_action_links', 'hal_plugin_action_links',10,2);
52 53
53 54
54 55 /***********************************************************************************************************************
55 - * PLUGIN SHORTCODE
56 + * PLUGIN SHORTCODE ND-DOC
56 57 **********************************************************************************************************************/
58 +function nb_doc($param)
59 +{
60 + $idhal = verifSolr(get_option('option_idhal'));
61 + extract(shortcode_atts(array(
62 + 'type' => get_option('option_type'),
63 + 'id' => $idhal
64 + ),
65 + $param
66 + ));
67 + $id = verifSolr($id);
68 +
69 + $url = api . '?q=*:*&fq=' . $type . ':(' . urlencode($id) . ')&rows=0&wt=json';
70 + $ch = curl_init($url);
71 + // Options
72 + $options = array(
73 + CURLOPT_RETURNTRANSFER => true,
74 + CURLOPT_HTTPHEADER => array('Content-type: application/json'),
75 + CURLOPT_TIMEOUT => 10,
76 + CURLOPT_USERAGENT => "HAL Plugin Wordpress " . version
77 + );
78 +
79 + // Bind des options et de l'objet cURL que l'on va utiliser
80 + curl_setopt_array($ch, $options);
81 + // Récupération du résultat JSON
82 + $json = json_decode(curl_exec($ch));
83 + curl_close($ch);
84 +
85 + return $json->response->numFound;
86 +}
87 +/***********************************************************************************************************************
88 + * PLUGIN SHORTCODE CV-HAL
89 + **********************************************************************************************************************/
57 90 function cv_hal($param){
58 91 if ( !function_exists('curl_init' ) ) {
59 92 echo 'Please check the';?> <a href="https://wordpress.org/plugins/hal/faq/" target="_blank" id="curl">FAQ</a><?php echo ' with the code : CURL';
60 93 } else {
@@ -61,9 +94,10 @@
61 94 if (get_option('option_idhal') != '') {
62 95 $idhal = verifSolr(get_option('option_idhal'));
63 96 extract(shortcode_atts(array(
64 97 'type' => get_option('option_type'),
65 - 'id' => $idhal
98 + 'id' => $idhal,
99 + 'contact' => get_option('option_infocontact')
66 100 ),
67 101 $param
68 102 ));
69 103 $id = verifSolr($id);
@@ -154,8 +188,58 @@
154 188 <h3 class="wphal-titre">' . __('Contact', 'wp-hal');
155 189 $content .= '</h3>
156 190
157 191 <ul id="wphal-cont" style="list-style-type: none;">';
192 +
193 + if ($contact == 'yes' && $type == 'authIdHal_s') {
194 + $urlauthor = urlauthor.'?indent=true&fq=valid_s:VALID&fl=idref_s,url_s,email_s,fullName_s,arxiv_s,idHal_s,viaf_s,isni_s,orcid_s,hasCV_bool&q=idHal_s:'.urlencode($id);
195 + $ch = curl_init($urlauthor);
196 + // Options
197 + $options = array(
198 + CURLOPT_RETURNTRANSFER => true,
199 + CURLOPT_HTTPHEADER => array('Content-type: application/json'),
200 + CURLOPT_TIMEOUT => 10,
201 + CURLOPT_USERAGENT => "HAL Plugin Wordpress " . version
202 + );
203 +
204 + // Bind des options et de l'objet cURL que l'on va utiliser
205 + curl_setopt_array($ch, $options);
206 + // Récupération du résultat JSON
207 + $jsonauthor = json_decode(curl_exec($ch));
208 + curl_close($ch);
209 +
210 + for ($i = 0; $jsonauthor->response->docs[$i] != ''; $i++) {
211 + $content .= '<div class="wphal-infocontact" id="wphal-infocontact'.$i.'">';
212 + if ($jsonauthor->response->docs[$i]->fullName_s != '') {
213 + $content .= '<li class="wphal-fullname"><span>Nom : </span><span>'. $jsonauthor->response->docs[$i]->fullName_s .'</span></li>';
214 + }
215 + if ($jsonauthor->response->docs[$i]->email_s != '') {
216 + $content .= '<li class="wphal-email"><span>Email : </span><span><a href="mailto:'. $jsonauthor->response->docs[$i]->email_s .'">' . $jsonauthor->response->docs[$i]->email_s . '</a></span></li>';
217 + }
218 + if ($jsonauthor->response->docs[$i]->idHal_s != '') {
219 + $content .= '<li class="wphal-idhal"><span>IdHAL : </span><span>' . $jsonauthor->response->docs[$i]->idHal_s . '</span></li>';
220 + }
221 + if ($jsonauthor->response->docs[$i]->hasCV_bool == true){
222 + $content .= '<li class="wphal-cvhal"><span>CV HAL : </span><a href="'.cvhal. $jsonauthor->response->docs[$i]->idHal_s.'" target="_blank">CV de '.$jsonauthor->response->docs[$i]->fullName_s.'</a></li>';
223 + }
224 + if ($jsonauthor->response->docs[$i]->arxiv_s != '') {
225 + $content .= '<li class="wphal-"><span>arXiv : </span><span><a href="' . $jsonauthor->response->docs[$i]->arxiv_s . '" target="_blank">' . substr(strrchr($jsonauthor->response->docs[$i]->arxiv_s, "/"), 1) . '</a></span></li>';
226 + }
227 + if ($jsonauthor->response->docs[$i]->idref_s != '') {
228 + $content .= '<li class="wphal-"><span>IdRef : </span><span><a href="' . $jsonauthor->response->docs[$i]->idref_s . '" target="_blank">' . substr(strrchr($jsonauthor->response->docs[$i]->idref_s, "/"), 1) . '</a></span></li>';
229 + }
230 + if ($jsonauthor->response->docs[$i]->orcid_s != '') {
231 + $content .= '<li class="wphal-"><span>ORCID : </span><span><a href="' . $jsonauthor->response->docs[$i]->orcid_s . '" target="_blank">' . substr(strrchr($jsonauthor->response->docs[$i]->orcid_s, "/"), 1) . '</a></span></li>';
232 + }
233 + if ($jsonauthor->response->docs[$i]->viaf_s != '') {
234 + $content .= '<li class="wphal-"><span>VIAF : </span><span><a href="' . $jsonauthor->response->docs[$i]->viaf_s . '" target="_blank">' . substr(strrchr($jsonauthor->response->docs[$i]->viaf_s, "/"), 1) . '</a></span></li>';
235 + }
236 + if ($jsonauthor->response->docs[$i]->isni_s != '') {
237 + $content .= '<li class="wphal-"><span>ISNI : </span><span><a href="' . $jsonauthor->response->docs[$i]->isni_s . '" target="_blank">' . substr(strrchr($jsonauthor->response->docs[$i]->isni_s, "/"), 1) . '</a></span></li>';
238 + }
239 + $content .= '</div>';
240 + }
241 + }
158 242 if (get_option('option_email') != '') {
159 243 $content .= '<li><img alt="mail" src=" ' . plugin_dir_url(__FILE__) . 'img/mail.svg" style=" width:16px; margin-left:2px; margin-right:2px;"/><a href="mailto:' . get_option('option_email') . '" target="_blank">' . get_option('option_email') . '</a></li>';
160 244 }
161 245 if (get_option('option_tel') != '') {
@@ -161,18 +245,18 @@
161 245 if (get_option('option_tel') != '') {
162 246 $content .= '<li><img alt="phone" src=" ' . plugin_dir_url(__FILE__) . 'img/phone.svg" style="width:16px; margin-left:2px; margin-right:2px;"/>' . get_option('option_tel') . '</li>';
163 247 }
164 248 if (get_option('option_social0') != '') {
165 - $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>';
249 + $content .= '<li><a href="http://www.facebook.com/' . get_option('option_social0') . '" target="_blank"><img src=" ' . plugin_dir_url(__FILE__) . 'img/facebook.svg" style="width:32px; margin:4px;"/></a></li>';
166 250 }
167 251 if (get_option('option_social1') != '') {
168 - $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>';
252 + $content .= '<li><a href="http://www.twitter.com/' . get_option('option_social1') . '" target="_blank"><img src=" ' . plugin_dir_url(__FILE__) . 'img/twitter.svg" style="width:32px; margin:4px;"/></a></li>';
169 253 }
170 254 if (get_option('option_social2') != '') {
171 - $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>';
255 + $content .= '<li><a href="https://plus.google.com/u/0/+' . get_option('option_social2') . '" target="_blank"><img src=" ' . plugin_dir_url(__FILE__) . 'img/google-plus.svg" style="width:32px; margin:4px;"/></a></li>';
172 256 }
173 257 if (get_option('option_social3') != '') {
174 - $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>';
258 + $content .= '<li><a href="https://www.linkedin.com/in/' . get_option('option_social3') . '" target="_blank"><img src=" ' . plugin_dir_url(__FILE__) . 'img/linkedin.svg" style="width:32px; margin:4px;"/></a></li>';
175 259 }
176 260 $content .= '</ul>
177 261 </div>
178 262 <div class="display" id="wphal-disciplines" style="display: none;">
@@ -922,9 +1006,9 @@
922 1006 register_setting( 'wphal_option', 'option_type' );
923 1007 register_setting( 'wphal_option', 'option_groupe' );
924 1008 register_setting( 'wphal_option', 'option_idhal' );
925 1009 register_setting( 'wphal_option', 'option_lang' );
926 - register_setting( 'wphal_option', 'option_css' );
1010 + register_setting( 'wphal_option', 'option_infocontact' );
927 1011 register_setting( 'wphal_option', 'option_email' );
928 1012 register_setting( 'wphal_option', 'option_tel' );
929 1013 register_setting( 'wphal_option', 'option_social0' );
930 1014 register_setting( 'wphal_option', 'option_social1' );
@@ -990,13 +1074,18 @@
990 1074 </tr>
991 1075 <tr valign="top">
992 1076 <th scope="row" style="font-size: 18px;"><?php echo __('Contact :','wp-hal');?></th>
993 1077 </tr>
994 - <tr valign="top">
1078 + <tr>
1079 + <th scope="row"><?php echo __("Afficher les informations d'un chercheur ayant un IdHal ?",'wp-hal');?></th>
1080 + <td><input type="radio" name="option_infocontact" id="wphal-yes" value="yes" <?php echo (get_option('option_infocontact') == "yes")?'checked':''; ?>><label for="wphal-yes"><?php echo __("Oui",'wp-hal')?></label><br>
1081 + <input type="radio" name="option_infocontact" id="wphal-no" value="no" <?php echo (get_option('option_infocontact') == "no")?'checked':''; ?>><label for="wphal-no"><?php echo __("Non",'wp-hal')?></label><br>
1082 + </td>
1083 + <tr>
995 1084 <th scope="row"><?php echo __('Email','wp-hal');?></th>
996 1085 <td><input type="text" style="width:300px;" placeholder="Exemple : hi@mail.com" name="option_email" id="option_email" value="<?php echo get_option('option_email'); ?>"/><img alt="email" src="<?php echo plugin_dir_url( __FILE__ ) ?>img/mail.svg" style="vertical-align:middle; width:32px; margin-left:2px; margin-right:2px;"/></td>
997 1086 </tr>
998 - <tr valign="top">
1087 + <tr>
999 1088 <th scope="row"><?php echo __('Téléphone','wp-hal');?></th>
1000 1089 <td><input type="text" style="width:300px;" placeholder="Exemple : 06-01-02-03-04" name="option_tel" id="option_tel" value="<?php echo get_option('option_tel');?>"/><img alt="phone" src="<?php echo plugin_dir_url( __FILE__ ) ?>img/phone.svg" style="vertical-align:middle; width:32px; margin-left:2px; margin-right:2px;"/></td>
1001 1090 </tr>
1002 1091 <tr>
@@ -1041,9 +1130,9 @@
1041 1130 delete_option('option_type');
1042 1131 delete_option('option_groupe');
1043 1132 delete_option('option_idhal');
1044 1133 delete_option('option_lang');
1045 - delete_option('option_css');
1134 + delete_option('option_infocontact');
1046 1135 delete_option('option_email');
1047 1136 delete_option('option_tel');
1048 1137 delete_option('option_social0');
1049 1138 delete_option('option_social1');