本文整理汇总了PHP中Math::convertKilometersToMiles方法的典型用法代码示例。如果您正苦于以下问题:PHP Math::convertKilometersToMiles方法的具体用法?PHP Math::convertKilometersToMiles怎么用?PHP Math::convertKilometersToMiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Math
的用法示例。
在下文中一共展示了Math::convertKilometersToMiles方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index($value, $parameters = array())
{
if (!isset($parameters[0])) {
return 'Unknown';
}
if (!preg_match(Pattern::COORDINATES, $value, $point_1_matches)) {
return 'Unknown';
}
if (!preg_match(Pattern::COORDINATES, $parameters[0], $point_2_matches)) {
return 'Unknown';
}
$point_1 = array($point_1_matches[1], $point_1_matches[2]);
$point_2 = array($point_2_matches[1], $point_2_matches[2]);
$distance = Math::getDistanceInKilometers($point_1, $point_2);
return Math::convertKilometersToMiles($distance);
}
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:16,代码来源:mod.distance_in_mi_from.php
示例2: supplement
/**
* Supplements the content in the set
*
* @param array $context Context for supplementing
* @return void
*/
public function supplement($context = array())
{
$hash = Debug::markStart('content', 'supplementing');
if ($this->supplemented) {
return;
}
$this->supplemented = true;
$context = Helper::ensureArray($context);
// determine context
$given_context = $context;
$context = array('locate_with' => isset($given_context['locate_with']) ? $given_context['locate_with'] : null, 'center_point' => isset($given_context['center_point']) ? $given_context['center_point'] : null, 'list_helpers' => isset($given_content['list_helpers']) ? $given_context['list_helpers'] : true, 'context_urls' => isset($given_context['context_urls']) ? $given_context['context_urls'] : true, 'total_found' => isset($given_context['total_found']) ? $given_context['total_found'] : null, 'group_by_date' => isset($given_context['group_by_date']) ? $given_context['group_by_date'] : null, 'inherit_folder_data' => isset($given_context['inherit_folder_data']) ? $given_context['inherit_folder_data'] : true, 'merge_with_data' => isset($given_context['merge_with_data']) ? $given_context['merge_with_data'] : true);
// set up helper variables
$center_point = false;
if ($context['center_point'] && preg_match(Pattern::COORDINATES, $context['center_point'], $matches)) {
$center_point = array($matches[1], $matches[2]);
}
// contextual urls are based on current page, not individual data records
// we can figure this out once and then set it with each one
if ($context['context_urls']) {
$raw_url = Request::getResourceURI();
$page_url = Path::tidy($raw_url);
}
// iteration memory
$last_date = null;
// loop through content, supplementing each record with data
foreach ($this->content as $content_key => $data) {
// locate
if ($context['locate_with']) {
$location_data = isset($data[$context['locate_with']]) ? $data[$context['locate_with']] : null;
// check that location data is fully set
if (is_array($location_data) && isset($location_data['latitude']) && $location_data['latitude'] && isset($location_data['longitude']) && $location_data['longitude']) {
$data['latitude'] = $location_data['latitude'];
$data['longitude'] = $location_data['longitude'];
$data['coordinates'] = $location_data['latitude'] . "," . $location_data['longitude'];
// get distance from center
if ($center_point) {
$location = array($data['latitude'], $data['longitude']);
$data['distance_km'] = Math::getDistanceInKilometers($center_point, $location);
$data['distance_mi'] = Math::convertKilometersToMiles($data['distance_km']);
}
}
}
// contextual urls
if ($context['context_urls']) {
$data['raw_url'] = $raw_url;
$data['page_url'] = $page_url;
}
// total entries
if ($context['total_found']) {
$data['total_found'] = (int) $context['total_found'];
}
// group by date
if ($context['group_by_date'] && $data['datestamp']) {
$formatted_date = Date::format($context['group_by_date'], $data['datestamp']);
if ($formatted_date !== $last_date) {
$last_date = $formatted_date;
$data['grouped_date'] = $formatted_date;
} else {
$data['grouped_date'] = '';
}
}
// loop through content to add data for variables that are arrays
foreach ($data as $key => $value) {
// Only run on zero indexed arrays/loops
if (is_array($value) && isset($value[0]) && !is_array($value[0])) {
// list helpers
if ($context['list_helpers']) {
// make automagic lists
$data[$key . "_list"] = join(", ", $value);
$data[$key . "_spaced_list"] = join(" ", $value);
$data[$key . "_option_list"] = join("|", $value);
$data[$key . "_ordered_list"] = "<ol><li>" . join("</li><li>", $value) . "</li></ol>";
$data[$key . "_unordered_list"] = "<ul><li>" . join("</li><li>", $value) . "</li></ul>";
$data[$key . "_sentence_list"] = Helper::makeSentenceList($value);
$data[$key . "_ampersand_sentence_list"] = Helper::makeSentenceList($value, "&", false);
// handle taxonomies
if (Taxonomy::isTaxonomy($key)) {
$url_list = array_map(function ($item) use($data, $key, $value) {
return '<a href="' . Taxonomy::getURL($data['_folder'], $key, $item) . '">' . $item . '</a>';
}, $value);
$data[$key . "_url_list"] = join(", ", $url_list);
$data[$key . "_spaced_url_list"] = join(" ", $url_list);
$data[$key . "_ordered_url_list"] = "<ol><li>" . join("</li><li>", $url_list) . "</li></ol>";
$data[$key . "_unordered_url_list"] = "<ul><li>" . join("</li><li>", $url_list) . "</li></ul>";
$data[$key . "_sentence_url_list"] = Helper::makeSentenceList($url_list);
$data[$key . "_ampersand_sentence_url_list"] = Helper::makeSentenceList($url_list, "&", false);
}
}
}
}
// update content with supplemented data merged with global config data
if ($context['merge_with_data'] || $context['inherit_folder_data']) {
$folder_data = array();
$all_config = array();
//.........这里部分代码省略.........
示例3: convert_km_to_miles
/**
* Convert kilometers to miles
*
* @param float $kilometers Kilometers to convert
* @return float
*/
public static function convert_km_to_miles($kilometers)
{
Log::warn("Use of Statamic_Helper::convert_km_to_miles() is deprecated. Use Math::convertKilometersToMiles() instead.", "core", "Statamic_Helper");
return Math::convertKilometersToMiles($kilometers);
}