Advertisement
KeyDog

osm-import.php

Jan 5th, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.22 KB | None | 0 0
  1. <?php
  2. /*
  3.   import function for OSM wordpress plugin
  4.   Michael Kang * april 2009
  5.   http://www.Fotomobil.at/wp-osm-plugin
  6.   file is used within:
  7.   function createMarkerList($a_import, $a_import_UserName, $a_Customfield)
  8. */
  9. ?>
  10.  
  11. <?php  
  12.  
  13. define (GC_STATS_INTERFACE_VER,1);
  14.  
  15. // wpgmg plugin of Karl Kevilus
  16. // generate lat,lon from address
  17. // http://karlkevilus.com/wordpress-google-maps-geocoder/
  18. if ($a_import == 'wpgmg'){
  19.    $temp_lat = get_post_meta($post->ID, WPGMG_LAT, true);  
  20.    $temp_lon = get_post_meta($post->ID, WPGMG_LON, true);  
  21. }
  22. // gcStats plugin of Michael Jostmeyer
  23. // statistics about geocaching
  24. // http://michael.josi.de/projects/gcstats/
  25. else if($a_import == 'gcstats'){
  26.  
  27.   // check whether the plugin is loaded
  28.   if (!function_exists('gcStats__getInterfaceVersion')) {
  29.      Osm::traceText(DEBUG_ERROR, "e_missing_gcStats");
  30.      return;
  31.   }
  32.   // the plugin-version is not important, but the interface of gcStats
  33.   // has to fullfill all the requests of OSM-plugin
  34.   else if (gcStats__getInterfaceVersion() < GC_STATS_INTERFACE_VER){
  35.      Osm::traceText(DEBUG_ERROR, "e_version_gcStats");
  36.      return;
  37.   }
  38.  
  39.   // get the data from gcstats plugin, check it and add it to the marker-array
  40.   $temp_caches = gcStats__getCachesData($a_import_UserName, $a_Customfield);
  41.   foreach($temp_caches as $CachesArray){
  42.     list($temp_lat, $temp_long) = Osm::checkLatLongRange('gcStats',$CachesArray[lat], $CachesArray[lon]);
  43.     $MarkerArray[] = array('lat'=> $temp_lat,'lon'=>$temp_long,'marker'=>GCSTATS_MARKER_PNG, 'text' => $CachesArray[text],'popup_height'=>'150', 'popup_width'=>'100');
  44.   }
  45. }
  46.  
  47. // extra comment field plugin of Nate Weiner
  48. // adding comment fields
  49. // http://www.ideashower.com/our_solutions/wordpress-plugin-extra-comment-fields/
  50. else if($a_import == 'ecf'){
  51.  
  52.   // Get Total Comments Poster
  53.     global $wpdb;
  54.  
  55.     // check whether the plugin is loaded
  56.     if (!function_exists('ecf_getComments')) {
  57.        Osm::traceText(DEBUG_ERROR, "e_missing_ecf");
  58.        return;
  59.     }
  60.  
  61.     //      WHERE comment_approved = '1' AND comment_type = '' AND
  62.     // SUBSTRING(comment_content,1,80) AS com_excerpt    
  63.         $sql = "SELECT DISTINCT ID, post_title, comment_author, post_password, comment_ID, comment_post_ID, comment_content
  64.    FROM $wpdb->comments
  65.         LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID =
  66.         $wpdb->posts.ID)
  67.         WHERE comment_type = '' AND
  68.         post_password = '' AND comment_post_ID = '".$post->ID."'
  69.         ORDER BY comment_date DESC
  70.         LIMIT 100";
  71.         $comments = $wpdb->get_results($sql);
  72.     $comments = ecf_getComments($comments, $post->ID);
  73.  
  74.         foreach ($comments as $comment) :
  75.           Osm::traceText(DEBUG_INFO, "Found a tagged comment!");
  76.       $ecf_lat = $comment->extra_lat;
  77.       $ecf_lon = $comment->extra_lon;
  78.       $ecf_txt = $comment->comment_content;
  79.       $ecf_txt= preg_replace("/[^a-zA-Z0-9 ]/","",$ecf_txt);
  80.       //echo $ecf_txt;
  81.       if ($ecf_lat != '' && $ecf_lon != ''){
  82.         list($ecf_lat, $ecf_lon) = Osm::checkLatLongRange('ecf_'.$ecf_author,$ecf_lat, $ecf_lon);
  83.         $MarkerArray[] = array('lat'=> $ecf_lat,'lon'=>$ecf_lon,'marker'=>INDIV_MARKERG, 'text' => $ecf_txt,'popup_height'=>'150', 'popup_width'=>'100');
  84.       }
  85.     endforeach;
  86.   }
  87. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement