Пример #1
0
 /**
  * Parse
  */
 private function parse()
 {
     // get list of recent products
     $numItems = FrontendModel::getModuleSetting('Catalog', 'recent_products_full_num_items', 3);
     $recentProducts = FrontendCatalogModel::getAll($numItems);
     $this->tpl->assign('widgetCatalogRecentProducts', $recentProducts);
 }
Пример #2
0
 /**
  * Load the data
  */
 private function loadData()
 {
     // Get category
     $this->category = FrontendCatalogModel::getCategoryById((int) $this->data['id']);
     // Get Products
     $this->products = FrontendCatalogModel::getAllByCategory($this->data['id']);
 }
Пример #3
0
 /**
  * Parse
  */
 private function parse()
 {
     // get categories
     $brands = FrontendCatalogModel::getAllBrands();
     // assign comments
     $this->tpl->assign('widgetCatalogBrands', $brands);
 }
Пример #4
0
 /**
  * Parse
  */
 private function parse()
 {
     // get categories
     $categories = FrontendCatalogModel::getAllCategories();
     $count = 0;
     // any categories?
     if (!empty($categories)) {
         // build link
         $link = FrontendNavigation::getURLForBlock('Catalog', 'Category');
         // loop and reset url
         foreach ($categories as $key => &$row) {
             if ($row['parent_id'] > 0 || $count >= 4) {
                 unset($categories[$key]);
                 continue;
             }
             //--Create url
             $row['url'] = $link . '/' . $row['url'];
             //--Get image
             $row['image'] = FrontendMediaHelper::getFromModule('Catalog', $row['id'], 0, 1, 'category');
             //--add count
             $count++;
         }
     }
     // assign comments
     $this->tpl->assign('categories', $categories);
 }
Пример #5
0
 /**
  * Execute the order save
  */
 public function execute()
 {
     parent::execute();
     // get order values
     $this->orderValues['product_id'] = \SpoonFilter::getPostValue('productId', null, '');
     $this->orderValues['amount'] = \SpoonFilter::getPostValue('productAmount', null, '');
     $action = \SpoonFilter::getPostValue('action', null, '');
     // get cookie
     $cookieOrderId = Cookie::get('order_id');
     // check if cookies are enabled
     $cookiesEnabled = Cookie::set('enabled', 'true');
     $cookieExists = Cookie::exists('enabled');
     // check if cookies are set, when true update the order
     if (isset($cookieOrderId) && FrontendCatalogModel::existsOrder($cookieOrderId) == true) {
         $this->orderValues['order_id'] = $cookieOrderId;
         // action add or update
         if ($action == 'add-update') {
             if (FrontendCatalogModel::existsOrderValue($this->orderValues['product_id'], $this->orderValues['order_id']) == true) {
                 // update the order values
                 FrontendCatalogModel::updateOrderValue($this->orderValues, $this->orderValues['order_id'], $this->orderValues['product_id']);
                 $this->output(self::OK, null, 'Order values updated.');
             } else {
                 // insert order values
                 FrontendCatalogModel::insertOrderValue($this->orderValues);
                 $this->output(self::OK, null, 'Order values inserted.');
             }
         } elseif ($action == 'delete') {
             if (FrontendCatalogModel::existsOrderValue($this->orderValues['product_id'], $this->orderValues['order_id']) == true) {
                 // delete the order values
                 FrontendCatalogModel::deleteOrderValue($this->orderValues['order_id'], $this->orderValues['product_id']);
                 $this->output(self::OK, null, 'Order values deleted.');
             }
         }
     } else {
         // when no cookies are set, create new cookie and insert order
         $orderId = FrontendCatalogModel::insertOrder();
         if ($orderId != '') {
             // set order id
             $this->orderValues['order_id'] = $orderId;
             // set cookie
             Cookie::set('order_id', $orderId);
             // insert order values
             FrontendCatalogModel::insertOrderValue($this->orderValues);
             $this->output(self::OK, null, 'Order imported.');
         }
     }
 }
Пример #6
0
 /**
  * Parse
  */
 private function parse()
 {
     // get list of recent products
     $products = FrontendCatalogModel::getAllForFrontpage();
     foreach ($products as &$product) {
         $product['image'] = FrontendMediaHelper::getFromModule('Catalog', $product['id'], 0, 1, 'product');
     }
     unset($product);
     $productsTotal = array();
     while (count($productsTotal) < 20) {
         foreach ($products as $product) {
             $productsTotal[] = $product;
         }
     }
     $this->tpl->assign('products', $products);
     $this->tpl->assign('productsCarousel', $productsTotal);
 }
