classes/php5_classes/Region.class.php

Properties

Description

Holds the geoRegion class.

Classes

geoRegion

Properties

 
 
System  
No 
No 

Description

Stuff for regions and sub-regions.

Methods

RadiusAssistant, _remove, billingCountrySelector, billingRegionSelector, billingStateSelector, displayRegionsForListing, getAbbreviationForRegion, getCountryNameForListing, getCountryNameForUser, getDefaultNameForRegion, getDirectSiblingsOfRegion, getEndRegions, getInstance, getLabelForLevel, getLevel, getLevelLabels, getLevels, getLevelsForOverrides, getListingCountByRegion, getListingCountBySubRegion, getLowestLevel, getMaxLevel, getNameForListingLevel, getNameForRegion, getParents, getRegionCount, getRegionFields, getRegionIdFromAbbreviation, getRegionInfo, getRegionNameById, getRegionNamesForListingByLevel, getRegionWithParents, getRegionsForListing, getRegionsForUser, getRegionsFromParent, getStateNameForListing, getStateNameForUser, getStatesDescendedFromCountry, getSubRegionAbbreviationById, getSubRegionCount, getSubRegionNameById, getTopLevelRegions, isFancy, regionSelector, remove, setListingEndRegions, setListingRegions, setUserRegions,

RadiusAssistant( float   $Latitude, float   $Longitude, int   $distance, string   $units = \geoNumber::UNITS_MILES, ) : n/a

Description

Used by the search class.

Arguments

Name Type Description Default
$Latitude float
$Longitude float
$distance int
$units string \geoNumber::UNITS_MILES

Return value

Type Description
n/a n/a

_remove( int   $region_id, bool   $dryRun, array   $info, ) : n/a

Description

Used internally to recursively remove a region

Arguments

Name Type Description Default
$region_id int
$dryRun bool
$info array

Return value

Type Description
n/a n/a

Tags

Name Description
since Version 7.0.0

billingCountrySelector( String   $name, array   $prevalue = false, ) : array

Description

Gets the HTML for the country selector in the billing form

Arguments

Name Type Description Default
$name String

prefix for the HTML name of the created dropdowns

$prevalue array

array of starting regions

false

Return value

Type Description
array

billingRegionSelector( String   $name, array   $prevalue = false, ) : array

Description

Convenience method to get both the country and state selectors for the Billing form

Arguments

Name Type Description Default
$name String

prefix for the HTML name of the created dropdowns

$prevalue array

array of starting regions

false

Return value

Type Description
array

billingStateSelector( String   $name, int   $forCountry = 0, array   $prevalue = false, ) : array

Description

Gets the HTML for the state selector in the billing form. NOTE: used by AJAX call to adjust state selections on-the-fly with country selections

Arguments

Name Type Description Default
$name String

prefix for the HTML name of the created dropdowns

$forCountry int

the ID of the country to get states for. if not set, checks $prevalue for a country level

0
$prevalue array

array of starting regions

false

Return value

Type Description
array

displayRegionsForListing( int   $listing_id, int   $maxLevel = 0, int   $regionOrder = 0, ) : String

Description

Returns the names of regions associated with a listing in a format suitable for display

Arguments

Name Type Description Default
$listing_id int
$maxLevel int

The highest level region that should be shown in the list

0
$regionOrder int 0

Return value

Type Description
String

getAbbreviationForRegion( int   $region_id, ) : string

Description

Gets the (billing) abbreviation to use for a region, or its full name if no abbreviation is set

Arguments

Name Type Description Default
$region_id int

Return value

Type Description
string

getCountryNameForListing( int   $listing_id, ) : String

Description

Convenience method to get the "country" name for a given listing in the current language

Arguments

Name Type Description Default
$listing_id int

Return value

Type Description
String

getCountryNameForUser( int   $user_id, ) : String

Description

Convenience method to get the "country" name for a given user in the current language

Arguments

