classes/php5_classes/String.class.php

Properties

Description

Holds the geoString class, which is a swiss army knife for your mouth.

Classes

geoString

Properties

 
 
System  
No 
No 

Description

Utility functions relating to languages and string manipulation.

Methods

breakLongWords, convertCharset, displayPrice, emailDomainCanRegister, fromDB, getCharset, getCharsetFrom, getCharsetTo, isEmail, isFilePath, isInt, isUtf8, removeAccents, specialChars, specialCharsDecode, substr, toDB,

breakLongWords( string   $str, int   $maxLength, string   $breakChar = "\n", ) : string

Description

Breaks up "words" by the maxLength specified. It is multi-byte safe as of version 6.0.0

Arguments

Name Type Description Default
$str string

String to break up the words in

$maxLength int
$breakChar string

What will be used to split up the long words

"\n"

Return value

Type Description
string

Tags

Name Description
since Version 4.0.0 or so

convertCharset( string   $string, string   $charset_from = null, string   $charset_to = null, ) : n/a

Description

Converts a string from a given charset, to a given charset, using the "clean method" as set in the config file, or using utf8_encode() if able to.

Arguments

Name Type Description Default
$string string
$charset_from string null
$charset_to string null

Return value

Type Description
n/a n/a

Tags

Name Description
since Version 6.0.0

displayPrice( float   $price, string   $pre = false, string   $post = false, string   $price_type = null, ) : string

Description

Displays the price with pre and post currency, and formats the number according to number type.

Arguments

Name Type Description Default
$price float

If this is not a float, things mess up

$pre string

String displayed before price. If specified, the value will be put through fromDB. If left at default, will use site wide precurrency.

false
$post string

String displayed after price. If specified, the value will be put through fromDB. If left at default, will use site wide post currency.

false
$price_type string

The type of price, either it is a "cart" price or a "listing" price, if this value is specified and the price is 0, the value could be replaced with string as specified in admin panel. This parameter added in Version 6.0.0

null

Return value

Type Description
string

emailDomainCanRegister( string   $email, ) : bool

Description

determines whether the domain of a given email address is blocked from registration

Arguments

Name Type Description Default
$email string

Return value

Type Description
bool

Tags

Name Description
since Version 6.0.4

fromDB( string   $string, ) : string

Description

Un-does what the toDB function does. Use this when retrieving data that has been processed using toDB prior to being inserted into the database.

Arguments

Name Type Description Default
$string string

Return value

Type Description
string

getCharset( int   $language_id = 0, ) : String

Description

Gets the charset for the given language_id.
(Charset per language not implemented yet! For now, charset is site-wide, set in config.php)

Arguments

Name Type Description Default
$language_id int

Language id to get charset for. Defaults to language used for main page. (Oops! Language ID not really implemented yet, charset is site-wide)

0

Return value

Type Description
String The current charset, used for cleaning strings, see the PHP function htmlspecialchars()

Tags

Name Description
todo Add ability to set charset per language ID.

getCharsetFrom( int   $language_id = 0, ) : string|bool

Description

Gets the charset from for the given language_id.
(Charset per language not implemented yet! For now, charset from is site-wide, set in config.php)

Arguments

Name Type Description Default
$language_id int

Language id to get charset from for. Defaults to language used for main page. (not implemented yet, charset_from is site-wide)

0

Return value

Type Description
string|bool The current charset from setting, or false if there is none. Used to convert FROM charset before cleaning a string, see PHP function mb_convert_encoding()

getCharsetTo(   $language_id = 0, ) : Mixed

Description

Gets the charset to for the given language_id.
(Charset per language not implemented yet! For now, charset to is site-wide, set in config.php)

Arguments

Name Type Description Default
$language_id n/a 0

Return value

Type Description
Mixed The current charset to setting, or false if there is none. Used to convert TO charset after cleaning a string, see PHP function mb_convert_encoding()

isEmail( string   $email, ) : bool

Description

validates whether string passed is a valid e-mail address or not. Validates syntax only, using geoString::EMAIL_PREG_EXPR

Arguments

Name Type Description Default
$email string

Return value

Type Description
bool

Tags

Name Description
since Version 4.0.0 or so

isFilePath( string   $filePath, bool   $allowSingleQuote = false, ) : bool

Description

Makes sure the given file path does not have any invalid characters in it that would not work to use with a filename.

Arguments

Name Type Description Default
$filePath string
$allowSingleQuote bool

If set to true, will "allow" single quotes (defaults to false)

false

Return value

Type Description
bool

Tags

Name Description
since Version 5.0.2

isInt( string   $string, ) : bool

Description

Whether or not the provided string could be considered an int, works a little better than is_numeric since that would return true for something like 'abc' because of hex.

Arguments

Name Type Description Default
$string string

Return value

Type Description
bool

Tags

Name Description
since Version 5.2.0

isUtf8( string   $string, ) : bool

Description

