本文整理汇总了PHP中Text::limit_words方法的典型用法代码示例。如果您正苦于以下问题:PHP Text::limit_words方法的具体用法?PHP Text::limit_words怎么用?PHP Text::limit_words使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Text
的用法示例。
在下文中一共展示了Text::limit_words方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* Updates or Creates the record depending on loaded()
*
* @param Validation $validation Validation object
* @return ORM
*
* @uses User::active_user
* @uses ACL::check
* @uses Text::limit_words
* @uses Text::markup
* @uses Request::$client_ip
*/
public function save(Validation $validation = NULL)
{
// Set some defaults
$this->updated = time();
$this->format = empty($this->format) ? Kohana::$config->load('inputfilter.default_format', 1) : $this->format;
$this->author = empty($this->author) ? User::active_user()->id : $this->author;
if (!$this->loaded()) {
// New comment
$this->created = $this->updated;
$this->hostname = substr(Request::$client_ip, 0, 32);
//set hostname only if its new comment.
if (empty($this->status)) {
$this->status = ACL::check('skip comment approval') ? 'publish' : 'draft';
}
}
// Validate the comment's title. If not specified, extract from comment body.
if (trim($this->title) == '' and !empty($this->body)) {
// The body may be in any format, so:
// 1) Filter it into HTML
// 2) Strip out all HTML tags
// 3) Convert entities back to plain-text.
$this->title = Text::limit_words(trim(UTF8::clean(strip_tags(Text::markup($this->body, $this->format)))), 10, '');
// Edge cases where the comment body is populated only by HTML tags will
// require a default subject.
if ($this->title == '') {
$this->title = __('(No subject)');
}
}
parent::save($validation);
return $this;
}
示例2: __get
public function __get($field)
{
if ($field === 'post_excerpt') {
if (!parent::__get('post_excerpt')) {
return Text::limit_words(parent::__get('post_content'), 50, ' ...');
}
}
if ($field === 'link') {
return Route::get('public/blog')->uri(array('slug' => $this->slug));
}
return parent::__get($field);
}
示例3: __get
/**
* Overload Sprig::__get() to get
* - permalink URLs
* - associated category URL
* - tag list (with URLs)
* - article excerpt
*/
public function __get($name)
{
if ($name == 'permalink') {
$date = date('Y/n/j', $this->date);
return Route::get('blog/permalink')->uri(array('date' => $date, 'slug' => $this->slug));
} elseif ($name == 'category_link') {
return Route::get('blog/filter')->uri(array('action' => 'category', 'name' => $this->category->load()->name));
} elseif ($name == 'tag_list') {
$return = '';
foreach ($this->tags as $tag) {
$return .= HTML::anchor(Route::get('blog/filter')->uri(array('action' => 'tag', 'name' => $tag->name)), ucfirst($tag->name));
}
return $return;
} elseif ($name == 'excerpt') {
$text = $this->text;
if (strpos($text, '<p>') !== FALSE) {
$text = substr($text, strpos($text, '<p>'));
}
return strip_tags(Text::limit_words($text, 100, '...'));
} else {
return parent::__get($name);
}
}
示例4: _teaser
/**
* Get teaser from the body either by delimiter or size
*
* @param integer $size Defaults to 105 words [Optional]
* @return string Teaser
* @uses Text::limit_words
*/
protected function _teaser($size = 105)
{
// Find where the delimiter is in the body
$delimiter = strpos($this->rawbody, self::TEASER_TAG);
// If the size is zero, and there is no delimiter, the entire body is teaser.
if ($size == 0 and $delimiter === FALSE) {
return $this->rawbody;
}
// If a valid delimiter has been specified, use it to chop off the teaser.
if ($delimiter !== FALSE) {
return substr($this->rawbody, 0, $delimiter);
}
return Text::limit_words($this->rawbody, $size, ' ...');
}
示例5: foreach
<?php
if (isset($data)) {
?>
<h2 class="text-right">Полезная информация</h2>
<div class="list-group">
<?php
foreach ($data as $item) {
?>
<a href="/<?php
echo $item['node'];
?>
/<?php
echo $item['url'];
?>
.html" class="list-group-item" title="<?php
echo $item['name'];
?>
"><?php
echo Text::limit_words($item['name'], 20);
?>
</a>
<?php
}
?>
</div>
<?php
}
?>
</div>
</div>
</div>
示例6: foreach
foreach ($vacancies as $v) {
?>
<div class="content-group">
<div class="header with-date">
<div class="title"><?php
echo HTML::anchor(Model_Service::$type_urls[$v->service->type] . '/' . $v->service->id . '/vacancies/' . $v->id, $v->title);
?>
</div>
<div class="date"><?php
echo Date::full_date($v->date);
?>
</div>
</div>
<div class="body">
<div class="text">
<?php
echo Text::limit_words(strip_tags($v->text), 100);
?>
<?php
echo HTML::anchor(Model_Service::$type_urls[$v->service->type] . '/' . $v->service->id . '/vacancies/' . $v->id, 'Подробнее');
?>
</div>
</div>
</div>
<?php
}
?>
</div>
示例7:
</div>
<div class="right">
<?php
echo HTML::anchor('cabinet/vacancy/edit/' . $v->id, HTML::image('assets/img/icons/pencil.png')) . HTML::anchor('cabinet/vacancy/delete/' . $v->id, HTML::image('assets/img/icons/del.png'));
?>
</div>
</div>
<div style="clear: both;">
<?php
echo HTML::anchor('vacancies/' . $v->id, $v->title);
?>
</div>
<div style="clear: both;">
<?php
echo Text::limit_words($v->text, 50);
?>
</div>
</li>
<?php
}
?>
</ul>
<?php
} else {
?>
<?php
echo __('s_havent_vacancies');
?>
<?php
}
示例8: date
echo date("d.m.Y h:i", strtotime($truyen['created_at']));
?>
,
Cười: <strong><?php
echo $truyen['cuoi'];
?>
</strong>,
Đọc: <strong><?php
echo $truyen['hits'];
?>
</strong>
</em>
</div>
<div style="border-top:1px dotted #ccc;padding:5px 0 0 0; color: #3E2E17">
<?php
echo Text::limit_words(strip_tags($truyen['content']), 50, '...');
?>
</div>
<div style="border-top:1px dotted #ccc;padding:5px 0 0 0; color: #3E2E17">
<a href="<?php
echo url::site('truyen-cuoi/' . $truyen['id'] . '-' . $truyen['slug']);
?>
">Đọc ngay ;0)</a>
</div>
</li>
<?php
}
?>
</ul>
<?php
}
示例9: count
<p style="font-size: 20px; color: #8d8d8d; margin: 10px 10px 0;">Найдено автосервисов <?php
echo count($service->find_all());
?>
</p>
<div class="search_services_all">
<ul>
<?php
foreach ($service->find_all() as $s) {
?>
<li>
<div class="name"><?php
echo $s->name;
?>
</div>
<div class="about"><?php
echo Text::limit_words($s->about, 40);
?>
</div>
<div class="more"><?php
echo HTML::anchor('services/' . $s->id, 'Подробнее');
?>
</div>
</li>
<?php
}
?>
</ul>
</div>
<?php
}
echo View::factory('profiler/stats');
示例10:
<?php
echo Text::limit_words('This is my really cool and super awesome string.', 4, '...');
?>
<br/>
<?php
echo Text::limit_chars('This is my really cool and super awesome string.', 15, '...');
?>
<br/>
<?php
echo Text::alternate('You are cool', 'You are smart', 'You are funny');
?>
<br/>
<?php
echo Text::alternate('You are nice', 'You are happy', 'You are stinky');
?>
<br/>
<?php
echo Text::alternate('You are ugly', 'You are sleepy', 'You are bored');
?>
<br/>
示例11:
echo Text::getSuffix(Arr::get($item['material'][0], 'value'));
?>
<?php
}
?>
<p><?php
echo Arr::get($item, 'description');
?>
</p>
</div>
<p><?php
echo Text::limit_words(strip_tags(Arr::get($item, 'text')), 15);
?>
</p>
<p><?php
echo Text::limit_words(strip_tags(Arr::get($item, 'entry')), 15);
?>
</p>
</div>
<hr>
<?php
}
?>
<?php
}
?>
<?php
} else {
?>
По вашему запросу "<?php
echo Arr::get($_GET, 'string');
示例12: action_view
/**
* Shows an add
*/
public function action_view($url = null)
{
// Regex the url and get the ID
if (!$url || !preg_match("/-(\\d*)\$/i", $url, $matches)) {
throw new HTTP_Exception_404('Job not found', array('page' => $url));
}
// Is numeric ?
if (!is_numeric($matches[1])) {
throw new HTTP_Exception_404('Job not found', array('page' => $url));
}
// Creates ORM Object
$ad = ORM::factory('ad', $matches[1]);
// Makes sure the date is still new and the ad is set to active = 1
if (!$ad->id || !$ad->active == 1) {
throw new HTTP_Exception_404('Job not found', array('page' => $url));
}
// Parse URL's into A tags
$ad->description = Helper_Utils::link_url($ad->description);
// Get similiar jobs if any using cookie saved variables
$similiar_ads = $this->search(array('limit' => 5, 'random_order' => true, 'search_string' => arr::get(null, 'search_string', Cookie::get('search_string')), 'jobtype_id' => arr::get(null, 'jobtype_id', $ad->jobtype_id), 'telecommute' => arr::get(null, 'telecommute', $ad->telecommute)));
// If no ads were found in the previously query do a default one using just
// the job type
if (count($similiar_ads['ads']) === 0) {
$similiar_ads = $this->search(array('limit' => 5, 'random_order' => true, 'jobtype_id' => arr::get(null, 'jobtype_id', $ad->jobtype_id)));
}
// show ad
$this->template->title = __($ad->title);
$this->template->description = Text::limit_words(strip_tags($ad->description), 80);
$this->template->content = View::factory('ads/ad', array('ad' => $ad, 'config' => $this->config, 'similiar_ads' => $similiar_ads['ads']));
}
示例13: foreach
<table class="table table-bordered table-striped">
<thead>
<tr>
<th style="width: 350px;">Описание уведомления (не меняется)</th>
<th>Текст</th>
<th style="width: 36px;"></th>
</tr>
</thead>
<tbody>
<?php
foreach ($notice->order_by('date', 'DESC')->find_all() as $c) {
?>
<tr>
<td><?php
echo $c->description;
?>
</td>
<td><?php
echo Text::limit_words(strip_tags($c->text), 120);
?>
</td>
<td><?php
echo HTML::edit_button($c->id, 'admin/notice/edit_system', TRUE);
?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
示例14: foreach
">
<span class="glyphicon glyphicon-arrow-down"></span>
</a>
<?php
}
?>
</th>
<?php
if (isset($data['admfields'])) {
?>
<?php
foreach ($data['admfields'] as $field) {
?>
<th>
<?php
echo Text::limit_words($field['title'], 2);
?>
</th>
<?php
}
?>
<?php
}
?>
<th class="mat_public">
<span class="glyphicon glyphicon-eye-open" title="Количество просмотров"></span>
<?php
if (isset($_GET['sort']) && $_GET['sort'] == 'views_DESC') {
?>
<a href="<?php
echo Request::getUrl('sort', 'views_ASC');
示例15: modify_fields
public function modify_fields($gid, $item, $config)
{
$materials = new Model_Material("groups");
$fields = $materials->getFieldsSet($gid);
// Атрибуты каталога
$finish_fields = array();
// Перебор атрибутов
foreach ($fields as $field) {
$field_name = $field["name"];
$field_model = array("name" => $field_name, "title" => $field["title"]);
if ($field["type"] == "select") {
if (isset($item[$field_name])) {
$field_model["value"] = $item[$field_name][0]["value"];
if (isset($config[$field_name]["modify"])) {
$field_model = $config[$field_name]["modify"]($field_model);
}
}
}
/*if ($field["type"] == "photoalbum") {
if (isset($item[$field_name])) {
$field_model["value"] = $item[$field_name][0]["value"];
if (isset($config[$field_name]["modify"])) {
$field_model = $config[$field_name]["modify"]($field_model);
}
}
}*/
if ($field["type"] == "price") {
if (isset($item[$field_name])) {
$field_model["value"] = number_format($item[$field_name], 0, "", " ");
if (isset($config[$field_name]["modify"])) {
$field_model = $config[$field_name]["modify"]($field_model);
}
}
}
if ($field["type"] == "chars") {
if (isset($item[$field_name])) {
$field_model["value"] = Text::limit_words($item[$field_name], 40);
if (isset($config[$field_name]["modify"])) {
$field_model = $config[$field_name]["modify"]($field_model);
}
}
}
$field_visible = true;
if (isset($config[$field_name])) {
if (isset($config[$field_name]["visible"])) {
if (!$config[$field_name]["visible"]) {
$field_visible = false;
}
}
}
// Отображать поле?
if ($field_visible) {
$finish_fields[$field_name] = $field_model;
}
}
return $finish_fields;
}