當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FSS_Helper::truncate方法代碼示例

本文整理匯總了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;
 }
開發者ID:vstorm83,項目名稱:propertease,代碼行數:101,代碼來源:parser.php

示例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[] = "&hellip; <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', "");
}
開發者ID:vstorm83,項目名稱:propertease,代碼行數:31,代碼來源:comment.php


注:本文中的FSS_Helper::truncate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。