Пример #1
0
 function placeBadges(&$image, &$badges, $vertical, $horizontal, $echo = true)
 {
     if (empty($badges)) {
         return;
     }
     $position1 = 0;
     $position2 = 0;
     $position3 = 0;
     $position4 = 0;
     $backup_main_x = $image->main_thumbnail_x;
     $backup_main_y = $image->main_thumbnail_y;
     $width_real = $image->thumbnail_x;
     $height_real = $image->thumbnail_y;
     $html = '';
     $config = hikashop_config();
     foreach ($badges as $badge) {
         if ($badge->badge_published == 1) {
             if (!empty($badge->badge_keep_size)) {
                 list($badge_width, $badge_height) = getimagesize($image->getPath(@$badge->badge_image, false));
             } else {
                 $badge_width = intval($width_real * $badge->badge_size / 100);
                 $badge_height = intval($height_real * $badge->badge_size / 100);
             }
             $position = $badge->badge_position;
             $position_top = $badge->badge_vertical_distance + $vertical;
             $position_right = $badge->badge_horizontal_distance + $horizontal;
             $position_left = $badge->badge_horizontal_distance + $horizontal;
             $position_bottom = $badge->badge_vertical_distance + $vertical;
             $styletopleft = "position: absolute; z-index:2; top: " . $position_top . "px; left: " . $position_left . "px;margin-top:10px;";
             $styletopright = "position: absolute; z-index:3; top: " . $position_top . "px; right: " . $position_right . "px;margin-top:10px;";
             $stylebottomleft = "position: absolute; z-index:4; bottom: " . $position_bottom . "px; left: " . $position_left . "px;margin-bottom:10px;";
             $stylebottomright = "position: absolute; z-index:5; bottom: " . $position_bottom . "px; right: " . $position_right . "px;margin-bottom:10px;";
             $image_options = array('default' => true, 'forcesize' => $config->get('image_force_size', true), 'scale' => $config->get('image_scale_mode', 'inside'));
             $img = $image->getThumbnail(@$badge->badge_image, array('width' => $badge_width, 'height' => $badge_height), $image_options);
             if (!$img) {
                 continue;
             }
             $imageDisplayed = '<img class="hikashop_product_badge_image" title="' . htmlentities(@$badge->badge_name) . '" alt="' . htmlentities(@$badge->badge_name) . '" src="' . $img->url . '"/>';
             if (!empty($badge->badge_url)) {
                 $imageDisplayed = '<a href="' . hikashop_cleanURL($badge->badge_url) . '">' . $imageDisplayed . '</a>';
             }
             if ($position == 'topleft' && ($position1 == 0 || $badge->badge_ordering < $position1)) {
                 $html .= '<div class="hikashop_badge_topleft_div" style="' . $styletopleft . '">' . $imageDisplayed . '</div>';
                 $position1 = $badge->badge_ordering;
             } elseif ($position == 'topright' && ($position2 == 0 || $badge->badge_ordering < $position2)) {
                 $html .= '<div class="hikashop_badge_topright_div" style="' . $styletopright . '">' . $imageDisplayed . '</div>';
                 $position2 = $badge->badge_ordering;
             } elseif ($position == 'bottomright' && ($position3 == 0 || $badge->badge_ordering < $position3)) {
                 $html .= '<div class="hikashop_badge_bottomright_div" style="' . $stylebottomright . '">' . $imageDisplayed . '</div>';
                 $position3 = $badge->badge_ordering;
             } elseif ($position == 'bottomleft' && ($position4 == 0 || $badge->badge_ordering < $position4)) {
                 $html .= '<div class="hikashop_badge_bottomleft_div" style="' . $stylebottomleft . '">' . $imageDisplayed . '</div>';
                 $position4 = $badge->badge_ordering;
             }
         }
     }
     $image->main_thumbnail_x = $backup_main_x;
     $image->main_thumbnail_y = $backup_main_y;
     if ($echo) {
         echo $html;
     } else {
         return $html;
     }
 }
Пример #2
0
	<<?php 
    echo $titleType;
    ?>
>
	<?php 
    echo $heading;
    ?>
	</<?php 
    echo $titleType;
    ?>
