Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
317
Merge Requests
317
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
117a617b
Commit
117a617b
authored
Jan 25, 2013
by
webchick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#1896268
by tim.plunkett: Add Views integration for translation_entity().
parent
f464f8ee
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
315 additions
and
0 deletions
+315
-0
core/modules/comment/comment.views.inc
core/modules/comment/comment.views.inc
+11
-0
core/modules/node/node.views.inc
core/modules/node/node.views.inc
+11
-0
core/modules/taxonomy/taxonomy.views.inc
core/modules/taxonomy/taxonomy.views.inc
+11
-0
core/modules/translation_entity/lib/Drupal/translation_entity/Plugin/views/field/TranslationLink.php
...translation_entity/Plugin/views/field/TranslationLink.php
+90
-0
core/modules/translation_entity/lib/Drupal/translation_entity/Tests/Views/TranslationLinkTest.php
...al/translation_entity/Tests/Views/TranslationLinkTest.php
+76
-0
core/modules/translation_entity/tests/modules/translation_entity_test_views/test_views/views.view.test_entity_translations_link.yml
...s/test_views/views.view.test_entity_translations_link.yml
+96
-0
core/modules/translation_entity/tests/modules/translation_entity_test_views/translation_entity_test_views.info
...tion_entity_test_views/translation_entity_test_views.info
+8
-0
core/modules/translation_entity/tests/modules/translation_entity_test_views/translation_entity_test_views.module
...on_entity_test_views/translation_entity_test_views.module
+1
-0
core/modules/user/user.views.inc
core/modules/user/user.views.inc
+11
-0
No files found.
core/modules/comment/comment.views.inc
View file @
117a617b
...
...
@@ -376,6 +376,17 @@ function comment_views_data() {
),
);
// Entity translation field.
if
(
drupal_container
()
->
get
(
'module_handler'
)
->
moduleExists
(
'translation_entity'
))
{
$data
[
'comment'
][
'translation_link'
]
=
array
(
'title'
=>
t
(
'Translation link'
),
'help'
=>
t
(
'Provide a link to the translations overview for comments.'
),
'field'
=>
array
(
'id'
=>
'translation_entity_link'
,
),
);
}
// node_comment_statistics table
// define the group
...
...
core/modules/node/node.views.inc
View file @
117a617b
...
...
@@ -226,6 +226,17 @@ function node_views_data() {
);
}
// Entity translation field.
if
(
drupal_container
()
->
get
(
'module_handler'
)
->
moduleExists
(
'translation_entity'
))
{
$data
[
'node'
][
'translation_link'
]
=
array
(
'title'
=>
t
(
'Translation link'
),
'help'
=>
t
(
'Provide a link to the translations overview for nodes.'
),
'field'
=>
array
(
'id'
=>
'translation_entity_link'
,
),
);
}
// Define some fields based upon views_handler_field_entity in the entity
// table so they can be re-used with other query backends.
// @see views_handler_field_entity
...
...
core/modules/taxonomy/taxonomy.views.inc
View file @
117a617b
...
...
@@ -176,6 +176,17 @@ function taxonomy_views_data() {
),
);
// Entity translation field.
if
(
drupal_container
()
->
get
(
'module_handler'
)
->
moduleExists
(
'translation_entity'
))
{
$data
[
'taxonomy_term_data'
][
'translation_link'
]
=
array
(
'title'
=>
t
(
'Translation link'
),
'help'
=>
t
(
'Provide a link to the translations overview for taxonomy terms.'
),
'field'
=>
array
(
'id'
=>
'translation_entity_link'
,
),
);
}
// taxonomy_index table
$data
[
'taxonomy_index'
][
'table'
][
'group'
]
=
t
(
'Taxonomy term'
);
...
...
core/modules/translation_entity/lib/Drupal/translation_entity/Plugin/views/field/TranslationLink.php
0 → 100644
View file @
117a617b
<?php
/**
* @file
* Contains \Drupal\translation_entity\Plugin\views\field\TranslationLink.
*/
namespace
Drupal\translation_entity\Plugin\views\field
;
use
Drupal\views\Plugin\views\field\FieldPluginBase
;
use
Drupal\Core\Annotation\Plugin
;
use
Drupal\Core\Entity\EntityInterface
;
/**
* Provides a translation link for an entity.
*
* @ingroup views_field_handlers
*
* @Plugin(
* id = "translation_entity_link",
* module = "translation_entity"
* )
*/
class
TranslationLink
extends
FieldPluginBase
{
/**
* Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::defineOptions().
*/
protected
function
defineOptions
()
{
$options
=
parent
::
defineOptions
();
$options
[
'text'
]
=
array
(
'default'
=>
''
,
'translatable'
=>
TRUE
);
return
$options
;
}
/**
* Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::buildOptionsForm().
*/
public
function
buildOptionsForm
(
&
$form
,
&
$form_state
)
{
$form
[
'text'
]
=
array
(
'#type'
=>
'textfield'
,
'#title'
=>
t
(
'Text to display'
),
'#default_value'
=>
$this
->
options
[
'text'
],
);
parent
::
buildOptionsForm
(
$form
,
$form_state
);
}
/**
* Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::render().
*/
function
render
(
$values
)
{
return
$this
->
render_link
(
$this
->
get_entity
(
$values
),
$values
);
}
/**
* Alters the field to render a link.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity being rendered.
* @param \stdClass $values
* The current row of the views result.
*
* @return string
* The acutal rendered text (without the link) of this field.
*/
public
function
render_link
(
EntityInterface
$entity
,
\
stdClass
$values
)
{
if
(
translation_entity_translate_access
(
$entity
))
{
$text
=
!
empty
(
$this
->
options
[
'text'
])
?
$this
->
options
[
'text'
]
:
t
(
'translate'
);
$this
->
options
[
'alter'
][
'make_link'
]
=
TRUE
;
$uri
=
$entity
->
uri
();
$this
->
options
[
'alter'
][
'path'
]
=
$uri
[
'path'
]
.
'/translations'
;
return
$text
;
}
}
/**
* Overrides \Drupal\views\Plugin\views\Plugin\field\FieldPluginBase::query().
*/
public
function
query
()
{
}
/**
* Overrides \Drupal\views\Plugin\views\Plugin\field\FieldPluginBase::click_sortable().
*/
public
function
click_sortable
()
{
return
FALSE
;
}
}
core/modules/translation_entity/lib/Drupal/translation_entity/Tests/Views/TranslationLinkTest.php
0 → 100644
View file @
117a617b
<?php
/**
* @file
* Contains \Drupal\translation_entity\Tests\Views\TranslationLinkTest.
*/
namespace
Drupal\translation_entity\Tests\Views
;
use
Drupal\views\Tests\ViewTestBase
;
use
Drupal\translation_entity
\
Tests\EntityTranslationUITest
;
use
Drupal\views\Tests\ViewTestData
;
/**
* Tests the Entity translation overview link field handler.
*
* @see \Drupal\translation_entity\Plugin\views\field\TranslationLink
*/
class
TranslationLinkTest
extends
EntityTranslationUITest
{
/**
* Views used by this test.
*
* @var array
*/
public
static
$testViews
=
array
(
'test_entity_translations_link'
);
/**
* Modules to enable.
*
* @var array
*/
public
static
$modules
=
array
(
'translation_entity_test_views'
);
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Entity Translation: Link field'
,
'description'
=>
'Tests the Entity translation overview link field handler.'
,
'group'
=>
'Views Modules'
,
);
}
function
setUp
()
{
// @todo Use entity_type once it is has multilingual Views integration.
$this
->
entityType
=
'user'
;
parent
::
setUp
();
ViewTestData
::
importTestViews
(
get_class
(
$this
),
array
(
'translation_entity_test_views'
));
}
/**
* Implements \Drupal\translation_entity\Tests\EntityTranslationUITest::getTranslatorPermission().
*/
function
getTranslatorPermissions
()
{
return
array
(
"translate
$this->entityType
entities"
,
'edit original values'
);
}
/**
* Tests the Entity translation overview link field handler.
*/
public
function
testTranslationLink
()
{
$this
->
drupalGet
(
'test-entity-translations-link'
);
$this
->
assertLinkByHref
(
'user/1/translations'
);
$this
->
assertNoLinkByHref
(
'user/2/translations'
,
'The translations link is not present when translation_entity_translate_access() is FALSE.'
);
}
/**
* Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::testTranslationUI().
*/
public
function
testTranslationUI
()
{
// @todo \Drupal\translation_entity\Tests\EntityTranslationUITest contains
// essential helper methods that should be seprarated from test methods.
}
}
core/modules/translation_entity/tests/modules/translation_entity_test_views/test_views/views.view.test_entity_translations_link.yml
0 → 100644
View file @
117a617b
base_field
:
uid
base_table
:
users
core
:
8.x
description
:
'
'
disabled
:
'
0'
display
:
default
:
display_plugin
:
default
id
:
default
display_title
:
Master
position
:
'
'
display_options
:
access
:
type
:
none
cache
:
type
:
none
query
:
type
:
views_query
exposed_form
:
type
:
basic
options
:
submit_button
:
Filter
reset_button
:
'
1'
reset_button_label
:
Reset
pager
:
type
:
full
options
:
items_per_page
:
'
50'
style
:
type
:
table
options
:
columns
:
name
:
name
translation_link
:
translation_link
default
:
created
row
:
type
:
fields
fields
:
name
:
id
:
name
table
:
users
field
:
name
label
:
Username
link_to_user
:
'
1'
format_username
:
'
1'
translation_link
:
id
:
translation_link
table
:
users
field
:
translation_link
label
:
'
Translation
link'
exclude
:
'
0'
alter
:
alter_text
:
'
0'
element_class
:
'
'
element_default_classes
:
'
1'
empty
:
'
'
hide_empty
:
'
0'
empty_zero
:
'
0'
hide_alter_empty
:
'
1'
text
:
Translate
filters
:
uid_raw
:
id
:
uid_raw
table
:
users
field
:
uid_raw
operator
:
'
!='
value
:
value
:
'
0'
group
:
'
1'
exposed
:
'
0'
sorts
:
created
:
id
:
created
table
:
users
field
:
created
order
:
DESC
title
:
People
empty
:
area
:
id
:
area
table
:
views
field
:
area
empty
:
'
1'
content
:
'
No
people
available.'
format
:
filtered_html
page_1
:
display_plugin
:
page
id
:
page_1
display_title
:
Page
position
:
'
'
display_options
:
path
:
test-entity-translations-link
human_name
:
People
module
:
views
id
:
test_entity_translations_link
tag
:
'
'
core/modules/translation_entity/tests/modules/translation_entity_test_views/translation_entity_test_views.info
0 → 100644
View file @
117a617b
name
=
Entity
translation
test
views
description
=
Provides
default
views
for
views
entity
translation
tests
.
package
=
Testing
version
=
VERSION
core
=
8.
x
dependencies
[]
=
translation_entity
dependencies
[]
=
views
hidden
=
TRUE
core/modules/translation_entity/tests/modules/translation_entity_test_views/translation_entity_test_views.module
0 → 100644
View file @
117a617b
<?php
core/modules/user/user.views.inc
View file @
117a617b
...
...
@@ -295,6 +295,17 @@ function user_views_data() {
),
);
// Entity translation field.
if
(
drupal_container
()
->
get
(
'module_handler'
)
->
moduleExists
(
'translation_entity'
))
{
$data
[
'users'
][
'translation_link'
]
=
array
(
'title'
=>
t
(
'Translation link'
),
'help'
=>
t
(
'Provide a link to the translations overview for users.'
),
'field'
=>
array
(
'id'
=>
'translation_entity_link'
,
),
);
}
$data
[
'users'
][
'edit_node'
]
=
array
(
'field'
=>
array
(
'title'
=>
t
(
'Edit link'
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment