Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into theme/ma
Browse files Browse the repository at this point in the history
  • Loading branch information
hmert committed Oct 4, 2016
2 parents 9c48e91 + 88afa17 commit 1a89b3c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 8 deletions.
7 changes: 5 additions & 2 deletions src/Ojs/JournalBundle/Entity/ArticleAuthor.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,11 @@ public function setArticle(Article $article = null)

public function __toString()
{
return $this->getAuthor()->getTitle().' '.$this->getAuthor()->getFirstName().' '.$this->getAuthor(
)->getLastName();
return implode(' ', [
$this->getAuthor()->getTitle(),
$this->getAuthor()->getFirstName(),
$this->getAuthor()->getLastName()
]);
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/Ojs/OAIBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
services:
ojs.oai.twig_extension:
class: Ojs\OAIBundle\Twig\OaiExtension
public: false
tags:
- { name: twig.extension }
14 changes: 8 additions & 6 deletions src/Ojs/OAIBundle/Resources/views/Default/records.xml.twig
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@
xmlns:dc="http://purl.org/dc/elements/1.1/">
{% for translation in record.translations %}
{% if translation.title is not empty and translation.title != '-' %}
<dc:title xml:lang="en-US"><![CDATA[{{ translation.title }}]]></dc:title>
<dc:title xml:lang="en-US"><![CDATA[{{ translation.title|fixEncoding }}]]></dc:title>
{% endif %}
{% endfor %}
{% for author in record.articleAuthors %}
<dc:creator>
<![CDATA[{{ author.author.lastName }}, {{ author.author.firstName }}]]>{% if author.author.institution %}; {{ author.author.institution.name }}{% endif %}
<![CDATA[{{ author.author.lastName|fixEncoding }}, {{ author.author.firstName|fixEncoding }}]]>{% if author.author.institution %}; {{ author.author.institution.name }}{% endif %}
</dc:creator>
{% endfor %}
{% for translation in record.translations %}
{% if translation.keywords is not empty and translation.keywords != '-' %}
<dc:subject><![CDATA[{{ record.keywords }}]]></dc:subject>
<dc:subject><![CDATA[{{ record.keywords|fixEncoding }}]]></dc:subject>
{% endif %}
{% endfor %}
{% for translation in record.translations %}
{% if translation.abstract is not empty and translation.abstract != '-' %}
<dc:description><![CDATA[{{ translation.abstract|striptags|replace({'': '', '': '','': '','': ''}) }}]]></dc:description>
<dc:description><![CDATA[{{ translation.abstract|striptags|replace({'': '', '': '','': '','': ''})|fixEncoding }}]]></dc:description>
{% endif %}
{% endfor %}
{% for translation in record.journal.publisher.translations %}
Expand All @@ -55,16 +55,18 @@
<dc:identifier>{{ record.doi }}</dc:identifier>
{% if record.issue %}
<dc:source xml:lang="en-US">
<![CDATA[
{% if record.issue.displayMode is null or record.issue.displayMode == displayModes.all %}
{{ record.issue.title }}; Volume: {{ record.issue.volume }}, Issue: {{ record.issue.number }}
{{ record.issue.title|fixEncoding }}; Volume: {{ record.issue.volume }}, Issue: {{ record.issue.number }}
{% elseif record.issue.displayMode == displayModes.title %}
{{ record.issue.title }}
{{ record.issue.title|fixEncoding }}
{% elseif record.issue.displayMode == displayModes.volumeAndNumber %}
Volume: {{ record.issue.volume }}, Issue: {{ record.issue.number }}
{% endif %}
{% if record.firstPage and record.lastPage %}
{{ record.firstPage }}-{{ record.lastPage }}
{% endif %}
]]>
</dc:source>
{% endif %}
{% if record.journal.issn %}
Expand Down
30 changes: 30 additions & 0 deletions src/Ojs/OAIBundle/Twig/OaiExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Ojs\OAIBundle\Twig;

class OaiExtension extends \Twig_Extension
{
/**
* @return array
*/
public function getFilters()
{
return [
new \Twig_SimpleFilter('fixEncoding', [$this, 'fixEncoding'])
];
}

public function fixEncoding($value)
{
return preg_replace("/[[:cntrl:]]+/", "", $value);
}

/**
* Returns the name of the extension.
* @return string The extension name
*/
public function getName()
{
return 'ojs_oai_extension';
}
}

0 comments on commit 1a89b3c

Please sign in to comment.