Example #1
0
 /**
  * @return String HTML
  */
 public function getHTML()
 {
     $title = $this->product->getTitle();
     $desciption = $this->product->getDescription();
     $price = $this->product->getPrice();
     $popularity = $this->popularityView->getHTML();
     $backLink = $this->navigationView->getLinkToCatalog();
     return "<div>\n\t\t\t\t\t<h2>{$title}</h2>\n\t\t\t\t\t{$popularity}\n\t\t\t\t\t<p>Price: {$price} sek</p>\n\t\t\t\t\t<p>{$desciption}</p>\n\t\t\t\t\t{$backLink}\n\t\t\t\t</div>";
 }
Example #2
0
 public function indexAction()
 {
     $product = new Product();
     $product->setName('Hello');
     $this->model->persist($product);
     $this->model->flush();
     echo "Created Product with ID " . $product->getId() . "\n";
     var_dump($this->request->getParams());
 }
 /**
  *	Method for creating a product
  *	@param \model\Product $p
  *	@param \model\Image $image
  */
 public function createProduct(\model\Product $p, \model\Image $image)
 {
     if ($this->productDAL->checkUniqueExists($p->getUnique())) {
         throw new \PDOUniqueExistsException("Unique already exists in database.");
     }
     $this->productDAL->addProduct($p);
     $image->uploadImage();
     $image->createSquareImage(self::$thumbSide, self::$thumbPath);
     $image->createSquareImage(self::$mediumSide, self::$mediumPath);
 }
 public function addProductAction()
 {
     if (!empty($_POST)) {
         $product = new Product();
         $product->setName(htmlentities($_POST["name"]));
         $product->setContent(htmlentities($_POST["content"]));
         $em = $this->getEntityManager();
         $em->persist($product);
         $em->flush();
         return $this->redirectTo();
     }
     return $this->renderView("productAdd.html.twig");
 }
Example #5
0
 public function getProduct(\model\Product $product, LikeView $likeView)
 {
     $name = $product->getName();
     $price = $product->getPrice();
     $unique = $product->getUniqueProductID();
     $backUrl = $this->url->getURL();
     $this->url->addArgument(self::$productURLID, $unique);
     $likeHTML = $likeView->createLikeButton();
     $ret = "<h1>Product {$name}</h1>{$likeHTML}<br/>";
     $ret .= "";
     $ret .= "{$price} sek<br/>";
     $ret .= "<a href='{$backUrl}'>back</a> ";
     return $ret;
 }
 /**
  * 	Method to get new product from old product
  *	@param \model\Product $p
  * 	@return new \model\Product()
  */
 public function getUpdatedProduct(\model\Product $p)
 {
     $this->message = "";
     try {
         return new \model\Product($this->getTitle(), $p->getFilename(), $p->getDesc(), $this->getPrice(), $p->getUnique(), $p->getProductID());
     } catch (\TitleMissingException $e) {
         $this->message = $e->getMessage();
     } catch (\TitleWrongLengthException $e) {
         $this->message = $e->getMessage();
     } catch (\DescMissingException $e) {
         $this->message = $e->getMessage();
     } catch (\DescWrongLengthException $e) {
         $this->message = $e->getMessage();
     } catch (\PriceWrongFormatException $e) {
         $this->message = $e->getMessage();
     } catch (\PriceTooLowException $e) {
         $this->message = $e->getMessage();
     } catch (\PriceMissingException $e) {
         $this->message = $e->getMessage();
     } catch (\UniqueMissingException $e) {
         $this->message = $e->getMessage();
     } catch (\UniqueURLException $e) {
         $this->message = $e->getMessage();
     } catch (\Exception $e) {
         $this->message = $e->getMessage();
     }
 }
 public function updateProduct(\model\Product $p)
 {
     $smt = $this->conn->prepare("UPDATE " . self::$table . " SET " . self::$c_title . " = '" . $p->getTitle() . "', \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . self::$c_desc . " = '" . $p->getDesc() . "', \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . self::$c_price . " = '" . $p->getPrice() . "', \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . self::$c_unique . " = '" . $p->getUnique() . "' WHERE " . self::$c_id . "=" . $p->getProductID() . "");
     $smt->execute();
 }