/**
  * Override Migration::prepare().
  *
  * Set the term parent for heirarchical terms
  *
  * @param $term
  * @param $row
  */
 public function prepare($term, $row)
 {
     // Handle og_vocab
     $vocab_name = $this->bundle;
     if (!($vocabulary = taxonomy_vocabulary_machine_name_load($vocab_name))) {
         // Create a new vocabulary
         $vocabulary = (object) array('name' => 'Meter categories for ' . $row->account_id, 'description' => 'Meter categories for ' . $row->account_id, 'machine_name' => $vocab_name);
         taxonomy_vocabulary_save($vocabulary);
     }
     // Create an OG-vocab and relate new vocabulary with OG.
     $account_id = $term->account_id['destid1'];
     $settings = array('cardinality' => 1, 'required' => TRUE);
     // Loop for all meter content-types and create og-vocabulary.
     $node_types = node_type_get_types();
     foreach ($node_types as $content_type) {
         if (strpos($content_type->type, '_meter') === FALSE) {
             // Not a meter type, skip.
             continue;
         }
         $og_vocab = og_vocab_create_og_vocab($vocabulary->vid, 'node', $content_type->type, OG_VOCAB_FIELD, $settings);
         $og_vocab->save();
     }
     og_vocab_relation_save($vocabulary->vid, 'node', $account_id);
     // Save vocabulary id.
     $term->vid = $vocabulary->vid;
     // Handle parent.
     $term->name = ucwords(trim($term->name));
     $parent = ucwords(trim($row->parent));
     $parent_term = taxonomy_get_term_by_name($parent, $vocab_name);
     $parent_term = reset($parent_term);
     if ($parent_term) {
         $term->parent = $parent_term->tid;
     }
 }
 public static function checkTerms($vocabName, $termName)
 {
     /*@param $vocabName
      *@param $termName
      *@return $tid
      */
     $vocab = taxonomy_vocabulary_machine_name_load($vocabName);
     $vid = $vocab->vid;
     //check term
     $checkTerm = taxonomy_get_term_by_name($termName, $vocabName);
     if (empty($checkTerm)) {
         $term = new stdClass();
         $term->name = $termName;
         $term->vid = $vid;
         taxonomy_term_save($term);
         $termArray = taxonomy_get_term_by_name($termName, $vocabName);
         $term = current($termArray);
         $tid = $term->tid;
         return $tid;
     } else {
         $term = current($checkTerm);
         $tid = $term->tid;
         return $tid;
     }
 }
 /**
  * @Given :provider previews are :setting for :format_name resources
  *
  * Changes variables in the database to enable or disable external previews
  */
 public function externalPreviewsAreEnabledForFormat($provider, $setting, $format_name)
 {
     $format = current(taxonomy_get_term_by_name($format_name, 'format'));
     $preview_settings = variable_get("dkan_dataset_format_previews_tid{$format->tid}", array());
     // If $setting was "enabled," the preview is turned on. Otherwise, it's
     // turned off.
     $preview_settings[$provider] = $setting == 'enabled' ? $provider : 0;
     variable_set("dkan_dataset_format_previews_tid{$format->tid}", $preview_settings);
 }
 /**
  * {@inheritdoc}
  */
 public function expand($values)
 {
     $return = array();
     foreach ($values as $name) {
         $terms = taxonomy_get_term_by_name($name, $this->getVocab());
         if (!$terms) {
             throw new \Exception(sprintf("No term '%s' exists.", $name));
         }
         $return[$this->language][] = array('tid' => array_shift($terms)->tid);
     }
     return $return;
 }
Example #5
0
/**
 * This function is used to verify api tags with cms tags and update its status 
 * $tag_names pass parameter as api tags
 * $tag_status mena its verified tags or unverified tag
 */
