|
|
|
File: C:/usr/local/lib/php/blueshoes-4.2/core/text/Bs_TextUtil.class.php
BlueShoes Application Framework - text
Bs_TextUtil
Bs_Object | +-- Bs_TextUtil
dependencies: Bs_String, Bs_Array
|
public class Bs_TextUtil extends Bs_Object
dependencies: Bs_String, Bs_Array
| Authors | |
| Version | 4.0.$id$ |
| Copyright | blueshoes.org |
|
| |
|
Methods inherited from Bs_Object |
| isex, isexception, tostring, tohtml, persist, unpersist, bs_object, bbsetoutput, bbawake, bbisawake, bbxmsg, bbxfunctionstart, bbxfunctionend, bbxecho, bbxvar, bbxvardump, bbforcetrace, bbbufferstart, bbbufferget, bbbufferendflush, bbbufferendclean |
|
|
|
|
|
Private Field Summary |
| object [unknown] |
$_Bs_Stringreference to the globally used Bs_String class. |
| object [unknown] |
$_Bs_Arrayreference to the globally used Bs_Array class. |
|
|
|
Public Method Details |
getLanguageDependentValue |
|
public string getLanguageDependentValue( mixed $var, [ string $lang ] )
|
| |
returns the value of a [language dependant] [object] var for the current language.
example:you have a language setting var like$hello = array('en' =>'hello','en_us'=>'hi','en_uk'=>'good morning sir','de' =>'guten morgen','de_ch'=>'guete morge',);now you want the best match for your language.examples:de_de => defr => en (first entry)en_us => en_us
|
| Parameter |
|
| mixed |
$var |
|
|
(string or lang-hash.) |
|
|
| string |
$lang |
= >>'en'<< |
|
(like 'en' or 'en_uk'. default is 'en'.) |
|
| Returns |
string |
| Throws |
NULL if var is not set [correctly]. |
|
parseSearchQuery |
|
public array parseSearchQuery( string $string )
|
| |
i am not sure where to put that method. so i place it here. :/
parses the search input we got from the user.example: "+foobar -"hello world" AND blah"returns a vector filled with hashes that have the 3 keys:'phrase' => the word like 'hello' or more if it was a phrasein quotes like "pole position". it is the originaluser input.'words' => the words the user is looking for (vector).if the "word" was in quotes like "hello world" thenthis is vector has more than 1 element.'operator' => the operator, one of & (and), | (or), ! (not).features:- boolean searches, examples:- "tom AND cherry"- "hello -world"- "tom UND cherry NOT foo bar lala blah"- support for quotes, eg "foobar AND "hello world""missing:- support for brackets, eg "foobar AND (hello OR world)"all input is converted to lower case. Bs_String->normalize() is appliedto the whole string. but no further converting is done, no check fornoise words, no min/max word length etc. do that yourself.
|
| Parameter |
|
|
| Returns |
array (may be empty) |
|
ordinal |
|
public string ordinal( [ integer $num ] )
|
| |
returns the number as a string with it's ordinal value
examples: 1 => 1st22 => 22nd133 => 133rd9 => 9ththanks to: http://www.phpclasses.org/browse.html/file/1027.html
|
| Parameter |
|
|
| Returns |
string |
|
pluralS |
|
public string pluralS( int $count )
|
| |
determine whether to print a plural 's' or not
example:you want to print something likeyou have 5 product[s] in your basket.now if the user has 1 product, it should be without the 's', otherwiseit should with 's'. even if there is no (0) product.thanks to: http://www.phpclasses.org/browse.html/file/1027.html
|
| Parameter |
|
|
| Returns |
string ('s' or an empty string) |
|
longestCommonSubstring |
|
public string longestCommonSubstring( string $string1, string $string2 )
|
| |
finds the longest common substring of 2 strings and returns that part.
http://www.php.net/manual/en/ref.strings.phpcarl@youngbloods.org 09-Jan-2002 08:27I've ported a function to PHP that will find the longest common substringin two different strings. Here it is:Here is where I found the original:http://www1.ics.uci.edu/~eppstein/161/960229.html
|
| Parameter |
|
|
|
|
| Returns |
string (substring) |
|
percentUppercase |
|
public int percentUppercase( string $string )
|
| |
tells how many % of the given string are written in uppercase.
may be useful to modify a post to a bbs or detect it as spam/junk.
|
| Parameter |
|
|
| Returns |
int (number from 0 to 100.) |
|
Bs_TextUtil |
|
public void Bs_TextUtil( )
|
| |
Warning: documentation is missing.
|
| Returns |
void |
|
|
Private Method Details |
shortenString |
|
private string shortenString( string $text, int $length, [ string $suffix ] )
|
| |
To shorten a string to a certain number of characters, replacing surplus
chars with a shortening suffix-string such as "[...]"If shortening would make no sense, the original string is returned.Total string size (incl. suffix) is max the given length.
|
| Parameter |
|
| string |
$text |
|
|
the string to be shortened. |
|
|
| int |
$length |
|
|
is the maximum number of characters in the new string |
|
|
| string |
$suffix |
= >>'...'<< |
|
(default is '...') |
|
| Returns |
string |
| Author(s) |
|
|
abbreviateString |
|
private string abbreviateString( string $text, [ integer $maxLength ] )
|
| |
To abbreviate a string to something meaningfull
Keep as mutch of the beginning string as possible and abbreviate starting atthe end. NOTE: Only words with a beginning capital lettre are abbreviated; the rest is trashedE.g.:Bs_TextUtil::abbreviateString('The Quick Red Fox', 12) // -> 'The Q. R. F.'Bs_TextUtil::abbreviateString('Hi, my name is Sam', 12) // -> 'Hi, my N. S.'
|
| Parameter |
|
| string |
$text |
|
|
the string to be abbreviated. |
|
|
| integer |
$maxLength |
= >>12<< |
|
is the maximum number of characters in the new string. |
|
| Returns |
string |
|
|
Private Field Details |
$_Bs_String |
|
private object [unknown] $_Bs_String
>><<
reference to the globally used Bs_String class.
|
|
$_Bs_Array |
|
private object [unknown] $_Bs_Array
>><<
reference to the globally used Bs_Array class.
|
|
|
Private Constant Details |
BS_TEXTUTIL_VERSION
define( BS_TEXTUTIL_VERSION, >>4.0.$x$<< )
Case: default: case sensitive
|
|
|
|
|
|
| PHPDoc 1.0beta |