Exemple #1
0
    ?>
<div class="category_description">
	
	<?php 
    //echo $this->category->images;
    ?>
	<?php 
    echo $this->category->category_description;
    ?>
</div>
<?php 
}
// Show child categories
if (VmConfig::get('showCategory', 1) and empty($this->keyword)) {
    if (!empty($this->category->haschildren)) {
        echo ShopFunctionsF::renderVmSubLayout('categories', array('categories' => $this->category->children));
    }
}
if ($this->showproducts) {
    ?>
<div class="browse-view">
<?php 
    if (!empty($this->keyword)) {
        //id taken in the view.html.php could be modified
        $category_id = vRequest::getInt('virtuemart_category_id', 0);
        ?>
    <form action="<?php 
        echo JRoute::_('index.php?option=com_virtuemart&view=category&search=false&limitstart=0');
        ?>
" method="get">
 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);
 }
	/**
	 * Return an array with userFields in several formats.
	 *
	 * @access public
	 * @param $_selection An array, as returned by getuserFields(), with fields that should be returned.
	 * @param $_userData Array with userdata holding the values for the fields
	 * @param $_prefix string Optional prefix for the formtag name attribute
	 * @author Oscar van Eijk
	 * @return array List with all userfield data in the format:
	 * array(
	 *    'fields' => array(   // All fields
	 *                   <fieldname> => array(
	 *                                     'name' =>       // Name of the field
	 *                                     'value' =>      // Existing value for the current user, or the default
	 *                                     'title' =>      // Title used for label and such
	 *                                     'type' =>       // Field type as specified in the userfields table
	 *                                     'hidden' =>     // True/False
	 *                                     'required' =>   // True/False. If True, the formcode also has the class "required" for the Joomla formvalidator
	 *                                     'formcode' =>   // Full HTML tag
	 *                                  )
	 *                   [...]
	 *                )
	 *    'functions' => array() // Optional javascript functions without <script> tags.
	 *                           // Possible usage: if (count($ar('functions')>0) echo '<script ...>'.join("\n", $ar('functions')).'</script>;
	 *    'scripts'   => array(  // Array with scriptsources for use with JHtml::script();
	 *                      <name> => <path>
	 *                      [...]
	 *                   )
	 *    'links'     => array(  // Array with stylesheets for use with JHtml::stylesheet();
	 *                      <name> => <path>
	 *                      [...]
	 *                   )
	 * )
	 * @example This example illustrates the use of this function. For additional examples, see the Order view
	 * and the User view in the administrator section.
	 * <pre>
	 *   // In the controller, make sure this model is loaded.
	 *   // In view.html.php, make the following calls:
	 *   $_usrDetails = getUserDetailsFromSomeModel(); // retrieve an user_info record, eg from the usermodel or ordermodel
	 *   $_usrFieldList = $userFieldsModel->getUserFields(
	 *                    'registration'
	 *                  , array() // Default switches
	 *                  , array('delimiter_userinfo', 'username', 'email', 'password', 'password2', 'agreed', 'address_type') // Skips
	 *    );
	 *   $usrFieldValues = $userFieldsModel->getUserFieldsFilled(
	 *                      $_usrFieldList
	 *                     ,$_usrDetails
	 *   );
	 *   $this->assignRef('userfields', $userfields);
	 *   // In the template, use code below to display the data. For an extended example using
	 *   // delimiters, JavaScripts and StyleSheets, see the edit_shopper.php in the user view
	 *   <table class="admintable" width="100%">
	 *     <thead>
	 *       <tr>
	 *         <td class="key" style="text-align: center;"  colspan="2">
	 *            <?php echo vmText::_('COM_VIRTUEMART_TABLE_HEADER') ?>
	 *         </td>
	 *       </tr>
	 *     </thead>
	 *      <?php
	 *        foreach ($this->shipmentfields['fields'] as $_field ) {
	 *          echo '  <tr>'."\n";
	 *          echo '    <td class="key">'."\n";
	 *          echo '      '.$_field['title']."\n";
	 *          echo '    </td>'."\n";
	 *          echo '    <td>'."\n";
	 *
	 *          echo '      '.$_field['value']."\n";    // Display only
	 *       Or:
	 *          echo '      '.$_field['formcode']."\n"; // Input form
	 *
	 *          echo '    </td>'."\n";
	 *          echo '  </tr>'."\n";
	 *        }
	 *      ?>
	 *    </table>
	 * </pre>
	 */
	public function getUserFieldsFilled($_selection, $_userData = null, $_prefix = ''){


		//if(!class_exists('ShopFunctions')) require(VMPATH_ADMIN.DS.'helpers'.DS.'shopfunctions.php');
		$_return = array(
				 'fields' => array()
		,'functions' => array()
		,'scripts' => array()
		,'links' => array()
		);

		$admin = false;
		$user = JFactory::getUser();
		if($user->authorise('core.admin','com_virtuemart') or $user->authorise('core.manage','com_virtuemart')){
			$admin  = true;
		}

		// 		vmdebug('my user data in getUserFieldsFilled',$_selection,$_userData);
		$_userData=(array)($_userData);
		if (is_array($_selection)) {

			foreach ($_selection as $_fld) {

				$_return['fields'][$_fld->name] = array(
					     'name' => $_prefix . $_fld->name
				,'value' => (($_userData == null || !array_key_exists($_fld->name, $_userData))
				? $_fld->default
				: $_userData[$_fld->name])
				,'title' => vmText::_($_fld->title)
				,'type' => $_fld->type
				,'required' => $_fld->required
				,'hidden' => false
				,'formcode' => ''
				,'description' => vmText::_($_fld->description)
				);

				$readonly = '';
				if(!$admin){
					if($_fld->readonly ){
						$readonly = ' readonly="readonly" ';
					}
				}
 				//vmdebug ('getUserFieldsFilled',$_fld->name,$_return['fields'][$_fld->name]['value']);
				// 			if($_fld->name==='email') vmdebug('user data email getuserfieldbyuser',$_userData);
				// First, see if there are predefined fields by checking the name
				switch( $_fld->name ) {

					// 				case 'email':
					// 					$_return['fields'][$_fld->name]['formcode'] = $_userData->email;
					// 					break;
					case 'virtuemart_country_id':

						if(!class_exists('shopFunctionsF'))require(VMPATH_SITE.DS.'helpers'.DS.'shopfunctionsf.php');
						$attrib = array();
						if ($_fld->size) {
							$attrib = array('style'=>"width: ".$_fld->size."px");
						}
						$_return['fields'][$_fld->name]['formcode'] =
							ShopFunctionsF::renderCountryList($_return['fields'][$_fld->name]['value'], false, $attrib , $_prefix, $_fld->required);

						if(!empty($_return['fields'][$_fld->name]['value'])){
							// Translate the value from ID to name
							$_return['fields'][$_fld->name]['virtuemart_country_id'] = (int)$_return['fields'][$_fld->name]['value'];
							$db = JFactory::getDBO ();
							$q = 'SELECT * FROM `#__virtuemart_countries` WHERE virtuemart_country_id = "' . (int)$_return['fields'][$_fld->name]['value'] . '"';
							$db->setQuery ($q);
							$r = $db->loadAssoc();
							if($r){
								$_return['fields'][$_fld->name]['value'] = !empty($r['country_name'])? $r['country_name']:'' ;
								$_return['fields'][$_fld->name]['country_2_code'] = !empty($r['country_2_code'])? $r['country_2_code']:'' ;
								$_return['fields'][$_fld->name]['country_3_code'] = !empty($r['country_3_code'])? $r['country_3_code']:'' ;
							} else {
								vmError('Model Userfields, country with id '.$_return['fields'][$_fld->name]['value'].' not found');
							}
						} else {
							$_return['fields'][$_fld->name]['value'] = '' ;
							$_return['fields'][$_fld->name]['country_2_code'] = '' ;
							$_return['fields'][$_fld->name]['country_3_code'] = '' ;
						}

						//$_return['fields'][$_fld->name]['value'] = vmText::_(shopFunctions::getCountryByID($_return['fields'][$_fld->name]['value']));
						//$_return['fields'][$_fld->name]['state_2_code'] = vmText::_(shopFunctions::getCountryByID($_return['fields'][$_fld->name]['value']));
						break;

					case 'virtuemart_state_id':
						if (!class_exists ('shopFunctionsF'))
							require(VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php');
						$attrib = array();
						if ($_fld->size) {
							$attrib = array('style'=>"width: ".$_fld->size."px");
						}
						$_return['fields'][$_fld->name]['formcode'] =
						shopFunctionsF::renderStateList(	$_return['fields'][$_fld->name]['value'],
						$_prefix,
						false,
						$_fld->required,
							$attrib
						);


						if(!empty($_return['fields'][$_fld->name]['value'])){
							// Translate the value from ID to name
							$_return['fields'][$_fld->name]['virtuemart_state_id'] = (int)$_return['fields'][$_fld->name]['value'];
							$db = JFactory::getDBO ();
							$q = 'SELECT * FROM `#__virtuemart_states` WHERE virtuemart_state_id = "' . (int)$_return['fields'][$_fld->name]['value'] . '"';
							$db->setQuery ($q);
							$r = $db->loadAssoc();
							if($r){
								$_return['fields'][$_fld->name]['value'] = !empty($r['state_name'])? $r['state_name']:'' ;
								$_return['fields'][$_fld->name]['state_2_code'] = !empty($r['state_2_code'])? $r['state_2_code']:'' ;
								$_return['fields'][$_fld->name]['state_3_code'] = !empty($r['state_3_code'])? $r['state_3_code']:'' ;
							} else {
								vmError('Model Userfields, state with id '.$_return['fields'][$_fld->name]['value'].' not found');
							}
						} else {
							$_return['fields'][$_fld->name]['value'] = '' ;
							$_return['fields'][$_fld->name]['state_2_code'] = '' ;
							$_return['fields'][$_fld->name]['state_3_code'] = '' ;
						}

						//$_return['fields'][$_fld->name]['value'] = shopFunctions::getStateByID($_return['fields'][$_fld->name]['value']);
						break;
						//case 'agreed':
						//	$_return['fields'][$_fld->name]['formcode'] = '<input type="checkbox" id="'.$_prefix.'agreed_field" name="'.$_prefix.'agreed" value="1" '
						//		. ($_fld->required ? ' class="required"' : '') . ' />';
						//	break;
					case 'password':
					case 'password2':
						$_return['fields'][$_fld->name]['formcode'] = '<input type="password" id="' . $_prefix.$_fld->name . '_field" name="' . $_prefix.$_fld->name .'" '.($_fld->required ? ' class="required"' : ''). ' size="30" class="inputbox" />'."\n";
					break;
						break;

					//case 'agreed':
					//case 'tos':


						break;
						// It's not a predefined field, so handle it by it's fieldtype
					default:
						if(strpos($_fld->type,'plugin')!==false){

							JPluginHelper::importPlugin('vmuserfield');
							$dispatcher = JDispatcher::getInstance();
							$dispatcher->trigger('plgVmOnUserfieldDisplay',array($_prefix, $_fld,isset($_userData['virtuemart_user_id'])?$_userData['virtuemart_user_id']:0,  &$_return) );
							break;
						}
					switch( $_fld->type ) {
						case 'hidden':
							$_return['fields'][$_fld->name]['formcode'] = '<input type="hidden" id="'
							. $_prefix.$_fld->name . '_field" name="' . $_prefix.$_fld->name.'" size="' . $_fld->size
							. '" value="' . $_return['fields'][$_fld->name]['value'] .'" '
							. ($_fld->required ? ' class="required"' : '')
							. ($_fld->maxlength ? ' maxlength="' . $_fld->maxlength . '"' : '')
							. $readonly . ' /> ';
							$_return['fields'][$_fld->name]['hidden'] = true;
							break;
						case 'date':
						case 'age_verification':
							//echo JHtml::_('behavior.calendar');
							/*
							 * TODO We must add the joomla.javascript here that contains the calendar,
							 * since Joomla does not load it when there's no user logged in.
							 * Gotta find out why... some security issue or a bug???
							 * Note by Oscar
							 */
							// if ($_userData === null) { // Not logged in
							// $_doc = JFactory::getDocument();
							// $_doc->addScript( JURI::root(true).'/includes/js/joomla.javascript.js');
							// }
							$currentYear= date('Y');

						//	$calendar = vmJsApi::jDate($_return['fields'][$_fld->name]['value'],  $_prefix.$_fld->name,  $_prefix.$_fld->name . '_field',false,($currentYear-100).':'.$currentYear);
						//	$_return['fields'][$_fld->name]['formcode'] = $calendar ;

							//if(empty($_return['fields'][$_fld->name]['value'])){
							//	$_return['fields'][$_fld->name]['value'] = "1912-01-01 00:00:00";
							//}                                                     jDate($date='',$name="date",$id=null,$resetBt = true, $yearRange='') {
							// Year range MUST start 100 years ago, for birthday
							$_return['fields'][$_fld->name]['formcode'] = vmJsApi::jDate($_return['fields'][$_fld->name]['value'],  $_prefix.$_fld->name,$_prefix.$_fld->name . '_field',false,($currentYear-100).':'.$currentYear);
							break;
						case 'emailaddress':
							if( JFactory::getApplication()->isSite()) {
								if(empty($_return['fields'][$_fld->name]['value'])) {
									$_return['fields'][$_fld->name]['value'] = JFactory::getUser()->email;
								}
							}							// 							vmdebug('emailaddress',$_fld);
						case 'text':
						case 'webaddress':

							$_return['fields'][$_fld->name]['formcode'] = '<input type="text" id="'
							. $_prefix.$_fld->name . '_field" name="' . $_prefix.$_fld->name.'" size="' . $_fld->size
							. '" value="' . $_return['fields'][$_fld->name]['value'] .'" '
							. ($_fld->required ? ' class="required"' : '')
							. ($_fld->maxlength ? ' maxlength="' . $_fld->maxlength . '"' : '')
							. $readonly . ' /> ';
							break;
						case 'textarea':
							$_return['fields'][$_fld->name]['formcode'] = '<textarea id="'
							. $_prefix.$_fld->name . '_field" name="' . $_prefix.$_fld->name . '" cols="' . $_fld->cols
							. '" rows="'.$_fld->rows . '" class="inputbox" '
							. $readonly.'>'
							. $_return['fields'][$_fld->name]['value'] .'</textarea>';
							break;
						case 'editorta':
							jimport( 'joomla.html.editor' );
							$editor = JFactory::getEditor();
							$_return['fields'][$_fld->name]['formcode'] = $editor->display($_prefix.$_fld->name, $_return['fields'][$_fld->name]['value'], '150', '100', $_fld->cols, $_fld->rows,  array('pagebreak', 'readmore'));
							break;
						case 'checkbox':
							$_return['fields'][$_fld->name]['formcode'] = '<input type="checkbox" name="'
							. $_prefix.$_fld->name . '" id="' . $_prefix.$_fld->name . '_field" value="1" '
							. ($_return['fields'][$_fld->name]['value'] ? 'checked="checked"' : '') .'/>';
							 if($_return['fields'][$_fld->name]['value']) {
								 $_return['fields'][$_fld->name]['value'] = vmText::_($_prefix.$_fld->title);
							 }
							break;
						case 'custom':
							if(!class_exists('shopFunctionsF'))require(VMPATH_SITE.DS.'helpers'.DS.'shopfunctionsf.php');
							$_return['fields'][$_fld->name]['formcode'] =  shopFunctionsF::renderVmSubLayout($_fld->name,array('field'=>$_return['fields'][$_fld->name],'userData' => $_userData,'prefix' => $_prefix));
							break;
							// /*##mygruz20120223193710 { :*/
						// case 'userfieldplugin': //why not just vmuserfieldsplugin ?
							// JPluginHelper::importPlugin('vmuserfield');
							// $dispatcher = JDispatcher::getInstance();
							// //Todo to adjust to new pattern, using &
							// $html = '' ;
							// $dispatcher->trigger('plgVmOnUserFieldDisplay',array($_return['fields'][$_fld->name], &$html) );
							// $_return['fields'][$_fld->name]['formcode'] = $html;
							// break;
							// /*##mygruz20120223193710 } */
						case 'multicheckbox':
						case 'multiselect':
						case 'select':
						case 'radio':
							$_qry = 'SELECT fieldtitle, fieldvalue '
							. 'FROM #__virtuemart_userfield_values '
							. 'WHERE virtuemart_userfield_id = ' . $_fld->virtuemart_userfield_id
							. ' ORDER BY ordering ';
							$_values = $this->_getList($_qry);
							// We need an extra lok here, especially for the Bank info; the values
							// must be translated.
							// Don't check on the field name though, since others might be added in the future :-(

							foreach ($_values as $_v) {
								$_v->fieldtitle = vmText::_($_v->fieldtitle);
							}
							$_attribs = array();
							if ($_fld->readonly and !$admin) {
								$_attribs['readonly'] = 'readonly';
							}
							if ($_fld->required) {
								$_attribs['class'] = 'required';
							}

							if ($_fld->type == 'radio' or $_fld->type == 'select') {
								$_selected = $_return['fields'][$_fld->name]['value'];
							} else {
								$_attribs['size'] = $_fld->size; // Use for all but radioselects
								if (!is_array($_return['fields'][$_fld->name]['value'])){
									$_selected = explode("|*|", $_return['fields'][$_fld->name]['value']);
								} else {
									$_selected = $_return['fields'][$_fld->name]['value'];
								}
							}

							// Nested switch...
							switch($_fld->type) {
								case 'multicheckbox':
									// todo: use those
									$_attribs['rows'] = $_fld->rows;
									$_attribs['cols'] = $_fld->cols;
									$formcode = '';
									$field_values="";
									$_idx = 0;
									$separator_form = '<br />';
									$separator_title = ',';
									foreach ($_values as $_val) {
										 if ( in_array($_val->fieldvalue, $_selected)) {
											 $is_selected='checked="checked"';
											 $field_values.= vmText::_($_val->fieldtitle). $separator_title;
										 }  else {
											 $is_selected='';
										 }
										$formcode .= '<input type="checkbox" name="'
										. $_prefix.$_fld->name . '[]" id="' . $_prefix.$_fld->name . '_field' . $_idx . '" value="'. $_val->fieldvalue . '" '
										. $is_selected .'/> <label for="' . $_prefix.$_fld->name . '_field' . $_idx . '">'.vmText::_($_val->fieldtitle) .'</label>'. $separator_form;
										$_idx++;
									}
									// remove last br
									$_return['fields'][$_fld->name]['formcode'] =substr($formcode ,0,-strlen($separator_form));
									$_return['fields'][$_fld->name]['value'] = substr($field_values,0,-strlen($separator_title));
									break;
								case 'multiselect':
									$_attribs['multiple'] = 'multiple';
									$_attribs['class'] = 'vm-chzn-select';
									$field_values="";
									$_return['fields'][$_fld->name]['formcode'] = JHtml::_('select.genericlist', $_values, $_prefix.$_fld->name.'[]', $_attribs, 'fieldvalue', 'fieldtitle', $_selected);
									$separator_form = '<br />';
									$separator_title = ',';
									foreach ($_values as $_val) {
										 if ( in_array($_val->fieldvalue, $_selected)) {
											 $field_values.= vmText::_($_val->fieldtitle). $separator_title;
										 }
										}
									$_return['fields'][$_fld->name]['value'] = substr($field_values,0,-strlen($separator_title));

									break;
								case 'select':
									$_attribs['class'] = 'vm-chzn-select';
									if ($_fld->size) {
										$_attribs['style']= "width: ".$_fld->size."px";
									}
									if(!$_fld->required){
										$obj = new stdClass();
										$obj->fieldtitle = vmText::_('COM_VIRTUEMART_LIST_EMPTY_OPTION');
										$obj->fieldvalue = '';
										array_unshift($_values,$obj);
									}

									$_return['fields'][$_fld->name]['formcode'] = JHTML::_('select.genericlist', $_values, $_prefix.$_fld->name, $_attribs, 'fieldvalue', 'fieldtitle', $_selected);
									if ( !empty($_selected)){
										foreach ($_values as $_val) {
											if ( $_val->fieldvalue==$_selected ) {
												// vmdebug('getUserFieldsFilled set empty select to value',$_selected,$_fld,$_return['fields'][$_fld->name]);
												$_return['fields'][$_fld->name]['value'] = vmText::_($_val->fieldtitle);
											}
										}
									}

									break;

								case 'radio':
									$_return['fields'][$_fld->name]['formcode'] =  JHtml::_('select.radiolist', $_values, $_prefix.$_fld->name, $_attribs, 'fieldvalue', 'fieldtitle', $_selected);
									if ( !empty($_selected)){
										foreach ($_values as $_val) {
											if (  $_val->fieldvalue==$_selected) {
												$_return['fields'][$_fld->name]['value'] = vmText::_($_val->fieldtitle);
											}
										}
									}

									break;
							}
							break;
					}
					break;
				}
			}
		} else {
			vmdebug('getUserFieldsFilled $_selection is not an array ',$_selection);
// 			$_return['fields'][$_fld->name]['formcode'] = '';
		}

		return $_return;
	}
Exemple #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);

	}
    ?>
