code for review update
This commit is contained in:
parent
53e43b7bbf
commit
5193e4f5b5
15 changed files with 262 additions and 37 deletions
|
@ -43,7 +43,7 @@ trait DatasetExtension
|
|||
'pivot' => array('role' => 'author'),
|
||||
//'sort_order' => array('sort_order' => 'ASC'), // <-- We need a sorted authors list.
|
||||
//'sort_field' => 'SortOrder',
|
||||
'relation' => 'authors',
|
||||
'relation' => 'persons',
|
||||
'fetch' => 'eager'
|
||||
),
|
||||
'PersonContributor' => array(
|
||||
|
@ -52,7 +52,7 @@ trait DatasetExtension
|
|||
'pivot' => array('role' => 'contributor'),
|
||||
// 'sort_order' => array('sort_order' => 'ASC'), // <-- We need a sorted authors list.
|
||||
//'sort_field' => 'SortOrder',
|
||||
'relation' => 'contributors',
|
||||
'relation' => 'persons',
|
||||
'fetch' => 'eager'
|
||||
),
|
||||
'Subject' => array(
|
||||
|
@ -85,14 +85,9 @@ trait DatasetExtension
|
|||
{
|
||||
$fields = array(
|
||||
"Id",
|
||||
"CompletedDate", "CompletedYear",
|
||||
"ContributingCorporation",
|
||||
"CreatingCorporation",
|
||||
"ThesisDateAccepted", "ThesisYearAccepted",
|
||||
"Edition",
|
||||
"Issue",
|
||||
"Language",
|
||||
"PageFirst", "PageLast", "PageNumber",
|
||||
"PublishedDate", "PublishedYear",
|
||||
"PublisherName", "PublisherPlace",
|
||||
"PublicationState",
|
||||
|
@ -102,7 +97,6 @@ trait DatasetExtension
|
|||
"ServerDateDeleted",
|
||||
"ServerState",
|
||||
"Type",
|
||||
"Volume",
|
||||
"BelongsToBibliography",
|
||||
"EmbargoDate"
|
||||
);
|
||||
|
@ -121,7 +115,7 @@ trait DatasetExtension
|
|||
// Initialize available date fields and set up date validator
|
||||
// if the particular field is present
|
||||
$dateFields = array(
|
||||
'ServerDateCreated', 'CompletedDate', 'PublishedDate',
|
||||
'ServerDateCreated', 'PublishedDate',
|
||||
'ServerDateModified', 'ServerDatePublished', 'ServerDateDeleted', 'EmbargoDate'
|
||||
);
|
||||
foreach ($dateFields as $fieldName) {
|
||||
|
|
|
@ -70,6 +70,37 @@ class Strategy
|
|||
return $this->_config->dom;
|
||||
}
|
||||
|
||||
public function getModelFieldValues(Dataset $model)
|
||||
{
|
||||
$fields = $model->describe();
|
||||
$excludeFields = $this->getConfig()->excludeFields;
|
||||
if (count($excludeFields) > 0) {
|
||||
$fieldsDiff = array_diff($fields, $excludeFields);
|
||||
} else {
|
||||
$fieldsDiff = $fields;
|
||||
}
|
||||
|
||||
foreach ($fieldsDiff as $fieldname) {
|
||||
$field = $model->getField($fieldname);
|
||||
$fieldValue = $this->getFieldValue($field);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getFieldValue(Field $field): string
|
||||
{
|
||||
$modelClass = $field->getValueModelClass();
|
||||
$fieldValues = $field->getValue();
|
||||
|
||||
if (null === $modelClass) {
|
||||
$fieldName = $field->getName();
|
||||
$fieldValues = $this->getFieldValues($field);
|
||||
|
||||
// Replace invalid XML-1.0-Characters by UTF-8 replacement character.
|
||||
$fieldValues = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/', "\xEF\xBF\xBD ", $fieldValues);
|
||||
}
|
||||
return fieldValues;
|
||||
}
|
||||
|
||||
protected function _mapModel(Dataset $model, \DOMDocument $dom, \DOMNode $rootNode)
|
||||
{
|
||||
$fields = $model->describe();
|
||||
|
|
|
@ -126,7 +126,7 @@ class XmlModel
|
|||
return $domDocument;
|
||||
}
|
||||
|
||||
//create xml:
|
||||
//$domDocument == null -> create xml:
|
||||
$domDocument = $this->strategy->getDomDocument();
|
||||
//if caching is not desired, return domDocument
|
||||
if (is_null($this->cache)) {
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue