params)){ $plugin =& JPluginHelper::getPlugin('system', 'hikashopproductinsert'); jimport('joomla.html.parameter'); $this->params = new JParameter( $plugin->params ); } } function escape($str){ return htmlspecialchars($str, ENT_COMPAT, 'UTF-8');} function onAfterRender() { $app = & JFactory::getApplication(); if ($app->isAdmin()) return true; $layout = JRequest::getString('layout'); if ($layout == 'edit') return true; $body = JResponse::getBody(); if (preg_match_all('#\{product\}(.*)\{\/product\}#Uis', $body, $matches)) { if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')) return true; $db = & JFactory::getDBO(); $currencyClass = hikashop_get('class.currency'); $this->image = hikashop_get('helper.image'); $para=array(); $nbtag = count($matches[1]); for ($i = 0; $i < $nbtag; $i++) { $para[$i] = explode('|', $matches[1][$i]); } $k = 0; $ids=array(); for ($i = 0; $i<$nbtag; $i++){ for ($u=0; $usetQuery($product_query); $products = $db->loadObjectList(); $db->setQuery('SELECT * FROM '.hikashop_table('variant').' WHERE variant_product_id IN ('.implode(',',$ids).')'); $variants = $db->loadObjectList(); if(!empty($variants)){ foreach($products as $k => $product){ foreach($variants as $variant){ if($product->product_id==$variant->variant_product_id){ $products[$k]->has_options = true; break; } } } } $queryImage = 'SELECT * FROM ' . hikashop_table('file') . ' WHERE file_ref_id IN (' . implode(',', $ids) . ') AND file_type=\'product\' ORDER BY file_ordering ASC, file_id ASC'; $db->setQuery($queryImage); $images = $db->loadObjectList(); foreach ($products as $k => $row) { if(method_exists($app,'stringURLSafe')){ $products[$k]->alias = $app->stringURLSafe(strip_tags($row->product_name)); }else{ $products[$k]->alias = JFilterOutput::stringURLSafe(strip_tags($row->product_name)); } foreach ($images as $j => $image) { if ($row->product_id == $image->file_ref_id) { foreach (get_object_vars($image) as $key => $name) { $products[$k]->images[$j]->$key = $name; } } } } $zone_id=hikashop_getZone(); $currencyClass = hikashop_get('class.currency'); $config =& hikashop_config(); $main_currency = (int)$config->get('main_currency',1); $currencyClass->getListingPrices($products,$zone_id,$main_currency,'all'); for ($i = 0; $i < $nbtag; $i++) { $nbprodtag = count($para[$i]); $this->name = 0; $this->pricetax = 0; $this->pricedis = 0; $this->price = 0; $this->cart = 0; $this->quantityfield = 0; $this->description = 0; $this->picture = 0; $this->link = 0; $this->border = 0; if (in_array("name", $para[$i])) { $this->name = 1; $nbprodtag--; } if (in_array("pricedis1", $para[$i])) { $this->pricedis = 1; $nbprodtag--; } if (in_array("pricedis2", $para[$i])) { $this->pricedis = 2; $nbprodtag--; } if (in_array("pricedis3", $para[$i])) { $this->pricedis = 3; $nbprodtag--; } if (in_array("pricetax1", $para[$i])) { $this->pricetax = 1; $nbprodtag--; } if (in_array("pricetax2", $para[$i])) { $this->pricetax = 2; $nbprodtag--; } if (in_array("price", $para[$i])) { $this->price = 1; $nbprodtag--; } if (in_array("cart", $para[$i])) { $this->cart = 1; $nbprodtag--; } if (in_array("quantityfield", $para[$i])) { $this->quantityfield = 1; $nbprodtag--; } if (in_array("description", $para[$i])) { $this->description = 1; $nbprodtag--; } if (in_array("picture", $para[$i])) { $this->picture = 1; $nbprodtag--; } if (in_array("link", $para[$i])) { $this->link = 1; $nbprodtag--; } if (in_array("border", $para[$i])) { $this->border = 1; $nbprodtag--; } $id = array(); for ($j = 0; $j < $nbprodtag; $j++) { $id[$j] = $para[$i][$j]; } JHTML::_('behavior.mootools'); $name = 'hikashopproductinsert_view.php'; $path = JPATH_THEMES.DS.$app->getTemplate().DS.'system'.DS.$name; if(!file_exists($path)){ if(version_compare(JVERSION,'1.6','<')){ $path = JPATH_PLUGINS .DS.'system'.DS.$name; }else{ $path = JPATH_PLUGINS .DS.'system'.DS.'hikashopproductinsert'.DS.$name; } if(!file_exists($path)){ return true; } } ob_start(); require($path); $product_view = ob_get_clean(); $pattern = '#\{product\}(.*)\{\/product\}#Uis'; $replacement = ''; $body = JResponse::getBody(); $body = preg_replace($pattern, str_replace('$','\$',$product_view), $body, 1); JResponse::setBody($body); } return; } else { return; } } } ?>