function analysize_api_tags($tag_names, $tag_status, $all_tids, $node)
{
    $tag_status = $tag_status == 'Verified' ? 'verified' : 'unverified';
    foreach ($tag_names as $tag_name) {
        $terms = taxonomy_get_term_by_name($tag_name, 'tags');
        if (empty($terms)) {
            $node->field_tags['und'][]['tid'] = custom_create_taxonomy_term($tag_name, 1, $tag_status);
            continue;
        }
        foreach ($terms as $key => $term) {
            $term->name = $tag_name;
            $term_id = $term->tid;
            if (!in_array($term_id, $all_tids)) {
                $node->field_tags['und'][]['tid'] = $term->tid;
            }
            update_tag_status($term, 'base', $tag_status);
        }
    }
    api_node_save($node);
}
function createTip($content)
{
    $term1 = taxonomy_get_term_by_name($content[0]);
    $term2 = taxonomy_get_term_by_name($content[1]);
    $tip = trim($content[2]);
    print "tip is: " . $content[0] . "," . $content[1] . "," . $content[2] . "\n";
    print "      : " . $term1[0]->tid . "," . $term2[0]->tid . "," . $tip . "\n";
    $terms = array($term1[0]->tid, $term2[0]->tid);
    $node = new stdClass();
    $node->type = 'quicktip';
    $node->title = $tip;
    $node->body = '';
    $node->teaser = '';
    $node->uid = 1;
    $node->language = 'en';
    $node->status = 0;
    $node->promote = 0;
    $node->field_ordinal = array(array('value' => $ordinal));
    $node->field_source = array(array('value' => $source));
    $node->taxonomy = $terms;
    node_save($node);
}
Example #7
0
 /**
  * {@inheritdoc}
  */
 public function expand($values)
 {
     $result = array();
     $values = (array) $values;
     foreach ($values as $entry) {
         $terms = explode(',', $entry);
         foreach ($terms as $term) {
             // Try to split things out in order to find optional specified vocabs.
             $term_name_or_tid = '';
             $parts = explode(':', $term);
             if (count($parts) == 1) {
                 $term_name_or_tid = $term;
             } elseif (count($parts) == 2) {
                 $term_name_or_tid = $term;
             }
             if ($term_list = taxonomy_get_term_by_name($term_name_or_tid)) {
                 $term = reset($term_list);
                 $result[] = $term;
             }
         }
     }
     return $result;
 }
function set_article_categories($articleobj, $bundle, $categoryObj = NULL)
{
    $type = variable_get('brafton_existing_type');
    //Grabs the categories from the feed.
    if ($categoryObj != NULL) {
        $categories = array($categoryObj);
        $video_loader = true;
        $type = 'b_video';
    } else {
        $categories = $articleobj->getCategories();
        $video_loader = false;
    }
    switch ($type) {
        case 'b_news':
            $vocab = 'b_news_t';
            break;
        case 'b_video':
            $vocab = 'b_news_v';
            break;
        default:
            $info = field_info_field(variable_get('brafton_custom_taxonomy'));
            $vocab = $info['settings']['allowed_values'][0]['vocabulary'];
            break;
    }
    //Checks to see if the terms already exist in the Brafton Taxonomy Vocabulary.  If they do not, new terms are created.
    $i = 0;
    $brafton_vocabulary = taxonomy_vocabulary_machine_name_load($vocab);
    $vid = $brafton_vocabulary->vid;
    $cat_array = array();
    foreach ($categories as $category) {
        if ($video_loader) {
            $name = $categories[0]->name;
        } else {
            $name = get_category($categories, $i);
            $i = $i + 1;
        }
        $check_cat = taxonomy_get_term_by_name($name);
        $found = 0;
        foreach ($check_cat as $term) {
            if ($term->vid == $vid) {
                $tid = $term->tid;
                $found = 1;
            }
        }
        if ($found == 0) {
            $new_term = array('vid' => $vid, 'name' => $name);
            $new_term = (object) $new_term;
            taxonomy_term_save($new_term);
            $tid = $new_term->tid;
        }
        array_push($cat_array, $tid);
    }
    //Returns an array of valid term ids for the given article.
    return $cat_array;
}
Example #9
0
 /**
  * {@inheritdoc}
  */
 public function termCreate(\stdClass $term)
 {
     // Map vocabulary names to vid, these take precedence over machine names.
     if (!isset($term->vid)) {
         $vocabularies = \taxonomy_get_vocabularies();
         foreach ($vocabularies as $vid => $vocabulary) {
             if ($vocabulary->name == $term->vocabulary_machine_name) {
                 $term->vid = $vocabulary->vid;
             }
         }
     }
     if (!isset($term->vid)) {
         // Try to load vocabulary by machine name.
         $vocabularies = $this->taxonomyVocabularyLoadMultiple(array($term->vid));
         if (!empty($vocabularies)) {
             $vids = array_keys($vocabularies);
             $term->vid = reset($vids);
         }
     }
     // If `parent` is set, look up a term in this vocab with that name.
     if (isset($term->parent)) {
         $parent = \taxonomy_get_term_by_name($term->parent);
         if (!empty($parent)) {
             $parent = reset($parent);
             $term->parent = $parent->tid;
         }
     }
     if (empty($term->vid)) {
         throw new \Exception(sprintf('No "%s" vocabulary found.'));
     }
     // Attempt to decipher any fields that may be specified.
     $this->expandEntityFields('taxonomy_term', $term);
     // Protect against a failure from hook_taxonomy_term_insert() in pathauto.
     $current_path = getcwd();
     chdir(DRUPAL_ROOT);
     $term_array = (array) $term;
     \taxonomy_save_term($term_array);
     chdir($current_path);
     // Loading a term by name returns an array of term objects, but there should
     // only be one matching term in a testing context, so take the first match
     // by reset()'ing $matches.
     $matches = \taxonomy_get_term_by_name($term->name);
     $saved_term = reset($matches);
     return $saved_term;
 }
 /**
  * This function is called after an EntityForm is submitted. Iterate over
  * $termNames variable and see which ones have taxonomy terms. These taxonomy
  * terms are created during form submission. Add these to global $entities
  * object so that they can be deleted later.
  *
  * @param Form $formObject
  *   Form object.
  * @param string $field_name
  *   Field name.
  *
  * @return array
  *   An array with 2 values:
  *   (1) $success: TRUE.
  *   (2) $msg: An empty string.
  */
 public static function processAfterSubmit(Form $formObject, $field_name)
 {
     if (self::isCckField($formObject, $field_name)) {
         $field_info = Field::getFieldInfo($field_name);
         $vocabulary = $field_info['settings']['allowed_values'][0]['vocabulary'];
         $class = "RedTest\\entities\\TaxonomyTerm\\" . Utils::makeTitleCase($vocabulary);
         if (sizeof(self::$termNames)) {
             global $entities;
             foreach (self::$termNames as $termName) {
                 $terms = taxonomy_get_term_by_name($termName, $vocabulary);
                 foreach ($terms as $tid => $term) {
                     // We are assuming that there will be only one term with the same
                     // name in a given vocabulary.
                     $entities['taxonomy_term'][$tid] = new $class($tid);
                     unset(self::$termNames[$termName]);
                 }
             }
         }
     }
     return new Response(TRUE, NULL, "");
 }
Example #11
0
function get_title_data()
{
    $navigation_vocab = 'taxanavigation';
    $trail = menu_get_active_trail();
    $taxon = taxonomy_get_term_by_name($trail[2]['title'], $navigation_vocab);
    reset($taxon);
    return current($taxon);
}
Example #12
0
 /**
  * {@inheritdoc}
  */
 public function termCreate(\stdClass $term)
 {
     // Map vocabulary names to vid, these take precedence over machine names.
     if (!isset($term->vid)) {
         $vocabularies = \taxonomy_get_vocabularies();
         foreach ($vocabularies as $vid => $vocabulary) {
             if ($vocabulary->name == $term->vocabulary_machine_name) {
                 $term->vid = $vocabulary->vid;
             }
         }
     }
     if (!isset($term->vid)) {
         // Try to load vocabulary by machine name.
         $vocabularies = \taxonomy_vocabulary_load_multiple(FALSE, array('machine_name' => $term->vocabulary_machine_name));
         if (!empty($vocabularies)) {
             $vids = array_keys($vocabularies);
             $term->vid = reset($vids);
         }
     }
     // If `parent` is set, look up a term in this vocab with that name.
     if (isset($term->parent)) {
         $parent = \taxonomy_get_term_by_name($term->parent, $term->vocabulary_machine_name);
         if (!empty($parent)) {
             $parent = reset($parent);
             $term->parent = $parent->tid;
         }
     }
     if (empty($term->vid)) {
         throw new \Exception(sprintf('No "%s" vocabulary found.'));
     }
     // Attempt to decipher any fields that may be specified.
     $this->expandEntityFields('taxonomy_term', $term);
     \taxonomy_term_save($term);
     return $term;
 }
