TinyButXtreme (TBX) is a fork of TinyButStrong (TBS) with countless changes which make it incompatible with the original library. Documented below are the major changes that have been made, but know that this is not a complete list due to the active development nature of TBX.
The original reason for this fork is due to TBS inconsistent handling of Unix Timestamps. For example, the Unix Timestamp 20140416 in TBS will be read as a date of 2014-04-16, whereas the Unix Timestamp of 20142000 will be read as 1970-08-22 @ 03:00:00. Within TBX, both of these are handled as the latter case, as no assumptions are made about intended usage of strictly numerical values. From there, development continued to simplify the API, add performance optimizations, remove unused code features, and organize the code base.
- PHP 5.4 is now the minimum version. All support for previous PHP versions removed. PHP 7.x and HHVM are fully supported.
- Plugin support entirely removed.
- Microsoft Office support entirely removed.
- Most Data Sources removed.
onformat=removed.[var]global variables removed.
- All
TBS_*constants renamed toTBX_*. - Class
clsTinyButStrongrenamed totbx. - All
tbxclass constructor optional parameters removed. - Rendering templates no longer exits application.
- Method
meth_Misc_Alerthas been replaced by ExceptiontbxException. - Numerical values passed into Date functions are always treated as Unix Timestamps.
- Method
MergeFieldreplaced with methodfield. - Method
MergeBlockreplaced with methodblock. - Method
resetadded to reset all template states. - Method
fieldsadded to iterate through an array and callfieldon each item. - Method
repeatadded to simplify the process of access_P1. - Method
mergeadded to iterate through an array and callfieldorblockdepending upon data type of each item. - Method
LoadTemplatereplaced with methodload. $tbs->Source = $valuereplaced with methodloadString($value).$value = $tbs->Sourcereplaced with method$value = (string) $tbx- Method
loadArrayadded to load multiple files into a single template. - Method
Showreplaced with methodrender. - Method
renderToStringadded to output final template to a string instead of stdout/browser.
ope=[STRING FUNCTION]has been replaced withf=[STRING FUNCTION].ope=[MATH FUNCTION]has been extended to include more functions.ope=andf=may be used together on the same value.frm=date formatting replaced bydate=.- Date formatting now uses PHP's date string syntax instead of a proprietary syntax. http://php.net/manual/en/function.date.php
strconv=is now an alias ofsafe=.ifemptyno longer issues a warning/error for unset data source keys.magnetno longer issues a warning/error for unset data source keys.
TBS includes a variety of potential data sources to feed information into templates. The majority of these have all been removed. TBX on the other hand supports a very small set of data sources which are listed below.
The main difference is that all database engines supported have been removed, and instead replaced by support for the PHP Universal Database Library (PUDL). This greatly simplifies access to a number of database engines, while also allowing support for new engines without modifying TBX at all.
Additionally, numerous bugs involving PHP objects and Iterator have been fixed.
- PHP literals
- PHP arrays
- PHP objects
- PHP objects which implement the Iterator interface
- PUDL pudlResult
- PUDL pudlCollection
ope=listremovedope=minvremovedope=attboolremovedope=utf8removedope=upperremovedope=lowerremovedope=upper1removedope=upperwremovedope=max:VALUEunchanged (max between current vs value)ope=mod:VALUEunchanged (current % value)ope=add:VALUEunchanged (current + value)ope=mul:VALUEunchanged (current * value)ope=div:VALUEunchanged (current / value)ope=mok:VALUEunchanged (magnet??)ope=mko:VALUEunchanged (magnet??)ope=nif:VALUEunchanged (if current == value, set current='')ope=msk:VALUEunchanged (replace '*' in current with value)ope=sub:VALUEadded (current - value)ope=mdx:VALUEadded (value % current)ope=adx:VALUEadded (value + current)ope=sbx:VALUEadded (value - current)ope=mlx:VALUEadded (value * current)ope=dvx:VALUEadded (value / current)
Execute one or more PHP functions on a given value. Function names are separated
by , (commas). Any function not supported by the TBX library directly will be
forwarded to the _customFormat($value, $function) method. Inherit from the
tbx class and overwrite this method to do application specific function
processing of template parameters.
f= and convert= are aliases of function=.
Template Examples:
[item;f=hex] - convert [item] into a hex value
[item;f=upper] - convert [item] into upper case character
[item;f=hex,upper] - convert [item] into a hex value with upper case characters
[item;f=hex,lower] - convert [item] into a hex value with lower case characters
Custom Format Example:
Template:
[item;f=awesome]
PHP:
class myAwesomeClass extends tbx {
function _customFormat(&$value, $function) {
//Replace the value with 'AWESOME!'
if ($function === 'awesome') $value = 'AWESOME!';
}
}
Complete list of supported functions: https://github.com/darkain/TinyButXtreme/blob/master/tbx_function.inc.php
PHP functions supported
- addslashes
- bin2hex
- chr
- chunk_split
- hebrev
- hex2bin
- html_entity_decode
- htmlentities
- htmlspecialchars
- lcfirst
- ltrim
- md5
- metaphone
- nl2br
- number_format
- ord
- rawurlencode
- rtrim
- sha1
- soundex
- strip_tags
- stripcslashes
- stripslashes
- strlen
- strrev
- strtolower
- strtoupper
- trim
- ucfirst
- ucwords
- urlencode
- uudecode
- uuencode
- wordwrap
Additional functions and aliases supported
bin- alias ofhex2bincrc32- shortcut forhash('crc32', $value)crc32b- shortcut forhash('crc32b', $value)hex- alias ofbin2hexhtml- alias ofhtmlspecialcharslower- alias ofstrtolowermd2- shortcut forhash('md2', $value)md4- shortcut forhash('md4', $value)phone- cleans up a phone number (several formats supported)rawid- shortcut forstrtolower(rawurlencode(rtrim(substr($value, 0, 20))))rawname- shortcut forstrtolower(rawurlencode($value))sha256- shortcut forhash('sha256', $value)sha384- shortcut forhash('sha384', $value)sha512- shortcut forhash('sha512', $value)title- shortcut forucwords(strtolower($value))with special handling for certain wordsunhex- alias ofhex2binupper- alias ofstrtoupperurl- alias ofurlencodeurlid- shortcut forstrtolower(urlencode(rtrim(substr($value, 0, 20))))urlname- shortcut forstrtolower(urlencode($value))