From af6dd5f8f9844596e85db25a8e97df9e08cb795c Mon Sep 17 00:00:00 2001 From: Stefan Suhren Date: Mon, 1 Jun 2015 18:46:12 +0200 Subject: Port alls sites to smarty and use the inheritance model --- categories.php | 66 +++----------------------- categoryedit.php | 71 +++++----------------------- contact.php | 41 ++++------------ index.php | 43 ++++------------- login.php | 52 ++++----------------- productdetails.php | 80 ++++++-------------------------- productedit.php | 108 ++++++------------------------------------- products.php | 74 ++++++----------------------- templates/categories.tpl | 35 ++++++++++++++ templates/categoryedit.tpl | 36 +++++++++++++++ templates/contact.tpl | 16 +++++++ templates/index.tpl | 17 +++++++ templates/layout.tpl | 19 ++++++++ templates/login.tpl | 32 +++++++++++++ templates/productdetails.tpl | 49 ++++++++++++++++++++ templates/productedit.tpl | 66 ++++++++++++++++++++++++++ templates/products.tpl | 36 +++++++++++++++ 17 files changed, 389 insertions(+), 452 deletions(-) create mode 100644 templates/categories.tpl create mode 100644 templates/categoryedit.tpl create mode 100644 templates/contact.tpl create mode 100644 templates/index.tpl create mode 100644 templates/layout.tpl create mode 100644 templates/login.tpl create mode 100644 templates/productdetails.tpl create mode 100644 templates/productedit.tpl create mode 100644 templates/products.tpl diff --git a/categories.php b/categories.php index 0425ec1..7760655 100644 --- a/categories.php +++ b/categories.php @@ -1,63 +1,11 @@ - - - - -Categories - - - -

Categories

- -
- -find(); +$smarty->assign('loggedin', isset($_SESSION['username'])); +$smarty->assign('categories', CategoryQuery::create()->find()); - foreach( $categories as $category ){ - echo ""; - echo ""; - echo ""; - if(isset($username)) - { - echo ""; - echo ""; - } - echo ""; - } - if(isset($username)) - { - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - } -?> -
getId()}\">{$category->getName()}{$category->getDescription()}getId()}\">EditgetId()}\" onClick=\"return confirm('Confirm deletion.')\">Delete
Add
-
-
- - - \ 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 @@ findOneById($_GET['delete']); @@ -37,61 +37,12 @@ $category->save(); header('Location: categories.php'); } -?> - - - - -Category - - - -

getName(); ?>

- -
-
getId()}" ?>" method="post"> -

Category

-
- -
-
- - -
-
-   -
- - -
-
-
- - - \ 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 @@ - - - - -Contact Us - - - -

Contact us

- -
-

Name: SomeCompany Ltd.
Telephone: +1-555-6383
Address: SomeStreet in Alamo

-
-
- - - \ 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 diff --git a/index.php b/index.php index c7eb711..eeb50c5 100644 --- a/index.php +++ b/index.php @@ -1,36 +1,11 @@ - - - - -Home - - - -

Home

- -
-

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.

-
-
- - - \ 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 diff --git a/login.php b/login.php index bbe1897..4435684 100644 --- a/login.php +++ b/login.php @@ -1,5 +1,7 @@ findOneByUsername($username); if ( !is_object($user) ) { @@ -26,45 +27,8 @@ } header('Location: .'); } -?> - - - - -User - - - -

Customer login

- -
-
-

User

-
- -
-
- -
-
 
- - -
-
-
- - - \ 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 @@ findOneById($id); @@ -20,69 +21,14 @@ if ( !is_object($product) ) { header('Location: categories.php'); } -?> - - - - -Productdetails - - - -

getName(); ?>

- -
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
 
-
-
-
- - - \ 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 @@ findOneById($_GET['delete']); @@ -58,95 +58,15 @@ $product->save(); header("Location: products.php?id={$catid}"); } -?> - - - - -Production - - - -

getName(); ?>

- -
-
getId()}" ?>&catid=" method="post"> -

Product

-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
 
- - -
-
-
- - - \ 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 @@ findOneById($id); if ( !is_object($category) ) { header('Location: categories.php'); } -$products = $category->getProducts(); -?> - - - - -Products - - - -

getName(); ?>

- -
- -"; - echo ""; - echo ""; - if(isset($username)) - { - echo ""; - echo ""; - } - echo ""; - -} -if(isset($username)) -{ - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; -} -?> -
getId()}&catid={$id}\">{$product->getName()}{$product->getDescription()}getId()}&catid={$id}\">EditgetId()}&catid={$id}\" onClick=\"return confirm('Confirm deletion.')\">Delete
Add
-
-
- - - \ 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} +
+
Contact us
+
Home
+ {if $loggedin} +
Logout
+ {else} +
Login
+ {/if} +
+{/block} +{block name=content} + + {foreach from=$categories item=category} + + + + {if $loggedin} + + + {/if} + + {/foreach} + {if $loggedin} + + + + + + + {/if} +
{$category->getName()}{$category->getDescription()}EditDelete
Add
+{/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} +
+
Contact us
+
Home
+
Back
+ {if $loggedin} +
Logout
+ {else} +
Login
+ {/if} +
+{/block} +{block name=content} +
+

Category

+
+ +
+
+ + +
+
 
+ + +
+{/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} +
+
Home
+
Categories
+ {if $loggedin} +
Logout
+ {else} +
Login
+ {/if} +
+{/block} +{block name=content} +

Name: SomeCompany Ltd.
Telephone: +1-555-6383
Address: SomeStreet in Alamo

+{/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} +
+
Contact us
+
Categories
+ {if $loggedin} +
Logout
+ {else} +
Login
+ {/if} +
+{/block} +{block name=content} +

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.

+{/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 @@ + + + + +{block name=title}Untitled Page{/block} + + + +

{block name=title}Untitled Page{/block}

+ +
+ {block name=content}Error loading{/block} +
+
+ + + \ 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} +
+
Contact us
+
Categories
+
Home
+
+{/block} +{block name=content} +
+

{block name=title}{/block}

+
+ + +
+
+ + +
+
 
+ + +
+{/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} +
+
Contact us
+
Home
+
Categories
+
Back to Category
+ {if $loggedin} +
Logout
+ {else} +
Login
+ {/if} +
+{/block} +{block name=content} +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
 
+
+{/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} +
+
Contact us
+
Home
+
Categories
+
Back
+ {if $loggedin} +
Logout
+ {else} +
Login
+ {/if} +
+{/block} +{block name=content} +
+

{block name=title}{/block}

+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
 
+ + +
+{/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} +
+
Contact us
+
Home
+
Categories
+ {if $loggedin} +
Logout
+ {else} +
Login
+ {/if} +
+{/block} +{block name=content} + + {foreach from=$products item=product} + + + + {if $loggedin} + + + {/if} + + {/foreach} + {if $loggedin} + + + + + + + {/if} +
{$product->getName()}{$product->getDescription()}EditDelete
Add
+{/block} \ No newline at end of file -- cgit v1.2.3-70-g09d2