Пример #1
0
function get_category_tree($parent_id = '0', $spacing = EMPTY_STRING, $exclude = EMPTY_STRING, $category_tree_array = EMPTY_STRING, $include_itself = false, $cPath = EMPTY_STRING)
{
    if ($parent_id == 0) {
        $cPath = EMPTY_STRING;
    } else {
        $cPath .= $parent_id . '_';
    }
    if (!is_array($category_tree_array)) {
        $category_tree_array = array();
    }
    if (sizeof($category_tree_array) < 1 && $exclude != '0') {
        $category_tree_array[] = array('id' => '0', 'text' => TEXT_TOP);
    }
    if ($include_itself) {
        $category_query = olc_db_query("\n\t\t\tselect cd.categories_name\n\t\t\tfrom " . TABLE_CATEGORIES_DESCRIPTION . " cd\n\t\t\tWHERE c.categories_status = '1' AND cd.language_id = '" . SESSION_LANGUAGE_ID . "'\n\t\t\tand cd.categories_id = '" . $parent_id . APOS);
        $category = olc_db_fetch_array($category_query);
        $category_tree_array[] = array('id' => $parent_id, 'text' => $category['categories_name']);
    }
    $categories_query = olc_db_query("\n\t\tselect\n\t\tc.categories_id,\n\t\tcd.categories_name,\n\t\tc.parent_id\n\t\tfrom " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd\n\t\twhere c.categories_id = cd.categories_id\n\t\tand cd.language_id = '" . SESSION_LANGUAGE_ID . "'\n\t\tand c.parent_id = '" . $parent_id . "'\n\t\tand c.categories_status = '1'\n\t\torder by c.sort_order, cd.categories_name");
    while ($categories = olc_db_fetch_array($categories_query)) {
        $categories_id = $categories['categories_id'];
        if ($exclude != $categories_id) {
            $category_tree_array[] = array('id' => $categories_id, 'text' => $spacing . $categories['categories_name'], 'link' => olc_href_link(FILENAME_DEFAULT, 'cPath=' . $cPath . $categories_id, NONSSL, false, true, false), 'pcount' => olc_count_products_in_category($categories_id));
            $category_tree_array = get_category_tree($categories_id, $spacing . '&nbsp;&nbsp;&nbsp;', $exclude, $category_tree_array, false, $cPath);
        }
    }
    return $category_tree_array;
}
function olc_show_category($counter, $img = '')
{
    global $foo, $categories_string, $id;
    $current_entry = $foo[$counter];
    if ($current_entry['parent'] == 0) {
        $cPath_new = $counter;
    } else {
        $cPath_new = $current_entry['path'];
    }
    $cPath_new = 'cPath=' . $cPath_new;
    $two_blank = HTML_NBSP . HTML_NBSP;
    for ($a = 0; $a < $current_entry['level']; $a++) {
        $indent = $two_blank;
    }
    $link = olc_href_link(FILENAME_DEFAULT, $cPath_new);
    $link = HTML_A_START . $link . '"  title="' . $current_entry['title'] . '">';
    $make_bold = $id && in_array($counter, $id);
    if ($make_bold) {
        $link .= HTML_B_START;
    }
    // display category name
    $link .= $current_entry['name'];
    if ($make_bold) {
        $link .= HTML_B_END;
    }
    $link .= HTML_A_END;
    if (SHOW_COUNTS == TRUE_STRING_S) {
        $products_in_category = olc_count_products_in_category($counter, false);
        if ($products_in_category > 0) {
            $link .= HTML_NBSP . ltrim(LPAREN) . $products_in_category . RPAREN;
        }
    }
    if (strlen($categories_string) > 0) {
        $categories_string .= HTML_BR;
    }
    $categories_string .= $indent . $img . $link;
    $file = CURRENT_TEMPLATE_IMG . 'img_underline.gif';
    if (is_file(DIR_FS_CATALOG . $file)) {
        $categories_string .= HTML_BR . olc_image($file);
    }
    $next_id = $current_entry['next_id'];
    if ($next_id) {
        olc_show_category($next_id, $img);
    }
}
Пример #3
0
function olc_count_products_in_category($category_id, $include_inactive = false)
{
    $products_count = 0;
    if (SHOW_COUNTS == TRUE_STRING_S) {
        if (!$include_inactive) {
            $products_status = "\n\t\tp.products_status = '1' and\n";
        }
        $products_query = olc_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c\n\t\twhere\t" . $products_status . "\n\t\tp.products_id = p2c.products_id and\n\t\tp2c.categories_id = '" . $category_id . APOS);
        $products = olc_db_fetch_array($products_query);
        $products_count += $products['total'];
        $child_categories_query = olc_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . $category_id . APOS);
        if (olc_db_num_rows($child_categories_query)) {
            while ($child_categories = olc_db_fetch_array($child_categories_query)) {
                $products_count += olc_count_products_in_category($child_categories['categories_id'], $include_inactive);
            }
        }
    }
    return $products_count;
}
Пример #4
0
function olc_show_category_content($counter)
{
    global $foo, $categories_string, $id;
    for ($a = 0; $a < $foo[$counter]['level']; $a++) {
        $categories_string .= "&nbsp;&nbsp;";
    }
    $categories_string .= HTML_A_START;
    if ($foo[$counter]['parent'] == 0) {
        $cPath = $counter;
    } else {
        $cPath = $foo[$counter]['path'];
    }
    $cPath_new = 'cPath=' . $cPath;
    $categories_string .= olc_href_link(FILENAME_DEFAULT, $cPath_new) . '">';
    if ($id && in_array($counter, $id)) {
        $categories_string .= HTML_B_START;
    }
    // display category name
    $categories_string .= $foo[$counter]['name'];
    if ($id && in_array($counter, $id)) {
        $categories_string .= HTML_B_END;
    }
    if (olc_has_category_subcategories($counter)) {
        $categories_string .= '-&gt;';
    }
    $categories_string .= HTML_A_END;
    if (SHOW_COUNTS == TRUE_STRING_S) {
        $products_in_category = olc_count_products_in_category($counter);
        if ($products_in_category > 0) {
            $categories_string .= '&nbsp;(' . $products_in_category . RPAREN;
        }
    }
    $categories_string .= HTML_BR;
    if ($foo[$counter]['next_id']) {
        olc_show_category_content($foo[$counter]['next_id']);
    }
}
Пример #5
0
function tep_count_products_in_category($category_id, $include_inactive = false)
{
    return olc_count_products_in_category($category_id, $include_inactive);
}
function print_menu_line($menu_entries, $depth_size, $depth_parentid, $depth, &$top_level_items)
{
    global $html_blank, $html_break, $html_two_blanks, $menu_image;
    global $menu_start, $top_text, $sub_text, $sep, $two_sep, $sep_top_text;
    $size = 0;
    for ($i = 0; $depth_size[$i] != 0; $i++) {
        $size++;
    }
    $size1 = $size - 1;
    $depth_size_0 = $depth_size[0];
    $menu = $menu_start;
    if ($depth == 0) {
        $menu .= $top_text . $depth_size_0 . $two_sep;
        $top_level_items++;
    } else {
        if ($depth == 1) {
            $menu .= $sub_text . $depth_size_0 . UNDERSCORE . $depth_size[1] . $sep_top_text . $depth_size_0 . $sep;
        } else {
            $menu .= $sub_text;
            for ($i = 0; $i < $size; $i++) {
                $menu .= $depth_size[$i] != 0 ? UNDERSCORE . $depth_size[$i] : UNDERSCORE;
            }
            $menu .= $sep_sub_text;
            for ($i = 0; $i < $size1; $i++) {
                $menu .= $depth_size[$i] != 0 ? UNDERSCORE . $depth_size[$i] : UNDERSCORE;
            }
            $menu .= $sep;
        }
    }
    $menu .= $menu_image . $menu_entries['text'];
    //Add leading menu image
    if (IS_ADMIN_FUNCTION) {
        $link = olc_href_link($menu_entries['link']);
    } else {
        if (SHOW_COUNTS == TRUE_STRING_S) {
            $products_in_category = olc_count_products_in_category($menu_entries['id']);
            if ($products_in_category > 0) {
                $menu .= HTML_NBSP . "(" . $products_in_category . RPAREN;
            }
        }
        $cPathNew = "cPath=";
        for ($i = 0; $i < $size - 1; $i++) {
            $cPathNew .= $depth_size[$i] != 0 ? $depth_parentid[$i] . UNDERSCORE : EMPTY_STRING;
        }
        $cPathNew .= $menu_entries['id'];
        $link = olc_href_link(FILENAME_DEFAULT, $cPathNew);
        if (USE_AJAX) {
            //We need to make AJAX-links here, as "cool-menu" defines an "onclick"-handler for the menu-entries.
            //so these clicks will not "bubble" up to the common "onclick"-handler!
            $link = AJAX_REQUEST_FUNC_START . $link . AJAX_REQUEST_FUNC_END;
        }
    }
    $menu .= '\',"' . $link . '"';
    $c = str_replace($html_blank, BLANK, $menu_entries['title']);
    $c = str_replace($html_break, NEW_LINE, $c);
    $c = html_entity_decode($c);
    $c = str_replace(QUOTE, APOS, $c);
    $c = strip_tags($c);
    $menu .= ",\"" . $c . "\"" . RPAREN . SEMI_COLON . NEW_LINE;
    echo $menu;
}
Пример #7
0
function print_menu_line($categories, $depth_size, $depth_parentid, $depth)
{
    $size = 0;
    for ($i = 0; $depth_size[$i] != 0; $i++) {
        $size++;
    }
    echo "oCMenu.makeMenu('";
    if ($depth == 0) {
        echo "top" . '_' . $depth_size[0] . "','','";
    } else {
        if ($depth == 1) {
            echo "sub" . '_' . $depth_size[0] . '_' . $depth_size[1] . "','top" . '_' . $depth_size[0] . "','";
        } else {
            // $depth < 1
            echo "sub";
            for ($i = 0; $i < $size; $i++) {
                echo $depth_size[$i] != 0 ? '_' . $depth_size[$i] : '_';
            }
            echo "','sub";
            for ($i = 0; $i < $size - 1; $i++) {
                echo $depth_size[$i] != 0 ? '_' . $depth_size[$i] : '_';
            }
            echo "','";
        }
    }
    echo $categories['text'];
    if (SHOW_COUNT == TRUE_STRING_S) {
        $products_in_category = olc_count_products_in_category($categories['id']);
        if ($products_in_category > 0) {
            echo "&nbsp;(" . $products_in_category . RPAREN;
        }
    }
    $cPathNew = "cPath=";
    for ($i = 0; $i < $size - 1; $i++) {
        $cPathNew .= $depth_size[$i] != 0 ? $depth_parentid[$i] . '_' : '';
    }
    $cPathNew .= $categories['id'];
    echo "','" . olc_href_link(FILENAME_DEFAULT, $cPathNew) . "')\n";
}