Exemplo n.º 1
0
 /**
  * Displays the view, collects needed data for the different layouts
  *
  * Okey I try now a completly new idea.
  * We make a function for every tab and the display is getting the right tabs by an own function
  * putting that in an array and after that we call the preparedataforlayoutBlub
  *
  * @author Max Milbers
  */
 function display($tpl = null)
 {
     $document = JFactory::getDocument();
     $mainframe = JFactory::getApplication();
     $pathway = $mainframe->getPathway();
     $layoutName = $this->getLayout();
     $model = VmModel::getModel();
     $virtuemart_vendor_id = JRequest::getInt('virtuemart_vendor_id');
     // 		if ($layoutName=='default') {
     if (empty($virtuemart_vendor_id)) {
         $document->setTitle(JText::_('COM_VIRTUEMART_VENDOR_LIST'));
         $pathway->addItem(JText::_('COM_VIRTUEMART_VENDOR_LIST'));
         $vendors = $model->getVendors();
         $model->addImages($vendors);
         $this->assignRef('vendors', $vendors);
     } else {
         $vendor = $model->getVendor($virtuemart_vendor_id);
         $model->addImages($vendor);
         if (VmConfig::get('enable_content_plugin', 0)) {
             if (!class_exists('shopFunctionsF')) {
                 require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
             }
             shopFunctionsF::triggerContentPlugin($vendor, 'vendor', 'vendor_store_desc');
             shopFunctionsF::triggerContentPlugin($vendor, 'vendor', 'vendor_terms_of_service');
         }
         $this->assignRef('vendor', $vendor);
         if (!class_exists('VirtueMartModelVendor')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php';
         }
         $userId = VirtueMartModelVendor::getUserIdByVendorId($virtuemart_vendor_id);
         //$usermodel = VmModel::getModel('user');
         //$virtuemart_userinfo_id = $usermodel->getBTuserinfo_id($userId);
         //$usermodel->getVendor($virtuemart_vendor_id);
         //$userFields = $usermodel->getUserInfoInUserFields($layoutName, 'BT', $virtuemart_userinfo_id,true,true);
         //$this->assignRef('userFields', $userFields);
         if ($layoutName == 'tos') {
             $document->setTitle(JText::_('COM_VIRTUEMART_VENDOR_TOS'));
             $pathway->addItem(JText::_('COM_VIRTUEMART_VENDOR_TOS'));
         } elseif ($layoutName == 'contact') {
             $user = JFactory::getUser();
             $document->setTitle(JText::_('COM_VIRTUEMART_VENDOR_CONTACT'));
             $pathway->addItem(JText::_('COM_VIRTUEMART_VENDOR_CONTACT'));
             $this->assignRef('user', $user);
         } else {
             $document->setTitle(JText::_('COM_VIRTUEMART_VENDOR_DETAILS'));
             $pathway->addItem(JText::_('COM_VIRTUEMART_VENDOR_DETAILS'));
             $this->setLayout('details');
         }
         $linkdetails = '<a href="' . JRoute::_('index.php?option=com_virtuemart&view=vendor&layout=details&virtuemart_vendor_id=' . $virtuemart_vendor_id, FALSE) . '">' . JText::_('COM_VIRTUEMART_VENDOR_DETAILS') . '</a>';
         $linkcontact = '<a href="' . JRoute::_('index.php?option=com_virtuemart&view=vendor&layout=contact&virtuemart_vendor_id=' . $virtuemart_vendor_id, FALSE) . '">' . JText::_('COM_VIRTUEMART_VENDOR_CONTACT') . '</a>';
         $linktos = '<a href="' . JRoute::_('index.php?option=com_virtuemart&view=vendor&layout=tos&virtuemart_vendor_id=' . $virtuemart_vendor_id, FALSE) . '">' . JText::_('COM_VIRTUEMART_VENDOR_TOS') . '</a>';
         //$this->assignRef('lineSeparator', $lineSeparator);
         $this->assignRef('linkdetails', $linkdetails);
         $this->assignRef('linkcontact', $linkcontact);
         $this->assignRef('linktos', $linktos);
     }
     parent::display($tpl);
 }
Exemplo n.º 2
0
 function display($tpl = null)
 {
     $document = JFactory::getDocument();
     $mainframe = JFactory::getApplication();
     $pathway = $mainframe->getPathway();
     if (!class_exists('VmImage')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php';
     }
     $virtuemart_manufacturer_id = vRequest::getInt('virtuemart_manufacturer_id', 0);
     $mf_category_id = vRequest::getInt('mf_category_id', 0);
     // get necessary models
     $model = VmModel::getModel('manufacturer');
     if ($virtuemart_manufacturer_id != 0) {
         $manufacturer = $model->getManufacturer();
         $model->addImages($manufacturer, 1);
         $manufacturerImage = $manufacturer->images[0]->displayMediaThumb('class="manufacturer-image"', false);
         if (VmConfig::get('enable_content_plugin', 0)) {
             if (!class_exists('shopFunctionsF')) {
                 require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
             }
             shopFunctionsF::triggerContentPlugin($manufacturer, 'manufacturer', 'mf_desc');
         }
         $document->setTitle(vmText::_('COM_VIRTUEMART_MANUFACTURER_DETAILS') . ' ' . strip_tags($manufacturer->mf_name));
         //added so that the canonical points to page with visible products thx to P2Peter
         // remove joomla canonical before adding it
         foreach ($document->_links as $k => $array) {
             if ($array['relation'] == 'canonical') {
                 unset($document->_links[$k]);
                 break;
             }
         }
         $document->addHeadLink(JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_manufacturer_id=' . $virtuemart_manufacturer_id, FALSE), 'canonical', 'rel', '');
         $this->assignRef('manufacturerImage', $manufacturerImage);
         $this->assignRef('manufacturer', $manufacturer);
         $pathway->addItem(strip_tags($manufacturer->mf_name));
         $this->setLayout('details');
     } else {
         $document->setTitle(vmText::_('COM_VIRTUEMART_MANUFACTURER_PAGE'));
         $manufacturers = $model->getManufacturers(true, true, true);
         $model->addImages($manufacturers, 1);
         $this->assignRef('manufacturers', $manufacturers);
         $this->setLayout('default');
     }
     parent::display($tpl);
 }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
0
	public function display($tpl = null) {

		$vendorId = vRequest::getInt('vendorid', 1);

		$vendorModel = VmModel::getModel('vendor');

		$vendorIdUser = VmConfig::isSuperVendor();
		$vendorModel->setId($vendorId);
		$vendor = $vendorModel->getVendor();

		if(!class_exists('shopFunctionsF'))require(VMPATH_SITE.DS.'helpers'.DS.'shopfunctionsf.php');
		if (VmConfig::get ('enable_content_plugin', 0)) {
			shopFunctionsF::triggerContentPlugin($vendor, 'vendor','vendor_store_desc');
			shopFunctionsF::triggerContentPlugin($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);
		}

		$this->assignRef('vendor',$vendor);

		$document = JFactory::getDocument();

		if(!VmConfig::get('shop_is_offline',0)){

			vmJsApi::jPrice();
			//if($vendorIdUser){
				//$user = JFactory::getUser();
				if( $vendorIdUser ){
					$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');
			$currency = CurrencyDisplay::getInstance( );
			$this->assignRef('currency', $currency);
			
			$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;
			$recent_products = $productModel->getProductListing('recent');
			
			if (!empty($recent_products_count) and VmConfig::get('show_recent', 1) and !empty($recent_products)) {
				$this->products['recent']= $productModel->getProductListing('recent', $recent_products_count);
				$productModel->addImages($this->products['recent'],1);
			}

			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 $pType => $productSeries){
							foreach($productSeries as $i => $productItem){
								$productItem->stock = $productModel->getStockIndicator($productItem);
							}
						}
					} else {
						$customfieldsModel = VmModel::getModel ('Customfields');
						if (!class_exists ('vmCustomPlugin')) {
							require(JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php');
						}
						foreach($this->products as $pType => $productSeries){

							foreach($productSeries as $i => $productItem){

								if (!empty($productItem->customfields)) {

									$product = clone($productItem);
									$customfields = array();
									foreach($productItem->customfields as $cu){
										$customfields[] = clone ($cu);
									}

									$customfieldsSorted = array();
									$customfieldsModel -> displayProductCustomfieldFE ($product, $customfields);
									$product->stock = $productModel->getStockIndicator($product);
									foreach ($customfields as $k => $custom) {
										if (!empty($custom->layout_pos)  ) {
											$customfieldsSorted[$custom->layout_pos][] = $custom;
											unset($customfields[$k]);
										}
									}
									$customfieldsSorted['normal'] = $customfields;
									$product->customfieldsSorted = $customfieldsSorted;
									unset($product->customfields);
									$this->products[$pType][$i] = $product;
								} else {
									$productItem->stock = $productModel->getStockIndicator($productItem);
									$this->products[$pType][$i] = $productItem;
								}

							}
						}
					}
				}
			}

			$user = JFactory::getUser();
			$showBasePrice = ($user->authorise('core.admin','com_virtuemart') or $user->authorise('core.manage','com_virtuemart') or VmConfig::isSuperVendor());
			$this->assignRef('showBasePrice', $showBasePrice);

			$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);
			}
		} 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',$vendor->vendor_store_name));
		} else {

			if(empty($vendor->customtitle)){

				if ($menu){
					$menuTitle = $menu->params->get('page_title');
					if(empty($menuTitle)) {
						$menuTitle = vmText::sprintf('COM_VIRTUEMART_HOME',$vendor->vendor_store_name);
					}
					$document->setTitle($menuTitle);
				} else {
					$title = vmText::sprintf('COM_VIRTUEMART_HOME',$vendor->vendor_store_name);
					$document->setTitle($title);
				}
			} else {
				$document->setTitle($vendor->customtitle);
			}


			if(!empty($vendor->metadesc)) $document->setMetaData('description',$vendor->metadesc);
			if(!empty($vendor->metakey)) $document->setMetaData('keywords',$vendor->metakey);
			if(!empty($vendor->metarobot)) $document->setMetaData('robots',$vendor->metarobot);
			if(!empty($vendor->metaauthor)) $document->setMetaData('author',$vendor->metaauthor);

		}

		if(!class_exists('VmTemplate')) require(VMPATH_SITE.DS.'helpers'.DS.'vmtemplate.php');
		vmTemplate::setTemplate();

		parent::display($tpl);

	}
