本文整理汇总了PHP中truncate_text函数的典型用法代码示例。如果您正苦于以下问题:PHP truncate_text函数的具体用法?PHP truncate_text怎么用?PHP truncate_text使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了truncate_text函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: show_message_overview
private function show_message_overview()
{
if (($message_count = $this->model->count_messages()) === false) {
$this->output->add_tag("result", "Database error.");
return false;
}
$paging = new pagination($this->output, "admin_forum", $this->settings->admin_page_size, $message_count);
if (($messages = $this->model->get_messages($paging->offset, $paging->size)) === false) {
$this->output->add_tag("result", "Database error.");
return;
}
$this->output->open_tag("overview");
$this->output->open_tag("messages");
foreach ($messages as $message) {
$message["content"] = truncate_text($message["content"], 400);
$message["timestamp"] = date("j F Y, H:i", $message["timestamp"]);
if ($message["author"] == "") {
$message["author"] = $message["username"];
}
$this->output->record($message, "message");
}
$this->output->close_tag();
$paging->show_browse_links();
$this->output->close_tag();
}
开发者ID:shannara,项目名称:banshee,代码行数:25,代码来源:forum.php
示例2: show_faq_overview
public function show_faq_overview()
{
if (($sections = $this->model->get_all_sections()) === false) {
$this->output->add_tag("result", "Database error.");
return;
} else {
if (($faqs = $this->model->get_all_faqs()) === false) {
$this->output->add_tag("result", "Database error.");
return;
}
}
$this->output->open_tag("overview");
$this->output->open_tag("sections");
foreach ($sections as $section) {
$this->output->add_tag("section", $section["label"], array("id" => $section["id"]));
}
$this->output->close_tag();
$this->output->open_tag("faqs");
foreach ($faqs as $faq) {
$faq["question"] = truncate_text($faq["question"], 140);
$this->output->record($faq, "faq");
}
$this->output->close_tag();
$this->output->close_tag();
}
开发者ID:shannara,项目名称:banshee,代码行数:25,代码来源:faq.php
示例3: execute
public function execute()
{
if ($_SERVER["REQUEST_METHOD"] == "POST") {
/* Delete message
*/
if ($this->model->delete_message($_POST["id"])) {
$this->user->log_action("guestbook entry %d deleted", $_POST["id"]);
}
}
handle_table_sort("adminguestbook_order", array("author", "message", "timestamp", "ip_address"), array("timestamp", "author"));
$paging = new pagination($this->output, "admin_guestbook", $this->settings->admin_page_size, $message_count);
if (($guestbook = $this->model->get_messages($_SESSION["adminguestbook_order"], $paging->offset, $paging->size)) === false) {
$this->output->add_tag("result", "Database error.");
return;
}
$this->output->open_tag("guestbook");
foreach ($guestbook as $item) {
$item["message"] = truncate_text($item["message"], 45);
if ($this->output->mobile) {
$item["timestamp"] = date("Y-m-d", $item["timestamp"]);
} else {
$item["timestamp"] = date("j F Y, H:i", $item["timestamp"]);
}
$this->output->record($item, "item");
}
$paging->show_browse_links();
$this->output->close_tag();
}
开发者ID:shannara,项目名称:banshee,代码行数:28,代码来源:guestbook.php
示例4: extractSummaryArray
public static function extractSummaryArray($body, $min, $total)
{
//replace whitespaces with space
$body = preg_replace("/(\\r?\\n[ \\t]*)+/", " ", $body);
//find paragraphs
$matches = array();
preg_match_all("/<p>(.+)<\\/p>/isU", $body, $matches, PREG_SET_ORDER);
//put paragraphs to a fresh array and calculate total length
$total_length = 0;
$paragraphs = array();
foreach ($matches as $match) {
$len = 0;
if (($len = strlen($match[1])) > $min) {
$paragraphs[] = $match[1];
$total_length += strlen($match[1]);
}
}
//chop paragraphs
sfLoader::loadHelpers('Text');
$final = array();
for ($i = 0; $i < sizeof($paragraphs); $i++) {
$share = (int) ($total * strlen($paragraphs[$i]) / $total_length);
if ($share < $min) {
$total_length -= strlen($paragraphs[$i]);
continue;
}
$final[] = truncate_text($paragraphs[$i], $share, "", true);
}
return $final;
}
开发者ID:hoydaa,项目名称:snippets.hoydaa.org,代码行数:30,代码来源:myUtils.class.php
示例5: truncate_description
function truncate_description($description, $route, $length = 500, $has_abstract = false)
{
if ($has_abstract) {
$description = extract_abstract($description);
}
$more = '... <span class="more_text">' . link_to('[' . __('Read more') . ']', $route) . '</span>';
return parse_links(parse_bbcode_simple(truncate_text($description, $length, $more)));
}
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:8,代码来源:PopupHelper.php
示例6: execute
public function execute()
{
if ($this->user->logged_in == false) {
unset($this->sections["mail"]);
}
if (isset($_SESSION["search"]) == false) {
$_SESSION["search"] = array();
foreach ($this->sections as $section => $label) {
$_SESSION["search"][$section] = true;
}
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$this->log_search_query($_POST["query"]);
foreach ($this->sections as $section => $label) {
$_SESSION["search"][$section] = is_true($_POST[$section]);
}
}
$this->output->add_css("banshee/js_pagination.css");
$this->output->add_javascript("banshee/pagination.js");
$this->output->add_javascript("search.js");
$this->output->run_javascript("document.getElementById('query').focus()");
$this->output->add_tag("query", $_POST["query"]);
$this->output->open_tag("sections");
foreach ($this->sections as $section => $label) {
$params = array("label" => $label, "checked" => show_boolean($_SESSION["search"][$section]));
$this->output->add_tag("section", $section, $params);
}
$this->output->close_tag();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (strlen(trim($_POST["query"])) < 3) {
$this->output->add_tag("result", "Search query too short.");
} else {
if (($result = $this->model->search($_POST, $this->sections)) === false) {
/* Error
*/
$this->output->add_tag("result", "Search error.");
} else {
if (count($result) == 0) {
$this->output->add_tag("result", "No matches found.");
} else {
/* Results
*/
foreach ($result as $section => $hits) {
$this->output->open_tag("section", array("section" => $section, "label" => $this->sections[$section]));
foreach ($hits as $hit) {
$hit["text"] = strip_tags($hit["text"]);
$hit["content"] = strip_tags($hit["content"]);
$hit["content"] = preg_replace('/\\[.*?\\]/', "", $hit["content"]);
$hit["content"] = truncate_text($hit["content"], 400);
$this->output->record($hit, "hit");
}
$this->output->close_tag();
}
}
}
}
}
}
开发者ID:shannara,项目名称:banshee,代码行数:58,代码来源:search.php
示例7: link_to_related_property
/**
* creates a link to related schema property
*
* @return none
* @param schemaproperty $property
*/
function link_to_related_property($property)
{
$relPropertyId = $property->getIsSubpropertyOf();
$relPropertyUri = $property->getParentUri();
if ($relPropertyId) {
//get the related concept
$relProperty = SchemaPropertyPeer::retrieveByPK($relPropertyId);
if ($relProperty) {
return link_to($relProperty->getLabel(), 'schemaprop/show/?id=' . $relPropertyId, ['title' => $relPropertyUri]);
}
}
//if all else fails we display a truncated = 30 value
return truncate_text($property->getParentUri(), 30);
}
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:20,代码来源:SchemaHelper.php
示例8: show_mails
private function show_mails($mails, $column)
{
$this->output->open_tag("mailbox", array("column" => $column));
foreach ($mails as $mail) {
$mail["subject"] = truncate_text($mail["subject"], 55);
if ($this->mobile) {
$mail["timestamp"] = date_string("Y-m-d", $mail["timestamp"]);
} else {
$mail["timestamp"] = date_string("l, j F Y H:i:s", $mail["timestamp"]);
}
$mail["read"] = $mail["read"] == YES ? "read" : "unread";
$this->output->record($mail, "mail");
}
$this->output->close_tag();
}
开发者ID:shannara,项目名称:banshee,代码行数:15,代码来源:mailbox.php
示例9: generateMessage
/**
* generate Wildcard.. truncate if necessary, $pUrl is optional
*
* @param YiidActivity $pActivity
* @return string
*/
public function generateMessage($pActivity)
{
sfProjectConfiguration::getActive()->loadHelpers('Text');
$lUrl = ShortUrlTable::shortenUrl($pActivity->generateUrlWithClickbackParam($this->onlineIdentity));
$lMaxChars = 135;
$lText = $lUrl;
$lLengthOfText = strlen($lText);
if ($pActivity->getComment()) {
$lChars = $lMaxChars - $lLengthOfText;
$lText = truncate_text($pActivity->getComment(), $lChars, '...') . " " . $lText;
} elseif ($pActivity->getTitle()) {
$lChars = $lMaxChars - $lLengthOfText;
$lText = truncate_text($pActivity->getTitle(), $lChars, '...') . " " . $lText;
}
return array("status" => $lText);
}
开发者ID:42medien,项目名称:spreadly,代码行数:22,代码来源:TwitterPostApiClient.php
示例10: link_to_related
/**
* creates a link to related concept
*
* @return none
* @param conceptproperty $property
*/
function link_to_related($property)
{
$relConceptId = $property->getRelatedConceptId();
if ($relConceptId) {
//get the related concept
$relConcept = ConceptPeer::retrieveByPK($relConceptId);
if ($relConcept) {
return link_to($relConcept->getPrefLabel(), 'concept/show/?id=' . $relConceptId);
}
}
//If the skosProperty.objectType is resource then we display a truncated URI with a complete link_to
if ($property->getProfileProperty()->getIsObjectProp()) {
return link_to(truncate_text($property->getObject(), 30), $property->getObject());
}
//if all else fails we display a truncated = 30 value
return truncate_text($property->getObject(), 30);
}
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:23,代码来源:ConceptHelper.php
示例11: summarize
public function summarize($body)
{
$matches = array();
preg_match_all("/<p>(.+)<\\/p>/isU", $body, $matches, PREG_SET_ORDER);
$paragraphs = array();
foreach ($matches as $match) {
$paragraphs[] = preg_replace("/(\\r?\\n[ \\t]*)+/", " ", strip_tags($match[1]));
}
$total = $this->total($paragraphs);
foreach ($paragraphs as $i => $paragraph) {
if (strlen($paragraph) / $total * 100 < $this->threshold) {
unset($paragraphs[$i]);
}
}
$total = $this->total($paragraphs);
$spaces = count($paragraphs) - 1;
foreach ($paragraphs as $i => $paragraph) {
$paragraphs[$i] = truncate_text($paragraph, strlen($paragraph) / $total * ($this->max - $spaces), '...', true);
}
return implode(' ', $paragraphs);
}
开发者ID:hoydaa,项目名称:snippets.hoydaa.org,代码行数:21,代码来源:Summarizer.class.php
示例12: show_weblog_form
private function show_weblog_form($weblog)
{
$this->output->add_javascript("ckeditor/ckeditor.js");
$this->output->add_javascript("banshee/start_ckeditor.js");
$this->output->open_tag("edit");
$weblog["visible"] = show_boolean($weblog["visible"]);
$this->output->record($weblog, "weblog");
/* Tags
*/
$tagged = array();
if (isset($weblog["tag"])) {
$tagged = $weblog["tag"];
} else {
if (($weblog_tags = $this->model->get_weblog_tags($weblog["id"])) != false) {
foreach ($weblog_tags as $tag) {
array_push($tagged, $tag["id"]);
}
}
}
$this->output->open_tag("tags");
if (($tags = $this->model->get_tags()) != false) {
foreach ($tags as $tag) {
$this->output->add_tag("tag", $tag["tag"], array("id" => $tag["id"], "selected" => show_boolean(in_array($tag["id"], $tagged))));
}
}
$this->output->close_tag();
/* Comments
*/
$this->output->open_tag("comments");
if (($weblog_comments = $this->model->get_weblog_comments($weblog["id"])) != false) {
foreach ($weblog_comments as $comment) {
$comment["content"] = truncate_text($comment["content"], 100);
$this->output->record($comment, "comment");
}
}
$this->output->close_tag();
$this->output->close_tag();
}
开发者ID:shannara,项目名称:banshee,代码行数:38,代码来源:weblog.php
示例13: document_get_field_value
/**
* Функция получения содержимого поля для обработки в шаблоне рубрики
*
* @param int $field_id идентификатор поля, для [tag:fld:12] $field_id = 12
* @param int $length необязательный параметр,
* количество возвращаемых символов содержимого поля.
* если данный параметр указать со знаком минус
* содержимое поля будет очищено от HTML-тегов.
* @return string
*/
function document_get_field_value($field_id, $length = 0)
{
if (!is_numeric($field_id)) {
return '';
}
$document_fields = get_document_fields(get_current_document_id());
$field_value = trim($document_fields[$field_id]['field_value']);
if ($field_value != '') {
$field_value = strip_tags($field_value, "<br /><strong><em><p><i>");
if (is_numeric($length) && $length != 0) {
if ($length < 0) {
$field_value = strip_tags($field_value);
$field_value = preg_replace('/ +/', ' ', $field_value);
$field_value = trim($field_value);
$length = abs($length);
}
$field_value = truncate_text($field_value, $length, '…', true);
}
}
return $field_value;
}
开发者ID:RGBvision,项目名称:AVE.cms,代码行数:31,代码来源:func.parsefields.php
示例14: foreach
</thead>
<tbody>
<?php
foreach ($pager->getResults() as $rt_comment) {
?>
<tr>
<td>
<a href="<?php
echo url_for('rtCommentAdmin/edit?id=' . $rt_comment->getId());
?>
"><?php
echo $rt_comment->getAuthorName();
?>
</a>:<br />
<?php
echo truncate_text(strip_tags($rt_comment->getContent()), 100);
?>
</td>
<td class="rt-admin-publish-toggle">
<?php
echo rt_nice_boolean($rt_comment->getIsActive());
?>
<div style="display:none;"><?php
echo $rt_comment->getId();
?>
</div>
</td>
<td><?php
echo $rt_comment->getCreatedAt();
?>
</td>
开发者ID:pierswarmers,项目名称:rtCorePlugin,代码行数:31,代码来源:indexSuccess.php
示例15: truncate_text
<?php
echo truncate_text($event->getDescription(), 150);
开发者ID:pycmam,项目名称:neskuchaik.ru,代码行数:3,代码来源:_description.php
示例16: DateTime
<tr>
<td><?php
$date = new DateTime($info['modification_date_time']);
echo $date->format('d/m/Y H:i:s');
?>
</td>
<td><?php
echo $info['referenced_relation'];
?>
</td>
<td><?php
echo __($info['formattedStatus']);
?>
</td>
<td><?php
echo truncate_text($info['comment'], 30);
?>
</td>
<td>
<?php
echo image_tag('info.png', 'class=more_comment');
?>
<ul class="field_change">
<?php
echo $info['comment'];
?>
</ul>
<?php
echo link_to(image_tag('blue_eyel.png'), $info->getLink('view'));
?>
<?php
开发者ID:naturalsciences,项目名称:Darwin,代码行数:31,代码来源:searchSuccess.php
示例17: truncate_text
<td><?php
echo $nota->getIdNota();
?>
</td>
<td><?php
$texto = truncate_text($nota->getTexto(), 50);
echo link_to($texto ? $texto : '-', 'notas/edit?id_usuario=' . $nota->getIdUsuario() . "&id_nota=" . $nota->getIdNota());
?>
</td>
<td><?php
echo format_date($nota->getUpdatedAt(), 'f');
?>
</td>
开发者ID:Esleelkartea,项目名称:legedia-ESLE,代码行数:13,代码来源:_notas_td_tabular.php
示例18: generateTopGames
function generateTopGames($timeframe)
{
if ($timeframe == 'day') {
$topTenDivName = 'topTenElementForDay';
$queryInterval = '1 DAY';
} else {
if ($timeframe == 'week') {
$topTenDivName = 'topTenElementForWeek';
$queryInterval = '7 DAY';
} else {
if ($timeframe == 'month') {
$topTenDivName = 'topTenElementForMonth';
$queryInterval = '1 MONTH';
}
}
}
/*
else if ($timeframe == 'alltime')
{
$topTenDivName = 'topTenElementForAllTime';
$queryInterval = '100 YEAR';
}
*/
$query = '
SELECT media.file_path as file_path, temp.game_id, temp.name, temp.description, temp.count FROM
(SELECT games.game_id, games.name, games.description, games.icon_media_id, COUNT(DISTINCT player_id) AS count
FROM games
INNER JOIN player_log ON games.game_id = player_log.game_id
WHERE player_log.timestamp BETWEEN DATE_SUB(NOW(), INTERVAL ' . $queryInterval . ') AND NOW()
GROUP BY games.game_id
HAVING count > 1) as temp
LEFT JOIN media ON temp.icon_media_id = media.media_id
GROUP BY game_id
HAVING count > 1
ORDER BY count DESC
';
//echo "<!-- ".$query." -->";
$result = mysql_query($query);
$counter = 0;
echo "<div id=\"" . $topTenDivName . "\">\n";
while ($game = mysql_fetch_object($result)) {
$counter++;
if ($counter > $GLOBALS['numTopGames']) {
break;
}
$name = $game->name;
$gameid = $game->game_id;
$count = $game->count;
$iconFileURL = $game->file_path;
$description = truncate_text($game->description, 215);
$query = "SELECT name FROM game_editors LEFT JOIN editors ON game_editors.editor_id = editors.editor_id WHERE game_editors.game_id = {$gameid}";
$authorResult = mysql_query($query);
$authors = array();
while ($author = mysql_fetch_object($authorResult)) {
$authors[] = $author;
}
echo "<div class=\"topTenElement\">\n";
if ($iconFileURL) {
$iconURL = 'http://www.arisgames.org/server/gamedata/' . $iconFileURL;
} else {
$iconURL = 'defaultLogo.png';
}
echo '<div class="topTenNumBox"><div class="topTenNum"><img class="topTenImg" alt="img" width="64" height="64" src="' . $iconURL . "\" /></div></div>\n";
echo '<div class="topTenGameNameAndDesc"><p class="topTenName"><strong>' . $name . "</strong></p>\n";
$editorString = '<p class="topTenAuthor">';
foreach ($authors as $author) {
$editorString = $editorString . $author->name . ", ";
}
$editorString = substr($editorString, 0, strlen($editorString) - 2);
$editorString = $editorString . "</p>";
echo $editorString;
echo '<p class="topTenDescription">' . $description . "</p></div>\n";
echo '<div class="topTenGameCount"><span class="topTenPlayerCount">' . $count . '</span><p class="topTenPlayerText">players</p></div>';
/*
// get the location (use the google maps api to get a name for the long/lat)
$query2 = 'SELECT longitude, latitude FROM ' . $game->id . '_locations LIMIT 1';
$result2 = mysql_query($query2);
if (mysql_num_rows($result2) == 1)
{
$row = mysql_fetch_object($result2);
if ($row->latitude != 0 && $row->longitude != 0)
{
$toplat = $row->latitude;
$toplong = $row->longitude;
}
}
echo '<div class="topTenLocation">';
//echo '<script type="text/javascript">';
//echo 'document.write(reverseLatLng(' . $toplat . ', ' . $toplong . '));</script>';
//echo "</div>\n"; */
echo "</div>\n";
}
echo "</div>\n";
}
开发者ID:kimblemj,项目名称:server,代码行数:98,代码来源:index.php
示例19: image_tag
<h1>Announcements</h1>
<?php
echo image_tag('divider.png', 'class=divider');
if ($projectAnnouncementPager->getResults()) {
?>
<div id="announcements">
<?php
foreach ($projectAnnouncementPager->getResults() as $projectAnnouncement) {
?>
<div>
<h3><?php
echo $projectAnnouncement->getSubject();
?>
</h3>
<p><?php
echo truncate_text($projectAnnouncement->getDetails(), 200);
?>
<?php
echo link_to('more', 'project/showAnnouncement?id=' . $projectAnnouncement->getId());
?>
</p>
<span class="date">Posted on <?php
echo $projectAnnouncement->getCreatedAt();
?>
</span>
</div>
<?php
}
?>
</div>
<?php
开发者ID:hoydaa,项目名称:hoydaa.org,代码行数:31,代码来源:listAnnouncementsSuccess.php
示例20:
{
echo '<div class="img-browser"><a href="#" onclick="selectURL(\''.$linkpath.$file['name'][$i].'\');" title="'.TB_FILENAME.': '.$file['name'][$i]
.' '.TB_DIMENSIONS.': '.$file['width'][$i].' x '.$file['height'][$i]
.' '.TB_DATE.': '.date($tinybrowser['dateformat'],$file['modified'][$i])
.' '.TB_TYPE.': '.$file['type'][$i]
.' '.TB_SIZE.': '.bytestostring($file['size'][$i],1)
.'"><img src="'.$thumbpath.'_thumbs/_'.$file['name'][$i]
.'" /><div class="filename">'.$file['name'][$i].'</div></a></div>';
}
}
else
{
for($i=$showpage_start;$i<$showpage_end;$i++)
{
$alt = (IsOdd($i) ? 'r1' : 'r0');
echo '<tr class="'.$alt.'">';
if($typenow=='image') echo '<td><a class="imghover" href="#" onclick="selectURL(\''.$linkpath.$file['name'][$i].'\');" title="'.$file['name'][$i].'"><img src="'.$thumbpath.'_thumbs/_'.$file['name'][$i].'" alt="" />'.truncate_text($file['name'][$i],30).'</a></td>';
else echo '<td><a href="#" onclick="selectURL(\''.$linkpath.$file['name'][$i].'\');" title="'.$file['name'][$i].'">'.truncate_text($file['name'][$i],30).'</a></td>';
echo '<td>'.bytestostring($file['size'][$i],1).'</td>';
if($typenow=='image') echo '<td>'.$file['width'][$i].' x '.$file['height'][$i].'</td>';
echo '<td>'.$file['type'][$i].'</td>'
.'<td>'.date($tinybrowser['dateformat'],$file['modified'][$i]).'</td></tr>'."\n";
}
echo '</table></div>';
}
?>
</fieldset></div></div>
<form name="passform"><input name = "fileurl" type="hidden" value= "" /></form>
</body>
</html>
开发者ID:nyroDev,项目名称:nyroFwk,代码行数:30,代码来源:tinybrowser.php
注:本文中的truncate_text函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论