update
This commit is contained in:
78
core/plugins/Smarty/function.formatText.php
Normal file
78
core/plugins/Smarty/function.formatText.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: function.formatText.php
|
||||
* Type: function
|
||||
* Name: formatText
|
||||
* Purpose: Formatuje tekst - wstawia <br /> za znaki koñca linii, przycina, prawdopodobnie bêdzie wstawiaæ
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
|
||||
function smarty_function_formatText($params, &$smarty)
|
||||
{
|
||||
require_once $smarty->_get_plugin_filepath('modifier', 'truncate');
|
||||
|
||||
if (!isset($params['lenght'])) {
|
||||
$lenght = CONTENT_MAX_DISP_LEN;
|
||||
} else {
|
||||
$lenght = $params['lenght'];
|
||||
unset($params['lenght']);
|
||||
}
|
||||
|
||||
if (!isset($params['etc'])) {
|
||||
$etc = '...';
|
||||
} else {
|
||||
$etc = $params['etc'];
|
||||
unset($params['etc']);
|
||||
}
|
||||
|
||||
$string = $params['text'];
|
||||
unset($params['text']);
|
||||
|
||||
if (!isset($params['moreTitle'])) {
|
||||
$wiecejT = "Zobacz wiêcej";
|
||||
} else {
|
||||
$wiecejT = $params['moreTitle'];
|
||||
unset($params['moreTitle']);
|
||||
}
|
||||
|
||||
if (!isset($params['moreName'])) {
|
||||
$wiecejN = " ";
|
||||
} else {
|
||||
$wiecejN = $params['moreName'];
|
||||
unset($params['moreName']);
|
||||
}
|
||||
|
||||
$string = nl2br($string);
|
||||
|
||||
if(isset($params['urlWiecej']))
|
||||
$params['moreUrl'] = $params['urlWiecej'];
|
||||
|
||||
if (is_integer($lenght)) {
|
||||
if (!isset($params['moreUrl']) && !isset($params['noMoreUrl'])) {
|
||||
|
||||
$moreArr = array();
|
||||
|
||||
foreach ($params as $key => $val) {
|
||||
if($key != "limit")
|
||||
$moreArr[] = "$key,$val";
|
||||
}
|
||||
|
||||
$params['moreUrl'] = implode(',', $moreArr);
|
||||
$params['moreUrl'] .= ".html";
|
||||
}
|
||||
|
||||
$string = smarty_modifier_truncate($string, $lenght, $etc);
|
||||
}
|
||||
|
||||
if (isset($params['moreUrl']) && $params['moreUrl']) {
|
||||
$more = ' <a class="more" href="' . $params['moreUrl'] . '" title="' . $wiecejT . '" rel="nofollow">'.$wiecejN.'</a>';
|
||||
} else {
|
||||
$more = '';
|
||||
}
|
||||
|
||||
return $string . $more;
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user