Name Type Description Default
$user_id int

Return value

Type Description
String

getDefaultNameForRegion( int   $region, int   $listing_id = 0, int   $user_id = 0, ) : string

Description

Gets the "default" name for a region. For use if getNameForRegion fails (for instance, if the region itself has been removed by the admin, but listings still use it)

Arguments

Name Type Description Default
$region int

ID of the region

$listing_id int

If looking up a listing, the listing's id. 0 otherwise

0
$user_id int

If looking up a user, the user's id. 0 otherwise

0

Return value

Type Description
string

getDirectSiblingsOfRegion( int   $region_id, ) : array

Description

Gets the regions on the same level as the chosen region that have the same parent (returned array includes the original region)

Arguments

Name Type Description Default
$region_id int

Return value

Type Description
array

getEndRegions( array   $regions, ) : array

Description

Simple tool to take array of regions that are in the below example array structure, and returns a flat array for each "end region". This does NOT check for duplicates. This is useful to get end regions for use in method setListingEndRegions()
Sample array: array ( 0 => array ( 1 => 1, 2 => 245, 3 => 532, ), 1 => array ( 1 => 38, 2 => '' ), 2 => array ( 1 => 1 2 => 287 ) ) Sample return: array ( 0 => 532, 1 => 38, 2 => 287 )

Arguments

Name Type Description Default
$regions array

Return value

Type Description
array

Tags

Name Description
since Version 7.1.0

getInstance( ) : \geoRegion

Description

Get instance of region class.

Return value

Type Description
\geoRegion

getLabelForLevel( int   $level, ) : string

Description

Gets the label for the requested level in the language currently in use

Arguments

Name Type Description Default
$level int

Return value

Type Description
string

Tags

Name Description
since 7.0.0

getLevel( int   $level, int   $language_id = 1, ) : boolean|array

Description

Gets a specific level, this is like calling getLevels but only returns a specific level.

Arguments

Name Type Description Default
$level int
$language_id int

Will fill in the label with the one for the specified language ID, if the level id labeled.

1

Return value

Type Description
boolean|array The array of level information or bool false on error.

Tags

Name Description
since Version 7.0.0

getLevelLabels( int   $level, ) : boolean|array

Description

Gets the labels for all the different languages for the given level. Note that this takes care of DB encoding, all labels are in un-encoded format.

Arguments

Name Type Description Default
$level int

Return value

Type Description
boolean|array The array of labels, or false on error.

Tags

Name Description
since Version 7.0.0

getLevels( ) : array

Description

Gets all the region levels and their settings in associative array

Return value

Type Description
array

Tags

Name Description
since Version 7.0.0

getLevelsForOverrides( ) : Array

Description

Figures out which geographic levels are assigned to specific level types.
For use in preventing those types of levels from appearing in individual form fields

Return value

Type Description
Array

getListingCountByRegion( int   $region_id, ) : int

Description

Get the number of listings in a given region

Arguments

Name Type Description Default
$region_id int

Return value

Type Description
int

Tags

Name Description
deprecated 7.0.0

getListingCountBySubRegion( int   $subregion, ) : int

Description

Get the number of listings in a particular sub region.

Arguments

Name Type Description Default
$subregion int

Return value

Type Description
int

Tags

Name Description
deprecated 7.0.0

getLowestLevel( ) : int

Description

Gets the number of the lowest active/enabled region level

Return value

Type Description
int

Tags

Name Description
since 7.0.0

getMaxLevel( bool   $onlyEnabled = false, ) : int

Description

Gets the maximum level for regions found in the system.

Arguments

Name Type Description Default
$onlyEnabled bool

If true, gets the max level when you take into account if it is enabled or not.

false

Return value

Type Description
int Max number of levels found with regions in them.

getNameForListingLevel( int   $listing_id, int   $level, ) : String

Description

Convenience method to get the name for a generic region at a certain level for a given listing in the current language

Arguments

Name Type Description Default
$listing_id int
$level int