>
	<?php 
}
if (!$this->module) {
    if (isset($this->element->category_canonical) && !empty($this->element->category_canonical)) {
        $canonicalUrl = hikashop_cleanURL($this->element->category_canonical);
        $doc = JFactory::getDocument();
        $doc->addCustomTag('<link rel="canonical" href="' . $canonicalUrl . '" />');
    }
    if ($this->params->get('show_image') && !empty($this->element->file_path) || $this->params->get('show_description') && !empty($this->element->category_description)) {
        ?>
		<div class="hikashop_category_description">
		<?php 
        if ($this->params->get('show_image') && !empty($this->element->file_path)) {
            jimport('joomla.filesystem.file');
            if (JFile::exists($this->image->getPath($this->element->file_path, false))) {
                ?>
			<img src="<?php 
                echo $this->image->getPath($this->element->file_path);
                ?>
" class="hikashop_category_image" title="<?php 
Пример #3
0
 function _addFacebookButton(&$plugin)
 {
     if (empty($plugin->params['display_fb'])) {
         return;
     }
     $element = $this->_getElementInfo();
     if (empty($element)) {
         return '';
     }
     $options = array('layout' => 'standard', 'width' => 400);
     $xfbml_options = array();
     $classname = 'standard';
     switch ((int) $plugin->params['fb_style']) {
         case 1:
             $classname = 'button_count';
             $options['layout'] = 'button_count';
             $xfbml_options['layout'] = 'button_count';
             $options['width'] = 115;
             break;
         case 2:
             $classname = 'box_count';
             $options['layout'] = 'box_count';
             $xfbml_options['layout'] = 'box_count';
             $options['width'] = 115;
             break;
         case 3:
             $classname = 'button';
             $options['layout'] = 'button';
             $xfbml_options['layout'] = 'button';
             $options['width'] = 65;
             break;
     }
     if (empty($plugin->params['fb_faces'])) {
         $options['show_faces'] = 'false';
         $xfbml_options['show-faces'] = 'false';
     } else {
         $options['show_faces'] = 'true';
         $xfbml_options['show-faces'] = 'false';
         // in the first version of the plugin, in fact is was set to "false", so...
     }
     if (empty($plugin->params['fb_verb'])) {
         $options['action'] = 'like';
     } else {
         $options['action'] = 'recommend';
         $xfbml_options['action'] = 'recommend';
     }
     if (empty($plugin->params['fb_theme'])) {
         $options['colorscheme'] = 'light';
     } else {
         $options['colorscheme'] = 'dark';
         $xfbml_options['colorscheme'] = 'dark';
     }
     $fonts = array(0 => 'arial', 1 => 'lucida%20grande', 2 => 'segoe%20ui', 3 => 'tahoma', 4 => 'trebuchet%20ms', 5 => 'verdana');
     if (isset($fonts[(int) $plugin->params['fb_font']])) {
         $options['font'] = $fonts[(int) $plugin->params['fb_font']];
         $xfbml_options['font'] = $fonts[(int) $plugin->params['fb_font']];
     }
     if (!empty($plugin->params['fb_send'])) {
         $xfbml_options['send'] = 'true';
     }
     if (!empty($element->url_canonical)) {
         $url = hikashop_cleanURL($element->url_canonical);
     } else {
         $url = hikashop_currentURL('', false);
     }
     $html = '<span class="hikashop_social_fb">';
     if ($plugin->params['position'] == 1) {
         $html = '<span class="hikashop_social_fb_right">';
     }
     $url_options = array();
     if ($plugin->params['fb_tag'] == 'iframe') {
         foreach ($options as $k => $v) {
             $url_options[] = $k . '=' . urlencode($v);
         }
         $html .= '<iframe ' . 'src="//www.facebook.com/plugins/like.php?href=' . urlencode($url) . '&amp;send=false&amp;' . implode('&amp;', $url_options) . '&amp;height=30" ' . 'scrolling="no" frameborder="0" allowTransparency="true" ' . 'style="border:none; overflow:hidden;" class="hikashop_social_fb_' . $classname . '"></iframe>';
     } else {
         foreach ($xfbml_options as $k => $v) {
             $url_options[] = 'data-' . $k . '="' . urlencode($v) . '"';
         }
         $html .= '<div class="fb-like" data-href="' . $url . '" ' . implode(' ', $url_options) . '></div>';
     }
     $html .= '</span>';
     $this->meta['property="og:title"'] = '<meta property="og:title" content="' . htmlspecialchars($element->name, ENT_COMPAT, 'UTF-8') . '"/> ';
     $types = array(0 => 'product', 1 => 'album', 2 => 'book', 3 => 'company', 4 => 'drink', 5 => 'game', 6 => 'movie', 7 => 'song');
     if (isset($types[(int) $plugin->params['fb_type']])) {
         $this->meta['property="og:type"'] = '<meta property="og:type" content="' . $types[(int) $plugin->params['fb_type']] . '"/> ';
     }
     $config =& hikashop_config();
     $uploadFolder = ltrim(JPath::clean(html_entity_decode($config->get('uploadfolder', 'media/com_hikashop/upload/'))), DS);
     $uploadFolder = rtrim($uploadFolder, DS) . DS;
     $this->uploadFolder_url = str_replace(DS, '/', $uploadFolder);
     $this->uploadFolder = JPATH_ROOT . DS . $uploadFolder;
     $this->thumbnail = $config->get('thumbnail', 1);
     $this->thumbnail_y = $config->get('product_image_y', $config->get('thumbnail_y'));
     $this->thumbnail_x = $config->get('product_image_x', $config->get('thumbnail_x'));
     $this->main_thumbnail_x = $this->thumbnail_x;
     $this->main_thumbnail_y = $this->thumbnail_y;
     $this->main_uploadFolder_url = $this->uploadFolder_url;
     $this->main_uploadFolder = $this->uploadFolder;
     $imageUrl = $this->_getImageURL($element);
     if (!empty($imageUrl)) {
         $this->meta['property="og:image"'] = '<meta property="og:image" content="' . $imageUrl . '" /> ';
     }
     $this->meta['property="og:url"'] = '<meta property="og:url" content="' . $url . '" />';
     $this->meta['property="og:description"'] = '<meta property="og:description" content="' . htmlspecialchars(strip_tags($element->description), ENT_COMPAT, 'UTF-8') . '"/> ';
     $jconf = JFactory::getConfig();
     if (HIKASHOP_J30) {
         $siteName = $jconf->get('sitename');
     } else {
         $siteName = $jconf->getValue('config.sitename');
     }
     $this->meta['property="og:site_name"'] = '<meta property="og:site_name" content="' . htmlspecialchars($siteName, ENT_COMPAT, 'UTF-8') . '"/> ';
     if (!empty($plugin->params['admin'])) {
         $this->meta['property="fb:admins"'] = '<meta property="fb:admins" content="' . htmlspecialchars($plugin->params['admin'], ENT_COMPAT, 'UTF-8') . '" />';
     }
     return $html;
 }
Пример #4
0
 function onProcessProductMassActionsetCanonical(&$elements, &$action, $k)
 {
     $db = JFactory::getDBO();
     $columns = array_keys(get_object_vars($elements[0]));
     preg_match_all('#{(.*)}#U', $action['value'], $matches);
     foreach ($elements as $element) {
         $element->product_canonical = $action['value'];
         foreach ($matches[1] as $k => $v) {
             if (!in_array($v, $columns)) {
                 continue;
             }
             $element->product_canonical = str_replace($matches[0][$k], $element->{$v}, $element->product_canonical);
         }
         if (!empty($element->product_canonical)) {
             $element->product_canonical = str_replace('/administrator', '', hikashop_cleanURL($element->product_canonical));
         }
         $db->setQuery('UPDATE ' . hikashop_table('product') . ' SET `product_canonical` = ' . $db->Quote($element->product_canonical) . ' WHERE product_id = ' . (int) $element->product_id);
         $db->query();
     }
 }
Пример #5
0
 function onSearch($text, $phrase = '', $ordering = '', $areas = null)
 {
     if (!defined('DS')) {
         define('DS', DIRECTORY_SEPARATOR);
     }
     if (!(include_once rtrim(JPATH_ADMINISTRATOR, DS) . DS . 'components' . DS . 'com_hikashop' . DS . 'helpers' . DS . 'helper.php')) {
         return array();
     }
     $db = JFactory::getDBO();
     if (is_array($areas)) {
         if (!array_intersect($areas, array_keys($this->onSearchAreas()))) {
             return array();
         }
     }
     $limit = $this->params->def('search_limit', 50);
     $text = trim($text);
     if ($text == '') {
         return array();
     }
     switch ($ordering) {
         case 'alpha':
             $order = 'a.product_name ASC';
             break;
         case 'newest':
             $order = 'a.product_modified DESC';
             break;
         case 'oldest':
             $order = 'a.product_created ASC';
             break;
         case 'popular':
             $order = 'a.product_hit DESC';
             break;
         case 'category':
         default:
             $order = 'a.product_name DESC';
             break;
     }
     $trans = hikashop_get('helper.translation');
     $multi = $trans->isMulti();
     $trans_table = 'jf_content';
     if ($trans->falang) {
         $trans_table = 'falang_content';
     }
     $rows = array();
     $filters = array('a.product_published=1');
     $variants = (int) $this->params->get('variants', '0');
     if (!$variants) {
         $filters[] = 'a.product_type=\'main\'';
     }
     $out_of_stock = (int) $this->params->get('out_of_stock_display', '1');
     if (!$out_of_stock) {
         $filters[] = 'a.product_quantity!=0';
     }
     hikashop_addACLFilters($filters, 'product_access', 'a');
     $leftjoin = '';
     $catFilters = array('category_published=1', 'category_type=\'product\'');
     hikashop_addACLFilters($catFilters, 'category_access');
     $db->setQuery('SELECT category_id FROM ' . hikashop_table('category') . ' WHERE ' . implode(' AND ', $catFilters));
     if (!HIKASHOP_J25) {
         $cats = $db->loadResultArray();
     } else {
         $cats = $db->loadColumn();
     }
     if (!empty($cats)) {
         $filters[] = 'b.category_id IN (' . implode(',', $cats) . ')';
     }
     if ($variants) {
         $leftjoin = ' INNER JOIN ' . hikashop_table('product_category') . ' AS b ON a.product_parent_id=b.product_id OR a.product_id=b.product_id';
     } else {
         $leftjoin = ' INNER JOIN ' . hikashop_table('product_category') . ' AS b ON a.product_id=b.product_id';
     }
     $filters2 = array();
     if ($multi) {
         $registry = JFactory::getConfig();
         if (!HIKASHOP_J25) {
             $code = $registry->getValue('config.jflang');
         } else {
             $code = $registry->get('language');
         }
         $lg = $trans->getId($code);
         $filters2[] = "b.reference_table='hikashop_product'";
         $filters2[] = "b.published=1";
         $filters2[] = 'b.language_id=' . $lg;
     }
     $fields = $this->params->get('fields', '');
     if (empty($fields)) {
         $fields = array('product_name', 'product_description');
     } else {
         $fields = explode(',', $fields);
     }
     switch ($phrase) {
         case 'exact':
             $text = $db->Quote('%' . hikashop_getEscaped($text, true) . '%', false);
             $filters1 = array();
             foreach ($fields as $f) {
                 $filters1[] = "a." . $f . " LIKE " . $text;
             }
             if ($multi) {
                 $filters2[] = "b.value LIKE " . $text;
             }
             break;
         case 'all':
         case 'any':
         default:
             $words = explode(' ', $text);
             $wordFilters = array();
             $subWordFiltersX = array();
             $wordFilters2 = array();
             foreach ($words as $word) {
                 $word = $db->Quote('%' . hikashop_getEscaped($word, true) . '%', false);
                 foreach ($fields as $i => $f) {
                     $subWordFiltersX[$i][] = "a." . $f . " LIKE " . $word;
                 }
                 if ($multi) {
                     $wordFilters2[] = "b.value LIKE " . $word;
                 }
             }
             foreach ($subWordFiltersX as $i => $subWordFilters) {
                 $wordFilters[$i] = '((' . implode($phrase == 'all' ? ') AND (' : ') OR (', $subWordFilters) . '))';
             }
             $filters[] = '((' . implode(') OR (', $wordFilters) . '))';
             if ($multi) {
                 $filters2[] = '((' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wordFilters2) . '))';
             }
             break;
     }
     $new_page = (int) $this->params->get('new_page', '1');
     $select = ' a.product_id AS id, a.product_name, a.product_alias, a.product_canonical, a.product_created AS created , a.product_description, "' . $new_page . '" AS browsernav';
     if ($variants) {
         $select .= ', a.product_type, a.product_parent_id';
     }
     $count = 0;
     if ($multi && !empty($lg)) {
         $db->setQuery('SET SQL_BIG_SELECTS=1');
         $db->query();
         $query = ' SELECT DISTINCT ' . $select . ' FROM ' . hikashop_table($trans_table, false) . ' AS b LEFT JOIN ' . hikashop_table('product') . ' AS a ON b.reference_id=a.product_id WHERE ' . implode(' AND ', $filters2) . ' ORDER BY ' . $order;
         $db->setQuery($query, 0, $limit);
         $rows = $db->loadObjectList("id");
         $count = count($rows);
         if ($count) {
             $limit = $limit - $count;
             $filters[] = 'a.product_id NOT IN (' . implode(',', array_keys($rows)) . ')';
         }
     }
     if ($limit) {
         if (!empty($leftjoin)) {
             $select .= ', b.category_id as category_id';
         }
         $db->setQuery('SET SQL_BIG_SELECTS=1');
         $db->query();
         $filters = implode(' AND ', $filters);
         if (isset($filters1)) {
             $filters = '(' . $filters . ') AND (' . implode(' OR ', $filters1) . ')';
         }
         $query = ' SELECT DISTINCT ' . $select . ' FROM ' . hikashop_table('product') . ' AS a ' . $leftjoin . ' WHERE ' . $filters . ' GROUP BY (a.product_id) ORDER BY ' . $order;
         $db->setQuery($query, 0, $limit);
         $mainRows = $db->loadObjectList("id");
         if (!empty($mainRows)) {
             foreach ($mainRows as $k => $main) {
                 $rows[$k] = $main;
             }
             $count = count($rows);
         }
     }
     if ($count) {
         if ($multi && !empty($lg)) {
             $query = ' SELECT * FROM ' . hikashop_table($trans_table, false) . ' WHERE reference_table=\'hikashop_product\' AND language_id=\'' . $lg . '\' AND published=1 AND reference_id IN (' . implode(',', array_keys($rows)) . ')';
             $db->setQuery($query);
             $trans = $db->loadObjectList();
             foreach ($trans as $item) {
                 foreach ($rows as $key => $row) {
                     if ($row->id == $item->reference_id) {
                         if ($item->reference_field == 'product_name') {
                             $row->product_name = $item->value;
                         } elseif ($item->reference_field == 'product_description') {
                             $row->product_description = $item->value;
                         } else {
                             $row->product_name = $item->value;
                         }
                         break;
                     }
                 }
             }
         }
         $parent = '';
         $item_id = $this->params->get('item_id', '');
         $menuClass = hikashop_get('class.menus');
         $config =& hikashop_config();
         $pathway_sef_name = $config->get('pathway_sef_name', 'category_pathway');
         $menus = array();
         $Itemid = '';
         if (!empty($item_id)) {
             $Itemid = '&Itemid=' . $item_id;
             if ($this->params->get('full_path', 1)) {
                 $menuData = $menus[$item_id] = $menuClass->get($item_id);
                 if (!empty($menuData->hikashop_params['selectparentlisting'])) {
                     $parent = '&' . $pathway_sef_name . '=' . (int) $menuData->hikashop_params['selectparentlisting'];
                 }
             }
         }
         $itemids = array();
         $app = JFactory::getApplication();
         $class = hikashop_get('class.product');
         $ids = array();
         foreach ($rows as $k => $row) {
             $ids[$row->id] = $row->id;
             if (!empty($row->category_id)) {
                 if (empty($item_id)) {
                     if (!isset($itemids[$row->category_id])) {
                         $itemids[$row->category_id] = $menuClass->getItemidFromCategory($row->category_id);
                     }
                     $item_id = $itemids[$row->category_id];
                 }
                 if (!empty($item_id)) {
                     $Itemid = '&Itemid=' . $item_id;
                 }
                 if ($this->params->get('full_path', 1)) {
                     $parent = '&' . $pathway_sef_name . '=' . (int) $row->category_id;
                 }
                 if (!$this->params->get('item_id', '')) {
                     $item_id = '';
                 }
             }
             $class->addAlias($row);
             $row->title = $row->product_name;
             $row->text = $row->product_description;
             if ($variants && $row->product_type == 'variant') {
                 $ids[$row->product_parent_id] = $row->product_parent_id;
                 static $mains = array();
                 if (!isset($mains[$row->product_parent_id])) {
                     $mains[$row->product_parent_id] = $class->get((int) $row->product_parent_id);
                     $class->addAlias($mains[$row->product_parent_id]);
                 }
                 $db = JFactory::getDBO();
                 $db->setQuery('SELECT * FROM ' . hikashop_table('variant') . ' AS a LEFT JOIN ' . hikashop_table('characteristic') . ' AS b ON a.variant_characteristic_id=b.characteristic_id WHERE a.variant_product_id=' . (int) $row->id . ' ORDER BY a.ordering');
                 $row->characteristics = $db->loadObjectList();
                 $class->checkVariant($row, $mains[$row->product_parent_id]);
                 if (empty($row->title)) {
                     $row->title = $row->product_name;
                 }
                 if (empty($row->text)) {
                     $row->text = $mains[$row->product_parent_id]->product_description;
                 }
             }
             if (empty($row->product_canonical)) {
                 $rows[$k]->href = JRoute::_('index.php?option=com_hikashop&ctrl=product&task=show&name=' . $row->alias . '&cid=' . $row->id . $Itemid . $parent);
             } else {
                 $rows[$k]->href = $row->product_canonical;
             }
             $rows[$k]->href = hikashop_cleanURL($rows[$k]->href);
             $rows[$k]->section = JText::_('PRODUCT');
         }
         if (!empty($ids)) {
             $imageHelper = hikashop_get('helper.image');
             $height = (int) $config->get('thumbnail_y', '100');
             $width = (int) $config->get('thumbnail_x', '100');
             $image_options = array('default' => true, 'forcesize' => $config->get('image_force_size', true), 'scale' => $config->get('image_scale_mode', 'inside'));
             $db = JFactory::getDBO();
             $queryImage = 'SELECT * FROM ' . hikashop_table('file') . ' WHERE file_ref_id IN (' . implode(',', $ids) . ') AND file_type=\'product\' ORDER BY file_ref_id ASC, file_ordering DESC, file_id ASC';
             $db->setQuery($queryImage);
             $images = $db->loadObjectList('file_ref_id');
             foreach ($rows as $k => $row) {
                 foreach ($images as $k2 => $image) {
                     if ($k == $k2) {
                         $result = $imageHelper->getThumbnail(@$image->file_path, array('width' => $width, 'height' => $height), $image_options);
                         if ($result->success) {
                             $rows[$k]->image = $result->url;
                         }
                         break;
                     }
                 }
                 if (!empty($rows[$k]->image)) {
                     continue;
                 }
                 if (!$variants) {
                     continue;
                 }
                 foreach ($images as $k2 => $image) {
                     if ($row->product_parent_id == $k2) {
                         $result = $imageHelper->getThumbnail(@$image->file_path, array('width' => $width, 'height' => $height), $image_options);
                         if ($result->success) {
                             $rows[$k]->image = $result->url;
                         }
                         break;
                     }
                 }
             }
         }
     }
     return $rows;
 }
Пример #6
0
		<?php 
        $chaine = "abcdefghijklmnpqrstuvwxy0123456789";
        srand((double) microtime() * 1000000);
        for ($i = 0; $i < 20; $i++) {
            $token .= $chaine[rand() % strlen($chaine)];
        }
        $tokenLink = '&link=' . $token;
        ?>
		if(linkDisplay)
			linkDisplay.value = "<?php 
        echo hikashop_cleanURL(hikashop_completeLink('cart&task=showcart&cart_id=' . $cart_id . '&cart_type=' . $cart_type . $url_itemid . $tokenLink));
        ?>
";
		if(linkDisplayText)
			linkDisplayText.innerHTML = "<?php 
        echo hikashop_cleanURL(hikashop_completeLink('cart&task=showcart&cart_id=' . $cart_id . '&cart_type=' . $cart_type . $url_itemid . $tokenLink));
        ?>
";
		link.style.display="table-row";
	} else{
		link.style.display="none";
	}
	link.focus();
}
</script>
	<input type="hidden" name="hikashop_wishlist_token" value="<?php 
        echo $token;
        ?>
"/>
<?php 
    }
