/**
  * Process callback, That look all the parent of the categories Id of the
  * meter.
  *
  * @param id $value
  *   The meter ID.
  *
  * @return array
  *   A categories id array.
  */
 protected function meterCategories($value)
 {
     $wrapper = entity_metadata_wrapper('node', $value);
     $meter_categories = $wrapper->{OG_VOCAB_FIELD}->value();
     // Loop for meter-category vocabularies only
     $category_ids = array();
     foreach ($meter_categories as $meter_category) {
         if (strpos($meter_category->vocabulary_machine_name, 'meter_category_') === FALSE) {
             // Not a meter category vocabulary, skip.
             continue;
         }
         $categories = taxonomy_get_parents_all($meter_category->tid);
         foreach ($categories as $category) {
             $wrapper_category = entity_metadata_wrapper('taxonomy_term', $category);
             $category_ids[$wrapper_category->tid->value()] = array("id" => $wrapper_category->tid->value(), "name" => $wrapper_category->field_icon_categories->value());
         }
     }
     return $category_ids;
 }
예제 #2
0
/**
 * Return a themed breadcrumb trail.
 *
 * @param $breadcrumb
 *	 An array containing the breadcrumb links.
 * @return a string containing the breadcrumb output.
 */
function phptemplate_breadcrumb($breadcrumb)
{
    if (!empty($breadcrumb)) {
        // We need a special BC for forum topics and blog
        if (arg(0) == 'node' || arg(0) == 'comment' && arg(1) == 'reply') {
            if (arg(0) == 'node' && is_numeric(arg(1))) {
                $node = node_load(arg(1));
                // let's load the current node
            } elseif (is_numeric(arg(2))) {
                $node = node_load(arg(2));
                // commented node
            }
            if ($node->type == 'forum') {
                // is it a forum topic?
                $breadcrumb[] = l('Forums', 'forum');
                $par = array_keys($node->taxonomy);
                // ok, let's get the immediate parent term TID
                $par_tid = $par[0];
                $all_pars = taxonomy_get_parents_all($par_tid);
                $all_pars = array_reverse($all_pars);
                foreach ($all_pars as $this_par) {
                    $breadcrumb[] = l($this_par->name, drupal_get_path_alias('forum/' . $this_par->tid));
                }
                if (arg(0) == 'comment' && arg(1) == 'reply') {
                    $breadcrumb[] = l($node->title, drupal_get_path_alias('node/' . $node->nid));
                }
            }
        } elseif (arg(0) == 'blog') {
            $breadcrumb[] = l('Stay in Touch', 'stay-in-touch');
        } elseif (arg(0) == 'month') {
            $breadcrumb[] = l('Stay in Touch', 'stay-in-touch');
            $breadcrumb[] = l('Captain\'s Blog', 'stay-in-touch/blog');
        } elseif (arg(0) == 'taxonomy') {
            $this_term = taxonomy_get_term(arg(2));
            if ($this_term->vid == 2) {
                $breadcrumb[] = l('Stay in Touch', 'stay-in-touch');
                $breadcrumb[] = l('Captain\'s Blog Tags', 'stay-in-touch/blog');
            }
        }
        return implode(' <span>&gt</span> ', $breadcrumb);
    }
}
        <?php 
echo $messages;
include __DIR__ . '/partials/siteAdminBar.inc';
$term =& $page['content']['system_main']['term_heading']['term']['#term'];
$title = $term->name;
?>
        <h1 class="cob-portalHeader-title"><?php 
echo $title;
?>
</h1>
        <nav class="cob-portalHeader-breadcrumbs">
            <?php 
echo l('Home', '/');
?>
            <?php 
$ancestors = array_reverse(taxonomy_get_parents_all($term->tid));
$count = count($ancestors);
$i = 1;
foreach ($ancestors as $t) {
    if ($i < $count) {
        echo l($t->name, 'taxonomy/term/' . $t->tid);
    } else {
        echo "<span>{$t->name}</span>";
    }
    $i++;
}
?>
        </nav>
    </div>
</header>
<main    class="cob-portalMain" role="main">
예제 #4
0
/**
 * Save additonal fields to user object via the entity_metadata_wrapper.
 *
 * @param array $mapping
 *   Mapping configuration.
 * @param array $row
 *   Csv row.
 * @param object $account
 *   Drupal user object.
 *
 * @return object
 *   Entity meta data object.
 */
function import_users_save_fields($mapping, $row, $account)
{
    $col = 0;
    foreach ($mapping as $conf) {
        if (empty($row[$col])) {
            $col++;
            continue;
        }
        if (!empty($conf['field'])) {
            $field = $conf['field'];
            $user_wrapper = entity_metadata_wrapper('user', $account);
            $value = $row[$col];
            if (!empty($conf['value_callback'])) {
                $value = call_user_func($conf['value_callback'], $value);
            }
            // Convert value to UTF-8.
            import_users_convert_2_utf8($value);
            // Translate country code.
            if ($conf['col'] == 'LAND') {
                import_users_translate_country($value);
            }
            // If hierarical term ref is used.
            if (!empty($conf['field_type']) && $conf['field_type'] == 'term_ref_hierarical') {
                $term_lineage = taxonomy_get_parents_all($value);
                $value = !empty($term_lineage) ? $term_lineage : $value;
            }
            // If the field value is available at root level.
            if (!is_array($field)) {
                $user_wrapper->{$field}->set($value);
            } else {
                $user_wrapper->{$field[0]}->{$field[1]}->set($value);
            }
        }
        $col++;
    }
    $user_wrapper->save();
    return $user_wrapper;
}
예제 #5
0
ini_set('memory_limit', '256M');
// Perform import as admin user
global $user;
$user = user_load(array('uid' => 1));
/**
 *  MAIN
 */
// Find the correct term-id from the vocabulary name
$taxonomy_vid = taxonomy_vocabulary_machine_name_load('user_type');
// Get the taxonomy tree for the user term vocabulary
$taxonomy_tree = taxonomy_get_tree($taxonomy_vid->vid);
// Step through each tree element, and find leaf-children plus their parents
foreach ($taxonomy_tree as $id => $item) {
    $tid = $item->tid;
    $children = taxonomy_get_children($tid, $taxonomy->vid);
    if (empty($children)) {
        // This must be a leaf since it has no children
        $parents = taxonomy_get_parents_all($tid);
        $txt = '"';
        $first = TRUE;
        while (!empty($parents)) {
            $litem = array_pop($parents);
            $txt .= ($first ? '' : '-->') . $litem->name;
            $first = FALSE;
        }
        $txt .= '", "' . $item->tid . '"' . "\n";
        $output .= $txt;
    }
}
$iso_output = utf8_decode($output);
fwrite($stdout, $iso_output);
예제 #6
0
파일: template.php 프로젝트: 404pnf/d7sites
/**
 * Return a themed breadcrumb trail.
 *
 * @param $breadcrumb
 *   An array containing the breadcrumb links.
 * @return
 *   A string containing the breadcrumb output.
 */
function basic_breadcrumb($variables)
{
    $breadcrumb_separator = theme_get_setting('chinese_breadcrumb_separator');
    $current_path = drupal_get_path_alias();
    if ($current_path == 'aboutus') {
        $breadcrumbs = array();
        $breadcrumbs[] = '<a href="' . url() . '">' . t('首页') . '</a> >>';
        if ($current_path == 'aboutus') {
            $breadcrumbs[] = '<a href="' . url('aboutus') . '">' . t(' 关于我们') . '</a>';
        } else {
        }
        $output .= '<div class="breadcrumb">';
        $output .= implode($breadcrumb_separator, $breadcrumbs);
        $output .= '</div>';
        return $output;
    }
    if ($current_path == 'training') {
        $breadcrumbs = array();
        $breadcrumbs[] = '<a href="' . url() . '">' . t('首页') . '</a> >>';
        $breadcrumbs[] = '<a href="' . url('training') . '">' . t(' 教师培训') . '</a>';
        $output = '<div class="breadcrumb">';
        $output .= implode($breadcrumb_separator, $breadcrumbs);
        $output .= '</div>';
        return $output;
    }
    if ($current_path == 'products') {
        $breadcrumbs = array();
        $breadcrumbs[] = '<a href="' . url() . '">' . t('首页') . '</a> >>';
        if ($current_path == 'products') {
            $breadcrumbs[] = '<a href="' . url('products') . '">' . t(' 产品中心') . '</a>';
        } else {
        }
        $output .= '<div class="breadcrumb">';
        $output .= implode($breadcrumb_separator, $breadcrumbs);
        $output .= '</div>';
        return $output;
    }
    if (arg(0) == 'productslist' && arg(1) > 0) {
        $tid = arg(1);
        $breadcrumbs = array();
        $breadcrumbs[] = '<a href="' . url() . '">' . t('首页') . '</a> >';
        $breadcrumbs[] = '<a href="' . url('productslist') . '">' . t(' 产品中心') . '</a>';
        $parents = taxonomy_get_parents_all($tid);
        $parents = array_reverse($parents);
        foreach ($parents as $parent) {
            $breadcrumbs[] = ' > <a href="' . base_path() . 'productslist/' . $parent->tid . '">' . $parent->name . '</a>';
        }
        $output = '<div class="breadcrumb">';
        $output .= implode($breadcrumb_separator, $breadcrumbs);
        $output .= '</div>';
        return $output;
    }
    if (arg(0) == 'node' && arg(1) > 0) {
        $nid = arg(1);
        $node = node_load($nid);
        if ($node->type == 'book') {
            $breadcrumbs = array();
            $breadcrumbs[] = '<a href="' . url() . '">' . t('首页') . '</a> >';
            $breadcrumbs[] = '<a href="' . url('products') . '">' . t(' 产品中心') . '</a> ';
            $tid = $node->field_fenlei['und'][0]['tid'];
            //获得产品分类
            $parents = taxonomy_get_parents_all($tid);
            $parents = array_reverse($parents);
            foreach ($parents as $parent) {
                $breadcrumbs[] = '> <a href="' . base_path() . 'products/' . $parent->tid . '">' . $parent->name . '</a> ';
            }
            $output = '<div class="breadcrumb">';
            $output .= implode($breadcrumb_separator, $breadcrumbs);
            $output .= '</div>';
            return $output;
        }
    }
    $breadcrumb = $variables['breadcrumb'];
    // Determine if we are to display the breadcrumb.
    $show_breadcrumb = theme_get_setting('basic_breadcrumb');
    if ($show_breadcrumb == 'yes' || $show_breadcrumb == 'admin' && arg(0) == 'admin') {
        // Optionally get rid of the homepage link.
        $show_breadcrumb_home = theme_get_setting('basic_breadcrumb_home');
        if (!$show_breadcrumb_home) {
            array_shift($breadcrumb);
        }
        // Return the breadcrumb with separators.
        if (!empty($breadcrumb)) {
            $breadcrumb_separator = theme_get_setting('basic_breadcrumb_separator');
            $trailing_separator = $title = '';
            if (theme_get_setting('basic_breadcrumb_title')) {
                $item = menu_get_item();
                if (!empty($item['tab_parent'])) {
                    // If we are on a non-default tab, use the tab's title.
                    $title = check_plain($item['title']);
                } else {
                    $title = drupal_get_title();
                }
                if ($title) {
                    $trailing_separator = $breadcrumb_separator;
                }
            } elseif (theme_get_setting('basic_breadcrumb_trailing')) {
                $trailing_separator = $breadcrumb_separator;
            }
            // Provide a navigational heading to give context for breadcrumb links to
            // screen-reader users. Make the heading invisible with .element-invisible.
            $heading = '<h2 class="element-invisible">' . t('You are here') . '</h2>';
            return $heading . '<div class="breadcrumb">' . implode($breadcrumb_separator, $breadcrumb) . $trailing_separator . $title . '</div>';
        }
    }
    // Otherwise, return an empty string.
    return '';
}
    if ($language->language == 'et') {
        unset($row['field_position_in_english']);
        unset($row['field_position_in_russian']);
    }
    if ($language->language == 'en') {
        unset($row['field_position']);
        unset($row['field_position_in_russian']);
    }
    if ($language->language == 'ru') {
        unset($row['field_position_in_english']);
        unset($row['field_position']);
    }
}
if (!empty($title) || !empty($caption)) {
    $first = reset($result);
    $term = taxonomy_get_parents_all($first->taxonomy_term_data_field_data_field_department_tid);
    $count = count($term) + 1;
    print '<h' . $count . '>' . $caption . $title . '</h' . $count . '>';
}
?>
<table <?php 
if ($classes) {
    print 'class="' . $classes . '" ';
}
?>
>
  <?php 
