本文整理汇总了PHP中WT_I18N::reverseText方法的典型用法代码示例。如果您正苦于以下问题:PHP WT_I18N::reverseText方法的具体用法?PHP WT_I18N::reverseText怎么用?PHP WT_I18N::reverseText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WT_I18N
的用法示例。
在下文中一共展示了WT_I18N::reverseText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: embedText
function embedText($im, $text, $maxsize, $color, $font, $vpos, $hpos)
{
global $useTTF;
// there are two ways to embed text with PHP
// (preferred) using GD and FreeType you can embed text using any True Type font
// (fall back) if that is not available, you can insert basic monospaced text
if ($useTTF) {
// imagettftext is available, make sure the requested font exists
if (!isset($font) || $font == '' || !file_exists(WT_ROOT . 'includes/fonts/' . $font)) {
$font = 'DejaVuSans.ttf';
// this font ships with webtrees
if (!file_exists(WT_ROOT . 'includes/fonts/' . $font)) {
$useTTF = false;
}
}
}
# no errors if an invalid color string was passed in, just strange colors
$col = explode(",", $color);
$textcolor = @imagecolorallocate($im, $col[0], $col[1], $col[2]);
// paranoia is good! make sure all variables have a value
if (!isset($vpos) || $vpos != "top" && $vpos != "middle" && $vpos != "bottom" && $vpos != "across") {
$vpos = "middle";
}
if ($vpos == "across" && (!isset($hpos) || $hpos != "left" && $hpos != "right" && $hpos != "top2bottom" && $hpos != "bottom2top")) {
$hpos = "left";
}
// make adjustments to settings that imagestring and imagestringup can’t handle
if (!$useTTF) {
// imagestringup only writes up, can’t use top2bottom
if ($hpos == "top2bottom") {
$hpos = "bottom2top";
}
}
$text = WT_I18N::reverseText($text);
$height = imagesy($im);
$width = imagesx($im);
$calc_angle = rad2deg(atan($height / $width));
$hypoth = $height / sin(deg2rad($calc_angle));
// vertical and horizontal position of the text
switch ($vpos) {
case "top":
$taille = textlength($maxsize, $width, $text);
$pos_y = $height * 0.15 + $taille;
$pos_x = $width * 0.15;
$rotation = 0;
break;
case "middle":
$taille = textlength($maxsize, $width, $text);
$pos_y = ($height + $taille) / 2;
$pos_x = $width * 0.15;
$rotation = 0;
break;
case "bottom":
$taille = textlength($maxsize, $width, $text);
$pos_y = $height * 0.85 - $taille;
$pos_x = $width * 0.15;
$rotation = 0;
break;
case "across":
switch ($hpos) {
case "left":
$taille = textlength($maxsize, $hypoth, $text);
$pos_y = $height * 0.85 - $taille;
$pos_x = $width * 0.15;
$rotation = $calc_angle;
break;
case "right":
$taille = textlength($maxsize, $hypoth, $text);
$pos_y = $height * 0.15 - $taille;
$pos_x = $width * 0.85;
$rotation = $calc_angle + 180;
break;
case "top2bottom":
$taille = textlength($maxsize, $height, $text);
$pos_y = $height * 0.15 - $taille;
$pos_x = $width * 0.9 - $taille;
$rotation = -90;
break;
case "bottom2top":
$taille = textlength($maxsize, $height, $text);
$pos_y = $height * 0.85;
$pos_x = $width * 0.15;
$rotation = 90;
break;
}
break;
default:
}
// apply the text
if ($useTTF) {
// if imagettftext throws errors, catch them with a custom error handler
set_error_handler("imagettftextErrorHandler");
imagettftext($im, $taille, $rotation, $pos_x, $pos_y, $textcolor, 'includes/fonts/' . $font, $text);
restore_error_handler();
}
// Don’t use an ‘else’ here since imagettftextErrorHandler may have changed the value of $useTTF from true to false
if (!$useTTF) {
if ($rotation != 90) {
imagestring($im, 5, $pos_x, $pos_y, $text, $textcolor);
} else {
//.........这里部分代码省略.........
示例2: generate_fan_chart
/**
* Generate both the HTML and PNG components of the fan chart
*
* The HTML and PNG components both require the same co-ordinate calculations,
* so we generate them using the same code, but we send them in separate
* HTTP requests.
*
* @param string $what "png" or "html"
* @param string[] $fanChart Presentation parameters, provided by the theme.
*
* @return string
*/
public function generate_fan_chart($what, $fanChart)
{
$treeid = ancestry_array($this->root->getXref(), $this->generations);
$fanw = 640 * $this->fan_width / 100;
$fandeg = 90 * $this->fan_style;
$html = '';
$treesize = count($treeid);
// generations count
$gen = log($treesize) / log(2) - 1;
$sosa = $treesize - 1;
// fan size
if ($fandeg == 0) {
$fandeg = 360;
}
$fandeg = min($fandeg, 360);
$fandeg = max($fandeg, 90);
$cx = $fanw / 2 - 1;
// center x
$cy = $cx;
// center y
$rx = $fanw - 1;
$rw = $fanw / ($gen + 1);
$fanh = $fanw;
// fan height
if ($fandeg == 180) {
$fanh = round($fanh * ($gen + 1) / ($gen * 2));
}
if ($fandeg == 270) {
$fanh = round($fanh * 0.86);
}
$scale = $fanw / 640;
// image init
$image = ImageCreate($fanw, $fanh);
$white = ImageColorAllocate($image, 0xff, 0xff, 0xff);
ImageFilledRectangle($image, 0, 0, $fanw, $fanh, $white);
ImageColorTransparent($image, $white);
$color = ImageColorAllocate($image, hexdec(substr($fanChart['color'], 1, 2)), hexdec(substr($fanChart['color'], 3, 2)), hexdec(substr($fanChart['color'], 5, 2)));
$bgcolor = ImageColorAllocate($image, hexdec(substr($fanChart['bgColor'], 1, 2)), hexdec(substr($fanChart['bgColor'], 3, 2)), hexdec(substr($fanChart['bgColor'], 5, 2)));
$bgcolorM = ImageColorAllocate($image, hexdec(substr($fanChart['bgMColor'], 1, 2)), hexdec(substr($fanChart['bgMColor'], 3, 2)), hexdec(substr($fanChart['bgMColor'], 5, 2)));
$bgcolorF = ImageColorAllocate($image, hexdec(substr($fanChart['bgFColor'], 1, 2)), hexdec(substr($fanChart['bgFColor'], 3, 2)), hexdec(substr($fanChart['bgFColor'], 5, 2)));
// imagemap
$imagemap = '<map id="fanmap" name="fanmap">';
// loop to create fan cells
while ($gen >= 0) {
// clean current generation area
$deg2 = 360 + ($fandeg - 180) / 2;
$deg1 = $deg2 - $fandeg;
ImageFilledArc($image, $cx, $cy, $rx, $rx, $deg1, $deg2, $bgcolor, IMG_ARC_PIE);
$rx -= 3;
// calculate new angle
$p2 = pow(2, $gen);
$angle = $fandeg / $p2;
$deg2 = 360 + ($fandeg - 180) / 2;
$deg1 = $deg2 - $angle;
// special case for rootid cell
if ($gen == 0) {
$deg1 = 90;
$deg2 = 360 + $deg1;
}
// draw each cell
while ($sosa >= $p2) {
$pid = $treeid[$sosa];
$person = WT_Individual::getInstance($pid);
if ($person) {
$name = $person->getFullName();
$addname = $person->getAddName();
$text = WT_I18N::reverseText($name);
if ($addname) {
$text .= "\n" . WT_I18N::reverseText($addname);
}
$text .= "\n" . WT_I18N::reverseText($person->getLifeSpan());
switch ($person->getSex()) {
case 'M':
$bg = $bgcolorM;
break;
case 'F':
$bg = $bgcolorF;
break;
case 'U':
$bg = $bgcolor;
break;
}
ImageFilledArc($image, $cx, $cy, $rx, $rx, $deg1, $deg2, $bg, IMG_ARC_PIE);
// split and center text by lines
$wmax = (int) ($angle * 7 / $fanChart['size'] * $scale);
$wmax = min($wmax, 35 * $scale);
if ($gen == 0) {
$wmax = min($wmax, 17 * $scale);
//.........这里部分代码省略.........