Changeset 14913


Ignore:
Timestamp:
May 12, 2012, 9:04:29 AM (8 years ago)
Author:
psli
Message:

Version 1.3 :

  • correction de l'upgrade
  • correction des chemins d'accès
Location:
extensions/Psli_BingMaps
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • extensions/Psli_BingMaps/include/admin.php

    r14891 r14913  
    1010
    1111// Fetch the template.
    12 global $template, $conf, $page;
     12global $template, $conf, $page, $debug;
     13
     14$debug .= "PSLIDEBUG - ".$_SERVER['REQUEST_URI'];
    1315
    1416// Save configuration
     
    136138        'LON'          => $lon,
    137139        'ZOOM'         => $zoom,
    138         'JSPATH'           => PSLI_BINGMAPS_JS
     140        'JSPATH'           => PSLI_BINGMAPS_JS,
     141        'VERSION'          => " v".PSLI_VERSION_MAJ.".".PSLI_VERSION_MIN
    139142  )
    140143);
  • extensions/Psli_BingMaps/include/const.inc.php

    r14891 r14913  
    2222define('PSLI_CONF_LON', 'PsliBingMapsLon');
    2323define('PSLI_CONF_ZOOM', 'PsliBingMapsZoom');
     24define('PSLI_CONF_PATH', 'PsliBingMapsPath');
    2425define('PSLI_CONF_CATEGORY', 'PsliBingMapsCategoryInitiale');
    2526define('PSLI_CONF_VERSION_MAJ', 'PsliBingMapsVerMaj');
    2627define('PSLI_CONF_VERSION_MIN', 'PsliBingMapsVerMin');
    2728define('PSLI_VERSION_MAJ', 1);
    28 define('PSLI_VERSION_MIN', 2);
     29define('PSLI_VERSION_MIN', 3);
    2930
    3031?>
  • extensions/Psli_BingMaps/include/version.inc.php

    r14891 r14913  
    5959                        SET value = "' . PSLI_VERSION_MIN . '"
    6060                        WHERE param = "'.PSLI_CONF_VERSION_MIN.'"
    61                         LIMIT 2';
     61                        LIMIT 1';
    6262        pwg_query($query);
    63         $version_maj = PSLI_VERSION_MAJ;
    64         $version_min = PSLI_VERSION_MIN;
     63        $version_maj = "1";
     64        $version_min = "2";
    6565}
     66
     67// from version 1.2
     68if (($version_maj == "1") and ($version_min == "2"))
     69{
     70        // New Conf data in v1.3
     71        // Update version and create new conf param PSLI_CONF_PATH
     72        $query = '
     73                UPDATE '.CONFIG_TABLE.'
     74                        SET value = "' . PSLI_VERSION_MAJ . '"
     75                        WHERE param = "'.PSLI_CONF_VERSION_MAJ.'"
     76                        LIMIT 1';
     77        pwg_query($query);
     78        $query = '
     79                UPDATE '.CONFIG_TABLE.'
     80                        SET value = "' . PSLI_VERSION_MIN . '"
     81                        WHERE param = "'.PSLI_CONF_VERSION_MIN.'"
     82                        LIMIT 1';
     83        pwg_query($query);
     84        $version_maj = "1";
     85        $version_min = "3";
     86        $sql = 'INSERT INTO '.CONFIG_TABLE." (param, value) VALUES ('".PSLI_CONF_PATH."', 'http://".$_SERVER['HTTP_HOST'].substr($_SERVER['REQUEST_URI'],0, strrpos($_SERVER['REQUEST_URI'],"/"))."/');";       
     87    pwg_query($sql);
     88}
     89
    6690?>
  • extensions/Psli_BingMaps/main.inc.php

    r14891 r14913  
    11<?php
    22/*
    3 Version: 1.1
     3Version: 1.2
    44Plugin Name: Psli-BingMaps
    55Plugin URI: http://piwigo.org/ext/extension_view.php?eid=603
     
    1818// define Path for PHP and JS file
    1919define ('PSLI_BINGMAPS_PATH', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
    20 define ('PSLI_BINGMAPS_JS', PSLI_BINGMAPS_PATH.'JS/Psli-BingMaps.js');
     20//define ('PSLI_BINGMAPS_JS', PSLI_BINGMAPS_PATH.'JS/Psli-BingMaps.js');
    2121define ('PSLI_BINGMAPS_VERSION_INC_PHP', PSLI_BINGMAPS_PATH.'include/version.inc.php');
    2222define ('PSLI_BINGMAPS_ADMIN_INC_PHP', PSLI_BINGMAPS_PATH.'include/admin.inc.php');
     
    3737if (script_basename() == 'admin')   
    3838{
    39   include_once(PSLI_BINGMAPS_ADMIN_INC_PHP);
     39        // Check if site root changed
     40        // define Path for JS file
     41        $query = '
     42                SELECT value
     43                        FROM '.CONFIG_TABLE.'
     44                        WHERE param = "'.PSLI_CONF_PATH.'";';
     45        $result = pwg_query($query);
     46        $row = pwg_db_fetch_assoc($result);
     47        $root = 'http://'.$_SERVER['HTTP_HOST'].substr($_SERVER['REQUEST_URI'],0, strrpos($_SERVER['REQUEST_URI'],"/")).'/';
     48        if ($root != $row['value'])
     49        {
     50                $sql = 'UPDATE '.CONFIG_TABLE." SET value = '".$root."' WHERE param = '".PSLI_CONF_PATH."';";   
     51                pwg_query($sql);
     52        }
     53        else   
     54        {
     55                $root = $row['value'];
     56        }
     57        define ('PSLI_BINGMAPS_JS', $root.'plugins/Psli-BingMaps/JS/Psli-BingMaps.js');
     58        include_once(PSLI_BINGMAPS_ADMIN_INC_PHP);
    4059}
    4160else
    4261{
    43   include_once(PSLI_BINGMAPS_GUEST_INC_PHP);
     62        // define Path for JS file
     63        $query = '
     64                SELECT value
     65                        FROM '.CONFIG_TABLE.'
     66                        WHERE param = "'.PSLI_CONF_PATH.'";';
     67        $result = pwg_query($query);
     68        $row = pwg_db_fetch_assoc($result);
     69        define ('PSLI_BINGMAPS_JS', $row['value'].'plugins/Psli-BingMaps/JS/Psli-BingMaps.js');
     70       
     71        include_once(PSLI_BINGMAPS_GUEST_INC_PHP);
    4472}
    4573
  • extensions/Psli_BingMaps/maintain.inc.php

    r14872 r14913  
    1717// Create all needed tables and parameters ( with value by default) in CONFIG_TABLE
    1818/********************************************************************************************/
    19 function plugin_activate($plugin_id, $plugin_version, &$errors)
     19function plugin_install($plugin_id, $plugin_version, &$errors)
    2020{
    2121        global $prefixeTable;
     
    4747       
    4848        $sql = 'INSERT INTO '.CONFIG_TABLE." (param, value) VALUES ('".PSLI_CONF_LON."', '0');";
    49     pwg_query($sql);
     49        pwg_query($sql);
    5050       
    5151        $sql = 'INSERT INTO '.CONFIG_TABLE." (param, value) VALUES ('".PSLI_CONF_LAT."', '0');";
    52     pwg_query($sql);
     52        pwg_query($sql);
    5353       
    5454        $sql = 'INSERT INTO '.CONFIG_TABLE." (param, value) VALUES ('".PSLI_CONF_ZOOM."', '2');";
    55     pwg_query($sql);
     55        pwg_query($sql);
    5656       
    5757        $sql = 'INSERT INTO '.CONFIG_TABLE." (param, value) VALUES ('".PSLI_CONF_KEY."', 'to define');";
    58     pwg_query($sql);
     58        pwg_query($sql);
    5959       
    6060        $sql = 'INSERT INTO '.CONFIG_TABLE." (param, value) VALUES ('".PSLI_CONF_CATEGORY."', 'to define');";
    61     pwg_query($sql);
     61        pwg_query($sql);
    6262
    6363        $sql = 'INSERT INTO '.CONFIG_TABLE." (param, value) VALUES ('".PSLI_CONF_VERSION_MAJ."', '".PSLI_VERSION_MAJ."');";
    64     pwg_query($sql);
     64        pwg_query($sql);
    6565       
    6666        $sql = 'INSERT INTO '.CONFIG_TABLE." (param, value) VALUES ('".PSLI_CONF_VERSION_MIN."', '".PSLI_VERSION_MIN."');";
    67     pwg_query($sql);   
     67        pwg_query($sql);       
     68       
     69        $sql = 'INSERT INTO '.CONFIG_TABLE." (param, value) VALUES ('".PSLI_CONF_PATH."', 'http://".$_SERVER['HTTP_HOST'].substr($_SERVER['REQUEST_URI'],0, strrpos($_SERVER['REQUEST_URI'],"/"))."/');";       
     70        pwg_query($sql);
     71       
    6872}
    6973
     
    7276// Destroy tables and parameters created by plugin
    7377/********************************************************************************************/
    74 function plugin_deactivate($plugin_id)
     78function plugin_uninstall($plugin_id)
    7579{
    7680        global $prefixeTable;
  • extensions/Psli_BingMaps/template/admin.tpl

    r14891 r14913  
    1111
    1212<fieldset>
    13 <legend>{'Configuration'|@translate}tatata</legend>
     13<legend>{'Configuration'|@translate} {$VERSION}</legend>
    1414<table style="width:100%;">
    1515        <colgroup>
Note: See TracChangeset for help on using the changeset viewer.