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;
     }
 }
示例#2
0
function jollyness_preprocess_html(&$vars)
{
    //Process portfolio color
    if ($portfolio_category = taxonomy_vocabulary_machine_name_load('portfolio_category')) {
        $terms = taxonomy_get_tree($portfolio_category->vid);
        $less = new lessc();
        $css = '';
        $color = '';
        $class = '';
        foreach ($terms as $t) {
            $term = taxonomy_term_load($t->tid);
            $class = drupal_html_class($t->name);
            if (!empty($term->field_color)) {
                foreach ($term->field_color as $v) {
                    $color = $v[0]['value'];
                    break;
                }
            }
            if ($color) {
                $css .= ".dexp-masonry-filter,.dexp-portfolio-filter{.{$class} span:before{background-color: {$color} !important;}}";
                $css .= ".{$class} .portfolio-item-overlay{background-color: rgba(red({$color}), green({$color}), blue({$color}), 0.7) !important;}";
            }
        }
        $css = $less->compile($css);
        drupal_add_css($css, array('type' => 'inline'));
    }
}
示例#3
0
function _bootstrap_theme_category_contents($vocab_name)
{
    global $user;
    //$contents = bootstrap_theme_get_category_contents(NODE_PUBLISHED, $user);
    $output = '';
    $myvoc = taxonomy_vocabulary_machine_name_load($vocab_name);
    $tree = taxonomy_get_tree($myvoc->vid);
    $depth = 0;
    $output .= '<div>Vocabulary terms under <a href="' . base_path() . 'category/' . $vocab_name . '" class="category-title">' . $myvoc->name . '</a>. Click on term you want to search content for.</div>
				<div style="float:right;"><a href="' . base_path() . '" class="btn btn-primary form-submit">Back</a></div><br>';
    $output .= '<ul>';
    foreach ($tree as $term) {
        if ($term->depth > $depth) {
            $output .= '<ul>';
            $depth = $term->depth;
        }
        if ($term->depth < $depth) {
            $output .= '</ul>';
            $depth = $term->depth;
        }
        //$output .= '<li>' . l($term->name, 'taxonomy/term/' . $term->tid) . '</li>';
        $output .= '<li>' . l($term->name, 'taxonomy/term/' . $term->tid) . "<br>";
        $output .= '<div>' . $term->description . '</div></li>';
    }
    $output .= '</ul>';
    return $output;
}
 /**
  * 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;
     }
 }
/**
 * Implements hook_draw_chart_alter().
 */
