Packageindex Classtrees Modulegroups Elementlist Report XML Files

File: c:/web/jpeto2/jpeto/jpeto_util.php
JPETo - James's Publishing & Editing Tool - jpeto_system

jpeto_util

jpeto_util

This class provides some utility functions like number & date formatting, etc.

 

private class jpeto_util

This class provides some utility functions like number & date formatting, etc.
You may use these functions as statics and call them like jpeto_util::FUNCTIONNAME()

 

Public Method Summary

void

jpeto_util()

constructor for jpeto_util

Private Method Summary

void

maxValue(integer $value1, integer $value2)

returns the bigger value of 2 values
integer

minValue(integer $value1, integer $value2)

returns the smaller value of 2 values
string

formatString(string $value, integer $numChars, [ boolean $addRight ])

returns a formatted String of a fixed length (filled up with blanks)
string

formatInteger(string $value, integer $numDigits)

returns a formatted integer with leading zeroes
string

formatDecimal(string $value, [ integer $decimals ])

returns a formatted decimal
string

percentage(float $value, float $total)

calculates and returns a percentage value
boolean

isNumber(string $value)

returns true if the given value is a number
boolean

isGoodString(string &$value)

returns true if a string is not null and not empty
boolean

combineIfGoodString([ string $pre ], string &$value, [ string $app ])

combines the three given Strings if $value is a god string
string

joinIfArray([ string $glue ], string $value)

joins the array element with $glue
string

toTableString(string &$value)

returns   if the given string is empty or null
string

toFileName(string $value)

converts a given string to a correct filename (without any special characters)
string

string2xml(string $value)

converts a string to xml data
string

array2xml(string $array)

converts an (nested) array to xml data
string

object2xml(object jpeto_object $object)

converts an object to xml data
string

html2mail(string $html)

Converts HTML Code to Mail-conform HTML Code
string

bin2mail(string $bin)

Converts Binary Data to Mail-conform Data
string

sqlDateFormat(string $SqlDate, [ string $Format ])

Converts the extended ISO 8601 format "yyyy-mm-dd hh:mm:ss" date to dd.mm.yyyy date
string

sqlDateToUnixDate(string $SqlDate)

Converts the extended ISO 8601 format "yyyy-mm-dd hh:mm:ss" date to a Unix Timestamp
string

unixDateToSqlDate(string $UnixDate)

Converts a Unix Timestamp to the extended ISO 8601 format "yyyy-mm-dd hh:mm:ss"
string

sqlDateSum([ string $SqlDate1, string $SqlDate2 ])

Calculates the Sum of 2 SqlDates
integer

getWeekNumber(string $SqlDate)

returns the number of the week in the microsoft office format
string

memFormat(integer $bytes)

Formats a given amount of bytes (=integer) in MBytes, KBytes,...
string

formatPath(string $path)

This function formats a Path according to your operating system, using forward slash (Unix) or backslash (windows)
boolean

syntaxCheckEmail(string $email)

checks the syntax of an email adress
String

addUrlParameter(String $key, String $value)

this function adds a key=value to the current QueryString
void

updateGetInSession()

Updates all session-registered get-parameters (=queryString)
void

updatePostInSession()

Updates all session-registered post-parameters
String

getProjectName()

This function retrieves the ProjectName
boolean

loadObjectFromArray(object [unknown] &$object, array &$array, [ string $prefix, boolean $removePrefix, boolean $removeFromArray ])

these function sets an object properties with the given Array values depending on
void

array_remove(Array &$array, String $value)

This function removes a given value from the given array
String

markLinks(String $in, [ string $linkArray ])

This function converts all (hyper-) links in the given string to html links

Public Method Details

jpeto_util

public void jpeto_util( )

  constructor for jpeto_util
no need to run that!

Returns void


Private Method Details

maxValue

private void maxValue( integer $value1, integer $value2 )

  returns the bigger value of 2 values

Parameter
integer $value1
integer $value2
Returns void


minValue

private integer minValue( integer $value1, integer $value2 )

  returns the smaller value of 2 values

Parameter
integer $value1
integer $value2
Returns integer $minValue


formatString

private string formatString( string $value, integer $numChars, [ boolean $addRight ] )

  returns a formatted String of a fixed length (filled up with blanks)

Parameter
string $value
the original String
integer $numChars
the fix number of characters to display
boolean $addRight = >>true<<
Returns string $value


formatInteger

private string formatInteger( string $value, integer $numDigits )

  returns a formatted integer with leading zeroes

Parameter
string $value
the original Integer
integer $numDigits
the fix number of digits to display
Returns string $numDigits


formatDecimal

private string formatDecimal( string $value, [ integer $decimals ] )

  returns a formatted decimal

Parameter
string $value
the original decimal
integer $decimals = >>2<<
the fix number of decimals to display
Returns string $value


percentage

private string percentage( float $value, float $total )

  calculates and returns a percentage value

Parameter
float $value
float $total
Returns string $perc


isNumber

private boolean isNumber( string $value )

  returns true if the given value is a number

Parameter
string $value
Returns boolean $isNumber


isGoodString

private boolean isGoodString( string &$value )

  returns true if a string is not null and not empty

Parameter
string &$value
the String to check
Returns boolean $isGoodString


combineIfGoodString

private boolean combineIfGoodString( [ string $pre ], string &$value, [ string $app ] )

  combines the three given Strings if $value is a god string

