tce__functions__general_8php

It appears that you are using AdBlocking software. The cost of running this website is covered by advertisements. If you like it please feel free to a small amount of money to secure the future of this website.
tce_functions_general.php File Reference

Namespaces

 com\tecnick\tcexam\shared
 TCExam Shared Area.
 

Functions

 F_count_rows ($dbtable, $where=“)
 
 F_empty_to_null ($str)
 
 F_zero_to_null ($num)
 
 F_getBoolean ($str)
 
 F_check_unique ($table, $where, $fieldname=FALSE, $fieldid=FALSE)
 
 unhtmlentities ($text_to_convert, $preserve_tagsign=FALSE)
 
 F_compact_string ($string, $dquotes=false)
 
 F_replace_angulars ($str)
 
 F_substr_utf8 ($str, $start=0, $length)
 
 F_text_to_xml ($str)
 
 F_xml_to_text ($str)
 
 F_text_to_tsv ($str)
 
 F_tsv_to_text ($str)
 
 showRequiredField ($mode=1)
 
 utrim ($txt)
 
 getNormalizedIP ($ip)
 
 getIpAsInt ($ip)
 
 getIpAsString ($ip)
 
 F_formatFloat ($num)
 
 F_formatPercentage ($num, $ratio=true)
 
 F_formatPdfPercentage ($num, $ratio=true)
 
 F_formatXMLPercentage ($num, $ratio=true)
 
 F_getUTCoffset ($timezone)
 
 F_db_getUTCoffset ($timezone)
 
 getDataXML ($data, $level=1)
 
 getDataTSVHeader ($data, $prefix=“)
 
 getDataTSV ($data)
 
 F_html_to_TSV ($str)
 
 F_select_table_header_element ($order_field, $orderdir, $title, $name, $current_order_field=“, $filter=”)
 
 getContrastColor ($color)
 
 F_isURL ($str)
 
 F_utf8_normalizer ($str, $mode=‘NONE’)
 
 bcdechex ($dec)
 

Detailed Description

General functions.

Function Documentation

bcdechex (   $dec)

Convert an long integer number to a Hexadecimal representation

Parameters
string | int$decDecimal number to convert.
Returns
string containing the HEX representation in uppercase.
Author
Nicola Asuni
Since
2013-07-02

F_check_unique (   $table,
  $where,
  $fieldname = FALSE,
  $fieldid = FALSE 
)

Check if specified fields are unique on table.

Parameters
$table(string) table name
$where(string) SQL where clause
$fieldname(mixed) name of table column to check
$fieldid(mixed) ID of table row to check
Returns
bool true if unique, false otherwise

F_compact_string (   $string,
  $dquotes = false 
)

Remove the following characters:

  • “\t” (ASCII 9 (0x09)), a tab.
  • “\n” (ASCII 10 (0x0A)), a new line (line feed)
  • “\r” (ASCII 13 (0x0D)), a carriage return
  • “\0” (ASCII 0 (0x00)), the NUL-byte
  • “\x0B” (ASCII 11 (0x0B)), a vertical tab
Parameters
$string(string) input string to convert
$dquotes(boolean) If true add slash in fron of double quotes;
Returns
converted string

F_count_rows (   $dbtable,
  $where =  
)

Count rows of the given table.

Parameters
$dbtable(string) database table name
$where(string) optional where SQL clause (including the WHERE keyword).
Returns
number of rows

F_db_getUTCoffset (   $timezone)

Returns the UTC time offset yo be used with CONVERT_TZ function

Parameters
$timezone(string) current user timezone
Returns
string UTC time offset (+HH:mm)

F_empty_to_null (   $str)

Prepare field value for SQL query.
Returns the quoted string if not empty, NULL otherwise.

Parameters
$str(string) string to check.
Returns
string $str quoted if not empty, NULL otherwise

F_formatFloat (   $num)

Format a percentage number.

Parameters
$num(float) number to be formatted
Returns
formatted string

F_formatPdfPercentage (   $num,
  $ratio = true 
)

format a percentage number

Parameters
$num(float) number to be formatted
$ratio(boolean) Set to true if the number is a ratio between 0 and 1, false if is a percentage number between 0 an 100.
Returns
string

F_formatPercentage (   $num,
  $ratio = true 
)

Format a percentage number.

Parameters
$num(float) Number to be formatted.
$ratio(boolean) Set to true if the number is a ratio between 0 and 1, false if is a percentage number between 0 an 100.
Returns
formatted string

F_formatXMLPercentage (   $num,
  $ratio = true 
)

format a percentage number for XML

Parameters
$num(float) number to be formatted
$ratio(boolean) Set to true if the number is a ratio between 0 and 1, false if is a percentage number between 0 an 100.
Returns
string

F_getBoolean (   $str)

Returns boolean value from string or integer.
This function is needed to get the right boolean value from boolean field returned by PostgreSQL query.

Parameters
$str(string) string to check.
Returns
boolean value.