Return value

Type Description
String

getNameForRegion( int   $region_id, ) : string

Description

Gets the plain-text name for a given region in the current language.

Arguments

Name Type Description Default
$region_id int

Return value

Type Description
string

getParents( int   $region_id, bool   $use_bottom = false, ) : boolean|array

Description

Get the parent regions for the specified region ID in an array.

Arguments

Name Type Description Default
$region_id int
$use_bottom bool

If true, will also return the requested region info as part of the array of parent regions, handy for things like displaying the full breadcrumb.

false

Return value

Type Description
boolean|array Returns an array with all the parent region info, the array index is the parent region level and the info is same as returned by {@see geoRegion::getRegioninfo()}

Tags

Name Description
since Version 7.0.0

getRegionCount( ) : int

Description

Gets the number of main regions.

Return value

Type Description
int Number of regions found.

getRegionFields( ) : array

Description

Gets the fields as used in the geoFields class when getting default fields.

Return value

Type Description
array

Tags

Name Description
since Version 7.0.0

getRegionIdFromAbbreviation( String   $abbreviation, ) : int

Description

Converts a Billing Abbreviation into the corresponding Region ID Number

Arguments

Name Type Description Default
$abbreviation String

Return value

Type Description
int

getRegionInfo( int   $region_id, ) : array|bool

Description

Gets info about a region

Arguments

Name Type Description Default
$region_id int

Return value

Type Description
array|bool Returns info about region, or false on error.

Tags

Name Description
since Version 7.0.0

getRegionNameById( int|string   $region_id, ) : string|bool

Description

Gets the "name" for the given region ID.

Arguments

Name Type Description Default
$region_id int|string

The region ID OR abbreviation

Return value

Type Description
string|bool will return false if problem occurs, or the name (empty string if region id not found) @deprecated 7.0.0

getRegionNamesForListingByLevel( int   $listing_id, int   $region_order = 0, ) : array

Description

Gets the displayable (per-language) names for a chosen listing, sorted by region level.

Arguments

Name Type Description Default
$listing_id int
$region_order int

The region order, 0 for "main" region (as opposed to an additional region). {@since Version 7.1.3}

0

Return value

Type Description
array

getRegionWithParents( int   $child, ) : Array

Description

returns an array of the chosen region and all its parents

Arguments

Name Type Description Default
$child int

Typically, this should be a terminal region

Return value

Type Description
Array

getRegionsForListing( int   $listing_id, int   $maxLevel = 0, int   $regionOrder = 0, ) : Array

Description

Gets the array of regions from the requested listing

Arguments

Name Type Description Default
$listing_id int
$maxLevel int 0
$regionOrder int 0

Return value

Type Description
Array

getRegionsForUser( int   $user_id, ) : Array

Description

Gets the array of regions from the requested user's registration data

Arguments

Name Type Description Default
$user_id int

Return value

Type Description
Array

getRegionsFromParent( string   $fieldName, int   $parent = 0, Array   $prevalue = array(), int   $maxLevel = false, bool   $skipEmptyRegions = false, ) : Array

Description

Gets data about the enabled child regions of a region. With no parameter, gets top-level regions.
Most commonly, this is used by regionSelector() and friends

Arguments

Name Type Description Default
$fieldName string

HTML "name" of the array of fields to build

$parent int

The ID of the region to aquire the children of

0
$prevalue Array

Array of starting values for the dropdowns. Region IDs keyed by Level.

array()
$maxLevel int

The highest level dropdown to show, based on settings specific to where selector is being used

false
$skipEmptyRegions bool

If true, regions that do not contain at least one listing will be omitted

false

Return value

Type Description
Array

getStateNameForListing( int   $listing_id, ) : String

Description

Convenience method to get the "state" name for a given listing in the current language

Arguments

Name Type Description Default
$listing_id int

Return value

Type Description
String

getStateNameForUser( int   $user_id, ) : String

