GeoMashup
[ class tree: GeoMashup ] [ index: GeoMashup ] [ all elements ]

Class: GeoMashupDB

Source Location: /geo-mashup-db.php

Class Overview


Static class to provide a namespace for Geo Mashup data functions.


Author(s):

Variables

Methods



Class Details

[line 17]
Static class to provide a namespace for Geo Mashup data functions.



Tags:

since:  1.2


[ Top ]


Class Variables

static $geocode_error = array()

[line 44]

The last geocode error, or empty if no error.



Tags:

access:  public

Type:   WP_Error


[ Top ]



Class Methods


static method action_added_comment_meta [line 137]

static void action_added_comment_meta( $meta_id, $comment_id, $meta_key, $meta_value)

WordPress action to update Geo Mashup comment location when geodata custom fields are updated.



Tags:

since:  1.4
access:  public


Parameters:

   $meta_id  
   $comment_id  
   $meta_key  
   $meta_value  

[ Top ]

static method action_added_post_meta [line 119]

static void action_added_post_meta( $meta_id, $post_id, $meta_key, $meta_value)

WordPress action to update Geo Mashup post location when geodata custom fields are updated.



Tags:

since:  1.4
access:  public


Parameters:

   $meta_id  
   $post_id  
   $meta_key  
   $meta_value  

[ Top ]

static method action_added_user_meta [line 128]

static void action_added_user_meta( $meta_id, $user_id, $meta_key, $meta_value)

WordPress action to update Geo Mashup user location when geodata custom fields are updated.



Tags:

since:  1.4
access:  public


Parameters:

   $meta_id  
   $user_id  
   $meta_key  
   $meta_value  

[ Top ]

static method activation_log [line 596]

static string activation_log( [string $message = null], [boolean $write = false])

Append to the activation log.

Add a message and optionally write the activation log. Needs to be written before the end of the request or it will not be saved.




Tags:

return:  The current log.
since:  1.4
access:  public
usedby:  GeoMashupDB::install()


Parameters:

string   $message   The message to append.
boolean   $write   Whether to save the log.

[ Top ]

static method add_geodata_sync_hooks [line 73]

static void add_geodata_sync_hooks( )

Add hooks to synchronize Geo Mashup ojbect locations with WordPress geodata.



Tags:

since:  1.4
access:  public


[ Top ]

static method are_any_location_fields_empty [line 829]

static bool are_any_location_fields_empty( array $location, [array $fields = null])

Check a location for empty fields.



Tags:

return:  Whether any of the specified fields are empty.
since:  1.4
access:  public


Parameters:

array   $location   The location to check.
array   $fields   The fields to check.

[ Top ]

static method blank_location [line 1232]

static array|object Empty blank_location( [string $format = OBJECT])

Get a blank location.

Used to return object fields too - use blank_object_location for that if desired.




Tags:

return:  location.
since:  1.2
access:  public


Parameters:

string   $format   OBJECT or ARRAY_A

[ Top ]

static method blank_object_location [line 1258]

static array|object Empty blank_object_location( [string $format = OBJECT])

Get a blank object location.



Tags:

return:  object location.
since:  1.4
access:  public


Parameters:

string   $format   OBJECT or ARRAY_A

[ Top ]

static method bulk_reverse_geocode [line 932]

static string bulk_reverse_geocode( )

Try to reverse-geocode all locations with relevant missing data.

Used by the options page. Tries to comply with the PHP maximum execution time, and delay requests if Google sends a 604.




Tags:

return:  An HTML log of the actions performed.
since:  1.3
access:  public


[ Top ]

static method cache_administrative_name [line 1000]

static int cache_administrative_name( string $country_code, string $admin_code, string $isolanguage, string $name, [string $geoname_id = null])

Store an administrative name in the database to prevent future web service lookups.



Tags:

return:  Rows affected.
since:  1.2
access:  public


Parameters:

string   $country_code  
string   $admin_code  
string   $isolanguage  
string   $name  
string   $geoname_id  

[ Top ]

static method category_located_post_count [line 1906]

static int category_located_post_count( id $category_id)

Get the number of located posts in a category.



Tags:

since:  1.2
access:  public


Parameters:

id   $category_id  

[ Top ]

static method copy_to_geodata [line 266]

static void copy_to_geodata( string $meta_type, int $object_id, $geo_date, $location_id, array $location)

Update object geodata if needed.



Tags:

since:  1.4
access:  public


Parameters:

string   $meta_type   'post','user','comment'
int   $object_id  
array   $location   The location to copy from.
   $geo_date  
   $location_id  

[ Top ]

static method delete_comment [line 2000]

