本文整理汇总了PHP中truncate函数的典型用法代码示例。如果您正苦于以下问题:PHP truncate函数的具体用法?PHP truncate怎么用?PHP truncate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了truncate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: display
public function display()
{
$strTag = utf8_strtolower($this->patharray[0]);
if (!strlen($strTag)) {
redirect($this->controller_path_plain . $this->SID);
}
$arrArticleIDs = $this->pdh->get('articles', 'articles_for_tag', array($strTag));
$arrArticleIDs = $this->pdh->sort($arrArticleIDs, 'articles', 'date', 'desc');
$intStart = $this->in->get('start', 0);
$arrLimitedIDs = $this->pdh->limit($arrArticleIDs, $intStart, $this->user->data['user_nlimit']);
//Articles to template
foreach ($arrLimitedIDs as $intArticleID) {
$userlink = '<a href="' . $this->routing->build('user', $this->pdh->geth('articles', 'user_id', array($intArticleID)), 'u' . $this->pdh->get('articles', 'user_id', array($intArticleID))) . '">' . $this->pdh->geth('articles', 'user_id', array($intArticleID)) . '</a>';
//Content dependet from list_type
//1 = until readmore
//2 = Headlines only
//3 = only first 600 characters
$strText = $this->pdh->get('articles', 'text', array($intArticleID));
$arrContent = preg_split('#<hr(.*)id="system-readmore"(.*)\\/>#iU', xhtml_entity_decode($strText));
$strText = $this->bbcode->parse_shorttags($arrContent[0]);
$strPath = $this->pdh->get('articles', 'path', array($intArticleID));
$intCategoryID = $this->pdh->get('articles', 'category', array($intArticleID));
//Replace Image Gallery
$arrGalleryObjects = array();
preg_match_all('#<p(.*)class="system-gallery"(.*) data-sort="(.*)" data-folder="(.*)">(.*)</p>#iU', $strText, $arrGalleryObjects, PREG_PATTERN_ORDER);
if (count($arrGalleryObjects[0])) {
include_once $this->root_path . 'core/gallery.class.php';
foreach ($arrGalleryObjects[4] as $key => $val) {
$objGallery = registry::register('gallery');
$strGalleryContent = $objGallery->create($val, (int) $arrGalleryObjects[3][$key], $this->server_path . $strPath, 1);
$strText = str_replace($arrGalleryObjects[0][$key], $strGalleryContent, $strText);
}
}
//Replace Raidloot
$arrRaidlootObjects = array();
preg_match_all('#<p(.*)class="system-raidloot"(.*) data-id="(.*)"(.*) data-chars="(.*)">(.*)</p>#iU', $strText, $arrRaidlootObjects, PREG_PATTERN_ORDER);
if (count($arrRaidlootObjects[0])) {
include_once $this->root_path . 'core/gallery.class.php';
foreach ($arrRaidlootObjects[3] as $key => $val) {
$objGallery = registry::register('gallery');
$withChars = $arrRaidlootObjects[5][$key] == "true" ? true : false;
$strRaidlootContent = $objGallery->raidloot((int) $val, $withChars);
$strText = str_replace($arrRaidlootObjects[0][$key], $strRaidlootContent, $strText);
}
}
$this->comments->SetVars(array('attach_id' => $intArticleID, 'page' => 'articles'));
$intCommentsCount = $this->comments->Count();
//Tags
$arrTags = $this->pdh->get('articles', 'tags', array($intArticleID));
$this->tpl->assign_block_vars('article_row', array('ARTICLE_CONTENT' => $strText, 'ARTICLE_TITLE' => $this->pdh->get('articles', 'title', array($intArticleID)), 'ARTICLE_SUBMITTED' => sprintf($this->user->lang('news_submitter'), $userlink, $this->time->user_date($this->pdh->get('articles', 'date', array($intArticleID)), false, true)), 'ARTICLE_DATE' => $this->time->user_date($this->pdh->get('articles', 'date', array($intArticleID)), false, false, true), 'ARTICLE_PATH' => $this->controller_path . $this->pdh->get('articles', 'path', array($intArticleID)), 'ARTICLE_SOCIAL_BUTTONS' => $arrCategory['social_share_buttons'] ? $this->social->createSocialButtons($this->env->link . $this->pdh->get('articles', 'path', array($intArticleID)), strip_tags($this->pdh->get('articles', 'title', array($intArticleID)))) : '', 'PERMALINK' => $this->pdh->get('articles', 'permalink', array($intArticleID)), 'S_TAGS' => count($arrTags) && $arrTags[0] != "" ? true : false, 'ARTICLE_CUTTED_CONTENT' => truncate($strText, 600, '...', false, true), 'S_READMORE' => isset($arrContent[1]) ? true : false, 'COMMENTS_COUNTER' => $intCommentsCount == 1 ? $intCommentsCount . ' ' . $this->user->lang('comment') : $intCommentsCount . ' ' . $this->user->lang('comments'), 'S_COMMENTS' => $this->pdh->get('articles', 'comments', array($intArticleID)) ? true : false, 'S_FEATURED' => $this->pdh->get('articles', 'featured', array($intArticleID))));
if (count($arrTags) && $arrTags[0] != "") {
foreach ($arrTags as $tag) {
$this->tpl->assign_block_vars('article_row.tag_row', array('TAG' => $tag, 'U_TAG' => $this->routing->build('tag', $tag)));
}
}
}
$this->tpl->assign_vars(array('TAG' => sanitize($strTag), 'PAGINATION' => generate_pagination($this->strPath . $this->SID, count($arrArticleIDs), $this->user->data['user_nlimit'], $intStart, 'start')));
$this->tpl->add_meta('<link rel="canonical" href="' . $this->env->link . $this->routing->build('tag', $tag, false, false, true) . '" />');
$this->core->set_vars(array('page_title' => $this->user->lang("tag") . ': ' . sanitize($strTag), 'template_file' => 'tag.html', 'display' => true));
}
开发者ID:rswiders,项目名称:core,代码行数:60,代码来源:tag_pageobject.class.php
示例2: altText
function altText($text)
{
if (strlen($text) > 100) {
$text = truncate($text, 100);
}
return str_replace("<br />", "\n", str_replace("'", "'", str_replace("\"", """, charReplace($text))));
}
开发者ID:archives-of-michigan,项目名称:Governing-Michigan-cdm,代码行数:7,代码来源:results_view.php
示例3: __construct
public function __construct()
{
gateKeeper();
$guid = getInput("guid");
$title = getInput("blog_title");
$description = getInput("description");
$access_id = getInput("access_id");
$container_guid = getInput("container_guid");
$owner_guid = getLoggedInUserGuid();
if ($guid) {
$blog = getEntity($guid);
} else {
$blog = new Blog();
}
$blog->title = $title;
$blog->description = $description;
$blog->access_id = $access_id;
$blog->owner_guid = $owner_guid;
$blog->status = "published";
$blog->container_guid = $container_guid;
$blog->save();
new Activity(getLoggedInUserGuid(), "blog:add", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $blog->getURL(), $blog->title, truncate($blog->description)), "", $access_id);
new SystemMessage("Your blog has been published");
forward("blogs/all_blogs");
}
开发者ID:socialapparatus,项目名称:socialapparatus,代码行数:25,代码来源:AddBlogActionHandler.php
示例4: generateMetaDescription
protected function generateMetaDescription()
{
sfProjectConfiguration::getActive()->loadHelpers('StringFunc');
$result = '';
switch ($this->getCurrentPageType()) {
case self::ARTICLE_PAGE:
//pealkiri. Sisu (250 chars)
if ($this->getRoute()->getObject()->getMetadescription()) {
return $this->getRoute()->getObject()->getMetadescription();
}
$content = truncate(strip_tags($this->getRoute()->getObject()->getTitle() . '. ' . $this->getRoute()->getObject()->getContent()), 250, '');
break;
case self::CATEGORY_PAGE:
// category name, products
if ($this->getRoute()->getCategoryObject()->getMetaDescription()) {
return $this->getRoute()->getCategoryObject()->getMetaDescription();
}
$content = implode(',', $this->getProductCategoryPageWords($this->getRoute()->getCategoryObject()));
break;
case self::PRODUCT_PAGE:
//toote nimi (kategooriad) - toode kirjelduse esimesed tähemärgid
$content = $this->getRoute()->getProductObject()->getName() . ' (' . implode(', ', $this->getProductCategoryPageWords($this->getRoute()->getCategoryObject())) . ') ' . $this->getRoute()->getProductObject()->getDescription();
break;
}
$result = truncate(strip_tags($content), 250, '');
return $result;
}
开发者ID:vcgato29,项目名称:poff,代码行数:27,代码来源:components.class.php
示例5: main_form
function main_form($x, $y, $data)
{
global $pdf;
global $_TITLE, $_LMARGIN, $_BMARGIN;
$balance = $data['balance'] < 0 ? -$data['balance'] : $data['balance'];
$font_size = 14;
$lineh = 25;
$x += $_LMARGIN;
$y += $_BMARGIN;
$y += 275;
$pdf->addtext($x, $y, $font_size, $data['d_name']);
$y -= $lineh;
$pdf->addtext($x, $y, $font_size, trim($data['d_zip'] . ' ' . $data['d_city'] . ' ' . $data['d_address']));
$y -= $lineh;
// for($i=0; $i<26; $i++)
// {
// $pdf->addtext($x+$i*14.6,$y,$font_size,$_ACCOUNT[$i]);
// }
$pdf->addtext($x, $y, $font_size, bankaccount($data['id'], $data['account']));
$y -= $lineh;
$pdf->addtext($x + 220, $y, $font_size, sprintf('%.2f', $balance));
$y -= $lineh;
$pdf->addtext($x, $y, $font_size, trans('$a dollars $b cents', to_words(floor($balance)), to_words(round(($balance - floor($balance)) * 100))));
$y -= $lineh;
$pdf->addtext($x, $y, $font_size, truncate($data['customername']));
$y -= $lineh;
$pdf->addtext($x, $y, $font_size, truncate(trim($data['zip'] . ' ' . $data['city'] . ' ' . $data['address'])));
$y -= $lineh;
$pdf->addtext($x, $y, $font_size, $_TITLE);
$y -= $lineh;
$pdf->addtext($x, $y, $font_size, trans('Customer ID: $a', sprintf('%04d', $data['id'])));
}
开发者ID:kornelek,项目名称:lms,代码行数:32,代码来源:transferforms2.php
示例6: urlize
static function urlize($url, $truncate = false)
{
if (preg_match('/^(http|https|ftp:\\/\\/([^\\s"\']+))/i', $url, $match)) {
$url = "<a href='{$url}'>" . ($truncate ? truncate($url, $truncate) : $url) . '</a>';
}
return $url;
}
开发者ID:hemantshekhawat,项目名称:Snippets,代码行数:7,代码来源:filters.php
示例7: getContentArticle
function getContentArticle($article, $wordwrap = 0)
{
if ($wordwrap > 0) {
$content = strip_tags($article->content);
return truncate($content, $wordwrap, '...');
} else {
return $article->content;
}
}
开发者ID:singgihsap,项目名称:elearning,代码行数:9,代码来源:article_helper.php
示例8: __NLStreamCopy
function __NLStreamCopy(NLStream $in, NLStream $out)
{
truncate($out, 0);
fseek($in->_imp_data, 0, SEEK_SET);
fseek($out->_imp_data, 0, SEEK_SET);
$len = __NLStreamCopyAtOffset($in->_imp_data, $out->_imp_data);
fseek($in->_imp_data, 0, SEEK_SET);
fseek($out->_imp_data, 0, SEEK_SET);
}
开发者ID:pombredanne,项目名称:Inutero,代码行数:9,代码来源:NLStream.php
示例9: test_truncate_with_options_hash
function test_truncate_with_options_hash()
{
$this->assertEqual("This is a string that wil[...]", truncate("This is a string that will go longer then the default truncate length of 30", array("omission" => "[...]")));
$this->assertEqual("Hello W...", truncate("Hello World!", array("length" => 10)));
$this->assertEqual("Hello[...]", truncate("Hello World!", array("omission" => "[...]", "length" => 10)));
$this->assertEqual("Hello[...]", truncate("Hello Big World!", array("omission" => "[...]", "length" => 13, "separator" => ' ')));
$this->assertEqual("Hello Big[...]", truncate("Hello Big World!", array("omission" => "[...]", "length" => 14, "separator" => ' ')));
$this->assertEqual("Hello Big[...]", truncate("Hello Big World!", array("omission" => "[...]", "length" => 15, "separator" => ' ')));
}
开发者ID:nerdfiles,项目名称:wordless_bp,代码行数:9,代码来源:text_helper_test.php
示例10: pingback_ping
public function pingback_ping($args)
{
$config = Config::current();
$linked_from = str_replace('&', '&', $args[0]);
$linked_to = str_replace('&', '&', $args[1]);
$cleaned_url = str_replace(array("http://www.", "http://"), "", $config->url);
if ($linked_to == $linked_from) {
return new IXR_ERROR(0, __("The from and to URLs cannot be the same."));
}
if (!substr_count($linked_to, $cleaned_url)) {
return new IXR_Error(0, __("There doesn't seem to be a valid link in your request."));
}
if (preg_match("/url=([^&#]+)/", $linked_to, $url)) {
$post = new Post(array("url" => $url[1]));
} else {
$post = MainController::current()->post_from_url(null, str_replace(rtrim($config->url, "/"), "/", $linked_to), true);
}
if (!$post) {
return new IXR_Error(33, __("I can't find a post from that URL."));
}
# Wait for the "from" server to publish
sleep(1);
$from = parse_url($linked_from);
if (empty($from["host"])) {
return false;
}
if (empty($from["scheme"]) or $from["scheme"] != "http") {
$linked_from = "http://" . $linked_from;
}
# Grab the page that linked here.
$content = get_remote($linked_from);
# Get the title of the page.
preg_match("/<title>([^<]+)<\\/title>/i", $content, $title);
$title = $title[1];
if (empty($title)) {
return new IXR_Error(32, __("There isn't a title on that page."));
}
$content = strip_tags($content, "<a>");
$url = preg_quote($linked_to, "/");
if (!preg_match("/<a[^>]*{$url}[^>]*>([^>]*)<\\/a>/", $content, $context)) {
$url = str_replace("&", "&", preg_quote($linked_to, "/"));
if (!preg_match("/<a[^>]*{$url}[^>]*>([^>]*)<\\/a>/", $content, $context)) {
$url = str_replace("&", "&", preg_quote($linked_to, "/"));
if (!preg_match("/<a[^>]*{$url}[^>]*>([^>]*)<\\/a>/", $content, $context)) {
return false;
}
}
}
$context[1] = truncate($context[1], 100, "...", true);
$excerpt = strip_tags(str_replace($context[0], $context[1], $content));
$match = preg_quote($context[1], "/");
$excerpt = preg_replace("/.*?\\s(.{0,100}{$match}.{0,100})\\s.*/s", "\\1", $excerpt);
$excerpt = "[...] " . trim(normalize($excerpt)) . " [...]";
Trigger::current()->call("pingback", $post, $linked_to, $linked_from, $title, $excerpt);
return _f("Pingback from %s to %s registered!", array($linked_from, $linked_to));
}
开发者ID:relisher,项目名称:chyrp,代码行数:56,代码来源:xmlrpc.php
示例11: __construct
public function __construct($data = NULL)
{
gateKeeper();
$logged_in_user = getLoggedInUser();
if (!$data) {
// Get the comment body
$comment_body = getInput("comment");
// Get container url
$container_guid = getInput("guid");
} else {
$comment_body = $data['comment_body'];
$container_guid = $data['container_guid'];
}
$container = getEntity($container_guid);
$container_owner_guid = $container->owner_guid;
if ($container_owner_guid) {
$container_owner = getEntity($container_owner_guid);
}
$url = $container->getURL();
if (!$url) {
$url = getSiteURL();
}
// Create the comment
CommentsPlugin::createComment($container_guid, $comment_body);
if ($container_owner_guid) {
if ($container_owner_guid != getLoggedInUserGuid()) {
$params = array("to" => array($container_owner->full_name, $container_owner->email), "from" => array(getSiteName(), getSiteEmail()), "subject" => "You have a new comment.", "body" => "You have a new comment. Click <a href='{$url}'>Here</a> to view it.", "html" => true);
switch ($logged_in_user->getSetting("notify_when_comment")) {
case "email":
sendEmail($params);
break;
case "none":
break;
case "site":
notifyUser("comment", $container_guid, getLoggedInUserGuid(), $container_owner_guid);
break;
case "both":
sendEmail($params);
notifyUser("comment", $container_guid, getLoggedInUserGuid(), $container_owner_guid);
break;
}
}
}
runHook("add:comment:after");
if (getLoggedInUserGuid() != $container_owner_guid && $container_owner_guid) {
new Activity(getLoggedInUserGuid(), "activity:comment", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $container_owner->getURL(), $container_owner->full_name, $container->getURL(), translate($container->type), truncate($comment_body)));
} elseif (!$container_owner_guid) {
new Activity(getLoggedInUserGuid(), "activity:comment:own", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $container->getURL(), $container->title, translate($container->type), truncate($comment_body)));
}
// Return to container page.
forward();
}
开发者ID:socialapparatus,项目名称:socialapparatus,代码行数:52,代码来源:AddCommentActionHandler.php
示例12: __construct
public function __construct()
{
gateKeeper();
$email_users = array();
$container_guid = getInput("container_guid");
$topic = getEntity($container_guid);
$category_guid = $topic->container_guid;
$category = getEntity($category_guid);
$description = getInput("comment");
$comment = new Forumcomment();
$comment->description = $description;
$comment->container_guid = $container_guid;
$comment->category_guid = $category_guid;
$comment->owner_guid = getLoggedInUserGuid();
$comment->save();
new SystemMessage("Your comment has been posted.");
new Activity(getLoggedInUserGuid(), "forum:comment:posted", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $topic->getURL(), $topic->title, truncate($comment->description)), $container_guid, $category->access_id);
$all_comments = getEntities(array("type" => "Forumcomment", "metadata_name" => "container_guid", "metadata_value" => $container_guid));
$notify_users = array($topic->owner_guid);
$container_owner_guid = $topic->owner_guid;
$container_owner = getEntity($container_owner_guid);
if ($container_owner->notify_when_forum_comment_topic_i_own == "email" || $container_owner->notify_when_forum_comment_topic_i_own == "both") {
$email_users[] = $container_guid;
}
foreach ($all_comments as $comment) {
$user_guid = $comment->owner_guid;
$user = getEntity($user_guid);
switch ($user->notify_when_forum_comment_topic_i_own) {
case "both":
$notify_users[] = $comment->owner_guid;
$email_users[] = $comment->owner_guid;
break;
case "email":
$email_users[] = $comment->owner_guid;
break;
case "site":
$notify_users[] = $comment->owner_guid;
break;
case "none":
break;
}
}
$notify_users = array_unique($notify_users);
foreach ($notify_users as $user_guid) {
notifyUser("forumcomment", $container_guid, getLoggedInUserGuid(), $user_guid);
}
foreach ($email_users as $user) {
$params = array("to" => array($user->full_name, $user->email), "from" => array(getSiteName(), getSiteEmail()), "subject" => "You have a new comment.", "body" => "You have a new comment. Click <a href='{$url}'>Here</a> to view it.", "html" => true);
sendEmail($params);
}
forward();
}
开发者ID:socialapparatus,项目名称:socialapparatus,代码行数:52,代码来源:AddForumCommentActionHandler.php
示例13: save_note
function save_note($id, $title, $body)
{
if ($body == "" && $title == "") {
$title = "Empty note";
}
if (($title == "" || $title == "Empty note") && $body != "") {
$title = truncate(strip_tags($body), 30);
}
$db = new db();
$result = $db->update("notes", array("title" => $title, "body" => $body), "id = :id", array(":id" => $id));
$result = array("id" => $id, "title" => $title, "body" => $body);
return $result;
}
开发者ID:thuraucsy,项目名称:holiday,代码行数:13,代码来源:note.php
示例14: formatTeaser
function formatTeaser($r)
{
$teaser = '';
if (array_key_exists('highlight', $r)) {
$teaser = trim(preg_replace('/\\s+/', ' ', preg_replace('/^\\*{2,}.*?\\n/', '', $r['highlight']['description'][0])));
} elseif (array_key_exists('description', $r['_source'])) {
$teaser = truncate(trim(preg_replace('/\\s+/', ' ', preg_replace('/^\\*{2,}.*/m', '', $r['_source']['description']))));
}
if ($teaser == '') {
$teaser = 'No data.';
}
return strip_tags($teaser);
}
开发者ID:jaksmid,项目名称:website,代码行数:13,代码来源:results.php
示例15: smarty_function_ajax_input
function smarty_function_ajax_input($params, &$smarty)
{
$id = $params['id'];
$class = $params['class'];
$value = $params['value'];
$default = $params['default'];
$display = $params['display'];
$mode = $params['mode'];
$noclear = $params['noclear'];
$truncate = (int) $params['truncate'];
$permission = $params['permission'];
$callSave = isset($params['file']) ? "saveField(this, " . $params['file'] . ")" : "saveField(this)";
$trucated = truncate($value, $truncate);
if ($mode == 'edit') {
$edit = 1;
} elseif ($mode == 'show') {
$edit = 0;
} else {
$edit = $value ? 0 : 1;
}
if (!$display) {
$display = 'block';
}
if (!$permission) {
$output .= '<div id="show-' . $id . '" class="' . $class . '" style="display:' . $display . '">';
$output .= $trucated ? $trucated : $default;
$output .= "</div>";
return $output;
} else {
$class .= " editable";
}
$output = '';
$output .= '<div id="show-' . $id . '" class="' . $class . '" style="display:' . ($edit ? 'none' : $display) . '" onClick="editaCampo(' . "'" . $id . "'" . ');">';
$output .= $edit ? $default : $trucated;
$output .= "</div>";
// TODO: escape value
$output .= '<input class="' . $class . '" id="input-' . $id . '" value="' . ($value ? $value : $default) . '" ';
if (!$value && !$noclear) {
$output .= " onFocus=\"limpaCampo('{$id}');\"";
}
$output .= " onChange=\"mudado['{$id}']=1; editing['{$id}'] = false;\" onBlur=\"{$callSave}\" style=\"display:" . ($edit ? $display : 'none') . "\">";
$output .= "<img id=\"error-{$id}\" class=\"gUpErrorImg\" style=\"display: none\" src=\"styles/estudiolivre/errorImg.png\" onMouseover=\"tooltip(errorMsg_{$id});\" onMouseout=\"nd();\"> ";
$output .= '<script language="JavaScript">';
$output .= ' display["' . $id . '"] = "' . $display . '";errorMsg_' . $id . ' = "";';
if ($truncate) {
$output .= ' truncations["' . $id . '"] = "' . $truncate . '";';
}
$output .= '</script>';
return $output;
}
开发者ID:rodrigoprimo,项目名称:estudiolivre,代码行数:50,代码来源:function.ajax_input.php
示例16: smarty_function_recentposts
function smarty_function_recentposts($params, &$bBlog)
{
$crit['num'] = isset($params['num']) ? $params['num'] : 5;
$crit['mode'] = isset($params['mode']) ? $params['mode'] : "br";
$crit['sep'] = isset($params['sep']) ? $params['sep'] : "<br />";
$crit['titlelen'] = isset($params['titlelen']) ? $params['titlelen'] : 30;
$crit['skip'] = isset($params['skip']) ? $params['skip'] : 0;
$linkcode = '';
$ph = $bBlog->_ph;
$posts = $ph->get_posts($crit);
if ($mode == "list") {
$linkcode .= "<ul>";
}
$i = 0;
if (is_array($posts)) {
/* <a([^<]*)?href=(\"|')?([a-zA-Z]*://[a-zA-Z0-9]*\.[a-zA-Z0-9]*\.[a-zA-Z]*([^>]*)?)(\"|')?([^>]*)?>([^<]*)</a> */
// This should match any protocol, any port, any URL, any title. URL's like www.yest.com are supported, and should be treated as HTTP by browsers.
$regex = "#<a([^<]*)?href=(\"|')?(([a-zA-Z]*://)?[a-zA-Z0-9]*\\.[a-zA-Z0-9]*\\.[a-zA-Z]*(:[0-9]*)?([^>\"\\']*)?)(\"|')?([^>]*)?>([^<]*)</a>#i";
foreach ($posts as $post) {
if ($post['title'] === 'No posts found') {
$linkcode .= '<strong>' . $post['title'] . '</strong>';
continue;
}
$title = $post["title"];
$fulltitle = $title;
//wont be cut off
if (preg_match($regex, $title, $matches) == 1) {
$title = $matches[9];
}
$i++;
if ($mode == "list") {
$linkcode .= "<li>";
}
// we using arrays in the template and objects in the core..
$url = $post['permalink'];
$title = truncate($title, $titlelen, '...', FALSE);
$linkcode .= "<a href='{$url}' title='{$fulltitle}'>{$title}</a>";
if ($mode == "br" && $num > $i) {
$linkcode .= $sep;
}
if ($mode == "list") {
$linkcode .= "</li>";
}
}
}
if ($mode == "list") {
$linkcode .= "</ul>";
}
return $linkcode;
}
开发者ID:BackupTheBerlios,项目名称:loquacity-svn,代码行数:50,代码来源:function.recentposts.php
示例17: sendpmmail
function sendpmmail($uid, $pm)
{
global $config, $check, $data;
$tempsql = $data->select_query("users", "WHERE id='{$uid}'", "id, uname, allowemail, newpm, email");
$temp = $data->fetch_array($tempsql);
if ($temp['allowemail'] && $temp['newpm']) {
$email = $data->select_fetch_one_row("emails", "WHERE type='newpm'");
$link = $config['siteaddress'] . "index.php?page=pmmain&action=readpm&id={$pm['id']}";
$cmscoutTags = array("!#uname#!", "!#postuname#!", "!#title#!", "!#type#!", "!#link#!", "!#extract#!", "!#website#!");
$replacements = array($temp['uname'], $check['uname'], $pm['subject'], "personal message", $link, truncate($pm['text'], 300), $config['troopname']);
$emailContent = str_replace($cmscoutTags, $replacements, $email['email']);
sendMail($temp['email'], $temp['uname'], $config['emailPrefix'] . $email['subject'], $emailContent);
}
}
开发者ID:burak-tekin,项目名称:CMScout2,代码行数:14,代码来源:typepm.php
示例18: custom_excerpt
function custom_excerpt($length = "750", $readMore = true)
{
// character length
$excerpt_length = $length;
$content = get_the_content();
$content = preg_replace('/<img[^>]+./', '', $content);
// preg_replace("/<img[^>]+\>/i", "(image) ", $content);
$excerpt = truncate($content, $excerpt_length, '...', false, true);
if ($readMore) {
$excerptHTML = '<p class="post-excerpt">' . $excerpt . ' <a href="' . get_permalink() . '">Read Post</a></p>';
} else {
$excerptHTML = '<p class="post-excerpt">' . $excerpt . '</p>';
}
echo strlen($excerpt) > 100 ? $excerptHTML : '';
}
开发者ID:vespertines,项目名称:wordpress_theme_starter,代码行数:15,代码来源:excerpt.php
示例19: vimeo
function vimeo($atts, $content = null)
{
extract(shortcode_atts(array('id' => ''), $atts));
$VideoInfo = getVimeoInfo($id);
$thumbnail = $VideoInfo['thumbnail_large'];
$title = $VideoInfo['title'];
$url = $VideoInfo['url'];
return '<dl class="gallery-item">
<dt class="gallery-icon vimeo">
<a href="' . $url . '" title="' . $title . '" rel="prettyPhoto">
<img width="300" height="200" src="' . $thumbnail . '" alt="' . $title . '" />
</a>
</dt>
<dd class="gallery-caption" style="opacity: 1; ">
' . truncate($title, 20) . '
</dd>
</dl>';
}
开发者ID:nishant368,项目名称:newlifeoffice-new,代码行数:18,代码来源:vimeo.php
示例20: article
function article()
{
$uri = $this->uri->rsegment(3);
if (is_numeric($uri) && $uri != 0) {
$query = $this->db->get_where('blog', array('id' => $uri));
$query2 = $this->db->get('catblog');
$this->load->view('newarticle', array('cats' => $query2->result(), 'data' => $query->row_array()));
return;
}
if (isset($_POST['title']) == false) {
$data = array('title' => '', 'textpost' => '', 'catid' => -1, 'url' => '', 'keywords' => " ", 'mainpage' => 0);
$query = $this->db->get('catblog');
$this->load->view('newarticle', array('cats' => $query->result(), 'data' => $data));
} else {
if (isset($_POST['title']) && isset($_POST['catid']) && isset($_POST['text'])) {
$perm = $this->userauth->default_permision;
$catid = $this->input->post('catid');
if (!isset($_POST['admin']) && !isset($_POST['user'])) {
$query = $this->db->get_where('catblog', array('id' => $this->input->post('catid')));
if ($query->num_rows > 0) {
$row = $query->row();
$perm = $row->permissions;
}
} else {
$perm = $this->_post_perm();
}
$data = array('title' => $this->input->post('title'), 'textpost' => $this->input->post('text'), 'permissions' => $perm, 'catid' => $catid, 'author' => $this->session->userdata('userid'), 'url' => isset($_POST['url']) && !empty($_POST['url']) ? $this->input->post('url') : date("Y_m_d_h_m"), 'keywords' => isset($_POST['keywords']) && !empty($_POST['keywords']) ? $this->input->post('keywords') : " ", 'shorttext' => truncate($this->input->post('text'), 200), 'datepost' => date("Y-m-d"), 'mainpage' => isset($_POST['mainpage']) ? $this->input->post('mainpage') : 0);
if (isset($_POST['article_id'])) {
$this->db->where('id', $this->input->post('article_id'));
if ($this->db->update('blog', $data) == 1) {
echo 'Added';
} else {
echo 'error';
}
} else {
if ($this->db->insert('blog', $data) == 1) {
echo 'Added';
} else {
echo 'error';
}
}
}
}
}
开发者ID:pussbb,项目名称:CI_DEV_CMS,代码行数:44,代码来源:action.php
注:本文中的truncate函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论