summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDries2012-11-22 16:03:57 (GMT)
committerDries2012-11-22 16:03:57 (GMT)
commit69a5eefd13d0f3166b95cb44045a00713e71e0e5 (patch)
tree5dae70569c02eeeff7677ab48073deecf426f24d
parent5cae761805f0638c23d3ea97e053eb5599154553 (diff)
Issue #1832778 by Schnitzel, ancamp, nagwani, YesCT, Lukas von Blarer, rvilar, Gábor Hojtsy: include translation operation in overviews for translatable entities.
-rw-r--r--core/modules/comment/comment.admin.inc7
-rw-r--r--core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php24
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php17
-rw-r--r--core/modules/node/node.admin.inc7
-rw-r--r--core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php44
-rw-r--r--core/modules/taxonomy/taxonomy.admin.inc13
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserTranslationUITest.php15
-rw-r--r--core/modules/user/user.admin.inc11
8 files changed, 129 insertions, 9 deletions
diff --git a/core/modules/comment/comment.admin.inc b/core/modules/comment/comment.admin.inc
index 26e9c8b..52d1740 100644
--- a/core/modules/comment/comment.admin.inc
+++ b/core/modules/comment/comment.admin.inc
@@ -136,6 +136,13 @@ function comment_admin_overview($form, &$form_state, $arg) {
'href' => 'comment/' . $comment->cid . '/edit',
'query' => $destination,
);
+ if (module_invoke('translation_entity', 'translate_access', $comment)) {
+ $links['translate'] = array(
+ 'title' => t('translate'),
+ 'href' => 'comment/' . $comment->cid . '/translations',
+ 'query' => $destination,
+ );
+ }
$options[$comment->cid]['operations']['data'] = array(
'#type' => 'operations',
'#links' => $links,
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php
index 75ca1d8..7dfb02e 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php
@@ -74,8 +74,11 @@ class CommentTranslationUITest extends EntityTranslationUITest {
/**
* Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::createEntity().
*/
- protected function createEntity($values, $langcode) {
- $node = $this->drupalCreateNode(array('type' => $this->nodeBundle));
+ protected function createEntity($values, $langcode, $node_bundle = NULL) {
+ if (!isset($node_bundle)) {
+ $node_bundle = $this->nodeBundle;
+ }
+ $node = $this->drupalCreateNode(array('type' => $node_bundle));
$values['nid'] = $node->nid;
$values['uid'] = $node->uid;
return parent::createEntity($values, $langcode);
@@ -92,4 +95,21 @@ class CommentTranslationUITest extends EntityTranslationUITest {
) + parent::getNewEntityValues($langcode);
}
+ /**
+ * Tests translate link on comment content admin page.
+ */
+ function testTranslateLinkCommentAdminPage() {
+ $this->admin_user = $this->drupalCreateUser(array('access administration pages', 'administer comments', 'translate any entity'));
+ $this->drupalLogin($this->admin_user);
+
+ $cid_translatable = $this->createEntity(array(), $this->langcodes[0], $this->nodeBundle);
+ $cid_untranslatable = $this->createEntity(array(), $this->langcodes[0], 'page');
+
+ // Verify translation links.
+ $this->drupalGet('admin/content/comment');
+ $this->assertResponse(200);
+ $this->assertLinkByHref('comment/' . $cid_translatable . '/translations');
+ $this->assertNoLinkByHref('comment/' . $cid_untranslatable . '/translations');
+ }
+
}
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php
index 5fda368..8cd5b49 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php
@@ -60,6 +60,23 @@ class NodeTranslationUITest extends EntityTranslationUITest {
}
/**
+ * Tests translate link on content admin page.
+ */
+ function testTranslateLinkContentAdminPage() {
+ $this->admin_user = $this->drupalCreateUser(array('access administration pages', 'access content overview', 'administer nodes', 'bypass node access'));
+ $this->drupalLogin($this->admin_user);
+
+ $page = $this->drupalCreateNode(array('type' => 'page'));
+ $article = $this->drupalCreateNode(array('type' => 'article'));
+
+ // Verify translation links.
+ $this->drupalGet('admin/content');
+ $this->assertResponse(200);
+ $this->assertLinkByHref('node/' . $article->nid . '/translations');
+ $this->assertNoLinkByHref('node/' . $page->nid . '/translations');
+ }
+
+ /**
* Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::getNewEntityValues().
*/
protected function getNewEntityValues($langcode) {
diff --git a/core/modules/node/node.admin.inc b/core/modules/node/node.admin.inc
index bca4dc2..e171b75 100644
--- a/core/modules/node/node.admin.inc
+++ b/core/modules/node/node.admin.inc
@@ -560,6 +560,13 @@ function node_admin_nodes() {
'query' => $destination,
);
}
+ if (module_invoke('translation_entity', 'enabled', 'node', $node->bundle())) {
+ $operations['translate'] = array(
+ 'title' => t('translate'),
+ 'href' => 'node/' . $node->nid . '/translations',
+ 'query' => $destination,
+ );
+ }
$options[$node->nid]['operations'] = array();
if (count($operations) > 1) {
// Render an unordered list of operations links.
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php
index 90982f4..ba9c152 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php
@@ -72,8 +72,11 @@ class TermTranslationUITest extends EntityTranslationUITest {
/**
* Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::createEntity().
*/
- protected function createEntity($values, $langcode) {
- $vocabulary = taxonomy_vocabulary_machine_name_load($this->bundle);
+ protected function createEntity($values, $langcode, $vocabulary_name = NULL) {
+ if (!isset($vocabulary_name)) {
+ $vocabulary_name = $this->bundle;
+ }
+ $vocabulary = taxonomy_vocabulary_machine_name_load($vocabulary_name);
$values['vid'] = $vocabulary->id();
return parent::createEntity($values, $langcode);
}
@@ -99,4 +102,41 @@ class TermTranslationUITest extends EntityTranslationUITest {
$this->assertEqual('taxonomy_term', $rows[0]->entity_type);
$this->assertEqual('taxonomy_term', $rows[1]->entity_type);
}
+
+ /**
+ * Tests translate link on vocabulary term list.
+ */
+ function testTranslateLinkVocabularyAdminPage() {
+ $this->admin_user = $this->drupalCreateUser(array('access administration pages', 'administer taxonomy', 'translate any entity'));
+ $this->drupalLogin($this->admin_user);
+
+ $translatable_vocabulary_name = taxonomy_vocabulary_machine_name_load($this->bundle)->name;
+ $translatable_tid = $this->createEntity(array(), $this->langcodes[0]);
+
+ // Create an untranslatable vocabulary.
+ $untranslatable_vocabulary = entity_create('taxonomy_vocabulary', array(
+ 'name' => 'untranslatable_voc',
+ 'description' => $this->randomName(),
+ 'machine_name' => 'untranslatable_voc',
+ 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'help' => '',
+ 'weight' => mt_rand(0, 10),
+ ));
+ taxonomy_vocabulary_save($untranslatable_vocabulary);
+
+ $untranslatable_vocabulary_name = $untranslatable_vocabulary->name;
+ $untranslatable_tid = $this->createEntity(array(), $this->langcodes[0], $untranslatable_vocabulary_name);
+
+ // Verify translation links.
+ $this->drupalGet('admin/structure/taxonomy/' . $translatable_vocabulary_name);
+ $this->assertResponse(200);
+ $this->assertLinkByHref('term/' . $translatable_tid . '/translations');
+ $this->assertLinkByHref('term/' . $translatable_tid . '/edit');
+
+ $this->drupalGet('admin/structure/taxonomy/' . $untranslatable_vocabulary_name);
+ $this->assertResponse(200);
+ $this->assertLinkByHref('term/' . $untranslatable_tid . '/edit');
+ $this->assertNoLinkByHref('term/' . $untranslatable_tid . '/translations');
+ }
+
}
diff --git a/core/modules/taxonomy/taxonomy.admin.inc b/core/modules/taxonomy/taxonomy.admin.inc
index 1a177ed..6a14e3c 100644
--- a/core/modules/taxonomy/taxonomy.admin.inc
+++ b/core/modules/taxonomy/taxonomy.admin.inc
@@ -249,7 +249,7 @@ function taxonomy_overview_terms($form, &$form_state, Vocabulary $vocabulary) {
}
}
}
-
+ $destination = drupal_get_destination();
// Build the actual form.
foreach ($current_page as $key => $term) {
// Save the term for the current page so we don't have to load it a second time.
@@ -285,9 +285,16 @@ function taxonomy_overview_terms($form, &$form_state, Vocabulary $vocabulary) {
);
}
$operations = array(
- 'edit' => array('title' => t('edit'), 'href' => 'taxonomy/term/' . $term->tid . '/edit', 'query' => drupal_get_destination()),
- 'delete' => array('title' => t('delete'), 'href' => 'taxonomy/term/' . $term->tid . '/delete', 'query' => drupal_get_destination()),
+ 'edit' => array('title' => t('edit'), 'href' => 'taxonomy/term/' . $term->tid . '/edit', 'query' => $destination),
+ 'delete' => array('title' => t('delete'), 'href' => 'taxonomy/term/' . $term->tid . '/delete', 'query' => $destination),
);
+ if (module_invoke('translation_entity', 'translate_access', $term)) {
+ $operations['translate'] = array(
+ 'title' => t('translate'),
+ 'href' => 'taxonomy/term/' . $term->tid . '/translations',
+ 'query' => $destination,
+ );
+ }
$form[$key]['operations'] = array(
'#type' => 'operations',
'#links' => $operations,
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserTranslationUITest.php b/core/modules/user/lib/Drupal/user/Tests/UserTranslationUITest.php
index ae5528f..1b6160a 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserTranslationUITest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserTranslationUITest.php
@@ -59,4 +59,19 @@ class UserTranslationUITest extends EntityTranslationUITest {
return array('name' => $this->name) + parent::getNewEntityValues($langcode);
}
+ /**
+ * Tests translate link on user admin list.
+ */
+ function testTranslateLinkUserAdminPage() {
+ $this->admin_user = $this->drupalCreateUser(array('access administration pages', 'administer users', 'translate any entity'));
+ $this->drupalLogin($this->admin_user);
+
+ $uid = $this->createEntity(array('name' => $this->randomName()), $this->langcodes[0]);
+
+ // Verify translation links.
+ $this->drupalGet('admin/people');
+ $this->assertResponse(200);
+ $this->assertLinkByHref('user/' . $uid . '/translations');
+ }
+
}
diff --git a/core/modules/user/user.admin.inc b/core/modules/user/user.admin.inc
index f4363cf..bab307b 100644
--- a/core/modules/user/user.admin.inc
+++ b/core/modules/user/user.admin.inc
@@ -192,11 +192,11 @@ function user_admin_account() {
);
$destination = drupal_get_destination();
-
$status = array(t('blocked'), t('active'));
$roles = array_map('check_plain', user_roles(TRUE));
$accounts = array();
foreach ($result as $account) {
+ $account = user_load($account->uid);
$users_roles = array();
$roles_result = db_query('SELECT rid FROM {users_roles} WHERE uid = :uid', array(':uid' => $account->uid));
foreach ($roles_result as $user_role) {
@@ -214,9 +214,16 @@ function user_admin_account() {
$links = array();
$links['edit'] = array(
'title' => t('edit'),
- 'href' => "user/$account->uid/edit",
+ 'href' => 'user/' . $account->uid . '/edit',
'query' => $destination,
);
+ if (module_invoke('translation_entity', 'translate_access', $account)) {
+ $links['translate'] = array(
+ 'title' => t('translate'),
+ 'href' => 'user/' . $account->uid . '/translations',
+ 'query' => $destination,
+ );
+ }
$options[$account->uid]['operations']['data'] = array(
'#type' => 'operations',
'#links' => $links,