Class helpers

Description

StockManiac Helper Functionality

collection of public functions that do not fit anywhere else.

Located in /lib/helpers.class.php (line 37)


	
			
Method Summary
 void __construct ()
 int get_fixed_time (int $t, [int $hour = 12], [int $min = 0], [int $sec = 0], [int $mon = false], [int $day = false], [int $year = false])
 string get_human_date (int $date, string $timemark)
 string human_readable_bignumber (int $num, [string $locale = FALSE])
 int|float human_readable_number ( $number, int|float $n)
 int ini_get_number (string $val)
 int|float is_close (int|float $val, int|float $base, int|float $deviation)
 string resolve_php_file_upload_error (int $code)
 bool setting_array_explode ( &$val, [bool $key = FALSE], string $val)
Methods
Constructor __construct (line 45)

constructor

  • access: public
void __construct ()
get_fixed_time (line 85)

Get a fixed point of the same day out of the given timestamp.

By default it is noon (12:00:00). Optional it might be any other hour, day, year, ... suitable for use as callback.

  • access: public
int get_fixed_time (int $t, [int $hour = 12], [int $min = 0], [int $sec = 0], [int $mon = false], [int $day = false], [int $year = false])
  • int $t
  • int $hour
  • int $min
  • int $sec
  • int $mon
  • int $day
  • int $year
get_human_date (line 112)

Return timestamp for various 'human'ish time marks.

accepted timemarks are:

  • start_of_day
  • end_of_day
  • end_of_week
  • end_of_month
  • end_of_year
  • first_of_month
  • first_of_year
  • one_year_ahead

  • access: public
string get_human_date (int $date, string $timemark)
  • int $date
  • string $timemark
human_readable_bignumber (line 221)

Convert a large number to a human readable abbreviation.

Ie. 1500 becomes 1.5 K, 25000000 becomes 25 M, etc ... the returned string will be formatted according to $locale. Its 'negative safe'. NOTE: this method is available in templates as modifier, ie. you can write {$var|human_readable_bignumber}

  • access: public
string human_readable_bignumber (int $num, [string $locale = FALSE])
  • int $num
  • string $locale
human_readable_number (line 202)

Convert $number to int in case the decimal part is 0, otherwise return as it is.

NOTE: this method is available in templates as modifier, ie. you can write {$var|human_readable_number}

  • access: public
int|float human_readable_number ( $number, int|float $n)
  • int|float $n
  • $number
ini_get_number (line 309)

Get a php.ini value and try to resolve 'shorthand strings' such as '5M' or '10G'.

I do wonder why there is no public function call for that, since PHP *is* doing this internally?

  • access: public
int ini_get_number (string $val)
  • string $val
is_close (line 338)

Verify whether val is close or equal to base given the max deviation.

  • access: public
int|float is_close (int|float $val, int|float $base, int|float $deviation)
  • int|float $val
  • int|float $base
  • int|float $deviation
resolve_php_file_upload_error (line 280)

Decode file upload error numbers as documented in the PHP Manual.

I wonder why this is not build into PHP?

  • access: public
string resolve_php_file_upload_error (int $code)
  • int $code
setting_array_explode (line 59)

Convert settings data as it is stored in the database into real array.

Single values (no '|') are kept as they are. The public function operates straight on the given value (=reference) which makes it useful as callback for array_walk_recursive())

  • access: public
bool setting_array_explode ( &$val, [bool $key = FALSE], string $val)
  • string $val
  • bool $key
  • &$val

Documentation generated on Sun, 22 Aug 2010 11:20:20 +0200 by phpDocumentor 1.4.3