<?php
/**
 * @package SJ Categories Full for Hikashop
 * @version 1.0.0
 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @copyright (c) 2014 YouTech Company. All Rights Reserved.
 * @author YouTech Company http://www.smartaddons.com
 *
 */

defined('_JEXEC') or die;

$small_image_config = array(
'type' => $params->get('imgcfg_width') ? $params->get('imgcfg_type') : null,
'width' => $params->get('imgcfg_width'),
'height' => $params->get('imgcfg_height'),
'quality' => 90,
'function' => ($params->get('imgcfg_function') == 'none') ? null : 'resize',
'function_mode' => ($params->get('imgcfg_function') == 'none') ? null : substr($params->get('imgcfg_function'), 7),
'transparency' => $params->get('imgcfg_transparency', 1) ? true : false,
'background' => $params->get('imgcfg_background')
);

$subcategories = isset($items->child) ? $items->child : array();
$category_image = HKCategoriesFullHelper::getCHKImage($items, $params, 'imgcfgcat');
$category_title = isset($items->title) ? $items->title : $items->category_name;
$category_link = isset($items->link) ? $items->link : '#';
?>

<div class="cf-items cf-subcategories">
<?php if ($category_image) { ?>
	<div class="cf-subcat-image">
		<a href="<?php echo $category_link; ?>" title="<?php echo htmlspecialchars($category_title, ENT_QUOTES, 'UTF-8'); ?>">
			<?php echo HKCategoriesFullHelper::imageTag($category_image, $small_image_config); ?>
		</a>
	</div>
<?php } ?>    
	<div class="cf-subcat-header">
		<h3 class="cf-subcat-title">
			<a href="<?php echo $category_link; ?>" title="<?php echo htmlspecialchars($category_title, ENT_QUOTES, 'UTF-8'); ?>">
				<?php echo htmlspecialchars($category_title, ENT_QUOTES, 'UTF-8'); ?>
			</a>
		</h3>
	</div>

	<div class="cf-subcat-list">
<?php if (!empty($subcategories)) { ?>
<ul>
<?php foreach ($subcategories as $subcategory) { ?>
<li>
<a href="<?php echo $subcategory->link; ?>" title="<?php echo htmlspecialchars($subcategory->title, ENT_QUOTES, 'UTF-8'); ?>">
<?php echo htmlspecialchars($subcategory->title, ENT_QUOTES, 'UTF-8'); ?>
</a>
</li>
<?php } ?>
</ul>
<?php } else { ?>
<div class="cf-no-subcategories"><?php echo \Joomla\CMS\Language\Text::_('MOD_SJ_HK_CATEGORIES_FULL_NO_SUBCATS'); ?></div>
<?php } ?>
</div>
</div>
