/** * 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; }
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); }
/** * 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); } }
/** * 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, ' ...'); }
<?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>
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>
</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 }
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 }
<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');
<?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/>
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');
/** * 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'])); }
<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>
"> <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');
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; }
">Zarządzaj obrazkami</a></li> <?php } ?> <li><a href="<?php echo Route::url('protected', array('controller' => 'image', 'action' => 'create', 'id' => $project->link)); ?> ">Dodaj obrazek</a></li> </ul> </div> </header> <div> <span>Opis:</span> <span><?php echo Text::limit_words(Html::chars(strip_tags($project->description)), 15); ?> </span> </div> </article> <?php } ?> <?php } else { ?> <article> <p>Brak projektów w tej kategorii</p> </article> <?php }
?> <h1 style="margin-bottom: 20px;">Новости автомира</h1> <div class="content_all"> <ul> <?php foreach ($news->order_by('date', 'DESC')->find_all() as $n) { ?> <li> <div class="title"><?php echo HTML::anchor($url . $n->id, $n->title); ?> </div> <div class="date"><?php echo MyDate::show($n->date); ?> </div> <div class="text"><?php echo Text::limit_words($n->text, 70); ?> </div> <div class="more"><?php echo HTML::anchor('news/world/' . $n->id, 'Подробнее'); ?> </div> </li> <?php } ?> </ul> </div>
<div class="header"> <div class="title"><?php echo HTML::anchor('services/' . $s->id, $s->name); ?> </div> <?php echo $service->get_words($s); ?> </div> <div class="body"> <div class="address"><?php echo $s->get_address(); ?> </div> <div class="text"> <?php echo Text::limit_words(strip_tags($s->about), 40); ?> <?php echo HTML::anchor('services/' . $s->id, 'Подробнее'); ?> </div> </div> </div> <?php } } elseif (isset($service) and $service === FALSE or isset($service_count) and $service_count < 1) { ?> <p style="font-size: 20px; color: #8d8d8d; margin: 10px 0 0;">Найдено автосервисов 0</p> <?php }
<th>Текст</th> <th style="width: 110px;">Дата ред.</th> <th style="width: 45px;"></th> </tr> </thead> <tbody> <?php foreach ($content->find_all() as $c) { ?> <tr> <td style="width: 300px;">Округ <?php echo $c->district->name . ' г.' . $c->district->city->genitive_name; ?> </td> <td><?php echo mb_strlen($c->text) > 0 ? Text::limit_words(strip_tags($c->text), 30) : 'Текст отсутствует'; ?> </td> <td><?php echo $c->date_edited != '0000-00-00 00:00:00' ? MyDate::show($c->date_edited, TRUE) : 'ни разу'; ?> </td> <td><?php echo HTML::edit_button($c->id, 'admin/content/district'); ?> </td> </tr> <?php } ?> </tbody>
?> </div> <div class="date"><?php echo Date::full_date($n->date); ?> </div> </div> <div class="body"> <div class="address"><?php echo $n->service->get_address(); ?> </div> <noindex> <div class="text"> <?php echo Text::limit_words(strip_tags($n->text), 30); ?> <?php echo HTML::anchor('services/' . $n->service->id . '/vacancies/' . $n->id, 'Подробнее'); ?> </div> </noindex> </div> </div> <?php } } else { ?> Вакансий нет. Пока что. <?php }
<h2>Новости</h2> <?php foreach ($news as $news_item) { ?> <div class="news"> <h3><?php echo $news_item->news_title; ?> </h3> <p><?php echo $news_item->news_date; ?> - <?php echo Text::limit_words($news_item->news_text, 18); ?> </p> <a href="<?php echo URL::base(); ?> news/get_news/<?php echo $news_item->id; ?> ">Читать далее</a> <div class="clear"></div> </div> <?php } ?>
foreach ($articles->where('active', '=', 1)->order_by('date_create', 'DESC')->limit(5)->find_all() as $article) { ?> <div class="content"> <div class="title"> <div class="company"><?php echo HTML::anchor('articles/' . $article->id, Text::limit_chars(strip_tags($article->title), 28)); ?> </div> <div class="date"><?php echo Date::full_date($article->date_create, FALSE); ?> </div> </div> <div class="text"> <?php echo Text::limit_words(strip_tags($article->text), 10) . ' ' . HTML::anchor('articles/' . $article->id, 'Подробнее'); ?> </div> </div> <?php } ?> <div class="buttons"> <?php echo HTML::anchor('articles', '<span>Все статьи</span>', array('class' => 'open-other-contents', 'rel' => 'nofollow')); ?> </div> </div> </div> <?php
?> .html"> <?php if (isset($item['meh-shuby'][0])) { ?> Шуба из <?php echo Text::getSuffix(Arr::get($item['meh-shuby'][0], 'value')); ?> <?php } ?> </a> <p> <small> <?php echo Text::limit_words(Arr::get($item, 'description'), 5); ?> </small> </p> <?php if (isset($item['material'][0])) { ?> <?php if (isset($item['type'][0])) { ?> <?php echo Arr::get($item['type'][0], 'value'); ?> из <?php }
?> </h2> <?php foreach ($comments as $comment) { ?> <div> <h2>To <?php echo HTML::anchor($comment->parent->load()->permalink, $comment->parent->title); ?> </h2> <p> <strong>Name : </strong> <?php echo $comment->name; ?> <br /> <strong>Date : </strong> <?php echo $comment->verbose('date'); ?> <br /> </p> <p><?php echo strip_tags(Text::limit_words($comment->text, 15, '...')); ?> </p> </div> <?php } ?>
public function action_event() { header('Content-type: application/json'); $id = Arr::get($_POST, 'id', 0); $language = Arr::get($_POST, 'language'); $event = ORM::factory('Chronology_Line', $id); if (!$event->loaded()) { throw new HTTP_Exception_404('Not Found'); } $image = 0; if (isset($event->picture->file_path)) { $image = URL::media('/images/w300-cct-si/' . $event->picture->file_path, TRUE); } switch ($language) { case 'ru': $text = Text::limit_words($event->text_ru, 30); $data = array('id' => $event->id, 'title' => $event->title_ru, 'description' => $event->description_ru, 'text' => $text, 'date' => $event->date_ru, 'image' => $image); break; case 'kz': $text = Text::limit_words($event->text_kz, 30); $data = array('id' => $event->id, 'title' => $event->title_kz, 'description' => $event->description_kz, 'text' => $text, 'date' => $event->date_kz, 'image' => $image); break; case 'en': $text = Text::limit_words($event->text_en, 30); $data = array('id' => $event->id, 'title' => $event->title_en, 'description' => $event->description_en, 'text' => $text, 'date' => $event->date_en, 'image' => $image); break; } $this->response->body(json_encode($data)); }
</thead> <tbody> <?php foreach ($stock->order_by('date', 'DESC')->find_all() as $s) { ?> <tr> <td><?php echo $s->service->name; ?> </td> <td><?php echo MyDate::show($s->date, TRUE); ?> </td> <td><?php echo Text::limit_words(strip_tags($s->text), 7); ?> </td> <td><?php echo HTML::activate_checker($s->id, $s->active, 'admin/service/stock'); ?> </td> <td><?php echo HTML::edit_button($s->id, 'admin/service/stock') . HTML::delete_button($s->id, 'admin/service/stock'); ?> </td> </tr> <?php } ?> </tbody>
echo Arr::get($item, 'name'); ?> </a> <p> <small class="text-muted"> Артикул: <?php echo Arr::get($item, 'art'); ?> </small> </p> <?php if (isset($item['type'][0])) { ?> <p> Тип: <?php echo Text::limit_words($item['type'][0]['value'], 20); ?> </p> <?php } ?> </div> <div class="col-sm-3 col-lg-2"> <div class="rateit"></div> <p class="catalog-price"> <?php echo number_format(Arr::get($item, 'price'), 0, '', ' '); ?> руб. </p>
<div class="thumbnail"> <a href="/news/<?php echo $data[0]['url']; ?> .html"> <img src="<?php echo Route::url('miniimg3', array('filename' => $data[0]['photos'][0]['value'])); ?> " alt="<?php echo $data[0]['name']; ?> "> </a> <div class="caption"> <h2><?php echo $data[0]['name']; ?> </h2> <p><?php echo Text::limit_words($data[0]['name'], 20); ?> </p> <p><a href="/news/<?php echo $data[0]['url']; ?> .html" class="btn btn-primary" role="button">Подробнее</a></p> </div> </div> </div> <?php }
/** * * @test * @dataProvider provider_limit_words */ function test_limit_words($expected, $str, $limit, $end_char) { $this->assertSame($expected, Text::limit_words($str, $limit, $end_char)); }
public function fetch_headline_value($value, $document_id) { return Text::limit_words($value, 50); }