function assignItem()
 {
     if ((int) $this->request('i')) {
         $item = new struct_corecatalog_measurement(array('ms_id' => (int) $this->request('i')));
         $this->setVar('item', $item->load());
     }
 }
Esempio n. 2
0
 /**
  * Assign product to the template
  */
 function assignProduct()
 {
     $pId = (int) $this->request('p');
     if (strlen($pId) !== strlen($this->request('p'))) {
         $this->redirect('404');
     }
     if ($pId) {
         $this->setVar('comments_show', $this->_showComments);
         $this->setVar('tab', $this->request('tab', 1));
         $model = rad_instances::get('model_corecatalog_catalog');
         $model->setState('with_download_files', true);
         $model->setState('with_vv', true);
         $product = $model->getItem($pId);
         if (!empty($product->cat_id)) {
             if (count($product->tree_catin_link) and $product->tree_catin_link[0]->cit_tre_id) {
                 $modelTree = rad_instances::get('model_coremenus_tree');
                 $category = $modelTree->getItem($product->tree_catin_link[0]->cit_tre_id);
                 $this->addBC('category', $category);
                 if ($this->getParamsObject()->getcategories) {
                     /* for template need category of product */
                     foreach ($product->tree_catin_link as &$tcl) {
                         $tcl->tree = $modelTree->getItem($tcl->cit_tre_id);
                     }
                 }
                 /* if have already geted categories, get link from it */
                 if ($category->tre_pid != 0 and $category->tre_pid != $this->getParamsObject()->treestart) {
                     $parents = array();
                     $modelTree->clearState();
                     $parents[] = $modelTree->getItem($category->tre_pid);
                     $treestart = $this->getParamsObject()->treestart;
                     while ($parents[count($parents) - 1]->tre_pid != $treestart and $parents[count($parents) - 1]->tre_pid != 0) {
                         $modelTree->clearState();
                         $parents[] = $modelTree->getItem($parents[count($parents) - 1]->tre_pid);
                     }
                     $parents = array_reverse($parents);
                     $this->addBC('parents', $parents);
                 }
             }
             if (count($product->type_vl_link)) {
                 foreach ($product->type_vl_link as $tvlkey => $tvl) {
                     if ($product->type_vl_link[$tvlkey]->vl_measurement_id) {
                         $mesId = $product->type_vl_link[$tvlkey]->vl_measurement_id;
                         $mes = new struct_corecatalog_measurement(array('ms_id' => $mesId));
                         $mes->load();
                         $product->type_vl_link[$tvlkey]->ms_value = $mes->ms_value;
                     }
                 }
             }
             if ($this->config('partners.3dbin.license')) {
                 rad_instances::get('model_corecatalog_3dimages')->assign3Dimage($product);
             }
             $this->setVar('item', $product);
             $product->cat_showed++;
             $product->save();
             $this->addBC('product', $product);
             if (count($product->images_link)) {
                 $images = array();
                 foreach ($product->images_link as $id) {
                     if (!$id->img_main) {
                         $images[] = $id;
                     }
                 }
                 //foreach
                 $this->setVar('t_images', $images);
             }
             //if images_link
             if ($this->_showComments) {
                 $modelComments = rad_instances::get('model_coreresource_comments');
                 $modelComments->setState('active', 1);
                 $modelComments->setState('item_id', $pId);
                 $modelComments->setState('type', 'product');
                 $commentsTotal = $modelComments->getCount();
                 $modelComments->setState('order', 'rcm_datetime DESC');
                 $limit = '';
                 if ($commentsTotal > $this->_commentsPerPage) {
                     $paginator = new rad_paginator(array('total' => $commentsTotal, 'itemsperpage' => $this->_commentsPerPage));
                     $pageNumber = (int) $this->request('page');
                     $limit = $paginator->getSQLLimit($pageNumber);
                 } else {
                     $paginator = false;
                 }
                 $this->setVar('paginator', $paginator);
                 $comments = $modelComments->getItems($limit);
                 $comments = array_reverse($comments);
                 $this->fixSubComments($comments);
                 $this->setVar('comments', $comments);
                 $this->setVar('comments_total', $commentsTotal);
                 $this->setVar('hash', $this->hash());
                 //$this->sendMail($insert_id);
             }
         }
         //!empty product
     } else {
         $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName());
     }
 }