function hook_draw_chart_alter(&$settings)
{
    foreach ($settings as $chart) {
        if (isset($chart['chart']['chartCategory']) && !empty($chart['chart']['chartCategory'])) {
            // Geting the count result by vocabulary machine name.
            $voc = taxonomy_vocabulary_machine_name_load('categories');
            $tree = taxonomy_get_tree($voc->vid);
            $header = array();
            foreach ($tree as $term) {
                // Feeds the header with terms names.
                $header[] = $term->name;
                $query = db_select('taxonomy_index', 'ti');
                $query->condition('ti.tid', $term->tid, '=')->fields('ti', array('nid'));
                // Feeding the terms with the node count.
                $terms[] = $query->countQuery()->execute()->fetchField();
            }
            $columns = array('Content per category');
            $rows = array($terms);
            // Replacing the data of the chart.
            $chart['chart']['chartCategory']['header'] = $header;
            $chart['chart']['chartCategory']['rows'] = $rows;
            $chart['chart']['chartCategory']['columns'] = $columns;
            // Adding a colors attribute to the pie.
            $chart['chart']['chartCategory']['options']['colors'] = array('red', '#004411');
        }
    }
}
 /**
  * @param  \stdClass $config
  * @return array
  */
 protected function getTaxonomyTermsAsSelectOptions($config)
 {
     $answer = [];
     if (isset($config->vocabulary) && isset($config->level)) {
         /** @var \stdClass $vocabulary */
         if ($vocabulary = taxonomy_vocabulary_machine_name_load($config->vocabulary)) {
             $tree = $tree = taxonomy_get_tree($vocabulary->vid, 0, null, true);
             dpm($tree, "FLAT TREE");
             /*
             				if(count($terms) == 1) {
             					$term = array_pop($terms);
             					if(isset($term->description)) {
             						$answer = $term->description;
             						if($stripHtml) {
             							$answer = strip_tags($answer);
             						}
             					}
             				}*/
         } else {
             drupal_set_message("Vocabulary not found by name: " . $config->vocabulary, 'warning');
         }
     } else {
         drupal_set_message("Vocabulary or Level not set in config: " . json_encode($config), 'warning');
     }
     return $answer;
 }
 public function synchronize(NodeInterface $node, Context $context, $dirtyAllowed = false)
 {
     /* @var $node EntityNode */
     $machineName = $node->getBundle();
     $object = $node->getValue();
     if (!is_array($object)) {
         $object = [];
     }
     if (empty($object['description'])) {
         $description = '';
     } else {
         $description = $object['description'];
     }
     if ($node->isMerge() && ($existing = $this->getExistingObject($node, $context))) {
         $info = ['machine_name' => $machineName, 'description' => $description] + $object + $existing;
     } else {
         $info = ['machine_name' => $machineName, 'description' => $description] + $object + self::$defaults;
         if ($vocabulary = taxonomy_vocabulary_machine_name_load($machineName)) {
             // So an existing object is here, but the vid parameter is
             // actually never loaded (we don't want to export it when we
             // are building a yml file) - therefore we need to load it
             // once again. In case we didn't set the vid, the taxonomy
             // save method will attempt an SQL INSERT and cause bad SQL
             // STATE errors (constraint violation)
             $info['vid'] = $vocabulary->vid;
         }
     }
     if (empty($info['name'])) {
         $context->logWarning(sprintf('%s: has no name', $node->getPath()));
         $info['name'] = $machineName;
     }
     taxonomy_vocabulary_save((object) $info);
 }
 /**
  * Overrides DataProviderEntity::setPropertyValues().
  *
  * This class is created to override this method. This method is overridden to
  * add the vocabulary ID based on the vocabulary machine name when creating a
  * taxonomy term.
  */
 protected function setPropertyValues(\EntityDrupalWrapper $wrapper, $object, $replace = FALSE)
 {
     $term = $wrapper->value();
     if (empty($term->vid)) {
         $vocabulary = taxonomy_vocabulary_machine_name_load($term->vocabulary_machine_name);
         $term->vid = $vocabulary->vid;
     }
     parent::setPropertyValues($wrapper, $object, $replace);
 }
function getOptionsfrom($taxonomy)
{
    $terms = array();
    $myvoc = taxonomy_vocabulary_machine_name_load($taxonomy);
    $tree = taxonomy_get_tree($myvoc->vid);
    foreach ($tree as $term) {
        array_push($terms, $term->name);
    }
    return $terms;
}
 public function build()
 {
     if ($voc = taxonomy_vocabulary_machine_name_load($this->bundle)) {
         $voc->name = $this->label;
         $voc->description = $this->description;
     } else {
         $voc = (object) array('machine_name' => $this->bundle, 'name' => $this->label, 'description' => $this->description);
     }
     taxonomy_vocabulary_save($voc);
 }
  /**
   * Overrides \RestfulEntityBase::setPropertyValues().
   *
   * Set the "vid" property on new terms.
   */
  protected function setPropertyValues(EntityMetadataWrapper $wrapper, $null_missing_fields = FALSE) {
    $term = $wrapper->value();
    if (!empty($term->tid)) {
      return;
    }

    $vocabulary = taxonomy_vocabulary_machine_name_load($term->vocabulary_machine_name);
    $term->vid = $vocabulary->vid;

    parent::setPropertyValues($wrapper, $null_missing_fields);
  }
