Ignore:
Timestamp:
Mar 24, 2012, 4:47:28 PM (9 years ago)
Author:
bystrano@…
Message:

ajoute la possibilite de declancher soit meme les remplacements des divs + regle probleme avec sites multilingues.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • _plugins_/ajax_nav/ajax_nav_insert_head.php

    r58261 r59686  
    22function ajax_nav_insert_head($flux) {
    33
    4   $options = unserialize($GLOBALS['meta']['ajax_nav_config']);
     4  $res = sql_select('valeur', 'spip_meta', 'nom="ajax_nav_config"');
     5  $options = array();
     6  if (sql_count($res) == 1) {
     7    $options = sql_fetch($res);
     8    $options = unserialize($options['valeur']);
    59
    6   function prepare($options) {
    7     $options = preg_replace("/[^a-zA-Z0-9\-\_]+/", "', ", $options);
    8     $options = preg_replace("/([a-zA-Z0-9\-\_]+)/", "'$1", $options);
    9     $options = preg_replace("/([^'])$/", "$1'", $options);
    10     return $options;
     10    /* evite les problemes lors de mises a jour du plugin */
     11    if ( ! $options['autoReplaceDivs'] ) {
     12      $options['autoReplaceDivs'] = 'on';
     13    }
     14  }
     15
     16  function prepare($option) {
     17    $option = preg_replace("/[^a-zA-Z0-9\-\_]+/", "', ", $option);
     18    $option = preg_replace("/([a-zA-Z0-9\-\_]+)/", "'$1", $option);
     19    $option = preg_replace("/([^'])$/", "$1'", $option);
     20    return $option;
    1121  }
    1222
     
    2030    $flux .= "<script type='text/javascript' src='" . find_in_path("lib/modernizr.js") . "'></script>";
    2131  }
     32
     33  $auto_replace_divs = ($options["autoReplaceDivs"] == "on") ? 'true' : 'false';
    2234
    2335  $flux .= "<script type='text/javascript'>
     
    4254                    pagesToAjaxify: ["  . prepare($options["pagesToAjaxify"]) . "],
    4355                    ajaxDivs: ["        . prepare($options["ajaxDivs"]) . "],
    44                     localizedDivs: ["   . prepare($options["localizedDivs"]) . "]
     56                    localizedDivs: ["   . prepare($options["localizedDivs"]) . "],
     57                    autoReplaceDivs: "  . $auto_replace_divs . "
    4558                };
    4659                AjaxNav();
Note: See TracChangeset for help on using the changeset viewer.