| @@ -2,39 +2,32 @@ | ||
| 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.5 | |
| 6 | + * Version: 2.7.2 | |
| 7 | 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 | |
| 20 | - | |
| 21 | -if (wphal_locale == 'fr_FR') { | |
| 22 | - define('wphal_lang', 'fr'); | |
| 23 | -} elseif (wphal_locale == 'es_ES') { | |
| 24 | - define('wphal_lang', 'es'); | |
| 25 | -} else { | |
| 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: | |
| 26 | 24 | define('wphal_lang', 'en'); |
| 27 | 25 | } |
| 28 | 26 | |
| 29 | 27 | function wphal_is_curl_installed() { |
| 30 | 28 | $loaded_extentions = get_loaded_extensions(); |
| 31 | - if (in_array ('curl', $loaded_extentions)) { | |
| 32 | - return true; | |
| 33 | - } | |
| 34 | - else { | |
| 35 | - return false; | |
| 36 | - } | |
| 29 | + return (bool) (in_array('curl', $loaded_extentions)); | |
| 37 | 30 | } |
| 38 | 31 | |
| 39 | 32 | // Création du shortcode ('nom du shortcode', 'fonction appelée') |
| 40 | 33 | add_shortcode( 'cv-hal', 'wphal_cv_hal' ); |
| @@ -39,9 +32,8 @@ | ||
| 39 | 32 | // Création du shortcode ('nom du shortcode', 'fonction appelée') |
| 40 | 33 | add_shortcode( 'cv-hal', 'wphal_cv_hal' ); |
| 41 | 34 | add_shortcode( 'nb-doc', 'wphal_nb_doc' ); |
| 42 | 35 | |
| 43 | - | |
| 44 | 36 | function wphal_charger_languages() { |
| 45 | 37 | load_plugin_textdomain('wp-hal', false, dirname(plugin_basename(__FILE__)) . '/lang/'); |
| 46 | 38 | } |
| 47 | 39 | |
| @@ -51,14 +43,13 @@ | ||
| 51 | 43 | if ( $file != plugin_basename( __FILE__ )) |
| 52 | 44 | return $links; |
| 53 | 45 | |
| 54 | 46 | $settings_link = '<a href="admin.php?page=wp-hal.php">' . __( 'Paramètres', 'wp-hal' ) . '</a>'; |
| 55 | - | |
| 56 | 47 | array_unshift( $links, $settings_link ); |
| 57 | - | |
| 58 | 48 | return $links; |
| 59 | 49 | } |
| 60 | 50 | |
| 51 | + | |
| 61 | 52 | add_filter( 'query_vars', 'wphal_query_vars' ); |
| 62 | 53 | function wphal_query_vars( $query_vars ) { |
| 63 | 54 | $query_vars[] = 'hal_page'; |
| 64 | 55 | return $query_vars; |
| @@ -86,9 +77,9 @@ | ||
| 86 | 77 | { |
| 87 | 78 | global $wpdb; |
| 88 | 79 | // delete all "hal namespace" transients |
| 89 | 80 | $sql = " |
| 90 | - DELETE | |
| 81 | + DELETE | |
| 91 | 82 | FROM {$wpdb->options} |
| 92 | 83 | WHERE option_name like '\_transient\_hal\_%' |
| 93 | 84 | OR option_name like '\_transient\_timeout\_hal\_%' |
| 94 | 85 | "; |
| @@ -110,10 +101,11 @@ | ||
| 110 | 101 | } |
| 111 | 102 | $cache_expiration = empty(get_option('option_cache_timeout')) ? 1 * DAY_IN_SECONDS : intval(get_option('option_cache_timeout')) * MINUTE_IN_SECONDS; |
| 112 | 103 | if ( false === ( $value = get_transient( $transient_id ) ) ) { |
| 113 | 104 | $json = wphal_do_common_curl_call($url); |
| 114 | - if($json) | |
| 115 | - set_transient( $transient_id, $json, $cache_expiration); | |
| 105 | + if ($json) { | |
| 106 | + set_transient($transient_id, $json, $cache_expiration); | |
| 107 | + } | |
| 116 | 108 | return $json; |
| 117 | 109 | } else{ |
| 118 | 110 | return $value; |
| 119 | 111 | } |
| @@ -143,8 +135,9 @@ | ||
| 143 | 135 | |
| 144 | 136 | $json =wphal_do_get_data($url); |
| 145 | 137 | return $json->response->numFound; |
| 146 | 138 | } |
| 139 | + | |
| 147 | 140 | /** |
| 148 | 141 | * PLUGIN SHORTCODE CV-HAL |
| 149 | 142 | * @param $param |
| 150 | 143 | * @return string |
| @@ -172,13 +165,25 @@ | ||
| 172 | 165 | // here we merge with shortcode parameters |
| 173 | 166 | extract(shortcode_atts(array( |
| 174 | 167 | 'type' => $default_type, |
| 175 | 168 | 'id' => $default_id, |
| 176 | - 'contact' => $default_contact | |
| 169 | + 'contact' => $default_contact, | |
| 170 | + 'doctype_s' => null, | |
| 171 | + 'debug' => false, | |
| 172 | + 'option_groupe' => get_option('option_groupe') | |
| 177 | 173 | ), |
| 178 | 174 | $param |
| 179 | 175 | )); |
| 180 | - $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>'; | |
| 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>'; | |
| 181 | 186 | |
| 182 | 187 | /** @var $id : defined by extract |
| 183 | 188 | * @var string $type : defined by extract |
| 184 | 189 | * @var string $contact : defined by extract |
| @@ -194,20 +199,35 @@ | ||
| 194 | 199 | |
| 195 | 200 | $facets = wphal_buildfacet($option_choix, $structIDs); |
| 196 | 201 | $facetQuery = !empty($facets) ? 'facet.field='.implode("&facet.field=", $facets).'&facet.limit=200&facet.mincount=1&facet=true':''; |
| 197 | 202 | |
| 198 | - if (get_option('option_groupe') == 'grouper') { | |
| 203 | + $url = wphal_api . '?q=*:*&fq=' . $type . ':(' . urlencode($id) . ')'; | |
| 204 | + if (!empty($doctype_s) && $doctype_s != "") { | |
| 205 | + $url .= '&fq=docType_s:('.$doctype_s.')'; | |
| 206 | + } | |
| 207 | + switch ($option_groupe) { | |
| 208 | + case 'grouper': | |
| 199 | 209 | //cURL sur l'API pour récupérer les données |
| 200 | - $url = wphal_api . '?q=*:*&fq=' . $type . ':(' . urlencode($id) . ')&group=true&group.field=docType_s&group.limit=1000&fl=docid,citationFull_s&'.$facetQuery.'&sort=' . wphal_producedDateY . '&wt=json&json.nl=arrarr'; | |
| 201 | - } elseif (get_option('option_groupe') == 'paginer') { | |
| 202 | - $url = wphal_api . '?q=*:*&fq=' . $type . ':(' . urlencode($id) . ')&fl=docid,citationFull_s&'.$facetQuery.'&sort=' . wphal_producedDateY . '&wt=json&json.nl=arrarr'; | |
| 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 | |
| 203 | 216 | } |
| 217 | + $url .= '&fl=docid,citationFull_s&'.$facetQuery.'&sort=' . wphal_producedDateY . '&wt=json&json.nl=arrarr'; | |
| 204 | 218 | |
| 205 | 219 | $json = wphal_do_get_data($url); |
| 206 | 220 | if(!isset($json->error)){ |
| 207 | - $hal_page = (get_query_var('hal_page')) ? get_query_var('hal_page') : 1; | |
| 208 | - | |
| 209 | - $content = '<div id="wphal-content">'; | |
| 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">'; | |
| 210 | 230 | if (is_array($option_choix) && !empty($option_choix)){ |
| 211 | 231 | $content .= '<ul id="wphal-menu">'; |
| 212 | 232 | $content .= '<li><a href="#publications" onclick="displayElem(\'publications\'); return false;" style="font-size:18px; text-decoration: none;">' . __('Publications', 'wp-hal') . '</a></li>'; |
| 213 | 233 | |
| @@ -259,9 +279,8 @@ | ||
| 259 | 279 | $content .= '</a></li>'; |
| 260 | 280 | } |
| 261 | 281 | } |
| 262 | 282 | $content .= '</ul></li>'; |
| 263 | - | |
| 264 | 283 | $content .= '</ul><br/><hr>'; |
| 265 | 284 | } |
| 266 | 285 | |
| 267 | 286 | $content .= '<div id="meta"> |
| @@ -387,15 +406,15 @@ | ||
| 387 | 406 | $r = 0; |
| 388 | 407 | // CSS Nuage de mots |
| 389 | 408 | $maxsize = 25; |
| 390 | 409 | $minsize = 10; |
| 391 | - $maxval = max(array_values($json->facet_counts->facet_fields->keyword_s[1])); | |
| 392 | - $minval = min(array_values($json->facet_counts->facet_fields->keyword_s[1])); | |
| 393 | - if(!is_numeric($minval)) {$minval = 0;} | |
| 394 | - if(!is_numeric($maxval)) {$maxval = 0;} | |
| 395 | - $spread = ($maxval - $minval); | |
| 396 | - $step = ($maxsize - $minsize) / $spread; | |
| 397 | - $tab = array(); | |
| 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 = []; | |
| 398 | 417 | foreach ($json->facet_counts->facet_fields->keyword_s as $res) { |
| 399 | 418 | $r = $r + 1; |
| 400 | 419 | if ($r > 20) { |
| 401 | 420 | break; |
| @@ -476,9 +495,9 @@ | ||
| 476 | 495 | } |
| 477 | 496 | $content .= '</div> |
| 478 | 497 | <div class="display" id="wphal-affiliated" style="display: none;"> |
| 479 | 498 | <h3 class="wphal-titre">' . __('Auteurs de la structure', 'wp-hal') . '</h3>'; |
| 480 | - $parsed_facetfield = wphal_parse_affiliation_facet($json->facet_counts->facet_fields, $structIDs); | |
| 499 | + $parsed_facetfield = isset($json->facet_counts->facet_fields) ? wphal_parse_affiliation_facet($json->facet_counts->facet_fields, $structIDs) : []; | |
| 481 | 500 | if (!empty($parsed_facetfield)) { |
| 482 | 501 | $content .= '<span id="triauteurs">'; |
| 483 | 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>'; |
| 484 | 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>'; |
| @@ -769,19 +788,20 @@ | ||
| 769 | 788 | } |
| 770 | 789 | } |
| 771 | 790 | $content .= '</div> |
| 772 | 791 | <div class="display" id="publications">'; |
| 773 | - if (get_option('option_groupe') == 'grouper') { | |
| 774 | - $doctype = file_get_contents(plugin_dir_path( __FILE__ ).'json'. DIRECTORY_SEPARATOR .'doctype_fr.json'); | |
| 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'); | |
| 775 | 795 | $jsontype = json_decode($doctype); |
| 776 | 796 | |
| 777 | 797 | //LISTE DES DOCUMENTS PAR GROUPE |
| 778 | 798 | |
| 779 | 799 | $content .= '<div class="counter-doc"><span class="wphal-nbtot">' . $json->grouped->docType_s->matches . ' </span>'; |
| 780 | - $content .= __('documents', 'wp-hal'). '</div><br>'; | |
| 800 | + $content .= __('documents', 'wp-hal') . '</div><br>'; | |
| 781 | 801 | for ($i = 0; !empty($jsontype->response->result->doc[$i]); $i++) { |
| 782 | 802 | for ($d = 0; !empty($json->grouped->docType_s->groups[$d]); $d++) { |
| 783 | - if ($json->grouped->docType_s->groups[$d]->groupValue == $jsontype->response->result->doc[$i]->str[0]){ | |
| 803 | + if ($json->grouped->docType_s->groups[$d]->groupValue == $jsontype->response->result->doc[$i]->str[0]) { | |
| 784 | 804 | $titre = $jsontype->response->result->doc[$i]->str[1]; |
| 785 | 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>'; |
| 786 | 806 | $content .= '<div class="grp-content">'; |
| 787 | 807 | $content .= '<ul>'; |
| @@ -793,13 +813,13 @@ | ||
| 793 | 813 | break; |
| 794 | 814 | } |
| 795 | 815 | } |
| 796 | 816 | } |
| 797 | - } elseif (get_option('option_groupe') == 'paginer') { | |
| 817 | + } elseif ($option_groupe == 'paginer') { | |
| 798 | 818 | |
| 799 | 819 | //LISTE DES DOCUMENTS AVEC PAGINATION |
| 800 | 820 | $content .= '<div class="counter-doc"><span class="wphal-nbtot">' . $json->response->numFound . ' </span>'; |
| 801 | - $content .= __('documents', 'wp-hal'). '</div><br>'; | |
| 821 | + $content .= __('documents', 'wp-hal') . '</div><br>'; | |
| 802 | 822 | |
| 803 | 823 | //--MODULE PAGINATION--// |
| 804 | 824 | $messagesParPage = 10; |
| 805 | 825 | |
| @@ -818,109 +838,115 @@ | ||
| 818 | 838 | } |
| 819 | 839 | $premiereEntree = ($pageActuelle - 1) * $messagesParPage; |
| 820 | 840 | |
| 821 | 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 | + } | |
| 822 | 845 | $json = wphal_do_get_data($url); |
| 823 | 846 | |
| 824 | 847 | //--MODULE PAGINATION--// |
| 825 | - $count_results = count($json->response->docs); | |
| 826 | - if($count_results>0) { | |
| 827 | - $content .= '<ul>'; | |
| 828 | - for ( $i = 0; $i <= $count_results - 1; $i ++ ) { | |
| 829 | - $content .= '<li>' . $json->response->docs[ $i ]->citationFull_s . '</li>'; | |
| 830 | - } | |
| 831 | - $content .= '</ul>'; | |
| 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>'; | |
| 832 | 855 | } else { |
| 833 | - $content = '<div> no results !</div>'; | |
| 856 | + $content = '<div> no results !</div>'; | |
| 834 | 857 | } |
| 835 | - if($total> $messagesParPage) { | |
| 836 | - $base_url = ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on' ? 'https' : 'http' ) . '://' . $_SERVER['HTTP_HOST']; | |
| 858 | + if ($total > $messagesParPage) { | |
| 859 | + $base_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST']; | |
| 837 | 860 | $url = $base_url . $_SERVER["REQUEST_URI"]; |
| 838 | - $explodedURL= explode('?', $url); | |
| 839 | - $queryString = isset($explodedURL[1])?$explodedURL[1]:""; | |
| 861 | + $explodedURL = explode('?', $url); | |
| 862 | + $queryString = isset($explodedURL[1]) ? $explodedURL[1] : ""; | |
| 840 | 863 | $pagedHref = $explodedURL[0]; |
| 841 | - if(!empty($queryString)){ | |
| 864 | + if (!empty($queryString)) { | |
| 842 | 865 | $parsedQueryString = []; |
| 843 | 866 | parse_str($queryString, $parsedQueryString); |
| 844 | - if(isset($parsedQueryString["hal_page"])){ | |
| 867 | + if (isset($parsedQueryString["hal_page"])) { | |
| 845 | 868 | unset($parsedQueryString["hal_page"]); |
| 846 | 869 | } |
| 847 | 870 | $pagedHref .= '?'; |
| 848 | - foreach($parsedQueryString as $name => $value){ | |
| 849 | - $pagedHref .= $name.'='.$value.'&'; | |
| 871 | + foreach ($parsedQueryString as $name => $value) { | |
| 872 | + $pagedHref .= $name . '=' . $value . '&'; | |
| 850 | 873 | } |
| 851 | 874 | // we add it back.. |
| 852 | 875 | $pagedHref .= 'hal_page='; |
| 853 | - }else { | |
| 876 | + } else { | |
| 854 | 877 | $pagedHref .= '?hal_page='; |
| 855 | 878 | } |
| 856 | 879 | |
| 857 | - //--AFFICHAGE PAGINATION--// | |
| 858 | - $precedents = $pageActuelle - 2; | |
| 859 | - $suivants = $pageActuelle + 2; | |
| 860 | - $precedent = $pageActuelle - 1; | |
| 861 | - $suivant = $pageActuelle + 1; | |
| 880 | + //--AFFICHAGE PAGINATION--// | |
| 881 | + $precedents = $pageActuelle - 2; | |
| 882 | + $suivants = $pageActuelle + 2; | |
| 883 | + $precedent = $pageActuelle - 1; | |
| 884 | + $suivant = $pageActuelle + 1; | |
| 862 | 885 | $penultimate = $nombreDePages - 1; |
| 863 | 886 | |
| 864 | 887 | $content .= '<ul class="wphal-pagination">'; |
| 865 | - //--BOUTON PRECEDENT--// | |
| 866 | - if ( $pageActuelle != 1 ) { | |
| 867 | - $content .= '<li><a href="'. $pagedHref . $precedent . '">«</a></li>'; | |
| 888 | + //--BOUTON PRECEDENT--// | |
| 889 | + if ($pageActuelle != 1) { | |
| 890 | + $content .= '<li><a href="' . $pagedHref . $precedent . '">«</a></li>'; | |
| 868 | 891 | } |
| 869 | - if ( $nombreDePages <= 6 ) {// Cas 1 : 6 pages ou moins - Pas de troncature | |
| 870 | - for ( $i = 1; $i <= $nombreDePages; $i ++ ) { | |
| 871 | - if ( $i == $pageActuelle ) { | |
| 892 | + if ($nombreDePages <= 6) {// Cas 1 : 6 pages ou moins - Pas de troncature | |
| 893 | + for ($i = 1; $i <= $nombreDePages; $i++) { | |
| 894 | + if ($i == $pageActuelle) { | |
| 872 | 895 | $content .= '<li class="active"><a href="#">' . $i . '</a></li>'; |
| 873 | 896 | } else { |
| 874 | - $content .= ' <li><a href="'. $pagedHref . $i . '">' . $i . '</a></li> '; | |
| 897 | + $content .= ' <li><a href="' . $pagedHref . $i . '">' . $i . '</a></li> '; | |
| 875 | 898 | } |
| 876 | 899 | } |
| 877 | - } elseif ( $nombreDePages >= 7 ) {// Cas 2 : 7 pages ou plus - Troncature | |
| 878 | - if ( $pageActuelle <= 3 ) {// Lorsque l'on est sur les trois premières pages | |
| 879 | - for ( $i = 1; $i <= 4; $i ++ ) { | |
| 880 | - if ( $i == $pageActuelle ) { | |
| 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) { | |
| 881 | 904 | $content .= '<li class="active"><a href="#">' . $i . '</a></li>'; |
| 882 | 905 | } else { |
| 883 | - $content .= '<li><a href="'. $pagedHref . $i . '">' . $i . '</a></li>'; | |
| 906 | + $content .= '<li><a href="' . $pagedHref . $i . '">' . $i . '</a></li>'; | |
| 884 | 907 | } |
| 885 | 908 | } |
| 886 | 909 | $content .= '<li class="disabled"><a href="#">…</a></li>'; |
| 887 | - $content .= '<li><a href="'. $pagedHref . $penultimate . '">' . $penultimate . '</a></li>'; | |
| 888 | - $content .= '<li><a href="'. $pagedHref . $nombreDePages . '">' . $nombreDePages . '</a></li>'; | |
| 910 | + $content .= '<li><a href="' . $pagedHref . $penultimate . '">' . $penultimate . '</a></li>'; | |
| 911 | + $content .= '<li><a href="' . $pagedHref . $nombreDePages . '">' . $nombreDePages . '</a></li>'; | |
| 889 | 912 | } |
| 890 | - if ( $pageActuelle >= 4 && $pageActuelle <= $penultimate - 2 ) {//Lorsque l'on arrive sur la quatrième page | |
| 891 | - $content .= '<li><a href="'.$pagedHref.'1">1</a></li>'; | |
| 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>'; | |
| 892 | 915 | $content .= '<li class="disabled"><a href="#">…</a></li>'; |
| 893 | - $content .= '<li><a href="'. $pagedHref . $precedents . '">' . $precedents . '</a></li>'; | |
| 894 | - $content .= '<li><a href="'. $pagedHref . $precedent . '">' . $precedent . '</a></li>'; | |
| 916 | + $content .= '<li><a href="' . $pagedHref . $precedents . '">' . $precedents . '</a></li>'; | |
| 917 | + $content .= '<li><a href="' . $pagedHref . $precedent . '">' . $precedent . '</a></li>'; | |
| 895 | 918 | $content .= '<li class="active"><a href="#">' . $pageActuelle . '</a></li>'; |
| 896 | - $content .= '<li><a href="'. $pagedHref . $suivant . '">' . $suivant . '</a></li>'; | |
| 897 | - $content .= '<li><a href="'. $pagedHref . $suivants . '">' . $suivants . '</a></li>'; | |
| 919 | + $content .= '<li><a href="' . $pagedHref . $suivant . '">' . $suivant . '</a></li>'; | |
| 920 | + $content .= '<li><a href="' . $pagedHref . $suivants . '">' . $suivants . '</a></li>'; | |
| 898 | 921 | $content .= '<li class="disabled"><a href="#">…</a></li>'; |
| 899 | - $content .= '<li><a href="'. $pagedHref . $nombreDePages . '">' . $nombreDePages . '</a></li>'; | |
| 922 | + $content .= '<li><a href="' . $pagedHref . $nombreDePages . '">' . $nombreDePages . '</a></li>'; | |
| 900 | 923 | } |
| 901 | - if ( $pageActuelle >= $penultimate - 1 ) { | |
| 902 | - $content .= '<li><a href="'.$pagedHref.'1">1</a></li>'; | |
| 903 | - $content .= '<li><a href="'.$pagedHref.'2">2</a></li>'; | |
| 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>'; | |
| 904 | 927 | $content .= '<li class="disabled"><a href="#">…</a></li>'; |
| 905 | - for ( $i = $penultimate - 2; $i <= $nombreDePages; $i ++ ) { | |
| 906 | - if ( $i == $pageActuelle ) { | |
| 928 | + for ($i = $penultimate - 2; $i <= $nombreDePages; $i++) { | |
| 929 | + if ($i == $pageActuelle) { | |
| 907 | 930 | $content .= '<li class="active"><a href="#">' . $i . '</a></li>'; |
| 908 | 931 | } else { |
| 909 | - $content .= '<li><a href="'. $pagedHref . $i . '">' . $i . '</a></li>'; | |
| 932 | + $content .= '<li><a href="' . $pagedHref . $i . '">' . $i . '</a></li>'; | |
| 910 | 933 | } |
| 911 | 934 | } |
| 912 | 935 | } |
| 913 | 936 | } |
| 914 | - //--BOUTON SUIVANT--// | |
| 915 | - if ( $pageActuelle < $nombreDePages ) { | |
| 916 | - $content .= '<li><a href="'. $pagedHref . $suivant . '">»</a></li>'; | |
| 937 | + //--BOUTON SUIVANT--// | |
| 938 | + if ($pageActuelle < $nombreDePages) { | |
| 939 | + $content .= '<li><a href="' . $pagedHref . $suivant . '">»</a></li>'; | |
| 917 | 940 | } |
| 918 | 941 | $content .= '</ul>'; |
| 919 | - //--AFFICHAGE PAGINATION--// | |
| 942 | + //--AFFICHAGE PAGINATION--// | |
| 920 | 943 | } |
| 921 | 944 | } |
| 922 | - $content .= '</div> | |
| 945 | + } else { | |
| 946 | + $content .= '<div> empty response !</div>'; | |
| 947 | + } | |
| 948 | + $content .= '</div> | |
| 923 | 949 | </div> |
| 924 | 950 | </div>'; |
| 925 | 951 | }} |
| 926 | 952 | $content .= '<div class="wphal-footer">'; |