Determines if a string uses UTF8 encoding or not. Note that there is no way to determine what the charset is, but you can tell if it is UTF8 or not (according to W3C I18N articles found on w3c.org)
Note that the regular expresion to determine if UTF-8 was addapted from: http://www.w3.org/International/questions/qa-forms-utf-8.en.php

Arguments

Name Type Description Default
$string string

Return value

Type Description
bool

Tags

Name Description
since 4.0.0

removeAccents(   $string, ) : string

Description

Replaces all accented characters with their non-accented equivelent.
ONLY Works reliably with UTF-8 charsets! This will attempt to account for non-utf8 charset, but may not always work with such a charset. Known side effect: if there are any multi-byte chars that are not converted by this function, they will be changed to ?. This is un-avoidable, the only fix is to add the char to also be converted. This is not designed to (or should it) work with "non-latin" charsets such as farsi, where the characters do not "translate" cleanly into english alphabet. This function should not be used on such charsets.

Arguments

Name Type Description Default
$string n/a

string to be filtered

Return value

Type Description
string

Tags

Name Description
since Version 4.0.0

specialChars( string   $input, string   $charset_clean = null, int   $quoteStyle = null, bool   $entities = false, bool   $addSlashes = false, ) : String

Description

The equivelent of htmlspecialchars(), used to prepare text for using in textarea or as part of an HTML tag, where the text needs to be encoded.
Used to ensure save encoding for charsets that might be messed up by running normal htmlspecialchars() or htmlentities() on them.

Arguments

Name Type Description Default
$input string

The string that gets encoded.

$charset_clean string

The charset being used in the string. If none is given, then the site setting charset is used.

null
$quoteStyle int

The quote style, as used in htmlspecialchars() if not set, set to value that is best for the charset used, usually ENT_COMPAT

null
$entities bool

If set to true, will use htmlentities instead of htmlspecialchars.

false
$addSlashes bool

if set to true, will call addslashes on the string before cleaning it. (handy for inserting inside of html tags inside javascript)

false

Return value

Type Description
String string with special chars HTML encoded.

specialCharsDecode( String   $input,   $charset_clean = null,   $quoteStyle = null,   $limitedEntities = false, ) : String

Description

The equivelent of html_entity_decode(), used to prepare text for using in textarea or as part of an HTML tag, where the text needs to be encoded.
Used to ensure save encoding for charsets that might be messed up by running normal htmlspecialchars() on them. ONLY CALL STATICALLY (geoString::specialCharsDecode())

Arguments

Name Type Description Default
$input String

The string that gets encoded.

$charset_clean n/a null
$quoteStyle n/a null
$limitedEntities n/a false

Return value

Type Description
String string with special chars HTML encoded.

substr( string   $string, int   $start, int|false   $length = false, string   $charset = CHARSET_CLEAN, ) : string

Description

Multibyte-safe version of substr() -- performs exactly like PHP's substr(), but automatically calls in CHARSET_CLEAN

Arguments

Name Type Description Default
$string string
$start int
$length int|false

Length of string, or false/empty for rest of string

false
$charset string

Will pull charset from config.php if not specified

CHARSET_CLEAN

Return value

Type Description
string

toDB( string   $string, ) : string

Description

Use this function to prepare strings to be inserted into the DB.
If this is used to insert a string into the DB, then when retrieving the data, the sister function geoString::fromDB() must be used to un-do what this one does. Note that this is done NOT for sql injection prevention, since the ADODb libraries already provide ways to prevent sql injection, the primary reason is to ensure the best compatibility for charsets.

Arguments

Name Type Description Default
$string string

Return value

Type Description
string String that has been prepared to be inserted into the DB

Constants

  EMAIL_PREG_EXPR = "[a-zA-Z0-9]+[a-zA-Z0-9._+-]*@[a-zA-Z0-9]+(?:(?:\.|-)[a-zA-Z0-9]+)*\.[a-zA-Z]{2,6}"

This is the regular expression used in the preg_match for the function isEmail(). This will ONLY be the expression, it will not contain the surrounding "/" chars that are needed by preg_* functions. Also, the expr will NOT have any "capturing" sub-patterns.
If the e-mail regular expression needs to be used for other purposes, use this var when possible, so that if it needs to be updated, it only needs to be updated in one place. Note: This is used in multiple places, so if changing, be very careful and TEST! Regex does this: Broken up into 2 parts: local part and domain (seperated by @): local part: -can have any alpha-numeric, plus chars: ._+- -the first char can only be alpha-numeric domain: -Can have alpha-numeric, plus chars: .- (note that _ is invalid for domains) -the first char must be alpha-numeric, and multiple . or - are not allowed without alpha-numeric chars between them, so no .. or .- or -- -the last part (the top level domain) must be between 2 and 6 chars, at the time of this being made the shortest top-level are 2 letter country codes, and the longest are .museum (6 chars) and .travel (6 chars)

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.