Exemplo n.º 5
0
 public function display($tpl = null)
 {
     $document = JFactory::getDocument();
     VmConfig::loadJLang('com_virtuemart_shoppers', true);
     //We never want that the cart is indexed
     $document->setMetaData('robots', 'NOINDEX, NOFOLLOW, NOARCHIVE, NOSNIPPET');
     if (empty($this->uselayout)) {
         $layout = JRequest::getWord('layout', 'mail');
     } else {
         $layout = $this->uselayout;
     }
     switch ($layout) {
         case 'invoice':
             $this->doctype = $layout;
             $title = JText::_('COM_VIRTUEMART_INVOICE');
             break;
         case 'deliverynote':
             $this->doctype = $layout;
             $layout = 'invoice';
             $title = JText::_('COM_VIRTUEMART_DELIVERYNOTE');
             break;
         case 'confirmation':
             $this->doctype = $layout;
             $layout = 'confirmation';
             $title = JText::_('COM_VIRTUEMART_CONFIRMATION');
             break;
         case 'mail':
             if (VmConfig::get('order_mail_html')) {
                 $layout = 'mail_html';
             } else {
                 $layout = 'mail_raw';
             }
     }
     $this->setLayout($layout);
     $tmpl = JRequest::getWord('tmpl');
     $print = false;
     if ($tmpl) {
         $print = true;
     }
     $this->assignRef('print', $print);
     $this->format = JRequest::getWord('format', 'html');
     if ($layout == 'invoice') {
         $document->setTitle(JText::_('COM_VIRTUEMART_INVOICE'));
     }
     $order_print = false;
     if ($print and $this->format == 'html') {
         $order_print = true;
     }
     $orderModel = VmModel::getModel('orders');
     $orderDetails = $this->orderDetails;
     if ($orderDetails == 0) {
         $orderDetails = $orderModel->getMyOrderDetails();
         if (!$orderDetails or empty($orderDetails['details'])) {
             echo JText::_('COM_VIRTUEMART_CART_ORDER_NOTFOUND');
             return;
         }
     }
     if (empty($orderDetails['details'])) {
         echo JText::_('COM_VIRTUEMART_ORDER_NOTFOUND');
         return 0;
     }
     if (!empty($orderDetails['details']['BT']->order_language)) {
         $jlang = JFactory::getLanguage();
         $jlang->load('com_virtuemart', JPATH_SITE, $orderDetails['details']['BT']->order_language, true);
         $jlang->load('com_virtuemart_shoppers', JPATH_SITE, $orderDetails['details']['BT']->order_language, true);
         $jlang->load('com_virtuemart_orders', JPATH_SITE, $orderDetails['details']['BT']->order_language, true);
     }
     $this->assignRef('orderDetails', $orderDetails);
     // if it is order print, invoice number should not be created, either it is there, either it has not been created
     if (empty($this->invoiceNumber) and !$order_print) {
         $invoiceNumberDate = array();
         if ($orderModel->createInvoiceNumber($orderDetails['details']['BT'], $invoiceNumberDate)) {
             if (ShopFunctions::InvoiceNumberReserved($invoiceNumberDate[0])) {
                 if ($this->uselayout != 'mail') {
                     $document->setTitle(JText::_('COM_VIRTUEMART_PAYMENT_INVOICE'));
                     return;
                 }
             }
             $this->invoiceNumber = $invoiceNumberDate[0];
             $this->invoiceDate = $invoiceNumberDate[1];
             if (!$this->invoiceNumber or empty($this->invoiceNumber)) {
                 vmError('Cant create pdf, createInvoiceNumber failed');
                 if ($this->uselayout != 'mail') {
                     return;
                 }
             }
         } else {
             // Could OR should not create Invoice Number, createInvoiceNumber failed
             if ($this->uselayout != 'mail') {
                 return;
             }
         }
     }
     //Todo multix
     $vendorId = 1;
     $emailCurrencyId = $orderDetails['details']['BT']->user_currency_id;
     $exchangeRate = FALSE;
     if (!class_exists('vmPSPlugin')) {
         require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
     }
     JPluginHelper::importPlugin('vmpayment');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('plgVmgetEmailCurrency', array($orderDetails['details']['BT']->virtuemart_paymentmethod_id, $orderDetails['details']['BT']->virtuemart_order_id, &$emailCurrencyId));
     if (!class_exists('CurrencyDisplay')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     $currency = CurrencyDisplay::getInstance($emailCurrencyId, $vendorId);
     if ($emailCurrencyId) {
         $currency->exchangeRateShopper = $orderDetails['details']['BT']->user_currency_rate;
     }
     $this->assignRef('currency', $currency);
     //Create BT address fields
     $userFieldsModel = VmModel::getModel('userfields');
     $_userFields = $userFieldsModel->getUserFields('account', array('captcha' => true, 'delimiters' => true), array('delimiter_userinfo', 'user_is_vendor', 'username', 'password', 'password2', 'agreed', 'address_type'));
     $userfields = $userFieldsModel->getUserFieldsFilled($_userFields, $orderDetails['details']['BT']);
     $this->assignRef('userfields', $userfields);
     //Create ST address fields
     $orderst = array_key_exists('ST', $orderDetails['details']) ? $orderDetails['details']['ST'] : $orderDetails['details']['BT'];
     $shipmentFieldset = $userFieldsModel->getUserFields('shipment', array(), array('delimiter_userinfo', 'username', 'email', 'password', 'password2', 'agreed', 'address_type'));
     $shipmentfields = $userFieldsModel->getUserFieldsFilled($shipmentFieldset, $orderst);
     $this->assignRef('shipmentfields', $shipmentfields);
     $civility = "";
     foreach ($userfields['fields'] as $field) {
         if ($field['name'] == "title") {
             $civility = $field['value'];
             break;
         }
     }
     $company = empty($orderDetails['details']['BT']->company) ? "" : $orderDetails['details']['BT']->company . ", ";
     $shopperName = $company . $civility . ' ' . $orderDetails['details']['BT']->first_name . ' ' . $orderDetails['details']['BT']->last_name;
     $this->assignRef('shopperName', $shopperName);
     $this->assignRef('civility', $civility);
     // Create an array to allow orderlinestatuses to be translated
     // We'll probably want to put this somewhere in ShopFunctions..
     $orderStatusModel = VmModel::getModel('orderstatus');
     $_orderstatuses = $orderStatusModel->getOrderStatusList();
     $orderstatuses = array();
     foreach ($_orderstatuses as $_ordstat) {
         $orderstatuses[$_ordstat->order_status_code] = JText::_($_ordstat->order_status_name);
     }
     $this->assignRef('orderstatuslist', $orderstatuses);
     $this->assignRef('orderstatuses', $orderstatuses);
     $_itemStatusUpdateFields = array();
     $_itemAttributesUpdateFields = array();
     foreach ($orderDetails['items'] as $_item) {
         // 			$_itemStatusUpdateFields[$_item->virtuemart_order_item_id] = JHTML::_('select.genericlist', $orderstatuses, "item_id[".$_item->virtuemart_order_item_id."][order_status]", 'class="selectItemStatusCode"', 'order_status_code', 'order_status_name', $_item->order_status, 'order_item_status'.$_item->virtuemart_order_item_id,true);
         $_itemStatusUpdateFields[$_item->virtuemart_order_item_id] = $_item->order_status;
     }
     if (empty($orderDetails['shipmentName'])) {
         if (!class_exists('vmPSPlugin')) {
             require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
         }
         JPluginHelper::importPlugin('vmshipment');
         $dispatcher = JDispatcher::getInstance();
         $returnValues = $dispatcher->trigger('plgVmOnShowOrderFEShipment', array($orderDetails['details']['BT']->virtuemart_order_id, $orderDetails['details']['BT']->virtuemart_shipmentmethod_id, &$orderDetails['shipmentName']));
     }
     if (empty($orderDetails['paymentName'])) {
         if (!class_exists('vmPSPlugin')) {
             require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
         }
         JPluginHelper::importPlugin('vmpayment');
         $dispatcher = JDispatcher::getInstance();
         $returnValues = $dispatcher->trigger('plgVmOnShowOrderFEPayment', array($orderDetails['details']['BT']->virtuemart_order_id, $orderDetails['details']['BT']->virtuemart_paymentmethod_id, &$orderDetails['paymentName']));
     }
     $virtuemart_vendor_id = 1;
     $vendorModel = VmModel::getModel('vendor');
     $vendor = $vendorModel->getVendor($virtuemart_vendor_id);
     $vendorModel->addImages($vendor);
     $vendor->vendorFields = $vendorModel->getVendorAddressFields();
     if (VmConfig::get('enable_content_plugin', 0)) {
         if (!class_exists('shopFunctionsF')) {
             require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
         }
         shopFunctionsF::triggerContentPlugin($vendor, 'vendor', 'vendor_store_desc');
         shopFunctionsF::triggerContentPlugin($vendor, 'vendor', 'vendor_terms_of_service');
         shopFunctionsF::triggerContentPlugin($vendor, 'vendor', 'vendor_legal_info');
     }
     $this->assignRef('vendor', $vendor);
     // 		vmdebug('vendor', $vendor);
     if (strpos($layout, 'mail') !== false) {
         $lineSeparator = "<br />";
     } else {
         $lineSeparator = "\n";
     }
     $this->assignRef('headFooter', $this->showHeaderFooter);
     //Attention, this function will be removed, it wont be deleted, but it is obsoloete in any view.html.php
     if (!class_exists('ShopFunctions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php';
     }
     $vendorAddress = shopFunctions::renderVendorAddress($virtuemart_vendor_id, $lineSeparator);
     $this->assignRef('vendorAddress', $vendorAddress);
     $vendorEmail = $vendorModel->getVendorEmail($virtuemart_vendor_id);
     $vars['vendorEmail'] = $vendorEmail;
     // this is no setting in BE to change the layout !
     //shopFunctionsF::setVmTemplate($this,0,0,$layoutName);
     //vmdebug('renderMailLayout invoice '.date('H:i:s'),$this->order);
     if (strpos($layout, 'mail') !== false) {
         if ($this->doVendor) {
             //Old text key COM_VIRTUEMART_MAIL_SUBJ_VENDOR_C
             $this->subject = JText::sprintf('COM_VIRTUEMART_MAIL_SUBJ_VENDOR_' . $orderDetails['details']['BT']->order_status, $this->shopperName, strip_tags($currency->priceDisplay($orderDetails['details']['BT']->order_total, $currency)), $orderDetails['details']['BT']->order_number);
             $recipient = 'vendor';
         } else {
             $this->subject = JText::sprintf('COM_VIRTUEMART_MAIL_SUBJ_SHOPPER_' . $orderDetails['details']['BT']->order_status, $vendor->vendor_store_name, strip_tags($currency->priceDisplay($orderDetails['details']['BT']->order_total, $currency)), $orderDetails['details']['BT']->order_number);
             $recipient = 'shopper';
         }
         $this->assignRef('recipient', $recipient);
     }
     $tpl = null;
     // 		vmdebug('my view data',$this->getLayout(),$layout);
     // 		ob_start();
     // 		echo '<pre>';
     // 		echo debug_print_backtrace();
     // 		echo '</pre>';
     // 		$dumptrace = ob_get_contents();
     // 		ob_end_clean();
     // 		return false;
     parent::display($tpl);
 }
Exemplo n.º 6
0
 function prepareVendor()
 {
     if (empty($this->vendor)) {
         $vendorModel = VmModel::getModel('vendor');
         $this->vendor = $vendorModel->getVendor($this->vendorId);
         $vendorModel->addImages($this->vendor, 1);
         if (VmConfig::get('enable_content_plugin', 0)) {
             shopFunctionsF::triggerContentPlugin($this->vendor, 'vendor', 'vendor_terms_of_service');
         }
     }
 }
Exemplo n.º 7
0
 /**
  * Collect all data to show on the template
  *
  * @author RolandD, Max Milbers
  */
 function display($tpl = null)
 {
     //TODO get plugins running
     //		$dispatcher	= JDispatcher::getInstance();
     //		$limitstart	= JRequest::getVar('limitstart', 0, '', 'int');
     VmConfig::loadJLang('com_virtuemart', true);
     $show_prices = VmConfig::get('show_prices', 1);
     if ($show_prices == '1') {
         if (!class_exists('calculationHelper')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php';
         }
     }
     $this->assignRef('show_prices', $show_prices);
     $document = JFactory::getDocument();
     // add javascript for price and cart, need even for quantity buttons, so we need it almost anywhere
     vmJsApi::jPrice();
     $mainframe = JFactory::getApplication();
     $pathway = $mainframe->getPathway();
     $task = JRequest::getCmd('task');
     if (!class_exists('VmImage')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'image.php';
     }
     // Load the product
     //$product = $this->get('product');	//Why it is sensefull to use this construction? Imho it makes it just harder
     $product_model = VmModel::getModel('product');
     $this->assignRef('product_model', $product_model);
     $virtuemart_product_idArray = JRequest::getVar('virtuemart_product_id', 0);
     if (is_array($virtuemart_product_idArray) and count($virtuemart_product_idArray) > 0) {
         $virtuemart_product_id = (int) $virtuemart_product_idArray[0];
     } else {
         $virtuemart_product_id = (int) $virtuemart_product_idArray;
     }
     $quantityArray = JRequest::getVar('quantity', array());
     //is sanitized then
     JArrayHelper::toInteger($quantityArray);
     $quantity = 1;
     if (!empty($quantityArray[0])) {
         $quantity = $quantityArray[0];
     }
     $product = $product_model->getProduct($virtuemart_product_id, TRUE, TRUE, TRUE, $quantity);
     if (!class_exists('shopFunctionsF')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     $last_category_id = shopFunctionsF::getLastVisitedCategoryId();
     if (empty($product->slug)) {
         //Todo this should be redesigned to fit better for SEO
         $mainframe->enqueueMessage(JText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND'));
         $categoryLink = '';
         if (!$last_category_id) {
             $last_category_id = JRequest::getInt('virtuemart_category_id', false);
         }
         if ($last_category_id) {
             $categoryLink = '&virtuemart_category_id=' . $last_category_id;
         }
         if (VmConfig::get('handle_404', 1)) {
             $mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=category' . $categoryLink . '&error=404', FALSE));
         } else {
             JError::raise(E_ERROR, '404', 'Not found');
         }
         return;
     }
     if (!empty($product->customfields)) {
         foreach ($product->customfields as $k => $custom) {
             if (!empty($custom->layout_pos)) {
                 $product->customfieldsSorted[$custom->layout_pos][] = $custom;
                 unset($product->customfields[$k]);
             }
         }
         $product->customfieldsSorted['normal'] = $product->customfields;
         unset($product->customfields);
     }
     $product->event = new stdClass();
     $product->event->afterDisplayTitle = '';
     $product->event->beforeDisplayContent = '';
     $product->event->afterDisplayContent = '';
     if (VmConfig::get('enable_content_plugin', 0)) {
         shopFunctionsF::triggerContentPlugin($product, 'productdetails', 'product_desc');
     }
     $product_model->addImages($product);
     $this->assignRef('product', $product);
     if (isset($product->min_order_level) && (int) $product->min_order_level > 0) {
         $min_order_level = $product->min_order_level;
     } else {
         $min_order_level = 1;
     }
     $this->assignRef('min_order_level', $min_order_level);
     if (isset($product->step_order_level) && (int) $product->step_order_level > 0) {
         $step_order_level = $product->step_order_level;
     } else {
         $step_order_level = 1;
     }
     $this->assignRef('step_order_level', $step_order_level);
     // Load the neighbours
     if (VmConfig::get('product_navigation', 1)) {
         $product->neighbours = $product_model->getNeighborProducts($product);
     }
     // Load the category
     $category_model = VmModel::getModel('category');
     shopFunctionsF::setLastVisitedCategoryId($product->virtuemart_category_id);
     if ($category_model) {
         $category = $category_model->getCategory($product->virtuemart_category_id);
         $category_model->addImages($category, 1);
         $this->assignRef('category', $category);
         //Seems we dont need this anylonger, destroyed the breadcrumb
         if ($category->parents) {
             foreach ($category->parents as $c) {
                 if (is_object($c) and isset($c->category_name)) {
                     $pathway->addItem(strip_tags($c->category_name), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id, FALSE));
                 } else {
                     vmdebug('Error, parent category has no name, breadcrumb maybe broken, category', $c);
                 }
             }
         }
         $category->children = $category_model->getChildCategoryList($product->virtuemart_vendor_id, $product->virtuemart_category_id);
         $category_model->addImages($category->children, 1);
     }
     if (!empty($tpl)) {
         $format = $tpl;
     } else {
         $format = JRequest::getWord('format', 'html');
     }
     if ($format == 'html') {
         // Set Canonic link
         $document->addHeadLink($product->canonical, 'canonical', 'rel', '');
     }
     $pathway->addItem(strip_tags($product->product_name));
     // Set the titles
     // $document->setTitle should be after the additem pathway
     if ($product->customtitle) {
         $document->setTitle(strip_tags($product->customtitle));
     } else {
         $document->setTitle(strip_tags(($category->category_name ? $category->category_name . ' : ' : '') . $product->product_name));
     }
     $ratingModel = VmModel::getModel('ratings');
     $allowReview = $ratingModel->allowReview($product->virtuemart_product_id);
     $this->assignRef('allowReview', $allowReview);
     $showReview = $ratingModel->showReview($product->virtuemart_product_id);
     $this->assignRef('showReview', $showReview);
     if ($showReview) {
         $review = $ratingModel->getReviewByProduct($product->virtuemart_product_id);
         $this->assignRef('review', $review);
         $rating_reviews = $ratingModel->getReviews($product->virtuemart_product_id);
         $this->assignRef('rating_reviews', $rating_reviews);
     }
     $showRating = $ratingModel->showRating($product->virtuemart_product_id);
     $this->assignRef('showRating', $showRating);
     if ($showRating) {
         $vote = $ratingModel->getVoteByProduct($product->virtuemart_product_id);
         $this->assignRef('vote', $vote);
         $rating = $ratingModel->getRatingByProduct($product->virtuemart_product_id);
         $this->assignRef('rating', $rating);
     }
     $allowRating = $ratingModel->allowRating($product->virtuemart_product_id);
     $this->assignRef('allowRating', $allowRating);
     // Check for editing access
     // @todo build edit page
     if (!class_exists('Permissions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php';
     }
     //if (Permissions::getInstance()->check("admin,storeadmin")) {
     $perm = Permissions::getInstance();
     $admin = $perm->check("admin");
     if (!$admin) {
         vmdebug('No admin');
     }
     $storeadmin = $perm->check("admin,storeadmin");
     if (!$storeadmin) {
         vmdebug('No $storeadmin');
     }
     $superVendor = $perm->isSuperVendor();
     if (!$superVendor) {
         vmdebug('No $superVendor');
     }
     if ($admin or $perm->isSuperVendor() == $product->virtuemart_vendor_id and $storeadmin) {
         $edit_link = JURI::root() . 'index.php?option=com_virtuemart&tmpl=component&view=product&task=edit&virtuemart_product_id=' . $product->virtuemart_product_id;
         $edit_link = $this->linkIcon($edit_link, 'COM_VIRTUEMART_PRODUCT_FORM_EDIT_PRODUCT', 'edit', false, false);
     } else {
         $edit_link = "";
     }
     $this->assignRef('edit_link', $edit_link);
     // todo: atm same form for "call for price" and "ask a question". Title of the form should be different
     $askquestion_url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id . '&tmpl=component', FALSE);
     $this->assignRef('askquestion_url', $askquestion_url);
     // Load the user details
     $user = JFactory::getUser();
     $this->assignRef('user', $user);
     // More reviews link
     $uri = JURI::getInstance();
     $uri->setVar('showall', 1);
     $uristring = vmURI::getCleanUrl();
     $this->assignRef('more_reviews', $uristring);
     if ($product->metadesc) {
         $document->setDescription($product->metadesc);
     }
     if ($product->metakey) {
         $document->setMetaData('keywords', $product->metakey);
     }
     if ($product->metarobot) {
         $document->setMetaData('robots', $product->metarobot);
     }
     if ($mainframe->getCfg('MetaTitle') == '1') {
         $document->setMetaData('title', $product->product_name);
         //Maybe better product_name
     }
     if ($mainframe->getCfg('MetaAuthor') == '1') {
         $document->setMetaData('author', $product->metaauthor);
     }
     $showBasePrice = Permissions::getInstance()->check('admin');
     //todo add config settings
     $this->assignRef('showBasePrice', $showBasePrice);
     $productDisplayShipments = array();
     $productDisplayPayments = array();
     if (!class_exists('vmPSPlugin')) {
         require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
     }
     JPluginHelper::importPlugin('vmshipment');
     JPluginHelper::importPlugin('vmpayment');
     $dispatcher = JDispatcher::getInstance();
     $returnValues = $dispatcher->trigger('plgVmOnProductDisplayShipment', array($product, &$productDisplayShipments));
     $returnValues = $dispatcher->trigger('plgVmOnProductDisplayPayment', array($product, &$productDisplayPayments));
     $this->assignRef('productDisplayPayments', $productDisplayPayments);
     $this->assignRef('productDisplayShipments', $productDisplayShipments);
     if (empty($category->category_template)) {
         $category->category_template = VmConfig::get('categorytemplate');
     }
     shopFunctionsF::setVmTemplate($this, $category->category_template, $product->product_template, $category->category_product_layout, $product->layout);
     shopFunctionsF::addProductToRecent($virtuemart_product_id);
     $currency = CurrencyDisplay::getInstance();
     $this->assignRef('currency', $currency);
     if (JRequest::getCmd('layout', 'default') == 'notify') {
         $this->setLayout('notify');
     }
     //Added by Seyi Awofadeju to catch notify layout
     parent::display($tpl);
 }
Exemplo n.º 8
0
 public function display($tpl = null)
 {
     $vendorId = JRequest::getInt('vendorid', 1);
     $vendorModel = VmModel::getModel('vendor');
     $vendorModel->setId(1);
     $vendor = $vendorModel->getVendor();
     if (!class_exists('shopFunctionsF')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     if (VmConfig::get('enable_content_plugin', 0)) {
         shopFunctionsF::triggerContentPlugin($vendor, 'vendor', 'vendor_store_desc');
         shopFunctionsF::triggerContentPlugin($vendor, 'vendor', 'vendor_terms_of_service');
     }
     $this->assignRef('vendor', $vendor);
     $document = JFactory::getDocument();
     if (!VmConfig::get('shop_is_offline', 0)) {
         $categoryModel = VmModel::getModel('category');
         $productModel = VmModel::getModel('product');
         $ratingModel = VmModel::getModel('ratings');
         $productModel->withRating = $ratingModel->showRating();
         $products = array();
         $categoryId = JRequest::getInt('catid', 0);
         $categoryChildren = $categoryModel->getChildCategoryList($vendorId, $categoryId);
         $categoryModel->addImages($categoryChildren, 1);
         $this->assignRef('categories', $categoryChildren);
         if (!class_exists('CurrencyDisplay')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
         }
         $currency = CurrencyDisplay::getInstance();
         $this->assignRef('currency', $currency);
         $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)) {
             $products['featured'] = $productModel->getProductListing('featured', $featured_products_count);
             $productModel->addImages($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)) {
             $products['latest'] = $productModel->getProductListing('latest', $latest_products_count);
             $productModel->addImages($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)) {
             $products['topten'] = $productModel->getProductListing('topten', $topTen_products_count);
             $productModel->addImages($products['topten'], 1);
         }
         $recent_products_rows = VmConfig::get('recent_products_rows');
         $recent_products_count = $products_per_row * $recent_products_rows;
         $recent_products = $productModel->getProductListing('recent');
         if (!empty($recent_products_count) and VmConfig::get('show_recent', 1) and !empty($recent_products)) {
             $products['recent'] = $productModel->getProductListing('recent', $recent_products_count);
             $productModel->addImages($products['recent'], 1);
         }
         $this->assignRef('products', $products);
         if (!class_exists('Permissions')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php';
         }
         $showBasePrice = Permissions::getInstance()->check('admin');
         //todo add config settings
         $this->assignRef('showBasePrice', $showBasePrice);
         //		$layoutName = VmConfig::get('vmlayout','default');
         $layout = VmConfig::get('vmlayout', 'default');
         $this->setLayout($layout);
         // Add feed links
         if ($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);
         }
     } else {
         $this->setLayout('off_line');
     }
     $error = JRequest::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(JText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND') . JText::sprintf('COM_VIRTUEMART_HOME', $vendor->vendor_store_name));
     } else {
         if (empty($vendor->customtitle)) {
             $app = JFactory::getApplication();
             $menus = $app->getMenu();
             $menu = $menus->getActive();
             if ($menu) {
                 $menuTitle = $menu->params->get('page_title');
                 if (empty($menuTitle)) {
                     $menuTitle = JText::sprintf('COM_VIRTUEMART_HOME', $vendor->vendor_store_name);
                 }
                 $document->setTitle($menuTitle);
             } else {
                 $title = JText::sprintf('COM_VIRTUEMART_HOME', $vendor->vendor_store_name);
                 $document->setTitle($title);
             }
         } else {
             $document->setTitle($vendor->customtitle);
         }
         if (!empty($vendor->metadesc)) {
             $document->setMetaData('description', $vendor->metadesc);
         }
         if (!empty($vendor->metakey)) {
             $document->setMetaData('keywords', $vendor->metakey);
         }
         if (!empty($vendor->metarobot)) {
             $document->setMetaData('robots', $vendor->metarobot);
         }
         if (!empty($vendor->metaauthor)) {
             $document->setMetaData('author', $vendor->metaauthor);
         }
     }
     $template = VmConfig::get('vmtemplate', 0);
     shopFunctionsF::setTemplate($template);
     parent::display($tpl);
 }
Exemplo n.º 9
0
 /**
  * Collect all data to show on the template
  *
  * @author RolandD, Max Milbers
  */
 function display($tpl = null)
 {
     $show_prices = VmConfig::get('show_prices', 1);
     $this->assignRef('show_prices', $show_prices);
     $document = JFactory::getDocument();
     $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);
         }
     }
     $pathway = $app->getPathway();
     $task = vRequest::getCmd('task');
     if (!class_exists('VmImage')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php';
     }
     // Load the product
     //$product = $this->get('product');	//Why it is sensefull to use this construction? Imho it makes it just harder
     $product_model = VmModel::getModel('product');
     $this->assignRef('product_model', $product_model);
     $virtuemart_product_idArray = vRequest::getInt('virtuemart_product_id', 0);
     if (is_array($virtuemart_product_idArray) and count($virtuemart_product_idArray) > 0) {
         $virtuemart_product_id = (int) $virtuemart_product_idArray[0];
     } else {
         $virtuemart_product_id = (int) $virtuemart_product_idArray;
     }
     $quantityArray = vRequest::getInt('quantity', array());
     //is sanitized then
     $quantity = 1;
     if (!empty($quantityArray[0])) {
         $quantity = $quantityArray[0];
     }
     $ratingModel = VmModel::getModel('ratings');
     $product_model->withRating = $this->showRating = $ratingModel->showRating($virtuemart_product_id);
     $product = $product_model->getProduct($virtuemart_product_id, TRUE, TRUE, TRUE, $quantity);
     if (!class_exists('shopFunctionsF')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     $last_category_id = shopFunctionsF::getLastVisitedCategoryId();
     $customfieldsModel = VmModel::getModel('Customfields');
     if ($product->customfields) {
         if (!class_exists('vmCustomPlugin')) {
             require JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php';
         }
         $customfieldsModel->displayProductCustomfieldFE($product, $product->customfields);
     }
     if (empty($product->slug)) {
         //Todo this should be redesigned to fit better for SEO
         $app->enqueueMessage(vmText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND'));
         $categoryLink = '';
         if (!$last_category_id) {
             $last_category_id = vRequest::getInt('virtuemart_category_id', false);
         }
         if ($last_category_id) {
             $categoryLink = '&virtuemart_category_id=' . $last_category_id;
         }
         if (VmConfig::get('handle_404', 1)) {
             $app->redirect(JRoute::_('index.php?option=com_virtuemart&view=category' . $categoryLink . '&error=404', FALSE));
         } else {
             JError::raise(E_ERROR, '404', 'Not found');
         }
         return;
     }
     $isCustomVariant = false;
     if (!empty($product->customfields)) {
         foreach ($product->customfields as $k => $custom) {
             if ($custom->field_type == 'C' and $custom->virtuemart_product_id != $virtuemart_product_id) {
                 $isCustomVariant = $custom;
             }
             if (!empty($custom->layout_pos)) {
                 $product->customfieldsSorted[$custom->layout_pos][] = $custom;
             } else {
                 $product->customfieldsSorted['normal'][] = $custom;
             }
             unset($product->customfields);
         }
     }
     $product->event = new stdClass();
     $product->event->afterDisplayTitle = '';
     $product->event->beforeDisplayContent = '';
     $product->event->afterDisplayContent = '';
     if (VmConfig::get('enable_content_plugin', 0)) {
         shopFunctionsF::triggerContentPlugin($product, 'productdetails', 'product_desc');
     }
     $product_model->addImages($product);
     if (isset($product->min_order_level) && (int) $product->min_order_level > 0) {
         $this->min_order_level = $product->min_order_level;
     } else {
         $this->min_order_level = 1;
     }
     if (isset($product->step_order_level) && (int) $product->step_order_level > 0) {
         $this->step_order_level = $product->step_order_level;
     } else {
         $this->step_order_level = 1;
     }
     // Load the neighbours
     if (VmConfig::get('product_navigation', 1)) {
         $product->neighbours = $product_model->getNeighborProducts($product);
     }
     $this->assignRef('product', $product);
     if (VmConfig::get('show_manufacturers', 1) && !empty($this->product->virtuemart_manufacturer_id)) {
         $manModel = VmModel::getModel('manufacturer');
         $mans = array();
         // Gebe die Hersteller aus
         foreach ($this->product->virtuemart_manufacturer_id as $manufacturer_id) {
             $manufacturer = $manModel->getManufacturer($manufacturer_id);
             $manModel->addImages($manufacturer, 1);
             $mans[] = $manufacturer;
         }
         $this->product->manufacturers = $mans;
     }
     // Load the category
     $category_model = VmModel::getModel('category');
     shopFunctionsF::setLastVisitedCategoryId($product->virtuemart_category_id);
     if ($category_model) {
         $category = $category_model->getCategory($product->virtuemart_category_id);
         $category_model->addImages($category, 1);
         $this->assignRef('category', $category);
         //Seems we dont need this anylonger, destroyed the breadcrumb
         if ($category->parents) {
             foreach ($category->parents as $c) {
                 if (is_object($c) and isset($c->category_name)) {
                     $pathway->addItem(strip_tags(vmText::_($c->category_name)), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id, FALSE));
                 } else {
                     vmdebug('Error, parent category has no name, breadcrumb maybe broken, category', $c);
                 }
             }
         }
         $category->children = $category_model->getChildCategoryList($product->virtuemart_vendor_id, $product->virtuemart_category_id);
         $category_model->addImages($category->children, 1);
     }
     $pathway->addItem(strip_tags(html_entity_decode($product->product_name, ENT_QUOTES)));
     if (!empty($tpl)) {
         $format = $tpl;
     } else {
         $format = vRequest::getCmd('format', 'html');
     }
     if ($format == 'html') {
         // remove joomla canonical before adding it
         foreach ($document->_links as $k => $array) {
             if ($array['relation'] == 'canonical') {
                 unset($document->_links[$k]);
                 break;
             }
         }
         // Set Canonic link
         if ($isCustomVariant !== false and !empty($isCustomVariant->usecanonical) and !empty($product->product_parent_id)) {
             $parent = $product_model->getProduct($product->product_parent_id);
             $document->addHeadLink($parent->canonical, 'canonical', 'rel', '');
         } else {
             $document->addHeadLink($product->canonical, 'canonical', 'rel', '');
         }
     } else {
         if ($format == 'pdf') {
             defined('K_PATH_IMAGES') or define('K_PATH_IMAGES', VMPATH_ROOT);
         }
     }
     // Set the titles
     // $document->setTitle should be after the additem pathway
     if ($product->customtitle) {
         $document->setTitle(strip_tags(html_entity_decode($product->customtitle, ENT_QUOTES)));
     } else {
         $document->setTitle(strip_tags(html_entity_decode(($category->category_name ? vmText::_($category->category_name) . ' : ' : '') . $product->product_name, ENT_QUOTES)));
     }
     $this->allowReview = $ratingModel->allowReview($product->virtuemart_product_id);
     $this->showReview = $ratingModel->showReview($product->virtuemart_product_id);
     $this->rating_reviews = '';
     if ($this->showReview) {
         $this->review = $ratingModel->getReviewByProduct($product->virtuemart_product_id);
         $this->rating_reviews = $ratingModel->getReviews($product->virtuemart_product_id);
     }
     if ($this->showRating) {
         $this->vote = $ratingModel->getVoteByProduct($product->virtuemart_product_id);
     }
     $this->allowRating = $ratingModel->allowRating($product->virtuemart_product_id);
     $superVendor = vmAccess::isSuperVendor();
     if ($superVendor == 1 or $superVendor == $product->virtuemart_vendor_id or $superVendor) {
         $edit_link = JURI::root() . 'index.php?option=com_virtuemart&tmpl=component&manage=1&view=product&task=edit&virtuemart_product_id=' . $product->virtuemart_product_id;
         $this->edit_link = $this->linkIcon($edit_link, 'COM_VIRTUEMART_PRODUCT_FORM_EDIT_PRODUCT', 'edit', false, false);
     } else {
         $this->edit_link = "";
     }
     // Load the user details
     $this->user = JFactory::getUser();
     // More reviews link
     $uri = JURI::getInstance();
     $uri->setVar('showall', 1);
     $uristring = vmURI::getCleanUrl();
     $this->assignRef('more_reviews', $uristring);
     if ($product->metadesc) {
         $document->setDescription(strip_tags(html_entity_decode($product->metadesc, ENT_QUOTES)));
     } else {
         $document->setDescription(strip_tags(html_entity_decode($product->product_name, ENT_QUOTES)) . " " . $category->category_name . " " . strip_tags(html_entity_decode($product->product_s_desc, ENT_QUOTES)));
     }
     if ($product->metakey) {
         $document->setMetaData('keywords', $product->metakey);
     }
     if ($product->metarobot) {
         $document->setMetaData('robots', $product->metarobot);
     }
     if ($app->getCfg('MetaTitle') == '1') {
         $document->setMetaData('title', $product->product_name);
         //Maybe better product_name
     }
     if ($app->getCfg('MetaAuthor') == '1') {
         $document->setMetaData('author', $product->metaauthor);
     }
     $user = JFactory::getUser();
     $showBasePrice = (vmAccess::manager() or vmAccess::isSuperVendor());
     $this->assignRef('showBasePrice', $showBasePrice);
     $productDisplayShipments = array();
     $productDisplayPayments = array();
     if (!class_exists('vmPSPlugin')) {
         require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
     }
     JPluginHelper::importPlugin('vmshipment');
     JPluginHelper::importPlugin('vmpayment');
     $dispatcher = JDispatcher::getInstance();
     $returnValues = $dispatcher->trigger('plgVmOnProductDisplayShipment', array($product, &$productDisplayShipments));
     $returnValues = $dispatcher->trigger('plgVmOnProductDisplayPayment', array($product, &$productDisplayPayments));
     $this->assignRef('productDisplayPayments', $productDisplayPayments);
     $this->assignRef('productDisplayShipments', $productDisplayShipments);
     if (empty($category->category_template)) {
         $category->category_template = VmConfig::get('categorytemplate');
     }
     shopFunctionsF::setVmTemplate($this, $category->category_template, $product->product_template, $category->category_product_layout, $product->layout);
     shopFunctionsF::addProductToRecent($virtuemart_product_id);
     $currency = CurrencyDisplay::getInstance();
     $this->assignRef('currency', $currency);
     if (vRequest::getCmd('layout', 'default') == 'notify') {
         $this->setLayout('notify');
     }
     //Added by Seyi Awofadeju to catch notify layout
     VmConfig::loadJLang('com_virtuemart');
     vmJsApi::chosenDropDowns();
     //This must be loaded after the customfields are rendered (they may need to overwrite the handlers)
     if (VmConfig::get('jdynupdate', TRUE) or $app->isAdmin()) {
         vmJsApi::jDynUpdate();
     }
     if ($show_prices == '1') {
         if (!class_exists('calculationHelper')) {
             require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php';
         }
         vmJsApi::jPrice();
     }
     parent::display($tpl);
 }
