Commit 1c4a00f3 authored by webchick's avatar webchick

Issue #1616972 by webflo, Schnitzel, Berdir, pfrenssen, gaspaio: Replace ->name with ->label().

parent b1d01493
......@@ -61,10 +61,10 @@ function hook_options_list($field, $instance, $entity_type, $entity) {
// 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']);
$terms = taxonomy_get_tree($tree['vid'], $tree['parent'], NULL, TRUE);
if ($terms) {
foreach ($terms as $term) {
$options[$term->tid] = str_repeat('-', $term->depth) . $term->name;
$options[$term->tid] = str_repeat('-', $term->depth) . $term->label();
}
}
}
......
......@@ -54,7 +54,7 @@
<div class="icon forum-status-<?php print $forum->icon_class; ?>" title="<?php print $forum->icon_title; ?>">
<span class="element-invisible"><?php print $forum->icon_title; ?></span>
</div>
<div class="name"><a href="<?php print $forum->link; ?>"><?php print $forum->name; ?></a></div>
<div class="name"><a href="<?php print $forum->link; ?>"><?php print $forum->label(); ?></a></div>
<?php if ($forum->description): ?>
<div class="description"><?php print $forum->description; ?></div>
<?php endif; ?>
......
......@@ -212,9 +212,9 @@ function forum_confirm_delete($form, &$form_state, $tid) {
$term = taxonomy_term_load($tid);
$form['tid'] = array('#type' => 'value', '#value' => $tid);
$form['name'] = array('#type' => 'value', '#value' => $term->name);
$form['name'] = array('#type' => 'value', '#value' => $term->label());
return confirm_form($form, t('Are you sure you want to delete the forum %name?', array('%name' => $term->name)), 'admin/structure/forum', t('Deleting a forum or container will also delete its sub-forums, if any. To delete posts in this forum, visit <a href="@content">content administration</a> first. This action cannot be undone.', array('@content' => url('admin/content'))), t('Delete'), t('Cancel'));
return confirm_form($form, t('Are you sure you want to delete the forum %label?', array('%label' => $term->label())), 'admin/structure/forum', t('Deleting a forum or container will also delete its sub-forums, if any. To delete posts in this forum, visit <a href="@content">content administration</a> first. This action cannot be undone.', array('@content' => url('admin/content'))), t('Delete'), t('Cancel'));
}
/**
......@@ -342,7 +342,7 @@ function _forum_parent_select($tid, $title, $child_type) {
}
$vid = config('forum.settings')->get('vocabulary');
$children = taxonomy_get_tree($vid, $tid);
$children = taxonomy_get_tree($vid, $tid, NULL, TRUE);
// A term can't be the child of itself, nor of its children.
foreach ($children as $child) {
......@@ -350,12 +350,12 @@ function _forum_parent_select($tid, $title, $child_type) {
}
$exclude[] = $tid;
$tree = taxonomy_get_tree($vid);
$tree = taxonomy_get_tree($vid, 0, NULL, TRUE);
$options[0] = '<' . t('root') . '>';
if ($tree) {
foreach ($tree as $term) {
if (!in_array($term->tid, $exclude)) {
$options[$term->tid] = str_repeat(' -- ', $term->depth) . $term->name;
$options[$term->tid] = str_repeat(' -- ', $term->depth) . $term->label();
}
}
}
......
......@@ -274,7 +274,7 @@ function forum_node_view(Node $node, $view_mode) {
if ($parents = taxonomy_term_load_parents_all($node->forum_tid)) {
$parents = array_reverse($parents);
foreach ($parents as $parent) {
$breadcrumb[] = l($parent->name, 'forum/' . $parent->tid);
$breadcrumb[] = l($parent->label(), 'forum/' . $parent->tid);
}
}
drupal_set_breadcrumb($breadcrumb);
......@@ -313,7 +313,7 @@ function forum_node_validate(Node $node, $form) {
':vid' => $term->vid,
))->fetchField();
if ($used && in_array($term->tid, $containers)) {
form_set_error('taxonomy_forums', t('The item %forum is a forum container, not a forum. Select one of the forums below instead.', array('%forum' => $term->name)));
form_set_error('taxonomy_forums', t('The item %forum is a forum container, not a forum. Select one of the forums below instead.', array('%forum' => $term->label())));
}
}
}
......@@ -802,7 +802,7 @@ function forum_forum_load($tid = NULL) {
// Load the tree below.
$forums = array();
$_forums = taxonomy_get_tree($vid, $tid);
$_forums = taxonomy_get_tree($vid, $tid, NULL, TRUE);
if (count($_forums)) {
$query = db_select('node', 'n');
......@@ -1081,10 +1081,10 @@ function template_preprocess_forums(&$variables) {
$variables['parents'] = array_reverse($variables['parents']);
foreach ($variables['parents'] as $p) {
if ($p->tid == $variables['tid']) {
$title = $p->name;
$title = $p->label();
}
else {
$breadcrumb[] = l($p->name, 'forum/' . $p->tid);
$breadcrumb[] = l($p->label(), 'forum/' . $p->tid);
}
}
}
......@@ -1152,7 +1152,7 @@ function template_preprocess_forum_list(&$variables) {
foreach ($variables['forums'] as $id => $forum) {
$variables['forums'][$id]->description = !empty($forum->description) ? filter_xss_admin($forum->description) : '';
$variables['forums'][$id]->link = url("forum/$forum->tid");
$variables['forums'][$id]->name = check_plain($forum->name);
$variables['forums'][$id]->name = check_plain($forum->label());
$variables['forums'][$id]->is_container = !empty($forum->container);
$variables['forums'][$id]->zebra = $row % 2 == 0 ? 'odd' : 'even';
$row++;
......
......@@ -142,10 +142,10 @@ function testTaxonomyTermRdfaAttributes() {
// Views the term and checks that the RDFa markup is correct.
$this->drupalGet('taxonomy/term/' . $term->tid);
$term_url = url('taxonomy/term/' . $term->tid);
$term_name = $term->name;
$term_rdfa_meta = $this->xpath('//meta[@typeof="skos:Concept" and @about=:term-url and contains(@property, "rdfs:label") and contains(@property, "skos:prefLabel") and @content=:term-name]', array(
$term_label = $term->label();
$term_rdfa_meta = $this->xpath('//meta[@typeof="skos:Concept" and @about=:term-url and contains(@property, "rdfs:label") and contains(@property, "skos:prefLabel") and @content=:term-label]', array(
':term-url' => $term_url,
':term-name' => $term_name,
':term-label' => $term_label,
));
$this->assertTrue(!empty($term_rdfa_meta), t('RDFa markup found on term page.'));
}
......
......@@ -755,7 +755,7 @@ function rdf_preprocess_taxonomy_term(&$variables) {
'about' => url('taxonomy/term/' . $term->tid),
'typeof' => $term->rdf_mapping['rdftype'],
'property' => $term->rdf_mapping['name']['predicates'],
'content' => $term->name,
'content' => $term->label(),
),
);
drupal_add_html_head($term_label_meta, 'rdf_term_label');
......
......@@ -153,12 +153,12 @@ public function save(array $form, array &$form_state) {
$status = taxonomy_term_save($term);
switch ($status) {
case SAVED_NEW:
drupal_set_message(t('Created new term %term.', array('%term' => $term->name)));
watchdog('taxonomy', 'Created new term %term.', array('%term' => $term->name), WATCHDOG_NOTICE, l(t('edit'), 'taxonomy/term/' . $term->tid . '/edit'));
drupal_set_message(t('Created new term %term.', array('%term' => $term->label())));
watchdog('taxonomy', 'Created new term %term.', array('%term' => $term->label()), WATCHDOG_NOTICE, l(t('edit'), 'taxonomy/term/' . $term->tid . '/edit'));
break;
case SAVED_UPDATED:
drupal_set_message(t('Updated term %term.', array('%term' => $term->name)));
watchdog('taxonomy', 'Updated term %term.', array('%term' => $term->name), WATCHDOG_NOTICE, l(t('edit'), 'taxonomy/term/' . $term->tid . '/edit'));
drupal_set_message(t('Updated term %term.', array('%term' => $term->label())));
watchdog('taxonomy', 'Updated term %term.', array('%term' => $term->label()), WATCHDOG_NOTICE, l(t('edit'), 'taxonomy/term/' . $term->tid . '/edit'));
// Clear the page and block caches to avoid stale data.
cache_invalidate(array('content' => TRUE));
break;
......
......@@ -126,7 +126,7 @@ function testTaxonomyTermFieldWidgets() {
field_attach_prepare_view('test_entity', $entities, 'full');
$entity->content = field_attach_view('test_entity', $entity, 'full');
$this->content = drupal_render($entity->content);
$this->assertText($term->name, 'Term name is displayed.');
$this->assertText($term->label(), 'Term label is displayed.');
// Delete the vocabulary and verify that the widget is gone.
taxonomy_vocabulary_delete($this->vocabulary->vid);
......
......@@ -157,7 +157,7 @@ function taxonomy_overview_terms($form, &$form_state, Vocabulary $vocabulary) {
$delta = 0;
$term_deltas = array();
$tree = taxonomy_get_tree($vocabulary->vid);
$tree = taxonomy_get_tree($vocabulary->vid, 0, NULL, TRUE);
$term = current($tree);
do {
// In case this tree is completely empty.
......@@ -248,7 +248,7 @@ function taxonomy_overview_terms($form, &$form_state, Vocabulary $vocabulary) {
unset($form[$key]['#term']['parents'], $term->parents);
}
$form[$key]['view'] = array('#type' => 'link', '#title' => $term->name, '#href' => "taxonomy/term/$term->tid");
$form[$key]['view'] = array('#type' => 'link', '#title' => $term->label(), '#href' => "taxonomy/term/$term->tid");
if ($vocabulary->hierarchy != TAXONOMY_HIERARCHY_MULTIPLE && count($tree) > 1) {
$form['#parent_fields'] = TRUE;
$form[$key]['tid'] = array(
......@@ -532,7 +532,7 @@ function taxonomy_term_add($vocabulary) {
* @ingroup forms
* @see taxonomy_term_confirm_delete_submit()
*/
function taxonomy_term_confirm_delete($form, &$form_state, $term) {
function taxonomy_term_confirm_delete($form, &$form_state, Term $term) {
// Always provide entity id in the same form key as in the entity edit form.
$form['tid'] = array('#type' => 'value', '#value' => $term->tid);
......@@ -543,7 +543,7 @@ function taxonomy_term_confirm_delete($form, &$form_state, $term) {
$form['delete'] = array('#type' => 'value', '#value' => TRUE);
return confirm_form($form,
t('Are you sure you want to delete the term %title?',
array('%title' => $term->name)),
array('%title' => $term->label())),
'admin/structure/taxonomy',
t('Deleting a term will delete all its children if there are any. This action cannot be undone.'),
t('Delete'),
......
......@@ -1052,13 +1052,13 @@ function taxonomy_implode_tags($tags, $vid = NULL) {
// Extract terms belonging to the vocabulary in question.
if (!isset($vid) || $tag->vid == $vid) {
// Make sure we have a completed loaded taxonomy term.
if (isset($tag->name)) {
if ($tag instanceof EntityInterface && $label = $tag->label()) {
// Commas and quotes in tag names are special cases, so encode 'em.
if (strpos($tag->name, ',') !== FALSE || strpos($tag->name, '"') !== FALSE) {
$typed_tags[] = '"' . str_replace('"', '""', $tag->name) . '"';
if (strpos($label, ',') !== FALSE || strpos($label, '"') !== FALSE) {
$typed_tags[] = '"' . str_replace('"', '""', $label) . '"';
}
else {
$typed_tags[] = $tag->name;
$typed_tags[] = $label;
}
}
}
......@@ -1243,7 +1243,7 @@ function taxonomy_field_formatter_view($entity_type, $entity, $field, $instance,
$uri = entity_uri('taxonomy_term', $term);
$element[$delta] = array(
'#type' => 'link',
'#title' => $term->name,
'#title' => $term->label(),
'#href' => $uri['path'],
'#options' => $uri['options'],
);
......@@ -1253,7 +1253,7 @@ function taxonomy_field_formatter_view($entity_type, $entity, $field, $instance,
case 'taxonomy_term_reference_plain':
foreach ($items as $delta => $item) {
$name = ($item['tid'] != 'autocreate' ? $item['taxonomy_term']->name : $item['name']);
$name = ($item['tid'] != 'autocreate' ? $item['taxonomy_term']->label() : $item['name']);
$element[$delta] = array(
'#markup' => check_plain($name),
);
......@@ -1264,7 +1264,7 @@ function taxonomy_field_formatter_view($entity_type, $entity, $field, $instance,
foreach ($items as $delta => $item) {
$entity->rss_elements[] = array(
'key' => 'category',
'value' => $item['tid'] != 'autocreate' ? $item['taxonomy_term']->name : $item['name'],
'value' => $item['tid'] != 'autocreate' ? $item['taxonomy_term']->label() : $item['name'],
'attributes' => array(
'domain' => $item['tid'] != 'autocreate' ? url('taxonomy/term/' . $item['tid'], array('absolute' => TRUE)) : '',
),
......@@ -1298,9 +1298,9 @@ function taxonomy_allowed_values($field, $instance, $entity_type, $entity) {
$options = array();
foreach ($field['settings']['allowed_values'] as $tree) {
if ($vocabulary = taxonomy_vocabulary_machine_name_load($tree['vocabulary'])) {
if ($terms = taxonomy_get_tree($vocabulary->vid, $tree['parent'])) {
if ($terms = taxonomy_get_tree($vocabulary->vid, $tree['parent'], NULL, TRUE)) {
foreach ($terms as $term) {
$options[$term->tid] = str_repeat('-', $term->depth) . $term->name;
$options[$term->tid] = str_repeat('-', $term->depth) . $term->label();
}
}
}
......@@ -1368,7 +1368,7 @@ function taxonomy_field_formatter_prepare_view($entity_type, $entities, $field,
* The term name to be used as the page title.
*/
function taxonomy_term_title(Term $term) {
return $term->name;
return $term->label();
}
/**
......
......@@ -17,7 +17,7 @@
*/
function taxonomy_term_page(Term $term) {
// Assign the term name as the page title.
drupal_set_title($term->name);
drupal_set_title($term->label());
// Build breadcrumb based on the hierarchy of the term.
$current = (object) array(
......@@ -28,12 +28,12 @@ function taxonomy_term_page(Term $term) {
$breadcrumb = array();
while ($parents = taxonomy_term_load_parents($current->tid)) {
$current = array_shift($parents);
$breadcrumb[] = l($current->name, 'taxonomy/term/' . $current->tid);
$breadcrumb[] = l($current->label(), 'taxonomy/term/' . $current->tid);
}
$breadcrumb[] = l(t('Home'), NULL);
$breadcrumb = array_reverse($breadcrumb);
drupal_set_breadcrumb($breadcrumb);
drupal_add_feed('taxonomy/term/' . $term->tid . '/feed', 'RSS - ' . $term->name);
drupal_add_feed('taxonomy/term/' . $term->tid . '/feed', 'RSS - ' . $term->label());
$build = array();
......@@ -69,7 +69,7 @@ function taxonomy_term_page(Term $term) {
*/
function taxonomy_term_feed(Term $term) {
$channel['link'] = url('taxonomy/term/' . $term->tid, array('absolute' => TRUE));
$channel['title'] = config('system.site')->get('name') . ' - ' . $term->name;
$channel['title'] = config('system.site')->get('name') . ' - ' . $term->label();
// Only display the description if we have a single term, to avoid clutter and confusion.
// HTML will be removed from feed description.
$channel['description'] = check_markup($term->description, $term->format, '', TRUE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment