/** * Override or insert variables into the node templates. * * @param $vars * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered ("node" in this case.) */ function THEMENAME_preprocess_node(&$vars, $hook) { $node = (object)$vars; if (uc_product_is_product($node->type) && variable_get('uc_catalog_breadcrumb', TRUE)) { $crumbs = array(); if (variable_get('site_frontpage', 'node') != 'catalog') { $crumbs[] = l(t('Home'), ''); } $terms = taxonomy_node_get_terms_by_vocabulary($node, variable_get('uc_catalog_vid', 0)); if (count($terms)) { //fix by alexku start //$crumbs[] = l(variable_get('uc_catalog_name', t('Catalog')), variable_get('uc_catalog_url', 'catalog')); global $language; $catalog_name = variable_get('uc_catalog_name', 'Catalog'); $catalog_id = variable_get('uc_catalog_vid', '1'); $translated_name = i18nstrings("taxonomy:vocabulary:$catalog_id:name", $catalog_name, $language->language, FALSE); $crumbs[] = l($translated_name, variable_get('uc_catalog_url', 'catalog')); //fix by alexku end $used_tids = array(); foreach ($terms as $term) { if (!isset($parents[$term->tid])) { $parents[$term->tid] = taxonomy_get_parents_all($term->tid); } //drupal_set_message('
'. print_r($parents[$term->tid], TRUE) .''); foreach (array_reverse($parents[$term->tid]) as $parent) { //fix by alexku start $parent->name = i18nstrings("taxonomy:term:$parent->tid:name", $parent->name, $language->language, FALSE); if ($parent->description) { $parent->description = i18nstrings("taxonomy:term:$parent->tid:description", $parent->description, $language->language, FALSE); } //fix by alexku end if (!in_array($parent->tid, $used_tids)) { $crumbs[] = l($parent->name, uc_catalog_path($parent)); $used_tids[] = $parent->tid; } } } } drupal_set_breadcrumb($crumbs); } } /** * Theme the catalog block. * * @ingroup themeable * @see theme_uc_catalog_item() */ function THEMENAME_uc_catalog_block($menu_tree) { $output = ''; return $output; } /** * Multilingual version. Emulate Drupal's menu system, but based soley on the structure of "Product Catalog". * * @param $branch * A treeNode object. Determines if the URL points to itself, * or possibly one of it's children, if present. * * If the URL points to itself or one of its products, it displays its name, and * expands to show its children, otherwise displays a link and a count of the products in it. * If the URL points to one of it's children, it still displays a link and product count, * but must still be expanded. * Otherwise, it is collapsed and a link. * @return * An array whose first element is true if the treeNode is in hierarchy of the URL path. * The second element is the HTML of the list item of itself and it's children. */ function _uc_catalog_navigation_multilingual($branch) { static $terms; static $breadcrumb; static $types; //fix by alexku start global $language; if ($branch->tid) { $branch->name = i18nstrings("taxonomy:term:$branch->tid:name", $branch->name, $language->language, TRUE); if ($branch->description) { $branch->description = i18nstrings("taxonomy:term:$branch->tid:description", $branch->description, $language->language, FALSE); } } //fix by alexku end if (empty($types)) { $types = uc_product_types(); } $num = 0; foreach ($types as $type) { $num += taxonomy_term_count_nodes($branch->tid, $type); } // No nodes in category or descendants. Not in path and display nothing. if (!$num) { return array(FALSE, ''); } $branch_path = uc_catalog_path($branch); if (!isset($breadcrumb)) { $breadcrumb = drupal_get_breadcrumb(); } $vid = variable_get('uc_catalog_vid', 0); if ($_GET['q'] == $branch_path) { // The URL points to this term. $here = TRUE; } else { $here = FALSE; } if (!isset($terms)) { $terms = taxonomy_node_get_terms_by_vocabulary(menu_get_object('node', 1), $vid); } // Determine whether to expand menu item. if ((arg(0) == 'node' && array_key_exists($branch->tid, $terms))) { $inpath = FALSE; foreach ($breadcrumb as $link) { if (strpos($link, drupal_get_path_alias($branch_path)) !== FALSE) { $inpath = TRUE; } } } else { $inpath = $here; } // Checks to see if node counts are desired in navigation $num_text = ''; if (variable_get('uc_catalog_block_nodecount', TRUE)) { $num_text = ' ('. $num .')'; } $lis = array(); $expand = variable_get('uc_catalog_expand_categories', FALSE); $link = l($branch->name . $num_text, $branch_path); if ($expand || count($branch->children)) { foreach ($branch->children as $twig) { // Expand if children are in the menu path. Capture their output. list($child_in_path, $lis[]) = _uc_catalog_navigation_multilingual($twig); if ($child_in_path) { $inpath = $child_in_path; } } } $output = theme("uc_catalog_item", $here, $link, $lis, $expand, $inpath, count($branch->children)); // Tell parent category your status, and pass on output. return array($inpath, $output); } /** * Implementation of hook_preprocess_block(). */ function THEMENAME_preprocess_block(&$variables, $hook) { if ($variables['block']->module == 'uc_catalog' && $variables['block']->delta == '0') { $subject = &$variables['block']->subject; global $language; $catalog_name = variable_get('uc_catalog_name', 'Catalog'); $catalog_id = variable_get('uc_catalog_vid', '1'); $subject = i18nstrings("taxonomy:vocabulary:$catalog_id:name", $catalog_name, $language->language, FALSE); if (variable_get('uc_catalog_block_title', FALSE)) { $subject = l($subject, 'catalog'); } } } function THEMENAME_uc_catalog_browse($tid = 0) { global $language; drupal_add_css(drupal_get_path('module', 'uc_catalog') .'/uc_catalog.css'); $output = ''; $catalog = uc_catalog_get_page((int)$tid); //fix by alexku start //check if we are on the catalog or on the category page if (!$catalog->tid) { //if on catalog page $catalog->name = i18nstrings("taxonomy:vocabulary:$catalog->vid:name", $catalog->name, $language->language, FALSE); if ($catalog->description) { $catalog->description = i18nstrings("taxonomy:vocabulary:$catalog->vid:description", $catalog->description, $language->language, FALSE); } } else { //if on category (term) page $catalog->name = i18nstrings("taxonomy:term:$catalog->tid:name", $catalog->name, $language->language, FALSE); if ($catalog->description) { $catalog->description = i18nstrings("taxonomy:term:$catalog->tid:description", $catalog->description, $language->language, FALSE); } } //fix by alexku end drupal_set_title(check_plain($catalog->name)); drupal_set_breadcrumb(uc_catalog_set_breadcrumb($catalog->tid)); $types = uc_product_types(); $links = array(); $child_list = array(); foreach ($catalog->children as $child) { //fix by alexku start $child->name = i18nstrings("taxonomy:term:$child->tid:name", $child->name, $language->language, FALSE); if ($child->description) { $child->description = i18nstrings("taxonomy:term:$child->tid:description", $child->description, $language->language, FALSE); } //fix by alexku end if (!empty($child->nodes)) { $links[] = array('title' => $child->name . (variable_get('uc_catalog_breadcrumb_nodecount', FALSE) ? ' ('. $child->nodes .')' : ''), 'href' => uc_catalog_path($child), 'attributes' => array('rel' => 'tag'), ); } if (!empty($child->image)) { $image = '
'. print_r($breadcrumbs, TRUE) .''; return $breadcrumbs; } else { return NULL; } }