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