Parameter
string $pre = >>""<<
the first part of the result String
string &$value
the String to check (and the middle part of the result String)
string $app = >>""<<
the last part of the result String
Returns boolean $combineIfGoodString


joinIfArray

private string joinIfArray( [ string $glue ], string $value )

  joins the array element with $glue

Parameter
string $glue = >>""<<
the glue
string $value
the array
Returns string $joinedArray


toTableString

private string toTableString( string &$value )

  returns &nbsp; if the given string is empty or null

Parameter
string &$value
the String to check
Returns string $value


toFileName

private string toFileName( string $value )

  converts a given string to a correct filename (without any special characters)

Parameter
string $value
the filename to correct
Returns string $ret_value

the corrected filename


string2xml

private string string2xml( string $value )

  converts a string to xml data

Parameter
string $value
the string to convert
Returns string $xml


array2xml

private string array2xml( string $array )

  converts an (nested) array to xml data

Parameter
string $array
the array to convert
Returns string $xml


object2xml

private string object2xml( object jpeto_object $object )

  converts an object to xml data

Parameter
object jpeto_object $object
Returns string $xml


html2mail

private string html2mail( string $html )

  Converts HTML Code to Mail-conform HTML Code

Parameter
string $html
the html code
Returns string $mail


bin2mail

private string bin2mail( string $bin )

  Converts Binary Data to Mail-conform Data

Parameter
string $bin
the binary data
Returns string $mail


sqlDateFormat

private string sqlDateFormat( string $SqlDate, [ string $Format ] )

  Converts the extended ISO 8601 format "yyyy-mm-dd hh:mm:ss" date to dd.mm.yyyy date

Parameter
string $SqlDate
the date-string to convert
string $Format = >>"%d.%m. %Y"<<
the date-format to use
Returns string $String


sqlDateToUnixDate

private string sqlDateToUnixDate( string $SqlDate )

  Converts the extended ISO 8601 format "yyyy-mm-dd hh:mm:ss" date to a Unix Timestamp

Parameter
string $SqlDate
the date-string to convert
Returns string $String


unixDateToSqlDate

private string unixDateToSqlDate( string $UnixDate )

  Converts a Unix Timestamp to the extended ISO 8601 format "yyyy-mm-dd hh:mm:ss"

Parameter
string $UnixDate
the date-string to convert
Returns string $String


sqlDateSum

private string sqlDateSum( [ string $SqlDate1, string $SqlDate2 ] )

  Calculates the Sum of 2 SqlDates

Parameter
string $SqlDate1 = >>"1970-01-01 00:00:00"<<
- e.g. 1970-01-01 00:00:00 (extended ISO 8601 format "yyyy-mm-dd hh:mm:ss")
string $SqlDate2 = >>"0000-00-00 00:00:00"<<
- e.g. 0001-00-00 00:00:00 (extended ISO 8601 format "yyyy-mm-dd hh:mm:ss")
Returns string $result

absolute - e.g. 1971-01-01 00:00:00 (extended ISO 8601 format "yyyy-mm-dd hh:mm:ss")


getWeekNumber

private integer getWeekNumber( string $SqlDate )

  returns the number of the week in the microsoft office format
(first week has got 01/01 within)

Parameter
string $SqlDate
e.g. 1970-01-01 00:00:00 (extended ISO 8601 format "yyyy-mm-dd hh:mm:ss")
Returns integer $week


memFormat

private string memFormat( integer $bytes )

  Formats a given amount of bytes (=integer) in MBytes, KBytes,...

Parameter
integer $bytes
Returns string $String


formatPath

private string formatPath( string $path )

  This function formats a Path according to your operating system, using forward slash (Unix) or backslash (windows)

Parameter
string $path
Returns string $path


syntaxCheckEmail

private boolean syntaxCheckEmail( string $email )

  checks the syntax of an email adress

Parameter
string $email
Returns boolean $correct


addUrlParameter

private String addUrlParameter( String $key, String $value )

  this function adds a key=value to the current QueryString

Parameter
String $key
the name of the parameter
String $value
the value
Returns String $QueryString


updateGetInSession

private void updateGetInSession( )

  Updates all session-registered get-parameters (=queryString)

Returns void


updatePostInSession

private void updatePostInSession( )

  Updates all session-registered post-parameters

Returns void


getProjectName

private String getProjectName( )

  This function retrieves the ProjectName

Returns String $projectname


loadObjectFromArray

private boolean loadObjectFromArray( object [unknown] &$object, array &$array, [ string $prefix, boolean $removePrefix, boolean $removeFromArray ] )

  these function sets an object properties with the given Array values depending on
the Condition "Prefix" and optionally removes the Prefix before setting and/or thevalues from the Array

Parameter
object [unknown] &$object
array &$array
string $prefix = >>""<<
boolean $removePrefix = >>false<<
boolean $removeFromArray = >>false<<
Returns boolean $success


array_remove

private void array_remove( Array &$array, String $value )

  This function removes a given value from the given array

Parameter
Array &$array
the array
String $value
the Value to remove
Returns void


markLinks

private String markLinks( String $in, [ string $linkArray ] )

  This function converts all (hyper-) links in the given string to html links

Parameter
String $in
the string to convert
string $linkArray = >>""<<
the types of links to convert (see sourcecode to understand format)
Returns String $out

the converted string



Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta