本文整理汇总了PHP中text::limit_chars方法的典型用法代码示例。如果您正苦于以下问题:PHP text::limit_chars方法的具体用法?PHP text::limit_chars怎么用?PHP text::limit_chars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类text
的用法示例。
在下文中一共展示了text::limit_chars方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: keywords
public static function keywords($str, $limit_chars = 255)
{
$clean_str = preg_replace('/[^\\p{L}\\p{M}\\p{Z}\\p{S}\\p{N}\\p{C}\\s]{1,}/', '', $str);
$clean_str = trim(preg_replace('/\\s{2,}/', ' ', $clean_str));
$words = explode(' ', $clean_str);
foreach ($words as $key => $word) {
if (in_array($word, self::$stop_words) === TRUE || in_array(mb_strtolower($word), self::$stop_words)) {
unset($words[$key]);
}
}
// Limit to 255 characters total and preserve words
$clean_str = text::limit_chars(implode(', ', $words), $limit_chars, '', TRUE);
// Get rid of any trailing comma that may have been left behind from text::limit_chars
$clean_str = preg_replace('/,$/', '', $clean_str);
// Remove the extra spaces introduced on explode above and return the cleaned string
return str_replace(' ', '', $clean_str);
}
示例2: database
/**
* Benchmark times and memory usage from the Benchmark library.
*
* @return void
*/
public function database()
{
$queries = Postgres_Lite::$benchmarks;
$total_time = $total_rows = 0;
$table = array();
$table[] = array('SQL Statement', 'Time', 'Rows');
foreach ($queries as $query) {
if (mb_strlen($query['query']) < 2048) {
$table[] = array(str_replace("\n", ' ', $query['query']), number_format($query['time'], 3), $query['rows']);
$total_time += $query['time'];
$total_rows += $query['rows'];
} else {
$table[] = array(str_replace("\n", ' ', text::limit_chars($query['query'], 2036, ' [TRUNCATED]')), number_format($query['time'], 3), $query['rows']);
$total_time += $query['time'];
$total_rows += $query['rows'];
}
}
$this->fb(array(count($queries) . ' SQL queries took ' . number_format($total_time, 3) . ' seconds and returned ' . $total_rows . ' rows', $table), FirePHP::TABLE);
}
示例3: foreach
if ($total_items == 0) {
?>
<tr>
<td colspan="4" class="col">
<h3><?php
echo Kohana::lang('ui_main.no_results');
?>
</h3>
</td>
</tr>
<?php
}
foreach ($incidents as $incident) {
$incident_id = $incident->id;
$incident_title = strip_tags($incident->incident_title);
$incident_description = text::limit_chars(strip_tags($incident->incident_description), 150, "...", true);
$incident_date = $incident->incident_date;
$incident_date = date('Y-m-d', strtotime($incident->incident_date));
$incident_mode = $incident->incident_mode;
// Mode of submission... WEB/SMS/EMAIL?
//XXX incident_Mode will be discontinued in favour of $service_id
if ($incident_mode == 1) {
$submit_mode = "WEB";
// Who submitted the report?
if ($incident->incident_person->id) {
// Report was submitted by a visitor
$submit_by = $incident->incident_person->person_first . " " . $incident->incident_person->person_last;
} else {
if ($incident->user_id) {
$submit_by = $incident->user->name;
} else {
示例4: foreach
<a href="#filter" data-filter=".Dec">Dec</a> -->
</span>
</p>
<div class="polaroids">
<?php
if ($total_items == 0) {
?>
<p><?php
echo Kohana::lang('ui_main.no_reports');
?>
</p>
<?php
}
foreach ($incidents as $incident) {
$incident_id = $incident->id;
$incident_title = text::limit_chars($incident->incident_title, 20, '...', False);
$incident_date = $incident->incident_date;
$incident_date = date('l j F Y', strtotime($incident->incident_date));
$incident_month = date('M', strtotime($incident->incident_date));
$incident_location = $incident->location->location_name;
$incident_lat = $incident->location->latitude;
$incident_lon = $incident->location->longitude;
$incident_category = $incident->incident_category;
?>
<?php
$isotope_js_filters = $incident_month;
foreach ($incident_category as $category) {
// don't show hidden categoies
if ($category->category->category_visible == 0) {
continue;
示例5: foreach
</div>
<?php
if ($reports_total == 0) {
?>
<div class="post">
<h3><?php
echo Kohana::lang('ui_main.no_results');
?>
</h3>
</div>
<?php
}
foreach ($incidents as $incident) {
$incident_id = $incident->id;
$incident_title = $incident->incident_title;
$incident_description = text::limit_chars($incident->incident_description, 150, '...');
$incident_date = $incident->incident_date;
$incident_date = date('g:i A', strtotime($incident->incident_date));
$incident_mode = $incident->incident_mode;
// Mode of submission... WEB/SMS/EMAIL?
if ($incident_mode == 1) {
$submit_mode = "mail";
} elseif ($incident_mode == 2) {
$submit_mode = "sms";
} elseif ($incident_mode == 3) {
$submit_mode = "mail";
} elseif ($incident_mode == 4) {
$submit_mode = "twitter";
}
// Incident Status
$incident_approved = $incident->incident_active;
示例6: foreach
<tr>
<td colspan="4" class="col">
<h3><?php
echo Kohana::lang('ui_main.no_results');
?>
</h3>
</td>
</tr>
<?php
}
foreach ($pages as $page) {
$page_id = $page->id;
$page_title = $page->page_title;
$page_tab = $page->page_tab;
$page_description = $page->page_description;
$page_description_short = strip_tags(text::limit_chars($page_description, "100", "..."));
$page_active = $page->page_active;
?>
<tr>
<td class="col-1"> </td>
<td class="col-2">
<div class="post">
<h4><?php
echo $page_title;
?>
</h4>
<p><?php
echo $page_description_short;
?>
</p>
</div>
示例7: foreach
// Incident Status
$incident_approved = $incident->incident_active;
$incident_verified = $incident->incident_verified;
// Get Edit Log
$edit_count = $incident_orm->verify->count();
$edit_css = $edit_count == 0 ? "post-edit-log-gray" : "post-edit-log-blue";
$edit_log = "<div class=\"" . $edit_css . "\">" . "<a href=\"javascript:showLog('edit_log_" . $incident_id . "')\">" . Kohana::lang('ui_admin.edit_log') . ":</a> (" . $edit_count . ")</div>" . "<div id=\"edit_log_" . $incident_id . "\" class=\"post-edit-log\"><ul>";
foreach ($incident_orm->verify as $verify) {
$edit_log .= "<li>" . Kohana::lang('ui_admin.edited_by') . " " . $verify->user->name . " : " . $verify->verified_date . "</li>";
}
$edit_log .= "</ul></div>";
// Get Any Translations
$i = 1;
$incident_translation = "<div class=\"post-trans-new\">" . "<a href=\"" . url::base() . 'admin/reports/translate/?iid=' . $incident_id . "\">" . strtoupper(Kohana::lang('ui_main.add_translation')) . ":</a></div>";
foreach ($incident_orm->incident_lang as $translation) {
$incident_translation .= "<div class=\"post-trans\">" . Kohana::lang('ui_main.translation') . $i . ": " . "<a href=\"" . url::base() . 'admin/reports/translate/' . $translation->id . '/?iid=' . $incident_id . "\">" . text::limit_chars($translation->incident_title, 150, "...", TRUE) . "</a>" . "</div>";
}
?>
<tr>
<td class="col-1">
<input name="incident_id[]" id="incident" value="<?php
echo $incident_id;
?>
" type="checkbox" class="check-box"/>
</td>
<td class="col-2">
<div class="post">
<h4>
<a href="<?php
echo url::site() . 'admin/reports/edit/' . $incident_id;
?>
示例8: nl2br
">
<?php
echo $item->thumb_img(array("class" => "g-thumbnail"));
?>
<p>
<span class="<?php
echo $item_class;
?>
"></span>
<?php
echo html::purify(text::limit_chars($item->title, 32, "…"));
?>
</p>
<div>
<?php
echo nl2br(html::purify(text::limit_chars($item->description, 64, "…")));
?>
</div>
</a>
</li>
<?php
}
?>
</ul>
<?php
echo $theme->paginator();
?>
<?php
} else {
?>
示例9: t
<?php
} else {
?>
<?php
if ($theme->tag()) {
?>
<?php
echo t("Photos tagged with %tag_title", array("tag_title" => $theme->tag()->name));
?>
<?php
} else {
/* Not an item, not a tag, no page_title specified. Help! */
?>
<?php
echo html::purify(text::limit_chars(item::root()->title, 40));
?>
<?php
}
?>
<?php
}
?>
</div>
<?php
}
?>
<div class="rNavBar">
<button class="ui-button ui-button-text-only ui-widget ui-state-default ui-corner-all" onclick="$('#g-header').slideToggle('normal', function(){$('#g-header').is(':hidden') ? $('#sidebarButton').text('Show Options') : $('#sidebarButton').text('Hide Options')});"> <span class="ui-button-text">Show Options</span> </button>
</div>
示例10: foreach
<h3><?php
echo Kohana::lang('ui_main.no_results');
?>
</h3>
</td>
</tr>
<?php
}
foreach ($checkins as $checkin) {
$checkin_id = $checkin->id;
$incident_id = $checkin->incident_id;
$location = $checkin->location->location_name;
$latitude = $checkin->location->latitude;
$longitude = $checkin->location->longitude;
$description = $checkin->checkin_description;
$preview = text::limit_chars(strip_tags($description), 150, "...", true);
$checkin_date = date('Y-m-d h:i', strtotime($checkin->checkin_date));
$auto_checkin = $checkin->checkin_auto ? "YES" : "NO";
?>
<tr>
<td class="col-1"><input name="checkin_id[]" id="checkin" value="<?php
echo $checkin_id;
?>
" type="checkbox" class="check-box"/></td>
<td class="col-2">
<div class="post">
<p><?php
echo $preview;
?>
</p>
<p><a href="javascript:showCheckin('checkin_preview_<?php
示例11: edit
/**
* Edit a report
* @param bool|int $id The id no. of the report
* @param bool|string $saved
*/
public function edit($id = FALSE, $saved = FALSE)
{
$db = new Database();
$this->template->content = new View('members/reports_edit');
$this->template->content->title = Kohana::lang('ui_admin.create_report');
// setup and initialize form field names
$form = array('location_id' => '', 'form_id' => '', 'locale' => '', 'incident_title' => '', 'incident_description' => '', 'incident_date' => '', 'incident_hour' => '', 'incident_minute' => '', 'incident_ampm' => '', 'latitude' => '', 'longitude' => '', 'geometry' => array(), 'location_name' => '', 'country_id' => '', 'country_name' => '', 'incident_category' => array(), 'incident_news' => array(), 'incident_video' => array(), 'incident_photo' => array(), 'person_first' => '', 'person_last' => '', 'person_email' => '', 'custom_field' => array(), 'incident_zoom' => '', 'incident_source' => '', 'incident_information' => '');
// copy the form as errors, so the errors will be stored with keys corresponding to the form field names
$errors = $form;
$form_error = FALSE;
$form_saved = $saved == 'saved';
// Initialize Default Values
$form['locale'] = Kohana::config('locale.language');
//$form['latitude'] = Kohana::config('settings.default_lat');
//$form['longitude'] = Kohana::config('settings.default_lon');
$form['country_id'] = Kohana::config('settings.default_country');
$form['incident_date'] = date("m/d/Y", time());
$form['incident_hour'] = date('h');
$form['incident_minute'] = date('i');
$form['incident_ampm'] = date('a');
// initialize custom field array
$form['custom_field'] = customforms::get_custom_form_fields($id, '', TRUE);
// Locale (Language) Array
$this->template->content->locale_array = Kohana::config('locale.all_languages');
// Create Categories
$this->template->content->categories = Category_Model::get_categories();
// Time formatting
$this->template->content->hour_array = $this->_hour_array();
$this->template->content->minute_array = $this->_minute_array();
$this->template->content->ampm_array = $this->_ampm_array();
$this->template->content->stroke_width_array = $this->_stroke_width_array();
// Get Countries
$countries = array();
foreach (ORM::factory('country')->orderby('country')->find_all() as $country) {
// Create a list of all categories
$this_country = $country->country;
if (strlen($this_country) > 35) {
$this_country = substr($this_country, 0, 35) . "...";
}
$countries[$country->id] = $this_country;
}
$this->template->content->countries = $countries;
// Initialize Default Value for Hidden Field Country Name, just incase Reverse Geo coding yields no result
$form['country_name'] = $countries[$form['country_id']];
//GET custom forms
$forms = array();
foreach (ORM::factory('form')->where('form_active', 1)->find_all() as $custom_forms) {
$forms[$custom_forms->id] = $custom_forms->form_title;
}
$this->template->content->forms = $forms;
// Retrieve thumbnail photos (if edit);
//XXX: fix _get_thumbnails
$this->template->content->incident = $this->_get_thumbnails($id);
// Are we creating this report from a Checkin?
if (isset($_GET['cid']) and !empty($_GET['cid'])) {
$checkin_id = (int) $_GET['cid'];
$checkin = ORM::factory('checkin', $checkin_id);
if ($checkin->loaded) {
// Has a report already been created for this Checkin?
if ((int) $checkin->incident_id > 0) {
// Redirect to report
url::redirect('members/reports/edit/' . $checkin->incident_id);
}
$incident_description = $checkin->checkin_description;
$incident_title = text::limit_chars(strip_tags($incident_description), 100, "...", true);
$form['incident_title'] = $incident_title;
$form['incident_description'] = $incident_description;
$form['incident_date'] = date('m/d/Y', strtotime($checkin->checkin_date));
$form['incident_hour'] = date('h', strtotime($checkin->checkin_date));
$form['incident_minute'] = date('i', strtotime($checkin->checkin_date));
$form['incident_ampm'] = date('a', strtotime($checkin->checkin_date));
// Does the sender of this message have a location?
if ($checkin->location->loaded) {
$form['location_id'] = $checkin->location_id;
$form['latitude'] = $checkin->location->latitude;
$form['longitude'] = $checkin->location->longitude;
$form['location_name'] = $checkin->location->location_name;
}
}
}
// check, has the form been submitted, if so, setup validation
if ($_POST) {
// Instantiate Validation, use $post, so we don't overwrite $_POST fields with our own things
$post = array_merge($_POST, $_FILES);
if (reports::validate($post)) {
// STEP 1: SAVE LOCATION
$location = new Location_Model();
reports::save_location($post, $location);
// STEP 2: SAVE INCIDENT
$incident = new Incident_Model();
reports::save_report($post, $incident, $location->id);
// STEP 2b: SAVE INCIDENT GEOMETRIES
reports::save_report_geometry($post, $incident);
// STEP 3: SAVE CATEGORIES
reports::save_category($post, $incident);
//.........这里部分代码省略.........
示例12: edit
/**
* Edit a report
* @param bool|int $id The id no. of the report
* @param bool|string $saved
*/
function edit($id = false, $saved = false)
{
$db = new Database();
$this->template->content = new View('members/reports_edit');
$this->template->content->title = Kohana::lang('ui_admin.create_report');
// setup and initialize form field names
$form = array('location_id' => '', 'form_id' => '', 'locale' => '', 'incident_title' => '', 'incident_description' => '', 'incident_date' => '', 'incident_hour' => '', 'incident_minute' => '', 'incident_ampm' => '', 'latitude' => '', 'longitude' => '', 'geometry' => array(), 'location_name' => '', 'country_id' => '', 'incident_category' => array(), 'incident_news' => array(), 'incident_video' => array(), 'incident_photo' => array(), 'person_first' => '', 'person_last' => '', 'person_email' => '', 'custom_field' => array(), 'incident_source' => '', 'incident_information' => '', 'incident_zoom' => '');
// copy the form as errors, so the errors will be stored with keys corresponding to the form field names
$errors = $form;
$form_error = FALSE;
if ($saved == 'saved') {
$form_saved = TRUE;
} else {
$form_saved = FALSE;
}
// Initialize Default Values
$form['locale'] = Kohana::config('locale.language');
//$form['latitude'] = Kohana::config('settings.default_lat');
//$form['longitude'] = Kohana::config('settings.default_lon');
$form['country_id'] = Kohana::config('settings.default_country');
$form['incident_date'] = date("m/d/Y", time());
$form['incident_hour'] = date('h');
$form['incident_minute'] = date('i');
$form['incident_ampm'] = date('a');
// initialize custom field array
$form['custom_field'] = $this->_get_custom_form_fields($id, '', true);
// Locale (Language) Array
$this->template->content->locale_array = Kohana::config('locale.all_languages');
// Create Categories
$this->template->content->categories = $this->_get_categories();
// Time formatting
$this->template->content->hour_array = $this->_hour_array();
$this->template->content->minute_array = $this->_minute_array();
$this->template->content->ampm_array = $this->_ampm_array();
$this->template->content->stroke_width_array = $this->_stroke_width_array();
// Get Countries
$countries = array();
foreach (ORM::factory('country')->orderby('country')->find_all() as $country) {
// Create a list of all categories
$this_country = $country->country;
if (strlen($this_country) > 35) {
$this_country = substr($this_country, 0, 35) . "...";
}
$countries[$country->id] = $this_country;
}
$this->template->content->countries = $countries;
//GET custom forms
$forms = array();
foreach (ORM::factory('form')->where('form_active', 1)->find_all() as $custom_forms) {
$forms[$custom_forms->id] = $custom_forms->form_title;
}
$this->template->content->forms = $forms;
// Retrieve thumbnail photos (if edit);
//XXX: fix _get_thumbnails
$this->template->content->incident = $this->_get_thumbnails($id);
// Are we creating this report from a Checkin?
if (isset($_GET['cid']) && !empty($_GET['cid'])) {
$checkin_id = (int) $_GET['cid'];
$checkin = ORM::factory('checkin', $checkin_id);
if ($checkin->loaded) {
// Has a report already been created for this Checkin?
if ((int) $checkin->incident_id > 0) {
// Redirect to report
url::redirect('members/reports/edit/' . $checkin->incident_id);
}
$incident_description = $checkin->checkin_description;
$incident_title = text::limit_chars(strip_tags($incident_description), 100, "...", true);
$form['incident_title'] = $incident_title;
$form['incident_description'] = $incident_description;
$form['incident_date'] = date('m/d/Y', strtotime($checkin->checkin_date));
$form['incident_hour'] = date('h', strtotime($checkin->checkin_date));
$form['incident_minute'] = date('i', strtotime($checkin->checkin_date));
$form['incident_ampm'] = date('a', strtotime($checkin->checkin_date));
// Does the sender of this message have a location?
if ($checkin->location->loaded) {
$form['location_id'] = $checkin->location_id;
$form['latitude'] = $checkin->location->latitude;
$form['longitude'] = $checkin->location->longitude;
$form['location_name'] = $checkin->location->location_name;
}
}
}
// check, has the form been submitted, if so, setup validation
if ($_POST) {
// Instantiate Validation, use $post, so we don't overwrite $_POST fields with our own things
$post = Validation::factory(array_merge($_POST, $_FILES));
// Add some filters
$post->pre_filter('trim', TRUE);
// Add some rules, the input field, followed by a list of checks, carried out in order
// $post->add_rules('locale','required','alpha_dash','length[5]');
$post->add_rules('location_id', 'numeric');
$post->add_rules('message_id', 'numeric');
$post->add_rules('incident_title', 'required', 'length[3,200]');
$post->add_rules('incident_description', 'required');
$post->add_rules('incident_date', 'required', 'date_mmddyyyy');
//.........这里部分代码省略.........
示例13:
</a>
</li>
<?php
$i++;
?>
<?php
}
?>
<li class="g-active<?php
if ($i == 0) {
print " g-first";
}
?>
">
<?php
echo html::purify(text::limit_chars($theme->item()->title, module::get_var("gallery", "visible_title_length")));
?>
</li>
</ul>
<?php
}
?>
</div>
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<div id="g-content" class="yui-g">
<?php
echo $theme->messages();
?>
<?php
示例14:
?>
<?php
echo $breadcrumb->first ? "g-first" : "";
?>
">
<?php
if (!$breadcrumb->last) {
?>
<a href="<?php
echo $breadcrumb->url;
?>
"><?php
}
?>
<?php
echo html::purify(text::limit_chars($breadcrumb->title, module::get_var("gallery", "visible_title_length")));
?>
<?php
if (!$breadcrumb->last) {
?>
</a><?php
}
?>
</li>
<?php
}
?>
</ul>
<?php
}
?>
示例15: foreach
<h3>Related Mainstream News of Incident</h3>
<div class="block-bg">
<div class="block-top">
<div class="block-bottom">
<ul>
<li>
<ul class="title">
<li class="w-01">TITLE</li>
<li class="w-02">SOURCE</li>
<li class="w-03">DATE</li>
</ul>
</li>
<?php
foreach ($feeds as $feed) {
$feed_id = $feed->id;
$feed_title = text::limit_chars($feed->item_title, 40, '...', True);
$feed_link = $feed->item_link;
$feed_date = date('M j Y', strtotime($feed->item_date));
$feed_source = "NEWS";
?>
<li>
<ul>
<li class="w-01">
<a href="<?php
echo $feed_link;
?>
" target="_blank">
<?php
echo $feed_title;
?>
</a></li>