Skip to content

Commit

Permalink
templating changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kballenegger committed Apr 6, 2011
1 parent 39cd354 commit 295ede1
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 75 deletions.
37 changes: 37 additions & 0 deletions _body.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Van De Graaf Generator, by Kenneth Ballenegger</title>
<style type="text/css" media="screen">
#container {
width: 200px;
height: 200px;
margin: auto;
margin-top: 200px;
}
</style>
</head>

<body>

<div id="container">
<?=$content?>
</div>

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-215884-13']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>
36 changes: 0 additions & 36 deletions _prompt.tpl
Original file line number Diff line number Diff line change
@@ -1,43 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Van De Graaf Generator, by Kenneth Ballenegger</title>
<style type="text/css" media="screen">
#container {
width: 200px;
height: 200px;
margin: auto;
margin-top: 200px;
}
</style>
</head>

<body>

<div id="container">
<?if(!empty($message)):echo $message;endif;?>
<form action="index.php" method="post" accept-charset="utf-8">
<p>Width: <input type="text" name="width" value="0" id="width"></p>
<p>Height: <input type="text" name="height" value="0" id="height"></p>

<p><input type="submit" value="Continue &rarr;"></p>
</form>
</div>

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-215884-13']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>
36 changes: 0 additions & 36 deletions _response.tpl
Original file line number Diff line number Diff line change
@@ -1,41 +1,5 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Van De Graaf Generator, by Kenneth Ballenegger</title>
<style type="text/css" media="screen">
#container {
width: 200px;
height: 200px;
margin: auto;
margin-top: 200px;
}
</style>
</head>

<body>

<div id="container">
<p>Here's your margins, buddy!</p>
<p>Top: <?=$top?></p>
<p>Bottom: <?=$bottom?></p>
<p>Inside: <?=$inside?></p>
<p>Outside: <?=$outside?></p>
</div>

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-215884-13']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>
11 changes: 8 additions & 3 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
require_once 'attemplate.inc.php';
require_once 'vdg.php';

if (empty($_POST['width']) || empty($_POST['height'])
|| !is_numeric($_POST['width']) || !is_numeric($_POST['height'])) {
if (empty($_POST['width']) && empty($_POST['height'])) {
$template = new ATTemplate(array());
echo $template->parse('_prompt.tpl');
} else if (empty($_POST['width']) || empty($_POST['height'])
|| !is_numeric($_POST['width']) || !is_numeric($_POST['height'])) {
$template = new ATTemplate(array('message' => 'Something went wrong!'));
$out_tpl = ATTemplate(array('content' => $template->parse('_prompt.tpl')))
echo $out_tpl->parse('_body.tpl');
} else {
$width = $_POST['width'];
$height = $_POST['height'];
Expand All @@ -17,5 +21,6 @@
'inside' => $inside,
'outside' => $outside
));
echo $template->parse('_response.tpl');
$out_tpl = ATTemplate(array('content' => $template->parse('_response.tpl')))
echo $out_tpl->parse('_body.tpl');
}

0 comments on commit 295ede1

Please sign in to comment.