本文整理汇总了PHP中Utils::pluralize方法的典型用法代码示例。如果您正苦于以下问题:PHP Utils::pluralize方法的具体用法?PHP Utils::pluralize怎么用?PHP Utils::pluralize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utils
的用法示例。
在下文中一共展示了Utils::pluralize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bulk
public function bulk()
{
$action = Input::get('action');
$ids = Input::get('id') ? Input::get('id') : Input::get('ids');
$count = $this->invoiceRepo->bulk($ids, $action);
if ($count > 0) {
$message = Utils::pluralize("{$action}d_quote", $count);
Session::flash('message', $message);
}
return Redirect::to('quotes');
}
示例2: add_to_dashboard
public function add_to_dashboard()
{
$post_type = get_post_type_object($this->slug);
$num_posts = wp_count_posts($post_type->name);
$num = number_format_i18n($num_posts->publish);
$text = _n(Utils::pluralize($post_type->labels->singular_name), Utils::pluralize($post_type->labels->name), intval($num_posts->publish));
if (current_user_can('edit_posts')) {
$num = "<a href='edit.php?post_type={$post_type->name}'>{$num}</a>";
$text = "<a href='edit.php?post_type={$post_type->name}'>{$text}</a>";
}
echo '<tr><td class="first b b-' . $post_type->name . '">' . $num . '</td>';
echo '<td class="t ' . $post_type->name . '">' . $text . '</td></tr>';
}
示例3: __call
/**
* Enables the use of build|create for associations.
*
* @param string $method Name of method
* @param mixed $args Method args
* @return mixed An instance of a given {@link AbstractRelationship}
*/
public function __call($method, $args)
{
//check for build|create_association methods
if (preg_match('/(build|create)_/', $method)) {
if (!empty($args)) {
$args = $args[0];
}
$association_name = str_replace(array('build_', 'create_'), '', $method);
$method = str_replace($association_name, 'association', $method);
$table = static::table();
if (($association = $table->get_relationship($association_name)) || ($association = $table->get_relationship($association_name = Utils::pluralize($association_name)))) {
// access association to ensure that the relationship has been loaded
// so that we do not double-up on records if we append a newly created
$this->{$association_name};
return $association->{$method}($this, $args);
}
}
throw new ActiveRecordException("Call to undefined method: {$method}");
}
示例4: importFilei
//.........这里部分代码省略.........
foreach ($data as $row) {
if ($hasHeaders) {
$hasHeaders = false;
continue;
}
$invoice = Invoice::createNew();
$invoiceItem = InvoiceItem::createNew();
$count++;
$branch = \DB::table('branches')->where('id', $branch_id)->first();
$invoice->branch_id = $branch_id;
$invoiceNumber = $branch->invoice_number_counter;
$invoice->invoice_number = $invoiceNumber;
$today = new DateTime('now');
$invoice->invoice_date = $today->format('Y-m-d');
$invoiceDesign = \DB::table('invoice_designs')->where('account_id', \Auth::user()->account_id)->orderBy('public_id', 'desc')->first();
$invoice->invoice_design_id = $invoiceDesign->id;
$account = \Auth::user()->account;
$invoice->account_name = $account->name;
$invoice->account_nit = $account->nit;
$invoice->branch_name = $branch->name;
$invoice->address1 = $branch->address1;
$invoice->address2 = $branch->address2;
$invoice->phone = $branch->postal_code;
$invoice->city = $branch->city;
$invoice->state = $branch->state;
$invoice->number_autho = $branch->number_autho;
$invoice->deadline = $branch->deadline;
$invoice->key_dosage = $branch->key_dosage;
$invoice->activity_pri = $branch->activity_pri;
$invoice->activity_sec1 = $branch->activity_sec1;
$invoice->law = $branch->law;
foreach ($row as $index => $value) {
$field = $map[$index];
$value = trim($value);
if ($field == Invoice::$fieldCodClient) {
$cod_client = intval($value);
$invoice->client_id = $clientMap[$cod_client][0];
$invoice->client_nit = $clientMap[$cod_client][1];
$invoice->client_name = $clientMap[$cod_client][2];
} else {
if ($field == Invoice::$fieldProduct) {
$notes = $value;
} else {
if ($field == Invoice::$fieldAmount) {
$invoiceItem->notes = wordwrap($notes, 70, "\n");
$str = str_replace(".", "", $value);
$amount = str_replace(",", ".", $str);
$invoiceItem->cost = $amount;
$invoiceItem->qty = 1;
$invoiceItem->tax_rate = 0;
$invoice->subtotal = $invoiceItem->cost;
$invoice->amount = $invoiceItem->cost;
$invoice->balance = $invoiceItem->cost;
}
}
}
}
$invoice_dateCC = date("Ymd", strtotime($invoice->invoice_date));
$invoice_date_limitCC = date("d/m/Y", strtotime($branch->deadline));
require_once app_path() . '/includes/control_code.php';
$cod_control = codigoControl($invoice->invoice_number, $invoice->client_nit, $invoice_dateCC, $invoice->amount, $branch->number_autho, $branch->key_dosage);
$invoice->control_code = $cod_control;
$invoice_date = date("d/m/Y", strtotime($invoice->invoice_date));
require_once app_path() . '/includes/BarcodeQR.php';
// $ice = $invoice->amount-$invoice->fiscal;
$desc = $invoice->subtotal - $invoice->amount;
$subtotal = number_format($invoice->subtotal, 2, '.', '');
$amount = number_format($invoice->amount, 2, '.', '');
$fiscal = number_format($invoice->fiscal, 2, '.', '');
// $icef = number_format($ice, 2, '.', '');
$descf = number_format($desc, 2, '.', '');
// if($icef=="0.00"){
// $icef = 0;
// }
if ($descf == "0.00") {
$descf = 0;
}
$icef = 0;
$qr = new BarcodeQR();
$datosqr = $invoice->account_nit . '|' . $invoice->invoice_number . '|' . $invoice->number_autho . '|' . $invoice_date . '|' . $subtotal . '|' . $amount . '|' . $invoice->control_code . '|' . $invoice->client_nit . '|' . $icef . '|0|0|' . $descf;
$qr->text($datosqr);
$qr->draw(150, 'qr/' . $account->account_key . '_' . $branch->name . '_' . $invoice->invoice_number . '.png');
$input_file = 'qr/' . $account->account_key . '_' . $branch->name . '_' . $invoice->invoice_number . '.png';
$output_file = 'qr/' . $account->account_key . '_' . $branch->name . '_' . $invoice->invoice_number . '.jpg';
$inputqr = imagecreatefrompng($input_file);
list($width, $height) = getimagesize($input_file);
$output = imagecreatetruecolor($width, $height);
$white = imagecolorallocate($output, 255, 255, 255);
imagefilledrectangle($output, 0, 0, $width, $height, $white);
imagecopy($output, $inputqr, 0, 0, 0, 0, $width, $height);
imagejpeg($output, $output_file);
$invoice->qr = HTML::image_data('qr/' . $account->account_key . '_' . $branch->name . '_' . $invoice->invoice_number . '.jpg');
$invoice->save();
$invoice->invoice_items()->save($invoiceItem);
// Activity::createInvoice($invoice, false);
}
$message = Utils::pluralize('created_invoicei', $count);
Session::flash('message', $message);
return Redirect::to('invoices');
}
示例5: foreach
if ($url['path'] == '3locales') {
$check['extra_locale'] = $locale2;
$searches[$locale2] = $locale3_strings;
$data[] = $tmx_target2;
}
$search_yields_results = false;
// This will hold the components names for the search filters
$components = [];
foreach ($searches as $key => $value) {
$search_results = ShowResults::getTMXResults(array_keys($value), $data);
$components += Project::getComponents($search_results);
if (count($value) > 0) {
// We have results, we won't display search suggestions but search results
$search_yields_results = true;
$search_id = strtolower(str_replace('-', '', $key));
$message_count = $real_search_results > $limit_results ? "<span class=\"results_count_{$search_id}\">{$limit_results} results</span> out of {$real_search_results}" : "<span class=\"results_count_{$search_id}\">" . Utils::pluralize(count($search_results), 'result') . '</span>';
$output[$key] = "<h2>Displaying {$message_count} for the string " . "<span class=\"searchedTerm\">{$initial_search_decoded}</span> in {$key}:</h2>";
$output[$key] .= ShowResults::resultsTable($search_id, $search_results, $initial_search, $source_locale, $locale, $check);
} else {
$output[$key] = "<h2>No matching results for the string " . "<span class=\"searchedTerm\">{$initial_search_decoded}</span>" . " for the locale {$key}</h2>";
}
}
// Remove duplicated components
$components = array_unique($components);
// Display a search hint for the closest string we have if we have no search results
if (!$search_yields_results) {
$merged_strings = [];
foreach ($data as $key => $values) {
$merged_strings = array_merge($merged_strings, array_values($values));
}
$best_matches = Strings::getSimilar($initial_search, $merged_strings, 3);
示例6: explode
<?php
namespace Transvision;
// Include the common simple search form
include __DIR__ . '/simplesearchform.php';
$search_id = 'unchanged_strings';
$content = "<h2><span class=\"results_count_{$search_id}\">" . Utils::pluralize(count($unchanged_strings), 'string') . "</span> identical to English</h2>\n";
if (isset($filter_block)) {
$content .= "<div id='filters'>" . " <h4>Filter by folder:</h4>\n" . " <a href='#showall' id='showall' class='filter'>Show all results</a>\n" . $filter_block . "</div>\n";
}
$content .= "<table class='collapsable results_table {$search_id}'>\n";
$content .= " <tr class='column_headers'>\n" . " <th>String ID</th>\n" . " <th>English</th>\n" . " <th>Translation</th>\n" . " </tr>\n";
foreach ($unchanged_strings as $string_id => $string_value) {
$component = explode('/', $string_id)[0];
$entity_link = "/?sourcelocale={$source_locale}" . "&locale={$locale}" . "&repo={$repo}" . "&search_type=entities&recherche={$string_id}";
/*
Since this view displays strings identical to source locale, I'll use the same
direction, not the locale's default (for example I'll use LTR for English+Arabic).
*/
$direction = RTLSupport::getDirection($source_locale);
$content .= " <tr class='{$component} {$search_id}'>\n" . " <td dir='ltr'><a href='{$entity_link}'>{$string_id}</a></td>\n" . " <td dir='{$direction}' lang='{$source_locale}'>{$string_value}</td>\n" . " <td dir='{$direction}' lang='{$locale}'>" . $strings_locale[$string_id] . "</td>\n" . " </tr>\n";
}
$content .= "</table>\n";
echo $content;
示例7: bulk
public function bulk()
{
$action = Input::get('action');
$statusId = Input::get('statusId');
$ids = Input::get('id') ? Input::get('id') : Input::get('ids');
$count = $this->invoiceRepo->bulk($ids, $action, $statusId);
if ($count > 0) {
$key = $action == 'mark' ? "updated_quote" : "{$action}d_quote";
$message = Utils::pluralize($key, $count);
Session::flash('message', $message);
}
return Redirect::to('quotes');
}
示例8: getStatsTab
/**
* Create a tab containing the repo info
*
* @param array $data Array containing structured commit data
* @param string $id ID that will be used in combination with an HTML anchor
* in a tab-link to show this tab-content. Should match the id in $data
* argument used in Health::getStatsPane.
* @param boolean $active Should this tab be the active one?
* @return string HTML element to add between <div class="tab-content"> and
* </div>, or false if data are missing.
*/
public static function getStatsTab($data, $id, $active)
{
// Create the tab only if we get data
if (isset($data['commit'])) {
$date = $data['commit']['date'];
$tab = '';
// Set CSS classes if the latest commit is 1 year old or older
$commit_class = $date->diff(new \DateTime('now'))->format('%y') >= 1 ? ' old' : '';
$active_class = $active ? ' active' : '';
// Build HTML
$commit = '<b>' . Utils::ago($date) . '</b> (' . $date->format('F d, Y \\a\\t H:i \\G\\M\\T e') . ') by ' . $data['commit']['author'];
$tab .= '<div id="' . $id . '" class="metrics tab' . $active_class . '">' . '<h4>Repo metrics:</h4><ul>' . '<li class="metric' . $commit_class . '">Last commit: ' . $commit . '</li>' . '<li class="metric">Number of commits: ' . Utils::pluralize($data['commit_sum'], 'commit') . '</li>' . '</ul></div>';
return $tab;
} else {
return false;
}
}
示例9: __construct
function __construct()
{
$class = get_class($this);
$this->file_name = strtolower(Utils::pluralize($class));
$this->file_path = DATAPATH . "data." . $this->file_name . ".json";
}
示例10: foreach
<?php
namespace Transvision;
// Include the common simple search form
include __DIR__ . '/simplesearchform.php';
if ($error_count > 0) {
$search_id = 'check_variable';
$content = "<h2><span class=\"results_count_{$search_id}\">" . Utils::pluralize($error_count, 'result') . "</span> found</h2>\n";
if (isset($filter_block)) {
$content .= "<div id='filters'>" . " <h4>Filter by folder:</h4>\n" . " <a href='#showall' id='showall' class='filter'>Show all results</a>\n" . $filter_block . "</div>\n";
}
$content .= "<table class='collapsable results_table {$search_id}'>\n" . " <tr>\n" . " <th>Entity</th>\n" . " <th>{$source_locale}</th>\n" . " <th>{$locale}</th>\n" . " </tr>\n";
foreach ($var_errors as $string_id) {
// Link to entity
$string_id_link = "?sourcelocale={$source_locale}" . "&locale={$locale}" . "&repo={$repo}" . "&search_type=entities&recherche={$string_id}";
$bugzilla_link = Bugzilla::reportErrorLink($locale, $string_id, $source[$string_id], $target[$string_id], $repo, $string_id_link);
$path_locale1 = VersionControl::hgPath($source_locale, $repo, $string_id);
$path_locale2 = VersionControl::hgPath($locale, $repo, $string_id);
$component = explode('/', $string_id)[0];
$content .= "<tr class='{$component} {$search_id}'>\n <td>\n <span class='celltitle'>Entity</span>\n <a class='link_to_entity' href=\"/{$string_id_link}\">" . ShowResults::formatEntity($string_id) . "</a>\n </td>\n <td dir='{$direction1}'>\n <span class='celltitle'>{$source_locale}</span>\n <div class='string'>" . Utils::secureText($source[$string_id]) . "</div>\n <div class='result_meta_link'>\n <a class='source_link' href='{$path_locale1}'><em><source></em></a>\n </div>\n </td>\n <td dir='{$direction2}'>\n <span class='celltitle'>{$locale}</span>\n <div class='string'>" . Utils::secureText($target[$string_id]) . "</div>\n <div class='result_meta_link'>\n <a class='source_link' href='{$path_locale2}'><em><source></em></a>\n <a class='bug_link' target='_blank' href='{$bugzilla_link}'><report a bug></a>\n </div>\n </td>\n </tr>\n";
}
$content .= "</table>\n";
} else {
$content = "<h2>Congratulations, no errors found.</h2>";
}
print $content;
示例11: importFile
private function importFile()
{
$data = Session::get('data');
Session::forget('data');
$map = Input::get('map');
$count = 0;
$hasHeaders = Input::get('header_checkbox');
$countries = Country::remember(DEFAULT_QUERY_CACHE)->get();
$countryMap = [];
foreach ($countries as $country) {
$countryMap[strtolower($country->name)] = $country->id;
}
foreach ($data as $row) {
if ($hasHeaders) {
$hasHeaders = false;
continue;
}
$client = Client::createNew();
$contact = Contact::createNew();
$contact->is_primary = true;
$contact->send_invoice = true;
$count++;
foreach ($row as $index => $value) {
$field = $map[$index];
$value = trim($value);
if ($field == Client::$fieldName && !$client->name) {
$client->name = $value;
} else {
if ($field == Client::$fieldPhone && !$client->work_phone) {
$client->work_phone = $value;
} else {
if ($field == Client::$fieldAddress1 && !$client->address1) {
$client->address1 = $value;
} else {
if ($field == Client::$fieldAddress2 && !$client->address2) {
$client->address2 = $value;
} else {
if ($field == Client::$fieldCity && !$client->city) {
$client->city = $value;
} else {
if ($field == Client::$fieldState && !$client->state) {
$client->state = $value;
} else {
if ($field == Client::$fieldPostalCode && !$client->postal_code) {
$client->postal_code = $value;
} else {
if ($field == Client::$fieldCountry && !$client->country_id) {
$value = strtolower($value);
$client->country_id = isset($countryMap[$value]) ? $countryMap[$value] : null;
} else {
if ($field == Client::$fieldNotes && !$client->private_notes) {
$client->private_notes = $value;
} else {
if ($field == Contact::$fieldFirstName && !$contact->first_name) {
$contact->first_name = $value;
} else {
if ($field == Contact::$fieldLastName && !$contact->last_name) {
$contact->last_name = $value;
} else {
if ($field == Contact::$fieldPhone && !$contact->phone) {
$contact->phone = $value;
} else {
if ($field == Contact::$fieldEmail && !$contact->email) {
$contact->email = strtolower($value);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
$client->save();
$client->contacts()->save($contact);
Activity::createClient($client, false);
}
$message = Utils::pluralize('created_client', $count);
Session::flash('message', $message);
return Redirect::to('clients');
}
示例12: foreach
if ($url['path'] == '3locales') {
$check['extra_locale'] = $locale2;
$searches[$locale2] = $locale3_strings;
$data[] = $tmx_target2;
}
$search_yields_results = false;
// This will hold the components names for the search filters
$components = [];
foreach ($searches as $key => $value) {
$search_results = ShowResults::getTMXResults(array_keys($value), $data);
$components += Project::getComponents($search_results);
if (count($value) > 0) {
// We have results, we won't display search suggestions but search results
$search_yields_results = true;
$message_count = $real_search_results > $limit_results ? $limit_results . ' of ' . $real_search_results : count($search_results);
$pluralized_count = Utils::pluralize($message_count, 'result');
$output[$key] = "<h2>Displaying {$pluralized_count} for the string " . "<span class=\"searchedTerm\">{$initial_search_decoded}</span> in {$key}:</h2>";
$output[$key] .= ShowResults::resultsTable($search_results, $initial_search, $source_locale, $locale, $check);
} else {
$output[$key] = "<h2>No matching results for the string " . "<span class=\"searchedTerm\">{$initial_search_decoded}</span>" . " for the locale {$key}</h2>";
}
}
// Remove duplicated components
$components = array_unique($components);
// Display a search hint for the closest string we have if we have no search results
if (!$search_yields_results) {
$merged_strings = [];
foreach ($data as $key => $values) {
$merged_strings = array_merge($merged_strings, array_values($values));
}
$best_matches = Strings::getSimilar($initial_search, $merged_strings, 3);
示例13: bulk
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function bulk($entityType = ENTITY_INVOICE)
{
$action = Input::get('action');
$ids = Input::get('id') ? Input::get('id') : Input::get('ids');
$count = $this->invoiceRepo->bulk($ids, $action);
if ($count > 0) {
$message = Utils::pluralize("{$action}d_{$entityType}", $count);
Session::flash('message', $message);
}
return Redirect::to("{$entityType}s");
}
示例14: bulk
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function bulk($entityType = ENTITY_INVOICE)
{
$action = Input::get('action');
$statusId = Input::get('statusId');
$ids = Input::get('id') ? Input::get('id') : Input::get('ids');
if ($action == 'delete') {
$invoices = Invoice::withTrashed()->scope($ids)->get();
foreach ($invoices as $invoice) {
BookSale::deleteBook($invoice);
}
}
//$count = $this->invoiceRepo->bulk($ids, $action, $statusId);
if ($count > 0) {
$key = $action == 'mark' ? "updated_{$entityType}" : "{$action}d_{$entityType}";
$message = Utils::pluralize($key, $count);
Session::flash('message', $message);
}
return Redirect::to("{$entityType}");
}
示例15: bulk
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function bulk($entityType = ENTITY_INVOICE)
{
$action = Input::get('action');
$statusId = Input::get('statusId', INVOICE_STATUS_SENT);
$ids = Input::get('id') ? Input::get('id') : Input::get('ids');
$count = $this->invoiceRepo->bulk($ids, $action, $statusId);
if ($count > 0) {
$key = $action == 'mark' ? "updated_{$entityType}" : "{$action}d_{$entityType}";
$message = Utils::pluralize($key, $count);
Session::flash('message', $message);
}
if ($action == 'restore' && $count == 1) {
return Redirect::to("{$entityType}s/" . $ids[0]);
} else {
return Redirect::to("{$entityType}s");
}
}