dmBridge PHP API
DMString Class Reference

A collection of static string validation & manipulation methods. More...

Static Public Member Functions


Detailed Description

A collection of static string validation & manipulation methods.

Author:
Alex Dolski <alex.dolski@unlv.edu> http://www.opensource.org/licenses/mit-license.php

Definition at line 15 of file DMString.php.


Member Function Documentation

static DMString::camelCaseToUnderscore ( str) [static]
Parameters:
stringstr
Returns:
string
Since:
0.4

Definition at line 22 of file DMString.php.

static DMString::clean ( str) [static]

Cleans a string of invalid UTF-8 characters using a strategy informed by http://www.phpwact.org/php/i18n/charsets.

This may strip out a lot more than just invalid UTF-8 characters; see the inline comments.

Parameters:
stringstr
Returns:
string Cleaned string
Since:
0.9

Definition at line 36 of file DMString.php.

static DMString::highlight ( term,
str,
class = "dmHighlightedTerm" 
) [static]

"Highlights" all occurrences of $term in $str by enclosing them in <span> elements with class $class.

Parameters:
stringterm Term to match
stringstr String in which to search
stringclass
Returns:
string

Definition at line 83 of file DMString.php.

Referenced by DMObjectTemplateHelper::getHtmlHighlightedFullText(), and DMObjectResultsTemplateHelper::getHtmlResults().

static DMString::hyperlink ( str,
DOMDocument $  dxml = null 
) [static]

Searches through text strings and adds HTML anchor tags around any words beginning with http://, https://, ftp://, or gopher://.

Parameters:
stringstr
DOMDocumentdxml
Returns:
If $dxml is null, a string; otherwise a DOMDocumentFragment
Since:
0.1

Definition at line 99 of file DMString.php.

Referenced by DMObjectTemplateHelper::getHtmlMetadataAsDL().

static DMString::isUTF8 ( str) [static]
Parameters:
stringstr
Returns:
Boolean True if $str is a valid UTF-8 string; false if not.
Since:
0.9

Definition at line 156 of file DMString.php.

static DMString::isValidHostname ( str) [static]

Adapted from EmailAddressValidator::check_domain_portion() by Dave Child.

Supposedly RFC2822-compliant.

Parameters:
str
Author:
Dave Child
See also:
http://code.google.com/p/php-email-address-validation/
Since:
0.1

Definition at line 174 of file DMString.php.

Referenced by DMMailer::isValidEmail().

static DMString::isValidIPv4Address ( str,
allow_ranges = false 
) [static]
Parameters:
stringstr
Booleanallow_ranges
Returns:
bool
Since:
0.1

Definition at line 213 of file DMString.php.

Referenced by DMLogger::setClientIP().

static DMString::isValidPathname ( str,
check_exists = false 
) [static]
Parameters:
stringstr
Booleancheck_exists
Returns:
Boolean
Since:
0.1

Definition at line 233 of file DMString.php.

static DMString::paranoid ( str,
allowed = array() 
) [static]

Strips all non-alphanumerics from a string, optionally sparing any characters in the $allowed array.

This should be an indexed array with one character per element. This method inspired by and partially stolen from CakePHP's paranoid().

Parameters:
stringstr
stringallowed
Returns:
string
Author:
CakePHP Foundation
Since:
0.1

Definition at line 64 of file DMString.php.

Referenced by DMJSONPRepresentationTransformerV1::__construct(), DMAPIVocabularyController::frequency(), DMResultsTemplateHelper::getHtmlFacetsAsUL(), DMObjectTemplateHelper::getHtmlHighlightedFullText(), DMTemplateSet::getPath(), DMCollection::getSanitizedAlias(), isValidPathname(), and DMAPIVocabularyController::suggest().

static DMString::truncate ( str,
max_words 
) [static]

Truncates a text string to the desired word length, appending an ellipsis (...) at the end.

Parameters:
stringstr
intmax_words
Returns:
string
Since:
0.1

Definition at line 142 of file DMString.php.

