Ignore:
Timestamp:
Oct 7, 2010, 8:04:43 PM (14 years ago)
Author:
grum
Message:

Admin interface + Gallery integration finished

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/GMaps/gmaps_root.class.inc.php

    r7054 r7125  
    1919    protected $css;
    2020
     21    /**
     22     * check the available AMD release
     23     */
     24    static public function checkAMDRelease()
     25    {
     26      if(!defined('AMD_VERSION')) return(false);
     27
     28      $currentAMDRelease = explode(".", GPC_VERSION);
     29
     30      $neededAMDRelease=explode('.', GMAPS_AMD_NEEDED);
     31      $major=$neededAMDRelease[0];
     32      $minor=$neededAMDRelease[1];
     33      $minor2=$neededAMDRelease[2];
     34
     35      if(($currentAMDRelease[0]>$major) ||
     36         ($currentAMDRelease[0]==$major)&&($currentAMDRelease[1]>$minor) ||
     37         ($currentAMDRelease[0]==$major)&&($currentAMDRelease[1]==$minor)&&($currentAMDRelease[2]>=$minor2))
     38      {
     39        return(true);
     40      }
     41      return(false);
     42    }
     43
     44    /**
     45     * check if AMD plugin is activated and mode
     46     *
     47     * @return String : 'none' if plugin is not installed
     48     *                  'inactive' if plugin is not active
     49     *                  'basic' if plugin active in basic mode
     50     *                  'advanced' if plugin active in advanced mode
     51     */
     52    static public function checkAMDActivated()
     53    {
     54      if(!self::checkAMDRelease()) return('none');
     55
     56      $sql="SELECT state FROM ".PLUGINS_TABLE." WHERE id='AMetaData';";
     57      $result=pwg_query($sql);
     58      if($result)
     59      {
     60        $row=pwg_db_fetch_assoc($result);
     61        if(!(isset($row['state']) and $row['state']='active')) return('inactive');
     62
     63        $amdConfig=array();
     64        GPCCore::loadConfig('amd', $amdConfig);
     65
     66        return($amdConfig['amd_InterfaceMode']);
     67      }
     68    }
     69
     70
    2171    public function __construct($prefixeTable, $filelocation)
    2272    {
     
    2676      $this->section_name=$this->getPluginNameFiles();
    2777
    28       $this->setTablesList(array('maps', 'category_maps'));
     78      $this->setTablesList(array('maps', 'category_maps', 'cache'));
    2979      $this->css = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().".css");
    3080    }
     
    3787    public function initEvents()
    3888    {
    39       add_event_handler('blockmanager_register_blocks', array(&$this, 'register_blocks') );
    4089    }
    4190
     
    111160
    112161    /* ---------------------------------------------------------------------------
    113       ajax functions
     162
    114163    --------------------------------------------------------------------------- */
    115164
     165    /**
     166     * update the given bound with the given coords
     167     *
     168     * @param &Array $bounds : the bounds (N,S,E,W)
     169     * @param Array $coords  : coords (0=>lat, 1=>lng)
     170     */
     171    protected function updateBounds(&$bounds, $coords)
     172    {
     173      if($bounds['E']<$coords['lng']) $bounds['E']=$coords['lng'];
     174      if($bounds['N']<$coords['lat']) $bounds['N']=$coords['lat'];
     175      if($bounds['W']>$coords['lng']) $bounds['W']=$coords['lng'];
     176      if($bounds['S']>$coords['lat']) $bounds['S']=$coords['lat'];
     177    }
     178
     179    /**
     180     * build the list of maps (initialize the $this->maps var)
     181     *
     182     * used by GMaps_ajax & GMaps_pip classes
     183     *
     184     * @param Array $categories : array of categories id (cat + parent list)
     185     * @param String $page : 'P' for picture page, 'C' for category page
     186     */
     187    protected function buildMapList($category, $page)
     188    {
     189      global $template ;
     190
     191      if($page=='C')
     192      {
     193        $where=" displayType='IC' ";
     194      }
     195      else
     196      {
     197        $where=" (displayType='IP' or displayType='MP') ";
     198      }
     199
     200      /*
     201       * sql request select all possible association, sorted from the highest to
     202       * the lowest priority
     203       */
     204      $sql="SELECT DISTINCT pgcm.id, pgcm.categoryId,
     205              pgcm.imgSort, pgcm.applySubCat, pgcm.kmlFileUrl,
     206              pgcm.icon, pgcm.title,
     207              pgmm.displayType, pgmm.sizeMode,
     208              pgmm.width, pgmm.height, pgmm.zoomLevel,
     209              pgmm.mapType, pgmm.mapTypeControl, pgmm.scaleControl,
     210              pgmm.navigationControl, pgmm.style,
     211              IF(pgcm.categoryId=0, 0, pct.global_rank) AS priorityRank
     212            FROM (".$this->tables['category_maps']." pgcm
     213              LEFT JOIN ".$this->tables['maps']." pgmm ON pgcm.mapId = pgmm.id)
     214              LEFT JOIN ".CATEGORIES_TABLE." pct ON (FIND_IN_SET(pgcm.categoryId, pct.uppercats)!=0 OR pgcm.categoryId=0)
     215            WHERE $where ";
     216      if($category!=0)
     217      {
     218        $sql.=" AND pct.id = '$category' ";
     219      }
     220      else
     221      {
     222        $sql.=" AND pgcm.categoryId = 0 ";
     223      }
     224      $sql.=" AND pgcm.applySubCat='y'
     225            ORDER BY priorityRank DESC, pgmm.displayType ASC, pgcm.categoryId ASC, pgcm.imgSort ASC;";
     226      $result=pwg_query($sql);
     227
     228      if($result)
     229      {
     230        // for each found row, choose the highest only
     231        $pcat='';
     232        $displayType=array(
     233         'IC' => true,
     234         'IP' => true,
     235         'MP' => true,
     236        );
     237        while($row=pwg_db_fetch_assoc($result))
     238        {
     239          if($row['displayType']!='MP')
     240          {
     241            $themeConf=$template->get_template_vars('themeconf');
     242            $fileName=preg_replace('/^([i|c]\d+x\d+)(?:_\d+){0,1}(\..*)/i', '$1$2', $row['icon']);
     243
     244            if(file_exists(PHPWG_ROOT_PATH.$themeConf['icon_dir'].'/gmaps/'.$fileName))
     245            {
     246              $row['icon']=$themeConf['icon_dir'].'/gmaps/'.$fileName;
     247              $row['iconStyle']=false;
     248            }
     249            else
     250            {
     251              $row['icon']='plugins/GMaps/img/'.$row['icon'];
     252              $row['iconStyle']=true;
     253            }
     254          }
     255
     256          if($displayType[$row['displayType']])
     257          {
     258            if($row['displayType']=='MP')
     259            {
     260              if($displayType['MP'] and ($row['categoryId']==$pcat or $pcat=='')) $this->maps[]=$row;
     261              if($displayType['MP'] and $row['categoryId']!=$pcat and $pcat!='') $displayType['MP']=false;
     262              $pcat=$row['categoryId'];
     263            }
     264            else
     265            {
     266              $this->maps[]=$row;
     267              $displayType[$row['displayType']]=false;
     268            }
     269          }
     270        }
     271      }
     272    }
     273
     274
    116275
    117276  } //class
Note: See TracChangeset for help on using the changeset viewer.