本文整理汇总了PHP中Utilities::textPreview方法的典型用法代码示例。如果您正苦于以下问题:PHP Utilities::textPreview方法的具体用法?PHP Utilities::textPreview怎么用?PHP Utilities::textPreview使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utilities
的用法示例。
在下文中一共展示了Utilities::textPreview方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: replaceTags
static function replaceTags($entries, $params, $matches)
{
/*
* Make sure the template tag has a matching array element
*/
if (array_key_exists(strtolower($matches[1]), $entries)) {
$val = $entries[strtolower($matches[1])];
// Run htmlentities() is the parameter is set to TRUE
if ($params['htmlentities'] === TRUE) {
$val = htmlentities($val, ENT_QUOTES);
}
// Run strip_tags() if the parameter is set to TRUE
if ($params['strip_tags'] === TRUE) {
$whitelist = NULL;
if (isset($params['strip_tags_whitelist'])) {
$whitelist = $params['strip_tags_whitelist'];
}
$val = strip_tags($val, $whitelist);
//TODO: Finish the attribute stripping function
// $val = Utilities::strip_tags_attr($val, $whitelist);
}
// Create a text preview if one the parameter is set to TRUE
if ($params['text_preview'] === TRUE && $matches[1] == 'body') {
$val = Utilities::textPreview($val, $params['text_preview_length']);
}
return $val;
} else {
return "{" . $matches[1] . "}";
}
}
示例2: displayPreview
protected function displayPreview($entries)
{
$id = isset($entries[0]['id']) ? $entries[0]['id'] : NULL;
$entry = $this->admin_general_options($this->url0, $id, false);
if (isset($entries[0]['title'])) {
// Number of results
$n = count($entries);
$entry_array = array();
// Initialize the variable to avoid a notice
foreach ($entries as $e) {
// Entry options for the admin, if logged in
$e['admin'] = $this->admin_gallery_options($this->url0, $e['id'], $n, $e['data7']);
/*
* URLs for different versions of the image
*/
$gal = $this->getGalleryImages($e['id'], TRUE);
/*
* Store the count
*/
$e['photo-count'] = count($gal);
/*
* Grab the first image
*/
$image = array_shift($gal);
if (!empty($image)) {
/*
* Display the latest two galleries
*/
$e['image'] = '/' . GAL_SAVE_DIR . $this->url0 . $e['id'] . $image;
$e['preview'] = '/' . GAL_SAVE_DIR . $this->url0 . $e['id'] . '/preview/' . $image;
$e['thumb'] = '/' . GAL_SAVE_DIR . $this->url0 . $e['id'] . '/thumbs/' . $image;
} else {
$e['image'] = '/assets/images/no-image.jpg';
$e['preview'] = '/assets/images/no-image.jpg';
$e['thumb'] = '/assets/images/no-image-thumb.jpg';
}
/*
* Entry URL
*/
$e['url'] = isset($e['data6']) ? $e['data6'] : urlencode($e['title']);
/*
* Text options
*/
$e['text-preview'] = Utilities::textPreview($e['body'], 45);
$entry_array[] = $e;
}
$template_file = $this->url0 . '-preview.inc';
} else {
$entry_array[] = array('admin' => NULL, 'title' => 'No Entry Found', 'body' => "<p>That entry doesn't appear to exist.</p>");
$template_file = 'default.inc';
}
/*
* Set up header and footer information
*/
if ($this->url1 == 'category') {
$name = $entry_array[0]['category-name'];
$count = count($entry_array);
$gal = $count == 1 ? 'gallery' : 'galleries';
$extra = array('header' => array('title' => "Viewing Category: {$name} ({$count} {$gal})"), 'footer' => array('backlink' => '<p><a href="/' . $this->url0 . '">« Back to All Photos</a></p>'));
} else {
$extra = array('header' => array('title' => 'Latest Galleries'), 'footer' => array('backlink' => NULL));
}
/*
* Load the template into a variable
*/
$template = UTILITIES::loadTemplate($template_file);
$entry .= UTILITIES::parseTemplate($entry_array, $template, $extra);
return $entry;
}
示例3: get_page_description
public function get_page_description()
{
if ($this->url0 === DB_Actions::get_default_page() && empty($this->url1)) {
return SITE_DESCRIPTION;
} else {
if (isset($this->entries[0]->excerpt)) {
return htmlentities(strip_tags($this->entries[0]->excerpt), ENT_QUOTES);
} else {
if (isset($this->entries[0]->entry)) {
$preview = Utilities::textPreview($this->entries[0]->entry, 25);
return htmlentities(strip_tags($preview), ENT_QUOTES);
} else {
return SITE_DESCRIPTION;
}
}
}
}