Public Method Details |
truncateToSentence |
public string truncateToSentence(string $text, int $length)
|
|
the character count (currently period, question mark, and exclamation point), or the whole string if it is too short. Ex: truncate_to_sentence('Hello World! How are you?', 8) would return 'Hello World!' Ex: truncate_to_sentence('Hello World! How', 80) would return 'Hello World! How'
|
Parameter |
|
|
|
|
Returns |
string |
Author(s) |
|
|
createLink |
public void createLink(string $url, string $text, [ string $title ])
|
|
|
Parameter |
|
|
|
|
|
string |
$title |
= >>null<< |
|
title (optional) |
|
Returns |
void |
Author(s) |
|
|
formatText |
public string formatText(string $text)
|
|
This is for descriptions & longer text bodies. Is smart about whether to use nl2br() or to simply display raw.
|
Parameter |
|
string |
$text |
|
|
String to be formatted |
|
Returns |
string $text Formatted |
|
formatTimestamp |
public string formatTimestamp(integer $time_stamp, [ constant $format ])
|
|
|
Parameter |
|
integer |
$time_stamp |
|
|
Unix Timestamp |
|
|
constant |
$format |
= >>LOCALE_DATE_STD<< |
|
Time formatting string |
|
Returns |
string formatted date |
|
formatDateString |
public string formatDateString(integer $time, [ constant $format ])
|
|
|
Parameter |
|
integer |
$time |
|
|
SQL Timestamp |
|
|
constant |
$format |
= >>LOCALE_DATE_STD<< |
|
Time formatting string |
|
Returns |
string formatted date |
|
&requestFactory |
public object reference &requestFactory(string $path)
|
|
at a path and loads the correct Request module. Very site-specicific (because of path conventions) -- so don't want this to be in Request classes [yet].
|
Parameter |
|
|
Returns |
object reference to new Request instance |
|
getSectionTemplate |
public string getSectionTemplate(object Section &$section, string $url_root)
|
|
so the Section object can be regenerated if its properties change. Useful for inheriting templates from parents.
|
Parameter |
|
|
|
string |
$url_root |
|
|
Warning: documentation is missing. |
|
Returns |
string |
|
findLastDate |
public int findLastDate(int $month, int $year)
|
|
|
Parameter |
|
int |
$month |
|
|
to have last date found for |
|
|
int |
$year |
|
|
to make sure leap year is calculated correctly |
|
Returns |
int last date of given month |
Author(s) |
Sandy Smith <ssmith@forumone.com> |
|
obfuscateAscii |
public string obfuscateAscii(string $text)
|
|
Useful for obfuscating e-mail addresses to prevent them from being harvested by spambots. Note--this will not work well with entities or non-ASCII characters.
|
Parameter |
|
string |
$text |
|
|
Plain ASCII text to be obfuscated |
|
Returns |
string obfuscated text |
|
isValidEmail |
public boolean isValidEmail(string $address)
|
|
is_valid_email(): an e-mail validation utility routine Version 1.1.1 -- September 10, 2000 Written by Michael A. Alderete Please send bug reports and improvements to: This function matches a proposed e-mail address against a validating regular expression. It's intended for use in web registration systems and other places where the user is inputting their e-mail address and you want to check that it's OK. It does NOT attempt to prove that the address exists, only that it COULD exist. Validators which look up the host, try to validate an MX record, etc. can significantly slow the response time of your application; network connections are significantly more expensive than regular expressions, especially on days when the Internet is slow. It also doesn't attempt to ensure that the TLD is a known valid TLD. Doing a lookup against a table isn't too expensive, performance-wise, but given the explosion in Internet usage, keeping a lookup table up-to-date would be problematic. The validating regular expression is significantly more accurate than many others I've seen in example code. It still won't prevent users from entering bogus entries like "a@b.com", but then, if the user really doesn't want to give your their e-mail address, there's nothing you can do about it, other than make a confirmation e-mail a requirement to registering. You should clean up the input e-mail address in your code before you validate it, with trim() and strtolower(), if you're planning to save it into a database or otherwise preserve it beyond the one-time use. The validator doesn't depend on it, but you'll want to save clean data! Example of usage: (assumes the user entry form variable is $f_email) $f_email = strtolower(trim($f_email)); if (is_valid_email($f_email)) { // Do database save here // Or send them a confirmation e-mail } Implementation notes: The routine uses the Perl Compatible Regular Expressions (pcre) routine preg_match(), which my benchmarking indicates is about twice as fast as the standard ereg() routines in this usage (10 seconds vs. 21 seconds to do 50,000 validations). If your installation of PHP doesn't have the pcre package compiled in, you can switch to using the is_valid_email_eregi() version, also provided. Notes about the expression: - The user name needs to be pretty tolerant; you'd be amazed at what can be in this portion of a valid address - The expression allows an unlimited number of sub-domains, e.g.: user@my.really.deep.sub.domain.com is allowed - The only four-character TLD that's valid is "arpa", but the expression doesn't know that, and allows any four-character TLD. ***********************************************************************
|
Parameter |
|
string |
$address |
|
|
E-mail address |
|
Returns |
boolean |
Author(s) |
Michael A. Alderete <michael@aldosoft.com> |
|
getImageLink |
public string getImageLink(string $url, [ constant $restrict, string $class, string $alt ])
|
|
and returns an HTML img tag. Only works on local images.
|
Parameter |
|
string |
$url |
|
|
The local URL (everything after the domain) |
|
|
constant |
$restrict |
= >>array('by'<< |
|
Associative array. Valid keys are 'by' (string 'width' or 'height') and 'max' (int) |
|
|
string |
$class |
= >>null<< |
|
CSS class |
|
|
string |
$alt |
= >>null<< |
|
Alt text |
|
Returns |
string The img tag. |
|
&listFromPicktable |
public object ListWidget &listFromPicktable(string $name, string $picktable, [ array $prepend ], string $value_field)
|
|
a Syntax pick table object.
|
Parameter |
|
string |
$name |
|
|
, name of list widget |
|
|
string |
$picktable |
|
|
, name of pick table |
|
|
array |
$prepend |
= >>null<< |
|
, optional array of values to prepend to options array |
|
|
string |
$value_field |
|
|
Warning: documentation is missing. |
|
Returns |
object ListWidget |
|
&listFromPicktableTree |
public object ListWidget &listFromPicktableTree(string $name, string $picktable, [ array $prepend ], $depth_label)
|
|
a Syntax pick table object.
|
Parameter |
|
string |
$name |
|
|
, name of list widget |
|
|
string |
$picktable |
|
|
, name of pick table |
|
|
array |
$prepend |
= >>null<< |
|
, optional array of values to prepend to options array |
|
|
|
$depth_label |
|
|
Warning: documentation is missing. |
|
Returns |
object ListWidget |
|
getSortDirection |
public string getSortDirection(string $field, object [unknown] &$Request)
|
|
|
Parameter |
|
string |
$field |
|
|
FIeld to sort by |
|
|
object [unknown] |
&$Request |
|
|
the request object |
|
Returns |
string The SQL direction for sorting |
|
isUrlExternal |
public bool isUrlExternal(string $url)
|
|
|
Parameter |
|
string |
$url |
|
|
the url to test |
|
Returns |
bool true if external, false if on this site |
|