Skip to content

Commit

Permalink
Merge pull request #5 from tonicospinelli/05-layout
Browse files Browse the repository at this point in the history
refactoring: isolating application layout
  • Loading branch information
tonicospinelli authored Jun 18, 2016
2 parents cd88321 + 1b3087e commit 4aa1c28
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 64 deletions.
9 changes: 9 additions & 0 deletions templates/layout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title><?php echo $title ?></title>
</head>
<body>
<?php echo $content ?>
</body>
</html>
63 changes: 32 additions & 31 deletions templates/products/list.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
<html>
<head></head>
<body>
<?php if (null !== $errormsg): ?>
<div class="alert error"><?php echo $errormsg; ?> </div>
<?php elseif (isset($product)): ?>
<div class="alert success"><?php echo $successmsg; ?></div>
<?php endif; ?>
<h3>Products</h3>
<table>
<thead>
<tr>
<th>ID</th>
<th>PRODUCT</th>
<th>UNIT PRICE</th>
<th>STOCK</th>
<th>ACTIONS</th>
</tr>
</thead>
<tbody>
<?php foreach ($products as $product): ?>
<?php $title = 'List of Producst' ?>

<?php ob_start() ?>
<h3>Products</h3>
<?php if (null !== $errormsg): ?>
<div class="alert error"><?php echo $errormsg; ?> </div>
<?php elseif (isset($product)): ?>
<div class="alert success"><?php echo $successmsg; ?></div>
<?php endif; ?>
<table>
<thead>
<tr>
<td><?php echo $product['id']; ?> </td>
<td><?php echo $product['name']; ?> </td>
<td><?php echo $product['unit_price']; ?> </td>
<td><?php echo $product['stock']; ?> </td>
<td><?php echo removeUrl('product.php', $product['id']); ?> </td>
<th>ID</th>
<th>PRODUCT</th>
<th>UNIT PRICE</th>
<th>STOCK</th>
<th>ACTIONS</th>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</body>
</html>
</thead>
<tbody>
<?php foreach ($products as $product): ?>
<tr>
<td><?php echo $product['id']; ?> </td>
<td><?php echo $product['name']; ?> </td>
<td><?php echo $product['unit_price']; ?> </td>
<td><?php echo $product['stock']; ?> </td>
<td><?php echo removeUrl('product.php', $product['id']); ?> </td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php $content = ob_get_clean() ?>

<?php include __DIR__.'/../layout.php' ?>
67 changes: 34 additions & 33 deletions templates/wishlists/list.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
<html>
<head></head>
<body>
<?php if (null !== $errormsg): ?>
<div class="alert error"><?php echo $errormsg; ?> </div>
<?php elseif (isset($wishItem)): ?>
<div class="alert success"><?php echo $successmsg; ?></div>
<?php endif; ?>
<h3>My Wish List</h3>
<table>
<thead>
<tr>
<th>ID</th>
<th>PRODUCT</th>
<th>STATUS</th>
<th>ACTIONS</th>
</tr>
</thead>
<tbody>
<?php foreach ($wishlist as $wish): ?>
<?php $title = 'My Wish List' ?>

<?php ob_start() ?>
<h3><?php echo $title;?></h3>
<?php if (null !== $errormsg): ?>
<div class="alert error"><?php echo $errormsg; ?> </div>
<?php elseif (isset($wishItem)): ?>
<div class="alert success"><?php echo $successmsg; ?></div>
<?php endif; ?>
<table>
<thead>
<tr>
<td><?php echo $wish['id']; ?> </td>
<td><?php echo $wish['product_name']; ?> </td>
<?php if ($wish['product_stock'] == 0): ?>
<td>Not Available</td>
<?php else: ?>
<td>Available</td>
<?php endif; ?>
<td><?php echo removeUrl('wishlist.php', $wish['id'], ['email' => $_GET['email']]); ?> </td>
<th>ID</th>
<th>PRODUCT</th>
<th>STATUS</th>
<th>ACTIONS</th>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</body>
</html>
</thead>
<tbody>
<?php foreach ($wishlist as $wish): ?>
<tr>
<td><?php echo $wish['id']; ?> </td>
<td><?php echo $wish['product_name']; ?> </td>
<?php if ($wish['product_stock'] == 0): ?>
<td>Not Available</td>
<?php else: ?>
<td>Available</td>
<?php endif; ?>
<td><?php echo removeUrl('wishlist.php', $wish['id'], ['email' => $_GET['email']]); ?> </td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php $content = ob_get_clean() ?>

<?php include __DIR__.'/../layout.php' ?>

0 comments on commit 4aa1c28

Please sign in to comment.