Guest User

Untitled

a guest
Jul 16th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.63 KB | None | 0 0
  1. <?php
  2.  
  3. #template
  4. class template
  5. {
  6. #var properties
  7. public $header="";
  8. public $html;
  9. public $footer="";
  10. private $_pageHandler;
  11. private $_postalCode;
  12. private $_products;
  13.  
  14.  
  15. #constructor
  16. public function __construct()
  17. {
  18. $this->_pageHandler = new pageHandler();
  19. $this->_postalCode = new postalCode();
  20. $this->_products = new products();
  21.  
  22. $header = $this->getHeader;
  23. $footer = $this->getFooter;
  24.  
  25.  
  26. }
  27.  
  28. #get header
  29. public function getHeader()
  30. {
  31. $this->header = file_get_contents('templates/header.tpl');
  32. return $this->header;
  33. }
  34.  
  35. #get body
  36. public function getBody()
  37. {
  38. if(!isset($this->_pageHandler->template))
  39. {
  40. header('Location: /home');
  41. }
  42. else
  43. {
  44. $html ='';
  45. //leest het uri($this->_pageHandler->page) en selecteert het juiste case
  46. switch($this->_pageHandler->page)
  47. {
  48. case 'home':
  49. $html .='<h2>[[pageTitle]]</h2>';
  50. $html .='[[pageContent]]';
  51. $html .='<div class="homeBox">';
  52. $html .='Bezorgen wij ook in uw postcode?';
  53. $html .='<form method="POST">';
  54. $html .='<input name="postalCode" type="text" maxlength="4" />';
  55. $html .='<input name="postalCodeControl" type="submit" value="Check" />';
  56. $html .='</form>';
  57. $html .='<span class="small fleft">(Voer de 4 cijfers van uw postcode)</span>';
  58. $html .='<span class="small fleft">Wij bezorgen dagelijks van 16:00uur tot 22:45uur</span>';
  59. $html .='</div>';
  60. $html .='<div class="homeBox fright">';
  61. $html .='</div>';
  62. if($_SERVER['REQUEST_METHOD'] == 'POST')
  63. {
  64. $postalCode = new postalCode();
  65. if(in_array($_POST['postalCode'], $postalCode->postalCodes()))
  66. {
  67. $_SESSION['postalCode']= $_POST['postalCode'];
  68. header('Location: /bestellen');
  69. }
  70. else
  71. {
  72. $_SESSION['postalCode']= '';
  73. $html .='<div class="warning">
  74. <img class="fleft" alt="waarschuwing" src="/imgs/icons/warning.png" /> Postcode valt niet onder onze bezorgroute.
  75. </div>';
  76. }
  77. }
  78. break;
  79.  
  80. case 'bestellen':
  81. if(!in_array($_SESSION['postalCode'], $this->_postalCode->postalCodes()))
  82. {
  83. $html .='<div class="warning"><img class="fleft" alt="waarschuwing" src="/imgs/icons/warning.png" />Er is geen postcode ingevuld. Klik <a href="/">hier</a> om terug te gaan.</div>';
  84. }
  85. else
  86. {
  87.  
  88. $html .='[[pageTitle]]';
  89. $html .='[[pageContent]]';
  90.  
  91. //category opbouw
  92. $html .='<ul class="category fleft">';
  93. foreach($this->_products->allCategorys as $category)
  94. {
  95. $html .='<li><a href="/'.$this->_pageHandler->page.'/'.$category['title'].'">'.$category['title'].'</a></li>';
  96. }
  97. $html .='</ul>';
  98. //testttt BEGINNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
  99. //$categoryTitle = strtolower(str_replace(' ', '-', $category['title']));
  100. // var_dump('categorytitle = '.$categoryTitle);
  101. // var_dump($this->_products->allCategorys);
  102.  
  103. // var_dump($this->_products->allCategorys);
  104. foreach ($this->_products->allCategorys as $value)
  105. {
  106. switch($value['title'])
  107. {
  108. case 'salades':
  109. echo 'salades';
  110. break;
  111. case 'soepen':
  112. echo 'soepen';
  113. break;
  114. case 'broodjes':
  115. echo 'broodjes';
  116. break;
  117.  
  118.  
  119. //case 'salades';
  120. // echo 'salades';
  121. // break;
  122. }
  123. }
  124. //testttt ENDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
  125.  
  126. //products opbouw
  127. $html .='<table class="products fleft">';
  128. foreach($this->_products->allProducts as $products)
  129. {
  130. $html .'<form method="POST">';
  131. $html .='<tr>
  132. <td class="title">'.$products['title'].'</td>
  133. <td class="euro">&euro;</td>
  134. <td class="price">'.$products['price'].'</td>
  135. <td class="add"><input type="image" alt="toevoegen" name="'.$prodcuts['ID'].'" src="/imgs/icons/add.png"></td>
  136. </tr>';
  137. $html .='<tr>
  138. <td class="description">'.$products['description'].'</td>
  139. <td></td>
  140. <td></td>
  141. <td></td>
  142. </tr>';
  143. $html .='</form>';
  144. }
  145.  
  146. $html .='</table>';
  147.  
  148. }
  149.  
  150. break;
  151.  
  152. case 'route':
  153. $html ='hallowhallow';
  154. break;
  155.  
  156. case 'contact':
  157. $html ='hallowhallow';
  158. break;
  159.  
  160.  
  161. }
  162. }
  163. return $html;
  164. }
  165.  
  166. #get footer
  167. public function getFooter()
  168. {
  169. $this->footer = file_get_contents('templates/footer.tpl');
  170. return $this->footer;
  171. }
  172.  
  173. }
  174.  
  175.  
  176. ?>
Add Comment
Please, Sign In to add comment