本文整理汇总了PHP中taxonomy_vocabulary_machine_name_load函数的典型用法代码示例。如果您正苦于以下问题:PHP taxonomy_vocabulary_machine_name_load函数的具体用法?PHP taxonomy_vocabulary_machine_name_load怎么用?PHP taxonomy_vocabulary_machine_name_load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了taxonomy_vocabulary_machine_name_load函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: checkTerms
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;
}
}
开发者ID:rochester-rcl,项目名称:rcl-seward-transformations,代码行数:25,代码来源:letter_node_generator.php
示例2: jollyness_preprocess_html
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'));
}
}
开发者ID:antoniodltm,项目名称:pinolguitars,代码行数:27,代码来源:template.php
示例3: _bootstrap_theme_category_contents
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;
}
开发者ID:episolve,项目名称:clasnetworkdev,代码行数:27,代码来源:page.category.php
示例4: prepare
/**
* 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;
}
}
开发者ID:Gizra,项目名称:negawatt-server,代码行数:42,代码来源:NegawattMeterCategoryTermsBase.php
示例5: hook_draw_chart_alter
/**
* 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');
}
}
}
开发者ID:LandPotential,项目名称:LandPKS_dev.landpotential.org_v2,代码行数:30,代码来源:google_chart_tools.api.php
示例6: getTaxonomyTermsAsSelectOptions
/**
* @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;
}
开发者ID:adamjakab,项目名称:D7WebformEnhancer,代码行数:30,代码来源:WebformEnhancer.php
示例7: synchronize
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);
}
开发者ID:makinacorpus,项目名称:drupal-usync,代码行数:33,代码来源:VocabularyEntityLoader.php
示例8: setPropertyValues
/**
* 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);
}
开发者ID:jhoffman-tm,项目名称:waldorf-deployment,代码行数:16,代码来源:DataProviderTaxonomyTerm.php
示例9: getOptionsfrom
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;
}
开发者ID:nwpointer,项目名称:facultymodule,代码行数:10,代码来源:utilityFucntions.php
示例10: build
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);
}
开发者ID:wesnick,项目名称:drupal-bootstrap,代码行数:10,代码来源:VocabularyBuilder.php
示例11: setPropertyValues
/**
* 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);
}
开发者ID:humanitarianresponse,项目名称:site,代码行数:16,代码来源:RestfulEntityBaseTaxonomyTerm.php
示例12: exploreworld_preprocess_page
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;
}
}
开发者ID:tarasbondar,项目名称:drupallocal,代码行数:14,代码来源:template.php
示例13: _create_vocabs
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
}
开发者ID:sandramchung,项目名称:drupalshortcuts,代码行数:14,代码来源:taxonomy.php
示例14: _taxonomy_options
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;
}
开发者ID:defrox,项目名称:bikespain,代码行数:14,代码来源:node--productos.tpl.php
示例15: hook_analytics_dashboard
/**
* 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);
}
开发者ID:LandPotential,项目名称:LandPKS_dev.landpotential.org_v2,代码行数:20,代码来源:analytics_dashboard.api.php
示例16: osha_configure_permissions
/**
* 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'));
}
}
}
开发者ID:enriquesanchezhernandez,项目名称:campaigns,代码行数:52,代码来源:post-update.php
示例17: getList
/**
* 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;
}
开发者ID:Gizra,项目名称:negawatt-server,代码行数:23,代码来源:NegawattTaxonomyTermMeterCategory.class.php
示例18: get_controls
/**
* 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;
}
开发者ID:Indicia-Team,项目名称:CoCoast,代码行数:44,代码来源:cocoast_dynamic_report_explorer.php
示例19: createTaxonomyTerm
/**
* 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;
}
开发者ID:kimlop,项目名称:platform-dev,代码行数:34,代码来源:Config.php
示例20: __construct
/**
* 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);
}
开发者ID:redcrackle,项目名称:redtest-core,代码行数:49,代码来源:TaxonomyFormTerm.php
注:本文中的taxonomy_vocabulary_machine_name_load函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论