Referenced by DMControlPanelTemplateHelper::getHtmlNews(), DMResultsTemplateHelper::getHtmlResultsAsGrid(), DMResultsTemplateHelper::getHtmlResultsAsList(), DMResultsTemplateHelper::getHtmlResultsAsTiles(), UNLVRandomAddForm::init(), and UNLVHighlightAddForm::init().

static DMString::underscoreToCamelCase ( str,
capitalize_first_char = false 
) [static]
Parameters:
stringstr
capitalize_first_char
Returns:
CamelCase string
Since:
0.4

Definition at line 250 of file DMString.php.

Referenced by DMRoute::setMethod().

static DMString::websafe ( str,
encoding = "UTF-8" 
) [static]

Strips all HTML tags from a string and HTML-escapes it.

Parameters:
stringstr String to escape
stringencoding An encoding accepted by PHP's htmlspecialchars() function
Returns:
string
Since:
0.3

Definition at line 273 of file DMString.php.

Referenced by DMInternalView::getFlash(), DMObjectTemplateHelper::getHtmlAddFavoriteButton(), DMObjectTemplateHelper::getHtmlChildLinksAsList(), DMObjectTemplateHelper::getHtmlChildLinksAsPulldown(), DMGenericTemplateHelper::getHtmlCollectionsAsPulldown(), DMObjectTemplateHelper::getHtmlCommentsSection(), DMObjectTemplateHelper::getHtmlCompoundObjectPageNumbersInSearchResultsAsString(), DMObjectTemplateHelper::getHtmlCompoundObjectSearchForm(), DMObjectTemplateHelper::getHtmlCompoundPageFlipLinks(), DMObjectTemplateHelper::getHtmlDownloadImageLink(), DMControlPanelTemplateHelper::getHtmlEditableCommentsAsTable(), DMSystemErrorTemplateHelper::getHtmlException(), DMResultsTemplateHelper::getHtmlFacetsAsUL(), DMSearchTemplateHelper::getHtmlFieldSearch(), DMGenericTemplateHelper::getHtmlFormattedFlash(), DMObjectTemplateHelper::getHtmlHighlightedFullText(), DMGenericTemplateHelper::getHtmlLoginPageLink(), DMObjectTemplateHelper::getHtmlMetadataAsDL(), DMObjectTemplateHelper::getHtmlMetadataAsMetaTags(), DMObjectTemplateHelper::getHtmlPreviousNextLinks(), DMSearchTemplateHelper::getHtmlProximitySearch(), DMObjectResultsTemplateHelper::getHtmlResults(), DMResultsTemplateHelper::getHtmlResultsAsGrid(), DMResultsTemplateHelper::getHtmlResultsAsList(), DMResultsTemplateHelper::getHtmlResultsAsTiles(), DMResultsTemplateHelper::getHtmlSearchTerms(), DMResultsTemplateHelper::getHtmlSortLinksAsUL(), SampleCustomViewer::getHTMLTag(), DMTextareaField::getHTMLTag(), DMRadioField::getHTMLTag(), DMQuickTimeViewer::getHTMLTag(), DMNullViewer::getHTMLTag(), DMHiddenField::getHTMLTag(), DMGenericPDFViewer::getHTMLTag(), DMGenericObjectViewer::getHTMLTag(), DMGenericImageViewer::getHTMLTag(), DMFileLinkViewer::getHTMLTag(), DMCheckboxField::getHTMLTag(), DMObjectTemplateHelper::getHtmlTaggingSection(), DMGenericTemplateHelper::getHtmlTagsAsCloud(), DMObjectTemplateHelper::getHtmlViewer(), DMGenericTemplateHelper::getHtmlVocabularyAsCloud(), DMGenericTemplateHelper::getHtmlVocabularyAsList(), DMGenericTemplateHelper::getHtmlVocabularyForSelect(), DMCPFeedSettingsForm::init(), DMMailer::sendNotificationOfNewComment(), and DMEmailMessage::setEmailSenderName().


The documentation for this class was generated from the following file:
 All Data Structures Functions Variables