</a>
				</td>
				<td align="left">
					<?php 
    echo JHtml::_('date', $row->created_on);
    ?>
				</td>
				<td align="left">
					<?php 
    echo JHtml::_('date', $row->modified_on);
    ?>
				</td>
				<td align="left">
					<?php 
    echo ShopFunctionsF::getOrderStatusName($row->order_status);
    ?>
				</td>
				<td align="left">
					<?php 
    echo $this->currency->priceDisplay($row->order_total);
    ?>
				</td>
			</tr>
	<?php 
    $k = 1 - $k;
}
?>
	</table>
</div>
Exemple #6
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);
 }
Exemple #7
0
 /**
  * Override
  *
  * @see VmModel::setPaginationLimits()
  */
 public function setPaginationLimits()
 {
     $app = JFactory::getApplication();
     $view = JRequest::getWord('view', 'virtuemart');
     $cateid = JRequest::getInt('virtuemart_category_id', -1);
     $manid = JRequest::getInt('virtuemart_manufacturer_id', 0);
     $limitString = 'com_virtuemart.' . $view . 'c' . $cateid . '.limit';
     $limit = (int) $app->getUserStateFromRequest($limitString, 'limit');
     $limitStartString = 'com_virtuemart.' . $view . '.limitstart';
     if ($app->isSite() and ($cateid != -1 or $manid != 0)) {
         $lastCatId = ShopFunctionsF::getLastVisitedCategoryId();
         $lastManId = ShopFunctionsF::getLastVisitedManuId();
         //vmdebug('setPaginationLimits is site and $cateid,$manid ',$cateid,$lastCatId,$manid);
         if (!empty($cateid) and $cateid != -1) {
             $gCatId = $cateid;
         } else {
             if (!empty($lastCatId)) {
                 $gCatId = $lastCatId;
             }
         }
         if (!empty($gCatId)) {
             $catModel = VmModel::getModel('category');
             $category = $catModel->getCategory($gCatId);
         } else {
             $category = new stdClass();
         }
         if (!empty($lastCatId) and $lastCatId != $cateid or !empty($manid) and $lastManId != $manid) {
             //We are in a new category or another manufacturer, so we start at page 1
             $limitStart = JRequest::getInt('limitstart', 0);
         } else {
             //We were already in the category/manufacturer, so we take the value stored in the session
             $limitStartString = 'com_virtuemart.' . $view . 'c' . $cateid . 'm' . $manid . '.limitstart';
             $limitStart = $app->getUserStateFromRequest($limitStartString, 'limitstart', JRequest::getInt('limitstart', 0), 'int');
         }
         if (empty($limit) and !empty($category->limit_list_initial)) {
             $suglimit = $category->limit_list_initial;
         } else {
             if (!empty($limit)) {
                 $suglimit = $limit;
             } else {
                 $suglimit = VmConfig::get('llimit_init_FE', 20);
             }
         }
         if (empty($category->products_per_row)) {
             $category->products_per_row = VmConfig::get('products_per_row', 3);
         }
         $rest = $suglimit % $category->products_per_row;
         $limit = $suglimit - $rest;
         if (!empty($category->limit_list_step)) {
             $prod_per_page = explode(",", $category->limit_list_step);
         } else {
             //fix by hjet
             $prod_per_page = explode(",", VmConfig::get('pagseq_' . $category->products_per_row));
         }
         if ($limit <= $prod_per_page['0'] && array_key_exists('0', $prod_per_page)) {
             $limit = $prod_per_page['0'];
         }
         //vmdebug('Calculated $limit  ',$limit,$suglimit);
     } else {
         $limitStart = $app->getUserStateFromRequest('com_virtuemart.' . $view . '.limitstart', 'limitstart', JRequest::getInt('limitstart', 0), 'int');
     }
     if (empty($limit)) {
         if ($app->isSite()) {
             $limit = VmConfig::get('llimit_init_FE');
         } else {
             $limit = VmConfig::get('llimit_init_BE');
         }
         if (empty($limit)) {
             $limit = 30;
         }
     }
     $this->setState('limit', $limit);
     $this->setState($limitString, $limit);
     $this->_limit = $limit;
     //There is a strange error in the frontend giving back 9 instead of 10, or 24 instead of 25
     //This functions assures that the steps of limitstart fit with the limit
     $limitStart = ceil((double) $limitStart / (double) $limit) * $limit;
     $this->setState('limitstart', $limitStart);
     $this->setState($limitStartString, $limitStart);
     $this->_limitStart = $limitStart;
     return array($this->_limitStart, $this->_limit);
 }
