Example #1
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'));
    }
}
 /**
  * @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;
 }
/**
 * 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');
        }
    }
}
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;
}
 /**
  * Implements \Drupal\block\BlockBase::blockBuild().
  */
 public function build()
 {
     static $vocabularies, $terms;
     $items = array();
     $faq_settings = \Drupal::config('faq.settings');
     if (!$faq_settings->get('use_categories')) {
         return;
     }
     $moduleHandler = \Drupal::moduleHandler();
     if ($moduleHandler->moduleExists('taxonomy')) {
         if (!isset($terms)) {
             $terms = array();
             $vocabularies = Vocabulary::loadMultiple();
             $vocab_omit = array_flip($faq_settings->get('omit_vocabulary'));
             $vocabularies = array_diff_key($vocabularies, $vocab_omit);
             foreach ($vocabularies as $vocab) {
                 foreach (taxonomy_get_tree($vocab->vid) as $term) {
                     if (FaqHelper::taxonomyTermCountNodes($term->tid)) {
                         $terms[$term->name] = $term->tid;
                     }
                 }
             }
         }
         if (count($terms) > 0) {
             foreach ($terms as $name => $tid) {
                 $items[] = l($name, 'faq-page/' . $tid);
             }
         }
     }
     return array('#theme' => 'item_list', '#items' => $items, '#list_type' => $faq_settings->get('category_listing'));
 }
 /**
  * Deletes all terms of a vocabulary.
  *
  * @param $vid
  *   int a vocabulary vid.
  */
 protected function deleteVocabularyTerms($vid)
 {
     $tids = array();
     foreach (taxonomy_get_tree($vid) as $term) {
         $tids[] = $term->tid;
     }
     entity_delete_multiple('taxonomy_term', $tids);
 }
function bootstrap_theme_get_taxonomy_vocabulary_category_options($taxonomy_vocabulary_id)
{
    $options = array();
    //$options[] = '<none>';
    foreach (taxonomy_get_tree($taxonomy_vocabulary_id) as $category) {
        $options[$category->tid] = $category->name;
    }
    return $options;
}
Example #8
0
function mis_theme_get_all_categories_array()
{
    $categories = taxonomy_get_tree(5);
    $catArray = null;
    foreach ($categories as $cat) {
        $catArray[] = taxonomy_term_load($cat->tid);
    }
    return $catArray;
}
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;
}
Example #10
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;
}
Example #11
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;
    }
}
/**
 * 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);
}
Example #13
0
 /**
  * Test a taxonomy with terms that have multiple parents of different depths.
  */
 function testTaxonomyVocabularyTree()
 {
     // Create a new vocabulary with 6 terms.
     $vocabulary = $this->createVocabulary();
     $term = array();
     for ($i = 0; $i < 6; $i++) {
         $term[$i] = $this->createTerm($vocabulary);
     }
     // $term[2] is a child of 1 and 5.
     $term[2]->parent = array($term[1]->id(), $term[5]->id());
     $term[2]->save();
     // $term[3] is a child of 2.
     $term[3]->parent = array($term[2]->id());
     $term[3]->save();
     // $term[5] is a child of 4.
     $term[5]->parent = array($term[4]->id());
     $term[5]->save();
     /**
      * Expected tree:
      * term[0] | depth: 0
      * term[1] | depth: 0
      * -- term[2] | depth: 1
      * ---- term[3] | depth: 2
      * term[4] | depth: 0
      * -- term[5] | depth: 1
      * ---- term[2] | depth: 2
      * ------ term[3] | depth: 3
      */
     // Count $term[1] parents with $max_depth = 1.
     $tree = taxonomy_get_tree($vocabulary->id(), $term[1]->id(), 1);
     $this->assertEqual(1, count($tree), 'We have one parent with depth 1.');
     // Count all vocabulary tree elements.
     $tree = taxonomy_get_tree($vocabulary->id());
     $this->assertEqual(8, count($tree), 'We have all vocabulary tree elements.');
     // Count elements in every tree depth.
     foreach ($tree as $element) {
         if (!isset($depth_count[$element->depth])) {
             $depth_count[$element->depth] = 0;
         }
         $depth_count[$element->depth]++;
     }
     $this->assertEqual(3, $depth_count[0], 'Three elements in taxonomy tree depth 0.');
     $this->assertEqual(2, $depth_count[1], 'Two elements in taxonomy tree depth 1.');
     $this->assertEqual(2, $depth_count[2], 'Two elements in taxonomy tree depth 2.');
     $this->assertEqual(1, $depth_count[3], 'One element in taxonomy tree depth 3.');
 }
 /**
  * {@inheritdoc}
  */
 public function getSettableOptions(AccountInterface $account = NULL)
 {
     if ($callback = $this->getSetting('options_list_callback')) {
         return call_user_func_array($callback, array($this->getFieldDefinition(), $this->getEntity()));
     } else {
         $options = array();
         foreach ($this->getSetting('allowed_values') as $tree) {
             if ($vocabulary = entity_load('taxonomy_vocabulary', $tree['vocabulary'])) {
                 if ($terms = taxonomy_get_tree($vocabulary->id(), $tree['parent'], NULL, TRUE)) {
                     foreach ($terms as $term) {
                         $options[$term->id()] = str_repeat('-', $term->depth) . $term->getName();
                     }
                 }
             }
         }
         return $options;
     }
 }
