dannylamb
5 years ago
18 changed files with 903 additions and 26 deletions
@ -0,0 +1,481 @@
|
||||
langcode: en |
||||
status: true |
||||
dependencies: |
||||
config: |
||||
- core.entity_view_mode.node.teaser |
||||
module: |
||||
- media |
||||
- node |
||||
- taxonomy |
||||
- user |
||||
id: collections |
||||
label: Collections |
||||
module: views |
||||
description: 'All collections in the repository' |
||||
tag: '' |
||||
base_table: node_field_data |
||||
base_field: nid |
||||
core: 8.x |
||||
display: |
||||
default: |
||||
display_plugin: default |
||||
id: default |
||||
display_title: Master |
||||
position: 0 |
||||
display_options: |
||||
access: |
||||
type: perm |
||||
options: |
||||
perm: 'access content' |
||||
cache: |
||||
type: tag |
||||
options: { } |
||||
query: |
||||
type: views_query |
||||
options: |
||||
disable_sql_rewrite: false |
||||
distinct: false |
||||
replica: false |
||||
query_comment: '' |
||||
query_tags: { } |
||||
exposed_form: |
||||
type: basic |
||||
options: |
||||
submit_button: Apply |
||||
reset_button: false |
||||
reset_button_label: Reset |
||||
exposed_sorts_label: 'Sort by' |
||||
expose_sort_order: true |
||||
sort_asc_label: Asc |
||||
sort_desc_label: Desc |
||||
pager: |
||||
type: mini |
||||
options: |
||||
items_per_page: 10 |
||||
offset: 0 |
||||
id: 0 |
||||
total_pages: null |
||||
expose: |
||||
items_per_page: false |
||||
items_per_page_label: 'Items per page' |
||||
items_per_page_options: '5, 10, 25, 50' |
||||
items_per_page_options_all: false |
||||
items_per_page_options_all_label: '- All -' |
||||
offset: false |
||||
offset_label: Offset |
||||
tags: |
||||
previous: ‹‹ |
||||
next: ›› |
||||
style: |
||||
type: table |
||||
options: |
||||
grouping: { } |
||||
row_class: '' |
||||
default_row_class: true |
||||
override: true |
||||
sticky: false |
||||
caption: '' |
||||
summary: '' |
||||
description: '' |
||||
columns: |
||||
title: title |
||||
info: |
||||
title: |
||||
sortable: false |
||||
default_sort_order: asc |
||||
align: '' |
||||
separator: '' |
||||
empty_column: false |
||||
responsive: '' |
||||
default: '-1' |
||||
empty_table: false |
||||
row: |
||||
type: 'entity:node' |
||||
options: |
||||
view_mode: teaser |
||||
fields: |
||||
title: |
||||
id: title |
||||
table: node_field_data |
||||
field: title |
||||
relationship: none |
||||
group_type: group |
||||
admin_label: '' |
||||
label: Title |
||||
exclude: false |
||||
alter: |
||||
alter_text: false |
||||
text: '' |
||||
make_link: false |
||||
path: '' |
||||
absolute: false |
||||
external: false |
||||
replace_spaces: false |
||||
path_case: none |
||||
trim_whitespace: false |
||||
alt: '' |
||||
rel: '' |
||||
link_class: '' |
||||
prefix: '' |
||||
suffix: '' |
||||
target: '' |
||||
nl2br: false |
||||
max_length: 0 |
||||
word_boundary: false |
||||
ellipsis: false |
||||
more_link: false |
||||
more_link_text: '' |
||||
more_link_path: '' |
||||
strip_tags: false |
||||
trim: false |
||||
preserve_tags: '' |
||||
html: false |
||||
element_type: '' |
||||
element_class: '' |
||||
element_label_type: '' |
||||
element_label_class: '' |
||||
element_label_colon: true |
||||
element_wrapper_type: '' |
||||
element_wrapper_class: '' |
||||
element_default_classes: true |
||||
empty: '' |
||||
hide_empty: false |
||||
empty_zero: false |
||||
hide_alter_empty: true |
||||
click_sort_column: value |
||||
type: string |
||||
settings: |
||||
link_to_entity: true |
||||
group_column: value |
||||
group_columns: { } |
||||
group_rows: true |
||||
delta_limit: 0 |
||||
delta_offset: 0 |
||||
delta_reversed: false |
||||
delta_first_last: false |
||||
multi_type: separator |
||||
separator: ', ' |
||||
field_api_classes: false |
||||
entity_type: node |
||||
entity_field: title |
||||
plugin_id: field |
||||
field_member_of: |
||||
id: field_member_of |
||||
table: node__field_member_of |
||||
field: field_member_of |
||||
relationship: reverse__node__field_member_of |
||||
group_type: count |
||||
admin_label: '' |
||||
label: Children |
||||
exclude: false |
||||
alter: |
||||
alter_text: false |
||||
text: '' |
||||
make_link: false |
||||
path: '' |
||||
absolute: false |
||||
external: false |
||||
replace_spaces: false |
||||
path_case: none |
||||
trim_whitespace: false |
||||
alt: '' |
||||
rel: '' |
||||
link_class: '' |
||||
prefix: '' |
||||
suffix: '' |
||||
target: '' |
||||
nl2br: false |
||||
max_length: 0 |
||||
word_boundary: true |
||||
ellipsis: true |
||||
more_link: false |
||||
more_link_text: '' |
||||
more_link_path: '' |
||||
strip_tags: false |
||||
trim: false |
||||
preserve_tags: '' |
||||
html: false |
||||
element_type: '' |
||||
element_class: '' |
||||
element_label_type: '' |
||||
element_label_class: '' |
||||
element_label_colon: true |
||||
element_wrapper_type: '' |
||||
element_wrapper_class: '' |
||||
element_default_classes: true |
||||
empty: '' |
||||
hide_empty: false |
||||
empty_zero: false |
||||
hide_alter_empty: true |
||||
set_precision: false |
||||
precision: 0 |
||||
decimal: . |
||||
separator: ', ' |
||||
format_plural: 0 |
||||
format_plural_string: !!binary MQNAY291bnQ= |
||||
prefix: '' |
||||
suffix: '' |
||||
click_sort_column: target_id |
||||
type: entity_reference_label |
||||
settings: { } |
||||
group_column: entity_id |
||||
group_columns: { } |
||||
group_rows: true |
||||
delta_limit: 0 |
||||
delta_offset: 0 |
||||
delta_reversed: false |
||||
delta_first_last: false |
||||
multi_type: separator |
||||
field_api_classes: false |
||||
plugin_id: field |
||||
field_file_size: |
||||
id: field_file_size |
||||
table: media__field_file_size |
||||
field: field_file_size |
||||
relationship: reverse__media__field_media_of |
||||
group_type: sum |
||||
admin_label: '' |
||||
label: 'Disk Usage' |
||||
exclude: false |
||||
alter: |
||||
alter_text: true |
||||
text: "{% if field_file_size > (1024 ** 5) %}\r\n {% set size = field_file_size / (1024 ** 5) %}\r\n {% set abbreviation = 'PB' %}\r\n{% elseif field_file_size > (1024 ** 4) %}\r\n {% set size = field_file_size / (1024 ** 4) %}\r\n {% set abbreviation = 'TB' %}\r\n{% elseif field_file_size > (1024 ** 3) %}\r\n {% set size = field_file_size / (1024 ** 3) %}\r\n {% set abbreviation = 'GB' %}\r\n{% elseif field_file_size > (1024 ** 2) %}\r\n {% set size = field_file_size / (1024 ** 2) %}\r\n {% set abbreviation = 'MB' %}\r\n{% elseif field_file_size > 1024 %}\r\n {% set size = field_file_size / 1024 %}\r\n {% set abbreviation = 'KB' %}\r\n{% else %}\r\n {% set size = field_file_size %}\r\n {% set abbreviation = 'B' %}\r\n{% endif %}\r\n\r\n{{ size|round(2, 'common') }} {{ abbreviation }}" |
||||
make_link: false |
||||
path: '' |
||||
absolute: false |
||||
external: false |
||||
replace_spaces: false |
||||
path_case: none |
||||
trim_whitespace: false |
||||
alt: '' |
||||
rel: '' |
||||
link_class: '' |
||||
prefix: '' |
||||
suffix: '' |
||||
target: '' |
||||
nl2br: false |
||||
max_length: 0 |
||||
word_boundary: true |
||||
ellipsis: true |
||||
more_link: false |
||||
more_link_text: '' |
||||
more_link_path: '' |
||||
strip_tags: false |
||||
trim: false |
||||
preserve_tags: '' |
||||
html: false |
||||
element_type: '' |
||||
element_class: '' |
||||
element_label_type: '' |
||||
element_label_class: '' |
||||
element_label_colon: true |
||||
element_wrapper_type: '' |
||||
element_wrapper_class: '' |
||||
element_default_classes: true |
||||
empty: '' |
||||
hide_empty: false |
||||
empty_zero: false |
||||
hide_alter_empty: true |
||||
set_precision: false |
||||
precision: 0 |
||||
decimal: . |
||||
separator: '' |
||||
format_plural: 0 |
||||
format_plural_string: !!binary MQNAY291bnQ= |
||||
prefix: '' |
||||
suffix: '' |
||||
click_sort_column: value |
||||
type: number_integer |
||||
settings: { } |
||||
group_column: value |
||||
group_columns: { } |
||||
group_rows: true |
||||
delta_limit: 0 |
||||
delta_offset: 0 |
||||
delta_reversed: false |
||||
delta_first_last: false |
||||
multi_type: separator |
||||
field_api_classes: false |
||||
plugin_id: field |
||||
operations: |
||||
id: operations |
||||
table: node |
||||
field: operations |
||||
relationship: none |
||||
group_type: group |
||||
admin_label: '' |
||||
label: 'Operations links' |
||||
exclude: false |
||||
alter: |
||||
alter_text: false |
||||
text: '' |
||||
make_link: false |
||||
path: '' |
||||
absolute: false |
||||
external: false |
||||
replace_spaces: false |
||||
path_case: none |
||||
trim_whitespace: false |
||||
alt: '' |
||||
rel: '' |
||||
link_class: '' |
||||
prefix: '' |
||||
suffix: '' |
||||
target: '' |
||||
nl2br: false |
||||
max_length: 0 |
||||
word_boundary: true |
||||
ellipsis: true |
||||
more_link: false |
||||
more_link_text: '' |
||||
more_link_path: '' |
||||
strip_tags: false |
||||
trim: false |
||||
preserve_tags: '' |
||||
html: false |
||||
element_type: '' |
||||
element_class: '' |
||||
element_label_type: '' |
||||
element_label_class: '' |
||||
element_label_colon: true |
||||
element_wrapper_type: '' |
||||
element_wrapper_class: '' |
||||
element_default_classes: true |
||||
empty: '' |
||||
hide_empty: false |
||||
empty_zero: false |
||||
hide_alter_empty: true |
||||
destination: true |
||||
entity_type: node |
||||
plugin_id: entity_operations |
||||
filters: |
||||
status: |
||||
value: '1' |
||||
table: node_field_data |
||||
field: status |
||||
plugin_id: boolean |
||||
entity_type: node |
||||
entity_field: status |
||||
id: status |
||||
expose: |
||||
operator: '' |
||||
group: 1 |
||||
field_external_uri_uri: |
||||
id: field_external_uri_uri |
||||
table: taxonomy_term__field_external_uri |
||||
field: field_external_uri_uri |
||||
relationship: field_model |
||||
group_type: group |
||||
admin_label: '' |
||||
operator: '=' |
||||
value: 'http://purl.org/dc/dcmitype/Collection' |
||||
group: 1 |
||||
exposed: false |
||||
expose: |
||||
operator_id: '' |
||||
label: '' |
||||
description: '' |
||||
use_operator: false |
||||
operator: '' |
||||
identifier: '' |
||||
required: false |
||||
remember: false |
||||
multiple: false |
||||
remember_roles: |
||||
authenticated: authenticated |
||||
placeholder: '' |
||||
is_grouped: false |
||||
group_info: |
||||
label: '' |
||||
description: '' |
||||
identifier: '' |
||||
optional: true |
||||
widget: select |
||||
multiple: false |
||||
remember: false |
||||
default_group: All |
||||
default_group_multiple: { } |
||||
group_items: { } |
||||
plugin_id: string |
||||
sorts: { } |
||||
title: Collections |
||||
header: { } |
||||
footer: { } |
||||
empty: { } |
||||
relationships: |
||||
field_model: |
||||
id: field_model |
||||
table: node__field_model |
||||
field: field_model |
||||
relationship: none |
||||
group_type: group |
||||
admin_label: 'field_model: Taxonomy term' |
||||
required: true |
||||
plugin_id: standard |
||||
reverse__node__field_member_of: |
||||
id: reverse__node__field_member_of |
||||
table: node_field_data |
||||
field: reverse__node__field_member_of |
||||
relationship: none |
||||
group_type: group |
||||
admin_label: field_member_of |
||||
required: false |
||||
entity_type: node |
||||
plugin_id: entity_reverse |
||||
reverse__media__field_media_of: |
||||
id: reverse__media__field_media_of |
||||
table: node_field_data |
||||
field: reverse__media__field_media_of |
||||
relationship: none |
||||
group_type: group |
||||
admin_label: field_media_of |
||||
required: false |
||||
entity_type: node |
||||
plugin_id: entity_reverse |
||||
arguments: { } |
||||
display_extenders: { } |
||||
filter_groups: |
||||
operator: AND |
||||
groups: |
||||
1: AND |
||||
group_by: true |
||||
cache_metadata: |
||||
max-age: -1 |
||||
contexts: |
||||
- 'languages:language_content' |
||||
- 'languages:language_interface' |
||||
- url.query_args |
||||
- 'user.node_grants:view' |
||||
- user.permissions |
||||
tags: { } |
||||
page_1: |
||||
display_plugin: page |
||||
id: page_1 |
||||
display_title: Page |
||||
position: 1 |
||||
display_options: |
||||
display_extenders: { } |
||||
path: admin/content/collections |
||||
menu: |
||||
type: tab |
||||
title: Collections |
||||
description: '' |
||||
expanded: false |
||||
parent: '' |
||||
weight: -100 |
||||
context: '0' |
||||
menu_name: admin |
||||
tab_options: |
||||
type: normal |
||||
title: Collections |
||||
description: '' |
||||
weight: 0 |
||||
cache_metadata: |
||||
max-age: -1 |
||||
contexts: |
||||
- 'languages:language_content' |
||||
- 'languages:language_interface' |
||||
- url.query_args |
||||
- 'user.node_grants:view' |
||||
- user.permissions |
||||
tags: { } |
@ -0,0 +1,47 @@
|
||||
<?php |
||||
|
||||
namespace Drupal\islandora\Controller; |
||||
|
||||
use Drupal\Core\Access\AccessResult; |
||||
use Drupal\Core\Routing\RouteMatch; |
||||
use Drupal\islandora\IslandoraUtils; |
||||
|
||||
/** |
||||
* Page to select new type to add as member. |
||||
*/ |
||||
class AddCollectionController extends ManageMembersController { |
||||
|
||||
/** |
||||
* Renders a list of types to add as a collection. |
||||
*/ |
||||
public function addCollectionPage() { |
||||
$term = $this->utils->getTermForUri('http://purl.org/dc/dcmitype/Collection'); |
||||
$field = IslandoraUtils::MODEL_FIELD; |
||||
|
||||
return $this->generateTypeList( |
||||
'node', |
||||
'node_type', |
||||
'node.add', |
||||
'node.type_add', |
||||
$field, |
||||
['query' => ["edit[$field][widget]" => $term->id()]] |
||||
); |
||||
} |
||||
|
||||
/** |
||||
* Check if the object being displayed "is Islandora". |
||||
* |
||||
* @param \Drupal\Core\Routing\RouteMatch $route_match |
||||
* The current routing match. |
||||
* |
||||
* @return \Drupal\Core\Access\AccessResultAllowed|\Drupal\Core\Access\AccessResultForbidden |
||||
* Whether we can or can't show the "thing". |
||||
*/ |
||||
public function access(RouteMatch $route_match) { |
||||
if ($this->utils->canCreateIslandoraEntity('node', 'node_type')) { |
||||
return AccessResult::allowed(); |
||||
} |
||||
return AccessResult::forbidden(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,60 @@
|
||||
<?php |
||||
|
||||
namespace Drupal\Tests\islandora\Functional; |
||||
|
||||
/** |
||||
* Tests the ManageMembersController. |
||||
* |
||||
* @group islandora |
||||
*/ |
||||
class AddChildTest extends IslandoraFunctionalTestBase { |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function setUp() { |
||||
parent::setUp(); |
||||
|
||||
$this->parent = |
||||
$this->collectionTerm = $this->container->get('entity_type.manager')->getStorage('taxonomy_term')->create([ |
||||
'name' => 'Collection', |
||||
'vid' => $this->testVocabulary->id(), |
||||
'field_external_uri' => [['uri' => "http://purl.org/dc/dcmitype/Collection"]], |
||||
]); |
||||
$this->collectionTerm->save(); |
||||
} |
||||
|
||||
/** |
||||
* @covers \Drupal\islandora\Controller\AddCollectionController::addToNodePage |
||||
* @covers \Drupal\islandora\Controller\AddCollectionController::access |
||||
* @covers \Drupal\islandora\IslandoraUtils::isIslandoraType |
||||
*/ |
||||
public function testAddChild() { |
||||
$account = $this->drupalCreateUser([ |
||||
'bypass node access', |
||||
]); |
||||
$this->drupalLogin($account); |
||||
|
||||
$parent = $this->container->get('entity_type.manager')->getStorage('node')->create([ |
||||
'type' => 'test_type', |
||||
'title' => 'Parent', |
||||
]); |
||||
$parent->save(); |
||||
|
||||
// Visit the add member page. |
||||
$this->drupalGet("/node/{$parent->id()}/members/add"); |
||||
|
||||
// Assert that test_type is on the list. |
||||
$this->assertSession()->pageTextContains($this->testType->label()); |
||||
$this->clickLink($this->testType->label()); |
||||
$url = $this->getUrl(); |
||||
|
||||
// Assert that the link creates the correct prepopulate query param. |
||||
$substring = 'node/add/test_type?edit%5Bfield_member_of%5D%5Bwidget%5D%5B0%5D%5Btarget_id%5D=1'; |
||||
$this->assertTrue( |
||||
strpos($url, $substring) !== FALSE, |
||||
"Malformed URL, could not find $substring in $url." |
||||
); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,62 @@
|
||||
<?php |
||||
|
||||
namespace Drupal\Tests\islandora\Functional; |
||||
|
||||
/** |
||||
* Tests the AddCollectionController. |
||||
* |
||||
* @group islandora |
||||
*/ |
||||
class AddCollectionTest extends IslandoraFunctionalTestBase { |
||||
|
||||
/** |
||||
* Term to belong to the media. |
||||
* |
||||
* @var \Drupal\taxonomy\TermInterface |
||||
*/ |
||||
protected $collectionTerm; |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function setUp() { |
||||
parent::setUp(); |
||||
|
||||
$this->collectionTerm = $this->container->get('entity_type.manager')->getStorage('taxonomy_term')->create([ |
||||
'name' => 'Collection', |
||||
'vid' => $this->testVocabulary->id(), |
||||
'field_external_uri' => [['uri' => "http://purl.org/dc/dcmitype/Collection"]], |
||||
]); |
||||
$this->collectionTerm->save(); |
||||
} |
||||
|
||||
/** |
||||
* @covers \Drupal\islandora\Controller\AddCollectionController::addCollectionPage |
||||
* @covers \Drupal\islandora\Controller\AddCollectionController::access |
||||
* @covers \Drupal\islandora\IslandoraUtils::isIslandoraType |
||||
*/ |
||||
public function testAddCollection() { |
||||
$account = $this->drupalCreateUser([ |
||||
'bypass node access', |
||||
]); |
||||
$this->drupalLogin($account); |
||||
|
||||
// Visit the add collection page. |
||||
$this->drupalGet('/collection/add'); |
||||
|
||||
// Assert the test type is in the list of available types. |
||||
$this->assertSession()->pageTextContains($this->testType->label()); |
||||
|
||||
// Click the test type and make sure you get sent to the right form. |
||||
$this->clickLink($this->testType->label()); |
||||
$url = $this->getUrl(); |
||||
|
||||
// Assert that the link creates the correct prepopulate query param. |
||||
$substring = 'node/add/test_type?edit%5Bfield_model%5D%5Bwidget%5D=1'; |
||||
$this->assertTrue( |
||||
strpos($url, 'node/add/test_type?edit%5Bfield_model%5D%5Bwidget%5D=1') !== FALSE, |
||||
"Malformed URL, could not find $substring in $url." |
||||
); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,46 @@
|
||||
<?php |
||||
|
||||
namespace Drupal\Tests\islandora\Functional; |
||||
|
||||
/** |
||||
* Tests the ManageMembersController. |
||||
* |
||||
* @group islandora |
||||
*/ |
||||
class AddMediaTest extends IslandoraFunctionalTestBase { |
||||
|
||||
/** |
||||
* @covers \Drupal\islandora\Controller\AddCollectionController::addToNodePage |
||||
* @covers \Drupal\islandora\Controller\AddCollectionController::access |
||||
* @covers \Drupal\islandora\IslandoraUtils::isIslandoraType |
||||
*/ |
||||
public function testAddMedia() { |
||||
$account = $this->drupalCreateUser([ |
||||
'bypass node access', |
||||
'create media', |
||||
]); |
||||
$this->drupalLogin($account); |
||||
|
||||
$parent = $this->container->get('entity_type.manager')->getStorage('node')->create([ |
||||
'type' => 'test_type', |
||||
'title' => 'Parent', |
||||
]); |
||||
$parent->save(); |
||||
|
||||
// Visit the add media page. |
||||
$this->drupalGet("/node/{$parent->id()}/media/add"); |
||||
|
||||
// Assert that test_meida_type is on the list. |
||||
$this->assertSession()->pageTextContains($this->testMediaType->label()); |
||||
$this->clickLink($this->testMediaType->label()); |
||||
$url = $this->getUrl(); |
||||
|
||||
// Assert that the link creates the correct prepopulate query param. |
||||
$substring = 'media/add/test_media_type?edit%5Bfield_media_of%5D%5Bwidget%5D%5B0%5D%5Btarget_id%5D=1'; |
||||
$this->assertTrue( |
||||
strpos($url, $substring) !== FALSE, |
||||
"Malformed URL, could not find $substring in $url." |
||||
); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue