Overview

Packages

  • Geolib

Classes

  • Geo
  • GeoBody
  • GeoCell
  • GeoDebug
  • GeoHead
  • GeoHtml
  • GeoImg
  • GeoLink
  • GeoList
  • GeoSelect
  • GeoTable
  • GeoTag

Functions

  • b
  • div
  • geoAbsLink
  • geoAnchor
  • geoBody
  • geoButton
  • geoCell
  • geoCheckbox
  • geoDb
  • geoEnd
  • geoFieldSet
  • geoForm
  • geoHead
  • geoHidden
  • geoHtml
  • geoif
  • geoIList
  • geoImg
  • geoImgSubmit
  • geoInput
  • geoIsMultiArr
  • geoItem
  • geoJSLink
  • geoLabel
  • geoLegend
  • geolib_autoloader
  • geoLink
  • geoList
  • geoMultiArr
  • geoNoScript
  • geoPassword
  • geoPre
  • geoRadio
  • geoRadios
  • geoScript
  • geoSelect
  • geoStart
  • geoSubmit
  • geoTable
  • geoTabs
  • geoTag
  • geoText
  • geoTextArea
  • geoTrace
  • geoUpload
  • geovar
  • h1
  • h2
  • h3
  • h4
  • i
  • idiv
  • ispan
  • itag
  • p
  • span
  • Overview
  • Package
  • Class

Class Geo

Geo - Class for static utility functions

Package: Geolib
Category: Utility
License: Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
Author: Peter Pitchford peter@geotonics.com
Version: Release: .1
Since: Class available since Release .1
Link: http://geotonics.com/#geolib
Located at classes/Geo.php
Methods summary
public static boolean
# isValidEmail( string $email )

Checks email address for valid syntax.

Checks email address for valid syntax.

Parameters

$email
Email address

Returns

boolean
public static string
# strReplace( string $find, string $replace, string $string )

Case-insensitive str_replace()

Case-insensitive str_replace()

Parameters

$find
Text to replace
$replace
Replacement
$string
Text to search

Returns

string
Updated text
public static html
# textToHtml( string $txt, boolean $addHtmlEntities = null )

Prepares text and converts it into html.

Prepares text and converts it into html.

Parameters

$txt
Text to convert
$addHtmlEntities
Add html entities

Returns

html
public static string
# writeToFile( string $filename, string $content, string $mode = 'w' )

Writes content to file.

Writes content to file.

Parameters

$filename
Name of file to write to
$content
Content to write to file
$mode
Mode for PHP fwrite

Returns

string
Message with status of write
public static
# natSort2d( array & $arrayInput )

Naturally sorts a Two dimensional array

Naturally sorts a Two dimensional array

Parameters

$arrayInput
Array to be sorted passed by reference
public static mixed
# firstWords( string $string, integer $numWords, boolean $returnString = null )

Parses string to find the first words or first paragraph

Parses string to find the first words or first paragraph

Parameters

$string
String to parse for first words
$numWords
Number of words to return. If true, return first paragraph
$returnString
Return first words, otherwise return an array of parts.

Returns

mixed

Either first words (plus ellipsis if text has been abbreviated), or array of parts Default is array of parts If parts, array[0] is the first $numWords words, array[1] is the rest of the text.

public static mixed
# val( mixed & $var, mixed $default = null )

Sets default value if value is not already set

Sets default value if value is not already set

Parameters

$var
Variable to be set if not already set.
$default
Value to be given to variable if it is not already set.

Returns

mixed
value
public static text|html
# geoTabs( integer $tabs = 1, boolean $text = " " )

Creates tabs for source code or html

Creates tabs for source code or html

Parameters

$tabs
Number of tabs to create
$text

Content of tabs. Default is 3 text spaces. If true, content is 3 html spaces

Returns

text|html
public static string
# exp( string $val, string $index = 1, string $sep = "_" )

Explodes string on given separator, returns given index of the resulting array.

Explodes string on given separator, returns given index of the resulting array.

Parameters

$val
Value to explode
$index
Index of array value to return. Default is 1
$sep
Separator to explode on

Returns

string
$arr[$index] index of array
public static
# setSession( string $name, string $value = null, string $subArrayName = null, string $userSessionName = null, string $arrayName = GEO_INSTANCE )

Sets session variables. Optionally add name of session array

Sets session variables. Optionally add name of session array

Parameters

$name
Name of session variable
$value
Value of session variable
$subArrayName
Name of session sub array.
$userSessionName
Name of user session
$arrayName
Name of session array. Default is "geolib"
public static
# session( string $name, string $subArrayName = null, string $arrayName = GEO_INSTANCE )

Gets session variables.

Gets session variables.

Parameters

$name
Name of session variable
$subArrayName
Name of session sub array.
$arrayName
Name of session array. Default is "geolib"
public static boolean
# email( string $text = "debug", string $subject = "debug", string $address = null, string $from = null )

Sends email with default parameters.

Sends email with default parameters.

Parameters

$text
Email content
$subject
Email subject
$address
Email to address
$from
Email from address

Returns

boolean
success or failure form php mail()
public static array|null
# arraySplit( array $arr, integer $numparts )