Example #15
0
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $term = $this->entity;
     $vocab_storage = $this->entityManager->getStorage('taxonomy_vocabulary');
     $vocabulary = $vocab_storage->load($term->bundle());
     $parent = array_keys(taxonomy_term_load_parents($term->id()));
     $form_state['taxonomy']['parent'] = $parent;
     $form_state['taxonomy']['vocabulary'] = $vocabulary;
     $language_configuration = $this->moduleHandler->moduleExists('language') ? language_get_default_configuration('taxonomy_term', $vocabulary->id()) : FALSE;
     $form['langcode'] = array('#type' => 'language_select', '#title' => $this->t('Language'), '#languages' => LanguageInterface::STATE_ALL, '#default_value' => $term->getUntranslated()->language()->id, '#access' => !empty($language_configuration['language_show']));
     $form['relations'] = array('#type' => 'details', '#title' => $this->t('Relations'), '#open' => $vocabulary->hierarchy == TAXONOMY_HIERARCHY_MULTIPLE, '#weight' => 10);
     // taxonomy_get_tree and taxonomy_term_load_parents may contain large
     // numbers of items so we check for taxonomy.settings:override_selector
     // before loading the full vocabulary. Contrib modules can then intercept
     // before hook_form_alter to provide scalable alternatives.
     if (!$this->config('taxonomy.settings')->get('override_selector')) {
         $parent = array_keys(taxonomy_term_load_parents($term->id()));
         $children = taxonomy_get_tree($vocabulary->id(), $term->id());
         // A term can't be the child of itself, nor of its children.
         foreach ($children as $child) {
             $exclude[] = $child->tid;
         }
         $exclude[] = $term->id();
         $tree = taxonomy_get_tree($vocabulary->id());
         $options = array('<' . $this->t('root') . '>');
         if (empty($parent)) {
             $parent = array(0);
         }
         foreach ($tree as $item) {
             if (!in_array($item->tid, $exclude)) {
                 $options[$item->tid] = str_repeat('-', $item->depth) . $item->name;
             }
         }
         $form['relations']['parent'] = array('#type' => 'select', '#title' => $this->t('Parent terms'), '#options' => $options, '#default_value' => $parent, '#multiple' => TRUE);
     }
     $form['relations']['weight'] = array('#type' => 'textfield', '#title' => $this->t('Weight'), '#size' => 6, '#default_value' => $term->getWeight(), '#description' => $this->t('Terms are displayed in ascending order by weight.'), '#required' => TRUE);
     $form['vid'] = array('#type' => 'value', '#value' => $vocabulary->id());
     $form['tid'] = array('#type' => 'value', '#value' => $term->id());
     if ($term->isNew()) {
         $form_state['redirect'] = current_path();
     }
     return parent::form($form, $form_state, $term);
 }
 /**
  * {@inheritdoc}
  */
 public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0)
 {
     if ($match || $limit) {
         return parent::getReferenceableEntities($match, $match_operator, $limit);
     }
     $options = array();
     $bundles = entity_get_bundles('taxonomy_term');
     $bundle_names = !empty($this->instance['settings']['handler_settings']['target_bundles']) ? $this->instance['settings']['handler_settings']['target_bundles'] : array_keys($bundles);
     foreach ($bundle_names as $bundle) {
         if ($vocabulary = entity_load('taxonomy_vocabulary', $bundle)) {
             if ($terms = taxonomy_get_tree($vocabulary->id(), 0, NULL, TRUE)) {
                 foreach ($terms as $term) {
                     $options[$vocabulary->id()][$term->id()] = str_repeat('-', $term->depth) . String::checkPlain($term->getName());
                 }
             }
         }
     }
     return $options;
 }
 /**
  *  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;
 }
Example #18
0
 /**
  * Tests the forum node pager for nodes with multiple grants per realm.
  */
 public function testForumPager()
 {
     // Look up the forums vocabulary ID.
     $vid = \Drupal::config('forum.settings')->get('vocabulary');
     $this->assertTrue($vid, 'Forum navigation vocabulary ID is set.');
     // Look up the general discussion term.
     $tree = taxonomy_get_tree($vid, 0, 1);
     $tid = reset($tree)->tid;
     $this->assertTrue($tid, 'General discussion term is found in the forum vocabulary.');
     // Create 30 nodes.
     for ($i = 0; $i < 30; $i++) {
         $this->drupalCreateNode(array('nid' => NULL, 'type' => 'forum', 'taxonomy_forums' => array(array('target_id' => $tid))));
     }
     // View the general discussion forum page. With the default 25 nodes per
     // page there should be two pages for 30 nodes, no more.
     $this->drupalLogin($this->web_user);
     $this->drupalGet('forum/' . $tid);
     $this->assertRaw('page=1');
     $this->assertNoRaw('page=2');
 }