Example #13
0
 /**
  * Delete a term in a given vocabulary.
  *
  * @param $term_name
  *  The name of the term.
  */
 public static function DeleteTerm($term_name)
 {
     $taxonomies = taxonomy_get_term_by_name($term_name);
     $term = reset($taxonomies);
     taxonomy_term_delete($term->tid);
 }
Example #14
0
function _panelize_gm_nodes(&$variables)
{
    if (isset($variables['node'])) {
        $node = $variables['node'];
        $gmCTs = array('good_practice' => 'Good Practices', 'structure' => 'Structures', 'method_tool' => 'Methods & Tools', 'resource' => 'Other resources');
        $gmTopicCTs = array('structure', 'method_tool', 'resource');
        if (array_key_exists($node->type, $gmCTs) && isset($node->field_topic) && isset($node->field_topic['und'][0])) {
            $tId = $node->field_topic['und'][0]['tid'];
            $nodeTopic = taxonomy_term_load($tId);
            $tcId = $nodeTopic->field_topic_category['und'][0]['tid'];
            $gmTopicTerm = taxonomy_get_term_by_name('Gender Mainstreaming', 'topics');
            reset($gmTopicTerm);
            $gmTopicTermId = key($gmTopicTerm);
            $gmTopicCategoryTerm = taxonomy_get_term_by_name('Gender Mainstreaming', 'topic_categories');
            reset($gmTopicCategoryTerm);
            $gmTopicCategoryTermId = key($gmTopicCategoryTerm);
            // only nodes with GM topic category (good practices) or GM topic (structures, methods & tools, resources) should be panelized
            if ($tcId != $gmTopicCategoryTermId || in_array($node->type, $gmTopicCTs) && $tId != $gmTopicTermId) {
                return;
            }
            $countryName = $node->field_country['und'][0]['safe_value'];
            $countryUrl = strtolower(str_replace(" ", "-", $countryName));
            $panes = array('about' => 'About', 'structures' => 'Structures', 'laws-and-policies' => 'Laws & Policies', 'methods-and-tools' => 'Methods & Tools', 'good-practices' => 'Good Practices', 'resources' => 'Other resources');
            $main_html_prefix = '<div class="page-gender-mainstreaming-countries panelized-gm-node">' . '<h1 class="title" id="page-title"><span class="country">' . $countryName . '</span> ' . $gmCTs[$node->type] . '</h1>' . '<div class="content-header">' . '<h2 class="element-invisible">Primary tabs</h2>' . '<ul class="button-group">';
            foreach ($panes as $paneUrl => $paneName) {
                $active = $paneName == $gmCTs[$node->type];
                $main_html_prefix .= '<li' . ($active ? ' class="active"' : '') . '><a class="small button secondary' . ($active ? ' active' : '') . '" href="/gender-mainstreaming/countries/' . $countryUrl . '/' . $paneUrl . '">' . $paneName . '' . ($active ? '<span class="element-invisible">(active tab)</span>' : '') . '</a></li>';
            }
            $main_html_prefix .= '</ul></div></div>';
            $variables['main_html_prefix'] = $main_html_prefix;
        }
    }
}
*/
?>
<!-- 	<b>Research Topics:</b>  -->
<?php 
// echo $result;
?>
<!-- <br> -->
<?php 
// }
?>

