本文整理汇总了PHP中text::limit_words方法的典型用法代码示例。如果您正苦于以下问题:PHP text::limit_words方法的具体用法?PHP text::limit_words怎么用?PHP text::limit_words使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类text
的用法示例。
在下文中一共展示了text::limit_words方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* 分类列表
*/
public function index()
{
//* 权限验证 */
$site_id = site::id();
Myseo_manage::instance()->update_seo_manage_by_site_id($site_id);
if ($site_id == 0) {
remind::set('请首先进入所要操作的站点', request::referrer(), 'error');
}
$site_id_list = role::check('seo_manage', 0, 0);
if (empty($site_id_list)) {
remind::set('access denied', request::referrer(), 'error');
}
$query_struct = array();
$query_struct = array('where' => array('site_id' => $site_id));
$list_columns = array(array('name' => 'ID', 'column' => 'id', 'class_num' => '1'), array('name' => '分类', 'column' => 'parent_id', 'class_num' => '4'), array('name' => '包含子分类', 'column' => 'is_contain_child', 'class_num' => '3'), array('name' => 'Meta Title', 'column' => 'meta_title', 'class_num' => '5'), array('name' => 'Meta Keywords', 'column' => 'meta_keywords', 'class_num' => '5'), array('name' => 'Meta Description', 'column' => 'meta_description', 'class_num' => '6'), array('name' => '发布时间', 'column' => 'create_timestamp', 'class_num' => '5'), array('name' => '更新时间', 'column' => 'update_timestamp', 'class_num' => '5'));
$this->template->content = new View("product/seo_manage_list");
$this->template->content->list_columns = $list_columns;
/**
* 搜索
*/
/*
$search_arr = array('site_domain','site_id');
$search_type = $this->input->get('search_type');
$search_value = $this->input->get('search_value');
if($search_value&&$search_type)
{
if(in_array($search_type,$search_arr))
{
$query_struct['like'][$search_type] = $search_value;
}
}*/
//调用分页
$per_page = controller_tool::per_page();
$this->pagination = new Pagination(array('total_items' => Myseo_manage::instance()->count($query_struct), 'items_per_page' => $per_page));
$orderby = array('update_timestamp' => 'DESC');
$seo_manages = Myseo_manage::instance()->seo_manages($query_struct, $orderby, $per_page, $this->pagination->sql_offset);
$request_category = array('where' => array('site_id' => $site_id), 'like' => array(), 'orderby' => array());
$category = Mycategory::instance()->lists($request_category);
foreach ($category as $val) {
$category_list[$val['id']] = $val;
}
foreach ($seo_manages as $seo_manages_key => $seo_manages_value) {
$seo_manages[$seo_manages_key]['is_contain_child'] = view_tool::get_active_img($seo_manages_value['is_contain_child']);
$seo_manages[$seo_manages_key]['meta_description'] = strip_tags(text::limit_words($seo_manages_value['meta_description'], 50));
$seo_manages[$seo_manages_key]['create_timestamp'] = date('Y-m-d H:i:s', $seo_manages_value['create_timestamp']);
$seo_manages[$seo_manages_key]['update_timestamp'] = date('Y-m-d H:i:s', $seo_manages_value['update_timestamp']);
if ($seo_manages_value['parent_id'] && array_key_exists($seo_manages_value['parent_id'], $category_list)) {
$seo_manages[$seo_manages_key]['parent_id'] = $category_list[$seo_manages_value['parent_id']]['name'];
} else {
$seo_manages[$seo_manages_key]['parent_id'] = '';
}
foreach ($seo_manages_value as $key => $value) {
if (!is_numeric($value) && empty($value)) {
$seo_manages[$seo_manages_key][$key] = "NULL";
}
}
}
$this->template->content->seo_manages = $seo_manages;
}
示例2: index
/**
* 列表
*/
public function index()
{
$query_struct = array();
/**
* 搜索
*/
$search_value = $this->input->get('search_value');
if ($search_value) {
$query_struct['where']['mail_category_id'] = $search_value;
}
//调用分页
$per_page = controller_tool::per_page();
$this->pagination = new Pagination(array('total_items' => Mymail_template::instance()->count($query_struct), 'items_per_page' => $per_page));
$mail_templates = Mymail_template::instance()->mail_templates($query_struct, array('id' => 'DESC'), $per_page, $this->pagination->sql_offset);
foreach ($mail_templates as $k => $v) {
foreach ($v as $key => $value) {
if (!is_numeric($value) && empty($value)) {
$mail_templates[$k][$key] = 'NULL';
}
}
$mail_templates[$k]['content_small'] = strip_tags(text::limit_words($v['content'], 30));
$mail_templates[$k]['active_img'] = view_tool::get_active_img($v['active']);
}
$mail_categories = Mymail_category::instance()->mail_categories();
$this->template->content = new View("manage/mail_template_list");
$this->template->content->mail_templates = $mail_templates;
$this->template->content->mail_categories = $mail_categories;
}
示例3: index
/**
* 列表
*/
public function index()
{
//查询条件
$query_struct = array('orderby' => array('id' => 'DESC'));
/* 搜索 */
$search_arr = array('title', 'content');
$search_type = $this->input->get('search_type');
$search_value = $this->input->get('search_value');
if (!empty($search_value) && in_array($search_type, $search_arr)) {
$query_struct['like'][$search_type] = $search_value;
}
$where_view['search_value'] = $search_value;
//调用分页
$per_page = controller_tool::per_page();
$query_struct['per_page'] = $per_page;
$this->pagination = new Pagination(array('total_items' => Mynotice::instance()->count($query_struct), 'items_per_page' => $per_page));
$query_struct['per_page'] = $this->pagination->sql_offset;
$notice = Mynotice::instance()->lists($query_struct);
foreach ($notice as $k => $v) {
$notice[$k]['content_small'] = strip_tags(text::limit_words($v['content'], 30));
$notice[$k]['manager_id'] = Mymanager::instance($v['manager_id'])->get('name');
}
//VIEW
$this->template->content = new View("manage/notice_list");
$this->template->content->notice = $notice;
$this->template->content->where = $where_view;
}
示例4: index
/**
* 列表
*/
public function index()
{
$mails = Mymail::instance()->mails();
foreach ($mails as $k => $v) {
$mails[$k]['content_small'] = strip_tags(text::limit_words($v['content'], 30));
$mails[$k]['active_img'] = view_tool::get_active_img($v['active']);
}
$this->template->content = new View("site/mail_list");
$this->template->content->mails = $mails;
}
示例5: full
public function full()
{
$posts = ORM::factory('feedpost')->{$feed}->where(array('status_id' => 2))->find_all();
$items = array();
foreach ($posts as $item) {
$items[] = array("pubDate" => $item->get_date('r'), "title" => $item->title, "description" => text::limit_words($item->text, 200), "item_is_complete" => 1, "link" => "http://" . $_SERVER['HTTP_HOST'] . $item->get_url());
}
$channel = array("title" => ORM::factory('setting', 'COMPANY_NAME')->value . " - " . $feed->title, "description" => $feed->description, "link" => "http://" . $_SERVER['HTTP_HOST'] . url::base(), "items" => $items);
$rss = new RSS_Writer($channel);
echo $rss->get_feed();
}
示例6: get_snips_public
public function get_snips_public($sql_limit, $sql_offset)
{
$results = '';
$db = Database::instance();
$query = $db->from('snips')->where(array('private =' => '0'))->limit($sql_limit * 10)->offset($sql_offset)->orderby('date_added', 'DESC')->get();
if ($query) {
if ($sql_limit == 1) {
$results .= "<ol start='" . $sql_limit . "' class='snipList'>\n";
} else {
$results .= "<ol start='" . $sql_limit * 10 . "' class='snipList'>\n";
}
foreach ($query as $row) {
$results .= "<li>\n";
$timeago = date::timespan(strtotime($row->date_added), time(), "days");
if ($timeago == 0) {
$timeago = date::timespan(strtotime($row->date_added), time(), "hours");
$timeago .= " hours";
} else {
$timeago .= " days";
}
$results .= "<h2>";
$username = $this->db->query("SELECT username FROM users WHERE id = " . $row->user_id . "");
foreach ($username as $row2) {
$username = $row2->username;
}
$results .= "<a href='/home/snip/" . $row->snip_id . "'>" . $row->title . "</a></h2><span class='favLink'><a href=\"#\">Favorite</a></span>" . "submitted " . $timeago . " ago by " . $username . " ";
$results .= "<p>";
$results .= "<pre>" . text::limit_words($row->snippet, 10, "...<a href='/home/snip/" . $row->snip_id . "'>see whole snippet</a>") . "</pre>";
if (strlen($row->description) > 1) {
$results .= "Description: " . strip_tags(text::limit_words($row->description, 25));
}
$results .= "</p>\n";
$results .= "</li>\n";
}
$results .= "</ol>\n";
}
return $results;
}
示例7: foreach
// Get the first category that this placemarker is assigned to
foreach ($item->category as $item_category) {
if (!$item_category->category_visible) {
continue;
}
echo "<styleUrl>#category_" . $item_category->id . "</styleUrl>";
break;
}
?>
<name><![CDATA[<?php
echo $item->incident_title;
?>
]]></name>
<description>
<![CDATA[<?php
echo text::limit_words($item->incident_description, 50, "...");
echo "<br /><a href=\"" . url::base() . 'reports/view/' . $item->id . "\">More...</a>";
?>
]]>
</description>
<address><![CDATA[<?php
echo $item->location->location_name;
?>
]]></address>
<Point>
<coordinates>
<?php
echo $item->location->longitude . "," . $item->location->latitude;
?>
</coordinates>
</Point>
示例8: foreach
foreach ($products as $v) {
?>
<tr id="product_<?php
echo !empty($v->id) ? $v->id : uniqid();
?>
">
<td>
<a class="product_name" title="Szczegóły" href="<?php
echo url::site('products/details.' . $v->id);
?>
"><b><?php
echo $v->name;
?>
</b></a>
<p class="description"><?php
echo text::limit_words($v->description, 10);
?>
</p>
</td>
<td ><p class="product_name">
<?php
echo form::input('product[' . $v->id . ']', $v->unit->type == 'integer' ? (int) $quantity[$v->id] : number_format($quantity[$v->id], 2), array('class' => 'input_width'));
?>
<?php
echo $v->unit->name;
?>
</p></td>
<td><p class="product_name"><?php
echo number_format($v->price->value * $quantity[$v->id], 2);
?>
示例9: foreach
<ul>
<?php
foreach ($comments as $i => $comment) {
?>
<li class="<?php
echo $i % 2 == 0 ? "gEvenRow" : "gOddRow";
?>
">
<img src="<?php
echo $comment->author()->avatar_url(32, $theme->url("images/avatar.jpg", true));
?>
"
class="gAvatar"
alt="<?php
echo $comment->author_name();
?>
"
width="32"
height="32" />
<?php
echo date("Y-M-d H:i:s", $comment->created);
?>
<?php
echo t("<a href=#>%author_name</a> said <em>%comment_text</em>", array("author_name" => $comment->author_name(), "comment_text" => text::limit_words($comment->text, 50)));
?>
</li>
<?php
}
?>
</ul>
示例10: foreach
?>
<Placemark>
<?php
// Get the first category that this placemarker is assigned to
foreach ($item->category as $item_category) {
echo "<styleUrl>#category_" . $item_category->id . "</styleUrl>";
break;
}
?>
<name><?php
echo htmlspecialchars($item->incident_title);
?>
</name>
<description>
<?php
echo htmlspecialchars(text::limit_words($item->incident_description, 50, "..."));
echo "<BR /><a href=\"" . url::base() . 'reports/view/' . $item->id . "\">More...</a>";
?>
</description>
<Point>
<coordinates><?php
echo $item->location->longitude . "," . $item->location->latitude;
?>
</coordinates>
</Point>
</Placemark>
<?php
}
?>
</Document>
</kml>
示例11: import_comment
/**
* Import a single comment.
*/
static function import_comment(&$queue)
{
$g2_comment_id = array_shift($queue);
try {
$g2_comment = g2(GalleryCoreApi::loadEntitiesById($g2_comment_id));
} catch (Exception $e) {
return t("Failed to import Gallery 2 comment with id: %id\\%exception", array("id" => $g2_comment_id, "exception" => $e->__toString()));
}
$text = $g2_comment->getSubject();
if ($text) {
$text .= " ";
}
$text .= $g2_comment->getComment();
// Just import the fields we know about. Do this outside of the comment API for now so that
// we don't trigger spam filtering events
$comment = ORM::factory("comment");
$comment->author_id = self::map($g2_comment->getCommenterId());
$comment->guest_name = $g2_comment->getAuthor();
$comment->item_id = self::map($g2_comment->getParentId());
$comment->text = self::_transform_bbcode($text);
$comment->state = "published";
$comment->server_http_host = $g2_comment->getHost();
$comment->created = $g2_comment->getDate();
$comment->save();
self::map($g2_comment->getId(), $comment->id);
return t("Imported comment '%comment' for item with id: %id", array("id" => $comment->item_id, "comment" => text::limit_words(nl2br(p::purify($comment->text)), 50)));
}
示例12: defined
<?php
defined("SYSPATH") or die("No direct script access.");
?>
<ul>
<?php
foreach ($feed as $entry) {
?>
<li>
<a href="<?php
echo $entry["link"];
?>
"><?php
echo $entry["title"];
?>
</a>
<p>
<?php
echo text::limit_words(strip_tags($entry["description"]), 25);
?>
</p>
</li>
<?php
}
?>
</ul>
示例13:
echo url::base();
?>
/media/img/x_btn.png" alt="X" align="absmiddle" style="border:0" width="18" />
</a>
<?php
} else {
?>
<?php
}
?>
</DIV>
<?php
if (!empty($form[$cat . 'feed_url' . $i])) {
$tempfeedurl = text::limit_chars($form[$cat . 'feed_url' . $i], 40, '...', False);
$tempfeedurl = text::limit_words($tempfeedurl, 1, '...', True);
echo $tempfeedurl;
} else {
?>
<?php
print form::input($cat . 'feed_url' . $i, $form[$cat . 'feed_url' . $i], ' class="text long3" ');
?>
<!-- <?php
print form::checkbox($cat . 'weight' . $i, $form[$cat . 'weight' . $i], $form[$cat . 'weight' . $i] >= 100 ? TRUE : FALSE, ' class="check-box"');
?>
--> <?php
}
?>
<input type="hidden" name="<?php
echo $cat . "weight_hf" . $i;
示例14: render
public function render($options = null)
{
if (!$options) {
$config = Kohana::config_load('zest');
$options = $config['feedpost.full'];
}
$array = array("date_format" => 'D jS M Y', "image" => array(250, 250), "image_class" => "", "html" => '<h1>{TITLE}</h1><h2>{DATE}</h2><h3>by {AUTHOR}</h3>{IMAGE}{TEXT}<div class="spacer"> </div>', "template" => '', "word_limit" => 0);
$array = arr::overwrite($array, $options);
if (isset($array['template']) && $array['template'] != "") {
$html = zest::template_to_html('snippets/' . $array['template']);
} else {
$html = $array['html'];
}
$html = str_replace('{TITLE}', $this->title, $html);
$html = str_replace('{DATE}', date($array['date_format'], strtotime($this->date)), $html);
if ($this->media_id > 0) {
$html = str_replace('{IMAGE}', $this->media->render_cropped($array['image'][0], $array['image'][1], $array['image_class']), $html);
} else {
$html = str_replace('{IMAGE}', '', $html);
}
if (isset($array['word_limit']) && $array['word_limit'] > 0) {
$html = str_replace('{TEXT}', text::limit_words(strip_tags($this->text), $array['word_limit']), $html);
} else {
$html = str_replace('{TEXT}', $this->text, $html);
$html = str_replace('{ADD_THIS}', zest::add_this($this->get_url(), $this->title), $html);
}
$html = str_replace('{LINK}', $this->get_url(), $html);
$html = str_replace('{FEED_LINK}', $this->feed->get_url(), $html);
$html = str_replace('{FEED_TITLE}', $this->feed->title, $html);
$html = str_replace('{AUTHOR}', $this->user->username, $html);
if ($this->feed->has_comments()) {
$html = str_replace('{COMMENT_FORM}', $this->comment_form(), $html);
$comments = $this->get_comments();
$comments_html = "<a name='comments'></a>";
foreach ($comments as $c) {
$comments_html .= $c->render();
}
if ($comments_html == "") {
$comments_html = "<p>No comments have yet been posted. Be the first!</p>";
}
$html = str_replace('{COMMENTS}', $comments_html, $html);
$com_count = count($comments);
switch ($com_count) {
case 0:
$str = '0 comments';
break;
case 1:
$str = '1 comment';
break;
default:
$str = $com_count . ' comments';
break;
}
$html = str_replace('{COMMENT_COUNT}', $str, $html);
} else {
$html = str_replace('{COMMENT_FORM}', '', $html);
$html = str_replace('{COMMENTS}', '', $html);
$html = str_replace('{COMMENT_COUNT}', '', $html);
}
return $html;
}
示例15: snip
public function snip($id)
{
$db = Database::instance();
$id = mysql_real_escape_string($id);
$sql = 'SELECT `snip_id`, `user_id`, `language`, `snippet`, `title`, `date_added`, `private`, `description` FROM `snips` WHERE `snip_id` = ' . $id . ' LIMIT 0, 30 ';
$result = $db->query($sql);
if ($result and $result->count() > 0) {
foreach ($result as $row) {
$user_id = $row->user_id;
$language = $row->language;
$snippet = $row->snippet;
$title = $row->title;
$date_added = $row->date_added;
$private = $row->private;
$description = $row->description;
}
if ($private == '1') {
// Redirect if no one is logged in and tries to view private snippet
if (!is_object($this->user)) {
url::redirect('/home/login?loginRequired=1&return_to=home~snip~' . $id);
}
// Redirect User if they are not the owner of the snippet
if ($this->user->id != $user_id) {
url::redirect('/home/?forbiddenSnip=1¤tUser=' . $this->user->id . "&neededUser=" . $user_id);
}
}
$this->template->title = "Snip: " . text::limit_words($title, 7);
$this->template->template_head .= '
<script type="text/javascript" src="/files/syntax/scripts/shCore.js"></script>
<script type="text/javascript" src="/files/syntax/scripts/shBrushBash.js"></script>
<script type="text/javascript" src="/files/syntax/scripts/shBrushCpp.js"></script>
<script type="text/javascript" src="/files/syntax/scripts/shBrushCSharp.js"></script>
<script type="text/javascript" src="/files/syntax/scripts/shBrushCss.js"></script>
<script type="text/javascript" src="/files/syntax/scripts/shBrushDelphi.js"></script>
<script type="text/javascript" src="/files/syntax/scripts/shBrushDiff.js"></script>
<script type="text/javascript" src="/files/syntax/scripts/shBrushGroovy.js"></script>
<script type="text/javascript" src="/files/syntax/scripts/shBrushJava.js"></script>
<script type="text/javascript" src="/files/syntax/scripts/shBrushJScript.js"></script>
<script type="text/javascript" src="/files/syntax/scripts/shBrushPhp.js"></script>
<script type="text/javascript" src="/files/syntax/scripts/shBrushPlain.js"></script>
<script type="text/javascript" src="/files/syntax/scripts/shBrushPowerShell.js"></script>
<script type="text/javascript" src="/files/syntax/scripts/shBrushPython.js"></script>
<script type="text/javascript" src="/files/syntax/scripts/shBrushRuby.js"></script>
<script type="text/javascript" src="/files/syntax/scripts/shBrushScala.js"></script>
<script type="text/javascript" src="/files/syntax/scripts/shBrushSql.js"></script>
<script type="text/javascript" src="/files/syntax/scripts/shBrushVb.js"></script>
<script type="text/javascript" src="/files/syntax/scripts/shBrushXml.js"></script>
<link type="text/css" rel="stylesheet" href="/files/syntax/styles/shCore.css"/>
<link type="text/css" rel="stylesheet" href="/files/syntax/styles/shThemeDefault.css"/>
<script type="text/javascript">
SyntaxHighlighter.config.clipboardSwf = "/files/syntax/scripts/clipboard.swf";
SyntaxHighlighter.all();
jQuery(function($) {
$("#dialog").hide();
});
</script>';
$home_nav = new view('home_nav');
$home_nav->highlight = 'none';
$this->template->page_nav = $home_nav;
$result = $db->query("SELECT username FROM users WHERE id = " . $user_id . " LIMIT 0, 1");
foreach ($result as $row) {
$username = $row->username;
}
$content = View::factory('snip/snip');
if (is_object($this->user)) {
if ($this->user->id != $user_id) {
$is_logged_in = "0";
} else {
$is_logged_in = "1";
}
} else {
$is_logged_in = "0";
}
$snips_model = new Snip_Model();
$content->username = $username;
$content->snipID = $id;
$content->is_logged_in = $is_logged_in;
$content->user_id = $user_id;
$content->brush = $snips_model->lang_to_brush($language);
$content->language = $language;
$content->title = $title;
$content->snippet = $snippet;
$content->date_added = $date_added;
$content->private = $private;
$content->description = $description;
$this->template->page_content = $content;
} else {
throw new Kohana_404_Exception('home/snip/' . $id);
}
}