static void delete_comment( $id)

When a comment is deleted, remove location relationships for it.

delete_comment action called by WordPress.




Tags:

since:  1.2
access:  public


Parameters:

   $id  

[ Top ]

static method delete_location [line 1864]

static int|WP_Error delete_location( id|array $ids)

Delete a location or locations.



Tags:

return:  Rows affected or Wordpress error.
since:  1.2
access:  public
usedby:  GeoMashupUIManager::save_posted_object_location()
uses:  do_action() - Calls 'geo_mashup_deleted_location' with the location object deleted.


Parameters:

id|array   $ids   Location ID or array of IDs to delete.

[ Top ]

static method delete_object_location [line 1835]

static int|WP_Error delete_object_location( string $object_name, id|array $object_ids)

Delete an object location or locations.

This removes the association of an object with a location, but does NOT delete the location.




Tags:

return:  Rows affected or WordPress error.
since:  1.3
access:  public
uses:  do_action() - Calls 'geo_mashup_deleted_object_location' with the object location object that was deleted.


Parameters:

string   $object_name   'post', 'user', a GeoMashupDB::object_storage() index.
id|array   $object_ids   Object ID or array of IDs to remove the locations of.

[ Top ]

static method delete_post [line 1988]

static void delete_post( $id)

When a post is deleted, remove location relationships for it.

delete_post action called by WordPress.




Tags:

since:  1.2
access:  public


Parameters:

   $id  

[ Top ]

static method delete_user [line 2012]

static void delete_user( $id)

When a user is deleted, remove location relationships for it.

delete_user action called by WordPress.




Tags:

since:  1.2
access:  public


Parameters:

   $id  

[ Top ]

static method duplicate_geodata [line 1021]

static bool duplicate_geodata( )

Copy missing geo data to and from the standard location (http://codex.wordpress.org/Geodata) for posts, users, and comments.



Tags:

return:  True if no more orphan locations can be found.
since:  1.4
access:  public


[ Top ]

static method filter_update_comment_metadata [line 175]

static void filter_update_comment_metadata( $ok, $object_id, $meta_key, $meta_value, $prev_value)

WordPress filter to prevent updates to geodata fields we've already updated.



Tags:

since:  1.4
access:  public


Parameters:

   $ok  
   $object_id  
   $meta_key  
   $meta_value  
   $prev_value  

[ Top ]

static method filter_update_post_metadata [line 146]

static void filter_update_post_metadata( $ok, $object_id, $meta_key, $meta_value, $prev_value)

WordPress filter to prevent updates to geodata fields we've already updated.



Tags:

since:  1.4
access:  public


Parameters:

   $ok  
   $object_id  
   $meta_key  
   $meta_value  
   $prev_value  

[ Top ]

static method filter_update_user_metadata [line 160]

static void filter_update_user_metadata( $ok, $object_id, $meta_key, $meta_value, $prev_value)

WordPress filter to prevent updates to geodata fields we've already updated.



Tags:

since:  1.4
access:  public


Parameters:

   $ok  
   $object_id  
   $meta_key  
   $meta_value  
   $prev_value  

[ Top ]

static method geocode [line 781]

static bool geocode( mixed $query, &$location, [string $language = ''], array $location)

Try to fill in coordinates and other fields of a location from a textual location search.

Multiple geocoding services may be used. Google services are only used if the default map provider is Google.




Tags:

return:  Whether a lookup succeeded.
since:  1.3
access:  public


Parameters:

mixed   $query   The search string.
array   $location   The location array to geocode, modified.
string   $language  
   &$location  

[ Top ]

static method get_comment_in [line 1945]

static array get_comment_in( $args)

Get multiple comments.

What is the WordPress way? Expect deprecation.




Tags:

return:  Comments.
access:  public


Parameters:

   $args  

[ Top ]

static method get_distinct_located_values [line 1289]

static object WP_DB get_distinct_located_values( string $names, [array $where = null])

Get distinct values of one or more object location fields.

Can be used to get a list of countries with locations, for example.




Tags:

return:  query results.
since:  1.2
access:  public


Parameters:

string   $names   Comma separated table field names.
array   $where   Associtive array of conditional field names and values.

[ Top ]

static method get_location [line 1397]

static object|array get_location( int $location_id, [string $output = OBJECT])

Get a location by ID.



Tags:

return:  Result or null if not found.
since:  1.4
access:  public


Parameters:

int   $location_id  
string   $output   (optional) one of ARRAY_A | ARRAY_N | OBJECT constants. Return an associative array (column => value, ...), a numerically indexed array (0 => value, ...) or an object ( ->column = value ), respectively.

[ Top ]

static method get_object_location [line 1368]

static object|array get_object_location( string $object_name, id $object_id, [string $output = OBJECT])

Get the location of an object.



Tags:

return:  Result or null if not found.
since:  1.3
access:  public
usedby:  GeoMashupDB::get_post_location()


Parameters:

string   $object_name   'post', 'user', a GeoMashupDB::object_storage() index.
id   $object_id   Object
string   $output   (optional) one of ARRAY_A | ARRAY_N | OBJECT constants. Return an associative array (column => value, ...), a numerically indexed array (0 => value, ...) or an object ( ->column = value ), respectively.

[ Top ]

static method get_object_locations [line 1440]

static array get_object_locations( [string $query_args = ''])

Get locations of objects.

  1.  $results GeoMashupDB::get_object_locationsarray(
  2.      'object_name' => 'user',
  3.      'map_cat' => '3,4,8',
  4.      'minlat' => 30,
  5.      'maxlat' => 40,
  6.      'minlon' => -106,
  7.      'maxlat' => -103 )
  8.  );




