Пример #1
0
 public function display($tpl = null)
 {
     $vendorId = vRequest::getInt('vendorid', 1);
     $vendorModel = VmModel::getModel('vendor');
     $vendorIdUser = vmAccess::isSuperVendor();
     $vendorModel->setId($vendorId);
     $this->vendor = $vendorModel->getVendor();
     if (!class_exists('shopFunctionsF')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     if (VmConfig::get('enable_content_plugin', 0)) {
         shopFunctionsF::triggerContentPlugin($this->vendor, 'vendor', 'vendor_store_desc');
         shopFunctionsF::triggerContentPlugin($this->vendor, 'vendor', 'vendor_terms_of_service');
     }
     $app = JFactory::getApplication();
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     if (!empty($menu->id)) {
         ShopFunctionsF::setLastVisitedItemId($menu->id);
     } else {
         if ($itemId = vRequest::getInt('Itemid', false)) {
             ShopFunctionsF::setLastVisitedItemId($itemId);
         }
     }
     $document = JFactory::getDocument();
     if (!VmConfig::get('shop_is_offline', 0)) {
         if (ShopFunctionsF::isFEmanager('product.edit')) {
             $add_product_link = JURI::root() . 'index.php?option=com_virtuemart&tmpl=component&view=product&task=edit&virtuemart_product_id=0&manage=1';
             $add_product_link = $this->linkIcon($add_product_link, 'COM_VIRTUEMART_PRODUCT_FORM_NEW_PRODUCT', 'edit', false, false);
         } else {
             $add_product_link = "";
         }
         $this->assignRef('add_product_link', $add_product_link);
         $categoryModel = VmModel::getModel('category');
         $productModel = VmModel::getModel('product');
         $ratingModel = VmModel::getModel('ratings');
         $productModel->withRating = $this->showRating = $ratingModel->showRating();
         $this->products = array();
         $categoryId = vRequest::getInt('catid', 0);
         $categoryChildren = $categoryModel->getChildCategoryList($vendorId, $categoryId);
         $categoryModel->addImages($categoryChildren, 1);
         $this->assignRef('categories', $categoryChildren);
         if (!class_exists('CurrencyDisplay')) {
             require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php';
         }
         $this->currency = CurrencyDisplay::getInstance();
         $products_per_row = VmConfig::get('homepage_products_per_row', 3);
         $featured_products_rows = VmConfig::get('featured_products_rows', 1);
         $featured_products_count = $products_per_row * $featured_products_rows;
         if (!empty($featured_products_count) and VmConfig::get('show_featured', 1)) {
             $this->products['featured'] = $productModel->getProductListing('featured', $featured_products_count);
             $productModel->addImages($this->products['featured'], 1);
         }
         $latest_products_rows = VmConfig::get('latest_products_rows');
         $latest_products_count = $products_per_row * $latest_products_rows;
         if (!empty($latest_products_count) and VmConfig::get('show_latest', 1)) {
             $this->products['latest'] = $productModel->getProductListing('latest', $latest_products_count);
             $productModel->addImages($this->products['latest'], 1);
         }
         $topTen_products_rows = VmConfig::get('topTen_products_rows');
         $topTen_products_count = $products_per_row * $topTen_products_rows;
         if (!empty($topTen_products_count) and VmConfig::get('show_topTen', 1)) {
             $this->products['topten'] = $productModel->getProductListing('topten', $topTen_products_count);
             $productModel->addImages($this->products['topten'], 1);
         }
         $recent_products_rows = VmConfig::get('recent_products_rows');
         $recent_products_count = $products_per_row * $recent_products_rows;
         if (!empty($recent_products_count) and VmConfig::get('show_recent', 1)) {
             $recent_products = $productModel->getProductListing('recent');
             if (!empty($recent_products)) {
                 $this->products['recent'] = $productModel->getProductListing('recent', $recent_products_count);
                 $productModel->addImages($this->products['recent'], 1);
             }
         }
         if ($this->products) {
             $display_stock = VmConfig::get('display_stock', 1);
             $showCustoms = VmConfig::get('show_pcustoms', 1);
             if ($display_stock or $showCustoms) {
                 if (!$showCustoms) {
                     foreach ($this->products as $pType => $productSeries) {
                         foreach ($productSeries as $i => $productItem) {
                             $this->products[$pType][$i]->stock = $productModel->getStockIndicator($productItem);
                         }
                     }
                 } else {
                     if (!class_exists('vmCustomPlugin')) {
                         require JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php';
                     }
                     foreach ($this->products as $pType => $productSeries) {
                         shopFunctionsF::sortLoadProductCustomsStockInd($this->products[$pType], $productModel);
                     }
                 }
             }
         }
         $this->showBasePrice = (vmAccess::manager() or vmAccess::isSuperVendor());
         $layout = VmConfig::get('vmlayout', 'default');
         $this->setLayout($layout);
         $productsLayout = VmConfig::get('productsublayout', 'products');
         if (empty($productsLayout)) {
             $productsLayout = 'products';
         }
         $this->productsLayout = empty($menu->query['productsublayout']) ? $productsLayout : $menu->query['productsublayout'];
         // Add feed links
         if ($this->products && (VmConfig::get('feed_featured_published', 0) == 1 or VmConfig::get('feed_topten_published', 0) == 1 or VmConfig::get('feed_latest_published', 0) == 1)) {
             $link = '&format=feed&limitstart=';
             $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
             $document->addHeadLink(JRoute::_($link . '&type=rss', FALSE), 'alternate', 'rel', $attribs);
             $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
             $document->addHeadLink(JRoute::_($link . '&type=atom', FALSE), 'alternate', 'rel', $attribs);
         }
         vmJsApi::jPrice();
     } else {
         $this->setLayout('off_line');
     }
     $error = vRequest::getInt('error', 0);
     //Todo this may not work everytime as expected, because the error must be set in the redirect links.
     if (!empty($error)) {
         $document->setTitle(vmText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND') . vmText::sprintf('COM_VIRTUEMART_HOME', $this->vendor->vendor_store_name));
     } else {
         if (empty($this->vendor->customtitle)) {
             if ($menu) {
                 $menuTitle = $menu->params->get('page_title');
                 if (empty($menuTitle)) {
                     $menuTitle = vmText::sprintf('COM_VIRTUEMART_HOME', $this->vendor->vendor_store_name);
                 }
                 $document->setTitle($menuTitle);
             } else {
                 $title = vmText::sprintf('COM_VIRTUEMART_HOME', $this->vendor->vendor_store_name);
                 $document->setTitle($title);
             }
         } else {
             $document->setTitle($this->vendor->customtitle);
         }
         if (!empty($this->vendor->metadesc)) {
             $document->setMetaData('description', $this->vendor->metadesc);
         }
         if (!empty($this->vendor->metakey)) {
             $document->setMetaData('keywords', $this->vendor->metakey);
         }
         if (!empty($this->vendor->metarobot)) {
             $document->setMetaData('robots', $this->vendor->metarobot);
         }
         if (!empty($this->vendor->metaauthor)) {
             $document->setMetaData('author', $this->vendor->metaauthor);
         }
     }
     if (!class_exists('VmTemplate')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'vmtemplate.php';
     }
     vmTemplate::setTemplate();
     parent::display($tpl);
 }
Пример #2
0
 public function display($tpl = null)
 {
     $show_prices = VmConfig::get('show_prices', 1);
     if ($show_prices == '1') {
         if (!class_exists('calculationHelper')) {
             require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php';
         }
     }
     $this->assignRef('show_prices', $show_prices);
     if (!class_exists('shopFunctionsF')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     $document = JFactory::getDocument();
     $app = JFactory::getApplication();
     $pathway = $app->getPathway();
     if (!class_exists('VmImage')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php';
     }
     // set search and keyword
     if ($keyword = vRequest::getString('keyword', false)) {
         //uword('keyword', false, ' ,-,+,.,_')) {
         $pathway->addItem($keyword);
         //$title .=' ('.$keyword.')';
     }
     //$search = vRequest::uword('keyword', null);
     $this->searchcustom = '';
     $this->searchCustomValues = '';
     //if (!empty($keyword)) {
     $this->getSearchCustom();
     $search = $keyword;
     /*} else {
     			$keyword ='';
     			$search = NULL;
     		}*/
     $this->assignRef('keyword', $keyword);
     $this->assignRef('search', $search);
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     if (!empty($menu->id)) {
         ShopFunctionsF::setLastVisitedItemId($menu->id);
     } else {
         if ($itemId = vRequest::getInt('Itemid', false)) {
             ShopFunctionsF::setLastVisitedItemId($itemId);
         }
     }
     $virtuemart_manufacturer_id = vRequest::getInt('virtuemart_manufacturer_id', -1);
     if ($virtuemart_manufacturer_id === -1 and !empty($menu->query['virtuemart_manufacturer_id'])) {
         $virtuemart_manufacturer_id = $menu->query['virtuemart_manufacturer_id'];
         vRequest::setVar('virtuemart_manufacturer_id', $virtuemart_manufacturer_id);
     }
     $this->categoryId = vRequest::getInt('virtuemart_category_id', -1);
     if ($this->categoryId === -1 and !empty($menu->query['virtuemart_category_id'])) {
         $this->categoryId = $menu->query['virtuemart_category_id'];
         vRequest::setVar('virtuemart_category_id', $this->categoryId);
     } else {
         if ($this->categoryId === -1 and $virtuemart_manufacturer_id === -1) {
             $this->categoryId = ShopFunctionsF::getLastVisitedCategoryId();
         }
     }
     $this->setCanonicalLink($tpl, $document, $this->categoryId, $virtuemart_manufacturer_id);
     if (($this->categoryId === -1 or $this->categoryId === 0) and $virtuemart_manufacturer_id) {
         $this->categoryId = 0;
         $catType = 'manufacturer';
         $this->setCanonicalLink($tpl, $document, $virtuemart_manufacturer_id, $catType);
     }
     $categoryModel = VmModel::getModel('category');
     $productModel = VmModel::getModel('product');
     if ($this->categoryId === -1) {
         $this->categoryId = 0;
     }
     $vendorId = 1;
     $category = $categoryModel->getCategory($this->categoryId);
     if (!isset($menu->query['showproducts'])) {
         $menu->query['showproducts'] = 1;
     }
     $this->showproducts = vRequest::getInt('showproducts', $menu->query['showproducts']);
     if (!empty($category)) {
         $vendorId = $category->virtuemart_vendor_id;
         if ($this->showproducts) {
             //if(empty($category->category_layout) or $category->category_layout != 'categories') {
             // Load the products in the given category
             $ids = $productModel->sortSearchListQuery(TRUE, $this->categoryId);
             $this->perRow = empty($category->products_per_row) ? VmConfig::get('products_per_row', 3) : $category->products_per_row;
             $this->vmPagination = $productModel->getPagination($this->perRow);
             $ratingModel = VmModel::getModel('ratings');
             $this->showRating = $ratingModel->showRating();
             $productModel->withRating = $this->showRating;
             $this->orderByList = $productModel->getOrderByList($this->categoryId);
             $this->products = $productModel->getProducts($ids);
             //$products = $productModel->getProductsInCategory($this->categoryId);
             $imgAmount = VmConfig::get('prodimg_browse', 1);
             $productModel->addImages($this->products, $imgAmount);
             if ($this->products) {
                 $currency = CurrencyDisplay::getInstance();
                 $this->assignRef('currency', $currency);
                 $display_stock = VmConfig::get('display_stock', 1);
                 $showCustoms = VmConfig::get('show_pcustoms', 1);
                 if ($display_stock or $showCustoms) {
                     if (!$showCustoms) {
                         foreach ($this->products as $i => $productItem) {
                             $productItem->stock = $productModel->getStockIndicator($productItem);
                         }
                     } else {
                         shopFunctionsF::sortLoadProductCustomsStockInd($this->products, $productModel);
                     }
                 }
                 // add javascript for price and cart, need even for quantity buttons, so we need it almost anywhere
                 vmJsApi::jPrice();
             }
             // Add feed links
             if ($this->showproducts and $this->products && VmConfig::get('feed_cat_published', 0) == 1) {
                 $link = '&format=feed&limitstart=';
                 $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
                 $document->addHeadLink(JRoute::_($link . '&type=rss', FALSE), 'alternate', 'rel', $attribs);
                 $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
                 $document->addHeadLink(JRoute::_($link . '&type=atom', FALSE), 'alternate', 'rel', $attribs);
             }
             $user = JFactory::getUser();
             $this->showBasePrice = (vmAccess::manager() or vmAccess::isSuperVendor());
         }
         //No redirect here, for category id = 0 means show ALL categories! note by Max Milbers
         if (!empty($this->categoryId) and $this->categoryId !== -1 and (empty($category->slug) or !$category->published)) {
             if (empty($category->slug)) {
                 vmInfo(vmText::_('COM_VIRTUEMART_CAT_NOT_FOUND'));
             } else {
                 if ($category->virtuemart_id !== 0 and !$category->published) {
                     vmInfo('COM_VIRTUEMART_CAT_NOT_PUBL', $category->category_name, $this->categoryId);
                 }
             }
             //Fallback
             $categoryLink = '';
             if ($category->category_parent_id) {
                 $categoryLink = '&view=category&virtuemart_category_id=' . $category->category_parent_id;
             } else {
                 $last_category_id = shopFunctionsF::getLastVisitedCategoryId();
                 if (!$last_category_id or $this->categoryId == $last_category_id) {
                     $last_category_id = vRequest::getInt('virtuemart_category_id', false);
                 }
                 if ($last_category_id and $this->categoryId != $last_category_id) {
                     $categoryLink = '&view=category&virtuemart_category_id=' . $last_category_id;
                 }
             }
             if (VmConfig::get('handle_404', 1)) {
                 $app->redirect(JRoute::_('index.php?option=com_virtuemart' . $categoryLink . '&error=404', FALSE));
             } else {
                 JError::raise(E_ERROR, '404', 'Not found');
             }
             return;
         }
         shopFunctionsF::setLastVisitedCategoryId($this->categoryId);
         shopFunctionsF::setLastVisitedManuId($virtuemart_manufacturer_id);
         // Add the category name to the pathway
         if ($category->parents) {
             foreach ($category->parents as $c) {
                 $pathway->addItem(strip_tags(vmText::_($c->category_name)), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id, FALSE));
             }
         }
         $catImgAmount = VmConfig::get('catimg_browse', 1);
         $categoryModel->addImages($category, $catImgAmount);
         if (!isset($menu->query['showcategory'])) {
             $menu->query['showcategory'] = 1;
         }
         $this->showcategory = vRequest::getInt('showcategory', $menu->query['showcategory']);
         //$this->showcategory = vRequest::getInt('showcategory',true);
         if ($this->showcategory) {
             //if($category->category_layout == 'categories' or ($this->categoryId >0 and $virtuemart_manufacturer_id <1)){
             $category->children = $categoryModel->getChildCategoryList($vendorId, $this->categoryId, $categoryModel->getDefaultOrdering(), $categoryModel->_selectedOrderingDir);
             $categoryModel->addImages($category->children, $catImgAmount);
         } else {
             $category->children = false;
         }
         if (VmConfig::get('enable_content_plugin', 0)) {
             shopFunctionsF::triggerContentPlugin($category, 'category', 'category_description');
         }
         $metadesc = '';
         $metakey = '';
         $metarobot = '';
         if (isset($menu->params)) {
             $metadesc = $menu->params->get('menu-meta_description');
             $metakey = $menu->params->get('menu-meta_keywords');
             $metarobot = $menu->params->get('robots');
         }
         if ($category->metadesc) {
             $metadesc = $category->metadesc;
         }
         if ($category->metakey) {
             $metakey = $category->metakey;
         }
         if ($category->metarobot) {
             $metarobot = $category->metarobot;
         }
         $document->setDescription($metadesc);
         $document->setMetaData('keywords', $metakey);
         $document->setMetaData('robots', $metarobot);
         if ($app->getCfg('MetaAuthor') == '1' and !empty($category->metaauthor)) {
             $document->setMetaData('author', $category->metaauthor);
         }
         if (empty($category->category_template)) {
             $category->category_template = VmConfig::get('categorytemplate');
         }
         if (!empty($menu->query['categorylayout'])) {
             //if(!empty($menu->query['categorylayout']) and $menu->query['virtuemart_category_id']==$this->categoryId){
             $category->category_layout = $menu->query['categorylayout'];
         }
         $productsLayout = VmConfig::get('productsublayout', 'products');
         if (empty($productsLayout)) {
             $productsLayout = 'products';
         }
         $this->productsLayout = empty($menu->query['productsublayout']) ? $productsLayout : $menu->query['productsublayout'];
         shopFunctionsF::setVmTemplate($this, $category->category_template, 0, $category->category_layout);
     } else {
         //Backward compatibility
         if (!isset($category)) {
             $category = new stdClass();
             $category->category_name = '';
             $category->category_description = '';
             $category->haschildren = false;
         }
     }
     $this->assignRef('category', $category);
     // Set the titles
     if (!empty($category->customtitle)) {
         $title = strip_tags($category->customtitle);
     } elseif (!empty($category->category_name)) {
         $title = strip_tags($category->category_name);
     } else {
         $title = $this->setTitleByJMenu($app);
     }
     $title = vmText::_($title);
     if (vRequest::getInt('error')) {
         $title .= ' ' . vmText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND');
     }
     if (!empty($keyword)) {
         $title .= ' (' . strip_tags(htmlspecialchars_decode($keyword)) . ')';
     }
     if ($virtuemart_manufacturer_id > 0 and !empty($this->products[0])) {
         $title .= ' ' . $this->products[0]->mf_name;
     }
     $document->setTitle($title);
     // Override Category name when viewing manufacturers products !IMPORTANT AFTER page title.
     if ($virtuemart_manufacturer_id > 0 and !empty($this->products[0]) and isset($category->category_name)) {
         $category->category_name = $this->products[0]->mf_name;
     }
     if ($app->getCfg('MetaTitle') == '1') {
         $document->setMetaData('title', $title);
     }
     parent::display($tpl);
 }
        echo $output;
        vmdebug('Use cached mod products');
        return true;
    }
}
$vendorId = vRequest::getInt('vendorid', 1);
if ($filter_category) {
    $filter_category = TRUE;
}
$productModel = tmsModel::getModel('Product');
$products = $productModel->getProductListing($Product_group, $max_items, $show_price, true, false, $filter_category, $category_id);
$productModel->addImages($products);
if (!class_exists('shopFunctionsF')) {
    require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
}
shopFunctionsF::sortLoadProductCustomsStockInd($products, $productModel);
$totalProd = count($products);
if (empty($products)) {
    return false;
}
if (!class_exists('CurrencyDisplay')) {
    require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php';
}
$currency = CurrencyDisplay::getInstance();
ob_start();
/* Load tmpl default */
require JModuleHelper::getLayoutPath('mod_virtuemart_product', $layout);
$output = ob_get_clean();
echo $output;
if ($cache) {
    $cache->store($output, $key);