Пример #7
0
 /**
  * Load the data, don't forget to validate the incoming data
  */
 private function getData()
 {
     // get cookie
     $this->orderId = Cookie::get('order_id');
     if ($this->orderId) {
         // get the products
         $this->products = FrontendCatalogModel::getProductsByOrder($this->orderId);
         // total price
         $this->totalPrice = '0';
         // calculate total amount
         foreach ($this->products as &$product) {
             // calculate total
             $subtotal = (int) $product['subtotal_price'];
             $this->totalPrice = (int) $this->totalPrice;
             $this->totalPrice = $this->totalPrice + $subtotal;
         }
     }
 }
Пример #8
0
 /**
  * Parse
  */
 private function parse()
 {
     // get categories
     $categories = FrontendCatalogModel::getAllCategories();
     // get tree of all categories
     $tree = FrontendCatalogModel::getCategoriesTree();
     // any categories?
     if (!empty($categories)) {
         // build link
         $link = FrontendNavigation::getURLForBlock('Catalog', 'Category');
         // loop and reset url
         foreach ($categories as &$row) {
             $row['url'] = $link . '/' . $row['url'];
         }
     }
     // assign comments
     $this->tpl->assign('widgetCatalogCategoriesFlat', $categories);
     $this->tpl->assign('widgetCatalogCategoriesTree', $tree);
 }
Пример #9
0
 /**
  * Get the data
  */
 private function getData()
 {
     // get cookie
     $this->orderId = Cookie::get('order_id');
     if ($this->orderId) {
         // get the products
         $this->products = FrontendCatalogModel::getProductsByOrder($this->orderId);
         // count amount of products in shopping cart
         $this->amountOfProducts = count($this->products);
         // total price
         $this->totalPrice = '0';
         // calculate total amount
         foreach ($this->products as &$product) {
             // calculate total
             $subtotal = (int) $product['subtotal_price'];
             $this->totalPrice = (int) $this->totalPrice;
             $this->totalPrice = $this->totalPrice + $subtotal;
         }
         // url for next step
         $this->personalDataUrl = FrontendNavigation::getURLForBlock('Catalog', 'PersonalData');
         // url for next step
         $this->catalogUrl = FrontendNavigation::getURLForBlock('Catalog');
     }
 }
Пример #10
0
 /**
  * Parse the page
  */
 protected function parse()
 {
     // add css
     $this->header->addCSS('/src/Frontend/Modules/' . $this->getModule() . '/Layout/Css/catalog.css');
     // add noty js
     $this->header->addJS('/src/Frontend/Modules/' . $this->getModule() . '/Js/noty/packaged/jquery.noty.packaged.min.js');
     // assign items
     $this->tpl->assign('products', $this->products);
     // flat array of categories
     $this->tpl->assign('categoriesFlat', $this->categories);
     // multidimensional array of categories
     $this->tpl->assign('categoriesTree', $this->categoriesTree);
     // multidimensional html list of categories
     $this->tpl->assign('categoriesHTML', FrontendCatalogModel::getTreeHTML($this->categoriesTree));
     // parse the pagination
     $this->parsePagination();
 }