Tags:

return:  Array of matching rows.
since:  1.3
access:  public
usedby:  GeoMashup::get_locations_json()
usedby:  GeoMashupDB::get_post_locations()


Parameters:

string   $query_args   Override default args.

[ Top ]

static method get_post_location [line 1329]

static object Post get_post_location( id $post_id)

Get the location of a post.



Tags:

return:  location.
since:  1.2
access:  public
uses:  GeoMashupDB::get_object_location()


Parameters:

id   $post_id  

[ Top ]

static method get_post_locations [line 1417]

static array get_post_locations( [string $query_args = ''])

Get locations of posts.



Tags:

return:  Array of matching rows.
since:  1.2
access:  public
uses:  GeoMashupDB::get_object_locations()


Parameters:

string   $query_args   Same as GeoMashupDB::get_object_locations()

[ Top ]

static method get_saved_locations [line 1887]

static array|WP_Error get_saved_locations( )

Get locations with saved names.



Tags:

return:  Array of location rows or WP_Error.
since:  1.2
access:  public


[ Top ]

static method get_user_in [line 1966]

static array get_user_in( $args)

Get multiple users.

What is the WordPress way? Expect deprecation.




Tags:

return:  Users.
access:  public


Parameters:

   $args  

[ Top ]

static method init [line 52]

static void init( )

WordPress action to set up data-related WordPress hooks.



Tags:

since:  1.4
access:  public


[ Top ]

static method install [line 617]

static void install( )

Install or update Geo Mashup tables.



Tags:

since:  1.2
access:  public
uses:  GeoMashupDB::activation_log()


[ Top ]

static method installed_version [line 307]

static string installed_version( string $new_version)

Get the installed database version.



Tags:

return:  The installed database version.
since:  1.2
access:  public


Parameters:

string   $new_version   If provided, overwrites any currently installed version.

[ Top ]

static method join_post_queries [line 378]

static bool join_post_queries( [bool $new_value = null])

Toggle joining of WordPress queries with Geo Mashup tables.

Use the public wrapper GeoMashup::join_post_queries()




Tags:

return:  The current state.
since:  1.3
access:  public


Parameters:

bool   $new_value   If provided, replaces the current active state.

[ Top ]

static method object_storage [line 335]

static array|bool object_storage( string $object_name, [array $new_storage = null])

Get or set storage information for an object name.

Potentially you could add storage information for a new kind of object:

  1.  GeoMashupDB::object_storage'foo'array(
  2.      'table' => $wpdb->prefix 'foos',
  3.      'id_column' => 'foo_id',
  4.      'label_column' => 'foo_display_name',
  5.      'sort' => 'foo_order ASC' )
  6.  );
Would add the necessary information for a custom table of foo objects.




Tags:

return:  The storage information array, or false if not found.
since:  1.3
access:  public


Parameters:

string   $object_name   A type of object to be stored, default is 'post', 'user', and 'comment'.
array   $new_storage   If provided, adds or replaces the storage information for the object name.

[ Top ]

static method parse_query [line 451]

static void parse_query( $query)

WordPress action to capture custom orderby field before it is removed.

parse_query action called by WordPress.




Tags:

since:  1.3
access:  public


Parameters:

   $query  

[ Top ]

static method posts_fields [line 493]

static void posts_fields( $fields)

WordPress filter to add Geo Mashup fields to WordPress post queries.

posts_fields filter called by WordPress.




Tags:

since:  1.3
access:  public


Parameters:

   $fields  

[ Top ]

static method posts_join [line 510]