示例#12
0
function exploreworld_preprocess_page(&$vars)
{
    $voc = taxonomy_vocabulary_machine_name_load('travel_destinations');
    $taxonomy = taxonomy_get_tree($voc->vid);
    $items = array();
    foreach ($taxonomy as $row) {
        $items[] = $row->name;
    }
    $vars['custom_item_list'] = theme('custom_item_list', array('items' => $items));
    $obj = menu_get_object();
    if (is_object($obj)) {
        $vars['theme_hook_suggestions'][] = 'page__' . $obj->type;
    }
}
示例#13
0
function _create_vocabs()
{
    $new_vocabs = array('vocab_machine_name_1' => 'Human readable name 1', 'vocab_machine_name_2' => 'Human readable name 2', 'vocab_machine_name_3' => 'Human readable name 3');
    foreach ($new_vocabs as $vocab_name => $name) {
        if (!taxonomy_vocabulary_machine_name_load($vocab_name)) {
            $vocab = new stdClass();
            $vocab->name = $name;
            $vocab->machine_name = $vocab_name;
            taxonomy_vocabulary_save($vocab);
        }
        //if
    }
    //foreach
}
示例#14
0
function _taxonomy_options($machine_name, $default = '')
{
    $vocabulary = taxonomy_vocabulary_machine_name_load($machine_name);
    $tree = taxonomy_get_tree($vocabulary->vid);
    if (!empty($default)) {
        $options[0] = $default;
    } else {
        $options = array();
    }
    foreach ($tree as $item) {
        $options[$item->tid] = str_repeat('-', $item->depth) . $item->name;
    }
    return $options;
}
/**
 * Implements hook_analytics_dashboard().
 */
function hook_analytics_dashboard()
{
    $voc = taxonomy_vocabulary_machine_name_load('categories');
    $tree = taxonomy_get_tree($voc->vid);
    $header = array();
    foreach ($tree as $term) {
        $header[] = $term->name;
        $query = db_select('taxonomy_index', 'ti');
        $query->condition('ti.tid', $term->tid, '=')->fields('ti', array('nid'));
        $terms[] = $query->countQuery()->execute()->fetchField();
    }
    $columns = array('Ideas in category');
    $rows = array($terms);
    $settings = array();
    $settings['chart']['chartCategory'] = array('header' => $header, 'rows' => $rows, 'columns' => $columns, 'weight' => -10, 'chartType' => 'PieChart', 'options' => array('curveType' => "function", 'is3D' => TRUE, 'forceIFrame' => FALSE, 'title' => 'Ideas per category', 'width' => 500, 'height' => 300));
    return draw_chart($settings);
}
/**
 * Configure permissions.
 *
 * @todo this is here because I cannot add it inside module due to SQL error:
 * SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'module' cannot
 * be null.
 *
 * {@inheritdoc}
 */
