本文整理汇总了PHP中PerchUtil::excerpt_char方法的典型用法代码示例。如果您正苦于以下问题:PHP PerchUtil::excerpt_char方法的具体用法?PHP PerchUtil::excerpt_char怎么用?PHP PerchUtil::excerpt_char使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PerchUtil
的用法示例。
在下文中一共展示了PerchUtil::excerpt_char方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: format_result
public static function format_result($key, $options, $result)
{
$result['campaignSubject'] = $result['col1'];
$result['campaignSlug'] = $result['col2'];
$result['campaignSendTime'] = $result['col3'];
$result['campaignText'] = $result['col4'];
$result['campaignID'] = $result['col5'];
$result['_id'] = $result['col5'];
$Settings = PerchSettings::fetch();
$html = PerchUtil::excerpt_char($result['campaignText'], $options['excerpt-chars'], true);
// keyword highlight
$html = preg_replace('/(' . $key . ')/i', '<span class="keyword">$1</span>', $html);
$match = array();
$match['url'] = $Settings->get('perch_mailchimp_campaign_url')->settingValue();
self::$tmp_url_vars = $result;
$match['url'] = preg_replace_callback('/{([A-Za-z0-9_\\-]+)}/', array('self', "substitute_url_vars"), $match['url']);
self::$tmp_url_vars = false;
$match['title'] = $result['campaignSubject'];
$match['excerpt'] = $html;
$match['key'] = $key;
return $match;
}
示例2: format_result
public static function format_result($key, $options, $result)
{
$result['eventTitle'] = $result['col1'];
$result['eventSlug'] = $result['col2'];
$result['eventDateTime'] = $result['col3'];
$result['eventDescHTML'] = $result['col4'];
$result['eventID'] = $result['col5'];
$result['_id'] = $result['col5'];
$Settings = PerchSettings::fetch();
$html = PerchUtil::excerpt_char($result['eventDescHTML'], $options['excerpt-chars'], true);
// keyword highlight
$html = preg_replace('/(' . $key . ')/i', '<span class="keyword">$1</span>', $html);
$match = array();
$match['url'] = $Settings->get('perch_events_detail_url')->settingValue();
self::$tmp_url_vars = $result;
$match['url'] = preg_replace_callback('/{([A-Za-z0-9_\\-]+)}/', array('self', "substitute_url_vars"), $match['url']);
self::$tmp_url_vars = false;
$match['title'] = $result['eventTitle'] . ' - ' . strftime('%d %b %Y', strtotime($result['col3']));
$match['excerpt'] = $html;
$match['key'] = $key;
return $match;
}
示例3: table_dump
public static function table_dump($vars, $class = '')
{
$out = '';
if (PerchUtil::count($vars)) {
$out .= '<table class="' . PerchUtil::html($class, true) . '"><tr><th>ID</th><th>Value</th></tr>';
foreach ($vars as $key => $val) {
$out .= '<tr><td><b>' . PerchUtil::html($key) . '</b></td><td>';
switch (gettype($val)) {
case 'array':
if (isset($val['processed'])) {
$out .= $val['processed'];
} else {
if (isset($val['_default'])) {
$out .= $val['_default'];
} else {
$out .= '<pre>' . print_r($val, true) . '</pre>';
}
}
break;
case 'object':
$out .= '<pre>' . print_r($val, true) . '</pre>';
break;
case 'boolean':
$out .= $val ? 'true' : 'false';
break;
default:
if (strlen($val) > 100) {
$val = PerchUtil::excerpt_char($val, 100) . '{...}';
}
$out .= $val;
}
$out .= '</td></tr>';
}
$out .= '</table>';
}
return $out;
}
示例4: replace_content_tags
public function replace_content_tags($namespace, $content_vars, $contents)
{
if (is_array($content_vars)) {
// Find all matching tags
$s = '#<perch:' . $namespace . '[^>]*/>#';
$count = preg_match_all($s, $contents, $matches, PREG_SET_ORDER);
if ($count) {
foreach ($matches as $match) {
$match = $match[0];
$tag = new PerchXMLTag($match);
if ($tag->suppress) {
$contents = str_replace($match, '', $contents);
} else {
if (isset($content_vars[$tag->id])) {
$value = $content_vars[$tag->id];
} else {
$replacement = '';
if ($tag->else()) {
$replacement = $tag->else();
}
$contents = str_replace($match, $replacement, $contents);
continue;
}
$field_is_markup = false;
if ($tag->type) {
$FieldType = PerchFieldTypes::get($tag->type, false, $tag);
$modified_value = $FieldType->get_processed($value);
$field_is_markup = $FieldType->processed_output_is_markup;
} else {
$modified_value = $value;
}
// check for 'rewrite' attribute
if ($tag->rewrite) {
$modified_value = $this->_rewrite($tag, $modified_value);
}
// check for 'format' attribute
if ($tag->format) {
$modified_value = $this->_format($tag, $modified_value);
}
// check for 'replace' strings
if ($tag->replace) {
$pairs = explode(',', $tag->replace);
if (PerchUtil::count($pairs)) {
foreach ($pairs as $pair) {
$pairparts = explode('|', $pair);
if (isset($pairparts[0]) && isset($pairparts[1])) {
$modified_value = str_replace(trim($pairparts[0]), trim($pairparts[1]), $modified_value);
}
}
}
}
// Urlify
if ($tag->urlify) {
$modified_value = PerchUtil::urlify($modified_value);
}
// Trim by chars
if ($tag->chars) {
if (strlen($modified_value) > (int) $tag->chars) {
$modified_value = PerchUtil::excerpt_char($modified_value, (int) $tag->chars, false, true, $tag->append);
}
}
// Trim by words
if ($tag->words) {
$modified_value = PerchUtil::excerpt($modified_value, (int) $tag->words, false, true, $tag->append);
}
// Hash
if ($tag->hash == 'md5') {
$modified_value = md5($modified_value);
}
// check that what we've got isn't an array. If it is, try your best to get a good string.
if (is_array($modified_value)) {
if (isset($modified_value['_default'])) {
$modified_value = (string) $modified_value['_default'];
} else {
if (isset($modified_value['processed'])) {
$modified_value = (string) $modified_value['processed'];
} else {
$modified_value = (string) array_shift($modified_value);
}
}
}
// Strip tags
if ($tag->striptags) {
$modified_value = strip_tags($modified_value);
}
// Append
if (!$tag->words && !$tag->chars && $tag->append) {
$modified_value .= $tag->append;
}
// URL Encode
if ($tag->urlencode) {
$modified_value = rawurlencode($modified_value);
}
// Escape quotes
if ($tag->escape) {
$modified_value = PerchUtil::html($modified_value, true, false);
$field_is_markup = true;
}
// check encoding
if ($this->autoencode && !$field_is_markup) {
//.........这里部分代码省略.........
示例5: strftime
echo $Form->checkbox('comment-' . $Comment->id(), '1', 0);
?>
<a href="<?php
echo $HTML->encode($API->app_path());
?>
/comments/edit/?id=<?php
echo $HTML->encode(urlencode($Comment->id()));
?>
" class="edit">
<?php
echo strftime(str_replace(' ', ' ', PERCH_DATE_SHORT), strtotime($Comment->commentDateTime()));
?>
</a>
</td>
<td title="<?php
echo PerchUtil::html(PerchUtil::excerpt_char($Comment->commentHTML(), 500));
?>
"><?php
echo $HTML->encode($Comment->postTitle());
?>
</td>
<td><?php
echo $HTML->encode($Comment->commentName());
?>
</td>
<td><?php
echo $HTML->encode($Comment->commentEmail());
?>
</td>