Esempio n. 3
0
 function __construct()
 {
     if ($this->getParamsObject()) {
         $params = $this->getParamsObject();
         $this->_showPages = $params->_get('showpages', $this->_showPages, $this->getCurrentLangID());
         $this->_treePages = $params->_get('treepages', $this->_treePages, $this->getCurrentLangID());
         $this->_showArticles = $params->_get('showarticles', $this->_showArticles, $this->getCurrentLangID());
         $this->_treeArticles = $params->_get('treearticles', $this->_treeArticles, $this->getCurrentLangID());
         $this->_showNews = $params->_get('shownews', $this->_showNews, $this->getCurrentLangID());
         $this->_treeNews = $params->_get('treenews', $this->_treeNews, $this->getCurrentLangID());
         $this->_showCatalog = $params->_get('showcatalog', $this->_showCatalog);
         $this->_treeCatalog = $params->_get('treecatalog', $this->_treeCatalog, $this->getCurrentLangID());
         $this->_exportSite = $params->_get('export', $this->_exportSite);
         $this->_shopName = $params->_get('shopname', $this->_shopName, $this->getCurrentLangID());
         $this->_shopCompany = $params->_get('shopcompany', $this->_shopCompany, $this->getCurrentLangID());
         $this->_shopAgency = $params->_get('shopagency', $this->_shopAgency, $this->getCurrentLangID());
         $this->setVar('params', $params);
     }
     switch ($this->_exportSite) {
         case 'sitemap':
             if ($this->_showPages) {
                 $pagesTree = rad_instances::get('model_coremenus_tree')->setState('active', 1)->setState('pid', $this->_treePages)->setState('lang', $this->getCurrentLangID())->getItems(true);
                 if (!empty($pagesTree)) {
                     rad_instances::get('model_corearticles_pages')->getPagesForTree($pagesTree, $this->getCurrentLangID());
                     $this->setVar('pagesTree', $pagesTree);
                 }
             }
             if ($this->_showArticles) {
                 $articlesTree = rad_instances::get('model_coremenus_tree')->setState('active', 1)->setState('pid', $this->_treeArticles)->setState('lang', $this->getCurrentLangID())->getItems(true);
                 if (!empty($articlesTree)) {
                     rad_instances::get('model_corearticles_articles')->getArticlessForTree($articlesTree, $this->getCurrentLangID());
                     $this->setVar('articlesTree', $articlesTree);
                 }
                 $this->setVar('articles', $articlesTree);
             }
             if ($this->_showNews) {
                 $newsTree = rad_instances::get('model_coremenus_tree')->setState('active', 1)->setState('pid', $this->_treeNews)->setState('lang', $this->getCurrentLangID())->getItems(true);
                 if (!empty($newsTree)) {
                     rad_instances::get('model_corearticles_news')->getNewsForTree($newsTree, $this->getCurrentLangID());
                     $this->setVar('newsTree', $newsTree);
                 }
             }
             //Show News
             if ($this->_showCatalog) {
                 $catalogTree = rad_instances::get('model_coremenus_tree')->setState('active', 1)->setState('pid', $this->_treeCatalog)->setState('lang', $this->getCurrentLangID())->getItems(true);
                 $modelCatalog = rad_instances::get('model_corecatalog_catalog')->setState('active', 1)->setState('join.mainimage', true)->setState('join.tree', true)->setState('lang', $this->getCurrentLangID())->setSTate('currency', model_corecatalog_currcalc::getDefaultCurrencyId());
                 $products = $modelCatalog->getItems();
                 if (!empty($products)) {
                     foreach ($products as $product) {
                         $this->_catRecursy($catalogTree, $product);
                     }
                 }
                 $this->setVar('catalog', $catalogTree);
             }
             break;
         case 'yandex.yml':
             header("Content-Type: text/xml");
             $this->setVar('nowdate', date("Y-m-d H:i"));
             $this->setVar('shop_name', mb_strlen($this->_shopName, 'utf-8') >= 20 ? mb_substr($this->_shopName, 0, 17, 'utf-8') . '...' : $this->_shopName);
             //Короткое название магазина — название, которое выводится в списке найденных на Яндекс. Маркете товаров. Оно не должно содержать более 20 символов.
             $this->setVar('shop_company', $this->_shopCompany);
             //Полное наименование компании, владеющей магазином. Не публикуется, используется для внутренней идентификации
             $this->setVar('shop_url', $this->config('url'));
             //URL главной страницы магазина.
             $this->setVar('shop_platform', 'Taberna');
             //CMS, на основе которой работает магазин.
             $this->setVar('shop_version', rad_update::getInstance()->getCurrentVersion());
             //Версия CMS.
             $this->setVar('shop_agency', $this->_shopAgency);
             //Наименование агентства, которое оказывает техническую поддержку магазину и отвечает за работоспособность сайта.
             $this->setVar('shop_email', $this->config('system.mail'));
             //Контактный адрес разработчиков CMS или агентства, осуществляющего техподдержку.
             //    Show currencies
             $currencies = rad_instances::get('model_corecatalog_currency')->getItems();
             $this->setVar('currencies', $currencies);
             //    Show categries & offers
             $this->setVar('showCatalog', $this->_showCatalog);
             if ($this->_showCatalog) {
                 $catalogTree = rad_instances::get('model_coremenus_tree')->setState('active', 1)->setState('pid', $this->_treeCatalog)->setState('lang', $this->getCurrentLangID())->getItems(true);
                 $modelCatalog = rad_instances::get('model_corecatalog_catalog')->setState('active', 1)->setState('join.mainimage', true)->setState('join.tree', true)->setState('lang', $this->getCurrentLangID())->setSTate('currency', model_corecatalog_currcalc::getDefaultCurrencyId());
                 $products = $modelCatalog->getItems();
                 if (!empty($products)) {
                     $modelCatalog->getValValues($products);
                     foreach ($products as $product) {
                         //    Params
                         if (count($product->type_vl_link)) {
                             foreach ($product->type_vl_link as $tvlkey => $tvl) {
                                 if ($product->type_vl_link[$tvlkey]->vl_measurement_id) {
                                     $mesId = $product->type_vl_link[$tvlkey]->vl_measurement_id;
                                     $mes = new struct_corecatalog_measurement(array('ms_id' => $mesId));
                                     $mes->load();
                                     $product->type_vl_link[$tvlkey]->ms_value = trim($mes->ms_value);
                                 }
                             }
                         }
                         //    Pictures
                         $model_images = rad_instances::get('model_core_image');
                         $model_images->setState('cat_id', $product->cat_id);
                         $product->images_link = $model_images->getItems();
                         //    Name
                         if (mb_strlen($product->cat_name, 'utf-8') >= 255) {
                             $product->cat_shortdesc = mb_substr($product->cat_name, 0, 252, 'utf-8') . '...';
                         }
                         //    Desctiption
                         $product->cat_shortdesc = strip_tags($product->cat_shortdesc);
                         if (mb_strlen($product->cat_shortdesc, 'utf-8') >= 512) {
                             $product->cat_shortdesc = mb_substr($product->cat_shortdesc, 0, 509, 'utf-8') . '...';
                         }
                         $this->_catRecursy($catalogTree, $product);
                     }
                 }
                 $this->setVar('catalog', $catalogTree);
             }
     }
 }