Exemple #8
0
 /**
  * Displays the view, collects needed data for the different layouts
  *
  * @author Max Milbers
  */
 function display($tpl = null)
 {
     $this->useSSL = tsmConfig::get('useSSL', 0);
     $this->useXHTML = false;
     tsmConfig::loadJLang('com_virtuemart_shoppers', TRUE);
     $mainframe = JFactory::getApplication();
     $pathway = $mainframe->getPathway();
     $layoutName = $this->getLayout();
     if ($layoutName == 'login') {
         parent::display($tpl);
         return;
     }
     if (empty($layoutName) or $layoutName == 'default') {
         $layoutName = vRequest::getCmd('layout', 'edit');
         if ($layoutName == 'default') {
             $layoutName = 'edit';
         }
         $this->setLayout($layoutName);
     }
     $this->_model = tmsModel::getModel('user');
     //$this->_model->setCurrent(); //without this, the administrator can edit users in the FE, permission is handled in the usermodel, but maybe unsecure?
     $editor = JFactory::getEditor();
     $virtuemart_user_id = vRequest::getInt('virtuemart_user_id', false);
     if ($virtuemart_user_id and is_array($virtuemart_user_id)) {
         $virtuemart_user_id = $virtuemart_user_id[0];
     }
     $this->_model->setId($virtuemart_user_id);
     $this->userDetails = $this->_model->getUser();
     $this->address_type = vRequest::getCmd('addrtype', 'BT');
     $new = false;
     if (vRequest::getInt('new', '0') == 1) {
         $new = true;
     }
     if ($new) {
         $virtuemart_userinfo_id = 0;
     } else {
         $virtuemart_userinfo_id = vRequest::getString('virtuemart_userinfo_id', 0);
     }
     $userFields = null;
     if (!class_exists('VirtueMartCart')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $this->cart = VirtueMartCart::getCart();
     $task = vRequest::getCmd('task', '');
     if (($this->cart->_fromCart or $this->cart->getInCheckOut()) && empty($virtuemart_userinfo_id)) {
         //New Address is filled here with the data of the cart (we are in the cart)
         $fieldtype = $this->address_type . 'address';
         $this->cart->prepareAddressFieldsInCart();
         $userFields = $this->cart->{$fieldtype};
     } else {
         if ($task == 'addST') {
             $this->address_type = 'ST';
         }
         if (!$new and empty($virtuemart_userinfo_id)) {
             $virtuemart_userinfo_id = $this->_model->getBTuserinfo_id();
             vmdebug('Try to get $virtuemart_userinfo_id by type BT', $virtuemart_userinfo_id);
         }
         $userFields = $this->_model->getUserInfoInUserFields($layoutName, $this->address_type, $virtuemart_userinfo_id, false);
         if (!$new && empty($userFields[$virtuemart_userinfo_id])) {
             $virtuemart_userinfo_id = $this->_model->getBTuserinfo_id();
             vmdebug('$userFields by getBTuserinfo_id', $userFields);
         }
         $userFields = $userFields[$virtuemart_userinfo_id];
     }
     $this->virtuemart_userinfo_id = $virtuemart_userinfo_id;
     $this->assignRef('userFields', $userFields);
     if ($layoutName == 'edit') {
         if ($this->_model->getId() == 0 && $this->_cuid == 0) {
             $button_lbl = tsmText::_('COM_VIRTUEMART_REGISTER');
         } else {
             $button_lbl = tsmText::_('COM_VIRTUEMART_SAVE');
         }
         $this->assignRef('button_lbl', $button_lbl);
         $this->lUser();
         $this->shopper($userFields);
         $this->payment();
         $this->lOrderlist();
         $this->lVendor();
     }
     $stTask = 'addST';
     if ($task == 'editaddresscart') {
         $stTask = 'editaddresscart';
     }
     $this->_lists['shipTo'] = ShopFunctionsF::generateStAddressList($this, $this->_model, $stTask);
     $this->assignRef('lists', $this->_lists);
     $this->assignRef('editor', $editor);
     if ($layoutName == 'mailregisteruser') {
         $vendorModel = tmsModel::getModel('vendor');
         //			$vendorModel->setId($this->_userDetails->virtuemart_vendor_id);
         $vendor = $vendorModel->getVendor();
         $this->assignRef('vendor', $vendor);
     }
     if ($layoutName == 'editaddress') {
         $layoutName = 'edit_address';
         $this->setLayout($layoutName);
     }
     if (!$this->userDetails->JUser->get('id')) {
         $corefield_title = tsmText::_('COM_VIRTUEMART_USER_CART_INFO_CREATE_ACCOUNT');
     } else {
         $corefield_title = tsmText::_('COM_VIRTUEMART_YOUR_ACCOUNT_DETAILS');
     }
     if ($this->cart->_fromCart or $this->cart->getInCheckOut()) {
         $pathway->addItem(tsmText::_('COM_VIRTUEMART_CART_OVERVIEW'), JRoute::_('index.php?option=com_virtuemart&view=cart', FALSE));
     } else {
         //$pathway->addItem(vmText::_('COM_VIRTUEMART_YOUR_ACCOUNT_DETAILS'), JRoute::_('index.php?option=com_virtuemart&view=user&&layout=edit'));
     }
     $pathway_text = tsmText::_('COM_VIRTUEMART_YOUR_ACCOUNT_DETAILS');
     if (!$this->userDetails->JUser->get('id')) {
         if ($this->cart->_fromCart or $this->cart->getInCheckOut()) {
             if ($this->address_type == 'BT') {
                 $vmfield_title = tsmText::_('COM_VIRTUEMART_USER_FORM_EDIT_BILLTO_LBL');
             } else {
                 $vmfield_title = tsmText::_('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL');
             }
         } else {
             if ($this->address_type == 'BT') {
                 $vmfield_title = tsmText::_('COM_VIRTUEMART_USER_FORM_EDIT_BILLTO_LBL');
                 $title = tsmText::_('COM_VIRTUEMART_REGISTER');
             } else {
                 $vmfield_title = tsmText::_('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL');
             }
         }
     } else {
         if ($this->address_type == 'BT') {
             $vmfield_title = tsmText::_('COM_VIRTUEMART_USER_FORM_BILLTO_LBL');
         } else {
             $vmfield_title = tsmText::_('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL');
         }
     }
     vmJsApi::vmValidator($this->userDetails->JUser->guest);
     $this->add_product_link = "";
     $this->manage_link = "";
     if (ShopFunctionsF::isFEmanager()) {
         $mlnk = JURI::root() . 'index.php?option=com_virtuemart&tmpl=component&manage=1';
         $this->manage_link = $this->linkIcon($mlnk, 'JACTION_MANAGE', 'new', false, false, true, true);
     }
     if (ShopFunctionsF::isFEmanager('product.edit')) {
         $aplnk = JURI::root() . 'index.php?option=com_virtuemart&tmpl=component&view=product&view=product&task=edit&virtuemart_product_id=0&manage=1';
         $this->add_product_link = $this->linkIcon($aplnk, 'COM_VIRTUEMART_PRODUCT_ADD_PRODUCT', 'new', false, false, true, true);
     }
     $document = JFactory::getDocument();
     $document->setTitle($pathway_text);
     $pathway->additem($pathway_text);
     $document->setMetaData('robots', 'NOINDEX, NOFOLLOW, NOARCHIVE, NOSNIPPET');
     $this->assignRef('page_title', $pathway_text);
     $this->assignRef('corefield_title', $corefield_title);
     $this->assignRef('vmfield_title', $vmfield_title);
     shopFunctionsF::setVmTemplate($this, 0, 0, $layoutName);
     parent::display($tpl);
 }
Exemple #9
0
 public function getProductSingle($virtuemart_product_id = NULL, $front = TRUE, $quantity = 1, $withParent = false, $virtuemart_shoppergroup_ids = 0)
 {
     if (!empty($virtuemart_product_id)) {
         $virtuemart_product_id = $this->setId($virtuemart_product_id);
     }
     if ($virtuemart_shoppergroup_ids === 0) {
         $usermodel = VmModel::getModel('user');
         $currentVMuser = $usermodel->getCurrentUser();
         if (!is_array($currentVMuser->shopper_groups)) {
             $virtuemart_shoppergroup_ids = (array) $currentVMuser->shopper_groups;
         } else {
             $virtuemart_shoppergroup_ids = $currentVMuser->shopper_groups;
         }
     }
     $virtuemart_shoppergroup_idsString = 0;
     if (!empty($virtuemart_shoppergroup_ids) and is_array($virtuemart_shoppergroup_ids)) {
         $virtuemart_shoppergroup_idsString = implode('.', $virtuemart_shoppergroup_ids);
     } else {
         if (!empty($virtuemart_shoppergroup_ids)) {
             $virtuemart_shoppergroup_idsString = $virtuemart_shoppergroup_ids;
         }
     }
     $front = $front ? TRUE : 0;
     $productKey = $virtuemart_product_id . ':' . $virtuemart_shoppergroup_idsString . ':' . $quantity . ':' . $front;
     if (array_key_exists($productKey, self::$_productsSingle)) {
         return clone self::$_productsSingle[$productKey];
     }
     if (!empty($this->_id)) {
         $product = $this->getTable('products');
         $product->load($this->_id, 0, 0);
         $product->allIds = array();
         $xrefTable = $this->getTable('product_medias');
         $product->virtuemart_media_id = $xrefTable->load((int) $this->_id);
         // Load the shoppers the product is available to for Custom Shopper Visibility
         $product->shoppergroups = $this->getTable('product_shoppergroups')->load($this->_id);
         if (!empty($product->shoppergroups) and $front) {
             if (!class_exists('VirtueMartModelUser')) {
                 require VMPATH_ADMIN . DS . 'models' . DS . 'user.php';
             }
             $commonShpgrps = array_intersect($virtuemart_shoppergroup_ids, $product->shoppergroups);
             if (empty($commonShpgrps)) {
                 return $this->fillVoidProduct($front);
             }
         }
         $this->getRawProductPrices($product, $quantity, $virtuemart_shoppergroup_ids, $front, $withParent);
         $xrefTable = $this->getTable('product_manufacturers');
         $product->virtuemart_manufacturer_id = $xrefTable->load((int) $this->_id);
         if (!empty($product->virtuemart_manufacturer_id[0])) {
             //This is a fallback
             $mfTable = $this->getTable('manufacturers');
             $mfTable->load((int) $product->virtuemart_manufacturer_id[0]);
             $product = (object) array_merge((array) $mfTable, (array) $product);
         } else {
             $product->virtuemart_manufacturer_id = array();
             $product->mf_name = '';
             $product->mf_desc = '';
             $product->mf_url = '';
         }
         // Load the categories the product is in
         $product->categoryItem = $this->getProductCategories($this->_id);
         //We need also the unpublished categories, else the calculation rules do not work
         $product->canonCatId = false;
         $public_cats = array();
         if (!empty($product->categoryItem)) {
             $tmp = array();
             foreach ($product->categoryItem as $category) {
                 if ($category['published']) {
                     if (!$product->canonCatId) {
                         $product->canonCatId = $category['virtuemart_category_id'];
                     }
                     $public_cats[] = $category['virtuemart_category_id'];
                 }
                 $tmp[] = $category['virtuemart_category_id'];
             }
             $product->categories = $tmp;
         }
         if (!empty($product->categories) and is_array($product->categories)) {
             if ($front) {
                 if (!class_exists('shopFunctionsF')) {
                     require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
                 }
                 //We must first check if we come from another category, due the canoncial link we would have always the same catgory id for a product
                 //But then we would have wrong neighbored products / category and product layouts
                 if (!isset($this->categoryId)) {
                     static $menu = null;
                     if (!isset($menu)) {
                         $app = JFactory::getApplication();
                         $menus = $app->getMenu();
                         $menu = $menus->getActive();
                     }
                     $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) {
                             $this->categoryId = ShopFunctionsF::getLastVisitedCategoryId();
                         }
                     }
                     //$last_category_id = shopFunctionsF::getLastVisitedCategoryId ();
                     if ($this->categoryId !== 0 and in_array($this->categoryId, $product->categories)) {
                         $product->virtuemart_category_id = $this->categoryId;
                     }
                     if ($this->categoryId !== 0 and $this->categoryId != $product->canonCatId) {
                         if (in_array($this->categoryId, $public_cats)) {
                             $product->virtuemart_category_id = $this->categoryId;
                         }
                     }
                 }
             }
             //vmdebug('$product->virtuemart_category_id',$product->virtuemart_category_id);
             if (empty($product->virtuemart_category_id)) {
                 $virtuemart_category_id = vRequest::getInt('virtuemart_category_id', 0);
                 if ($virtuemart_category_id !== 0 and in_array($virtuemart_category_id, $product->categories)) {
                     $product->virtuemart_category_id = $virtuemart_category_id;
                 } else {
                     if (!empty($product->canonCatId)) {
                         $product->virtuemart_category_id = $product->canonCatId;
                         //} else if (!$front and !empty($product->categories) and is_array ($product->categories) and array_key_exists (0, $product->categories)) {
                         //why the restriction why we should use it for BE only?
                     } else {
                         if (!empty($product->categories) and is_array($product->categories) and array_key_exists(0, $product->categories)) {
                             $product->virtuemart_category_id = $product->categories[0];
                             //vmdebug('I take for product the main category ',$product->virtuemart_category_id,$product->categories);
                         }
                     }
                 }
             }
         }
         if (empty($product->virtuemart_category_id)) {
             $product->virtuemart_category_id = $product->canonCatId;
         }
         if (!empty($product->virtuemart_category_id)) {
             $found = false;
             foreach ($product->categoryItem as $category) {
                 if ($category['virtuemart_category_id'] == $product->virtuemart_category_id) {
                     $product->ordering = $category['ordering'];
                     //This is the ordering id in the list to store the ordering notice by Max Milbers
                     $product->id = $category['id'];
                     $product->category_name = $category['category_name'];
                     $found = true;
                     break;
                 }
             }
             if (!$found) {
                 $product->ordering = $this->_autoOrder++;
                 $product->id = $this->_autoOrder;
                 vmdebug('$product->virtuemart_category_id no ordering stored for product ' . $this->_id);
             }
         } else {
             $product->category_name = '';
             $product->virtuemart_category_id = '';
             $product->ordering = '';
             $product->id = $this->_autoOrder++;
         }
         // Check the stock level
         if (empty($product->product_in_stock)) {
             $product->product_in_stock = 0;
         }
         self::$_productsSingle[$productKey] = $product;
     } else {
         self::$_productsSingle[$productKey] = $this->fillVoidProduct($front);
     }
     return clone self::$_productsSingle[$productKey];
 }
 /**
  * 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);
 }
 /**
  * There are too many functions doing almost the same for my taste
  * the results are sometimes slighty different and makes it hard to work with it, therefore here the function for future proxy use
  *
  */
 public function customFieldDisplay($product, $variantmods, $html, $trigger)
 {
     //vmdebug('customFieldDisplay $variantmods',$variantmods);
     $row = 0;
     if (!class_exists('shopFunctionsF')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     foreach ($variantmods as $selected => $variant) {
         if ($selected) {
             $productCustom = self::getProductCustomFieldCart($selected);
             if (!empty($productCustom)) {
                 $html .= ' <span class="product-field-type-' . $productCustom->field_type . '">';
                 if ($productCustom->field_type == "E") {
                     $product = self::addParam($product);
                     $product->productCustom = $productCustom;
                     //vmdebug('CustomsFieldCartDisplay $productCustom',$productCustom);
                     // 								vmdebug('customFieldDisplay $product->param selected '.$selected,$product->param);
                     if (!class_exists('vmCustomPlugin')) {
                         require JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php';
                     }
                     JPluginHelper::importPlugin('vmcustom');
                     $dispatcher = JDispatcher::getInstance();
                     $dispatcher->trigger($trigger, array($product, $row, &$html));
                 } else {
                     $value = '';
                     if ($productCustom->field_type == "G") {
                         $child = self::getChild($productCustom->custom_value);
                         // 						$html .= $productCustom->custom_title.' '.$child->product_name;
                         $value = $child->product_name;
                     } elseif ($productCustom->field_type == "M") {
                         // 						$html .= $productCustom->custom_title.' '.self::displayCustomMedia($productCustom->custom_value);
                         $value = self::displayCustomMedia($productCustom->custom_value);
                     } elseif ($productCustom->field_type == "S") {
                         // 					q	$html .= $productCustom->custom_title.' '.JText::_($productCustom->custom_value);
                         $value = $productCustom->custom_value;
                     } else {
                         // 						$html .= $productCustom->custom_title.' '.$productCustom->custom_value;
                         $value = $productCustom->custom_value;
                     }
                     $html .= ShopFunctionsF::translateTwoLangKeys($productCustom->custom_title, $value);
                 }
                 $html .= '</span><br />';
             } else {
                 // falldown method if customfield are deleted
                 foreach ((array) $selected as $key => $value) {
                     $html .= '<br/ >' . ($key ? '<span>' . $key . ' </span>' : '') . $value;
                 }
                 vmdebug('CustomsFieldOrderDisplay, $item->productCustom empty? ' . $variant);
                 vmdebug('customFieldDisplay, $productCustom is EMPTY ');
             }
         }
         $row++;
     }
     vmdebug('customFieldDisplay html begin: ' . $html . ' end');
     return $html . '</div>';
 }
Exemple #12
0
 function display($tpl = null)
 {
     if (!class_exists('VmHTML')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php';
     }
     $model = VmModel::getModel('calc');
     //@todo should be depended by loggedVendor
     $this->vendorId = vmAccess::getVendorId();
     $this->SetViewTitle();
     $layoutName = vRequest::getCmd('layout', 'default');
     if ($layoutName == 'edit') {
         $calc = $model->getCalc();
         $this->assignRef('calc', $calc);
         $isNew = $calc->virtuemart_calc_id < 1;
         if ($isNew) {
             $calc->virtuemart_vendor_id = $this->vendorId;
             $db = JFactory::getDBO();
             //get default currency of the vendor, if not set get default of the shop
             $q = 'SELECT `vendor_currency` FROM `#__virtuemart_vendors` WHERE `virtuemart_vendor_id` = "' . $this->vendorId . '"';
             $db->setQuery($q);
             $currency = $db->loadResult();
             if (empty($currency)) {
                 $q = 'SELECT `vendor_currency` FROM `#__virtuemart_vendors` WHERE `virtuemart_vendor_id` = "1" ';
                 $db->setQuery($q);
                 $currency = $db->loadResult();
                 $calc->calc_currency = $currency;
             } else {
                 $calc->calc_currency = $currency;
             }
         }
         $this->entryPointsList = self::renderEntryPointsList($calc->calc_kind);
         $this->mathOpList = self::renderMathOpList($calc->calc_value_mathop);
         if (empty($calc->calc_categories)) {
             $calc->calc_categories = array();
         } else {
             if (!is_array($calc->calc_categories)) {
                 $calc->calc_categories = array($calc->calc_categories);
             }
         }
         $calc_categories = $calc->calc_categories;
         $this->categoryTree = ShopFunctions::categoryListTree($calc_categories);
         $currencyModel = VmModel::getModel('currency');
         $this->currencies = $currencyModel->getCurrencies();
         $this->shopperGroupList = ShopFunctions::renderShopperGroupList($calc->virtuemart_shoppergroup_ids, True);
         if (!class_exists('ShopFunctionsF')) {
             require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
         }
         $this->countriesList = ShopFunctionsF::renderCountryList($calc->calc_countries, True);
         $this->statesList = ShopFunctionsF::renderStateList($calc->virtuemart_state_ids, '', True);
         $this->manufacturerList = ShopFunctions::renderManufacturerList($calc->virtuemart_manufacturers, true);
         if ($this->showVendors()) {
             $this->vendorList = ShopFunctions::renderVendorList($calc->virtuemart_vendor_id);
         }
         $this->addStandardEditViewCommands();
     } else {
         if ($this->showVendors()) {
             JToolBarHelper::custom('toggle.shared.1', 'publish', 'yes', vmText::_('COM_VIRTUEMART_SHARED_TOGGLE_ON'), true);
             JToolBarHelper::custom('toggle.shared.0', 'unpublish', 'no', vmText::_('COM_VIRTUEMART_SHARED_TOGGLE_OFF'), true);
         }
         $this->addStandardDefaultViewCommands();
         $this->addStandardDefaultViewLists($model);
         $search = vRequest::getCmd('search', false);
         $this->calcs = $model->getCalcs(false, false, $search);
         VmConfig::loadJLang('com_virtuemart_shoppers', true);
         foreach ($this->calcs as &$data) {
             $data->calcCategoriesList = shopfunctions::renderGuiList($data->virtuemart_calc_id, 'categories', 'category_name', 'category', 'calc_categories', 'virtuemart_calc_id');
             $data->calcShoppersList = shopfunctions::renderGuiList($data->virtuemart_calc_id, 'shoppergroups', 'shopper_group_name', 'shoppergroup', 'calc_shoppergroups', 'virtuemart_calc_id');
             $data->calcCountriesList = shopfunctions::renderGuiList($data->virtuemart_calc_id, 'countries', 'country_name', 'country', 'calc_countries', 'virtuemart_calc_id');
             $data->calcStatesList = shopfunctions::renderGuiList($data->virtuemart_calc_id, 'states', 'state_name', 'states', 'calc_states', 'virtuemart_calc_id');
             $data->calcManufacturersList = shopfunctions::renderGuiList($data->virtuemart_calc_id, 'manufacturers', 'mf_name', 'manufacturer', 'calc_manufacturers', 'virtuemart_calc_id');
         }
         $this->pagination = $model->getPagination();
     }
     parent::display($tpl);
 }
Exemple #13
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);
 }
 public function display($tpl = null)
 {
     $show_prices = VmConfig::get('show_prices', 1);
     if ($show_prices == '1') {
         JLoader::register('calculationHelper', JPATH_VM_ADMINISTRATOR . '/helpers/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();
     JLoader::register('VmImage', JPATH_VM_ADMINISTRATOR . '/helpers/image.php');
     $categoryModel = VmModel::getModel('category');
     $productModel = VmModel::getModel('product');
     $search = JRequest::getvar('keyword', null);
     if ($search !== null) {
         $searchcustom = $this->getSearchCustom();
     }
     $this->assignRef('keyword', $keyword);
     $this->assignRef('search', $search);
     $categoryId = JRequest::getInt('virtuemart_category_id', ShopFunctionsF::getLastVisitedCategoryId());
     $virtuemart_manufacturer_id = JRequest::getInt('virtuemart_manufacturer_id', 0);
     $this->setCanonicalLink($tpl, $document, $categoryId);
     // $vendorId = JRequest::getInt('virtuemart_vendor_id', 1);
     $vendorId = JRequest::getInt('virtuemart_vendor_id', null);
     // Load the products in the given category
     $products = $productModel->getProductsInCategory($categoryId, $vendorId);
     $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);
     }
     JLoader::register('Permissions', JPATH_VM_ADMINISTRATOR . '/helpers/permissions.php');
     $showBasePrice = Permissions::getInstance()->check('admin');
     //todo add config settings
     $this->assignRef('showBasePrice', $showBasePrice);
     //set this after the $categoryId definition
     $paginationAction = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $categoryId, FALSE);
     $this->assignRef('paginationAction', $paginationAction);
     shopFunctionsF::setLastVisitedCategoryId($categoryId);
     shopFunctionsF::setLastVisitedManuId($virtuemart_manufacturer_id);
     if ($categoryId !== -1) {
         $vendorId = JRequest::getInt('virtuemart_vendor_id', 1);
         $category = $categoryModel->getCategory($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);
     if (!empty($category)) {
         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);
                     //return false;
                 }
             }
             $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;
         }
         //No redirect here, category id = 0 means show ALL categories! note by Max Milbers
         /*		if(empty($category->virtuemart_vendor_id) && $search == null ) {
         					$app -> enqueueMessage(JText::_('COM_VIRTUEMART_CATEGORY_NOT_FOUND'));
         					$app -> redirect( 'index.php');
         				}*/
         // 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->addImages($category->children, 1);
         if (VmConfig::get('enable_content_plugin', 0)) {
             // add content plugin //
             $dispatcher = JDispatcher::getInstance();
             JPluginHelper::importPlugin('content');
             $params = new JRegistry();
             $category->event = new stdClass();
             $category->catid = $category->virtuemart_category_id;
             $category->id = null;
             $category->title = $category->category_name;
             $category->text = $category->category_description;
             $results = $dispatcher->trigger('onContentPrepare', array('com_virtuemart.category', &$category, &$params, 0));
             // More events for 3rd party content plugins
             // This do not disturb actual plugins, because we don't modify $product->text
             $res = $dispatcher->trigger('onContentAfterTitle', array('com_virtuemart.category', &$category, &$params, 0));
             $category->event->afterDisplayTitle = trim(implode("\n", $res));
             $res = $dispatcher->trigger('onContentBeforeDisplay', array('com_virtuemart.category', &$category, &$params, 0));
             $category->event->beforeDisplayContent = trim(implode("\n", $res));
             $res = $dispatcher->trigger('onContentAfterDisplay', array('com_virtuemart.category', &$category, &$params, 0));
             $category->event->afterDisplayContent = trim(implode("\n", $res));
             $category->category_description = $category->text;
             $category->category_name = $category->title;
         }
         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);
     }
     // set search and keyword
     if ($keyword = vmRequest::uword('keyword', '0', ' ,-,+,.,_')) {
         $pathway->addItem($keyword);
         //$title .=' ('.$keyword.')';
     }
     parent::display($tpl);
 }
