public function getPageContent()
 {
     $template = $this->getTemplateEngine()->readTemplate($this->getTemplate());
     $products = $this->getModel()->getProducts();
     $sum = 0;
     $visible = CSS::HIDDEN;
     $empty = "";
     $productsTpl = "";
     if (count($products) > 0) {
         $visible = "";
         $empty = CSS::HIDDEN;
         $engine = $tpl = $this->getTemplateEngine();
         foreach ($products as $product) {
             $tpl = $engine->readTemplate(Template::CART_PRODUCT);
             $tpl = $engine->replaceTag("classification", $product->getClassification(), $tpl);
             $tpl = $engine->replaceTag("type", $product->getType(), $tpl);
             $tpl = $engine->replaceTag("imgname", $product->getImgname(), $tpl);
             $tpl = $engine->replaceTag("id", $product->getId(), $tpl);
             $tpl = $engine->replaceTag("name", $product->getName(), $tpl);
             $tpl = $engine->replaceTag("optionsList", StringUtils::arrangeOptions($product->getProperties()), $tpl);
             $tpl = $engine->replaceTag("price", StringUtils::formatAmount($product->getPrice()), $tpl);
             $sum += $product->getPrice();
             $productsTpl .= $tpl;
         }
     }
     $template = $this->getTemplateEngine()->replaceTag("empty", $empty, $template);
     $template = $this->getTemplateEngine()->replaceTag("visible", $visible, $template);
     $template = $this->getTemplateEngine()->replaceTag("productrows", $productsTpl, $template);
     $template = $this->getTemplateEngine()->replaceTag("total", StringUtils::formatAmount($sum), $template);
     return $template;
 }
 /**
  * This method reads the e-mail body template and fills it 
  * with the values from the cart and the given information
  * about the user.
  * @return HTML e-mail body
  */
 private function createMailBody()
 {
     $engine = $this->getTemplateEngine();
     // read the template for the e-mail body
     $msgTpl = $engine->readTemplate(Template::MAIL_ORDER);
     // create a new CartModel instance to get access to the cart's products
     $cart = new CartModel();
     // write all ordered products in the cart into e-mail
     $rows = "";
     $amount = 0;
     foreach ($cart->getProducts() as $product) {
         $rowTpl = $engine->readTemplate(Template::MAIL_ORDER_ROW);
         $rowTpl = $engine->replaceTag("name", $product->getName(), $rowTpl);
         $rowTpl = $engine->replaceTag("options", StringUtils::arrangeOptions($product->getProperties()), $rowTpl);
         $rowTpl = $engine->replaceTag("price", StringUtils::formatAmount($product->getPrice()), $rowTpl);
         $rows .= $rowTpl;
         $amount += $product->getPrice();
     }
     // write the POST-ed values into e-mail
     $msgTpl = $engine->replaceTag("firstname", StringUtils::removeTags($_POST["name-firstname"]), $msgTpl);
     $msgTpl = $engine->replaceTag("lastname", StringUtils::removeTags($_POST["name-lastname"]), $msgTpl);
     $msgTpl = $engine->replaceTag("email", StringUtils::removeTags($_POST["name-email"]), $msgTpl);
     $msgTpl = $engine->replaceTag("address", StringUtils::removeTags($_POST["name-address"]), $msgTpl);
     $msgTpl = $engine->replaceTag("addressnr", StringUtils::removeTags($_POST["name-addressnr"]), $msgTpl);
     $msgTpl = $engine->replaceTag("zipcode", StringUtils::removeTags($_POST["name-zipcode"]), $msgTpl);
     $msgTpl = $engine->replaceTag("city", StringUtils::removeTags($_POST["name-city"]), $msgTpl);
     $msgTpl = $engine->replaceTag("country", StringUtils::removeTags($_POST["name-country"]), $msgTpl);
     $msgTpl = $engine->replaceTag("shippingmethod", StringUtils::removeTags($_POST["name-shippingmethod"]), $msgTpl);
     $msgTpl = $engine->replaceTag("paymentmethod", StringUtils::removeTags($_POST["name-paymentmethod"]), $msgTpl);
     $msgTpl = $engine->replaceTag("total", StringUtils::formatAmount($amount), $msgTpl);
     $giftboxYesNo = isset($_POST["name-giftbox"]) ? "yes" : "no";
     $msgTpl = $engine->replaceTag("yesno", $giftboxYesNo, $msgTpl);
     // replace the placeholder in e-mail's template with the product rows
     $msgTpl = $engine->replaceTag("rows", $rows, $msgTpl);
     // translate all keys in the template
     $msgTpl = $this->handleTranslations($msgTpl);
     // set the table with all informations to the view for displaying it
     $this->getView()->setTable($msgTpl);
     return $msgTpl;
 }
 public function getPageContent()
 {
     $template = $this->getTemplateEngine()->readTemplate($this->getTemplate());
     $products = $this->getModel()->getProducts();
     if (count($products) === 1) {
         $product = $products[0];
         $template = $this->getTemplateEngine()->replaceTag("id", $product->getId(), $template);
         $template = $this->getTemplateEngine()->replaceTag("classification", $product->getClassification(), $template);
         $template = $this->getTemplateEngine()->replaceTag("type", $product->getType(), $template);
         $template = $this->getTemplateEngine()->replaceTag("imgname", $product->getImgname(), $template);
         $template = $this->getTemplateEngine()->replaceTag("name", $product->getName(), $template);
         $template = $this->getTemplateEngine()->replaceTag("price", StringUtils::formatAmount($product->getPrice()), $template);
         $template = $this->getTemplateEngine()->replaceTag("description", nl2br($product->getDescription()), $template);
         $template = $this->getTemplateEngine()->replaceTag("options", $this->renderOptions($product), $template);
         $again = "";
         if (CartController::hasProduct($product)) {
             $again = CSS::CART_ADD_AGAIN;
         }
         $template = $this->getTemplateEngine()->replaceTag("again", $again, $template);
     }
     return $template;
 }