Esempio n. 4
0
 /**
  * Assign the products
  */
 function assignProducts()
 {
     $cat = (int) $this->request('cat', $this->_pid);
     $special_offer = (int) $this->request('so');
     $order_by = $this->request('o');
     $order_by_asc = (int) $this->request('asc', 2);
     if (!$cat and !$special_offer) {
         $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName());
         return;
     }
     $this->setVar('itemsPerPageDefault', $this->_itemsPerPage);
     $this->_itemsPerPage = (int) $this->request('i', $this->_itemsPerPage);
     $this->setVar('itemsPerPage', $this->_itemsPerPage);
     $model = rad_instances::get('model_corecatalog_catalog');
     if (!$special_offer) {
         $this->setVar('cat_id', $cat);
         $model->setState('tre_id', $cat);
         $tree_item = rad_instances::get('model_coremenus_tree')->getItem($cat);
         $this->setVar('tree_item', $tree_item);
     } else {
         $this->setVar('special_offer', $special_offer);
         $model->setState('special_offer', $special_offer);
         $model->setState('where_condition', ' 1 ');
         $this->addBC('so_id', $special_offer);
         $this->addBC('so_name', $this->lang('specialoffer' . $special_offer . '.catalog.title'));
     }
     $model->setState('active', 1);
     $model->setState('lang', $this->getCurrentLangID());
     if ($this->request('filter')) {
         if ((int) $this->request('brand_id')) {
             if (strstr($this->request('brand_id'), ',')) {
                 $brands = explode(',', $this->request('brand_id'));
                 foreach ($brands as $keyBrand => $valBrand) {
                     if (!(int) $valBrand) {
                         unset($brands[$keyBrand]);
                     }
                     //if
                 }
                 //foreach
             } else {
                 $brands = $this->request('brand_id', 0);
             }
             $model->setState('brand_id', $brands);
             $this->_currentFilter['brand_id'] = $brands;
         }
         if ($this->request('vv')) {
             $vv = array();
             foreach ($this->request('vv') as $vlNameId => $vvValue) {
                 if (!empty($vvValue)) {
                     $vv[$vlNameId] = $vvValue;
                 }
             }
             if (!empty($vv)) {
                 $model->setState('val_values', $vv);
                 $this->_currentFilter['vv'] = $vv;
             }
         }
         if ((double) $this->request('costfrom')) {
             $model->setState('cost.from', (double) $this->request('costfrom'));
             $this->_currentFilter['costfrom'] = (double) $this->request('costfrom');
             $model->setState('currency', model_corecatalog_currcalc::getDefaultCurrencyId());
         }
         if ((double) $this->request('costto')) {
             $model->setState('cost.to', (double) $this->request('costto'));
             $this->_currentFilter['costto'] = (double) $this->request('costto');
             $model->setState('currency', model_corecatalog_currcalc::getDefaultCurrencyId());
         }
     }
     $products_count = $model->getProductsListCount();
     $this->setVar('products_count', $products_count);
     $p = (int) $this->request('p');
     $page = $p ? $p : 0;
     $limit = $page * $this->_itemsPerPage . ',' . $this->_itemsPerPage;
     $model->setState('limit', $limit);
     $order = ' c.cat_position, ';
     switch ($this->request('o')) {
         case 'name':
             $order .= 'c.cat_name';
             break;
         case 'cost':
             $order .= 'c.cat_cost*(cr.cur_cost/' . model_corecatalog_currcalc::currCours() . ')';
             break;
         default:
             $order .= 'c.cat_name';
             break;
     }
     $order .= $this->request('asc', true) ? ' ASC' : ' DESC';
     $model->setState('order by', $order);
     $products = $model->getProductsList(true, $this->_ct_showing);
     if ($products_count) {
         $pages = div((int) $products_count, $this->_itemsPerPage);
         $pages += $products_count % $this->_itemsPerPage ? 1 : 0;
         $this->setVar('pages_count', $pages + 1);
         $this->setVar('page', $page + 1);
         $this->setVar('currPage', (int) $this->request('p', $page));
     } else {
         $this->setVar('pages_count', 0);
         $this->setVar('page', 1);
         $this->setVar('currPage', (int) $this->request('p', 0));
     }
     foreach ($products as $pkey => $product) {
         if (count($product->type_vl_link)) {
             foreach ($product->type_vl_link as $tvlkey => $tvl) {
                 if ($product->type_vl_link[$tvlkey]->vl_measurement_id) {
                     $mes_id = $product->type_vl_link[$tvlkey]->vl_measurement_id;
                     $mes = new struct_corecatalog_measurement(array('ms_id' => $mes_id));
                     $mes->load();
                     $products[$pkey]->type_vl_link[$tvlkey]->ms_value = $mes->ms_value;
                 }
             }
         }
         if ($this->config('partners.3dbin.license')) {
             rad_instances::get('model_corecatalog_3dimages')->assign3Dimages($products);
         }
     }
     $this->setVar('products', $products);
 }