static void posts_join( $join)

WordPress filter to join Geo Mashup tables to WordPress post queries.

posts_join filter called by WordPress.




Tags:

since:  1.3
access:  public


Parameters:

   $join  

[ Top ]

static method posts_orderby [line 570]

static void posts_orderby( $orderby)

WordPress filter to replace a WordPress post query orderby with a requested Geo Mashup field.

posts_orderby filter called by WordPress.




Tags:

since:  1.3
access:  public


Parameters:

   $orderby  

[ Top ]

static method posts_where [line 529]

static void posts_where( $where)

WordPress filter to incorporate geo mashup query vars in WordPress post queries.

posts_where filter called by WordPress.




Tags:

since:  1.3
access:  public


Parameters:

   $where  

[ Top ]

static method post_meta_key_suggest [line 2021]

static void post_meta_key_suggest( )

Geo Mashup action to echo post meta keys that match a jQuery suggest query.



Tags:

since:  1.4
access:  public


[ Top ]

static method primary_language_code [line 753]

static string primary_language_code( [string $language = null])

Trim a locale or browser accepted languages string down to the 2 or 3 character primary language code.



Tags:

return:  Two (rarely three?) character language code.
since:  1.2
access:  public


Parameters:

string   $language   Local or language code string, NULL for blog locale.

[ Top ]

static method query_vars [line 414]

static void query_vars( $public_query_vars)

WordPress filter to add Geo Mashup public query variables.

query_vars filter called by Wordpress.




Tags:

since:  1.3
access:  public


Parameters:

   $public_query_vars  

[ Top ]

static method remove_geodata_sync_hooks [line 96]

static void remove_geodata_sync_hooks( )

Remove hooks to synchronize Geo Mashup ojbect locations with WordPress geodata.



Tags:

since:  1.4
access:  public


[ Top ]

static method set_location [line 1712]

static id|WP_Error set_location( &$location, [bool $do_lookups = null], array $location)

Save a location.

This can create a new location or update an existing one. If a location exists within 5 decimal places of the passed in coordinates, it will be updated. If the saved_name of a different location is given, it will be removed from the other location and saved with this one. Blank fields will not replace existing data.




Tags:

return:  The location ID saved, or a WordPress error.
since:  1.2
access:  public
uses:  do_action() - Calls 'geo_mashup_added_location' with the location array added
uses:  do_action() - Calls 'geo_mashup_updated_location' with the location array updated


Parameters:

array   $location   Location to save, may be modified to match actual saved data.
bool   $do_lookups   Whether to try to look up address information before saving, default is to use the saved option.
   &$location  

[ Top ]

static method set_object_location [line 1646]

static id|WP_Error set_object_location( string $object_name, id $object_id, id|array $location, [bool $do_lookups = null], [string $geo_date = ''])

Save an object location in the database.

Object data is saved in the geo_mashup_location_relationships table, and location data is saved in geo_mashup_locations.




Tags:

return:  The location ID now assiociated with the object.
since:  1.3
access:  public
usedby:  GeoMashupCommentUIManager::save_comment()
usedby:  GeoMashupPostUIManager::save_post()
usedby:  GeoMashupUIManager::save_posted_object_location()
uses:  do_action() - Calls 'geo_mashup_updated_object_location' with the object name, object id, geo date, and location array
uses:  do_action() - Calls 'geo_mashup_added_object_location' with the object name, object id, geo date, and location array


Parameters:

string   $object_name   'post', 'user', a GeoMashupDB::object_storage() index.
id   $object_id   ID of the object to save the location for.
id|array   $location   If an ID, the location is not modified. If an array of valid location fields, the location is added or updated. If empty, the object location is deleted.
bool   $do_lookups   Whether to try looking up missing location information, which can take extra time. Default is to use the saved option.
string   $geo_date   Optional geo date to associate with the object.

[ Top ]

method get_administrative_name [line 707]

string|null get_administrative_name( string $country_code, [string $admin_code = null], [string $language = ''])

Try to get a language-sensitive place administrative name.

First look in the names cached in the database, then query geonames.org for it. If a name can't be found for the requested language, a default name is returned, usually in the local language. If nothing can be found, returns NULL.




Tags:

return:  Place name in the appropriate language, or if not available in the default language.
since:  1.4
access:  public


Parameters:

string   $country_code   Two-character ISO country code.
string   $admin_code   Code for the administrative area within the country, or NULL to get the country name.
string   $language   Language code, defaults to the WordPress locale language.

[ Top ]


Documentation generated on Sat, 09 Jul 2011 21:54:39 -0700 by phpDocumentor 1.4.3