diff options
| -rw-r--r-- | categories.php | 66 | ||||
| -rw-r--r-- | categoryedit.php | 71 | ||||
| -rw-r--r-- | contact.php | 41 | ||||
| -rw-r--r-- | index.php | 43 | ||||
| -rw-r--r-- | login.php | 52 | ||||
| -rw-r--r-- | productdetails.php | 80 | ||||
| -rw-r--r-- | productedit.php | 108 | ||||
| -rw-r--r-- | products.php | 74 | ||||
| -rw-r--r-- | templates/categories.tpl | 35 | ||||
| -rw-r--r-- | templates/categoryedit.tpl | 36 | ||||
| -rw-r--r-- | templates/contact.tpl | 16 | ||||
| -rw-r--r-- | templates/index.tpl | 17 | ||||
| -rw-r--r-- | templates/layout.tpl | 19 | ||||
| -rw-r--r-- | templates/login.tpl | 32 | ||||
| -rw-r--r-- | templates/productdetails.tpl | 49 | ||||
| -rw-r--r-- | templates/productedit.tpl | 66 | ||||
| -rw-r--r-- | templates/products.tpl | 36 |
17 files changed, 389 insertions, 452 deletions
diff --git a/categories.php b/categories.php index 0425ec1..7760655 100644 --- a/categories.php +++ b/categories.php @@ -1,63 +1,11 @@ <?php session_start(); -?> -<!DOCTYPE html> -<html> -<head> -<meta charset="UTF-8"> -<title>Categories</title> -<link rel="stylesheet" type="text/css" href="styles/style.css"> -</head> -<body> -<header><h1>Categories</h1></header> -<nav> -<dl> -<dt><a href="contact.php">Contact us</a></dt> -<dt><a href=".">Home</a></dt> -<?php -if(isset($_SESSION['username'])) -{ - echo "<dt><a href=\"login.php?logout\">Logout</a></dt>"; - $username = $_SESSION['username']; -} -else -{ - echo "<dt><a href=\"login.php\">Login</a></dt>"; -} -?> -</dl> -</nav> -<div id="content"> -<table> -<?php - require_once('vendor.inc.php'); +require_once('vendor.inc.php'); + +$smarty = new Smarty; - $categories = CategoryQuery::create()->find(); +$smarty->assign('loggedin', isset($_SESSION['username'])); +$smarty->assign('categories', CategoryQuery::create()->find()); - foreach( $categories as $category ){ - echo "<tr>"; - echo "<td><a href=\"products.php?id={$category->getId()}\">{$category->getName()}</a></td>"; - echo "<td>{$category->getDescription()}</td>"; - if(isset($username)) - { - echo "<td><a href=\"categoryedit.php?modify={$category->getId()}\">Edit</a></td>"; - echo "<td><a href=\"categoryedit.php?delete={$category->getId()}\" onClick=\"return confirm('Confirm deletion.')\">Delete</a></td>"; - } - echo "</tr>"; - } - if(isset($username)) - { - echo "<tr>"; - echo "<td></td>"; - echo "<td></td>"; - echo "<td></td>"; - echo "<td><a href=\"categoryedit.php?add\">Add</a></td>"; - echo "</tr>"; - } -?> -</table> -<div class="spacer"></div> -</div> -<footer>Copyright by SomeCompany Ltd.</footer> -</body> -</html>
\ No newline at end of file +$smarty->display('categories.tpl'); +?>
\ No newline at end of file diff --git a/categoryedit.php b/categoryedit.php index 6d83ee7..a3fb140 100644 --- a/categoryedit.php +++ b/categoryedit.php @@ -1,12 +1,12 @@ <?php session_start(); + require_once('vendor.inc.php'); + if(!isset($_SESSION['username'])) { header('Location: categories.php'); } - require_once('vendor.inc.php'); - if(isset($_GET['delete'])) { $category = CategoryQuery::create()->findOneById($_GET['delete']); @@ -37,61 +37,12 @@ $category->save(); header('Location: categories.php'); } -?> -<!DOCTYPE html> -<html> -<head> -<meta charset="UTF-8"> -<title>Category</title> -<link rel="stylesheet" type="text/css" href="styles/style.css"> -</head> -<body> - <header><h1><?php echo $category->getName(); ?></h1></header> - <nav> - <dl> - <dt><a href="contact.php">Contact us</a></dt> - <dt><a href=".">Home</a></dt> - <dt><a href="categories.php">Back</a></dt> - <?php - if(isset($_SESSION['username'])) - { - echo "<dt><a href=\"login.php?logout\">Logout</a></dt>"; - $username = $_SESSION['username']; - } - else - { - echo "<dt><a href=\"login.php\">Login</a></dt>"; - } - ?> - </dl> - </nav> - <div id="content"> - <form action="categoryedit.php?<?php echo "{$type}={$category->getId()}" ?>" method="post"> - <h1>Category</h1> - <div class="row"> - <label for="name"><u>N</u>ame:</label> <input class="formw" type="text" - placeholder="Name" id="name" name="name" accesskey="n" - maxlength="100" value="<?php echo $category->getName(); ?>"> - </div> - <div class="row"> - <label for="desc"><u>D</u>escription:</label> - <textarea class="formw" placeholder="Description" id="desc" name="desc" - accesskey="d" maxlength="1000"><?php echo $category->getDescription(); ?></textarea> - </div> - <div class="spacer"> - - </div> - <button type="submit"> - <?php - echo ucfirst($type); - ?> - </button> - <button type="reset"> - Reset - </button> - </form> - <div class="spacer"></div> - </div> - <footer>Copyright by SomeCompany Ltd.</footer> -</body> -</html>
\ No newline at end of file + + $smarty = new Smarty; + + $smarty->assign('loggedin', isset($_SESSION['username'])); + $smarty->assign('category', $category); + $smarty->assign('type', $type); + + $smarty->display('categoryedit.tpl'); +?>
\ No newline at end of file diff --git a/contact.php b/contact.php index 85fc9dc..9b9384c 100644 --- a/contact.php +++ b/contact.php @@ -1,35 +1,10 @@ <?php session_start(); -?> -<!DOCTYPE html> -<html> -<head> -<meta charset="UTF-8"> -<title>Contact Us</title> -<link rel="stylesheet" type="text/css" href="styles/style.css"> -</head> -<body> - <header><h1>Contact us</h1></header> - <nav> - <dl> - <dt><a href=".">Home</a></dt> - <dt><a href="categories.php">Categories</a></dt> - <?php - if(isset($_SESSION['username'])) - { - echo "<dt><a href=\"login.php?logout\">Logout</a></dt>"; - } - else - { - echo "<dt><a href=\"login.php\">Login</a></dt>"; - } - ?> - </dl> - </nav> - <div id="content"> - <p>Name: SomeCompany Ltd.<br>Telephone: +1-555-6383<br>Address: SomeStreet in Alamo</p> - <div class="spacer"></div> - </div> - <footer>Copyright by SomeCompany Ltd.</footer> -</body> -</html>
\ No newline at end of file +require_once('vendor.inc.php'); + +$smarty = new Smarty; + +$smarty->assign('loggedin', isset($_SESSION['username'])); + +$smarty->display('contact.tpl'); +?>
\ No newline at end of file @@ -1,36 +1,11 @@ <?php session_start(); -?> -<!DOCTYPE html> -<html> -<head> -<meta charset="UTF-8"> -<title>Home</title> -<link rel="stylesheet" type="text/css" href="styles/style.css"> -</head> -<body> - <header><h1>Home</h1></header> - <nav> - <dl> - <dt><a href="contact.php">Contact us</a></dt> - <dt><a href="categories.php">Categories</a></dt> - <?php - if(isset($_SESSION['username'])) - { - echo "<dt><a href=\"login.php?logout\">Logout</a></dt>"; - } - else - { - echo "<dt><a href=\"login.php\">Login</a></dt>"; - } - ?> - </dl> - </nav> - <div id="content"> - <p>This site will rock your chair. The best products from all over the world. - Furniture the like you have never seen. Contact us a get our catalog or login a order direct from our categories.</p> - <div class="spacer"></div> - </div> - <footer>Copyright by SomeCompany Ltd.</footer> -</body> -</html>
\ No newline at end of file + +require_once('vendor.inc.php'); + +$smarty = new Smarty; + +$smarty->assign('loggedin', isset($_SESSION['username'])); + +$smarty->display('index.tpl'); +?>
\ No newline at end of file @@ -1,5 +1,7 @@ <?php session_start(); + require_once('vendor.inc.php'); + if(isset($_GET['logout'])) { session_destroy(); @@ -13,8 +15,7 @@ { $username = $_POST['username']; $password = $_POST['password']; - require_once('vendor.inc.php'); - + $user = UserQuery::create()->findOneByUsername($username); if ( !is_object($user) ) { @@ -26,45 +27,8 @@ } header('Location: .'); } -?> -<!DOCTYPE html> -<html> -<head> -<meta charset="UTF-8"> -<title>User</title> -<link rel="stylesheet" type="text/css" href="styles/style.css"> -</head> -<body> - <header><h1>Customer login</h1></header> - <nav> - <dl> - <dt><a href="contact.php">Contact us</a></dt> - <dt><a href="categories.php">Categories</a></dt> - <dt><a href=".">Home</a></dt> - </dl> - </nav> - <div id="content"> - <form action="login.php" method="post"> - <h1>User</h1> - <div class="row"> - <label for="username"><u>U</u>sername:</label><input class="formw" type="text" - placeholder="Username" id="username" name="username" accesskey="u" - maxlength="100"> - </div> - <div class="row"> - <label for="password"><u>P</u>assword:</label><input class="formw" type="password" - placeholder="Password" id="password" name="password" accesskey="p"> - </div> - <div class="spacer"> </div> - <button type="submit" accesskey="l"> - <u>L</u>ogin - </button> - <button type="reset" accesskey="r"> - <u>R</u>eset - </button> - </form> - <div class="spacer"></div> - </div> - <footer>Copyright by SomeCompany Ltd.</footer> -</body> -</html>
\ No newline at end of file + + $smarty = new Smarty; + + $smarty->display('login.tpl'); +?>
\ No newline at end of file diff --git a/productdetails.php b/productdetails.php index 44f3e04..33fc6f5 100644 --- a/productdetails.php +++ b/productdetails.php @@ -1,5 +1,7 @@ <?php session_start(); +require_once('vendor.inc.php'); + if(isset($_GET['id'])) { $id = $_GET['id']; @@ -12,7 +14,6 @@ if(isset($_GET['catid'])) { $catid = $_GET['catid']; } -require_once('vendor.inc.php'); $product = ProductQuery::create()->findOneById($id); @@ -20,69 +21,14 @@ if ( !is_object($product) ) { header('Location: categories.php'); } -?> -<!DOCTYPE html> -<html> -<head> -<meta charset="UTF-8"> -<title>Productdetails</title> -<link rel="stylesheet" type="text/css" href="styles/style.css"> -</head> -<body> - <header><h1><?php echo $product->getName(); ?></h1></header> - <nav> - <dl> - <dt><a href="contact.php">Contact us</a></dt> - <dt><a href=".">Home</a></dt> - <dt><a href="categories.php">Categories</a></dt> - <dt><a href="products.php?id=<?php echo $catid; ?>">Back to Category</a></dt> - <?php - if(isset($_SESSION['username'])) - { - echo "<dt><a href=\"login.php?logout\">Logout</a></dt>"; - } - else - { - echo "<dt><a href=\"login.php\">Login</a></dt>"; - } - ?> - </dl> - </nav> - <div id="content"> - <form> - <div class="row"> - <label for="name"><u>N</u>ame:</label> - <input class="formw" type="text" - placeholder="Name" id="name" name="name" accesskey="n" - maxlength="100" readonly value="<?php echo $product->getName(); ?>"> - </div> - <div class="row"> - <label for="price"><u>P</u>rice (Euro):</label> - <input class="formw" type="text" - placeholder="Price (Euro)" id="price" name="price" accesskey="p" - maxlength="13" readonly value="<?php echo $product->getPrice(); ?>"> - </div> - <div class="row"> - <label for="width"><u>W</u>idth (mm):</label> - <input class="formw" type="text" - placeholder="Width (mm)" id="width" name="width" accesskey="w" - maxlength="11" readonly value="<?php echo $product->getWidth(); ?>"> - </div> - <div class="row"> - <label for="height"><u>H</u>eight (mm):</label> - <input class="formw" type="text" - placeholder="Height (mm)" id="height" name="height" accesskey="h" - maxlength="11" readonly value="<?php echo $product->getHeight(); ?>"> - </div> - <div class="row"> - <label for="desc"><u>D</u>escription:</label> - <textarea class="formw" placeholder="Description" id="desc" name="desc" - accesskey="d" maxlength="1000" readonly rows="5"><?php echo $product->getDescription(); ?></textarea> - </div> - <div class="spacer"> </div> - </form> - <div class="spacer"></div> - </div> - <footer>Copyright by SomeCompany Ltd.</footer> -</body> -</html>
\ No newline at end of file + +$smarty = new Smarty; + +$smarty->assign('loggedin', isset($_SESSION['username'])); +$smarty->assign('product', $product); +$smarty->assign('id', $id); +$smarty->assign('catid', $catid); + +$smarty->display('productdetails.tpl') + +?>
\ No newline at end of file diff --git a/productedit.php b/productedit.php index 2005444..0fd33e6 100644 --- a/productedit.php +++ b/productedit.php @@ -1,5 +1,7 @@ <?php session_start(); + require_once('vendor.inc.php'); + if(isset($_GET['catid'])) { $catid = $_GET['catid']; @@ -13,8 +15,6 @@ header("Location: product.php?id={$catid}"); } - require_once('vendor.inc.php'); - if(isset($_GET['delete'])) { $product = ProductQuery::create()->findOneById($_GET['delete']); @@ -58,95 +58,15 @@ $product->save(); header("Location: products.php?id={$catid}"); } -?> -<!DOCTYPE html> -<html> -<head> -<meta charset="UTF-8"> -<title>Production</title> -<link rel="stylesheet" type="text/css" href="styles/style.css"> -</head> -<body> - <header><h1><?php echo $product->getName(); ?></h1></header> - <nav> - <dl> - <dt><a href="contact.php">Contact us</a></dt> - <dt><a href=".">Home</a></dt> - <dt><a href="categories.php">Categories</a></dt> - <dt><a href="products.php?id=<?php echo $catid; ?>">Back</a></dt> - <?php - if(isset($_SESSION['username'])) - { - echo "<dt><a href=\"login.php?logout\">Logout</a></dt>"; - $username = $_SESSION['username']; - } - else - { - echo "<dt><a href=\"login.php\">Login</a></dt>"; - } - ?> - </dl> - </nav> - <div id="content"> - <form action="productedit.php?<?php echo "{$type}={$product->getId()}" ?>&catid=<?php echo $catid; ?>" method="post"> - <h1>Product</h1> - <div class="row"> - <label for="name"><u>N</u>ame:</label> - <input class="formw" type="text" - placeholder="Name" id="name" name="name" accesskey="n" - maxlength="100" value="<?php echo $product->getName(); ?>"> - </div> - <div class="row"> - <label for="price"><u>P</u>rice (Euro):</label> - <input class="formw" type="number" step="0.01" min="0" - placeholder="Price (Euro)" id="price" name="price" accesskey="p" - maxlength="13" value="<?php echo $product->getPrice(); ?>"> - </div> - <div class="row"> - <label for="width"><u>W</u>idth (mm):</label> - <input class="formw" type="number" - placeholder="Width (mm)" id="width" name="width" accesskey="w" - maxlength="11" value="<?php echo $product->getWidth(); ?>"> - </div> - <div class="row"> - <label for="height"><u>H</u>eight (mm):</label> - <input class="formw" type="number" - placeholder="Height (mm)" id="height" name="height" accesskey="h" - maxlength="11" value="<?php echo $product->getHeight(); ?>"> - </div> - <div class="row"> - <label for="desc"><u>D</u>escription:</label> - <textarea class="formw" placeholder="Description" id="desc" name="desc" - accesskey="d" maxlength="1000"><?php echo $product->getDescription(); ?></textarea> - </div> - <div class="row"> - <label for="cat"><u>C</u>ategories:</label> - <select multiple class="formw" id="cat" name="cat[]" accesskey="c"> - <?php - foreach (CategoryQuery::create()->find() as $category) - { - echo "<option value=\"{$category->getId()}\" "; - if($product->getCategories()->contains($category)) - { - echo "selected"; - } - echo ">{$category->getName()}</option>"; - } - ?> - </select> - </div> - <div class="spacer"> </div> - <button type="submit"> - <?php - echo ucfirst($type); - ?> - </button> - <button type="reset"> - Reset - </button> - </form> - <div class="spacer"></div> - </div> - <footer>Copyright by SomeCompany Ltd.</footer> -</body> -</html>
\ No newline at end of file + + $smarty = new Smarty; + + $smarty->assign('loggedin', isset($_SESSION['username'])); + $smarty->assign('catid', $catid); + $smarty->assign('product', $product); + $smarty->assign('allCategories', CategoryQuery::create()->find()); + $smarty->assign('type', $type); + + $smarty->display('productedit.tpl'); + +?>
\ No newline at end of file diff --git a/products.php b/products.php index 6e4d2bd..a737109 100644 --- a/products.php +++ b/products.php @@ -1,5 +1,7 @@ <?php session_start(); +require_once('vendor.inc.php'); + if(isset($_GET['id'])) { $id = $_GET['id']; @@ -8,70 +10,20 @@ else { header('Location: categories.php'); } -require_once('vendor.inc.php'); $category = CategoryQuery::create()->findOneById($id); if ( !is_object($category) ) { header('Location: categories.php'); } -$products = $category->getProducts(); -?> -<!DOCTYPE html> -<html> -<head> -<meta charset="UTF-8"> -<title>Products</title> -<link rel="stylesheet" type="text/css" href="styles/style.css"> -</head> -<body> -<header><h1><?php echo $category->getName(); ?></h1></header> -<nav> -<dl> -<dt><a href="contact.php">Contact us</a></dt> -<dt><a href=".">Home</a></dt> -<dt><a href="categories.php">Categories</a></dt> -<?php -if(isset($_SESSION['username'])) -{ - echo "<dt><a href=\"login.php?logout\">Logout</a></dt>"; - $username = $_SESSION['username']; -} -else -{ - echo "<dt><a href=\"login.php\">Login</a></dt>"; -} -?> -</dl> -</nav> -<div id="content"> -<table> -<?php -foreach( $products as $product ){ - echo "<tr>"; - echo "<td><a href=\"productdetails.php?id={$product->getId()}&catid={$id}\">{$product->getName()}</a></td>"; - echo "<td>{$product->getDescription()}</td>"; - if(isset($username)) - { - echo "<td><a href=\"productedit.php?modify={$product->getId()}&catid={$id}\">Edit</a></td>"; - echo "<td><a href=\"productedit.php?delete={$product->getId()}&catid={$id}\" onClick=\"return confirm('Confirm deletion.')\">Delete</a></td>"; - } - echo "</tr>"; - -} -if(isset($username)) -{ - echo "<tr>"; - echo "<td></td>"; - echo "<td></td>"; - echo "<td></td>"; - echo "<td><a href=\"productedit.php?add&catid={$id}\">Add</a></td>"; - echo "</tr>"; -} -?> -</table> -<div class="spacer"></div> -</div> -<footer>Copyright by SomeCompany Ltd.</footer> -</body> -</html>
\ No newline at end of file + +$smarty = new Smarty; + +$smarty->assign('loggedin', isset($_SESSION['username'])); +$smarty->assign('products', $category->getProducts()); +$smarty->assign('category', $category->getName()); +$smarty->assign('id', $id); + +$smarty->display('products.tpl'); + +?>
\ No newline at end of file diff --git a/templates/categories.tpl b/templates/categories.tpl new file mode 100644 index 0000000..11162a6 --- /dev/null +++ b/templates/categories.tpl @@ -0,0 +1,35 @@ +{extends file="layout.tpl"} +{block name=title}Categories{/block} +{block name=navigation} +<dl> + <dt><a href="contact.php">Contact us</a></dt> + <dt><a href=".">Home</a></dt> + {if $loggedin} + <dt><a href="login.php?logout">Logout</a></dt> + {else} + <dt><a href="login.php">Login</a></dt> + {/if} +</dl> +{/block} +{block name=content} +<table> + {foreach from=$categories item=category} + <tr> + <td><a href="products.php?id={$category->getId()}">{$category->getName()}</a></td> + <td>{$category->getDescription()}</td> + {if $loggedin} + <td><a href="categoryedit.php?modify={$category->getId()}">Edit</a></td> + <td><a href="categoryedit.php?delete={$category->getId()}" onClick="return confirm('Confirm deletion.')">Delete</a></td> + {/if} + </tr> + {/foreach} + {if $loggedin} + <tr> + <td></td> + <td></td> + <td></td> + <td><a href="categoryedit.php?add">Add</a></td> + </tr> + {/if} +</table> +{/block}
\ No newline at end of file diff --git a/templates/categoryedit.tpl b/templates/categoryedit.tpl new file mode 100644 index 0000000..c02962d --- /dev/null +++ b/templates/categoryedit.tpl @@ -0,0 +1,36 @@ +{extends file="layout.tpl"} +{block name=title}{$category->getName()}{/block} +{block name=navigation} +<dl> + <dt><a href="contact.php">Contact us</a></dt> + <dt><a href=".">Home</a></dt> + <dt><a href="categories.php">Back</a></dt> + {if $loggedin} + <dt><a href="login.php?logout">Logout</a></dt> + {else} + <dt><a href="login.php">Login</a></dt> + {/if} +</dl> +{/block} +{block name=content} +<form action="categoryedit.php?{$type}={$category->getId()}" method="post"> + <h1>Category</h1> + <div class="row"> + <label for="name"><u>N</u>ame:</label> <input class="formw" type="text" + placeholder="Name" id="name" name="name" accesskey="n" + maxlength="100" value="{$category->getName()}"> + </div> + <div class="row"> + <label for="desc"><u>D</u>escription:</label> + <textarea class="formw" placeholder="Description" id="desc" name="desc" + accesskey="d" maxlength="1000">{$category->getDescription()}</textarea> + </div> + <div class="spacer"> </div> + <button type="submit"> + {$type|capitalize} + </button> + <button type="reset"> + Reset + </button> +</form> +{/block}
\ No newline at end of file diff --git a/templates/contact.tpl b/templates/contact.tpl new file mode 100644 index 0000000..b8bf0d3 --- /dev/null +++ b/templates/contact.tpl @@ -0,0 +1,16 @@ +{extends file="layout.tpl"} +{block name=title}Contact us{/block} +{block name=navigation} +<dl> + <dt><a href=".">Home</a></dt> + <dt><a href="categories.php">Categories</a></dt> + {if $loggedin} + <dt><a href="login.php?logout">Logout</a></dt> + {else} + <dt><a href="login.php">Login</a></dt> + {/if} +</dl> +{/block} +{block name=content} +<p>Name: SomeCompany Ltd.<br>Telephone: +1-555-6383<br>Address: SomeStreet in Alamo</p> +{/block}
\ No newline at end of file diff --git a/templates/index.tpl b/templates/index.tpl new file mode 100644 index 0000000..d787033 --- /dev/null +++ b/templates/index.tpl @@ -0,0 +1,17 @@ +{extends file="layout.tpl"} +{block name=title}Home Page{/block} +{block name=navigation} +<dl> + <dt><a href="contact.php">Contact us</a></dt> + <dt><a href="categories.php">Categories</a></dt> + {if $loggedin} + <dt><a href="login.php?logout">Logout</a></dt> + {else} + <dt><a href="login.php">Login</a></dt> + {/if} +</dl> +{/block} +{block name=content} +<p>This site will rock your chair. The best products from all over the world. +Furniture the like you have never seen. Contact us a get our catalog or login a order direct from our categories.</p> +{/block}
\ No newline at end of file diff --git a/templates/layout.tpl b/templates/layout.tpl new file mode 100644 index 0000000..bd623a1 --- /dev/null +++ b/templates/layout.tpl @@ -0,0 +1,19 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="UTF-8"> +<title>{block name=title}Untitled Page{/block}</title> +<link rel="stylesheet" type="text/css" href="styles/style.css"> +</head> +<body> + <header><h1>{block name=title}Untitled Page{/block}</h1></header> + <nav> + {block name=navigation}Error loading{/block} + </nav> + <div id="content"> + {block name=content}Error loading{/block} + <div class="spacer"></div> + </div> + <footer>Copyright by SomeCompany Ltd. Powered by PropelORM and Smarty.</footer> +</body> +</html>
\ No newline at end of file diff --git a/templates/login.tpl b/templates/login.tpl new file mode 100644 index 0000000..c2bb0a2 --- /dev/null +++ b/templates/login.tpl @@ -0,0 +1,32 @@ +{extends file="layout.tpl"} +{block name=title}Login{/block} +{block name=navigation} +<dl> + <dt><a href="contact.php">Contact us</a></dt> + <dt><a href="categories.php">Categories</a></dt> + <dt><a href=".">Home</a></dt> +</dl> +{/block} +{block name=content} +<form action="login.php" method="post"> + <h1>{block name=title}{/block}</h1> + <div class="row"> + <label for="username"><u>U</u>sername:</label> + <input class="formw" type="text" + placeholder="Username" id="username" name="username" accesskey="u" + maxlength="100"> + </div> + <div class="row"> + <label for="password"><u>P</u>assword:</label> + <input class="formw" type="password" + placeholder="Password" id="password" name="password" accesskey="p"> + </div> + <div class="spacer"> </div> + <button type="submit" accesskey="l"> + <u>L</u>ogin + </button> + <button type="reset" accesskey="r"> + <u>R</u>eset + </button> +</form> +{/block}
\ No newline at end of file diff --git a/templates/productdetails.tpl b/templates/productdetails.tpl new file mode 100644 index 0000000..b850c7d --- /dev/null +++ b/templates/productdetails.tpl @@ -0,0 +1,49 @@ +{extends file="layout.tpl"} +{block name=title}{$product->getName()}{/block} +{block name=navigation} +<dl> + <dt><a href="contact.php">Contact us</a></dt> + <dt><a href=".">Home</a></dt> + <dt><a href="categories.php">Categories</a></dt> + <dt><a href="products.php?id={$catid}">Back to Category</a></dt> + {if $loggedin} + <dt><a href="login.php?logout">Logout</a></dt> + {else} + <dt><a href="login.php">Login</a></dt> + {/if} +</dl> +{/block} +{block name=content} +<form> + <div class="row"> + <label for="name"><u>N</u>ame:</label> + <input class="formw" type="text" + placeholder="Name" id="name" name="name" accesskey="n" + maxlength="100" readonly value="{$product->getName()}"> + </div> + <div class="row"> + <label for="price"><u>P</u>rice (Euro):</label> + <input class="formw" type="text" + placeholder="Price (Euro)" id="price" name="price" accesskey="p" + maxlength="13" readonly value="{$product->getPrice()}"> + </div> + <div class="row"> + <label for="width"><u>W</u>idth (mm):</label> + <input class="formw" type="text" + placeholder="Width (mm)" id="width" name="width" accesskey="w" + maxlength="11" readonly value="{$product->getWidth()}"> + </div> + <div class="row"> + <label for="height"><u>H</u>eight (mm):</label> + <input class="formw" type="text" + placeholder="Height (mm)" id="height" name="height" accesskey="h" + maxlength="11" readonly value="{$product->getHeight()}"> + </div> + <div class="row"> + <label for="desc"><u>D</u>escription:</label> + <textarea class="formw" placeholder="Description" id="desc" name="desc" + accesskey="d" maxlength="1000" readonly rows="5">{$product->getDescription()}</textarea> + </div> + <div class="spacer"> </div> +</form> +{/block}
\ No newline at end of file diff --git a/templates/productedit.tpl b/templates/productedit.tpl new file mode 100644 index 0000000..ccd8483 --- /dev/null +++ b/templates/productedit.tpl @@ -0,0 +1,66 @@ +{extends file="layout.tpl"} +{block name=title}{$product->getName()}{/block} +{block name=navigation} +<dl> + <dt><a href="contact.php">Contact us</a></dt> + <dt><a href=".">Home</a></dt> + <dt><a href="categories.php">Categories</a></dt> + <dt><a href="products.php?id={$catid}">Back</a></dt> + {if $loggedin} + <dt><a href="login.php?logout">Logout</a></dt> + {else} + <dt><a href="login.php">Login</a></dt> + {/if} +</dl> +{/block} +{block name=content} +<form action="productedit.php?{$type}={$product->getId()}&catid={$catid}" method="post"> + <h1>{block name=title}{/block}</h1> + <div class="row"> + <label for="name"><u>N</u>ame:</label> + <input class="formw" type="text" + placeholder="Name" id="name" name="name" accesskey="n" + maxlength="100" value="{$product->getName()}"> + </div> + <div class="row"> + <label for="price"><u>P</u>rice (Euro):</label> + <input class="formw" type="number" step="0.01" min="0" + placeholder="Price (Euro)" id="price" name="price" accesskey="p" + maxlength="13" value="{$product->getPrice()}"> + </div> + <div class="row"> + <label for="width"><u>W</u>idth (mm):</label> + <input class="formw" type="number" + placeholder="Width (mm)" id="width" name="width" accesskey="w" + maxlength="11" value="{$product->getWidth()}"> + </div> + <div class="row"> + <label for="height"><u>H</u>eight (mm):</label> + <input class="formw" type="number" + placeholder="Height (mm)" id="height" name="height" accesskey="h" + maxlength="11" value="{$product->getHeight()}"> + </div> + <div class="row"> + <label for="desc"><u>D</u>escription:</label> + <textarea class="formw" placeholder="Description" id="desc" name="desc" + accesskey="d" maxlength="1000">{$product->getDescription()}</textarea> + </div> + <div class="row"> + <label for="cat"><u>C</u>ategories:</label> + <select multiple class="formw" id="cat" name="cat[]" accesskey="c"> + {foreach from=$allCategories item=category} + <option value="{$category->getId()}" + {if $product->getCategories()->contains($category)}selected{/if} + >{$category->getName()}</option> + {/foreach} + </select> + </div> + <div class="spacer"> </div> + <button type="submit"> + {$type|capitalize} + </button> + <button type="reset"> + Reset + </button> +</form> +{/block}
\ No newline at end of file diff --git a/templates/products.tpl b/templates/products.tpl new file mode 100644 index 0000000..dac8f0e --- /dev/null +++ b/templates/products.tpl @@ -0,0 +1,36 @@ +{extends file="layout.tpl"} +{block name=title}{$category}{/block} +{block name=navigation} +<dl> + <dt><a href="contact.php">Contact us</a></dt> + <dt><a href=".">Home</a></dt> + <dt><a href="categories.php">Categories</a></dt> + {if $loggedin} + <dt><a href="login.php?logout">Logout</a></dt> + {else} + <dt><a href="login.php">Login</a></dt> + {/if} +</dl> +{/block} +{block name=content} +<table> + {foreach from=$products item=product} + <tr> + <td><a href="productdetails.php?id={$product->getId()}&catid={$id}">{$product->getName()}</a></td> + <td>{$product->getDescription()}</td> + {if $loggedin} + <td><a href="productedit.php?modify={$product->getId()}&catid={$id}">Edit</a></td> + <td><a href="productedit.php?delete={$product->getId()}&catid={$id}" onClick="return confirm('Confirm deletion.')">Delete</a></td> + {/if} + </tr> + {/foreach} + {if $loggedin} + <tr> + <td></td> + <td></td> + <td></td> + <td><a href="productedit.php?add&catid={$id}">Add</a></td> + </tr> + {/if} +</table> +{/block}
\ No newline at end of file |