Exemplo n.º 10
0
 public function display($tpl = null)
 {
     $mainframe = JFactory::getApplication();
     $pathway = $mainframe->getPathway();
     $document = JFactory::getDocument();
     $document->setMetaData('robots', 'NOINDEX, NOFOLLOW, NOARCHIVE, NOSNIPPET');
     // add javascript for price and cart, need even for quantity buttons, so we need it almost anywhere
     //vmJsApi::jPrice();
     $layoutName = $this->getLayout();
     if (!$layoutName) {
         $layoutName = JRequest::getWord('layout', 'default');
     }
     $this->assignRef('layoutName', $layoutName);
     $format = JRequest::getWord('format');
     if (!class_exists('VirtueMartCart')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $cart = VirtueMartCart::getCart();
     //$cart->getCartPrices();
     $this->assignRef('cart', $cart);
     //Why is this here, when we have view.raw.php
     if ($format == 'raw') {
         $cart->prepareCartViewData();
         JRequest::setVar('layout', 'mini_cart');
         $this->setLayout('mini_cart');
         $this->prepareContinueLink();
     }
     /*
     	  if($layoutName=='edit_coupon'){
     
     		$cart->prepareCartViewData();
     		$this->lSelectCoupon();
     		$pathway->addItem(JText::_('COM_VIRTUEMART_CART_OVERVIEW'),JRoute::_('index.php?option=com_virtuemart&view=cart'));
     		$pathway->addItem(JText::_('COM_VIRTUEMART_CART_SELECTCOUPON'));
     		$document->setTitle(JText::_('COM_VIRTUEMART_CART_SELECTCOUPON'));
     
     		} else */
     if ($layoutName == 'select_shipment') {
         $cart->prepareCartViewData();
         if (!class_exists('vmPSPlugin')) {
             require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
         }
         JPluginHelper::importPlugin('vmshipment');
         $this->lSelectShipment();
         $pathway->addItem(JText::_('COM_VIRTUEMART_CART_OVERVIEW'), JRoute::_('index.php?option=com_virtuemart&view=cart', FALSE));
         $pathway->addItem(JText::_('COM_VIRTUEMART_CART_SELECTSHIPMENT'));
         $document->setTitle(JText::_('COM_VIRTUEMART_CART_SELECTSHIPMENT'));
     } else {
         if ($layoutName == 'select_payment') {
             /* Load the cart helper */
             //			$cartModel = VmModel::getModel('cart');
             $cart->prepareCartViewData();
             $this->lSelectPayment();
             $pathway->addItem(JText::_('COM_VIRTUEMART_CART_OVERVIEW'), JRoute::_('index.php?option=com_virtuemart&view=cart', FALSE));
             $pathway->addItem(JText::_('COM_VIRTUEMART_CART_SELECTPAYMENT'));
             $document->setTitle(JText::_('COM_VIRTUEMART_CART_SELECTPAYMENT'));
         } else {
             if ($layoutName == 'order_done') {
                 VmConfig::loadJLang('com_virtuemart_shoppers');
                 $this->lOrderDone();
                 $pathway->addItem(JText::_('COM_VIRTUEMART_CART_THANKYOU'));
                 $document->setTitle(JText::_('COM_VIRTUEMART_CART_THANKYOU'));
             } else {
                 if ($layoutName == 'default') {
                     VmConfig::loadJLang('com_virtuemart_shoppers');
                     $cart->prepareCartViewData();
                     if (VmConfig::get('enable_content_plugin', 0)) {
                         shopFunctionsF::triggerContentPlugin($cart->vendor, 'vendor', 'vendor_terms_of_service');
                     }
                     $cart->prepareAddressRadioSelection();
                     $this->prepareContinueLink();
                     $this->lSelectCoupon();
                     $currencyDisplay = CurrencyDisplay::getInstance($this->cart->pricesCurrency);
                     $this->assignRef('currencyDisplay', $currencyDisplay);
                     $totalInPaymentCurrency = $this->getTotalInPaymentCurrency();
                     $checkoutAdvertise = $this->getCheckoutAdvertise();
                     if (!$cart->_redirect and !VmConfig::get('use_as_catalog', 0)) {
                         $cart->checkout(false);
                     }
                     if ($cart->getDataValidated()) {
                         $pathway->addItem(JText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU'));
                         $document->setTitle(JText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU'));
                         $text = JText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU');
                         $checkout_task = 'confirm';
                     } else {
                         $pathway->addItem(JText::_('COM_VIRTUEMART_CART_OVERVIEW'));
                         $document->setTitle(JText::_('COM_VIRTUEMART_CART_OVERVIEW'));
                         $text = JText::_('COM_VIRTUEMART_CHECKOUT_TITLE');
                         $checkout_task = 'checkout';
                     }
                     $this->assignRef('checkout_task', $checkout_task);
                     $this->checkPaymentMethodsConfigured();
                     $this->checkShipmentMethodsConfigured();
                     if ($cart->virtuemart_shipmentmethod_id) {
                         $shippingText = JText::_('COM_VIRTUEMART_CART_CHANGE_SHIPPING');
                     } else {
                         $shippingText = JText::_('COM_VIRTUEMART_CART_EDIT_SHIPPING');
                     }
                     $this->assignRef('select_shipment_text', $shippingText);
                     if ($cart->virtuemart_paymentmethod_id) {
                         $paymentText = JText::_('COM_VIRTUEMART_CART_CHANGE_PAYMENT');
                     } else {
                         $paymentText = JText::_('COM_VIRTUEMART_CART_EDIT_PAYMENT');
                     }
                     $this->assignRef('select_payment_text', $paymentText);
                     if (VmConfig::get('oncheckout_opc', 0)) {
                         if (!class_exists('vmPSPlugin')) {
                             require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
                         }
                         JPluginHelper::importPlugin('vmshipment');
                         JPluginHelper::importPlugin('vmpayment');
                         $this->lSelectShipment();
                         $this->lSelectPayment();
                     }
                     if (!VmConfig::get('use_as_catalog')) {
                         $checkout_link_html = '<a class="vm-button-correct" href="javascript:document.checkoutForm.submit();" ><span>' . $text . '</span></a>';
                     } else {
                         $checkout_link_html = '';
                     }
                     $this->assignRef('checkout_link_html', $checkout_link_html);
                     //set order language
                     $lang = JFactory::getLanguage();
                     $order_language = $lang->getTag();
                     $this->assignRef('order_language', $order_language);
                 }
             }
         }
     }
     //dump ($cart,'cart');
     $useSSL = VmConfig::get('useSSL', 0);
     $useXHTML = true;
     $this->assignRef('useSSL', $useSSL);
     $this->assignRef('useXHTML', $useXHTML);
     $this->assignRef('totalInPaymentCurrency', $totalInPaymentCurrency);
     $this->assignRef('checkoutAdvertise', $checkoutAdvertise);
     // @max: quicknirty
     $cart->setCartIntoSession();
     shopFunctionsF::setVmTemplate($this, 0, 0, $layoutName);
     //We never want that the cart is indexed
     $document->setMetaData('robots', 'NOINDEX, NOFOLLOW, NOARCHIVE, NOSNIPPET');
     // 		vmdebug('my cart ',$cart);
     parent::display($tpl);
 }
Exemplo n.º 11
0
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* @version $Id: cart.php 2551 2010-09-30 18:52:40Z milbo $
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
JHTML::script('facebox.js', 'components/com_virtuemart/assets/js/', false);
JHTML::stylesheet('facebox.css', 'components/com_virtuemart/assets/css/', false);
JHTML::script('plugins/system/onepage_generic/onepage_generic.js');
JHTML::stylesheet('plugins/system/onepage_generic/onepage_generic.css');
$taskRoute = "";
$vendorModel = VmModel::getModel('vendor');
$vendordata = $vendorModel->getVendor($this->cart->vendor->virtuemart_vendor_id);
$vendorModel->addImages($this->vendor, 1);
if (VmConfig::get('enable_content_plugin', 0)) {
    shopFunctionsF::triggerContentPlugin($vendordata, 'vendor', 'vendor_terms_of_service');
}
vmJsApi::jPrice();
JHTML::script('plugins/system/onepage_generic/vmprices.js');
require_once dirname(__FILE__) . DS . 'helper.php';
$this->helper = new CartHelper();
$this->helper->assignValues();
$plugin = JPluginHelper::getPlugin('system', 'onepage_generic');
$params = new JRegistry($plugin->params);
if ($params->get("buttoncolour") != "") {
    ?>
  <style type="text/css">
  .opg-button-primary
  {
    background:<?php 
    echo $params->get("buttoncolour");
Exemplo n.º 12
0
 public function display($tpl = null)
 {
     $show_prices = VmConfig::get('show_prices', 1);
     if ($show_prices == '1') {
         if (!class_exists('calculationHelper')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php';
         }
     }
     $this->assignRef('show_prices', $show_prices);
     // add javascript for price and cart, need even for quantity buttons, so we need it almost anywhere
     vmJsApi::jPrice();
     $document = JFactory::getDocument();
     $app = JFactory::getApplication();
     $pathway = $app->getPathway();
     if (!class_exists('VmImage')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'image.php';
     }
     $categoryModel = VmModel::getModel('category');
     $productModel = VmModel::getModel('product');
     // set search and keyword
     if ($keyword = vmRequest::uword('keyword', false, ' ,-,+,.,_')) {
         $pathway->addItem($keyword);
         //$title .=' ('.$keyword.')';
     }
     //$search = VmRequest::uword('keyword', null);
     $this->searchcustom = '';
     $this->searchcustomvalues = '';
     if (!empty($keyword)) {
         $this->searchcustom = $this->getSearchCustom();
         $search = $keyword;
     } else {
         $keyword = '';
         $search = NULL;
     }
     $this->assignRef('search', $search);
     $this->assignRef('keyword', $keyword);
     $categoryId = JRequest::getInt('virtuemart_category_id', false);
     $virtuemart_manufacturer_id = JRequest::getInt('virtuemart_manufacturer_id', false);
     if ($categoryId === false and $virtuemart_manufacturer_id === false) {
         $categoryId = ShopFunctionsF::getLastVisitedCategoryId();
         $catType = 'category';
         $this->setCanonicalLink($tpl, $document, $categoryId, $catType);
     } else {
         if ($categoryId === false and $virtuemart_manufacturer_id) {
             $catType = 'manufacturer';
             $this->setCanonicalLink($tpl, $document, $virtuemart_manufacturer_id, $catType);
         } else {
             $catType = 'category';
             $this->setCanonicalLink($tpl, $document, $categoryId, $catType);
         }
     }
     if ($categoryId !== -1) {
         $vendorId = 1;
         $category = $categoryModel->getCategory($categoryId);
     }
     if (!empty($category)) {
         if (empty($category->category_layout) or $category->category_layout != 'category') {
             // Load the products in the given category
             $ids = $productModel->sortSearchListQuery(TRUE, $categoryId);
             $perRow = empty($category->products_per_row) ? VmConfig::get('products_per_row', 3) : $category->products_per_row;
             $this->assignRef('perRow', $perRow);
             $pagination = $productModel->getPagination($perRow);
             $this->assignRef('vmPagination', $pagination);
             $products = $productModel->getProducts($ids);
             //$products = $productModel->getProductsInCategory($categoryId);
             $productModel->addImages($products, 1);
             $this->assignRef('products', $products);
             if ($products) {
                 $currency = CurrencyDisplay::getInstance();
                 $this->assignRef('currency', $currency);
                 foreach ($products as $product) {
                     $product->stock = $productModel->getStockIndicator($product);
                 }
             }
             $ratingModel = VmModel::getModel('ratings');
             $showRating = $ratingModel->showRating();
             $this->assignRef('showRating', $showRating);
             $orderByList = $productModel->getOrderByList($categoryId);
             $this->assignRef('orderByList', $orderByList);
             // Add feed links
             if ($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);
             }
             if (!class_exists('Permissions')) {
                 require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php';
             }
             $showBasePrice = Permissions::getInstance()->check('admin');
             //todo add config settings
             $this->assignRef('showBasePrice', $showBasePrice);
         }
         //No redirect here, for category id = 0 means show ALL categories! note by Max Milbers
         if (!empty($categoryId) and $categoryId !== -1 and (empty($category->slug) or !$category->published)) {
             if (empty($category->slug)) {
                 vmInfo(JText::_('COM_VIRTUEMART_CAT_NOT_FOUND'));
             } else {
                 if ($category->virtuemart_id !== 0 and !$category->published) {
                     vmInfo('COM_VIRTUEMART_CAT_NOT_PUBL', $category->category_name, $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 $categoryId == $last_category_id) {
                     $last_category_id = JRequest::getInt('virtuemart_category_id', false);
                 }
                 if ($last_category_id and $categoryId != $last_category_id) {
                     $categoryLink = '&view=category&virtuemart_category_id=' . $last_category_id;
                 }
             }
             $app->redirect(JRoute::_('index.php?option=com_virtuemart' . $categoryLink . '&error=404', FALSE));
             return;
         }
         shopFunctionsF::setLastVisitedCategoryId($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($c->category_name), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id, FALSE));
             }
         }
         $categoryModel->addImages($category, 1);
         $cache = JFactory::getCache('com_virtuemart', 'callback');
         $category->children = $cache->call(array('VirtueMartModelCategory', 'getChildCategoryList'), $vendorId, $categoryId, $categoryModel->getDefaultOrdering(), $categoryModel->_selectedOrderingDir);
         $categoryModel->addImages($category->children, 1);
         if (VmConfig::get('enable_content_plugin', 0)) {
             shopFunctionsF::triggerContentPlugin($category, 'category', 'category_description');
         }
         if ($category->metadesc) {
             $document->setDescription($category->metadesc);
         }
         if ($category->metakey) {
             $document->setMetaData('keywords', $category->metakey);
         }
         if ($category->metarobot) {
             $document->setMetaData('robots', $category->metarobot);
         }
         if ($app->getCfg('MetaAuthor') == '1') {
             $document->setMetaData('author', $category->metaauthor);
         }
         if (empty($category->category_template)) {
             $category->category_template = VmConfig::get('categorytemplate');
         }
         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);
     }
     if (JRequest::getInt('error')) {
         $title .= ' ' . JText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND');
     }
     if (!empty($keyword)) {
         $title .= ' (' . $keyword . ')';
     }
     if ($virtuemart_manufacturer_id and !empty($products[0])) {
         $title .= ' ' . $products[0]->mf_name;
     }
     $document->setTitle($title);
     // Override Category name when viewing manufacturers products !IMPORTANT AFTER page title.
     if (JRequest::getInt('virtuemart_manufacturer_id') and !empty($products[0]) and isset($category->category_name)) {
         $category->category_name = $products[0]->mf_name;
     }
     if ($app->getCfg('MetaTitle') == '1') {
         $document->setMetaData('title', $title);
     }
     parent::display($tpl);
 }
Exemplo n.º 13
0
 public function display($tpl = null)
 {
     $show_prices = tsmConfig::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 = tmsModel::getModel('category');
     $productModel = tmsModel::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
             $this->products = $productModel->getItemList();
             //$products = $productModel->getProductsInCategory($this->categoryId);
             $productModel->addImages($this->products, tsmConfig::get('prodimg_browse', 1));
         }
         //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(tsmText::_('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 (tsmConfig::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(tsmText::_($c->category_name)), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id, FALSE));
             }
         }
         $categoryModel->addImages($category, 1);
         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, 1);
         } else {
             $category->children = false;
         }
         if (tsmConfig::get('enable_content_plugin', 0)) {
             shopFunctionsF::triggerContentPlugin($category, 'category', 'category_description');
         }
         if ($category->metadesc) {
             $document->setDescription($category->metadesc);
         }
         if ($category->metakey) {
             $document->setMetaData('keywords', $category->metakey);
         }
         if ($category->metarobot) {
             $document->setMetaData('robots', $category->metarobot);
         }
         if ($app->getCfg('MetaAuthor') == '1') {
             $document->setMetaData('author', $category->metaauthor);
         }
         if (empty($category->category_template)) {
             $category->category_template = tsmConfig::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 = tsmConfig::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 = tsmText::_($title);
     if (vRequest::getInt('error')) {
         $title .= ' ' . tsmText::_('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);
 }