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
clsTinyButStrong
renamed totbx
. - All
tbx
class constructor optional parameters removed. - Rendering templates no longer exits application.
- Method
meth_Misc_Alert
has been replaced by ExceptiontbxException
. - Numerical values passed into Date functions are always treated as Unix Timestamps.
- Method
MergeField
replaced with methodfield
. - Method
MergeBlock
replaced with methodblock
. - Method
reset
added to reset all template states. - Method
fields
added to iterate through an array and callfield
on each item. - Method
repeat
added to simplify the process of access_P1
. - Method
merge
added to iterate through an array and callfield
orblock
depending upon data type of each item. - Method
LoadTemplate
replaced with methodload
. $tbs->Source = $value
replaced with methodloadString($value)
.$value = $tbs->Source
replaced with method$value = (string) $tbx
- Method
loadArray
added to load multiple files into a single template. - Method
Show
replaced with methodrender
. - Method
renderToString
added 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=
.ifempty
no longer issues a warning/error for unset data source keys.magnet
no 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=list
removedope=minv
removedope=attbool
removedope=utf8
removedope=upper
removedope=lower
removedope=upper1
removedope=upperw
removedope=max:VALUE
unchanged (max between current vs value)ope=mod:VALUE
unchanged (current % value)ope=add:VALUE
unchanged (current + value)ope=mul:VALUE
unchanged (current * value)ope=div:VALUE
unchanged (current / value)ope=mok:VALUE
unchanged (magnet??)ope=mko:VALUE
unchanged (magnet??)ope=nif:VALUE
unchanged (if current == value, set current='')ope=msk:VALUE
unchanged (replace '*' in current with value)ope=sub:VALUE
added (current - value)ope=mdx:VALUE
added (value % current)ope=adx:VALUE
added (value + current)ope=sbx:VALUE
added (value - current)ope=mlx:VALUE
added (value * current)ope=dvx:VALUE
added (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 ofhex2bin
crc32
- shortcut forhash('crc32', $value)
crc32b
- shortcut forhash('crc32b', $value)
hex
- alias ofbin2hex
html
- alias ofhtmlspecialchars
lower
- alias ofstrtolower
md2
- 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 ofhex2bin
upper
- alias ofstrtoupper
url
- alias ofurlencode
urlid
- shortcut forstrtolower(urlencode(rtrim(substr($value, 0, 20))))
urlname
- shortcut forstrtolower(urlencode($value))