Description

Convenience method to get the "state" name for a given user in the current language

Arguments

Name Type Description Default
$user_id int

Return value

Type Description
String

getStatesDescendedFromCountry( int   $country = 0, ) : Array

Description

gets IDs for all states that are decendants of the chosen country.
note that there may be other levels in the middle -- this gets ALL states underneath the country if country is not specified, simply gets all states from the db

Arguments

Name Type Description Default
$country int

ID of the country to get

0

Return value

Type Description
Array

getSubRegionAbbreviationById( int   $subregion_id, ) : string

Description

get the abbreviation of a state supplying the state id and region id

Arguments

Name Type Description Default
$subregion_id int

Return value

Type Description
string

Tags

Name Description
deprecated 7.0.0

getSubRegionCount( int   $region_id, ) : int

Description

Gets the number of sub-regions attached to the given region.

Arguments

Name Type Description Default
$region_id int

Return value

Type Description
int

getSubRegionNameById( int|string   $region_id, ) : string|bool

Description

Gets the name for the given region and sub region ID.

Arguments

Name Type Description Default
$region_id int|string

sub-region ID OR abbriviation

Return value

Type Description
string|bool The name, or empty string if not found, or false if problem occured.

Tags

Name Description
deprecated 7.0.0

getTopLevelRegions( bool   $withDisabled = false, ) : array

Description

Gets an array of regions with parent=0. Mostly for use in / formated for GeoNav addon

Arguments

Name Type Description Default
$withDisabled bool

if true, also include disabled regions

false

Return value

Type Description
array

isFancy( ) : bool

Description

Whether or not the states will depend on what country is selected.

Return value

Type Description
bool

Tags

Name Description
deprecated 7.0.0 -- will always return false

regionSelector( String   $fieldName, Array   $prevalue = array(), int   $maxLevel = false, bool   $required = false, bool   $skipEmptyRegions = false, ) : String

Description

Used to display a series of dropdowns that allow selecting a region

Arguments

Name Type Description Default
$fieldName String

name to use for form fields created by this method

$prevalue Array

Array of starting values for the dropdowns. Region IDs keyed by Level.

array()
$maxLevel int

The highest level dropdown to show, based on settings specific to where selector is being used

false
$required bool

If true, "required field" CSS styling will be added to this selector

false
$skipEmptyRegions bool

If true, regions that do not contain at least one listing will be omitted from the selector

false

Return value

Type Description
String

remove( array|int   $regions, bool   $dryRun = true, ) : bool|array

Description

Removes the specified region and all sub-regions. Or if dryRun is true (which is default), will only do a dry-run and return an array indicating how many at each "level" would be affected by this deletion.
This will remove sub-regions recursively as well.

Arguments

Name Type Description Default
$regions array|int

array of regions to remove, or single region ID to remove

$dryRun bool

Set to false to go forward with the removal.

true

Return value

Type Description
bool|array If dryRun is true, returns an array indicating how many of each level of regions will be removed. If dryRun is false, simply returns bool true if removal successful, false otherwise.

Tags

Name Description
since Version 7.0.0

setListingEndRegions( int   $listingId, array   $endRegions, int   $startOrder = 0, ) : boolean

Description

Set regions for the listing according to array of "end regions", meaning the furthest down region ID for each selected region.

Arguments

Name Type Description Default
$listingId int
$endRegions array

Array of end regions, in the order that they should be added, the first entry in the array should be the "primary" region. Note that any "duplicate" end regions should already be removed before calling this or it will stop at the duplicate.

$startOrder int

Can be used to start adding at a specific order, this is useful if you know that the primary region has already been added to a listing, can skip that one and start with additional regions

0

Return value

Type Description
boolean True if successful, false otherwise

Tags

Name Description
since Version 7.1.0

setListingRegions( int   $listingId, array   $regions, ) : bool

Description

Assigns a set of primary regions to a given listing. This is a shortcut to using {@see geoRegions::setListingEndRegions()} for only the primary regions.