Пример #11
0
 /**
  * Load the data, don't forget to validate the incoming data
  */
 private function getData()
 {
     $this->parameters = $this->URL->getParameters();
     $url = end($this->parameters);
     if ($url === null) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // get by URL
     $this->record = FrontendCatalogModel::getBrandFromUrl($url);
     if (empty($this->record)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // get products
     $this->products = FrontendCatalogModel::getAllByBrand($this->record['id']);
     // requested page
     $requestedPage = $this->URL->getParameter('page', 'int', 1);
     // set URL and limit
     $this->pagination['url'] = FrontendNavigation::getURLForBlock('catalog', 'category') . '/' . $this->record['url'];
     $this->pagination['limit'] = FrontendModel::getModuleSetting('catalog', 'overview_num_items', 10);
     // populate count fields in pagination
     $this->pagination['num_items'] = FrontendCatalogModel::getCategoryCount($this->record['id']);
     $this->pagination['num_pages'] = (int) ceil($this->pagination['num_items'] / $this->pagination['limit']);
     // num pages is always equal to at least 1
     if ($this->pagination['num_pages'] == 0) {
         $this->pagination['num_pages'] = 1;
     }
     // redirect if the request page doesn't exist
     if ($requestedPage > $this->pagination['num_pages'] || $requestedPage < 1) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // populate calculated fields in pagination
     $this->pagination['requested_page'] = $requestedPage;
     $this->pagination['offset'] = $this->pagination['requested_page'] * $this->pagination['limit'] - $this->pagination['limit'];
 }
Пример #12
0
 /**
  * Parse the page
  */
 protected function parse()
 {
     // add css
     $this->header->addCSS('/src/Frontend/Modules/' . $this->getModule() . '/Layout/Css/catalog.css');
     // add noty js
     $this->header->addJS('/src/Frontend/Modules/' . $this->getModule() . '/Js/noty/packaged/jquery.noty.packaged.min.js');
     // add breadcrumbs
     $categories = FrontendCatalogModel::getAllCategories();
     $paths = FrontendCatalogModel::traverseUp($categories, $this->record);
     $baseUrl = FrontendNavigation::getURLForBlock('Catalog', 'Category');
     // get full urls
     $parentCategories = array();
     foreach ($paths as $key => $value) {
         $category = FrontendCatalogModel::getCategoryById($key);
         $breadcrumbPaths = FrontendCatalogModel::traverseUp($categories, $category);
         $url = implode('/', $breadcrumbPaths);
         $category['full_url'] = $baseUrl . '/' . $url;
         // add breadcrumb
         $this->breadcrumb->addElement($category['title'], $category['full_url']);
         $parentCategories[] = array('title' => $category['title']);
     }
     if (!empty($parentCategories)) {
         unset($parentCategories[count($parentCategories) - 1]);
     }
     if (!empty($parentCategories)) {
         $this->tpl->assign('parentCategories', $parentCategories);
     }
     // hide action title
     $this->tpl->assign('hideContentTitle', true);
     // show the title
     $this->tpl->assign('title', $this->record['title']);
     // set meta
     $this->header->setPageTitle($this->record['meta_title'], $this->record['meta_title_overwrite'] == 'Y');
     $this->header->addMetaDescription($this->record['meta_description'], $this->record['meta_description_overwrite'] == 'Y');
     $this->header->addMetaKeywords($this->record['meta_keywords'], $this->record['meta_keywords_overwrite'] == 'Y');
     // advanced SEO-attributes
     if (isset($this->record['meta_data']['seo_index'])) {
         $this->header->addMetaData(array('name' => 'robots', 'content' => $this->record['meta_data']['seo_index']));
     }
     if (isset($this->record['meta_data']['seo_follow'])) {
         $this->header->addMetaData(array('name' => 'robots', 'content' => $this->record['meta_data']['seo_follow']));
     }
     // assign items
     $this->tpl->assign('products', $this->products);
     $this->tpl->assign('record', $this->record);
     // flat array of categories
     $this->tpl->assign('subcategoriesFlat', $this->subcategories);
     // multidimensional array of categories
     $this->tpl->assign('subcategoriesTree', $this->subcategoriesTree);
     $this->tpl->assign('categoriesTree', $this->categoriesTree);
     // multidimensional html list of subcategories
     $this->tpl->assign('subcategoriesHTML', FrontendCatalogModel::getTreeHTML($this->subcategoriesTree));
     // parse the pagination
     $this->parsePagination();
 }
Пример #13
0
 /**
  * Get the data
  */
 private function getData()
 {
     // get cookie
     $this->orderId = Cookie::get('order_id');
     // check if cookies are available
     $this->cookiesEnabled = Cookie::hasAllowedCookies();
     // check if cookies exists
     if ($this->orderId || $this->cookiesEnabled == true) {
         // get the products
         $this->products = FrontendCatalogModel::getProductsByOrder($this->orderId);
         // count amount of products in shopping cart
         $this->amountOfProducts = count($this->products);
         // total price
         $this->totalPrice = '0';
         // calculate total amount
         foreach ($this->products as &$product) {
             // calculate total
             $subtotal = (int) $product['subtotal_price'];
             $this->totalPrice = (int) $this->totalPrice;
             $this->totalPrice = $this->totalPrice + $subtotal;
         }
         $this->totalPriceArr['total'] = $this->totalPrice;
         // insert total price in db
         FrontendCatalogModel::updateOrder($this->totalPriceArr, $this->orderId);
     }
 }
Пример #14
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     // is the form submitted
     if ($this->frm->isSubmitted()) {
         // cleanup the submitted fields, ignore fields that were added by hackers
         $this->frm->cleanupFields();
         // validate required fields
         $this->frm->getField('email')->isEmail(FL::err('EmailIsRequired'));
         $this->frm->getField('fname')->isFilled(FL::err('MessageIsRequired'));
         $this->frm->getField('lname')->isFilled(FL::err('MessageIsRequired'));
         $this->frm->getField('address')->isFilled(FL::err('MessageIsRequired'));
         $this->frm->getField('hnumber')->isFilled(FL::err('MessageIsRequired'));
         $this->frm->getField('postal')->isFilled(FL::err('MessageIsRequired'));
         $this->frm->getField('hometown')->isFilled(FL::err('MessageIsRequired'));
         // correct?
         if ($this->frm->isCorrect()) {
             // build array
             $order['email'] = $this->frm->getField('email')->getValue();
             $order['fname'] = $this->frm->getField('fname')->getValue();
             $order['lname'] = $this->frm->getField('lname')->getValue();
             $order['address'] = $this->frm->getField('address')->getValue();
             $order['hnumber'] = $this->frm->getField('hnumber')->getValue();
             $order['postal'] = $this->frm->getField('postal')->getValue();
             $order['hometown'] = $this->frm->getField('hometown')->getValue();
             $order['status'] = 'moderation';
             // insert values in database
             FrontendCatalogModel::updateOrder($order, $this->cookieOrderId);
             // delete cookie
             $argument = 'order_id';
             unset($_COOKIE[(string) $argument]);
             setcookie((string) $argument, null, 1, '/');
             // set cookies person --> optional
             Cookie::set('email', $order['email']);
             Cookie::set('fname', $order['fname']);
             Cookie::set('lname', $order['lname']);
             Cookie::set('address', $order['address']);
             Cookie::set('hnumber', $order['hnumber']);
             Cookie::set('postal', $order['postal']);
             Cookie::set('hometown', $order['hometown']);
             Cookie::set('status', $order['status']);
             // trigger event
             FrontendModel::triggerEvent('Catalog', 'after_add_order', array('order' => $order));
             $url = FrontendNavigation::getURLForBlock('Catalog', 'OrderReceived');
             $this->redirect($url);
         }
     }
 }