Split array into equal pieces

Split array into equal pieces

Parameters

$arr
Array to be split
$numparts
Number of pieces

Returns

array|null
Array of pieces or null if no $arr
public static
# tidy( string $html )

Formats html. Leaves pre and text area tags alone Eliminates all line breaks and multiple spaces in the html, then adds new tabs and line breaks This function is memory intensive! Only use it for debugging.

Formats html. Leaves pre and text area tags alone Eliminates all line breaks and multiple spaces in the html, then adds new tabs and line breaks This function is memory intensive! Only use it for debugging.

Parameters

$html
Html to be formatted

Returns


$html Formatted html
public static array
# arr( mixed $value, boolean $returnEmptyArray = null )

Creates array from value if value is not already an array

Creates array from value if value is not already an array

Parameters

$value
Any value
$returnEmptyArray

If not value, instead of returning value in an array return an emtpy array;

Returns

array
public static mixed
# ifArr( array $array, string|integer $key = null )

Returns value from array, or array if array is not an array or key is null

Returns value from array, or array if array is not an array or key is null

Parameters

$array
Source of value
$key
Array key which indicates value

Returns

mixed
public static float
# dollars( integer|float $number, integer|boolean $divisor = 100, boolean $addDollarSign = null )

Turns cents into dollars

Turns cents into dollars

Parameters

$number
Dollars or cents (default assumes dollars)
$divisor

Devide $number by this int or if $divisor is true or null, just format dollars

$addDollarSign
Optionally add dollar sign to result

Returns

float
public static void,
# redirect( string $uri = null )

Direct browser to a different page before any page output

Direct browser to a different page before any page output

Parameters

$uri

target uri. If null, the requested uri without any parameters is used. If true the requested uri with any parameters is used.

Returns

void,
ends current script and redirects page

Errors

Will cause PHP runtime error if called after any character has been echoed


public static mixed
# makeTabs( array $contentArr, array $tabsClass = null )

Used with jquery to make tabs

Used with jquery to make tabs

Parameters

$contentArr
Contains title and content arrays
$tabsClass
Optional class for tabs

Returns

mixed

html and jquery to create tabs

$contentArr[0] is an array of tab titles $contentArr[1] is an array of tab content If content is multi-dementional, each array is treated the same as $contentArr to create a nested set of tabs.

public static string|html
# cssTable( array $rows, array|string $classes = null, array|string $rowClasses = null, array|string $rowIds = null, array|string $columnClasses = null, string $tableClass = "cssTable" )

Creates a css table from a multidimensional array

Creates a css table from a multidimensional array

Parameters

$rows

A mulitidemensional array. Each row is an array of content If the row index is non numeric: -The row index will be used as the row id -If the row index has one or more underlines "_" -The first segment will be used as the row class -Otherwise, if the row index has no underlines -The row index will also be used as the row class

$classes
Wrapper Class or classes (in addition to the default wrapper class(es))
$rowClasses

If $rowClasses is an array each value is a class for a corresponding row. This will only work is if $rows and $rowClassess have matching indexes. If $rowClasses is a string it becomes the class for all rows

$rowIds

If $rowIds is an array, each value is an id for a corresponding content row If $rowIds is a string, the id for a corresponding content row is the row key plus "_" plus the string.

$columnClasses

If an array each value is a class for a corresponding content column. If a string it becomes the class for all rows

$tableClass
Default class or classes for wrapper. Default is "cssTable"

Returns

string|html
public static boolean
# inArrayi( string $search, array & $array )

Case insensitive version of PHP's in_array

Case insensitive version of PHP's in_array

Parameters

$search
Variable to test for
$array
Target of case insensitive search

Returns

boolean
public static mixed
# ifVal( mixed & $var, mixed & $result1 = true, mixed & $result2 = null )

Allows inline test for value. Same as geoIf, except it can test undefined variables but not constants.

Allows inline test for value. Same as geoIf, except it can test undefined variables but not constants.

Parameters

$var
Variable to be tested for value
$result1
Value to be returned if test is passed
$result2
Value to be returns if test fails

Returns

mixed
Result of test
public static array
# fileNames( string $dirstr = null, boolean $includeSubDirs = false, boolean $geoLinks = true, array $skips = array('error_log', 'Thumbs.db', 'Desktop.ini', '.htaccess', '.htpasswd') )

Recurve method to get file names from a directory.

Recurve method to get file names from a directory.

Parameters

$dirstr
Directory to get filenames from
$includeSubDirs
Flag to indicate names of files from subdirectories will be included.
$geoLinks
Flag to indicate that the filenames will be linked to the files.
$skips
Names of files to skip over

Returns

array
File names
public static HTML
# validText( string $name, array & $values, array & $missing, string $prefix = null, string $printableClass = null, $class = null )

Creates validated text input fields, or simply displays values

Creates validated text input fields, or simply displays values

Parameters

$name
Input name
$values
Reference to array of values (usually from database)
$missing
Reference to array of validation messages
$prefix
Prefix to add to name
$printableClass
Display data as strings instead of text input fields, and use this as class
$class

Returns

HTML
text input with validation
API documentation generated by ApiGen