PluginProbe
HAL / 2.3
HAL v2.3
trunk 1.0 1.1 1.2 1.3 1.4 1.4.2 1.4.3 1.4.4 2.0 2.0.1 2.0.10 2.0.2 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.2 2.3 2.4 2.4.1 2.4.2 2.5 All 30 releases
← All changes | wp-hal.php +52 -22 2.22.3 View file →
@@ -2,9 +2,9 @@
2 2 /**
3 3 * Plugin Name: HAL
4 4 * Plugin URI: http://www.ccsd.cnrs.fr
5 5 * Description: Crée une page qui remonte les publications d'un auteur ou d'une structure en relation avec HAL et un widget des dernières publications d'un auteur ou d'une structure.
6 - * Version: 2.2
6 + * Version: 2.3
7 7 * Author: CCSD
8 8 * Author URI: http://www.ccsd.cnrs.fr
9 9 * Text Domain: wp-hal
10 10 * Domain Path: /lang/
@@ -96,8 +96,9 @@
96 96 $wpdb->query($sql);
97 97 }
98 98
99 99 /**
100 + * fetches data from cache or download data from HAL API
100 101 * @param $url
101 102 * @return object
102 103 */
103 104 function wphal_do_get_data($url) {
@@ -152,9 +153,9 @@
152 153 $content = '';
153 154 if ( !wphal_is_curl_installed() ) {
154 155 $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';
155 156 } else {
156 - $possible_ids = ["authIdHal_s", "structId_i", "authStructId_i", "authId_i", "anrProjectId_i", "europeanProjectId_i", "collCode_s"];
157 + $possible_ids = ["authIdHal_s", "structId_i", "authStructId_i", "anrProjectId_i", "europeanProjectId_i", "collCode_s"];
157 158 $option_choix = !empty(get_option('option_choix')) ? get_option('option_choix') : [];
158 159 if(in_array('disciplines', $option_choix)){ //Lance les scripts pour le Graphique
159 160 wp_enqueue_style('wp-hal-style2');
160 161
@@ -407,9 +408,14 @@
407 408 if ($r > 10) {
408 409 break;
409 410 }
410 411 $name = explode(wphal_delimiter, $res[0]);
411 - $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=authId_i:' . $name[0] . "+AND+" . $type . ':(' . $id . ')').'" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
412 + if($name[0] == 0){
413 + $q = 'authLastNameFirstName_s:'.urlencode("\"".$name[1]."\"");
414 + }else{
415 + $q = "authIdPerson_i:$name[0]";
416 + }
417 + $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>';
412 418 }
413 419 $i = 1;
414 420 $content .= '<div id="auteursuite" style="display:none;">';
415 421 foreach ($json->facet_counts->facet_fields->authIdLastNameFirstName_fs as $res) {
@@ -419,9 +425,14 @@
419 425 if ($i < $r) {
420 426 $i = $i + 1;
421 427 } else {
422 428 $name = explode(wphal_delimiter, $res[0]);
423 - $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=authId_i:' . $name[0] . "+AND+" . $type . ':(' . $id . ')').'" target="_blank">' . $name[1] . '</a><span class="wphal-nbmetadata">' . $res[1] . '</span></li>';
429 + if($name[0] == 0){
430 + $q = 'authLastNameFirstName_s:'.urlencode("\"".$name[1]."\"");
431 + }else{
432 + $q = "authIdPerson_i:$name[0]";
433 + }
434 + $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>';
424 435 }
425 436 }
426 437 $content .= '</div>';
427 438 $content .= '</div>';
@@ -738,8 +749,29 @@
738 749 } else {
739 750 $content = '<div> no results !</div>';
740 751 }
741 752 if($total> $messagesParPage) {
753 + $base_url = ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on' ? 'https' : 'http' ) . '://' . $_SERVER['HTTP_HOST'];
754 + $url = $base_url . $_SERVER["REQUEST_URI"];
755 + $explodedURL= explode('?', $url);
756 + $queryString = $explodedURL[1];
757 + $pagedHref = $explodedURL[0];
758 + if(!empty($queryString)){
759 + $parsedQueryString = [];
760 + parse_str($queryString, $parsedQueryString);
761 + if(isset($parsedQueryString["hal_page"])){
762 + unset($parsedQueryString["hal_page"]);
763 + }
764 + $pagedHref .= '?';
765 + foreach($parsedQueryString as $name => $value){
766 + $pagedHref .= $name.'='.$value.'&';
767 + }
768 + // we add it back..
769 + $pagedHref .= 'hal_page=';
770 + }else {
771 + $pagedHref .= '?hal_page=';
772 + }
773 +
742 774 //--AFFICHAGE PAGINATION--//
743 775 $precedents = $pageActuelle - 2;
744 776 $suivants = $pageActuelle + 2;
745 777 $precedent = $pageActuelle - 1;
@@ -748,9 +780,9 @@
748 780
749 781 $content .= '<ul class="wphal-pagination">';
750 782 //--BOUTON PRECEDENT--//
751 783 if ( $pageActuelle != 1 ) {
752 - $content .= '<li><a href="?hal_page=' . $precedent . '">&laquo;</a></li>';
784 + $content .= '<li><a href="'. $pagedHref . $precedent . '">&laquo;</a></li>';
753 785 }
754 786 if ( $nombreDePages <= 6 ) {// Cas 1 : 6 pages ou moins - Pas de troncature
755 787 for ( $i = 1; $i <= $nombreDePages; $i ++ ) {
756 788 if ( $i == $pageActuelle ) {
@@ -755,9 +787,9 @@
755 787 for ( $i = 1; $i <= $nombreDePages; $i ++ ) {
756 788 if ( $i == $pageActuelle ) {
757 789 $content .= '<li class="active"><a href="#">' . $i . '</a></li>';
758 790 } else {
759 - $content .= ' <li><a href="?hal_page=' . $i . '">' . $i . '</a></li> ';
791 + $content .= ' <li><a href="'. $pagedHref . $i . '">' . $i . '</a></li> ';
760 792 }
761 793 }
762 794 } elseif ( $nombreDePages >= 7 ) {// Cas 2 : 7 pages ou plus - Troncature
763 795 if ( $pageActuelle <= 3 ) {// Lorsque l'on est sur les trois premières pages
@@ -764,35 +796,35 @@
764 796 for ( $i = 1; $i <= 4; $i ++ ) {
765 797 if ( $i == $pageActuelle ) {
766 798 $content .= '<li class="active"><a href="#">' . $i . '</a></li>';
767 799 } else {
768 - $content .= '<li><a href="?hal_page=' . $i . '">' . $i . '</a></li>';
800 + $content .= '<li><a href="'. $pagedHref . $i . '">' . $i . '</a></li>';
769 801 }
770 802 }
771 803 $content .= '<li class="disabled"><a href="#">&hellip;</a></li>';
772 - $content .= '<li><a href="?hal_page=' . $penultimate . '">' . $penultimate . '</a></li>';
773 - $content .= '<li><a href="?hal_page=' . $nombreDePages . '">' . $nombreDePages . '</a></li>';
804 + $content .= '<li><a href="'. $pagedHref . $penultimate . '">' . $penultimate . '</a></li>';
805 + $content .= '<li><a href="'. $pagedHref . $nombreDePages . '">' . $nombreDePages . '</a></li>';
774 806 }
775 807 if ( $pageActuelle >= 4 && $pageActuelle <= $penultimate - 2 ) {//Lorsque l'on arrive sur la quatrième page
776 - $content .= '<li><a href="?hal_page=">1</a></li>';
808 + $content .= '<li><a href="'.$pagedHref.'1">1</a></li>';
777 809 $content .= '<li class="disabled"><a href="#">&hellip;</a></li>';
778 - $content .= '<li><a href="?hal_page=' . $precedents . '">' . $precedents . '</a></li>';
779 - $content .= '<li><a href="?hal_page=' . $precedent . '">' . $precedent . '</a></li>';
810 + $content .= '<li><a href="'. $pagedHref . $precedents . '">' . $precedents . '</a></li>';
811 + $content .= '<li><a href="'. $pagedHref . $precedent . '">' . $precedent . '</a></li>';
780 812 $content .= '<li class="active"><a href="#">' . $pageActuelle . '</a></li>';
781 - $content .= '<li><a href="?hal_page=' . $suivant . '">' . $suivant . '</a></li>';
782 - $content .= '<li><a href="?hal_page=' . $suivants . '">' . $suivants . '</a></li>';
813 + $content .= '<li><a href="'. $pagedHref . $suivant . '">' . $suivant . '</a></li>';
814 + $content .= '<li><a href="'. $pagedHref . $suivants . '">' . $suivants . '</a></li>';
783 815 $content .= '<li class="disabled"><a href="#">&hellip;</a></li>';
784 - $content .= '<li><a href="?hal_page=' . $nombreDePages . '">' . $nombreDePages . '</a></li>';
816 + $content .= '<li><a href="'. $pagedHref . $nombreDePages . '">' . $nombreDePages . '</a></li>';
785 817 }
786 818 if ( $pageActuelle >= $penultimate - 1 ) {
787 - $content .= '<li><a href="?hal_page=1">1</a></li>';
788 - $content .= '<li><a href="?hal_page=2">2</a></li>';
819 + $content .= '<li><a href="'.$pagedHref.'1">1</a></li>';
820 + $content .= '<li><a href="'.$pagedHref.'2">2</a></li>';
789 821 $content .= '<li class="disabled"><a href="#">&hellip;</a></li>';
790 822 for ( $i = $penultimate - 2; $i <= $nombreDePages; $i ++ ) {
791 823 if ( $i == $pageActuelle ) {
792 824 $content .= '<li class="active"><a href="#">' . $i . '</a></li>';
793 825 } else {
794 - $content .= '<li><a href="?hal_page=' . $i . '">' . $i . '</a></li>';
826 + $content .= '<li><a href="'. $pagedHref . $i . '">' . $i . '</a></li>';
795 827 }
796 828 }
797 829 }
798 830 }
@@ -797,9 +829,9 @@
797 829 }
798 830 }
799 831 //--BOUTON SUIVANT--//
800 832 if ( $pageActuelle < $nombreDePages ) {
801 - $content .= '<li><a href="?hal_page=' . $suivant . '">&raquo;</a></li>';
833 + $content .= '<li><a href="'. $pagedHref . $suivant . '">&raquo;</a></li>';
802 834 }
803 835 $content .= '</ul>';
804 836 //--AFFICHAGE PAGINATION--//
805 837 }
@@ -810,9 +842,9 @@
810 842 }else{
811 843 $content = 'Plugin is not configured correctly or shortcode parameters are not valid, please check the <a href="https://doc.archives-ouvertes.fr/afficher-une-liste-de-publications-dans-wordpress/" target="_blank" id="wrong_params">documentation</a>';
812 844 }
813 845 $content .= '<div class="wphal-footer">';
814 - $content .= '<p style="color:#B3B2B0">' . __("Documents récupérés de l'archive ouverte HAL", 'wp-hal') . '&nbsp;<a href="' . wphal_site . '" target="_blank"><img alt="logo" src=" ' . esc_url(plugin_dir_url(__FILE__) . 'img/logo-hal.svg').'" style="width:32px;"></a></p>';
846 + $content .= '<p style="color:#B3B2B0">' . __("Documents récupérés de l'archive ouverte HAL", 'wp-hal') . '&nbsp;<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>';
815 847 $content .= '</div>';
816 848
817 849 //--AFFICHAGE GRAPHIQUE DOMAINE--//
818 850 if (!is_null($facetdomain)) {
@@ -1116,9 +1148,8 @@
1116 1148 <select id="<?php echo esc_attr($this->get_field_id("select"));?>" name="<?php echo esc_attr($this->get_field_name("select"));?>">
1117 1149 <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>
1118 1150 <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>
1119 1151 <option id="<?php echo esc_attr($this->get_field_id("AuthorStructId"));?>" value="authStructId_i" <?php echo esc_attr(($instance["select"] == "authStructId_i")?'selected':''); ?>><label for="<?php echo esc_attr($this->get_field_id("AuthorStructId"));?>">AuthorStruct Id</label><span style="font-style: italic;"> <?php echo esc_html(__('(Exemple : 413106)','wp-hal'));?></span></option>
1120 - <option id="<?php echo esc_attr($this->get_field_id("AuthorId"));?>" value="authId_i" <?php echo esc_attr(($instance["select"] == "authId_i")?'selected':''); ?>><label for="<?php echo esc_attr($this->get_field_id("AuthorId"));?>">Author Id</label><span style="font-style: italic;"> <?php echo esc_html(__('(Exemple : 413106)','wp-hal'));?></span></option>
1121 1152 <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>
1122 1153 <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>
1123 1154 <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>
1124 1155 </select>
@@ -1234,9 +1265,8 @@
1234 1265 <td><select name="option_type">
1235 1266 <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>
1236 1267 <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>
1237 1268 <option id="AuthorStructId" value="authStructId_i" <?php echo esc_attr(((get_option('option_type') == "authStructId_i")?'selected':'')); ?>><label for="AuthorStructId">AuthorStruct Id</label><span style="font-style: italic;"> <?php echo esc_html(__('(Exemple : 413106)','wp-hal'));?></span></option>
1238 - <option id="AuthorId" value="authId_i" <?php echo esc_attr(((get_option('option_type') == "authId_i")?'selected':'')); ?>><label for="AuthorId">Author Id</label><span style="font-style: italic;"> <?php echo esc_html(__('(Exemple : 413106)','wp-hal'));?></span></option>
1239 1269 <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>
1240 1270 <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>
1241 1271 <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>
1242 1272 </select>