|
|
|
// remove this:
|
|
// var $caseConvStrings = array(..)
|
|
|
|
$charset = 'iso-8859-1'; // charset to work on, private so cObj may be used in any context (must be set by creator)
|
|
$localeCharset = ''; // charset of current locale (assumes locale is not changed during liftime of this object)
|
|
|
|
|
|
// in stdWrap() change call to strftime() to $this->strftime():
|
|
// if ($conf['strftime']){$content=$this->strftime($content, $conf['strftime']);}
|
|
|
|
|
|
/**
|
|
* Implements the stdWrap property "substring" which is basically a TypoScript implementation of the PHP function, substr()
|
|
*
|
|
* @param string The string to perform the operation on
|
|
* @param string The parameters to substring, given as a comma list of integers where the first and second number is passed as arg 1 and 2 to substr().
|
|
* @return string The processed input value.
|
|
* @access private
|
|
* @see stdWrap()
|
|
*/
|
|
function substring($content,$options) {
|
|
$options = t3lib_div::intExplode(',',$options.',');
|
|
if ($options[1]) {
|
|
return $GLOBALS['TSFE']->csConvObj->substr($this->charset,$content,$options[0],$options[1]);
|
|
} else {
|
|
return $GLOBALS['TSFE']->csConvObj->substr($this->charset,$content,$options[0]);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Implements the stdWrap property "crop" which is a modified "substr" function allowing to limit a string lenght to a certain number of chars (from either start or end of string) and having a pre/postfix applied if the string really was cropped.
|
|
*
|
|
* @param string The string to perform the operation on
|
|
* @param string The parameters splitted by "|": First parameter is the max number of chars of the string. Negative value means cropping from end of string. Second parameter is the pre/postfix string to apply if cropping occurs.
|
|
* @return string The processed input value.
|
|
* @access private
|
|
* @see stdWrap()
|
|
*/
|
|
function crop($content,$options) {
|
|
$options = explode('|',$options);
|
|
$chars=intval($options[0]);
|
|
$afterstring=trim($options[1]);
|
|
if ($chars) {
|
|
return $GLOBALS['TSFE']->csConvObj->crop($this->charset, $chars, $afterstring);
|
|
}
|
|
return $content;
|
|
}
|
|
|
|
|
|
/**
|
|
* Changing character case of a string, converting typically used western charset characters as well.
|
|
*
|
|
* @param string The string to change case for.
|
|
* @param string The direction; either "upper" or "lower"
|
|
* @return string
|
|
* @see HTMLcaseshift()
|
|
*/
|
|
function caseshift($theValue, $case) {
|
|
if (!$this->localeCharset) {
|
|
$this->localeCharset = $GLOBALS['TSFE']->config['config']['localeCharset'];
|
|
|
|
if (!$this->localeCharset) {
|
|
$this->localeCharset = $GLOBALS['TSFE']->csConvObj->get_locale_charset(setlocale(LC_ALL,''));
|
|
}
|
|
}
|
|
|
|
if ($this->localeCharset && $this->localeCharset == $this->charset) {
|
|
switch($case) {
|
|
case 'upper':
|
|
$theValue = strtoupper($theValue);
|
|
break;
|
|
|
|
case 'lower':
|
|
default:
|
|
$theValue = strtolower($theValue);
|
|
}
|
|
} else {
|
|
switch($case) {
|
|
case 'upper':
|
|
$theValue = $GLOBALS['TSFE']->csConvObj->case_conv($this->charset,$theValue,'toUpper');
|
|
break;
|
|
|
|
case 'lower':
|
|
default:
|
|
$theValue = $GLOBALS['TSFE']->csConvObj->case_conv($this->charset,$theValue,'toLower');
|
|
break;
|
|
}
|
|
}
|
|
return $theValue;
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Format a date/time string according to locale (in the correct output charset)
|
|
*
|
|
* @param string The Unix timestamp
|
|
* @param string The PHP strftime() compatible format string
|
|
* @return string The formatted date/time
|
|
* @see strftime()
|
|
*/
|
|
function strftime($content,$format) {
|
|
if (!$this->localeCharset) {
|
|
$this->localeCharset = $GLOBALS['TSFE']->config['config']['localeCharset'];
|
|
|
|
if (!$this->localeCharset) {
|
|
$this->localeCharset = $GLOBALS['TSFE']->csConvObj->get_locale_charset(setlocale(LC_ALL,''));
|
|
}
|
|
}
|
|
|
|
$time = strftime($format,$content);
|
|
if ($this->localeCharset && $this->localeCharset != $this->charset) $time = $GLOBALS['TSFE']->csConvObj->conv($time, $this->localeCharset, $this->charset);
|
|
|
|
return $time;
|
|
}
|
|
|