|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
alan Smarty Regular
Joined: 17 Apr 2003 Posts: 43
|
Posted: Wed Jan 28, 2004 6:44 pm Post subject: Cross-Browser Java Applet plugin |
|
|
Here's a little ditty I rattled up recently to help with embedding java applets into my templates...
Code: |
<?php
/* File: function.applet.php */
/**
**
** {applet width="..." height="..." code="..." codebase="..." [archive="..."] [param="..." ...]}
**
**/
function smarty_function_applet( $params, &$smarty )
{
//////
//
// width <integer> (required)
//
if (!isset($params['width']))
$smarty->trigger_error("applet: missing `width` parameter");
$width = trim($params['width']);
//////
//
// height <integer> (required)
//
if (!isset($params['height']))
$smarty->trigger_error("applet: missing `height` parameter");
$height = trim($params['height']);
//////
//
// code <string> (required)
//
if (!isset($params['code']))
$smarty->trigger_error("applet: missing `code` parameter");
$code = trim($params['code']);
//////
//
// codebase <string> (required)
//
if (!isset($params['codebase']))
$smarty->trigger_error("applet: missing `codebase` parameter");
$codebase = trim($params['codebase']);
//////
//
// archive <string> (optional)
//
if (isset($params['archive']))
$archive = trim($params['archive']);
//////
//
// user params (optional)
//
$list = array();
foreach ($params as $key => $value)
if (($key != "width") && ($key != "height") && ($key != "code") && ($key != "codebase") && ($key != "archive"))
$list[$key] = $value;
$params = $list;
//////
//
// Build result
//
$result = "<object classid = \"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93\" codebase=\"http://java.sun.com/products/plugin/autodl/jinstall-1_4-windows-i586.cab#Version=1,4,0,0\" width=\"$width\" height=\"$height\">";
$result .= "<param name=\"code\" value=\"$code\" />";
$result .= "<param name=\"codebase\" value=\"$codebase\" />";
if (isset($archive))
$result .= "<param name=\"archive\" value=\"$archive\" />";
$result .= "<param name=\"type\" value=\"application/x-java-applet;version=1.4\" />";
$result .= "<param name=\"scriptable\" value=\"false\" />";
foreach ($params as $name => $value)
$result .= "<param name=\"$name\" value=\"$value\" />";
$result .= "<comment>";
$result .= "<embed type=\"application/x-java-applet;version=1.4\" code=\"$code\" java_codebase=\"$codebase\" ";
if (isset($archive))
$result .= "archive=\"$archive\" ";
$result .= "width=\"$width\" height=\"$height\" ";
foreach ($params as $name => $value)
$result .= "$name=\"$value\" ";
$result .= "scriptable=\"false\" pluginspage=\"http://java.sun.com/products/plugin/index.html#download\">";
$result .= "<noembed>";
$result .= "</noembed>";
$result .= "</embed>";
$result .= "</comment>";
$result .= "</object>";
//////
//
// Return the result
//
return $result;
}
?>
|
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|