コード例 #1
0
function xtc_product_link($pID, $name = '')
{
    #Check for current category link
    $c_path = $_SERVER['QUERY_STRING'];
    if (strpos($c_path, 'cPath') !== false) {
        $category_path = substr($c_path, strpos($c_path, '=') + 1);
        $categorie_previous = end(explode('_', $category_path));
        $cat_children = array();
        $cat_children = xtc_get_categories_children($categorie_previous);
        foreach ($cat_children as $linked_cat) {
            $category_query_check = "select p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = '" . (int) $pID . "' and p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id != 0 and p2c.categories_id = '" . $linked_cat . "'";
            $category_query_check = xtDBquery($category_query_check);
            if (xtc_db_num_rows($category_query_check, true)) {
                $cID = xtc_db_fetch_array($category_query_check)['categories_id'];
                break;
            }
        }
    }
    #Take default categorie id
    if (!isset($cID)) {
        $category_query = "select p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = '" . (int) $pID . "' and p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id != 0";
        $category_query = xtDBquery($category_query);
        if (xtc_db_num_rows($category_query, true)) {
            $cID = xtc_db_fetch_array($category_query)['categories_id'];
        }
    }
    #Create category path from category ID
    $categories = array();
    xtc_get_parent_categories($categories, $cID);
    $categories = array_reverse($categories);
    $categories[] = $cID;
    $cPath = implode('_', $categories);
    return 'products_id=' . $pID . '&cPath=' . $cPath;
}
コード例 #2
0
function xtc_get_product_path($products_id)
{
    $cPath = '';
    $category_query = "select p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = '" . (int) $products_id . "' and p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id != 0";
    $category_query = xtDBquery($category_query);
    if (xtc_db_num_rows($category_query, true)) {
        #Default category( first picked from table)
        $category = xtc_db_fetch_array($category_query);
        $p_path_full = $_SERVER['REQUEST_URI'];
        $p_path = $_SERVER['QUERY_STRING'];
        #If we display product check linked categories
        if (strpos($p_path, 'products_id') !== false) {
            while ($categoryies = xtc_db_fetch_array($category_query)) {
                $cat_name = xtc_get_categories_name($categoryies['categories_id']);
                $cat_name_slug = shopstat_hrefSmallmask($cat_name);
                $p_path_full_array = explode('/', $p_path_full);
                if ($p_path_full_array[count($p_path_full_array) - 2] === $cat_name_slug) {
                    $category = $categoryies;
                    break;
                }
            }
        }
        # Check if current categorie or its children have linked product
        $c_path = $_SERVER['QUERY_STRING'];
        if (strpos($c_path, 'cPath') !== false) {
            $category_path = substr($c_path, strpos($c_path, '=') + 1);
            $categorie_previous = end(explode('_', $category_path));
            $cat_children = array();
            $cat_children = xtc_get_categories_children($categorie_previous);
            foreach ($cat_children as $linked_cat) {
                $category_query_check = "select p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = '" . (int) $products_id . "' and p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id != 0 and p2c.categories_id = '" . $linked_cat . "'";
                $category_query_check = xtDBquery($category_query_check);
                if (xtc_db_num_rows($category_query_check, true)) {
                    $category = xtc_db_fetch_array($category_query_check);
                    break;
                }
            }
        }
        $categories = array();
        xtc_get_parent_categories($categories, $category['categories_id']);
        $categories = array_reverse($categories);
        $cPath = implode('_', $categories);
        if (xtc_not_null($cPath)) {
            $cPath .= '_';
        }
        $cPath .= $category['categories_id'];
    }
    //BOF - Dokuman - 2009-10-02 - removed feature, due to wrong links in category on "last viewed"
    /*
      if($_SESSION['lastpath']!=''){
        $cPath = $_SESSION['lastpath'];
      }
    */
    //EOF - Dokuman - 2009-10-02 - removed feature, due to wrong links in category on "last viewed"
    return $cPath;
}
コード例 #3
0
function xtc_get_parent_categories(&$categories, $categories_id)
{
    $parent_categories_query = "select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . xtc_db_input((int) $categories_id) . "'";
    $parent_categories_query = xtDBquery($parent_categories_query);
    while ($parent_categories = xtc_db_fetch_array($parent_categories_query, true)) {
        if ($parent_categories['parent_id'] == 0) {
            return true;
        }
        $categories[sizeof($categories)] = $parent_categories['parent_id'];
        if ($parent_categories['parent_id'] != $categories_id) {
            xtc_get_parent_categories($categories, $parent_categories['parent_id']);
        }
    }
}
コード例 #4
0
function xtc_get_category_path($cID)
{
    $cPath = '';
    $category = $cID;
    $categories = array();
    xtc_get_parent_categories($categories, $cID);
    $categories = array_reverse($categories);
    $cPath = implode('_', $categories);
    if (xtc_not_null($cPath)) {
        $cPath .= '_';
    }
    $cPath .= $cID;
    return $cPath;
}
function xtc_get_product_original_path($products_id)
{
    $cPath = '';
    $category_query = "select p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = '" . (int) $products_id . "' and p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id != 0 limit 1";
    $category_query = xtDBquery($category_query);
    if (xtc_db_num_rows($category_query, true)) {
        $category = xtc_db_fetch_array($category_query);
        $categories = array();
        xtc_get_parent_categories($categories, $category['categories_id']);
        $categories = array_reverse($categories);
        $cPath = implode('_', $categories);
        if (xtc_not_null($cPath)) {
            $cPath .= '_';
        }
        $cPath .= $category['categories_id'];
    }
    return $cPath;
}