Пример #7
0
<?php

/**
 * @package	HikaShop for Joomla!
 * @version	2.6.1
 * @author	hikashop.com
 * @copyright	(C) 2010-2016 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
if (!empty($this->canonical)) {
    $doc = JFactory::getDocument();
    $doc->addCustomTag('<link rel="canonical" href="' . hikashop_cleanURL($this->canonical) . '" />');
}
$classes = array();
if (!empty($this->categories)) {
    foreach ($this->categories as $category) {
        $classes[] = 'hikashop_product_of_category_' . $category->category_id;
    }
}
?>
<div id="hikashop_product_<?php 
echo preg_replace('#[^a-z0-9]#i', '_', @$this->element->product_code);
?>
_page" class="hikashop_product_page <?php 
echo implode(' ', $classes);
?>
">
<?php 
$app = JFactory::getApplication();
if (empty($this->element)) {
        $_SESSION['hikashop_product'] = $product;
        if ($this->border == 1) {
            echo '<div class="hikashop_subcontainer hikashop_subcontainer_border">';
        }
        $productClass->addAlias($product);
        $url_itemid = '';
        if (!empty($custom_itemid)) {
            $url_itemid = '&Itemid=' . (int) $custom_itemid;
        } elseif (!empty($Itemid)) {
            $url_itemid = '&Itemid=' . (int) $Itemid;
        } elseif ($this->menuid != 0) {
            $url_itemid = '&Itemid=' . (int) $this->menuid;
        }
        $link = hikashop_contentLink('product&task=show&cid=' . $product->product_id . '&name=' . $product->alias . $url_itemid, $product);
        if (!empty($product->product_canonical)) {
            $link = hikashop_cleanURL($product->product_canonical);
        }
        if ($this->picture == 1) {
            ?>
			<!-- PRODUCT IMG -->
			<div style="position:relative;text-align:center;clear:both;width:200px;margin: auto;" class="hikashop_product_image">
				<?php 
            if ($this->link == 1) {
                ?>
						<a href="<?php 
                echo $link;
                ?>
" title="<?php 
                echo $this->escape($product->product_name);
                ?>
">
Пример #9
0
 function generateXML()
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDBO();
     $pluginsClass = hikashop_get('class.plugins');
     $plugin = $pluginsClass->getByName('hikashop', 'google_products');
     if (empty($plugin->params['condition'])) {
         $plugin->params['condition'] = "new";
     }
     if (@$plugin->params['increase_perf']) {
         $memory = '128M';
         $max_execution = '120';
         if ($plugin->params['increase_perf'] == 2) {
             $memory = '512M';
             $max_execution = '600';
         } elseif ($plugin->params['increase_perf'] == 3) {
             $memory = '1024M';
             $max_execution = '6000';
         } elseif ($plugin->params['increase_perf'] == 10) {
             $memory = '4096M';
             $max_execution = '0';
         }
         ini_set('memory_limit', $memory);
         ini_set('max_execution_timeout', $max_execution);
     }
     $query = 'SELECT * FROM ' . hikashop_table('product') . ' WHERE product_access=\'all\' AND product_published=1 AND product_type=\'main\'';
     if (!empty($plugin->params['in_stock_only'])) {
         $query .= ' AND product_quantity!=0';
     }
     $db->setQuery($query);
     $products = $db->loadObjectList();
     if (empty($products)) {
         return true;
     }
     $ids = array();
     foreach ($products as $key => $row) {
         $ids[] = $row->product_id;
         $products[$key]->alias = JFilterOutput::stringURLSafe($row->product_name);
     }
     $queryCategoryId = 'SELECT * FROM ' . hikashop_table('product_category') . ' WHERE product_id IN (' . implode(',', $ids) . ')';
     $db->setQuery($queryCategoryId);
     $categoriesId = $db->loadObjectList();
     foreach ($products as $k => $row) {
         foreach ($categoriesId as $catId) {
             if ($row->product_id == $catId->product_id) {
                 $products[$k]->categories_id[] = $catId->category_id;
             }
         }
     }
     $usedCat = array();
     $catList = "";
     foreach ($products as $product) {
         if (!empty($product->categories_id)) {
             foreach ($product->categories_id as $catId) {
                 if (!isset($usedCat[$catId])) {
                     $usedCat[$catId] = $catId;
                     $catList .= $catId . ',';
                 }
             }
         }
     }
     $catList = substr($catList, 0, -1);
     $parentCatId = 'product';
     $categoryClass = hikashop_get('class.category');
     $categoryClass->getMainElement($parentCatId);
     $query = 'SELECT DISTINCT b.* FROM ' . hikashop_table('category') . ' AS a LEFT JOIN ' . hikashop_table('category') . ' AS b ON a.category_left >= b.category_left WHERE ' . 'b.category_right >= a.category_right AND a.category_id IN (' . $catList . ') AND a.category_published=1 AND a.category_type=\'product\' AND b.category_id!=' . $parentCatId . ' ' . 'ORDER BY b.category_left';
     $db->setQuery($query);
     $categories = $db->loadObjectList();
     $category_path = array();
     $discard_products_without_valid_categories = array();
     foreach ($products as $k => $product) {
         if (empty($product->categories_id)) {
             $discard_products_without_valid_categories[] = $k;
         } else {
             $path = array();
             $at_least_a_category_valid = false;
             foreach ($categories as $category) {
                 foreach ($product->categories_id as $catID) {
                     if ($catID == $category->category_id) {
                         $at_least_a_category_valid = true;
                         if (!isset($category_path[$catID])) {
                             $category_path[$catID] = $this->_getCategoryParent($category, $categories, $path, $parentCatId);
                         }
                     }
                 }
             }
             if (!$at_least_a_category_valid) {
                 $discard_products_without_valid_categories[] = $k;
             }
         }
     }
     if (!empty($discard_products_without_valid_categories)) {
         foreach ($discard_products_without_valid_categories as $k) {
             unset($products[$k]);
         }
     }
     foreach ($category_path as $id => $mainCat) {
         $path = '';
         for ($i = count($mainCat); $i > 0; $i--) {
             $path .= $mainCat[$i - 1]->category_name . ' > ';
         }
         $category_path[$id]['path'] = substr($path, 0, -3);
     }
     $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();
     $products[$k]->images = array();
     foreach ($products as $k => $row) {
         $i = 0;
         foreach ($images as $image) {
             if ($row->product_id == $image->file_ref_id) {
                 $products[$k]->images[$i] = new stdClass();
                 foreach (get_object_vars($image) as $key => $name) {
                     $products[$k]->images[$i]->{$key} = $name;
                 }
             }
             $i++;
         }
     }
     $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;
                 }
             }
         }
     }
     $zone_id = hikashop_getZone();
     $currencyClass = hikashop_get('class.currency');
     $config =& hikashop_config();
     $main_currency = (int) $config->get('main_currency', 1);
     if (empty($plugin->params['price_displayed'])) {
         $plugin->params['price_displayed'] = 'cheapest';
     }
     if ($plugin->params['price_displayed'] == 'cheapest') {
         $currencyClass->getListingPrices($products, $zone_id, $main_currency, 'cheapest');
     }
     if ($plugin->params['price_displayed'] == 'unit') {
         $currencyClass->getListingPrices($products, $zone_id, $main_currency, 'unit');
     }
     if ($plugin->params['price_displayed'] == 'average') {
         $currencyClass->getListingPrices($products, $zone_id, $main_currency, 'range');
         $tmpPrice = 0;
         $tmpTaxPrice = 0;
         foreach ($products as $product) {
             if (isset($product->prices[0]->price_value)) {
                 if (count($product->prices) > 1) {
                     for ($i = 0; $i < count($product->prices); $i++) {
                         if ($product->prices[$i]->price_value > $tmpPrice) {
                             $tmpPrice += $product->prices[$i]->price_value;
                             $tmpTaxPrice += @$product->prices[$i]->price_value_with_tax;
                         }
                     }
                     $product->prices[0]->price_value = $tmpPrice / count($product->prices);
                     $product->prices[0]->price_value_with_tax = $tmpTaxPrice / count($product->prices);
                     for ($i = 1; $i < count($product->prices); $i++) {
                         unset($product->prices[$i]);
                     }
                 }
             }
         }
     }
     if ($plugin->params['price_displayed'] == 'expensive') {
         $currencyClass->getListingPrices($products, $zone_id, $main_currency, 'range');
         $tmpPrice = 0;
         foreach ($products as $product) {
             if (isset($product->prices[0]->price_value)) {
                 if (count($product->prices) > 1) {
                     for ($i = 0; $i < count($product->prices); $i++) {
                         if ($product->prices[$i]->price_value > $tmpPrice) {
                             $tmpPrice = $product->prices[$i]->price_value;
                             $key = $i;
                         }
                     }
                     $product->prices[0] = $product->prices[$key];
                     for ($i = 1; $i < count($product->prices); $i++) {
                         unset($product->prices[$i]);
                     }
                 }
             }
         }
     }
     if (!empty($plugin->params['use_brand'])) {
         $parentCatId = 'manufacturer';
         $categoryClass->getMainElement($parentCatId);
         $query = 'SELECT DISTINCT * FROM ' . hikashop_table('category') . ' AS a WHERE a.category_published=1 AND a.category_type=\'manufacturer\' AND a.category_parent_id=' . $parentCatId;
         $db->setQuery($query);
         $brands = $db->loadObjectList('category_id');
     }
     $config =& hikashop_config();
     $uploadFolder = ltrim(JPath::clean(html_entity_decode($config->get('uploadfolder'))), DS);
     $uploadFolder = rtrim($uploadFolder, DS) . DS;
     $this->uploadFolder_url = str_replace(DS, '/', $uploadFolder);
     $this->uploadFolder = JPATH_ROOT . DS . $uploadFolder;
     $app = JFactory::getApplication();
     $this->thumbnail = $config->get('thumbnail', 1);
     $this->thumbnail_x = $config->get('thumbnail_x', 100);
     $this->thumbnail_y = $config->get('thumbnail_y', 100);
     $this->main_thumbnail_x = $this->thumbnail_x;
     $this->main_thumbnail_y = $this->thumbnail_y;
     $this->main_uploadFolder_url = $this->uploadFolder_url;
     $this->main_uploadFolder = $this->uploadFolder;
     $conf = JFactory::getConfig();
     if (!HIKASHOP_J30) {
         $siteName = $conf->getValue('config.sitename');
         $siteDesc = $conf->getValue('config.MetaDesc');
     } else {
         $siteName = $conf->get('sitename');
         $siteDesc = $conf->get('MetaDesc');
     }
     $siteAddress = JURI::base();
     $siteAddress = str_replace('administrator/', '', $siteAddress);
     $xml = '<?xml version="1.0" encoding="UTF-8" ?>' . "\n" . '<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">' . "\n" . "\t" . '<channel>' . "\n" . "\t\t" . '<title><![CDATA[ ' . $siteName . ' ]]></title>' . "\n" . "\t\t" . '<description><![CDATA[ ' . $siteDesc . ' ]]></description>' . "\n" . "\t\t" . '<link><![CDATA[ ' . $siteAddress . ' ]]></link>' . "\n" . "\n";
     $productClass = hikashop_get('class.product');
     foreach ($products as $product) {
         if (isset($product->prices[0]->price_value)) {
             $price_name = 'price_value';
             if (!empty($plugin->params['taxed_price'])) {
                 $price_name = 'price_value_with_tax';
             }
             if (empty($product->product_min_per_order)) {
                 $price = round($product->prices[0]->{$price_name}, 2);
             } else {
                 $price = round($product->prices[0]->{$price_name}, 2) * $product->product_min_per_order;
             }
             $currencies = array();
             $currencyClass = hikashop_get('class.currency');
             $ids[$product->prices[0]->price_currency_id] = $product->prices[0]->price_currency_id;
             $currencies = $currencyClass->getCurrencies($ids[$product->prices[0]->price_currency_id], $currencies);
             $currency = reset($currencies);
             $xml .= '<item>' . "\n";
             $productClass->addAlias($product);
             if ($product->product_weight_unit == 'mg') {
                 $product->product_weight = $product->product_weight * 1000;
                 $product->product_weight_unit = 'g';
             }
             $xml .= "\t" . '<g:id>' . $product->product_id . '</g:id>' . "\n";
             $xml .= "\t" . '<title><![CDATA[ ' . $product->product_name . ' ]]></title>' . "\n";
             $itemID = '';
             if (!empty($plugin->params['item_id'])) {
                 $itemID = '&Itemid=' . $plugin->params['item_id'];
             }
             if (!empty($product->product_canonical)) {
                 $xml .= "\t" . '<g:link><![CDATA[ ' . str_replace('/administrator/', '/', hikashop_cleanURL($product->product_canonical)) . ' ]]></g:link>' . "\n";
             } else {
                 $xml .= "\t" . '<g:link><![CDATA[ ' . $siteAddress . 'index.php?option=com_hikashop&ctrl=product&task=show&cid=' . $product->product_id . '&name=' . $product->alias . $itemID . ' ]]></g:link>' . "\n";
             }
             $xml .= "\t" . '<g:price>' . $price . ' ' . $currency->currency_code . '</g:price>' . "\n";
             if (!empty($product->product_description)) {
                 if (@$plugin->params['preview']) {
                     $xml .= "\t" . '<g:description><![CDATA[ ' . strip_tags(preg_replace('#<hr *id="system-readmore" */>.*#is', '', $product->product_description)) . ' ]]></g:description>' . "\n";
                 } else {
                     $xml .= "\t" . '<g:description><![CDATA[ ' . strip_tags($product->product_description) . ' ]]></g:description>' . "\n";
                 }
             } elseif (!empty($plugin->params['message'])) {
                 $xml .= "\t" . '<g:description><![CDATA[ ' . $plugin->params['message'] . ' ]]></g:description>' . "\n";
             } else {
                 $xml .= "\t" . '<g:description>No description</g:description>' . "\n";
             }
             $xml .= $this->_additionalParameter($product, $plugin, 'condition', 'condition');
             $xml .= $this->_additionalParameter($product, $plugin, 'gender', 'gender');
             $xml .= $this->_additionalParameter($product, $plugin, 'gtin', 'gtin');
             $xml .= $this->_additionalParameter($product, $plugin, 'age_group', 'age_group');
             $xml .= $this->_additionalParameter($product, $plugin, 'size', 'size');
             $xml .= $this->_additionalParameter($product, $plugin, 'color', 'color');
             $xml .= $this->_additionalParameter($product, $plugin, 'identifier_exists', 'identifier_exists');
             $xml .= $this->_addShipping($product, $plugin);
             if (!empty($plugin->params['use_brand']) && !empty($brands[$product->product_manufacturer_id]->category_name)) {
                 $xml .= "\t" . '<g:brand><![CDATA[ ' . $brands[$product->product_manufacturer_id]->category_name . ' ]]></g:brand>' . "\n";
             } else {
                 $xml .= $this->_additionalParameter($product, $plugin, 'brand', 'brand');
             }
             $xml .= $this->_additionalParameter($product, $plugin, 'category', 'google_product_category');
             if ($plugin->params['add_code']) {
                 $xml .= "\t" . '<g:mpn><![CDATA[ ' . str_replace(array(' ', '-'), array('', ''), $product->product_code) . ' ]]></g:mpn>' . "\n";
             }
             if (isset($product->images) && count($product->images)) {
                 $i = 0;
                 $name = "image_link";
                 foreach ($product->images as $image) {
                     if ($i < 10) {
                         $xml .= "\t" . '<g:' . $name . '>' . htmlspecialchars($siteAddress . $this->main_uploadFolder_url . $image->file_path) . '</g:' . $name . '>' . "\n";
                         $name = "additional_image_link";
                         $i++;
                     }
                 }
             }
             $type = '';
             foreach ($product->categories_id as $catID) {
                 foreach ($category_path as $id => $catPath) {
                     if ($id == $catID) {
                         if (strlen($type . '"' . $catPath['path'] . '",') > 750) {
                             continue;
                         }
                         $type .= '"' . $catPath['path'] . '",';
                     }
                 }
             }
             if (!empty($type)) {
                 $type = substr($type, 0, -1);
                 $xml .= "\t" . '<g:product_type><![CDATA[ ' . $type . ' ]]></g:product_type>' . "\n";
             }
             if ($product->product_quantity != -1) {
                 $xml .= "\t" . '<g:quantity>' . $product->product_quantity . '</g:quantity>' . "\n";
             }
             if ($product->product_quantity == 0) {
                 $xml .= "\t" . '<g:availability>out of stock</g:availability>' . "\n";
             } else {
                 $xml .= "\t" . '<g:availability>in stock</g:availability>' . "\n";
             }
             $xml .= "\t" . '<g:shipping_weight>' . (double) hikashop_toFloat($product->product_weight) . ' ' . $product->product_weight_unit . '</g:shipping_weight>' . "\n";
             $xml .= '</item>' . "\n";
         }
     }
     $xml .= '</channel>' . "\n" . '</rss>' . "\n";
     return $xml;
 }