<?php 
$wrapper = entity_metadata_wrapper('node', $node);
foreach ($wrapper->field_people_spa as $i) {
    $values = $i->field_people_spa_title->value();
    $terms = taxonomy_get_term_by_name($i->field_people_spa_title->value());
    if (!empty($terms)) {
        $first_term = array_shift($terms);
        $first_term->tid;
    }
    $array_spa[] = "<a href=" . $base_url . "/taxonomy/term/" . rawurlencode(ucfirst($first_term->tid)) . ">" . ucfirst(trim($values)) . "</a>";
}
$result_spa = implode(", ", $array_spa);
if ($result_spa) {
    ?>
	<b>National Strategic Program Areas:</b>
	<?php 
    echo $result_spa;
    ?>
	<br>
<?php 
Example #16
0
/**
 * Adds story as a drupal node to our site.
 */
function newstory($head, $body, $taxonomy, $date, $data)
{
    global $mniblogpub_props;
    $cfg = $mniblogpub_props["mniblogpub.php"];
    // Check ContentType
    $pdf_file = null;
    if ($data['ContentType'] == "UUSTORY") {
        $pdf_file = move_pdf($body);
    }
    // Load data
    $author = loadAuthor();
    $format = loadFormat();
    $status = $cfg["node.status_published"] == 1;
    $codenums = array();
    $txttbl = 0;
    // Load taxonomy data
    foreach ($taxonomy as $key => $value) {
        $tt = $value;
        if ($cfg["node.taxonomy.load_from"] == "description") {
            $tt = tax_getHumanName_sql($value);
        }
        $theterm = taxonomy_get_term_by_name($tt);
        //if($value = "txttbl")
        //	$txttbl = "Text Table";
        foreach ($theterm as $mkey => $mvalue) {
            $codenums[] = $mvalue->tid;
        }
    }
    // Basic Data
    $node = array('type' => $cfg["node.type"], 'title' => $head, 'uid' => $cfg["user.use"] == 1 ? $author->uid : 3, 'name' => $cfg["user.use"] == 1 ? $author->name : 'mnieditor', 'status' => $status, 'comment' => $cfg["node.comments"] == 1 ? 2 : 0, 'promote' => 1, 'taxonomy' => $codenums, 'revision' => 1, 'format' => 1, 'body' => $data['ContentType'] == "UUSTORY" ? richbody($pdf_file) : $body);
    // Alacarte Specific
    if ($cfg["node.type"] == "alacarte_article") {
        $product_nid = newproduct($node, $data);
        $node['body'] = get_first_paragraph($body);
        $node['field_full_body'] = array(0 => array("value" => $body, "format" => $format));
        $node['field_product_nid'] = array(0 => array("value" => $product_nid));
        //$node['field_txttbl'] = array(0=> array("value" => $txttbl));
    }
    // Embargo specific
    if ($cfg["modules.mnembargo"] && module_exists('mnembargo')) {
        if ($data['mnembargo'] > 0) {
            $node['time_to_pub'] = $data['mnembargo'];
            $node['status'] = 0;
        }
    }
    // Expire Specific
    if ($cfg["modules.mnexpire"] && module_exists('mnexpire')) {
        $node['time_to_exp'] = $data['mnexpire'];
    }
    if ($format) {
        $node['format'] = $format;
    }
    if ($data['ContentType'] == "UUSTORY") {
        if ($cfg["rich.type"]) {
            $node['type'] = $cfg["rich.type"];
        }
        $node['format'] = 3;
    }
    $node = node_submit($node);
    // Final Changes
    if ($cfg["date.adjust"] == 1) {
        $node->created = intval($date);
        $node->changed = intval($date);
        if ($data['ContentType'] == "UUSTORY") {
            $node->files[$pdf_file->fid] = $pdf_file;
        }
    }
    // SAVE!
    node_save($node);
    $article_nid = $node->nid;
    //unset($node);
    // Aftermath
    if ($cfg["node.type"] == "alacarte_article") {
        set_uc_node_access_feature($product_nid, $article_nid);
    }
    return $node;
}
Example #17
0
 /**
  * Returns a unique term name that doesn't already exist.
  *
  * @param null|string $vocabulary_machine_name
  *   Vocabulary machine name if the term name is supposed to be unique in
  *   that vocabulary or NULL if the term name is supposed to be unique across
  *   all the vocabularies.
  *
  * @return string
  *   Unique term name.
  */
 public static function getUniqueName($vocabulary_machine_name = NULL)
 {
     do {
         $name = Utils::getRandomText(20);
         $terms = taxonomy_get_term_by_name($name, $vocabulary_machine_name);
     } while (sizeof($terms));
     return $name;
 }
Example #18
0
function user_get_proxy_list()
{
    $proxy_taxo_data = taxonomy_get_term_by_name('Carrefour Proxy');
    $proxy_ids = NULL;
    foreach ($proxy_taxo_data as $data) {
        $proxy_ids = $data->tid;
    }
    $proxy_child_ids = taxonomy_get_children($proxy_ids);
    $array_proxy = array();
    if (!empty($proxy_child_ids)) {
        foreach ($proxy_child_ids as $value) {
            $array_proxy[] = $value->tid;
        }
    }
    return $array_proxy;
}
  * and append 0.02 to longitude value in order to display properly in gmap view
  */
 if (!isset($coordinatesGroup[$coordinates[0] . $coordinates[1]])) {
     $coordinatesGroup[$coordinates[0] . $coordinates[1]] = 0;
 } else {
     $coordinatesGroup[$coordinates[0] . $coordinates[1]]++;
     $coordinates[1] = $coordinates[1] + 0.02 * $coordinatesGroup[$coordinates[0] . $coordinates[1]];
 }
 /*
  * marker text
  */
 $text = $row['field_first_name'] . $inlineDelim . $row['title'] . $paragraphDelim . $affiliationInfo . $paragraphDelim . implode($paragraphDelim, $groups);
 /*
  * get icon from taxonomy term
  */
 $term_tree = taxonomy_get_term_by_name($groups[0]);
 foreach ($term_tree as $term) {
     //var_dump($term);
     $icon = !empty($term) && !empty($term->field_marker_url) ? $term->field_marker_url['und']['0']['value'] : 'marker.png';
 }
 /*
  * markers options: https://developers.google.com/maps/documentation/javascript/reference?csw=1#MarkerOptions
  * markers icons: http://mabp.kiev.ua/2010/01/12/google-map-markers/
  */
 $icon_url = file_create_url(variable_get('file_public_path', conf_path() . '/files') . '/gmap3_markers/' . $icon);
 $markers[] = gmap3_tools_create_marker($coordinates[0], $coordinates[1], '', $text, array('icon' => $icon_url, 'group' => $groups[0]));
 /*
  * legend info
  */
 if (empty($legendInfo[$groups[0]])) {
     $legendInfo[$groups[0]] = array('iconUrl' => $icon_url, 'text' => $groups[0]);
$x = 0;
$numItems = count($wrapper->field_research_geography);
if ($numItems) {
    ?>
							<b>Geography:</b> <span class="rec-span">
							<?php 
    foreach ($wrapper->field_research_geography as $b => $i) {
        /*	$terms = taxonomy_get_term_by_name($i->field_state->value());
        			if (!empty($terms)) {
        			  $first_term = array_shift($terms);
        			  $first_term->tid;
        			}*/
        $values = $i->field_state->value();
        $numItems = count($values);
        foreach ($values as $key => $value) {
            $terms = taxonomy_get_term_by_name(trim($values[$key]->name));
            if (!empty($terms)) {
                $first_term = array_shift($terms);
                $first_term->tid;
            }
            $a = "<a href=" . $base_url . "/taxonomy/term/" . rawurlencode($first_term->tid) . ">" . ucfirst(trim($values[$key]->name)) . "</a>";
            echo $a;
            if ($x != $numItems) {
                echo ", ";
            }
            $x++;
        }
    }
    ?>
 
							</span><br>
$checked_plan = reset($memberships)->name;
if ($token == true) {
    $memberships = array_merge($special_memberships, $memberships);
    $checked_plan = reset($special_memberships)->membership_type_id;
}
?>

        <ul class="pure-g">
            <?php 
$num_of_plans = count($memberships);
?>
            <?php 
foreach ($memberships as $membership) {
    $plan_price_terms = taxonomy_get_term_by_name($membership->name, 'fitness_plan_price');
    $plan_price = reset($plan_price_terms);
    $plan_feature_parent = reset(taxonomy_get_term_by_name($membership->name, 'fitness_plan_features'));
    $plan_features = taxonomy_get_children($plan_feature_parent->tid, $plan_feature_parent->vid);
    $price = $plan_price->field_planprice['und'][0]['value'];
    if ($price <= 1) {
        $price = "Free";
    }
    ?>
                <li class="pure-u-1 pure-u-md-1-<?php 
    echo $num_of_plans > 3 ? '2 pure-u-lg-1-4' : '3';
    ?>
">
                    <label for="<?php 
    print $plan['d_plan']->m_plan_id;
    ?>
" class="form-item">
                        <input id="<?php 
 function tidFromTermName($field_name, $term)
 {
     $info = field_info_field($field_name);
     $vocab_machine_name = $info['settings']['allowed_values'][0]['vocabulary'];
     if ($found_terms = taxonomy_get_term_by_name($term, $vocab_machine_name)) {
         $found_term = reset($found_terms);
         return $found_term->tid;
     } else {
         return false;
     }
 }
Example #23
0
 /**
  * {@inheritDoc}
  */
 public function termCreate(\stdClass $term)
 {
     // Map vocabulary names to vid, these take precedence over machine names.
     if (!isset($term->vid)) {
         $vocabularies = \taxonomy_get_vocabularies();
         foreach ($vocabularies as $vid => $vocabulary) {
             if ($vocabulary->name == $term->vocabulary_machine_name) {
                 $term->vid = $vocabulary->vid;
             }
         }
     }
     if (!isset($term->vid)) {
         // Try to load vocabulary by machine name.
         $vocabularies = \taxonomy_vocabulary_load_multiple(FALSE, array('machine_name' => $term->vocabulary_machine_name));
         if (!empty($vocabularies)) {
             $vids = array_keys($vocabularies);
             $term->vid = reset($vids);
         }
     }
     // If `parent` is set, look up a term in this vocab with that name.
     if (isset($term->parent)) {
         $parent = \taxonomy_get_term_by_name($term->parent, $term->vocabulary_machine_name);
         if (!empty($parent)) {
             $parent = reset($parent);
             $term->parent = $parent->tid;
         }
     }
     if (empty($term->vid)) {
         throw new \Exception(sprintf('No "%s" vocabulary found.'));
     }
     \taxonomy_term_save($term);
     // Loading a term by name returns an array of term objects, but there should
     // only be one matching term in a testing context, so take the first match
     // by reset()'ing $matches.
     $matches = \taxonomy_get_term_by_name($term->name);
     $saved_term = reset($matches);
     return $saved_term;
 }
?>

<div id="node-<?php 
print $node->nid;
?>
" class="grid product-teaser text-center <?php 
print $classes;
?>
 clearfix"<?php 
print $attributes;
?>
>
    <div class="media_element clearfix">
        <figure>
            <?php 
$terms = taxonomy_get_term_by_name('New', 'product_characteristics');
if (!empty($terms)) {
    $first_term = array_shift($terms);
}
$sale = strip_tags(render($content['product:field_product_on_sale']));
if ($sale == 1) {
    print '<span class="onsale">Sale!</span>';
}
if (isset($node->field_characteristics['und'])) {
    $characters = $node->field_characteristics['und'];
    foreach ($characters as $key => $value) {
        if ($value['tid'] == $first_term->tid) {
            print '<span class="onnew">New!</span>';
        }
    }
}
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- Rounded Top Brick -->
    <div class="container-fluid brick rounded-top">
        <div class="row">
        <!--count the number of programs in search result-->
        <?php 
/*getting the term id from term name */
$term_array = taxonomy_get_term_by_name($_GET['interest1']);
$term = reset($term_array);
# get the first element of the array which is our term object
$arg1 = $term->tid;
$term_array = taxonomy_get_term_by_name($_GET['interest2']);
$term = reset($term_array);
$arg2 = $term->tid;
$view = views_get_view('ucgy_program_compare_view');
$view->set_display('block');
$view->set_arguments(array($arg1 . '+' . $arg2));
$current_student = _ucgy_programs_get_session('student');
$current_curriculum = _ucgy_programs_get_session('curriculum');
$view->exposed_input['field_requirement_student_type_target_id'] = $current_student;
$view->exposed_input['field_requirement_curriculum_target_id'] = $current_curriculum;
$view->execute();
$count = count($view->result);
?>
        <!-- Program List Brick (Large Tiles) -->
        <div class="container brick program-list">
            <div class="row header">
Example #26
0
 /**
  * @Then /^I create a new term "([^"]*)" under "([^"]*)" with quick form$/
  */
 public function iCreateNewTerm($term_name, $parent_term_name)
 {
     // Get parent term ID.
     $parent = taxonomy_get_term_by_name($parent_term_name);
     if (empty($parent)) {
         throw new \Exception("{$parent_term_name} is not a taxonomy term.");
     }
     $parent_id = key($parent);
     $steps = array();
     $steps[] = new Step\When('I fill in "name-' . $parent_id . '" with "' . $term_name . '"');
     $steps[] = new Step\When('I press "' . $parent_id . '"');
     return $steps;
 }