当前位置: 首页>>代码示例>>PHP>>正文


PHP Text::limit_words方法代码示例

本文整理汇总了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;
 }
开发者ID:MenZil-Team,项目名称:cms,代码行数:43,代码来源:comment.php

示例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);
 }
开发者ID:kerkness,项目名称:shindig,代码行数:12,代码来源:post.php

示例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);
     }
 }
开发者ID:vimofthevine,项目名称:kohana-blog,代码行数:30,代码来源:article.php

示例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, ' ...');
 }
开发者ID:MenZil-Team,项目名称:cms,代码行数:21,代码来源:post.php

示例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>
开发者ID:chernogolov,项目名称:blank,代码行数:31,代码来源:w_catalog_articles_mini.php

示例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>

开发者ID:Alexander711,项目名称:naav1,代码行数:29,代码来源:result.php

示例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 
}
开发者ID:Alexander711,项目名称:naav1,代码行数:31,代码来源:dashboard.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 
}
开发者ID:abdul-baten,项目名称:hbcms,代码行数:31,代码来源:index.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');
开发者ID:Alexander711,项目名称:naav1,代码行数:31,代码来源:search.php

示例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/>
开发者ID:ChangLeoplod,项目名称:kohana-demo,代码行数:29,代码来源:text.php

示例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');
开发者ID:chernogolov,项目名称:blank,代码行数:31,代码来源:w_search.php

示例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']));
 }
开发者ID:hbarroso,项目名称:Goworkat,代码行数:33,代码来源:ads.php

示例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>
开发者ID:Alexander711,项目名称:naav1,代码行数:31,代码来源:system_all.php

示例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');
开发者ID:chernogolov,项目名称:blank,代码行数:31,代码来源:admMaterials.php

示例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;
 }
开发者ID:chernogolov,项目名称:blank,代码行数:62,代码来源:Twig.php


注:本文中的Text::limit_words方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。