本文整理汇总了PHP中FSS_Helper::truncate方法的典型用法代码示例。如果您正苦于以下问题:PHP FSS_Helper::truncate方法的具体用法?PHP FSS_Helper::truncate怎么用?PHP FSS_Helper::truncate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FSS_Helper
的用法示例。
在下文中一共展示了FSS_Helper::truncate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ParseInt
//.........这里部分代码省略.........
$toffset = $end + 1;
//echo "If tag $tag, depth = $open<br>";
}
$ifend = $toffset;
$ifcode = substr($t, $ifstart, $ifend - $ifstart - 7);
//echo "IF Code : <pre>" . htmlentities($ifcode) . "</pre><br>";
// match the if
$matched = false;
//echo "If: " . print_r($bits, true) . " - ";
//echo $this->vars[$bits[1]] . " - ";
if (count($bits) == 2) {
$var = $bits[1];
if (array_key_exists($var, $this->vars)) {
$value = $this->vars[$var];
if ($value) {
$matched = true;
}
}
} else {
if (count($bits) == 3) {
$var = $bits[1];
$value = trim($bits[2], "\"'");
if (array_key_exists($var, $this->vars)) {
$varvalue = $this->vars[$var];
if ($varvalue == $value) {
$matched = true;
}
}
} else {
if (count($bits) == 4) {
$var = $bits[1];
$value = trim($bits[2], "\"'");
$op = $bits[3];
if (array_key_exists($var, $this->vars)) {
$varvalue = $this->vars[$var];
if ($op == "not") {
if ($varvalue != $value) {
$matched = true;
}
} else {
if ($varvalue == $value) {
$matched = true;
}
}
}
}
}
}
/*if ($matched)
echo "TRUE";
else
echo "FALSE";
echo "<br>";*/
// if IF statement is matched, parse the insides of it
if ($matched) {
$o .= $this->ParseInt($ifcode);
}
} else {
if ($bits[0] == "set") {
if (count($bits) == 3) {
$var = $bits[1];
$value = $bits[2];
if (is_numeric($value)) {
$this->vars[$var] = $value;
} else {
if ((substr($value, 0, 1) == "\"" || substr($value, 0, 1) == "'") && (substr($value, strlen($value) - 1, 1) == "\"" || substr($value, strlen($value) - 1, 1) == "'")) {
$this->vars[$var] = trim($value, "\"'");
} else {
if (array_key_exists($value, $this->vars)) {
$this->vars[$var] = $this->vars[$value];
} else {
$this->vars[$var] = $value;
}
}
}
//echo "Setting $var to {$this->vars[$var]}<br>";
}
} else {
if (array_key_exists($bits[0], $this->vars)) {
if (isset($bits[1]) && $bits[1] > 0) {
$ending = "";
if (isset($bits[2])) {
$ending = $bits[2];
}
$is_trimmed = false;
$o .= FSS_Helper::truncate($this->vars[$bits[0]], $bits[1], $is_trimmed, $ending);
} else {
$o .= $this->vars[$bits[0]];
}
}
}
}
}
$o .= substr($t, $toffset);
if ($max == 1000) {
exit;
}
return $o;
}
示例2: trim
$val = $this->comment['custom'][$field['id']];
$this->comment['custom_' . $field['id']] = $val;
$this->parser->SetVar('custom_' . $field['id'], trim($val));
$this->parser->SetVar('custom' . $field['id'], trim($val));
if (strlen(trim($val)) > 0) {
$custom[] = $val;
}
}
}
}
if ($this->opt_max_length > 0 && strlen($this->comment['body']) > $this->opt_max_length) {
$randno = mt_rand(100000, 999999);
$result = array();
$is_trimmed = false;
$result[] = "<div id='test_short_" . $randno . "'>";
$result[] = FSS_Helper::truncate($this->comment['body'], $this->opt_max_length, $is_trimmed, '');
if ($is_trimmed) {
$result[] = "… <a href='#' onclick='expand_test(" . $randno . ");return false;'>" . JText::_("MOD_FSS_TEST_READ_MORE") . "</a><div id='test_full_" . $randno . "' style='display:none'>" . $this->comment['body'] . "</div>";
$result[] = "</div>";
$this->comment['body'] = trim(implode($result));
}
}
$this->comment['body'] = str_replace("\n", "<br />", $this->comment['body']);
$this->comment['body'] = str_replace("\n", "<br />", $this->comment['body']);
$this->parser->AddVars($this->comment);
$this->parser->SetVar('divid', "fss_comment_{$this->uid}_{$this->comment['id']}");
if (count($custom) > 0) {
$this->parser->SetVar('custom', implode(", ", $custom));
} else {
$this->parser->SetVar('custom', "");
}