if (!empty($header)) {
    ?>
    <thead>
      <tr>
예제 #8
0
function _scratchy_theme_forum($node, $teaser, $page)
{
    $parents = taxonomy_get_parents_all($node->tid);
    $breadcrumb = array();
    $breadcrumb[] = l('Home', '');
    $breadcrumb[] = l('Forums', 'forum');
    if ($parents) {
        $parents = array_reverse($parents);
        foreach ($parents as $p) {
            if ($p->tid == $tid) {
                $title = $p->name;
            } else {
                $breadcrumb[] = l($p->name, 'forum/' . $p->tid);
            }
        }
    }
    drupal_set_breadcrumb($breadcrumb);
    $output = '<div class="node' . (!$node->status ? ' unpublished' : '') . ($node->sticky && !$page ? ' sticky' : '') . '">
  <div class="boxtop">
    <div class="bc ctr"></div>
    <div class="bc ctl"></div>
  </div>
  <div class="boxcontent">
    <div class="boxtitle' . ($node->sticky && !$page ? '-sticky' : '') . '">
      <h1>' . ($teaser ? l($node->title, "node/{$node->nid}") : check_plain($node->title)) . '</h1>
    </div>
    <div class="subboxcontent">';
    // Removed for now.  I SHALL RETURN!
    /*if ($tabs = theme('menu_local_tasks')) {
        $output .= $tabs;
      }*/
    $output .= '<div class="content">';
    if ($teaser && $node->teaser) {
        $output .= $node->teaser;
    } else {
        $output .= $node->body;
    }
    $output .= '</div>';
    if (theme_get_setting("toggle_node_info_{$node->type}")) {
        $submitted['node_submitted'] = array('title' => t("By !author at @date", array('!author' => theme('username', $node), '@date' => format_date($node->created, 'small'))), 'html' => TRUE);
    } else {
        $submitted['node_submitted'] = array();
    }
    $terms = array();
    if (module_exists('taxonomy')) {
        $terms = taxonomy_link("taxonomy terms", $node);
    }
    $links = array_merge($submitted, $terms);
    if ($node->links) {
        $links = array_merge($links, $node->links);
    }
    if (count($links)) {
        $output .= '<div class="links">' . theme('links', $links, array('class' => 'links inline')) . "</div>\n";
    }
    $output .= '</div>
  </div>
  <div class="boxbtm">
    <div class="bc cbr"></div>
    <div class="bc cbl"></div>
  </div>
</div>';
    return $output;
}
예제 #9
0
*
* @see template_preprocess()
* @see template_preprocess_block()
*/
?>
<div id="block-<?php 
print $block->module . '-' . $block->delta;
?>
" class="<?php 
print $classes;
?>
"><div class="block-inner">

  <?php 
// let's get the parent term title for the child term we are visiting
$parent_title = array_reverse(taxonomy_get_parents_all(arg(2)));
if ($parent_title) {
    $block->subject = $parent_title[0]->name;
}
?>

<?php 
$term = taxonomy_get_term(arg(2));
$region_name = $term->name;
?>

  <?php 
if (arg(1) == 'term') {
    ?>
    <h2 class="title"><?php 
    print $region_name;
        ?>
      <li><strong><?php 
        print t('Location');
        ?>
</strong><span><?php 
        //Company (maybe Hotel, Airline or travel service) is higher priority
        $place_node = node_load($addr_node->field_place[0]['nid']);
        if (!$place_node || strpos($node->field_dealtype[0]['value'], 'Tour') === TRUE || strpos($node->field_dealtype[0]['value'], 'Flight') === TRUE) {
            //if we don't have place_node from address,or this is not a Hotel Deal, we use mainplace
            $place_node = node_load($node->field_mainplace[0]['nid']);
        }
        if (!$place_node) {
            watchdog('alehap', 'missing any place');
        }
        //Get all terms
        $parents = taxonomy_get_parents_all($place_node->field_placeterm[0]['value']);
        $places = "";
        $first = TRUE;
        foreach ($parents as $parent) {
            //Get place node by term ID -  related to "place_by_term" view
            $place_by_term = sqrl('place_by_term', $parent->tid);
            //Load correspoding term object
            $term_obj = taxonomy_get_term($place_by_term[0]['field_placeterm_value']);
            //Append to places string
            //If this is the first item of object, do not append the ','
            if ($first) {
                $places .= $term_obj ? $term_obj->name : '';
                $first = FALSE;
            } else {
                $places .= $term_obj ? ', ' . $term_obj->name : '';
            }