function osha_configure_permissions()
{
    if ($role = user_role_load_by_name('administrator')) {
        $vocabularies = array('activity', 'article_types', 'esener', 'nace_codes', 'section', 'thesaurus', 'wiki_categories', 'workflow_status', 'publication_types', 'newsletter_sections');
        $permissions = array();
        foreach ($vocabularies as $voc_name) {
            if ($voc = taxonomy_vocabulary_machine_name_load($voc_name)) {
                $permissions[] = 'add terms in ' . $voc_name;
                $permissions[] = 'edit terms in ' . $voc->vid;
                $permissions[] = 'delete terms in ' . $voc->vid;
            }
        }
        $permissions[] = 'access workbench access by role';
        $permissions[] = 'translate taxonomy_term entities';
        $permissions[] = 'edit any content in rejected';
        $permissions[] = 'edit any content in approved';
        $permissions[] = 'edit any content in final_draft';
        $permissions[] = 'edit any content in to_be_approved';
        // Workbench access permissions.
        $moderated_types = workbench_moderation_moderate_node_types();
        $transitions = workbench_moderation_transitions();
        foreach ($transitions as $transition) {
            $permissions[] = "moderate content from {$transition->from_name} to {$transition->to_name}";
            foreach ($moderated_types as $node_type) {
                //@todo: $permissions[] = "moderate $node_type state from {$transition->from_name} to {$transition->to_name}";
            }
        }
        $permissions[] = 'create moderators_group entity collections';
        $permissions[] = 'edit moderators_group entity collections';
        $permissions[] = 'view moderators_group entity collections';
        $permissions[] = 'delete moderators_group entity collections';
        $permissions[] = 'add content to moderators_group entity collections';
        $permissions[] = 'manage content in moderators_group entity collections';
        user_role_grant_permissions($role->rid, $permissions);
        user_role_revoke_permissions($role->rid, array('use workbench_moderation needs review tab'));
    }
    $roles = array(OSHA_WORKFLOW_ROLE_TRANSLATION_MANAGER, OSHA_WORKFLOW_ROLE_TRANSLATION_LIAISON, OSHA_WORKFLOW_ROLE_LAYOUT_VALIDATOR, OSHA_WORKFLOW_ROLE_CONTENT_VALIDATOR);
    foreach ($roles as $role_name) {
        if ($role = user_role_load_by_name($role_name)) {
            user_role_grant_permissions($role->rid, array('access workbench'));
        }
    }
}
 /**
  *  Overrides \RestfulEntityBase::getList().
  */
 public function getList()
 {
     $list = parent::getList();
     $return = array();
     // Select vocabulary related.
     $vocabulary = taxonomy_vocabulary_machine_name_load($this->bundle);
     // Order according the taxonomy order.
     $tree = taxonomy_get_tree($vocabulary->vid);
     foreach ($tree as $term) {
         foreach ($list as $item) {
             if ($item['id'] == $term->tid) {
                 // Add extra properties.
                 $item['depth'] = $term->depth;
                 $return[] = $item;
                 break;
             }
         }
     }
     return $return;
 }
 /**
  * Define the HTML required for this filter's UI panel.
  */
 public function get_controls()
 {
     $r = '<div class="context-instruct messages warning">' . lang::get('Please note, you cannnot change this setting because of your access permissions in this context.') . '</div>';
     $r .= data_entry_helper::checkbox(array('label' => lang::get('Only include my records'), 'fieldname' => 'my_records'));
     $vocabulary = taxonomy_vocabulary_machine_name_load('hubs');
     $terms = entity_load('taxonomy_term', FALSE, array('vid' => $vocabulary->vid));
     // the hub is driven by a user field, stored as tid.
     $r .= '<fieldset><legend>' . lang::get('Members of Hub:') . '</legend>';
     $r .= "<p id=\"who-hub-instruct\">" . lang::get('Please note that this converts each Hub into a list of users associated with the Hub, and fetches the data created by those users.') . "</p>\n";
     $hubList = array();
     foreach ($terms as $term) {
         $hubList[] = array($term->tid, $term->name);
         // TODO Cache
         $query = new EntityFieldQuery();
         $query->entityCondition('entity_type', 'user')->fieldCondition('field_preferred_training_hub', 'tid', $term->tid);
         $result = $query->execute();
         // This gives us the CMS user ID: now convert to
         $userIDList = array();
         if (count($result) == 0) {
             $userIDList = array(-1);
         } else {
             $cmsUserIDs = array_keys($result['user']);
             foreach ($cmsUserIDs as $cmsUserID) {
                 $user_data = user_load($cmsUserID);
                 // TODO Making assumption about language
                 if (!empty($user_data->field_indicia_user_id['und'][0]['value'])) {
                     $userIDList[] = $user_data->field_indicia_user_id['und'][0]['value'];
                 }
             }
             if (count($userIDList) == 0) {
                 $userIDList = array(-1);
             }
         }
         $userIDList = array_unique($userIDList);
         data_entry_helper::$javascript .= "indiciaData.hub" . $term->tid . " = '" . implode(',', $userIDList) . "';\n";
         $r .= data_entry_helper::checkbox(array('label' => $term->name, 'fieldname' => 'hub' . $term->tid, 'helpText' => ($userIDList[0] == -1 ? 'No' : count($userIDList)) . lang::get(' users.')));
     }
     data_entry_helper::$javascript .= "indiciaData.hubList = " . json_encode($hubList) . ";\n";
     $r .= '</fieldset>';
     return $r;
 }
