ZenMagick 0.9.10


zenmagick.store.shared.utils\ZMTools
utils\ZMTools.php at line 32

Class ZMTools

ZMTools

public class ZMTools

(System) Tools.

Author:
DerManoMann

Constant Summary
final static str

RANDOM_CHARS

final static str

RANDOM_DIGITS

final static str

RANDOM_HEX

final static str

RANDOM_MIXED

Method Summary
static boolean

compareStoreUrl(string url1, string url2)

Compare URLs.

static void

fmod_round(mixed x, mixed y)

fmod variant that can handle values < 1.

static void

ifModifiedSince(string timestamp, boolean true)

Helper for conditional get support.

static array

parseDateString(string s, string format, array defaults)

Parse a date according to the given format.

static float

parseMoney(mixed money, string currencyCode, string amount)

Parse a money amount.

static array

parseRange(string range)

Convert a numeric range definition into an array of single values.

static array

parseRssDate(string date)

Parse RSS date.

static void

resolveZCClass(string clazz)

Resolve the given zen-cart class.

static void

setFilePerms(mixed files, boolean recursive, array perms)

Apply user/group settings to file(s) that should allow ftp users to modify/delete them.

static string

translateDateString(string s, string from, string to)

Convert a (UI) date from one format to another.

Constant Detail

utils\ZMTools.php at line 34

RANDOM_CHARS

public final static str RANDOM_CHARS = 'chars'

utils\ZMTools.php at line 33

RANDOM_DIGITS

public final static str RANDOM_DIGITS = 'digits'

utils\ZMTools.php at line 36

RANDOM_HEX

public final static str RANDOM_HEX = 'hex'

utils\ZMTools.php at line 35

RANDOM_MIXED

public final static str RANDOM_MIXED = 'mixed'

Method Detail

utils\ZMTools.php at line 226

compareStoreUrl

public static boolean compareStoreUrl(string url1, string url2)

Compare URLs.

This is defined only for URLs within the store.

NOTE: This function may not work with SEO solutions.

Parameters:
url1 - The first URL to compare.
url2 - Optional second URL; default is null to compare to the current URL.
Returns:
true if URLs are considered equal (based on various URL parameters).

utils\ZMTools.php at line 367

fmod_round

public static void fmod_round(mixed x, mixed y)

fmod variant that can handle values < 1.


utils\ZMTools.php at line 98

ifModifiedSince

public static void ifModifiedSince(string timestamp, boolean true)

Helper for conditional get support.

Parameters:
timestamp - The last change date of whatever resource this is about.
true - if a body should be returned, false if the resource changed.

utils\ZMTools.php at line 167

parseDateString

public static array parseDateString(string s, string format, array defaults)

Parse a date according to the given format.

This function supports the following format token:

  • hh - hours
  • ii - minutes
  • ss - seconds
  • dd - day
  • mm - month
  • cc - century
  • yy - year
  • yyyy - full year (if found both cc and yy will be populated accordingly

Parameters:
s - A date; usually either provided by the user or a database date.
format - The date format
defaults - Optional defaults for components; default is null for none.
Returns:
The individual date components as map using the token as keys.

utils\ZMTools.php at line 84

parseMoney

public static float parseMoney(mixed money, string currencyCode, string amount)

Parse a money amount.

Parameters:
amount - The amount.
currencyCode - The currency.
Returns:
The amount.

utils\ZMTools.php at line 58

parseRange

public static array parseRange(string range)

Convert a numeric range definition into an array of single values.

A range might be a single value, a range; for example 3-8 or a list of both.

Valid examples of ranges are:

  • 3
  • 3,4,8
  • 3,4-6,8
  • 1,3-5,9,13,100-302

Parameters:
range - The range value.
Returns:
List of numeric (int) values.

utils\ZMTools.php at line 210

parseRssDate

public static array parseRssDate(string date)

Parse RSS date.

Parameters:
date - The date.
Returns:
An array with 3 elements in the order [day] [month] [year].

utils\ZMTools.php at line 358

resolveZCClass

public static void resolveZCClass(string clazz)

Resolve the given zen-cart class.

This function ensures that the given class is loaded.

Parameters:
clazz - The class name.

utils\ZMTools.php at line 305

setFilePerms

public static void setFilePerms(mixed files, boolean recursive, array perms)

Apply user/group settings to file(s) that should allow ftp users to modify/delete them.

The file group attribute is only going to be changed if the $perms parameter is not empty.

This method may be disabled by setting fs.permissions.fix to false.

Parameters:
files - Either a single filename or list of files.
recursive - Optional flag to recursively process all files/folders in a given directory; default is false.
perms - Optional file permissions; defaults are taken from the settings fs.permissions.defaults.folder for folder, fs.permissions.defaults.file for files.

utils\ZMTools.php at line 136

translateDateString

public static string translateDateString(string s, string from, string to)

Convert a (UI) date from one format to another.

Parameters:
s - The date as received via the UI.
from - The current format of the date string.
to - The target format.
Returns:
The formatted date string or '' (if $s is empty).

ZenMagick 0.9.10