Пример #15
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     // get settings
     $commentsAllowed = isset($this->settings['allow_comments']) && $this->settings['allow_comments'];
     // comments aren't allowed so we don't have to validate
     if (!$commentsAllowed) {
         return false;
     }
     if ($this->frmContact->isSubmitted()) {
         //--Clean fields
         $this->frmContact->cleanUpFields();
         //--Get the fields
         $fields = $this->frmContact->getFields();
         //--Check if the fields are filled in
         $fields['name']->isFilled(FL::err('NameIsRequired'));
         $fields['emailContact']->isEmail(FL::err('EmailIsRequired'));
         //--Check if frm is correct
         if ($this->frmContact->isCorrect()) {
             //--Create variable array
             $arrVariables["sentOn"] = time();
             $arrVariables["product"] = $this->record['title'];
             $arrVariables["name"] = $fields['name']->getValue();
             $arrVariables["email"] = $fields['emailContact']->getValue();
             $arrVariables["phone"] = $fields['phone']->getValue();
             $arrVariables["message"] = nl2br($fields['messageContact']->getValue());
             $message = \Common\Mailer\Message::newInstance(FL::getMessage('Contact') . ": " . $this->record['title']);
             $message->parseHtml(FRONTEND_MODULES_PATH . '/Catalog/Layout/Templates/Mails/Contact.tpl', $arrVariables, true);
             //                $message->setTo(array('*****@*****.**'));
             $message->setTo(array('*****@*****.**'));
             $message->setFrom(array($arrVariables["email"] => $arrVariables['name']));
             $this->get('mailer')->send($message);
             $this->tpl->assign("showContactSend", true);
         }
     }
     // is the form submitted
     if ($this->frm->isSubmitted()) {
         // cleanup the submitted fields, ignore fields that were added by hackers
         $this->frm->cleanupFields();
         // does the key exists?
         if (\SpoonSession::exists('catalog_comment_' . $this->record['id'])) {
             // calculate difference
             $diff = time() - (int) \SpoonSession::get('catalog_comment_' . $this->record['id']);
             // calculate difference, it it isn't 10 seconds the we tell the user to slow down
             if ($diff < 10 && $diff != 0) {
                 $this->frm->getField('message')->addError(FL::err('CommentTimeout'));
             }
         }
         // validate required fields
         $this->frm->getField('author')->isFilled(FL::err('AuthorIsRequired'));
         $this->frm->getField('email')->isEmail(FL::err('EmailIsRequired'));
         $this->frm->getField('message')->isFilled(FL::err('MessageIsRequired'));
         // validate optional fields
         if ($this->frm->getField('website')->isFilled() && $this->frm->getField('website')->getValue() != 'http://') {
             $this->frm->getField('website')->isURL(FL::err('InvalidURL'));
         }
         // no errors?
         if ($this->frm->isCorrect()) {
             // get module setting
             $spamFilterEnabled = isset($this->settings['spamfilter']) && $this->settings['spamfilter'];
             $moderationEnabled = isset($this->settings['moderation']) && $this->settings['moderation'];
             // reformat data
             $author = $this->frm->getField('author')->getValue();
             $email = $this->frm->getField('email')->getValue();
             $website = $this->frm->getField('website')->getValue();
             if (trim($website) == '' || $website == 'http://') {
                 $website = null;
             }
             $text = $this->frm->getField('message')->getValue();
             // build array
             $comment['product_id'] = $this->record['id'];
             $comment['language'] = FRONTEND_LANGUAGE;
             $comment['created_on'] = FrontendModel::getUTCDate();
             $comment['author'] = $author;
             $comment['email'] = $email;
             $comment['website'] = $website;
             $comment['text'] = $text;
             $comment['status'] = 'published';
             $comment['data'] = serialize(array('server' => $_SERVER));
             // get URL for article
             $permaLink = $this->record['full_url'];
             $redirectLink = $permaLink;
             // is moderation enabled
             if ($moderationEnabled) {
                 // if the commenter isn't moderated before alter the comment status so it will appear in the moderation queue
                 if (!FrontendCatalogModel::isModerated($author, $email)) {
                     $comment['status'] = 'moderation';
                 }
             }
             // should we check if the item is spam
             if ($spamFilterEnabled) {
                 // check for spam
                 $result = FrontendModel::isSpam($text, SITE_URL . $permaLink, $author, $email, $website);
                 // if the comment is spam alter the comment status so it will appear in the spam queue
                 if ($result) {
                     $comment['status'] = 'spam';
                 } elseif ($result == 'unknown') {
                     $comment['status'] = 'moderation';
                 }
             }
             // insert comment
             $comment['id'] = FrontendCatalogModel::insertComment($comment);
             // trigger event
             FrontendModel::triggerEvent('catalog', 'after_add_comment', array('comment' => $comment));
             // append a parameter to the URL so we can show moderation
             if (strpos($redirectLink, '?') === false) {
                 if ($comment['status'] == 'moderation') {
                     $redirectLink .= '?comment=moderation#' . FL::act('Comment');
                 }
                 if ($comment['status'] == 'spam') {
                     $redirectLink .= '?comment=spam#' . FL::act('Comment');
                 }
                 if ($comment['status'] == 'published') {
                     $redirectLink .= '?comment=true#comment-' . $comment['id'];
                 }
             } else {
                 if ($comment['status'] == 'moderation') {
                     $redirectLink .= '&comment=moderation#' . FL::act('Comment');
                 }
                 if ($comment['status'] == 'spam') {
                     $redirectLink .= '&comment=spam#' . FL::act('Comment');
                 }
                 if ($comment['status'] == 'published') {
                     $redirectLink .= '&comment=true#comment-' . $comment['id'];
                 }
             }
             // set title
             $comment['product_title'] = $this->record['title'];
             $comment['product_url'] = $this->record['url'];
             // notify the admin
             FrontendCatalogModel::notifyAdmin($comment);
             // store timestamp in session so we can block excessive usage
             \SpoonSession::set('catalog_comment_' . $this->record['id'], time());
             // store author-data in cookies
             try {
                 Cookie::set('comment_author', $author);
                 Cookie::set('comment_email', $email);
                 Cookie::set('comment_website', $website);
             } catch (Exception $e) {
                 // settings cookies isn't allowed, but because this isn't a real problem we ignore the exception
             }
             // redirect
             $this->redirect($redirectLink);
         }
     }
 }