示例#19
0
 /**
  * Create a taxonomy term for a given vocabulary.
  *
  * @param string $vocabulary
  *    Vocabulary machine name.
  * @param string $name
  *    Term name.
  * @param string $parent
  *    Eventual parent name.
  *
  * @return object|bool
  *    Return new term object or FALSE.
  */
 public function createTaxonomyTerm($vocabulary, $name, $parent = NULL)
 {
     if ($vocabulary = taxonomy_vocabulary_machine_name_load($vocabulary)) {
         // Exit if term already exists for that vocabulary.
         $term = db_select('taxonomy_term_data', 't')->fields('t', array('tid'))->condition('t.name', $name)->condition('t.vid', $vocabulary->vid)->execute()->fetchAll(PDO::FETCH_COLUMN);
         if ($term) {
             return FALSE;
         }
         $values = array();
         $values['vocabulary_machine_name'] = $vocabulary->machine_name;
         $values['vid'] = $vocabulary->vid;
         $values['name'] = $name;
         if ($parent) {
             $parent_tid = (int) db_select('taxonomy_term_data', 't')->fields('t', array('tid'))->condition('t.name', $parent)->condition('t.vid', $vocabulary->vid)->execute()->fetchAll(PDO::FETCH_COLUMN);
             $values['parent'] = $parent_tid;
         }
         $entity = entity_create('taxonomy_term', $values);
         return entity_save('taxonomy_term', $entity);
     }
     return FALSE;
 }
 /**
  * Default constructor of the taxonomy term form. You should not be invoking
  * TaxonomyFormTerm directly. Create a form for your vocabulary that extends
  * TaxonomyFormTerm and invoke that. The access level has to be kept public
  * here because access level of parent class has to be match that of child
  * class.
  *
  * @param null|int $tid
  *   Taxonomy term id if a taxonomy term edit form is to be loaded. If a
  *   taxonomy term add form is to be created, then keep it empty.
  */
 public function __construct($tid = NULL)
 {
     $classname = get_called_class();
     $class = new \ReflectionClass($classname);
     $class_shortname = $class->getShortName();
     $vocabulary_name = Utils::makeSnakeCase(substr($class_shortname, 0, -4));
     if (!is_null($tid) && is_numeric($tid)) {
         // Tid is not null and is numeric.
         $term = taxonomy_term_load($tid);
         if ($term->vocabulary_machine_name == $vocabulary_name) {
             $this->vocabulary = taxonomy_vocabulary_machine_name_load($vocabulary_name);
             $base_path = "RedTest\\entities\\TaxonomyTerm\\";
             $class_fullname = $base_path . substr($class_shortname, 0, -4);
             $termObject = new $class_fullname($tid);
             $this->setEntityObject($termObject);
             $this->includeFile('inc', 'taxonomy', 'taxonomy.admin');
             parent::__construct('taxonomy_form_term', $term, $this->vocabulary);
             $this->setInitialized(TRUE);
             return;
         } else {
             // Vocabulary name of the provided term does not match the class it was called from. Return with a FAIL response.
             $this->setErrors("Vocabulary of the provided term does not match the class it was called from.");
             $this->setInitialized(FALSE);
             return;
         }
     } else {
         // Proper tid is not provided. Create a dummy term object.
         $base_path = "RedTest\\entities\\TaxonomyTerm\\";
         $class_fullname = $base_path . substr($class_shortname, 0, -4);
         $termObject = new $class_fullname();
         $this->setEntityObject($termObject);
     }
     // tid is not provided or is not numeric.
     $this->vocabulary = taxonomy_vocabulary_machine_name_load($vocabulary_name);
     $this->includeFile('inc', 'taxonomy', 'taxonomy.admin');
     parent::__construct('taxonomy_form_term', array(), $this->vocabulary);
     $this->setInitialized(TRUE);
 }
 /**
  * Overrides EntityReferenceHandler::getReferencableEntities().
  * @inheritdoc
  */
 public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0)
 {
     if ($match || $limit) {
         return parent::getReferencableEntities($match, $match_operator, $limit);
     }
     $options = array();
     $entity_type = $this->field['settings']['target_type'];
     // We imitate core by calling taxonomy_get_tree().
     $entity_info = entity_get_info('taxonomy_term');
     $bundles = !empty($this->field['settings']['handler_settings']['target_bundles']) ? $this->field['settings']['handler_settings']['target_bundles'] : array_keys($entity_info['bundles']);
     foreach ($bundles as $bundle) {
         if ($vocabulary = taxonomy_vocabulary_machine_name_load($bundle)) {
             if ($terms = taxonomy_get_tree($vocabulary->vid, 0)) {
                 foreach ($terms as $term) {
                     $context = array('entity' => $term);
                     od_entity_label_translate_factory::inst()->getTranslator('taxonomy_term', $context)->triggerEvent('pseudo_entity_load');
                     $options[$vocabulary->machine_name][$term->tid] = str_repeat('-', $term->depth) . check_plain($term->name);
                 }
             }
         }
     }
     return $options;
 }
