Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

Util Class Reference
[Helper Classes]

List of all members.

Detailed Description

Util handles all the oddball functions that are useful.

This is useful because you dont have to require the util.inc.php class everytime you want a function, it is automagically handled by autoload.

Definition at line 10 of file util.inc.php.

Static Public Member Functions

 redirect ($url)
 Redirects the user to the specified URL.
 dump ($data)
 dumps out information about a variable, nicely formatted.
 setUrlParam ($url, $name, $value)
 sets a parameter in a url.
 isValidEmail ($email)
 Checks is the provided email address is formally valid.
 ieDrawClear ()
 draws a clearing div.
 spawnHttpAsync ($page)
 This function calls a script and then moves on.
 getUrlContents ($link)
 This function opens a url and gets its contents.
 getBlurb ($text, $length=255, &$truncated=null)
 This function gets a blurb of text from a larger chunk of text.
 getNumberSuffix ($n)
 This function adds a suffix (st, nd, rd, th) to a supplied number.
 formatPhoneNumber ($number)
 shellExec ($call)
 noCache ()
 Prevents the current page from being cached in the client's browser.
 pluralize ($str, $amount=null, $num=false)
 Pluralizes the given string.


Member Function Documentation

Util::dump data  )  [static]
 

dumps out information about a variable, nicely formatted.

Parameters:
$data the variable to be dumped

Definition at line 28 of file util.inc.php.

Referenced by BaseAdmin::drawViewCachePage().

Util::formatPhoneNumber number  )  [static]
 

Definition at line 234 of file util.inc.php.

Util::getBlurb text,
length = 255,
&$  truncated = null
[static]
 

This function gets a blurb of text from a larger chunk of text.

It also strips it of tags and calls nl2br to give it basic formatting.

Parameters:
$text the text to take the blurb from.
$length how long of a blurb. default = 255 characters
$truncated is a boolean of whether the string was truncated. the variable you pass in will be changed! Use this to determine if it was truncated or not (so you can show a 'more...' link, etc.)
Returns:
the possibly truncated string.

Definition at line 173 of file util.inc.php.

References Linkify::bbcode().

Util::getNumberSuffix n  )  [static]
 

This function adds a suffix (st, nd, rd, th) to a supplied number.

Parameters:
a number to add suffix to.
Returns:
the number with suffix added.

Definition at line 213 of file util.inc.php.

Util::getUrlContents link  )  [static]
 

This function opens a url and gets its contents.

It can be tricky to do this across hosts with different configs. cURL is pretty widely used, so thats how it is implemented.

Parameters:
$link the url to load
Returns:
the contents of the url.

Definition at line 147 of file util.inc.php.

Util::ieDrawClear  )  [static]
 

draws a clearing div.

This is to fix float issues, and also for certain places where IE just barfs if there is no clearing div. Make sure you also declare this css data:

div#clear { clear: both; height: 0; line-height: 0; }

Definition at line 114 of file util.inc.php.

Referenced by BaseModule::drawNavigation(), and BaseModule::drawSideBar().

Util::isValidEmail email  )  [static]
 

Checks is the provided email address is formally valid.

Parameters:
string $email email address to be checked
Returns:
true if the email is valid, false otherwise

Definition at line 93 of file util.inc.php.

Util::noCache  )  [static]
 

Prevents the current page from being cached in the client's browser.

Definition at line 253 of file util.inc.php.

Util::pluralize str,
amount = null,
num = false
[static]
 

Pluralizes the given string.

If $amount is not null, it is a numeric quantity that determines whether the string is pluralized or not. If $num is not false, then the number is prepended to the string. If $num is -1, then HTML entities are used to represent fractional numbers.

Parameters:
$str the string to pluralize
$amount the numeric quantity (default: null)
$num true if $amount should be prepended to the result, and -1 if $amount should use HTML entities
Returns:
the pluralized string, optionally included numbers

Definition at line 283 of file util.inc.php.

Referenced by BaseThread::drawCommentSummary(), Time::elapsed(), and BaseCalendar::getDateContent().

Util::redirect url  )  [static]
 

Redirects the user to the specified URL.

Parameters:
$url the url to redirect to

Definition at line 17 of file util.inc.php.

Referenced by BaseModule::assertLogin(), BaseJumper::checkHost(), BaseObject::deletePost(), BaseUser::drawActivatePage(), BaseEvent::drawAttendPage(), BaseEvent::drawInvitePage(), BaseEvent::drawLeavePage(), BaseForum::drawPostPage(), BaseEvent::drawRSVPPage(), BaseRPSGame::drawTauntPage(), BaseEvent::drawUnInvitePage(), BaseComment::drawViewPage(), BaseObject::editPagePostSuccess(), BaseImage::editPagePostSuccess(), BaseComment::editPagePostSuccess(), BaseRPSGame::initDefendPage(), BaseOutbox::initDeletePage(), BaseInbox::initDeletePage(), BaseTicket::initGatePage(), BaseUser::initLogoutPage(), ObjectManager::initMainPage(), BaseCalendar::initMainPage(), BaseAlert::initViewPage(), BaseTicket::process(), BaseUser::processLoginForm(), and BaseUser::registrationPostSuccess().

Util::setUrlParam url,
name,
value
[static]
 

sets a parameter in a url.

it will either add the parameter afterwards, eg foo.php?name=value, or if there are already parameters, it will add it in like this with a &: foo.php?old=val&name=value. Additionally, it will also replace the value if it finds it in the paramters in the url.

Parameters:
$url the url to modify
$name the name of the parameter
$value the value of the parameter
Returns:
the formatted url with new name/value pair added

Definition at line 48 of file util.inc.php.

Referenced by BaseModule::getUrl().

Util::shellExec call  )  [static]
 

Definition at line 245 of file util.inc.php.

Referenced by BaseImage::centerCrop(), Img::convert(), Img::crop(), Img::flip(), EasyFileCache::flush(), Img::resize(), Img::rotate(), and Img::scale().

Util::spawnHttpAsync page  )  [static]
 

This function calls a script and then moves on.

The called script *must* call ignore_user_abort() otherwise it will die. This is used for things that may take a while... like resizing images. Currently it only supports async calling on the the current host.

Parameters:
$page the page you want to load. eg. /module/page

Definition at line 127 of file util.inc.php.

References Config::get().

Referenced by BaseImage::resizeUploadedFile().


The documentation for this class was generated from the following file:
Generated on Fri Oct 27 12:26:42 2006 for BaseJumper by doxygen 1.3.9.1