F_getUTCoffset (   $timezone)

Returns the UTC time offset in seconds

Parameters
$timezone(string) current user timezone
Returns
int UTC time offset in seconds

F_html_to_TSV (   $str)

Convert HTML code to TSV string.

Parameters
$str(string) HTML string to convert.
Returns
string TSV

F_isURL (   $str)

Returns true if the string is an URL.

Parameters
$str(string) String to check.
Returns
boolean true or false.

F_replace_angulars (   $str)

Replace angular parenthesis with html equivalents (html entities).

Parameters
$str(string) input string to convert
Returns
converted string

F_select_table_header_element (   $order_field,
  $orderdir,
  $title,
  $name,
  $current_order_field = ,
  $filter =  
)

Display table header element with order link.

Parameters
$order_field(string) name of table field
$orderdir(string) order direction
$titletitle (string) field of anchor link
$namecolumn (string) name
$current_order_field(string) current order field name
$filter(string) additional parameters to pass on URL
Returns
table header element string

F_substr_utf8 (   $str,
  $start = 0,
  $length 
)

Performs a multi-byte safe substr() operation based on number of characters.

Parameters
$str(string) input string
$start(int) substring start index
$length(int) substring max lenght
Returns
substring

F_text_to_tsv (   $str)

Escape some special characters for TSV output.

Parameters
$str(string) input string to convert
Returns
converted string

F_text_to_xml (   $str)

Escape some special characters (< > &).

Parameters
$str(string) input string to convert
Returns
converted string

F_tsv_to_text (   $str)

Unescape some special characters from TSV format.

Parameters
$str(string) input string to convert
Returns
converted string

F_utf8_normalizer (   $str,
  $mode = ‘NONE’ 
)

Normalize the UTF-8 input string. Modes greater than 0 requires php5-intl module. Please edit this function to implement your custom normalization method.

Parameters
$str(string) UTF-8 string to normalize.
$mode(int) Normalization type: NONE=None; C=Normalization Form C (NFC) - Canonical Decomposition followed by Canonical Composition; D=Normalization Form D (NFD) - Canonical Decomposition; KC=Normalization Form KC (NFKC) - Compatibility Decomposition, followed by Canonical Composition; KD=Normalization Form KD (NFKD) - Compatibility Decomposition; CUSTOM=Custom normalization using user defined function ‘user_utf8_custom_normalizer’.
Returns
normalized string using the specified algorithm.

F_xml_to_text (   $str)

Unescape some special characters (< > &).

Parameters
$str(string) input string to convert
Returns
converted string

F_zero_to_null (   $num)

Prepare field value for SQL query.
Returns the num if different from zero, NULL otherwise.

Parameters
$num(string) string to check.
Returns
string $num if != 0, NULL otherwise

getContrastColor (   $color)

Get a black or white color that maximize contrast.

Parameters
$color(string) color in HEX format.
Returns
(string) Color.

getDataTSV (   $data)

Get data in TSV format (tab separated text values).

Parameters
$data(array) Array of data.
Returns
string XML data

getDataTSVHeader (   $data,
  $prefix =  
)

Get data headers (keys) in TSV header (tab separated text values).

Parameters
$data(array) Array of data (key => value).
$prefix(string) Prefix to add to keys.
Returns
string data

getDataXML (   $data,
  $level = 1 
)

Get data array in XML format.

Parameters
$data(array) Array of data (key => value).
$level(int) Indentation level.
Returns
string XML data

getIpAsInt (   $ip)

Converts a string containing an IP address into its integer value.

Parameters
$ip(string) IP address to convert.
Returns
int IP address as integer number.
Since
7.1.000 (2009-02-13)

getIpAsString (   $ip)

Converts a string containing an IP address into its integer value and return string representation.

Parameters
$ip(string) IP address to convert.
Returns
int IP address as string.
Since
9.0.033 (2009-11-03)

getNormalizedIP (   $ip)

Convert all IP addresses to IPv6 expanded notation.

Parameters
$ip(string) IP address to normalize.
Returns
string IPv6 address in expanded notation or false in case of invalid input.
Since
7.1.000 (2009-02-13)

showRequiredField (   $mode = 1)

Return a string containing an HTML acronym for required/not required fields.

Parameters
$mode(int) field mode: 1=not required; 2=required.
Returns
html string

unhtmlentities (   $text_to_convert,
  $preserve_tagsign = FALSE 
)

Reverse function for htmlentities.

Parameters
$text_to_convert(string) input string to convert
$preserve_tagsign(boolean) if true preserve <> symbols, default=FALSE
Returns
converted string

utrim (   $txt)

Strip whitespace (or other characters) from the beginning and end of an UTF-8 string and replace the “\xA0” with normal space.

Parameters
$txt(string) The string that will be trimmed.
Returns
string The trimmed string.

 

© 2004-2017 – Nicola Asuni - Tecnick.com - All rights reserved.
about - disclaimer - privacy