/**
  * 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);
 }
Esempio n. 2
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);
 }
Esempio n. 3
0
 /**
  * Get the data
  */
 private function getData()
 {
     // validate incoming parameters
     if ($this->URL->getParameter(1) === null) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // get record
     $this->record = FrontendAgendaModel::get($this->URL->getParameter(1));
     // check if record is not empty
     if (empty($this->record)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // if parameters given - select parameters, else set original date
     $this->beginDate = date('Y-m-d H:i', $this->URL->getParameter('begindate'));
     $this->endDate = date('Y-m-d H:i', $this->URL->getParameter('enddate'));
     // settings
     $this->settings = $this->get('fork.settings')->getForModule('Agenda');
     // media
     //        $this->images = FrontendAgendaModel::getImages($this->record['id'], $this->settings);
     //        $this->files = FrontendAgendaModel::getFiles($this->record['id']);
     //        $this->videos = FrontendAgendaModel::getVideos($this->record['id']);
     $this->record['image'] = FrontendMediaHelper::getFromModule('Agenda', $this->record['id'], 0, 1, 'Agenda');
     $this->record['images'] = FrontendMediaHelper::getFromModule('Agenda', $this->record['id'], 0, 0, 'Agenda');
     $this->record['allow_subscriptions'] = $this->record['allow_subscriptions'] == 'Y';
     // location
     $this->settings['center']['lat'] = $this->record['lat'];
     $this->settings['center']['lng'] = $this->record['lng'];
     $this->settings['maps_url'] = FrontendAgendaModel::buildUrl($this->settings, array($this->record));
 }
Esempio n. 4
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::getCategory($url);
     if (empty($this->record)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // get subcategories
     $this->subcategories = FrontendCatalogModel::getAllCategories($this->record['id'], $this->record['url']);
     // get subcategories tree of parent
     $this->subcategoriesTree = FrontendCatalogModel::getCategoriesTree($this->record['id']);
     //--Get all the categories
     $this->categoriesTree = FrontendCatalogModel::getCategoriesTree(0, $this->record['id']);
     // get products
     $this->products = FrontendCatalogModel::getAllByCategory($this->record['id']);
     foreach ($this->products as &$product) {
         $product['image'] = FrontendMediaHelper::getFromModule('Catalog', $product['id'], 0, 1, 'product');
     }
     // 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'];
 }
Esempio n. 5
0
 /**
  * Get the data
  */
 private function getData()
 {
     // validate incoming parameters
     if ($this->URL->getParameter(1) === null) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // get information
     $this->record = FrontendCatalogModel::get($this->URL->getParameter(1));
     $this->comments = FrontendCatalogModel::getComments($this->record['id']);
     $this->specifications = FrontendCatalogModel::getProductSpecifications($this->record['id']);
     $this->tags = FrontendTagsModel::getForItem('Catalog', $this->record['id']);
     $this->settings = $this->get('fork.settings')->getForModule('Catalog');
     $this->files = FrontendCatalogModel::getFiles($this->record['id']);
     $this->videos = FrontendCatalogModel::getVideos($this->record['id']);
     $this->relatedProducts = FrontendCatalogModel::getRelatedProducts($this->record['id']);
     $this->brand = FrontendCatalogModel::getBrand($this->record['brand_id']);
     $this->record['allow_comments'] = $this->record['allow_comments'] == 'Y';
     $this->record['brand'] = $this->brand;
     $this->record['image'] = FrontendMediaHelper::getFromModule('Catalog', $this->record['id'], 0, 1, 'product');
     $this->record['images'] = FrontendMediaHelper::getFromModule('Catalog', $this->record['id'], 0, 0, 'product');
     // reset allow comments
     if (!$this->settings['allow_comments']) {
         $this->record['allow_comments'] = false;
     }
     // check if record is not empty
     if (empty($this->record)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     //--Get all the categories
     $this->categoriesTree = FrontendCatalogModel::getCategoriesTree(0, $this->record['category_id']);
 }