コード例 #1
0
ファイル: fontimage.php プロジェクト: p-2/wkw-theme
 /**
  * generates an image from arbitrary text.
  * @param string text to place on image
  * @param string file name
  * @return void
  */
 function generate($name, $overwrite = false)
 {
     $text = self::get_surname($name->sortkeyprefix);
     $filename = $name->pageid;
     $options = wkwThemeAdmin::get_datascape_options();
     /* get image path */
     $uploads_dir = wp_upload_dir();
     $namesDir = $uploads_dir["basedir"] . "/wkw-cache/names";
     $filename = $namesDir . "/" . $filename . ".png";
     if (file_exists($filename)) {
         if ($overwrite) {
             @unlink($filename);
         } else {
             return;
         }
     }
     /* settings */
     $fontPath = get_template_directory() . '/fonts/HandsomePro-Extended.ttf';
     $fontSize = $options["fontsize"];
     $textcolour = $name->urltitle ? wkwThemeAdmin::hex2RGB($options["names_colour"]) : wkwThemeAdmin::hex2RGB($options["names_colour_unlinked"]);
     /* get dimensions of image */
     $bbox = imagettfbbox($fontSize, 0, $fontPath, $text);
     $width = $bbox[4] + 24;
     $height = $fontSize * 2;
     /* set baseline */
     $y = $fontSize * 1.25;
     /* create image */
     $im = self::createImage($width, $height);
     /* set colour */
     $colour = imagecolorallocate($im, $textcolour["red"], $textcolour["green"], $textcolour["blue"]);
     /* Add the text */
     imagettftext($im, $fontSize, 0, 12, $y, $colour, $fontPath, $text);
     /* save image */
     imagepng($im, $filename, 9);
     /* clean up */
     imagedestroy($im);
 }
コード例 #2
0
ファイル: interface.php プロジェクト: p-2/wkw-theme
            $pageid = $name->pageid;
            $title = $name->title;
            $urltitle = $name->urltitle;
            $surname = $name->surname;
            $lastmod = $name->lastmod;
            break;
        }
    }
}
if (!$pageid) {
    /* get a random page if none specified */
    $rand_index = array_rand($all_names);
    header("Location: " . get_bloginfo("url") . "/names/" . $all_names[$rand_index]->urltitle);
    exit;
}
$datascape_options = wkwThemeAdmin::get_datascape_options();
?>
<!doctype html><!--[if IEMobile 7]><html class="no-js iem7"><![endif]-->
<!--[if (gt IEMobile 7)|!(IEMobile)]><!--><html class="no-js" lang="en"><!--<![endif]--><!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if (IE 7)&!(IEMobile)]><html class="no-js lt-ie9 lt-ie8" lang="en"><![endif]-->
<!--[if (IE 8)&!(IEMobile)]><html class="no-js lt-ie9" lang="en"><![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"><!--<![endif]--><head>
<meta charset="<?php 
bloginfo('charset');
?>
" />
<title>Who Knew Whom</title>
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- main stylesheet -->