本文整理汇总了PHP中Fisharebest\Webtrees\I18N::percentage方法的典型用法代码示例。如果您正苦于以下问题:PHP I18N::percentage方法的具体用法?PHP I18N::percentage怎么用?PHP I18N::percentage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fisharebest\Webtrees\I18N
的用法示例。
在下文中一共展示了I18N::percentage方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderContent
/**
* {@inhericDoc}
* @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent()
*/
protected function renderContent()
{
$nb_found = $this->data->get('stats_gen_nb_found');
$nb_other = $this->data->get('stats_gen_nb_other');
$nb_unknown = $this->data->get('stats_gen_nb_unknown');
$perc_known = Functions::safeDivision($nb_found - $nb_other, $nb_found + $nb_unknown);
$html = '<div id="geodispersion_summary">
<div class="maj-table center">
<div class="maj-row">
<div class="label">' . I18N::translate('Places found') . '</div>
<div class="value">' . I18N::translate('%1$d (%2$s)', $nb_found - $nb_other, I18N::percentage($perc_known)) . '</div>
</div>';
if ($nb_other > 0) {
$perc_other = Functions::safeDivision($nb_other, $nb_found + $nb_unknown);
$html .= '<div class="maj-row">
<div class="label">' . I18N::translate('Other places') . '</div>
<div class="value">' . I18N::translate('%1$d (%2$s)', $nb_other, I18N::percentage($perc_other)) . '</div>
</div>';
}
$html .= '<div class="maj-row">
<div class="label">' . I18N::translate('Places not found') . '</div>
<div class="value">' . I18N::translate('%1$d (%2$s)', $nb_unknown, I18N::percentage(1 - $perc_known)) . '</div>
</div>
</div>
</div>
<br/>
<div id="geodispersion_data">
' . $this->htmlAnalysisData() . '
</div>';
return $html;
}
示例2: htmlAnalysisData
/**
* {@inheritDoc}
* @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisTabGeneralView::htmlAnalysisData()
*/
protected function htmlAnalysisData()
{
$results = $this->data->get('results');
$analysis_level = $this->data->get('analysis_level');
$nb_found = $this->data->get('stats_gen_nb_found');
$nb_other = $this->data->get('stats_gen_nb_other');
$i = 1;
$previous_nb = 0;
$html = '<div class="maj-table center">';
foreach ($results as $place => $nb) {
$perc = Functions::safeDivision($nb, $nb_found - $nb_other);
if ($nb != $previous_nb) {
$j = I18N::number($i);
} else {
$j = ' ';
}
$levels = array_map('trim', explode(',', $place));
$placename = $levels[$analysis_level - 1];
if ($placename == '' && $analysis_level > 1) {
$placename = I18N::translate('Unknown (%s)', $levels[$analysis_level - 2]);
}
$html .= '<div class="maj-row">
<div class="label"><strong>' . $j . '</strong></div>
<div class="label">' . $placename . '</div>
<div class="value">' . I18N::translate('%d', $nb) . '</div>
<div class="value">' . I18N::percentage($perc, 1) . '</div>
</div>';
$i++;
$previous_nb = $nb;
}
$html .= '</div>';
return $html;
}
示例3: chartFamsWithSources
/**
* Create a chart of individuals with/without sources.
*
* @param string[] $params
*
* @return string
*/
public function chartFamsWithSources($params = array())
{
$WT_STATS_CHART_COLOR1 = Theme::theme()->parameter('distribution-chart-no-values');
$WT_STATS_CHART_COLOR2 = Theme::theme()->parameter('distribution-chart-high-values');
$WT_STATS_S_CHART_X = Theme::theme()->parameter('stats-small-chart-x');
$WT_STATS_S_CHART_Y = Theme::theme()->parameter('stats-small-chart-y');
if (isset($params[0]) && $params[0] != '') {
$size = strtolower($params[0]);
} else {
$size = $WT_STATS_S_CHART_X . "x" . $WT_STATS_S_CHART_Y;
}
if (isset($params[1]) && $params[1] != '') {
$color_from = strtolower($params[1]);
} else {
$color_from = $WT_STATS_CHART_COLOR1;
}
if (isset($params[2]) && $params[2] != '') {
$color_to = strtolower($params[2]);
} else {
$color_to = $WT_STATS_CHART_COLOR2;
}
$sizes = explode('x', $size);
$tot_fam = $this->totalFamiliesQuery();
if ($tot_fam == 0) {
return '';
} else {
$tot_sfam_per = round($this->totalFamsWithSourcesQuery() / $tot_fam, 3);
$chd = $this->arrayToExtendedEncoding(array(100 - 100 * $tot_sfam_per, 100 * $tot_sfam_per));
$chl = I18N::translate('Without sources') . ' - ' . I18N::percentage(1 - $tot_sfam_per, 1) . '|' . I18N::translate('With sources') . ' - ' . I18N::percentage($tot_sfam_per, 1);
$chart_title = I18N::translate('Families with sources');
return "<img src=\"https://chart.googleapis.com/chart?cht=p3&chd=e:{$chd}&chs={$size}&chco={$color_from},{$color_to}&chf=bg,s,ffffff00&chl={$chl}\" width=\"{$sizes[0]}\" height=\"{$sizes[1]}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />";
}
}
示例4: REPLACE
<div
class="progress-bar"
role="progressbar"
aria-valuenow="<?php
echo $progress * 100;
?>
"
aria-valuemin="0"
aria-valuemax="100"
style="width: <?php
echo $progress * 100;
?>
%; min-width: 40px;"
>
<?php
echo I18N::percentage($progress, 1);
?>
</div>
</div>
<?php
$first_time = $row->import_offset == 0;
// Run for one second. This keeps the resource requirements low.
for ($end_time = microtime(true) + 1.0; microtime(true) < $end_time;) {
$data = Database::prepare("SELECT gedcom_chunk_id, REPLACE(chunk_data, '\r', '\n') AS chunk_data" . " FROM `##gedcom_chunk`" . " WHERE gedcom_id=? AND NOT imported" . " ORDER BY gedcom_chunk_id" . " LIMIT 1")->execute(array($gedcom_id))->fetchOneRow();
// If we are loading the first (header) record, make sure the encoding is UTF-8.
if ($first_time) {
// Remove any byte-order-mark
Database::prepare("UPDATE `##gedcom_chunk`" . " SET chunk_data=TRIM(LEADING ? FROM chunk_data)" . " WHERE gedcom_chunk_id=?")->execute(array(WT_UTF8_BOM, $data->gedcom_chunk_id));
// Re-fetch the data, now that we have removed the BOM
$data = Database::prepare("SELECT gedcom_chunk_id, REPLACE(chunk_data, '\r', '\n') AS chunk_data" . " FROM `##gedcom_chunk`" . " WHERE gedcom_chunk_id=?")->execute(array($data->gedcom_chunk_id))->fetchOneRow();
if (substr($data->chunk_data, 0, 6) != '0 HEAD') {
示例5: renderContent
//.........这里部分代码省略.........
<?php
if (!$person->canShow() || Date::compare($birth_date, new Date(date('Y') - 100)) > 0) {
echo 'Y100';
} else {
echo 'YES';
}
?>
</td>
<td>
<?php
if (Date::compare($death_dates[0], new Date(date('Y') - 100)) > 0) {
echo 'Y100';
} elseif ($death_dates[0]->minimumJulianDay() || $person->isDead()) {
echo 'YES';
} else {
echo 'N';
}
?>
</td>
<td>
<?php
if (!$person->getChildFamilies()) {
echo 'R';
} elseif (!$person->isDead() && $person->getNumberOfChildren() < 1) {
echo 'L';
} else {
echo ' ';
}
?>
</td>
</tr>
<?php
}
?>
</tbody>
<tfoot>
<tr>
<th class="ui-state-default" colspan="22">
<div class="center">
<?php
echo I18N::translate('Number of Sosa ancestors: %1$s known / %2$s theoretical (%3$s)', I18N::number($this->data->get('sosa_count')), I18N::number($this->data->get('sosa_theo')), I18N::percentage($this->data->get('sosa_ratio'), 2));
?>
<?php
if ($this->data->get('sosa_hidden') > 0) {
echo '[' . I18N::translate('%s hidden', I18N::number($this->data->get('sosa_hidden'))) . ']';
}
?>
</div>
</th>
</tr>
<tr>
<th colspan="22">
<div class="btn-toolbar">
<div class="btn-group">
<button type="button" class="ui-state-default btn-toggle-parents">
<?php
echo I18N::translate('Show parents');
?>
</button>
<button id="btn-toggle-statistics-<?php
echo $table_id;
?>
" type="button" class="ui-state-default btn-toggle-statistics">
<?php
echo I18N::translate('Show statistics charts');
?>
</button>
</div>
</div>
</th>
</tr>
</tfoot>
</table>
<div id="indi_list_table-charts_<?php
echo $table_id;
?>
" style="display:none">
<table class="list-charts">
<tr>
<td><?php
echo $this->data->get('chart_births');
?>
</td>
<td><?php
echo $this->data->get('chart_deaths');
?>
</td>
</tr>
<tr>
<td colspan="2"><?php
echo $this->data->get('chart_ages');
?>
</td>
</tr>
</table>
</div>
</div>
<?php
}
}
示例6: htmlAncestorDispersionG3
/**
* Returns HTML code for a graph showing the dispersion of ancestors across grand-parents
* @return string HTML code
*/
private function htmlAncestorDispersionG3()
{
$ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(3);
$size = '700x300';
$color_motmot = 'ffd1dc';
$color_motfat = 'b998a0';
$color_fatfat = '577292';
$color_fatmot = '84beff';
$color_shared = '777777';
$total_fatfat = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0;
$total_fatmot = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0;
$total_motfat = array_key_exists(4, $ancestorsDispGen2) ? $ancestorsDispGen2[4] : 0;
$total_motmot = array_key_exists(8, $ancestorsDispGen2) ? $ancestorsDispGen2[8] : 0;
$total_sha = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0;
$total = $total_fatfat + $total_fatmot + $total_motfat + $total_motmot + $total_sha;
$chd = $this->arrayToExtendedEncoding(array(4095 * Functions::safeDivision($total_fatfat, $total), 4095 * Functions::safeDivision($total_fatmot, $total), 4095 * Functions::safeDivision($total_sha, $total), 4095 * Functions::safeDivision($total_motfat, $total), 4095 * Functions::safeDivision($total_motmot, $total)));
$chart_title = I18N::translate('Known Sosa ancestors\' dispersion - G3');
$chl = \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatfat, $total), 1) . '|' . \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatmot, $total), 1) . '|' . I18N::translate('Shared') . ' - ' . I18N::percentage(Functions::safeDivision($total_sha, $total), 1) . '|' . \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_motfat, $total), 1) . '|' . \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_motmot, $total), 1);
return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$color_fatfat},{$color_fatmot},{$color_shared},{$color_motfat},{$color_motmot}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />";
}
示例7: chartByDecade
/**
* Print a chart by decade using Google chart API
*
* @param integer[] $data
* @param string $title
*
* @return string
*/
public static function chartByDecade($data, $title)
{
$count = 0;
$vmax = 0;
foreach ($data as $v) {
$n = strlen($v);
$vmax = max($vmax, $n);
$count += $n;
}
if ($count < 1) {
return '';
}
$chart_url = "https://chart.googleapis.com/chart?cht=bvs";
// chart type
$chart_url .= "&chs=360x150";
// size
$chart_url .= "&chbh=3,3";
// bvg : 4,1,2
$chart_url .= "&chf=bg,s,FFFFFF99";
//background color
$chart_url .= "&chco=0000FF,FFA0CB";
// bar color
$chart_url .= "&chtt=" . rawurlencode($title);
// title
$chart_url .= "&chxt=x,y,r";
// axis labels specification
$chart_url .= "&chxl=0:|<|||";
// <1570
for ($y = 1600; $y < 2030; $y += 50) {
$chart_url .= $y . "|||||";
// x axis
}
$chart_url .= "|1:||" . rawurlencode(I18N::percentage($vmax / $count));
// y axis
$chart_url .= "|2:||";
$step = $vmax;
for ($d = $vmax; $d > 0; $d--) {
if ($vmax < $d * 10 + 1 && $vmax % $d == 0) {
$step = $d;
}
}
if ($step == $vmax) {
for ($d = $vmax - 1; $d > 0; $d--) {
if ($vmax - 1 < $d * 10 + 1 && ($vmax - 1) % $d == 0) {
$step = $d;
}
}
}
for ($n = $step; $n < $vmax; $n += $step) {
$chart_url .= $n . "|";
}
$chart_url .= rawurlencode($vmax . " / " . $count);
// r axis
$chart_url .= "&chg=100," . round(100 * $step / $vmax, 1) . ",1,5";
// grid
$chart_url .= "&chd=s:";
// data : simple encoding from A=0 to 9=61
$CHART_ENCODING61 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for ($y = 1570; $y < 2030; $y += 10) {
$chart_url .= $CHART_ENCODING61[(int) (substr_count($data[$y], "M") * 61 / $vmax)];
}
$chart_url .= ",";
for ($y = 1570; $y < 2030; $y += 10) {
$chart_url .= $CHART_ENCODING61[(int) (substr_count($data[$y], "F") * 61 / $vmax)];
}
$html = '<img src="' . $chart_url . '" alt="' . $title . '" title="' . $title . '" class="gchart">';
return $html;
}
示例8: renderContent
/**
* {@inhericDoc}
* @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent()
*/
protected function renderContent()
{
?>
<div id="maj-sosa-stats-page">
<h2><?php
echo $this->data->get('title');
?>
</h2>
<?php
/** @var \Fisharebest\Webtrees\Individual $root_indi */
$root_indi = $this->data->get('root_indi');
if ($root_indi !== null && $root_indi->canShowName()) {
?>
<h4 class="center"><?php
echo I18N::translate('%s: %s', I18N::translate('Root individual'), $root_indi->getFullName());
?>
<h4>
<?php
}
?>
<?php
if ($this->data->get('is_setup')) {
$general_stats = $this->data->get('general_stats');
?>
<h3><?php
echo I18N::translate('General statistics');
?>
</h3>
<div class="maj-table">
<div class="maj-row">
<div class="label"><?php
echo I18N::translate('Number of ancestors');
?>
</div>
<div class="value"><?php
echo I18N::number($general_stats['sosa_count']);
?>
</div>
</div>
<div class="maj-row">
<div class="label"><?php
echo I18N::translate('Number of different ancestors');
?>
</div>
<div class="value"><?php
echo I18N::number($general_stats['distinct_count']);
?>
</div>
</div>
<div class="maj-row">
<div class="label"><?php
echo I18N::translate('%% of ancestors in the base');
?>
</div>
<div class="value"><?php
echo I18N::percentage($general_stats['sosa_rate'], 1);
?>
</div>
</div>
<div class="maj-row">
<div class="label"><?php
echo I18N::translate('Pedigree collapse');
?>
</div>
<div class="value"><?php
echo I18N::percentage($general_stats['pedi_collapse'], 2);
?>
</div>
</div>
<div class="maj-row">
<div class="label"><?php
echo I18N::translate('Mean generation time');
?>
</div>
<div class="value"><?php
echo I18N::plural('%s year', '%s years', $general_stats['mean_gen_time'], I18N::number($general_stats['mean_gen_time'], 1));
?>
</div>
</div>
</div>
<h3><?php
echo I18N::translate('Statistics by generations');
?>
</h3>
<table class="maj-table">
<thead>
<tr class="maj-row">
<th class="label" colspan="2" > </th>
<th class="label help_tooltip" title="<?php
echo I18N::translate('Theoretical number of ancestors in generation G.');
?>
">
//.........这里部分代码省略.........
示例9: htmlAnalysisData
/**
* {@inheritDoc}
* @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisTabGeneralView::htmlAnalysisData()
*/
protected function htmlAnalysisData()
{
/** @var OutlineMap $map */
$map = $this->data->get('map');
$canvas = $map->getCanvas();
$subdvisions_results = $this->data->get('results_by_subdivisions');
$nb_found = $this->data->get('stats_gen_nb_found');
$nb_other = $this->data->get('stats_gen_nb_other');
$html = '<script>
var tip = null;
var tipText = "";
var over = false;
var isin = false;
function addTip(node, txt){
jQuery(node).bind({
mouseover : function(){
oldisin = isin;
isin = true;
if(oldisin != isin){
tipText = txt;
tip.stop(true, true).fadeIn();
over = true;
}
},
mouseout : function(){
oldisin = isin;
isin = false;
if(oldisin != isin){
tip.stop(true, true).fadeOut("fast");
over = false;
}
}
});
}
jQuery(document).ready(function() {
tip = $("#geodispersion_tip").hide();
var positionTab = jQuery("#geodispersion-tabs").offset();
jQuery("#geodispersion_map").mousemove(function(e){
if (over){
tip.css("left", e.pageX + 20 - positionTab.left).css("top", e.pageY + 20 - positionTab.top);
tip.html(tipText);
}
});
var paper = new Raphael(document.getElementById("geodispersion_map"), ' . $canvas->width . ', ' . $canvas->height . ');
var background = paper.rect(0, 0, ' . $canvas->width . ', ' . $canvas->height . ');
background.attr({"fill" : "' . $canvas->background_color . '", "stroke" : "' . $canvas->background_stroke . '", "stroke-width": 1, "stroke-linejoin": "round" });
var attr = { fill: "' . $canvas->default_color . '", stroke: "' . $canvas->default_stroke . '", "stroke-width": 1, "stroke-linejoin": "round" };
var map = {};
';
foreach ($subdvisions_results as $name => $location) {
$html .= 'map.area' . $location['id'] . ' = paper.path("' . $location['coord'] . '").attr(attr);';
if (isset($location['transparency'])) {
$textToolTip = '<strong>' . $location['displayname'] . '</strong><br/>';
if ($this->data->get('use_flags') && $location['flag'] != '') {
$textToolTip .= '<span class="geodispersion_flag">' . FunctionsPrint::htmlPlaceIcon($location['place'], $location['flag']) . '</span><br/>';
}
$textToolTip .= I18N::translate('%d individuals', $location['count']) . '<br/>' . I18N::percentage(Functions::safeDivision($location['count'], $nb_found - $nb_other), 1);
$html .= 'addTip(map.area' . $location['id'] . '.node, "' . Filter::escapeJs($textToolTip) . '");';
$html .= 'map.area' . $location['id'] . '.attr({"fill" : "' . $canvas->max_color . '", "fill-opacity" : ' . $location['transparency'] . ' });';
$html .= 'map.area' . $location['id'] . '.mouseover(function () {' . 'map.area' . $location['id'] . '.stop().animate({"fill" : "' . $canvas->hover_color . '", "fill-opacity" : 1}, 100, "linear");' . '});' . 'map.area' . $location['id'] . '.mouseout(function () {' . 'map.area' . $location['id'] . '.stop().animate({"fill" : "' . $canvas->max_color . '", "fill-opacity" : ' . $location['transparency'] . '}, 100, "linear");' . '});';
}
}
$html .= '});
</script>
<div id="geodispersion_map"></div>
<div id="geodispersion_tip"></div>';
return $html;
}
示例10: htmlGenerationTopPlacesRow
/**
* Returns the HTML code fo display a row of the Top Places found for a generation.
*
* @param array $data Data array
* @param int $analysis_level Level of subdivision of analysis
* @return string HTML code for Top Places row
*/
protected function htmlGenerationTopPlacesRow($data, $analysis_level)
{
$tmp_places = array();
$sum_gen = $data['sum'];
$other = $data['other'];
foreach ($data['places'] as $placename => $count) {
if ($placename != 'other') {
$levels = array_map('trim', explode(',', $placename));
$placename = '<span title="' . implode(I18N::$list_separator, array_reverse($levels)) . '">' . $levels[$analysis_level - 1] . '</span>';
} else {
$placename = I18N::translate('Other places');
}
$tmp_places[] = I18N::translate('<strong>%s</strong> [%d - %s]', $placename, $count, I18N::percentage(Functions::safeDivision($count, $sum_gen + $other), 1));
}
return implode(I18N::$list_separator, $tmp_places);
}
示例11: renderContent
//.........这里部分代码省略.........
">
<?php
echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($tmp->getShortName());
?>
</a>
<?php
}
?>
</td>
<?php
if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) {
$isBSourced = $dperson->isBirthSourced();
?>
<td><?php
echo FunctionsPrint::formatIsSourcedIcon('E', $isBSourced, 'BIRT', 1, 'medium');
?>
</td>
<td><?php
echo $isBSourced;
?>
</td>
<?php
} else {
?>
<td> </td>
<td></td>
<?php
}
?>
<td><?php
echo $person->getSex();
?>
</td>
</tr>
<?php
}
?>
</tbody>
<tfoot>
<tr>
<td class="ui-state-default" colspan="16">
<div class="center">
<?php
echo I18N::translate('Number of different missing ancestors: %s', I18N::number($this->data->get('missing_diff_count')));
?>
<?php
if ($this->data->get('missing_hidden') > 0) {
echo ' [' . I18N::translate('%s hidden', I18N::number($this->data->get('missing_hidden'))) . ']';
}
?>
<?php
echo ' - ' . I18N::translate('Generation complete at %s', I18N::percentage($this->data->get('perc_sosa'), 2));
?>
<?php
echo ' [' . I18N::translate('Potential %s', I18N::percentage($this->data->get('perc_sosa_potential'), 2)) . ']';
?>
</div>
</td>
</tr>
</tfoot>
</table>
<?php
} else {
if ($this->data->get('generation', 0) > 0) {
?>
<p><?php
echo I18N::translate('No ancestors are missing for this generation. Generation complete at %s.', I18N::percentage($this->data->get('perc_sosa'), 2));
?>
</p>
<?php
}
}
} else {
?>
<p class="warning"><?php
echo I18N::translate('The list could not be displayed. Reasons might be:');
?>
<br/>
<ul>
<li><?php
echo I18N::translate('No Sosa root individual has been defined.');
?>
</li>
<li><?php
echo I18N::translate('The Sosa ancestors have not been computed yet.');
?>
</li>
<li><?php
echo I18N::translate('No generation were found.');
?>
</li>
</ul>
</p>
<?php
}
?>
</div>
<?php
}