Skip to content

Commit 070a7c7

Browse files
authored
Merge pull request #18 from molarchaeology/omeka4
Omeka v4 Support
2 parents 940eb77 + 371cb0c commit 070a7c7

File tree

9 files changed

+28
-29
lines changed

9 files changed

+28
-29
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.DS_Store
1+
.DS_Store

asset/css/nesteddatatype.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,4 @@
172172
.nested-data-type_properties .items a:after {
173173
font-family: "Font Awesome 5 Free";
174174
content: " \f1b2";
175-
}
175+
}

asset/js/nesteddatatype.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,4 +361,4 @@ function getTemplateJson(url) {
361361
// sidebar.removeClass('loading');
362362
// });
363363
// }
364-
// }
364+
// }

config/module.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ name = "Nested Data Types"
33
description= "Allow users to choose a specific resource class as datatype, and inner properties."
44
author = "Giacomo Nanni"
55
author_link = "https://github.com/sinanatra"
6-
version = "3.3.1"
7-
omeka_version_constraint = "^3.0.0"
6+
version = "4.0.0"
7+
omeka_version_constraint = "^4.0.0"

src/Controller/IndexController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function sidebarSelectAction()
1313

1414
$response = $this->api()->search('items', $this->params()->fromQuery());
1515
$this->paginator($response->getTotalResults());
16-
16+
1717
$view = new ViewModel;
1818
$view->setVariable('items', $response->getContent());
1919
$view->setVariable('search', $this->params()->fromQuery('search'));
@@ -24,4 +24,4 @@ public function sidebarSelectAction()
2424
$view->setTemplate('/nested-data-type/item/sidebar-select');
2525
return $view;
2626
}
27-
}
27+
}

src/DataType/NestedDataType.php

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ public function getLabel()
4040
{
4141
return $this->resourceClass->term();
4242
}
43-
43+
4444
public function getOptgroupLabel()
4545
{
46-
return 'Specific class'; // @translate
46+
return 'Nested Class'; // @translate
4747
}
4848

4949
public function form(PhpRenderer $view)
@@ -58,7 +58,7 @@ public function form(PhpRenderer $view)
5858
}
5959

6060
public function getJsonLd(ValueRepresentation $value)
61-
{
61+
{
6262
$values= json_decode($value->value(), true);
6363
$simpleValue = [];
6464

@@ -94,9 +94,9 @@ public function getJsonLd(ValueRepresentation $value)
9494
'simpleValue' => implode('; ', $simpleValue),
9595
];
9696

97-
return $jsonLd;
97+
return $jsonLd;
9898
}
99-
99+
100100
/**
101101
* @param array $valueObject
102102
*/
@@ -120,7 +120,7 @@ public function isValid(array $valueObject){
120120
return true;
121121
}
122122

123-
public function hydrate(array $valueObject, Value $value, AbstractEntityAdapter $adapter){
123+
public function hydrate(array $valueObject, Value $value, AbstractEntityAdapter $adapter){
124124
$serviceLocator = $adapter->getServiceLocator();
125125

126126
$prevLabel = '';
@@ -140,19 +140,19 @@ public function hydrate(array $valueObject, Value $value, AbstractEntityAdapter
140140

141141

142142
foreach($valueObject as $key => $label) {
143-
143+
144144
if ($prevLabel == $label) {
145145
$num += 1;
146146
}
147-
147+
148148
if (substr($key,0,15) !== 'property-label-'){
149149
continue;
150150
}
151-
151+
152152
$idx = (int) substr($key,15);
153153
$val = $valueObject["property-value-$idx"];
154154
$uri = $valueObject["property-uri-$idx"];
155-
155+
156156
// Update title from Omeka Id - to be cleaned.
157157
if (strpos($uri, '/api/items/') !== false) {
158158
try {
@@ -180,21 +180,21 @@ public function hydrate(array $valueObject, Value $value, AbstractEntityAdapter
180180
$uri ? ['@id' => $uri, 'label' => $val] : ['@value' => $val],
181181
$isHidden ? ['is_hidden' => $isHidden] : []
182182
);
183-
}
183+
}
184184
}
185185

186-
$value->setValue(json_encode([$properties]));
186+
$value->setValue(json_encode([$properties]));
187187
$prevLabel .= $label;
188188
}
189189
}
190190

191191
public function render(PhpRenderer $view, ValueRepresentation $value){
192-
192+
193193
$values = json_decode($value->value(), true);
194194
$simpleValue = [];
195-
195+
196196
foreach ($values[0] as $key => $val) {
197-
197+
198198
if($key == '@type'){
199199
$simpleValue[$key] = $val;
200200
}
@@ -240,7 +240,7 @@ function ($v, $k) {
240240
else {
241241
$v = "<span class='value__property'>" . $v . "</span>";
242242
}
243-
243+
244244
$k = "<span class='value__label'><em>" . str_replace("_", " ", explode(":", $k)[1]) . "</em></span>";
245245

246246
return "<div class='value-container__value'>" . $k . "<span class='value__separator'>" .": " . "</span>" . $v . "</div>";
@@ -250,4 +250,3 @@ function ($v, $k) {
250250
)). "</div>";
251251
}
252252
}
253-

src/Service/NestedDataTypeFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ public function canCreate($services, $requestedName)
1515
public function __invoke($services, $requestedName, array $options = null)
1616
{
1717
$term = explode('#', $requestedName)[1];
18-
18+
1919
if (!$term) {
2020
throw new NestedDataTypeException("Invalid term : ".$term);
2121
}
22-
22+
2323
$apiManager = $services->get('Omeka\ApiManager');
2424
$resourceClasses = $apiManager->search('resource_classes', ['term' => $term])->getContent();
25-
25+
2626
$vocabularyId = $resourceClasses[0]->vocabulary()->id();
2727
$properties = $apiManager->search('properties', ['vocabulary_id' => $vocabularyId])->getContent();
2828
$classes = $apiManager->search('resource_classes', ['vocabulary_id' => $vocabularyId])->getContent();

view/nested-data-type/data-type/nested-data-type.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@
4242

4343
<a class="nested-data-type_button nested-data-type_add_resource o-icon- fa-link button resource-select" data-sidebar-content-url="<?= $this->url('admin/default', ['controller' => 'nested-data-type', 'action' => 'sidebar-select'], false) ?>" href="#item-resource-select">
4444
Link Item
45-
</a>
45+
</a>

view/nested-data-type/item/sidebar-select.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,4 @@ $expanded = $resourceClassId || $itemSetId || $id;
9191

9292
<div class="confirm-panel">
9393
<button type="button" class="nested-data-type__resource_multiple"><?php echo $translate('Add selected'); ?></button>
94-
</div>
94+
</div>

0 commit comments

Comments
 (0)