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):

Methods



Class Details

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



Tags:

since:  1.2
access:  public


[ Top ]


Class Methods


static method category_located_post_count [line 1534]

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 delete_location [line 1490]

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()


Parameters:

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

[ Top ]

static method delete_object_location [line 1464]

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


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 get_administrative_name [line 460]

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

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, or null.
since:  1.2
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 ]

static method get_distinct_located_values [line 988]

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_object_location [line 1072]

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

Get the location of an object.



Tags:

return:  Result.
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 1126]

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 1030]

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 1101]

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 1513]

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 object_storage [line 68]

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 set_location [line 1355]

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


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, defaults to no.
   &$location  

[ Top ]

static method set_object_location [line 1294]

static id|WP_Error set_object_location( string $object_name, id $object_id, id|array $location, [bool $do_lookups = true], [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:  GeoMashupUIManager::save_posted_object_location()


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 true.
string   $geo_date   Optional geo date to associate with the object.

[ Top ]


Documentation generated on Thu, 18 Feb 2010 20:41:28 +0000 by phpDocumentor 1.4.3