higrid.net


hiGrid\hgGridcommon
hgcommon.php at line 17

Class hgGridcommon

hgGridcommon

public abstract class hgGridcommon

Author:
She Yi [email protected]
Copyright:
HiGrid.net

Field Summary
static mixed

$days

static mixed

$days3

static mixed

$month

static mixed

$month3

static mixed

$patrVal

static mixed

$types

Method Summary
static string

toXml(array data, string rootNodeName, SimpleXMLElement xml, str encoding, bool cdata)

Function for converting to an XML document.

static string

quote(string string, boolean whether, mixed js, bool forUrl)

Quotes a javascript string.

static string

encode(mixed PHP, mixed value)

Encodes a PHP variable into javascript representation.

static array

decode(string json)

Decodes json string to PHP array.

static mixed

Strip(mixed value)

Strip slashes from a varaible if PHP magic quotes are on

static string

generatePattern(string dateformat)

Internal function which generates regex pattern from date pattern

static array

date_parse(string dateformat, string date, boolean localize)

Converts the string date to array by using the pattern generated by generatePattern() function

static mixed

parseDate(string patternFrom, string date, string patternTo)

Parses a $format and $date value and return the date formated via $newformat.

static mixed

GetParam(string parameter_name, string default_value)

Return the value from POST or from GET

static array

array_extend(array a, array b)

"Extend" recursively array $a with array $b values (no deletion in $a, just added and updated values)

static void

phpTojsDate(string phpdate)

Convert the php date string to Java Script date string

static string|false

sprintfn(string format, array args)

version of sprintf for cases where named arguments are desired (php syntax)with sprintf: sprintf('second: %2$s ; first: %1$s', '1st', '2nd');with sprintfn: sprintfn('second: %second$s ; first: %first$s', array( 'first' => '1st', 'second'=> '2nd' ));

Field Detail

hgcommon.php at line 20

days

public static mixed $days = array(...)

hgcommon.php at line 19

days3

public static mixed $days3 = array(...)

hgcommon.php at line 22

month

public static mixed $month = array(...)

hgcommon.php at line 21

month3

public static mixed $month3 = array(...)

hgcommon.php at line 31

patrVal

public static mixed $patrVal = ""

hgcommon.php at line 23

types

public static mixed $types = array(...)

Method Detail

hgcommon.php at line 42

toXml

public static string toXml(array data, string rootNodeName, SimpleXMLElement xml, str encoding, bool cdata)

Function for converting to an XML document. Pass in a multi dimensional array or object and this recrusively loops through and builds up an XML document.

Parameters:
rootNodeName - - what you want the root node to be - defaultsto data.
xml - - should only be used recursively
Returns:
XML

hgcommon.php at line 97

quote

public static string quote(string string, boolean whether, mixed js, bool forUrl)

Quotes a javascript string. After processing, the string can be safely enclosed within a pair of quotation marks and serve as a javascript string.

Parameters:
string - to be quoted
whether - this string is used as a URL
Returns:
the quoted string

hgcommon.php at line 122

encode

public static string encode(mixed PHP, mixed value)

Encodes a PHP variable into javascript representation.

Example:

$options=array('key1'=>true,'key2'=>123,'key3'=>'value');
echo hgGridcommon::encode($options);
// The following javascript code would be generated:
// {'key1':true,'key2':123,'key3':'value'}

For highly complex data structures use jsonEncode and jsonDecode to serialize and unserialize.

Parameters:
PHP - variable to be encoded
Returns:
the encoded string

hgcommon.php at line 174

decode

public static array decode(string json)

Decodes json string to PHP array. The function is used when the encoding is diffrent from utf-8

Parameters:
json - string to decode

hgcommon.php at line 201

Strip

public static mixed Strip(mixed value)

Strip slashes from a varaible if PHP magic quotes are on

Parameters:
value - to be striped

hgcommon.php at line 229

generatePattern

public static string generatePattern(string dateformat)

Internal function which generates regex pattern from date pattern


hgcommon.php at line 256

date_parse

public static array date_parse(string dateformat, string date, boolean localize)

Converts the string date to array by using the pattern generated by generatePattern() function


hgcommon.php at line 352

parseDate

public static mixed parseDate(string patternFrom, string date, string patternTo)

Parses a $format and $date value and return the date formated via $newformat. If the $patternTo is not set return the timestamp.

Parameters:
patternFrom - the format of the date to be parsed
date - the value of the data.
patternTo - the new format of the $date

hgcommon.php at line 365

GetParam

public static mixed GetParam(string parameter_name, string default_value)

Return the value from POST or from GET


hgcommon.php at line 382

array_extend

public static array array_extend(array a, array b)

"Extend" recursively array $a with array $b values (no deletion in $a, just added and updated values)


hgcommon.php at line 401

phpTojsDate

public static void phpTojsDate(string phpdate)

Convert the php date string to Java Script date string


hgcommon.php at line 465

sprintfn

public static string|false sprintfn(string format, array args)

version of sprintf for cases where named arguments are desired (php syntax)

with sprintf: sprintf('second: %2$s ; first: %1$s', '1st', '2nd');

with sprintfn: sprintfn('second: %second$s ; first: %first$s', array( 'first' => '1st', 'second'=> '2nd' ));

Parameters:
format - sprintf format string, with any number of named arguments
args - array of [ 'arg_name' => 'arg value', ... ] replacements to be made
Returns:
result of sprintf call, or bool false on error

higrid.net