Exemple #15
0
 static function getInvoiceFolderName()
 {
     if (!class_exists('ShopFunctionsF')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     return ShopFunctionsF::getInvoiceFolderName();
 }
 protected function truncate($string, $length)
 {
     if (!class_exists('shopFunctionsF')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     return ShopFunctionsF::vmSubstr($string, 0, $length);
 }
 /**
  * There are too many functions doing almost the same for my taste
  * the results are sometimes slighty different and makes it hard to work with it, therefore here the function for future proxy use
  *
  */
 public function customFieldDisplay($product, $variantmods, $html, $trigger)
 {
     //vmdebug('customFieldDisplay $variantmods',$variantmods);
     $row = 0;
     JLoader::register('shopFunctionsF', JPATH_VM_SITE . '/helpers/shopfunctionsf.php');
     //MarkerVarMods
     foreach ($variantmods as $selected => $variant) {
         //foreach ($variantmods as $variant=> $selected) {
         //vmdebug('customFieldDisplay '.$variant.' '.$selected);
         if ($selected) {
             $productCustom = self::getProductCustomField($selected);
             //vmdebug('customFieldDisplay',$selected,$productCustom);
             if (!empty($productCustom)) {
                 $html .= ' <span class="product-field-type-' . $productCustom->field_type . '">';
                 if ($productCustom->field_type == "E") {
                     $product = self::addParam($product);
                     $product->productCustom = $productCustom;
                     //vmdebug('CustomsFieldCartDisplay $productCustom',$productCustom);
                     // 								vmdebug('customFieldDisplay $product->param selected '.$selected,$product->param);
                     JLoader::register('vmCustomPlugin', JPATH_VM_PLUGINS . '/vmcustomplugin.php');
                     JPluginHelper::importPlugin('vmcustom');
                     $dispatcher = JDispatcher::getInstance();
                     $dispatcher->trigger($trigger, array($product, $row, &$html));
                 } else {
                     //vmdebug('customFieldDisplay $productCustom by self::getProductCustomField $variant: '.$variant.' $selected: '.$selected,$productCustom);
                     $value = '';
                     if ($productCustom->field_type == "G") {
                         $child = self::getChild($productCustom->custom_value);
                         // 						$html .= $productCustom->custom_title.' '.$child->product_name;
                         $value = $child->product_name;
                     } elseif ($productCustom->field_type == "M") {
                         // 						$html .= $productCustom->custom_title.' '.self::displayCustomMedia($productCustom->custom_value);
                         $value = self::displayCustomMedia($productCustom->custom_value);
                     } elseif ($productCustom->field_type == "S") {
                         // 					q	$html .= $productCustom->custom_title.' '.JText::_($productCustom->custom_value);
                         $value = $productCustom->custom_value;
                     } else {
                         // 						$html .= $productCustom->custom_title.' '.$productCustom->custom_value;
                         //vmdebug('customFieldDisplay',$productCustom);
                         $value = $productCustom->custom_value;
                     }
                     $html .= ShopFunctionsF::translateTwoLangKeys($productCustom->show_title ? $productCustom->custom_title : '', $value);
                 }
                 $html .= '</span>';
                 //STUDIO 42 , removed <br/>, why simply not "div" and not "span" ?
             } else {
                 // falldown method if customfield are deleted
                 foreach ((array) $selected as $key => $value) {
                     $html .= '<br/ >Couldnt find customfield' . ($key ? '<span>' . $key . ' </span>' : '') . $value;
                 }
             }
         }
         $row++;
     }
     //	vmdebug ('customFieldDisplay html begin: ' . $html . ' end');
     return $html . '</div>';
 }
Exemple #18
0
 /**
  * There are too many functions doing almost the same for my taste
  * the results are sometimes slighty different and makes it hard to work with it, therefore here the function for future proxy use
  *
  */
 public static function displayProductCustomfieldSelected($product, $html, $trigger)
 {
     if (isset($product->param)) {
         vmTrace('param found, seek and destroy');
         return false;
     }
     $row = 0;
     if (!class_exists('shopFunctionsF')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     $variantmods = isset($product->customProductData) ? $product->customProductData : $product->product_attribute;
     if (empty($variantmods)) {
         $productDB = VmModel::getModel('product')->getProduct($product->virtuemart_product_id);
         if ($productDB) {
             $product->customfields = $productDB->customfields;
         }
     }
     if (!is_array($variantmods)) {
         $variantmods = json_decode($variantmods, true);
     }
     $productCustoms = array();
     foreach ($product->customfields as $prodcustom) {
         //We just add the customfields to be shown in the cart to the variantmods
         if (is_object($prodcustom)) {
             if ($prodcustom->is_cart_attribute and !$prodcustom->is_input) {
                 $variantmods[$prodcustom->virtuemart_custom_id] = $prodcustom->virtuemart_customfield_id;
             } else {
                 if (!empty($variantmods) and !empty($variantmods[$prodcustom->virtuemart_custom_id])) {
                 }
             }
             $productCustoms[$prodcustom->virtuemart_customfield_id] = $prodcustom;
         }
     }
     foreach ($variantmods as $custom_id => $customfield_ids) {
         if (!is_array($customfield_ids)) {
             $customfield_ids = array($customfield_ids => false);
         }
         foreach ($customfield_ids as $customfield_id => $params) {
             if (empty($productCustoms) or !isset($productCustoms[$customfield_id])) {
                 continue;
             }
             $productCustom = $productCustoms[$customfield_id];
             //The stored result in vm2.0.14 looks like this {"48":{"textinput":{"comment":"test"}}}
             //and now {"32":[{"invala":"100"}]}
             if (!empty($productCustom)) {
                 $html .= ' <span class="product-field-type-' . $productCustom->field_type . '">';
                 if ($productCustom->field_type == "E") {
                     //$product->productCustom = $productCustom;
                     //$product->row = $row;
                     //
                     if (!class_exists('vmCustomPlugin')) {
                         require JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php';
                     }
                     JPluginHelper::importPlugin('vmcustom');
                     $dispatcher = JDispatcher::getInstance();
                     //vmdebug('displayProductCustomfieldSelected is PLUGIN use trigger '.$trigger,$product->virtuemart_product_id,$productCustom->virtuemart_customfield_id,$productCustom->custom_element);
                     $dispatcher->trigger($trigger . 'VM3', array(&$product, &$productCustom, &$html));
                 } else {
                     //vmdebug('customFieldDisplay $productCustom by self::getProductCustomField $variant: '.$variant.' $selected: '.$selected,$productCustom);
                     $value = '';
                     if ($productCustom->field_type == "G") {
                         $db = JFactory::getDBO();
                         $db->setQuery('SELECT  `product_name` FROM `#__virtuemart_products_' . VmConfig::$vmlang . '` WHERE virtuemart_product_id=' . (int) $productCustom->customfield_value);
                         $child = $db->loadObject();
                         $value = $child->product_name;
                     } elseif ($productCustom->field_type == "M") {
                         // 						$html .= $productCustom->custom_title.' '.self::displayCustomMedia($productCustom->custom_value);
                         $value = self::displayCustomMedia($productCustom->customfield_value);
                     } elseif ($productCustom->field_type == "S") {
                         //$value = $productCustom->custom_title.' '.vmText::_($productCustom->customfield_value);
                         $value = $productCustom->customfield_value;
                     } else {
                         // 						$html .= $productCustom->custom_title.' '.$productCustom->custom_value;
                         //vmdebug('customFieldDisplay',$productCustom);
                         $value = $productCustom->customfield_value;
                     }
                     $html .= ShopFunctionsF::translateTwoLangKeys($productCustom->custom_title, $value);
                 }
                 $html .= '</span><br />';
             } else {
                 // falldown method if customfield are deleted
                 foreach ((array) $customfield_id as $key => $value) {
                     $html .= '<br/ >Couldnt find customfield' . ($key ? '<span>' . $key . ' </span>' : '') . $value;
                 }
                 //vmdebug ('CustomsFieldOrderDisplay, $item->productCustom empty? ' . $variant);
                 vmdebug('customFieldDisplay, $productCustom is EMPTY ' . $customfield_id);
             }
         }
     }
     return $html . '</div>';
 }