Changeset 18936


Ignore:
Timestamp:
Nov 5, 2012, 1:05:53 PM (11 years ago)
Author:
cljosse
Message:

[extensions] Autosize fix compatibility with 2.4 (fix bug init, compatibility look_like_gbo2)

Location:
extensions/Autosize
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/Autosize/autosize.inc.php

    r18925 r18936  
    939939                                    $maxi_image = $img_select;   
    940940                                                             
    941                        
     941                               $maxi_image->url  =  $maxi_image->get_path();
     942
    942943                            } else {
    943944                           
    944945                                $mini_image->type=$img_type;
    945946                                $mini_image->url=$img_url;
    946                                 $mini_image=$img_select;                     
     947                                $mini_image=$img_select; 
     948                               $mini_image->url  =  $mini_image->get_path();           
    947949                            }                         
    948950       
     
    968970        $retour->url=$retours[1];
    969971     }
    970  
    971 
     972
     973   if(preg_match("|get_infos|", $DEBUG_autosize, $val)) $infos_message .= $retour->type . " " . $retour->url ;
    972974  if (!isset( $retour->type)){     
    973975                  $retour=$last_image;
    974976                  $retour->type =  $retour->get_type();
    975977                  $retour->url  =  $retour->get_path();
     978               
    976979}
    977980if (isset( $retour->type) && $retour->type=="Original" ){     
     
    979982                  $retour->type =  $last_derivative;
    980983                  $retour->url  =  $retour->get_path();
    981 }
    982 
    983          if(preg_match("|get_minfos|", $DEBUG_autosize, $val))     $infos_message .= $pictureSelType . " -> " .  $retour->type . "---" . $retour->url. "<br >";
     984             
     985}
     986
     987
    984988
    985989      if($nofile > 0){ 
     
    988992
    989993
    990     if(preg_match("|get_minfos|", $DEBUG_autosize, $val))
     994    if(preg_match("|get_infos|", $DEBUG_autosize, $val))
    991995            $infos_message .=$pictureSelType . " -> " . $retour->type . " : "  . $retour->url  ."<br >";
    992996
  • extensions/Autosize/js/Affiche_script.js

    r18925 r18936  
    5858    //____________________ Save_cookies _____________________________
    5959    /************************************************
    60     *
     60    *  Get COOKIE
    6161    *************************************************/
    6262    Get_cookies = function () {
     
    170170      if (typeof options.cl_visible == "undefined") return;
    171171      if (typeof src1 == "undefined") return;
    172 
    173172      if (options.cl_visible) src = src1;
    174173      else src = src2;
    175174
     175      if (typeof options.pictureSelType != "undefined" && (options.pictureSelType == "Autosize" || options.pictureSelType == "SelMaxi")) {
     176        if (options.pictureSelType == "SelMaxi") src = src6;
     177      } else {
     178        Valid = false;
     179        src = src2;
     180        jQuery("#bp_cla span").text("");
     181      }
    176182      if (options.cl_visible) {
    177183        src_info = src3;
     
    181187        src_infos_1 = src5;
    182188      }
    183 
     189      src_info = options.pictureDeriv;
    184190      if (!Valid) {
    185191        Zone_image.image.height = Zone_image.image_init.height;
    186192        Zone_image.image.width = Zone_image.image_init.width;
    187         src = src6;
     193
    188194      }
    189195      if ((typeof Zone_image != "undefined") && typeof Zone_image.image != "undefined") {
    190 
    191196        Zone_image.zoom = (Zone_image.image.height / Zone_image.image_init.height);
    192197        zoom_cl = parseInt(100 * Zone_image.zoom) + "%"; ;
    193 
    194198        if (!Valid) {
    195199          if (options.pictureSelType == "SelMaxi")
    196200            zoom_cl = options.pictureSelType + " [" + options.pictureDeriv + "]";
    197           else
    198             zoom_cl = " [" + options.pictureDeriv + "]";
    199 
    200         } else
    201 
    202 
    203           jQuery('#bp_cla').attr('alt', src_info);
     201          else {
     202            zoom_cl = "";
     203            src_info = options.pictureDeriv;
     204          }
     205        }
     206        jQuery('#bp_cla').attr('alt', src_info);
    204207        jQuery('#bp_cla').attr('title', src_info);
    205208        jQuery('#bp_cla').attr('Stitle', src_info);
     
    209212          rap_init: Zone_image.image_init.rapport
    210213        }
    211 
    212 
    213214        jQuery('#bp_cla span').text(zoom_cl);
    214215        color_back = jQuery('#imageToolBar').css("backgroundColor");
     
    251252
    252253    /********************************
    253     * Set__bgo
     254    * Set__llbgo
    254255    *********************************/
    255256    Set_llbgo = function (Force) {
    256257
    257       if (marges_llgbo == 0) return;
     258      if (options.marges_llgbo == 0) return;
    258259      if (Type_Img == "pamoorama") {
    259260
     
    470471    ********************************************/
    471472    jQuery(window).unload(function () {
    472       return;
     473    //  return;
    473474    });
    474475    //_________ unload ___________
     
    596597    spans.next().text(options.pictureDeriv);
    597598    //==========================================================
    598 
    599599    /*
    600 
    601 
    602600    jQuery('#derivativeCheckedAutosize').hide();
    603601    jQuery('#derivativeCheckedAutosize').next().hide();
    604602    jQuery('#derivativeCheckedAutosize').next().next().hide();
    605603    */
    606 
    607 
    608604    //=============================================================
    609605    // REPONSE ACTION
    610606    //=============================================================
    611607    theMainImage_st = false;
    612 
    613 
    614     /***********************
    615     *
    616     **********************/
    617     jQuery("#theMainImage," + theMainImage_id + ",.preload, .next1 , ")
    618         .load(function (e) {
    619           src = this.src;
    620           theMainImage_st = true;
    621           if (typeof Zone_image == "undefined") {
    622             Zone_image = {};
    623           }
    624           Zone_image.image_init = { width: this.width, height: this.height, rapport: this.width / this.height };
    625           if (!init_img(this)) {
    626             nu_img = 0;
    627           }
    628 
    629         })
    630          .error(function (e) {
    631            if (!this.complete) {
    632              src = jQuery(this).attr("src").replace("./_data/i/", "", 1);
    633              jQuery.ajax({
    634                type: 'GET',
    635                url: 'i.php?' + src + "&ajaxload=true",
    636                dataType: 'json',
    637                success: (function (data) {
    638                  j = data;
    639                })
    640 
    641              });
    642 
    643 
    644 
    645            }
    646 
    647          })
    648          .bind("Finish", function (e, data) {
    649            if (typeof imageInfos_id == "undefined") return;
    650 
    651          })
    652           .bind("ON", function (e, data) {
    653             if (data.status != "ok") {
    654               popup = jQuery(".errors");
    655               if (popup.length == 0) {
    656                 jQuery("#theImage").append("<div class='errors'><span></span></div>");
    657               }
    658               jQuery(".errors").text("Erreur : [" + data.done + "] " + data.responseText);
    659               jQuery(".errors").show().delay(10000).hide(2000);
    660               return;
    661             }
    662             if (data.src) {
    663               if (typeof imageInfos_id == "undefined") return;
    664               if (data.src.match(RegExp(options.pictureDeriv.substr(0, 2) + ".jpg", "gi"))) {
    665                 //   Autosize_resize(true, options);
    666               }
    667             }
    668           });
    669 
    670 
    671     ;
    672 
    673 
    674 
    675 
    676     ;
    677     //_________ theMainImage  ___________
    678 
    679 
    680608    jQuery("#reset").click(function () {
    681609      location.reload();
     
    850778        // options.pictureDeriv = retour.pictureDeriv;
    851779        options.pictureSelType = retour.pictureSelType;
    852         options.pictureMap = options.pictureDeriv;
    853 
     780        options.pictureDeriv = retour.pictureDeriv;
     781        options.pictureMap = retour.pictureDeriv;
    854782
    855783        if (this.name) {
    856784          options.pictureSelType = this.name;
    857785          n = Get_dimensions(true, options);
    858 
    859 
    860 
    861786        } else {
    862 
    863 
    864787        }
    865788
     
    872795          jQuery(".auto_details").text("");
    873796        }
     797        Autosize_resize(true, options);
    874798      }
    875799    });
     
    889813      return;
    890814    });
    891     //____________________ set_llgbo _____________________________
     815
    892816
    893817    //====================================
     
    927851      Save_cookies(options);
    928852      if (options.pictureSelType != "Autosize" && options.pictureSelType != "SelMaxi") {
     853        /**/
    929854        jQuery(theImg).width(Zone_image.image_init.width);
    930855        jQuery(theImg).height(Zone_image.image_init.height);
     856
     857        set_cl("no");
     858        Set_llbgo(true);
    931859        return;
    932860
     
    971899
    972900          } else {
    973             jQuery(theMainImage_id).height(Zone_image.image.height);
    974             jQuery(theMainImage_id).width(Zone_image.image.width);
     901            jQuery(theMainImage_id).width(Zone_image.image_init.width);
     902            jQuery(theMainImage_id).height(Zone_image.image_init.height);
    975903          }
    976904
     
    999927    changeImgSrc = function (url, typeSave, typeMap, type) {
    1000928      if (url) {
    1001         if (options.imgSrc != url) {
    1002           options.imgSrc = url;
    1003         }
    1004       }
    1005       jQuery("#theMainImage")
    1006       .removeAttr("width height")
    1007       .attr("src", url)
     929        if (url.match(RegExp("i.php", "gi"))) {
     930          urls = url.split("?");
     931        }
     932      }
     933      url2 = jQuery("#theMainImage").attr("src");
     934      return;
     935
     936      jQuery("#theMainImage").removeAttr("width height").attr("src", url)
    1008937      .load(function (i) {
    1009         url2 = this.src;
     938        if (!init_img(this))
     939          return;
     940        //=======================================================================       
    1010941        jQuery('#derivativeSwitchBox .switchCheck').css('visibility', 'hidden');
    1011942        newtype = options.pictureSelType;
    1012943        if (typeof type != "undefined" && (type == "Autosize" || type == "SelMaxi")) {
    1013 
    1014944          jQuery('#derivativeChecked' + type).css('visibility', 'visible');
    1015945          document.cookie = 'picture_sel_type=' + type + ';path=' + COOKIE_PATH;
     
    1018948          document.cookie = 'picture_sel_type=' + typeSave + ';path=' + COOKIE_PATH;
    1019949        }
    1020 
    1021950        options.pictureMap = typeMap;
    1022951        options.pictureDeriv = typeSave;
    1023952        document.cookie = 'picture_deriv=' + typeSave + ';path=' + COOKIE_PATH;
    1024         Autosize_resize(true, options);
    1025         if (typeof type != "undefined" && (type == "Autosize" || type == "SelMaxi")) {
    1026 
    1027         } else {
    1028           jQuery("#bp_img_cla").attr("src", "./plugins/Autosize/icons/button-maximize.png");
    1029           jQuery("#bp_cla span").text("");
    1030         }
     953
    1031954      })
    1032955      .live("ON", function (e) {
    1033956        theMainImage_st = this.complete;
    1034         this.src = this.src;
     957        imgsrc = this.src;
    1035958        // alert(this.src + ' Image does not exist !!');
    1036959      }).error(function (i) {
    1037         this.src = this.src;
     960        imgsrc = this.src;
    1038961      });
    1039       ;
    1040 
     962      /***********************
     963      *
     964      **********************/
     965      jQuery("#theMainImage," + theMainImage_id + ",.preload, .next1 , ")
     966         .error(function (e) {
     967           if (!this.complete) {
     968             // le fichier n'est pas present
     969             src = jQuery(this).attr("src").replace("./_data/i/", "", 1);
     970             src = this.src.split("/_data/i")[1];
     971             url = 'i.php?' + src + "&ajaxload=true";
     972             jQuery(theMainImage_id).attr("src", url);
     973             /*
     974             jQuery.ajax({
     975             type: 'GET',
     976             url: 'i.php?' + src + "&ajaxload=true",
     977             dataType: 'json',
     978             success: (function (data) {
     979             j = data.url;
     980             //  jQuery(theMainImage_id).attr("src", data.url);
     981
     982             })
     983
     984             });
     985             */
     986
     987
     988
     989           }
     990
     991         })
     992         .bind("Finish", function (e, data) {
     993           if (typeof imageInfos_id == "undefined") return;
     994
     995         })
     996          .bind("ON", function (e, data) {
     997            if (data.status != "ok") {
     998              popup = jQuery(".errors");
     999              if (popup.length == 0) {
     1000                jQuery("#theImage").append("<div class='errors'><span></span></div>");
     1001              }
     1002              jQuery(".errors").text("Erreur : [" + data.done + "] " + data.responseText);
     1003              jQuery(".errors").show().delay(10000).hide(2000);
     1004              return;
     1005            }
     1006            if (data.src) {
     1007              if (typeof imageInfos_id == "undefined") return;
     1008              if (!data.src.match(RegExp(options.pictureDeriv.substr(0, 2) + ".jpg", "gi"))) {
     1009                Autosize_resize(true, options);
     1010              }
     1011            }
     1012          });
     1013      //_________ theMainImage  ___________
    10411014
    10421015
     
    11181091    //__________________ Wait_pamoorama ______________________
    11191092    jQuery(".pwg-icon-clock-minus, .pwg-icon-clock-plus").click(function (i) {
    1120       n = window.myPamoorama;
    1121       n = this;
     1093
     1094
     1095
     1096
     1097
     1098    }).mouseover(function (i) {
     1099
    11221100    })
     1101
    11231102
    11241103    Wait_pamoorama_time = function () {
    11251104      if (nopano == true) return true;
     1105
     1106
     1107
    11261108      if (jQuery("#pamoorama").length) {
    11271109        tempo = tempo + 1;
     
    11521134
    11531135        nopano = true;
     1136
    11541137        Zone_image = { image_init: { width: mypanorama.imageWidth,
    11551138          height: mypanorama.imageHeight
     
    13091292                maxi_size = size_derive;
    13101293                maxi_size.idx = n;
    1311                 return false
     1294                if (options.pictureSelType == "SelMaxi" || options.pictureSelType == "Autosize")
     1295                  return false
    13121296              }
    13131297            }
     
    13301314
    13311315        }
     1316
    13321317        options.pictureDeriv = pt[n][0];
    13331318        return { url: pt[n][1], pictureDeriv: pt[n][0], pictureMap: pt[n][0], width: pt[n][2], height: pt[n][3] };
     
    13501335        options.theImageMargeZone = Zone_image.marges;
    13511336        if (Type_Img != 'charlie') {
     1337          /*
    13521338          if (options.pictureSelType != "SelMaxi" && options.pictureSelType != "Autosize") {
    1353             return;
     1339          options.pictureMap = options.pictureDeriv;
     1340           
     1341          imgSrc = options.liste_type[6];
     1342          changeImgSrc(imgSrc, options.pictureDeriv, options.pictureMap, options.pictureSelType);
     1343          src = theImg.src;
     1344          return;
    13541345          } else {
    1355             IMg = Get_Maxi(Zone_image.image);
     1346          IMg = Get_Maxi(Zone_image.image);
    13561347          }
     1348          */
     1349          IMg = Get_Maxi(Zone_image.image);
    13571350          imgSrc = IMg.url;
    1358           options.imgSrc = imgSrc;
     1351          if (options.imgSrc.match(RegExp(imgSrc, "gi")))
     1352            options.imgSrc = imgSrc;
     1353
    13591354          img_width = IMg.width;
    13601355          img_height = IMg.height;
     
    13761371        Zone_image.zoom = Zone_image.image.height / Zone_image.image_init.height;
    13771372        if (typeof Zone_image.src == "undefined") Zone_image.src = " ";
    1378         status = imgSrc.match(RegExp(Zone_image.src, "gi")); // status = '' si !=
    1379         status1 = (imgSrc.toString() == Zone_image.src.toString());
    1380 
    1381         if (status1 == true) {
    1382           //  changeImgSrc(imgSrc, IMg.pictureMap, IMg.pictureDeriv, options.pictureSelType);
    1383           return;
    1384 
    1385         }
     1373
     1374        identique = Zone_image.src.match(RegExp(imgSrc, "gi"));
     1375        if (identique) return;
    13861376        href_path = "javascript:changeImgSrc('" + imgSrc + "', '" + IMg.pictureMap + "', '" + IMg.pictureDeriv + "', '" + options.pictureSelType + "')";
    13871377        jQuery(".linkAutosize").attr("href", href_path);
     
    13921382          imgSrc_j = jQuery(theImg).css("background-image");
    13931383          return;
    1394 
    13951384        } else {
    1396           theImg.src = imgSrc;
     1385          changeImgSrc(imgSrc, IMg.pictureDeriv, IMg.pictureMap, options.pictureSelType);
    13971386        }
    13981387
     
    16731662
    16741663        }
    1675 
    1676 
    1677 
    1678 
    1679       }
    1680 
    1681 
    1682 
     1664      }
     1665      //=================================================================
    16831666      Zone_image.image = {
    16841667        width: width_theMainImage,
    16851668        height: height_theMainImage,
    16861669        rapport: width_theMainImage / height_theMainImage
    1687 
    16881670      };
    1689 
    1690 
    1691       //=================================================================
    16921671      Zone_image.marges = { width: marge_left + marge_right + retrait_img.width,
    16931672        height: marge_top + marge_bottom + retrait_img.height
    1694 
    16951673      }
    16961674      Zone_image.src = jQuery(theMainImage_id).attr("src");
    1697 
    16981675    }
    16991676
     
    17161693      options.theImageWidth = new_win.width - options.theImageLeft - options.theImageRight;
    17171694      options.theImageHeight = new_win.height - options.marge_top - options.theImageBottom - options.theImageTop;
    1718 
    1719 
    1720 
    1721 
    17221695      var chk = eval("options." + user_status + "_enabled");
    17231696      if (chk == "") { return; }
     
    18371810    *  init_gen
    18381811    *****************************/
    1839 
    18401812    init_gen = function (e) {
    1841 
    1842 
    18431813      theImg = document.getElementById(theMainImage_id.replace("#", ""));
    18441814      //==================================================
     
    19441914      pictureDeriv = options.pictureDeriv;
    19451915      Autosize_resize(true, options);
     1916      Autosize_resize(true, options);
    19461917      return;
     1918
    19471919      IMg = Get_Maxi(Zone_image.image);
    19481920      imgSrc = IMg.url;
     
    22002172
    22012173
    2202   });                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         // ready
     2174  });                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             // ready
    22032175
    22042176
  • extensions/Autosize/main.inc.php

    r18925 r18936  
    2323);
    2424
    25 if (isset($_GET['cl_debug']) && $_GET['cl_debug']=="NO"){
     25global $conf ;
     26  if( isset($_GET['cl_debug']) && $_GET['cl_debug'] =='false') {
     27      $DEBUG_autosize="";
     28  }else{
     29    $DEBUG_autosize = isset($_POST['cl_debug']) ? $_POST['cl_debug'] : "" ;
     30    $DEBUG_autosize = isset($_GET['cl_debug']) ? $_GET['cl_debug'] :  $DEBUG_autosize ;
     31    $DEBUG_autosize = isset($conf['cl_debug']) ? $conf['cl_debug']."," . $DEBUG_autosize : $DEBUG_autosize ;   
     32    }
     33
     34if(preg_match("|NO|", $DEBUG_autosize, $val)) { 
    2635
    2736}else{
     
    3746add_event_handler('get_admin_plugin_menu_links', array(&$autosize_ctrl,'cl_autosize_admin')  );
    3847
    39   if( isset($_GET['cl_debug']) && $_GET['cl_debug'] =='false') {
    40       $DEBUG_autosize="";
    41   }else{
    42     $DEBUG_autosize = isset($_POST['cl_debug']) ? $_POST['cl_debug'] : "" ;
    43     $DEBUG_autosize = isset($_GET['cl_debug']) ? $_GET['cl_debug'] :  $DEBUG_autosize ;
    44     $DEBUG_autosize = isset($conf['cl_debug']) ? $conf['cl_debug']."," . $DEBUG_autosize : $DEBUG_autosize ;
    45  //===============================================================
    46 }
     48//===============================================================
    4749if(!preg_match("|NO|", $DEBUG_autosize, $val)) { 
    48 // init cl_autosize_script_1 cl_autosize_affiche
    49 //Important avant pamooramics, gvideo
    50 add_event_handler('render_element_content', array(&$autosize_ctrl, 'autosize_calcContent'),EVENT_HANDLER_PRIORITY_NEUTRAL-11,2);
    51 /**/
    52 add_event_handler('render_element_content',  array(&$autosize_ctrl,'init'),EVENT_HANDLER_PRIORITY_NEUTRAL-1,2  );
    53 add_event_handler('render_element_content',  array(&$autosize_ctrl,'init2'),EVENT_HANDLER_PRIORITY_NEUTRAL+1,2  );
    54 add_event_handler('loc_after_page_header', array(&$autosize_ctrl, 'cl_autosize_script_1') );
    55 add_event_handler('loc_after_page_header', array(&$autosize_ctrl, 'cl_autosize_script_2')  );
    56 add_event_handler('loc_after_page_header',array(&$autosize_ctrl, 'cl_autosize_script_3')  );
    57 add_event_handler('loc_after_page_header', array(&$autosize_ctrl, 'cl_autosize_affiche'), EVENT_HANDLER_PRIORITY_NEUTRAL +21    );
    58 }
     50    add_event_handler('render_element_content', array(&$autosize_ctrl, 'autosize_calcContent'),EVENT_HANDLER_PRIORITY_NEUTRAL-11,2);
     51    add_event_handler('render_element_content',  array(&$autosize_ctrl,'init'),EVENT_HANDLER_PRIORITY_NEUTRAL-1,2  );
     52    add_event_handler('render_element_content',  array(&$autosize_ctrl,'init2'),EVENT_HANDLER_PRIORITY_NEUTRAL+1,2  );
     53    add_event_handler('loc_after_page_header', array(&$autosize_ctrl, 'cl_autosize_script_1') );
     54    add_event_handler('loc_after_page_header', array(&$autosize_ctrl, 'cl_autosize_script_2')  );
     55    add_event_handler('loc_after_page_header',array(&$autosize_ctrl, 'cl_autosize_script_3')  );
     56    add_event_handler('loc_after_page_header', array(&$autosize_ctrl, 'cl_autosize_affiche'), EVENT_HANDLER_PRIORITY_NEUTRAL +21    );
     57    }
    5958} ;
    6059
  • extensions/Autosize/maintain.inc.php

    r18716 r18936  
    6262 global $conf ;
    6363 global $infos_message , $erreur_message ,$warnings_message ;
    64  if (isset($conf['cl_derivatives_sav']))  {   
    65     $arr = unserialize($conf['cl_derivatives_sav']);         
    66       if(isset($arr['d'])){
    67           $conf['derivatives'] = $conf['cl_derivatives_sav'];
    68         }
    69           $query = '
    70           UPDATE '.CONFIG_TABLE.'
    71             SET value="'.addslashes(serialize($arr)).'"
    72           WHERE param = "derivatives"
    73           LIMIT 1';
    74           pwg_query($query);
     64   $arr = @unserialize($conf['derivatives']);
     65        if(isset($arr['d']['Autosize'])){   
     66                unset(  $arr['d']['SelMaxi']);
     67                unset(  $arr['d']['Autosize']); 
     68                $conf['derivatives']=serialize($arr);
     69                $arr = @unserialize($conf['derivatives']);       
     70                  $query = '
     71                      UPDATE '.CONFIG_TABLE.'
     72                      SET value="'.addslashes(serialize($arr)).'"
     73                      WHERE param = "derivatives"
     74                      LIMIT 1';
     75                  pwg_query($query);             
     76            }
     77
     78      if (isset($conf['cl_derivatives_sav']))  {   
    7579          $q = 'DELETE FROM '.CONFIG_TABLE.' WHERE param="cl_derivatives_sav"   ;';
    7680          pwg_query($q);
    77          unset ( $conf['cl_derivatives_sav']);         
    78        
    79     }   
     81         unset ( $conf['cl_derivatives_sav']);   
     82      }   
    8083      $model= $conf['derivative_default_size'];
    8184      $_COOKIE  ['picture_deriv'] = $model; 
Note: See TracChangeset for help on using the changeset viewer.