Arguments

Name Type Description Default
$listingId int
$regions array

Return value

Type Description
bool success

setUserRegions( int   $userId, array   $regions, ) : bool

Description

Assigns a set of regions to a given user

Arguments

Name Type Description Default
$userId int
$regions array

Return value

Type Description
bool success

Properties

$max_latitude, $max_longitude, $min_latitude, $min_longitude,

float  public  static $max_latitude =

Holds results of RadiusAssistant()


float  public  static $max_longitude =

Holds results of RadiusAssistant()


float  public  static $min_latitude =

Holds results of RadiusAssistant()


float  public  static $min_longitude =

Holds results of RadiusAssistant()


Documentation was generated by phpDocumentor 2.2.0 .

Namespaces

  • global

    Packages

    • Default
      • ExampleAddon
        • addon_example_admin
          In charge of doing stuff on the admin side, this is optional.
        • addon_example_info
          Required class for addons, this is the Addon information class, used by the addon system to determine what the addon can do. Also contains info about the addon that can be viewed in the addon management page in the admin.
        • addon_example_pages
          Addon page class, used by the addon system to display pages on the client side.
        • addon_example_setup
          This class is not required. If it, and the function for a particular routine exist, then that function will be called IN ADDITION TO the automated routines of the addon framework.
        • addon_example_tags
          Expects one function for each tag. Function name should be the same as the tag name. Can also have a constructor if anything needs to be constructed.
        • addon_example_util
          This is where to put functions that the main part of the addon will use.
        • eWidgetOrderItem
          This order item is designed to allow users on your site to purchase an eWidget.
      • System
        • DataAccess
          This is the main Database access object.
        • Singleton
          Singleton method class
        • _templateOrderItem
          Developers: use this file as a template to create a new order item.
        • _templatePaymentGateway
          This is the "developer template" payment gateway handler, a developer could use this file as a starting point for creating a new payment gateway in the system.
        • geoAPI
          The main system class for receiving and handling remote API calls, this acts as a translation layer between the communication with the "outside" and each API call.
        • geoAddon
          This is the class that handles anything and everything to do with addons.
        • geoArrayTools
          Utility functions for manipulating arrays
        • geoBrowse
          Contains functions common to browsing listings
        • geoBrowsingFilter
          System for activating, storing, and deactivating browsing filters.
        • geoCJAX
          Class that wraps the CJAX_FRAMEWORK, used to get the CJAX class.
        • geoCache
          This is the main part of the Geo cache system, it does all the "low level" stuff like writing files and escaping cache data.
        • geoCacheModule
          Part of Geo Cache system, specifically tuned to work best with cacheing module data (which will be an array).
        • geoCachePage
          Cache system specifically tuned to work best with cacheing output of pages and modules
        • geoCacheSetting
          Part of Geo Cache system, specifically tuned to work best with cacheing site-wide key=value type settings.
        • geoCacheText
          Part of Geo Cache system, this part specifically tuned to work best with cacheing language specific messages.
        • geoCalendar
          Holds utility method(s) for manipulating stuff dealing with calendar selector.
        • geoCart
          This class is behind the cart, loading all the order items and such and displaying, and processing all the different pages.
        • geoCategory
          Utility class that holds various methods to do stuff with categories in the system.
        • geoCombineResources
          This class helps to combine CSS and JS files, minify them, and optionally compress them.
        • geoCron
          This is the cron job backend, it handles all the communication and security and all that.
        • geoCrypt
          Class to use for encrypting information that needs to be able to be retrieved later.
        • geoDate
          Holds utility method(s) for manipulating stuff dealing with dates.
        • geoEmail
          Class that sends out e-mails.
        • geoFields
          Class that holds settings information for fields to use.
        • geoFieldsField
          A mini object to hold data about a specific field.
        • geoFile
          As the name implies, this is used for file-based utility methods.
        • geoFilter
          A few utility methods, good for filtering stuff.
        • geoFormatString
          Used to display a message nice and pretty, we'll probably be getting rid of this class though so don't go crazy using it.
        • geoHTML
          Class to generate chunks of HTML that are very common, used the most in the admin panel.
        • geoImage
          This class is responsible for a lot of the image processing, along with other aspects like generating the image tag for thumbnails.
        • geoInvoice
          This is the invoice object representing an invoice in the system.
        • geoLeveledField
          Class for doing common things with leveled fields.
        • geoListing
          A listing object, basically a container object for particular listing.
        • geoListingDisplay
          This is basically a container that is responsible for helping to display {listing .
        • geoListingFeed
          Class that helps to render RSS or other types of feeds based on list of listings.
        • geoMaster
          This is dedicated class for getting the value of, and setting, the various "master switches" within the software. Since this is meant as an easy way to get the values of master switches, most of the methods are static.
        • geoNumber
          Utility functions relating to number conversion/manipulation/validation ect.
        • geoOrder
          The geoOrder object, an object representation of an order in the system.
        • geoOrderItem
          The class that all order items must extend.
        • geoPC
          Used for login credential validation, password hashing, etc. along with software licensing.
        • geoPagination
          Utility functions useful for generating pagination of a results page such as when browing ads or searching
        • geoPaymentGateway
          This class should be extended by each different payment gateway, this will have some default functions that each gateway will inherit, and also has a few final static methods used by the system to affect all order items.
        • geoPlanItem
          A container to hold settings for a particular order item type, according to price plan ID, and optionally category ID for category specific settings.
        • geoRecurringBilling
          The geoRecurringBilling object, an object representation of a recurring billing in the system.
        • geoRegion
          Stuff for regions and sub-regions.
        • geoRegistry
          Handy little object, can be used to set registry type settings.
        • geoSearchUtils
          Class for search utilities.
        • geoSellerBuyer
          Handles back-end for the seller/buyer payment gateways, to allow the buyer to more easily pay the seller for a won auction. This handles the underlying system, but the actual work is done by individual seller/buyer gateways, for instance the Paypal buy-now functionality.
        • geoSession
          Manages session storage and session cookies for user sessions.
        • geoString
          Utility functions relating to languages and string manipulation.
        • geoStringData
          This class is to store accented chars, to be used by {@link geoString::removeAccents()}, mainly to keep the String.class.php file un-cluttered.
        • geoTable
          NOT FULLY IMPLEMENTED! Do not use this class yet as it is not finished and may change drastically before we are done with it, or may even be removed.
        • geoTableRow
          NOT FULLY IMPLEMENTED! Do not use this class yet as it is not finished and may change drastically before we are done with it, or may even be removed.
        • geoTableRowset
          NOT FULLY IMPLEMENTED! Do not use this class yet as it is not finished and may change drastically before we are done with it, or may even be removed.
        • geoTableSelect
          Class used to generate a select query, useful when multiple areas want to affect a single query, for instance when generating a search query and there are addons involved.
        • geoTables
          Used to hold database table names, used throughout the code.
        • geoTemplate
          Template object that extends the Smarty class (a 3rd party library) to enable using templates to display things.
        • geoTransaction
          This is the object used for a transaction in the order and invoice system.
        • geoUser
          An object representative of a certain user in the system.
        • geoUserRating
          Store, retrieve, and display inter-user ratings
        • geoUtil
          Misc utility functions
        • geoView
          As the name implies, this is used for creating the page view. It does take a little setup (like any class), the setup is normally done in the display_page method in geoSite, or display_page in geoAdmin if displaying a page in the admin.
        • iApiTransport
          Interface for API Transports, a transport must implement this interface for the system to use it.
        • iOrderItem
          You cannot have abstract static functions, so instead need to have an interface to force the given static functions to be defined.
        • metaDbTables
          Used so that old locations that use the old name geoTables will still work.