Changeset 28498


Ignore:
Timestamp:
05/18/14 09:12:50 (5 years ago)
Author:
rvelices
Message:

rv_gmaps simplification and use of persistent cache

Location:
extensions/rv_gmaps/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • extensions/rv_gmaps/trunk/admin/admin_boot.php

    r26331 r28498  
    33 
    44include_once( dirname(dirname(__FILE__)) .'/include/functions.php'); 
    5  
    6 add_event_handler('invalidate_user_cache', 'rvm_invalidate_cache' ); 
    75 
    86add_event_handler('get_admin_plugin_menu_links', 'rvm_plugin_admin_menu' ); 
     
    8987  WHERE id IN ('.implode(',',$collection).')'; 
    9088    pwg_query($update_query); 
    91     rvm_invalidate_cache(); 
    9289  } 
    9390} 
  • extensions/rv_gmaps/trunk/include/functions.php

    r26331 r28498  
    11<?php 
    2  
    3 function rvm_get_cache_file_name() 
    4 { 
    5         global $conf; 
    6         return PHPWG_ROOT_PATH.$conf['data_location'].'/tmp/_rvgm_cat_cache.dat'; 
    7 } 
    8  
    9 function rvm_invalidate_cache() 
    10 { 
    11         @unlink(  rvm_get_cache_file_name() ); 
    12 } 
    132 
    143function rvm_load_language($source=false) 
  • extensions/rv_gmaps/trunk/include/functions_map.php

    r26331 r28498  
    284284function rvm_get_cat_bounds() 
    285285{ 
    286   $cache_file_name = rvm_get_cache_file_name(); 
    287   if ( file_exists($cache_file_name) ) 
    288   { 
    289     return unserialize( file_get_contents($cache_file_name) ); 
    290   } 
    291   $forbidden = get_sql_condition_FandF( 
    292         array 
    293           ( 
    294             'forbidden_categories' => 'category_id', 
    295             'visible_categories' => 'category_id', 
    296             'visible_images' => 'i.id' 
    297           ), 
    298         'AND' 
    299     ); 
     286        global $persistent_cache; 
     287        if ($persistent_cache->get('rvgm_album_bounds', $cat_bounds)) 
     288                return $cat_bounds; 
    300289 
    301290  $query = ' 
     
    307296      INNER JOIN 
    308297    '.IMAGES_TABLE.' i ON image_id=i.id 
    309   WHERE lat IS NOT NULL '.$forbidden.' 
    310   GROUP BY category_id 
    311 ;'; 
     298  WHERE latitude IS NOT NULL 
     299  GROUP BY category_id'; 
    312300 
    313301  $result = pwg_query($query); 
     
    349337  } 
    350338  //echo "<pre>" . var_export($cat_bounds,true); 
    351         mkgetdir( dirname($cache_file_name) ); 
    352   $file = fopen($cache_file_name , 'w' ); 
    353   fwrite($file, serialize($cat_bounds) ); 
    354   fclose( $file ); 
    355  
     339 
     340        $persistent_cache->set('rvgm_album_bounds', $cat_bounds); 
    356341  return $cat_bounds; 
    357342} 
     
    375360        ( 
    376361          'forbidden_categories' => 'category_id', 
    377           'visible_categories' => 'category_id', 
    378           'visible_images' => 'i.id' 
     362          'forbidden_images' => 'i.id' 
    379363        ), 
    380364      "\n  AND" 
     
    530514    $page['title'] = l10n('Recent photos'); 
    531515  } 
    532   else if ('list'==$page['section']) 
     516  elseif ('list'==$page['section']) 
    533517  { 
    534518    $query =' 
  • extensions/rv_gmaps/trunk/main.inc.php

    r26717 r28498  
    11<?php /* 
    22Plugin Name: RV Maps&Earth 
    3 Version: 2.6.a 
     3Version: 2.7.a 
    44Description: Extend your gallery with Google Maps and Google Earth ... 
    55Plugin URI: http://piwigo.org/ext/extension_view.php?eid=122 
  • extensions/rv_gmaps/trunk/maintain.inc.php

    r26331 r28498  
    6767    @unlink( PHPWG_ROOT_PATH.'map.php' ); 
    6868  } 
    69    
    70   rvm_invalidate_cache(); 
    7169} 
    7270 
Note: See TracChangeset for help on using the changeset viewer.