예제 #1
0
    /**
     * Override function getCategories in model Category
     */
    public static function getCategories($onlyPublished = true, $parentId = false, $childId = false, $keyword = "", $vendorId = false)
    {
        $categoryModel = VmModel::getModel('Category');
        $select = ' c.`virtuemart_category_id`, l.`category_description`, l.`category_name`, c.`ordering`, c.`published`, cx.`category_child_id`, cx.`category_parent_id`, c.`shared` ';
        $joinedTables = ' FROM `#__virtuemart_categories_' . VmConfig::$vmlang . '` l
				  JOIN `#__virtuemart_categories` AS c using (`virtuemart_category_id`)
				  LEFT JOIN `#__virtuemart_category_categories` AS cx
				  ON l.`virtuemart_category_id` = cx.`category_child_id` ';
        $where = array();
        if ($onlyPublished) {
            $where[] = " c.`published` = 1 ";
        }
        if ($parentId !== false) {
            $where[] = ' cx.`category_parent_id` = ' . (int) $parentId;
        }
        if ($childId !== false) {
            $where[] = ' cx.`category_child_id` = ' . (int) $childId;
        }
        if ($vendorId === false) {
            $vendorId = VmConfig::isSuperVendor();
        }
        if ($vendorId == 1) {
            $where[] = ' (c.`virtuemart_vendor_id` = "' . (int) $vendorId . '" OR c.`shared` = "1") ';
        }
        if (!empty($keyword)) {
            $db = JFactory::getDBO();
            $keyword = '"%' . $db->escape($keyword, true) . '%"';
            //$keyword = $db->Quote($keyword, false);
            $where[] = ' ( l.`category_name` LIKE ' . $keyword . '
							   OR l.`category_description` LIKE ' . $keyword . ') ';
        }
        $whereString = '';
        if (count($where) > 0) {
            $whereString = ' WHERE ' . implode(' AND ', $where);
        } else {
            $whereString = 'WHERE 1 ';
        }
        $ordering = $categoryModel->_getOrdering();
        self::$_category_tree = $categoryModel->exeSortSearchListQuery(0, $select, $joinedTables, $whereString, 'GROUP BY virtuemart_category_id', $ordering);
        return self::$_category_tree;
    }
예제 #2
0
 * @author YouTech Company http://www.smartaddons.com
 *
 */
defined('_JEXEC') or die;
if (!defined('DS')) {
    define('DS', DIRECTORY_SEPARATOR);
}
require_once dirname(__FILE__) . '/core/helper.php';
$layout = $params->get('layout', 'default');
$list = VmAjaxtabsHelper::getList($params, $module);
if (!empty($list)) {
    $is_ajax_request = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
    $is_ajax_request = $is_ajax_request || JRequest::getInt('sj_module_ajax_request', 0);
    if ($is_ajax_request) {
        $category_id = JRequest::getVar('sj_category_id', null);
        $sj_module_id = JRequest::getVar('sj_module_id', null);
        $sj_module = JRequest::getVar('sj_module', null);
        if ($sj_module == $module->module && $sj_module_id == $module->id) {
            $category_items = VmAjaxtabsHelper::_getProductInfor($category_id, $params);
            ob_start();
            include JModuleHelper::getLayoutPath($module->module, $layout . '_items');
            $ajax_respond = ob_get_contents();
            ob_end_clean();
            die($ajax_respond);
        }
    } else {
        require JModuleHelper::getLayoutPath($module->module, $layout);
    }
} else {
    echo JText::_('Has no content to show!');
}