Example #19
0
/**
 * Returns the list of options to be displayed for a field.
 *
 * Field types willing to enable one or several of the widgets defined in
 * options.module (select, radios/checkboxes, on/off checkbox) need to
 * implement this hook to specify the list of options to display in the
 * widgets.
 *
 * @param $field
 *   The field definition.
 * @param $instance
 *   (optional) The instance definition. The hook might be called without an
 *   $instance parameter in contexts where no specific instance can be targeted.
 *   It is recommended to only use instance level properties to filter out
 *   values from a list defined by field level properties.
 * @param $entity_type
 *   The entity type the field is attached to.
 * @param $entity
 *   The entity object the field is attached to, or NULL if no entity
 *   exists (e.g. in field settings page).
 *
 * @return
 *   The array of options for the field. Array keys are the values to be
 *   stored, and should be of the data type (string, number...) expected by
 *   the first 'column' for the field type. Array values are the labels to
 *   display within the widgets. The labels should NOT be sanitized,
 *   options.module takes care of sanitation according to the needs of each
 *   widget. The HTML tags defined in _field_filter_xss_allowed_tags() are
 *   allowed, other tags will be filtered.
 */
function hook_options_list($field, $instance, $entity_type, $entity)
{
    // Sample structure.
    $options = array(0 => t('Zero'), 1 => t('One'), 2 => t('Two'), 3 => t('Three'));
    // Sample structure with groups. Only one level of nesting is allowed. This
    // is only supported by the 'options_select' widget. Other widgets will
    // flatten the array.
    $options = array(t('First group') => array(0 => t('Zero')), t('Second group') => array(1 => t('One'), 2 => t('Two')), 3 => t('Three'));
    // In actual implementations, the array of options will most probably depend
    // on properties of the field. Example from taxonomy.module:
    $options = array();
    foreach ($field['settings']['allowed_values'] as $tree) {
        $terms = taxonomy_get_tree($tree['vid'], $tree['parent']);
        if ($terms) {
            foreach ($terms as $term) {
                $options[$term->tid] = str_repeat('-', $term->depth) . $term->name;
            }
        }
    }
    return $options;
}
 /**
  * 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;
 }
Example #21
0
function tac_admin($form, $form_state, $rid = NULL)
{
    $vocabularyObjects = taxonomy_get_vocabularies();
    $vocabularies = array(-1 => '[Select One]');
    foreach ($vocabularyObjects as $vocabularyObject) {
        $vocabularies[$vocabularyObject->vid] = $vocabularyObject->name;
    }
    $vocabulary = variable_get('tac_vocabulary', -1);
    $form = array();
    $form[] = array('vocabulary' => array('#type' => 'select', '#options' => $vocabularies, '#title' => t('Vocabulary to use for Access Control'), '#default_value' => $vocabulary));
    if ($vocabulary > 0) {
        $query = db_select('tac_map', 'm');
        $query->fields('m');
        $data = $query->execute()->fetchAll();
        $currentValues = array();
        foreach ($data as $row) {
            $currentValues[$row->rid][$row->tid] = $row;
        }
        $user_roles = user_roles();
        $role_permissions = user_role_permissions($user_roles);
        foreach ($user_roles as $rid => $role) {
            if ($rid == DRUPAL_ANONYMOUS_RID) {
                continue;
            }
            if (isset($role_permissions[$rid]['bypass node access']) && $role_permissions[$rid]['bypass node access']) {
                continue;
            }
            $subform = array('#theme' => 'tac_term_list', '#title' => 'Permissions for role "' . $role . '"');
            foreach (taxonomy_get_tree($vocabulary) as $term) {
                $subform['term_' . $term->tid] = array('#title' => $term->name, 'list' => array('#parents' => array('edit', $rid, $term->tid, 'list'), '#type' => 'checkbox', '#default_value' => isset($currentValues[$rid][$term->tid]->grant_list) ? $currentValues[$rid][$term->tid]->grant_list : 0), 'create' => array('#parents' => array('edit', $rid, $term->tid, 'create'), '#type' => 'checkbox', '#default_value' => isset($currentValues[$rid][$term->tid]->grant_create) ? $currentValues[$rid][$term->tid]->grant_create : 0), 'update' => array('#parents' => array('edit', $rid, $term->tid, 'update'), '#type' => 'checkbox', '#default_value' => isset($currentValues[$rid][$term->tid]->grant_update) ? $currentValues[$rid][$term->tid]->grant_update : 0), 'delete' => array('#parents' => array('edit', $rid, $term->tid, 'delete'), '#type' => 'checkbox', '#default_value' => isset($currentValues[$rid][$term->tid]->grant_delete) ? $currentValues[$rid][$term->tid]->grant_delete : 0));
            }
            $form['role' . $rid] = $subform;
        }
    }
    $form[] = array('#type' => 'submit', '#value' => t('Submit'));
    return $form;
}
        </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]);
?>
    </div>
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 
}
Example #24
0
    }
}
$sel2 = "SELECT pms_history.DDCCSSS,pms_history.YEAR as yy from pms_history,pms_pers where pfno=pfnum and pfno='" . $ppf . "' and pms_history.DDCCSSS<>0 order by yy DESC";
$sql2 = mysql_query($sel2);
$enyr = "";
$styr = "";
$curcirc = "";
$history = "";
while ($res2 = mysql_fetch_array($sql2, MYSQL_ASSOC)) {
    $ddccsss2 = $res2['DDCCSSS'];
    if (strlen($ddccsss2) == 7) {
        $circ2 = substr($ddccsss2, 0, 4);
    } else {
        $circ2 = "0" . substr($ddccsss2, 0, 3);
    }
    if ($vterms2 = taxonomy_get_tree($vvvid)) {
        foreach ($vterms2 as $vterm2) {
            if (substr($vterm2->name, 0, 4) == $circ2) {
                $vlink2 = str_replace(" ", "-", strtolower($vterm2->name));
                $vlink2 = str_replace("/", "", $vlink2);
                $neatlink = "<a href=\"/circuit/{$vlink2}\">" . $vterm2->name . "</a>";
                //print $res2['yy'] . " " . $neatlink . "<br>";
            }
        }
    }
    if ($circ2 == "0100") {
        $neatlink = "<a href=\"/districts/cape-of-good-hope\">0100 CAPE OF GOOD HOPE DISTRICT</a>";
    } elseif ($circ2 == "0200") {
        $neatlink = "<a href=\"/districts/grahamstown\">0200 GRAHAMSTOWN DISTRICT</a>";
    } elseif ($circ2 == "0300") {
        $neatlink = "<a href=\"/districts/queenstown\">0300 QUEENSTOWN DISTRICT</a>";
Example #25
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();
     }
 }
Example #26
0
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;
        }
        $txt .= '", "' . $item->tid . '"' . "\n";
Example #27
0
    </div>

    <div id="log-wrapper" class="right-wrapper">
      <?php 
print work_log_view($node->nid);
?>
    </div>

    <div style="clear:both"></div><br /><br />
  </div>

<!-- POPUP DIVS --->

<div id="node-status-div">
  <?php 
$terms = taxonomy_get_tree(2);
foreach ($terms as $t) {
    if ($t->tid != 8) {
        print "<a href='#'\r\n                  onclick=' jQuery(\"#node-status-div\").hide();\r\n                            jQuery(\"#node-status\").html(\"{$t->name}\");\r\n                            jQuery.post(\"/stories/update-status/{$node->nid}/{$t->tid}\", function(){work_log.update_log({$node->nid});})'>\r\n                  {$t->name}\r\n               </a>\n";
    }
}
?>
</div>

<div id="node-assign-to-div">
  <?php 
foreach ($node->field_users['und'] as $u) {
    $assign_user = user_load($u['uid']);
    print " <a  href='#'\r\n                    onclick=' jQuery(\"#node-assign-to-div\").hide();\r\n                              jQuery(\"#node-assigned-to\").html(\"{$assign_user->name}\");\r\n                              jQuery.post(\"/stories/update-assigned/{$node->nid}/{$assign_user->uid}\", function(){work_log.update_log({$node->nid});})'>\r\n                    {$assign_user->name}\r\n                </a>\n";
}
?>
Example #28
0
 /**
  * Save, edit and delete a term using the user interface.
  */
 function testTermReorder()
 {
     $this->createTerm($this->vocabulary);
     $this->createTerm($this->vocabulary);
     $this->createTerm($this->vocabulary);
     // Fetch the created terms in the default alphabetical order, i.e. term1
     // precedes term2 alphabetically, and term2 precedes term3.
     \Drupal::entityManager()->getStorage('taxonomy_term')->resetCache();
     list($term1, $term2, $term3) = taxonomy_get_tree($this->vocabulary->id(), 0, NULL, TRUE);
     $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview');
     // Each term has four hidden fields, "tid:1:0[tid]", "tid:1:0[parent]",
     // "tid:1:0[depth]", and "tid:1:0[weight]". Change the order to term2,
     // term3, term1 by setting weight property, make term3 a child of term2 by
     // setting the parent and depth properties, and update all hidden fields.
     $edit = array('terms[tid:' . $term2->id() . ':0][term][tid]' => $term2->id(), 'terms[tid:' . $term2->id() . ':0][term][parent]' => 0, 'terms[tid:' . $term2->id() . ':0][term][depth]' => 0, 'terms[tid:' . $term2->id() . ':0][weight]' => 0, 'terms[tid:' . $term3->id() . ':0][term][tid]' => $term3->id(), 'terms[tid:' . $term3->id() . ':0][term][parent]' => $term2->id(), 'terms[tid:' . $term3->id() . ':0][term][depth]' => 1, 'terms[tid:' . $term3->id() . ':0][weight]' => 1, 'terms[tid:' . $term1->id() . ':0][term][tid]' => $term1->id(), 'terms[tid:' . $term1->id() . ':0][term][parent]' => 0, 'terms[tid:' . $term1->id() . ':0][term][depth]' => 0, 'terms[tid:' . $term1->id() . ':0][weight]' => 2);
     $this->drupalPostForm(NULL, $edit, t('Save'));
     \Drupal::entityManager()->getStorage('taxonomy_term')->resetCache();
     $terms = taxonomy_get_tree($this->vocabulary->id());
     $this->assertEqual($terms[0]->tid, $term2->id(), 'Term 2 was moved above term 1.');
     $this->assertEqual($terms[1]->parents, array($term2->id()), 'Term 3 was made a child of term 2.');
     $this->assertEqual($terms[2]->tid, $term1->id(), 'Term 1 was moved below term 2.');
     $this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview', array(), t('Reset to alphabetical'));
     // Submit confirmation form.
     $this->drupalPostForm(NULL, array(), t('Reset to alphabetical'));
     // Ensure form redirected back to overview.
     $this->assertUrl('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview');
     \Drupal::entityManager()->getStorage('taxonomy_term')->resetCache();
     $terms = taxonomy_get_tree($this->vocabulary->id(), 0, NULL, TRUE);
     $this->assertEqual($terms[0]->id(), $term1->id(), 'Term 1 was moved to back above term 2.');
     $this->assertEqual($terms[1]->id(), $term2->id(), 'Term 2 was moved to back below term 1.');
     $this->assertEqual($terms[2]->id(), $term3->id(), 'Term 3 is still below term 2.');
     $this->assertEqual($terms[2]->parents, array($term2->id()), 'Term 3 is still a child of term 2.');
 }
 *   - $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)) {
        $tooltips[$fields['field_program_curriculum_min_ave']->label]['label'] = $fields['field_program_curriculum_min_ave']->label;
        $tooltips[$fields['field_program_required_courses']->label]['label'] = $fields['field_program_required_courses']->label;
Example #30
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;
}