function showBoxCategory($cPath_array, $ii) { global $db, $current_category_id, $category_depth; $content .= '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $cPath_array[$ii]) . '"'; if ($current_category_id == $cPath_array[$ii]) { $content .= ' class="red b" '; } $content .= '> < ' . zen_get_category_name($cPath_array[$ii], $_SESSION['languages_id']) . '</a>'; $ii++; if ($ii < sizeof($cPath_array)) { $content .= '<div class="pad_1em">'; $content .= showBoxCategory($cPath_array, $ii); $content .= '</div>'; } else { if (zen_has_category_subcategories($cPath_array[$ii])) { $content .= $cPath_array[$ii]; $content .= '<ul class="pad_1em">'; $subcategories_query = "select categories_id\n\t from " . TABLE_CATEGORIES . "\n\t where parent_id = '" . (int) $cPath_array[$ii - 1] . "' order by sort_order"; $subcategoriesArray = $db->Execute($subcategories_query); while (!$subcategoriesArray->EOF) { $content .= '<li><a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $subcategoriesArray->fields['categories_id']) . '"'; if ($category_depth == 'products' && $subcategoriesArray->fields['categories_id'] == $current_category_id) { $content .= ' class="red b" '; } $content .= '>' . zen_get_category_name($subcategoriesArray->fields['categories_id'], $_SESSION['languages_id']) . '</a></li>'; $subcategoriesArray->MoveNext(); } $content .= '</ul>'; } else { print_r('ERROR'); } } return $content; }
function zen_show_category($counter, $ii) { global $cPath_array; $this->categories_string = ""; for ($i = 0; $i < $this->tree[$counter]['level']; $i++) { if ($this->tree[$counter]['parent'] != 0) { $this->categories_string .= CATEGORIES_SUBCATEGORIES_INDENT; } } if ($this->tree[$counter]['parent'] == 0) { $cPath_new = 'cPath=' . $counter; $this->box_categories_array[$ii]['top'] = 'true'; } else { $this->box_categories_array[$ii]['top'] = 'false'; $cPath_new = 'cPath=' . $this->tree[$counter]['path']; $this->categories_string .= CATEGORIES_SEPARATOR_SUBS; } $this->box_categories_array[$ii]['path'] = $cPath_new; if (isset($cPath_array) && in_array($counter, $cPath_array)) { $this->box_categories_array[$ii]['current'] = true; } else { $this->box_categories_array[$ii]['current'] = false; } // display category name $this->box_categories_array[$ii]['name'] = $this->categories_string . $this->tree[$counter]['name']; // make category image available in case needed $this->box_categories_array[$ii]['image'] = $this->tree[$counter]['image']; if (zen_has_category_subcategories($counter)) { $this->box_categories_array[$ii]['has_sub_cat'] = true; } else { $this->box_categories_array[$ii]['has_sub_cat'] = false; } $this->box_categories_array[$ii]['categories_id'] = $counter; $this->box_categories_array[$ii]['parent_id'] = $this->tree[$counter]['parent']; if (SHOW_COUNTS == 'true') { $products_in_category = zen_count_products_in_category($counter); if ($products_in_category > 0) { $this->box_categories_array[$ii]['count'] = $products_in_category; } else { $this->box_categories_array[$ii]['count'] = 0; } } if ($this->tree[$counter]['next_id'] != false) { $ii++; $this->zen_show_category($this->tree[$counter]['next_id'], $ii); } return $this->box_categories_array; }
</table></td> </tr> <tr> <td class="smallText" width="100%" align="right"> <?php // toggle switch for editor echo TEXT_EDITOR_INFO . zen_draw_form('set_editor_form', FILENAME_CATEGORIES, '', 'get') . ' ' . zen_draw_pull_down_menu('reset_editor', $editors_pulldown, $current_editor_key, 'onChange="this.form.submit();"') . zen_hide_session_id() . zen_draw_hidden_field('cID', $cPath) . zen_draw_hidden_field('cPath', $cPath) . zen_draw_hidden_field('pID', $_GET['pID']) . zen_draw_hidden_field('page', $_GET['page']) . zen_draw_hidden_field('action', 'set_editor') . '</form>'; ?> </td> </tr> <tr> <td class="smallText" width="100%" align="right"> <?php // check for which buttons to show for categories and products $check_categories = zen_has_category_subcategories($current_category_id); $check_products = zen_products_in_category_count($current_category_id, false, false, 1); $zc_skip_products = false; $zc_skip_categories = false; if ($check_products == 0) { $zc_skip_products = false; $zc_skip_categories = false; } if ($check_categories == true) { $zc_skip_products = true; $zc_skip_categories = false; } if ($check_products > 0) { $zc_skip_products = false; $zc_skip_categories = true; }
* @copyright Portions Copyright 2003 osCommerce * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 * @version $Id: categories.php 2718 2005-12-28 06:42:39Z drbyte $ */ $row = 0; $priceListArray = array(); $priceList = array(); // don't build a tree when no categories require $template->get_template_dir('tpl_categories.php', DIR_WS_TEMPLATE, $current_page_base, 'sideboxes') . '/tpl_categories.php'; $title = BOX_HEADING_CATEGORIES_BOX; $subtitle = BOX_SUBHEADING_CATEGORIES_BOX; $title_link = false; /* * priceList four part */ if (zen_has_category_subcategories($current_category_id)) { $priceListQuery_sql = ''; $priceListQueryArray = array(); zen_get_subcategories($product_in_categoriesArray, $current_category_id); $priceListQuery_sql = implode(' or p2c.categories_id =', $product_in_categoriesArray); $priceListQuery_sql = '( p2c.categories_id = ' . $priceListQuery_sql . ')'; } else { $priceListQuery_sql = 'p2c.categories_id = ' . (int) $current_category_id; } $priceListQuery = "SELECT p. products_id ,p.`products_price`,p2c.`categories_id` FROM products p,products_to_categories p2c WHERE p2c.products_id=p.products_id AND " . $priceListQuery_sql . " order by products_price"; $priceListArray = $db->Execute($priceListQuery); while (!$priceListArray->EOF) { //caizhouqing update left_discount $rs = $db->Execute("select specials_new_products_price from specials where products_id=" . $priceListArray->fields['products_id']); if (!$rs->EOF) { $priceList[] = $rs->fields['specials_new_products_price'];
function zen_rss_category_tree($id_parent = 0, $str_cPath = '', $limit = 32767) { global $db, $rss, $additionalURL; if ($limit < 0) { return; } $categories = $db->Execute("SELECT c.categories_id, c.parent_id, GREATEST(c.date_added, IFNULL(c.last_modified, 0)) AS categories_date, c.categories_image, cd.categories_name, cd.categories_description\n FROM " . TABLE_CATEGORIES . " c\n LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " cd on c.categories_id = cd.categories_id\n WHERE c.parent_id = " . (int) $id_parent . "\n AND cd.language_id = " . (int) $_SESSION['languages_id'] . "\n AND c.categories_status = 1\n ORDER BY c.sort_order, cd.categories_name", '', false, 150); if ($categories->RecordCount() == 0) { return; } while (!$categories->EOF && $limit > 0) { $new_str_cPath = zen_not_null($str_cPath) ? $str_cPath . '_' . $categories->fields['categories_id'] : $categories->fields['categories_id']; $products_in_category = zen_count_products_in_category($categories->fields['categories_id']); if (CATEGORIES_COUNT_ZERO == '1' && $products_in_category == 0 or $products_in_category >= 1) { $limit--; $link = zen_href_link(FILENAME_DEFAULT, 'cPath=' . $new_str_cPath . $additionalURL, 'NONSSL', false); $rss->rss_feed_item($categories->fields['categories_name'], $link, array('url' => $link, 'PermaLink' => true), date('r', strtotime($categories->fields['categories_date'])), $categories->fields['categories_description'], $categories->fields['categories_image'], false, RSS_AUTHOR == '' ? STORE_OWNER_EMAIL_ADDRESS . " <" . STORE_OWNER . ">" : RSS_AUTHOR); } if (zen_has_category_subcategories($categories->fields['categories_id'])) { zen_rss_category_tree($categories->fields['categories_id'], $new_str_cPath, $limit); } $categories->MoveNext(); } }
function google_base_category_tree($id_parent = 0, $cPath = '', $cName = '', $cats = array()) { global $db, $languages; $cat = $db->Execute("SELECT c.categories_id, c.parent_id, cd.categories_name\n FROM " . TABLE_CATEGORIES . " c\n LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " cd on c.categories_id = cd.categories_id\n WHERE c.parent_id = '" . (int) $id_parent . "'\n AND cd.language_id='" . (int) $languages->fields['languages_id'] . "'\n AND c.categories_status= '1'", '', false, 150); while (!$cat->EOF) { $cats[$cat->fields['categories_id']]['name'] = (zen_not_null($cName) ? $cName . ', ' : '') . trim($cat->fields['categories_name']); // previously used zen_froogle_sanita instead of trim $cats[$cat->fields['categories_id']]['cPath'] = (zen_not_null($cPath) ? $cPath . ',' : '') . $cat->fields['categories_id']; if (zen_has_category_subcategories($cat->fields['categories_id'])) { $cats = $this->google_base_category_tree($cat->fields['categories_id'], $cats[$cat->fields['categories_id']]['cPath'], $cats[$cat->fields['categories_id']]['name'], $cats); } $cat->MoveNext(); } return $cats; }
function zen_get_products_ids_categories($categories_id) { global $db; $products_ids = array(); $result = $db->Execute("SELECT p.`products_id` FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc \n \t WHERE p.`products_id` = ptc.`products_id`\n \t AND p.`products_status` = 1\n \t AND ptc.`categories_id` = " . $categories_id); while (!$result->EOF) { $products_ids[] = $result->fields['products_id']; $result->MoveNext(); } if (zen_has_category_subcategories($categories_id)) { $subCategories = $db->Execute("SELECT categories_id FROM " . TABLE_CATEGORIES . " WHERE parent_id = " . $categories_id); while (!$subCategories->EOF) { $products_ids = array_merge($products_ids, zen_get_products_ids_categories($subCategories->fields['categories_id'])); $subCategories->MoveNext(); } } return $products_ids; }
function buildBranch($parent_id, $level = 0, $submenu = false) { if ($level == 0) { $result = $this->parent_group_start_string_noif; } else { $result = sprintf($this->parent_group_start_string, ''); } if (isset($this->data[$parent_id])) { if ($this->i_display > 0) { $i = 0; while (list($category_id, $category) = each($this->data[$parent_id]) and $i <= $this->max_display) { $category_link = $category_id; if (isset($this->data[$category_id])) { if ($b_top < 1 && $level == 1) { $result .= sprintf($this->child_start_two, $submenu == true ? ' class="b_top"' : ''); $b_top++; } else { $result .= sprintf($this->child_start_two, ''); } } else { if ($b_top < 1 && $level == 1) { $result .= sprintf($this->child_start_two, ' class="b_top"'); $b_top++; } else { $result .= sprintf($this->child_start_two, ''); } } if (isset($this->data[$category_id])) { $result .= $this->parent_start_string; } if ($level == 0) { $result .= $this->root_start_string; } if ($i == $this->max_display) { $result .= str_repeat($this->spacer_string, $this->spacer_multiplier * $level) . '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . zen_get_categories_parent_id($category_link)) . '">'; $result .= 'All ' . zen_get_categories_parent_name($category_id); $result .= '</a>'; } else { $result .= str_repeat($this->spacer_string, $this->spacer_multiplier * $level) . '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $category_link) . '" title="' . SEO_COMMON_KEYWORDS . ' ' . $category['name'] . '">'; $result .= $category['name']; if (zen_count_products_in_category($category_id)) { $result .= ' (' . zen_count_products_in_category($category_id) . ')'; } $result .= '</a>'; } if ($level == 0) { $result .= $this->root_end_string; } if (isset($this->data[$category_id])) { $result .= $this->parent_end_string; } if (isset($this->data[$category_id]) && ($this->max_level == '0' || $this->max_level > $level + 1)) { $this->i_display++; $result .= $this->buildBranch($category_id, $level + 1, $submenu); } $result .= $this->child_end_string; $i++; } } else { while (list($category_id, $category) = each($this->data[$parent_id])) { $category_link = $category_id; if (isset($this->data[$category_id])) { if ($b_top < 1 && $level == 1) { $result .= sprintf($this->child_start_string, $submenu == true ? ' class="b_top"' : ''); $b_top++; } else { $result .= sprintf($this->child_start_string, ''); } } else { if ($b_top < 1 && $level == 1) { $result .= sprintf($this->child_start_string, ' class="b_top"'); $b_top++; } else { $result .= sprintf($this->child_start_string, ''); } } if (isset($this->data[$category_id])) { $result .= $this->parent_start_string; } if ($level == 0) { $result .= $this->root_start_string; } $result .= str_repeat($this->spacer_string, $this->spacer_multiplier * $level) . '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $category_link) . '" title="' . SEO_COMMON_KEYWORDS . ' ' . $category['name'] . '">'; $result .= substr($category['name'], 0, 25); if ($level == 0) { if (zen_has_category_subcategories($category_id)) { $result .= '<!--[if IE 7]><!--></a><!--<![endif]-->' . "\n"; } else { $result .= '</a>' . "\n"; } $result .= $this->root_end_string; } else { $result .= '</a>'; } if (isset($this->data[$category_id])) { $result .= $this->parent_end_string; } if (isset($this->data[$category_id]) && ($this->max_level == '0' || $this->max_level > $level + 1)) { $this->i_display++; $result .= $this->buildBranch($category_id, $level + 1, $submenu); } $result .= $this->child_end_string; } } } if ($level == 1) { $b_top = 0; } if ($level == 0) { $result .= $this->parent_group_end_string_noif; } else { $result .= $this->parent_group_end_string; } return $result; }
function zen_addOnModules_get_layout_location_blocks($layout_location, $page) { global $db, $layout_location_blocks, $template_dir; $return = false; if (!is_array($layout_location_blocks)) { $layout_location_blocks = array(); } if (!is_array($layout_location_blocks[$layout_location])) { $layout_location_blocks[$layout_location] = array(); } $module_names = ''; $enabled_addon_modules = zen_addOnModules_get_enabled_modules(); $enabled_addon_modules[] = 'sideboxes'; if (count($enabled_addon_modules) > 0) { for ($i = 0, $n = count($enabled_addon_modules); $i < $n; $i++) { $class = $enabled_addon_modules[$i]; $module_names .= " '" . zen_db_prepare_input($class) . "',"; } $module_names = trim($module_names, ','); $query = "\n SELECT\n *\n FROM " . TABLE_BLOCKS . "\n WHERE module IN (" . $module_names . ")\n AND status = 1\n AND location = :location\n AND template = :template\n ORDER BY sort_order, block\n ;"; $query = $db->bindVars($query, ':location', $layout_location, 'string'); $query = $db->bindVars($query, ':template', $template_dir, 'string'); $result = $db->Execute($query); while (!$result->EOF) { $module = $result->fields['module']; $block = $result->fields['block']; $pages = $result->fields['pages']; $visible = $result->fields['visible']; $display = false; if ($pages == '') { $display = true; } else { if ($page == FILENAME_DEFAULT) { if (isset($_GET['cPath'])) { global $current_category_id; $page = zen_has_category_subcategories($current_category_id) ? FILENAME_DEFAULT . '_categories' : FILENAME_DEFAULT . '_products'; } if (isset($_GET['manufacturers_id'])) { $page = FILENAME_DEFAULT . '_products'; } } if ($page == FILENAME_ADDON) { $perse_page_module = zen_addOnModules_persePageModule($_GET['module']); $page = $perse_page_module['class'] . '#' . $perse_page_module['method']; } $page_match = zen_addOnModules_page_match($pages, $page); if ($visible == 1 && $page_match || $visible == 0 && !$page_match) { $display = true; } } if ($display) { $layout_location_blocks[$layout_location][] = array('module' => $module, 'block' => $block, 'css_selector' => $result->fields['css_selector'], 'insert_position' => $result->fields['insert_position']); } $result->MoveNext(); } } return $layout_location_blocks; }
function get_categories($parent_id = '0', $cPath = "") { global $db; // cPathの展開 if ($cPath != "") { $cPathArray = explode("_", $cPath); } else { $cPathArray = array(); } // get categories $categories_query = "select c.categories_id, cd.categories_name, c.categories_status\n from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd\n where\n parent_id = '" . (int) $parent_id . "'\n and c.categories_id = cd.categories_id\n and cd.language_id = '" . (int) $_SESSION['languages_id'] . "'\n and c.categories_status = 1\n order by sort_order, cd.categories_name"; $categories = $db->Execute($categories_query); while (!$categories->EOF) { // cPathが指定された場合の子供の展開 $child = array(); // 今処理しているカテゴリーと同じ場合に // その下層を検索する if (count($cPathArray) > 0 && $categories->fields['categories_id'] == $cPathArray[0]) { $parent_id = $cPathArray[0]; array_shift($cPathArray); $child = $this->get_categories($parent_id, implode("_", $cPathArray)); } $categories_ids = $this->getCategoryIdList($categories->fields['categories_id']); if (count($child)) { $childjson = ", children:" . getAjaxCategoryTreeJson($child); } else { $childjson = ""; } $categories_array[] = array('key' => $categories->fields['categories_id'], 'title' => $categories->fields['categories_name'], 'haschild' => zen_has_category_subcategories($categories->fields['categories_id']), 'url' => implode("_", $categories_ids), 'categoryid' => $categories->fields['categories_id'], 'child' => $child, 'childjson' => $childjson); $categories->MoveNext(); } return $categories_array; }