示例#22
0
 /**
  * Perform a taxonomy_get_tree() for a given vocabulary.
  *
  * @param string $vocabulary_name
  *    Vocabulary machine name.
  * @param int $parent
  *    The term ID under which to generate the tree.
  *    If 0, generate the tree for the entire vocabulary.
  * @param int $max_depth
  *    Levels of the tree to return. Leave NULL to return all levels.
  * @param bool $load_entities
  *    If TRUE, a full entity load will occur on the term objects.
  *
  * @return array
  *    An array of all term objects in the tree.
  *
  * @see: taxonomy_get_tree().
  */
 public function getVocabularyTerms($vocabulary_name, $parent = 0, $max_depth = NULL, $load_entities = FALSE)
 {
     if ($vocabulary = taxonomy_vocabulary_machine_name_load($vocabulary_name)) {
         return taxonomy_get_tree($vocabulary->vid, $parent, $max_depth, $load_entities);
     } else {
         return array();
     }
 }
示例#23
0
         print " [" . $res['REASONEXIT'] . "]";
     }
 }
 print "</h3>";
 if (strlen($res['PERCLASS']) > 1) {
     print $res['PERCLASS'] . "<br>";
 }
 if (strlen($res['PERSTATUS']) > 1 and strlen($res['REASONEXIT']) < 1) {
     print $res['PERSTATUS'] . "<br>";
 }
 if (strlen($res['DEGREES']) > 1) {
     print "Academic qualification: " . $res['DEGREES'] . "<br>";
 }
 $ddccsss = $res['DDCCSSS'];
 $ppf = $res['PFNUM'];
 $vvvid = taxonomy_vocabulary_machine_name_load('circuits')->vid;
 if (strlen($ddccsss) == 7) {
     $circ = substr($ddccsss, 0, 4);
 } else {
     $circ = "0" . substr($ddccsss, 0, 3);
 }
 if ($vterms = taxonomy_get_tree($vvvid)) {
     foreach ($vterms as $vterm) {
         if (substr($vterm->name, 0, 4) == $circ) {
             $vlink = str_replace(" ", "-", strtolower($vterm->name));
             $vlink = str_replace("/", "", $vlink);
             $currentstation = "<a href=\"/circuit/{$vlink}\">" . $vterm->name . "</a>";
         }
     }
 }
 if ($circ == "0100") {
function cob_footer_links()
{
    $categories = taxonomy_vocabulary_machine_name_load('categories');
    echo '<h1>Services Directory</h1>';
    echo '<ul>';
    foreach (taxonomy_get_tree($categories->vid, 0, 1) as $t) {
        echo '<li>';
        echo l($t->name, 'taxonomy/term/' . $t->tid);
        echo '</li>';
    }
    echo '</ul>';
    ?>
        <h1>Transparency and Open Data</h1>
        <ul>
            <li><a href="https://data.bloomington.in.gov" target="_blank">B-Clear: Bloomington Open Data</a></li>
            <li><a href="http://www.in.gov/itp/" target="_blank">Indiana Transparency Portal</a></li>
        </ul>
    <?php 
}
示例#25
0
 public function getSourceLocale()
 {
     if ($this->entity_type == 'taxonomy_term') {
         $vocabulary = taxonomy_vocabulary_machine_name_load($this->vocabulary_machine_name);
         // If vocab uses 'Localize', change language from undefined to English.
         if ($vocabulary->i18n_mode == LINGOTEK_TAXONOMY_LOCALIZE_VALUE) {
             return 'en_US';
         }
     }
     return Lingotek::convertDrupal2Lingotek($this->language);
 }
示例#26
0
$_SERVER['REQUEST_METHOD'] = NULL;
$_SERVER['SERVER_SOFTWARE'] = 'KMS user-term export cli';
error_reporting(E_ERROR | E_PARSE);
require_once 'includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// Time and memory limits
set_time_limit(10000);
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;
 *   - $field->handler: The Views field handler object controlling this field. Do not use
 *     var_export to dump this object, as it can't handle the recursion.
 *   - $field->inline: Whether or not the field should be inline.
 *   - $field->inline_html: either div or span based on the above flag.
 *   - $field->wrapper_prefix: A complete wrapper containing the inline_html to use.
 *   - $field->wrapper_suffix: The closing tag for the wrapper.
 *   - $field->separator: an optional separator that may appear before a field.
 *   - $field->label: The wrap label text to use.
 *   - $field->label_html: The full HTML of the label to use including
 *     configured element type.
 * - $row: The raw result object from the query, with all data it fetched.
 *
 * @ingroup views_templates
 */
if ($fields['field_special_requirements_flag']->content != 1) {
    $tooltips_taxonomy = taxonomy_vocabulary_machine_name_load('tooltips');
    $tooltips = array();
    foreach (taxonomy_get_tree($tooltips_taxonomy->vid, 0, null, true) as $term) {
        $tooltips[$term->name] = array();
        if (!empty($term->description)) {
            $tooltips[$term->name]['tooltip'] = '<span onmouseover="ga(' . "'send','event','Admission requirements','Tooltip','" . $term->name . '\'); ga(' . "'secondTracker.send','event','Admission requirements','Tooltip','" . $term->name . '\');" data-toggle="tooltip" title="' . $term->description . '">
                      <span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></span>';
        }
        if (isset($term->field_replacement_label[LANGUAGE_NONE][0]['value'])) {
            $tooltips[$term->name]['label'] = $term->field_replacement_label[LANGUAGE_NONE][0]['value'];
        } else {
            $tooltips[$term->name]['label'] = $term->name;
        }
    }
    // If no tooltips are loaded, we still want to display the old labels...
    if (empty($tooltips)) {
示例#28
0
function get_token($token = NULL)
{
    if ($token == NULL) {
        return FALSE;
    }
    if ($vocabulary = taxonomy_vocabulary_machine_name_load("Tokens")) {
        $tree = taxonomy_get_tree($vocabulary->vid);
        foreach ($tree as $tokenTerm) {
            if ($tokenTerm->name == $token) {
                return taxonomy_term_load($tokenTerm->tid);
            }
        }
    }
    return FALSE;
}
?>
        </nav>
    </div>
</header>
<main    class="cob-portalMain" role="main">
    <div class="cob-portalMain-container">
        <div     class="cob-portalSidebar" id="taxonomy-term-<?php 
echo $term->tid;
?>
">
            <nav class="cob-portalSidebar-nav">
                <?php 
if (isset($term->parent)) {
    $siblings = taxonomy_get_children($term->parent->tid);
} else {
    $categories = taxonomy_vocabulary_machine_name_load('categories');
    $siblings = taxonomy_get_tree($categories->vid, 0, 1);
}
foreach ($siblings as $t) {
    $options = ['html' => true];
    if ($term->tid === $t->tid) {
        $options['attributes'] = ['class' => ['current']];
    }
    echo l("<span class=\"title\">{$t->name}</span><span class=\"description\">{$t->description}</span>", 'taxonomy/term/' . $t->tid, $options);
}
?>
            </nav>
        </div>
        <?php 
cob_include('term_nodes', ['term' => $term]);
?>
示例#30
0
function _get_vocab_id_from_taxon_field($bundle_name, $field_name)
{
    $fields = get_fields($bundle_name);
    foreach ($fields as $name => $field) {
        switch ($field['type']) {
            case 'taxonomy_term_reference':
                if ($name == $field_name) {
                    $vocab = taxonomy_vocabulary_machine_name_load($field['vocab']);
                    if (!empty($vocab)) {
                        return $vocab->vid;
                    }
                }
                break;
        }
    }
    return FALSE;
}