Skip to content

Commit

Permalink
Merge pull request #659 from jyhein/f699
Browse files Browse the repository at this point in the history
pkp/pkp-lib#699 Show locale in url in multilingual contexts
  • Loading branch information
bozana authored Apr 25, 2024
2 parents 2fbda9b + 0b9e650 commit 89fe381
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 18 deletions.
6 changes: 3 additions & 3 deletions cypress/tests/data/60-content/DphillipsSubmission.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('Data suite: Dphillips', function() {

it('Preprint is not available when unposted', function() {
cy.login('dbarnes');
cy.visit('/index.php/publicknowledge/workflow/access/' + submission.id);
cy.visit('/index.php/publicknowledge/en/workflow/access/' + submission.id);
cy.get('#publication-button').click();
cy.get('button').contains('Unpost').click();
cy.contains('Are you sure you don\'t want this to be posted?');
Expand All @@ -72,7 +72,7 @@ describe('Data suite: Dphillips', function() {
cy.contains('Signalling Theory Dividends').should('not.exist');
cy.logout();
cy.request({
url: '/index.php/publicknowledge/preprint/view/' + submission.id,
url: '/index.php/publicknowledge/en/preprint/view/' + submission.id,
failOnStatusCode: false
})
.then((response) => {
Expand All @@ -81,7 +81,7 @@ describe('Data suite: Dphillips', function() {

// Re-post it
cy.login('dbarnes');
cy.visit('/index.php/publicknowledge/workflow/access/' + submission.id);
cy.visit('/index.php/publicknowledge/en/workflow/access/' + submission.id);
cy.get('#publication-button').click();
cy.get('.pkpPublication button').contains('Post').click();
cy.contains('All requirements have been met.');
Expand Down
4 changes: 2 additions & 2 deletions cypress/tests/integration/Doi.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('DOI tests', function() {

cy.log('Check Submission Visibility');
// Select a submission
cy.visit(`/index.php/publicknowledge/preprint/view/${submissionId}`);
cy.visit(`/index.php/publicknowledge/en/preprint/view/${submissionId}`);

cy.get('section.item.doi')
.find('span.value').contains('https://doi.org/10.1234/');
Expand Down Expand Up @@ -411,7 +411,7 @@ describe('DOI tests', function() {
.click();
cy.get('#doisSetup [role="status"]').contains('Saved');

cy.visit('index.php/publicknowledge/dois');
cy.visit('index.php/publicknowledge/en/dois');

cy.get(
`#submission-doi-management .listPanel__item:contains("${articleTitle}") button.expander`
Expand Down
1 change: 0 additions & 1 deletion pages/user/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
// Misc.
//
case 'index':
case 'setLocale':
case 'authorizationDenied':
case 'toggleHelp':
case 'getInterests':
Expand Down
6 changes: 2 additions & 4 deletions plugins/blocks/languageToggle/LanguageToggleBlockPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,8 @@ public function getContents($templateMgr, $request = null)
$templateMgr->assign('languageToggleNoUser', true);
}

if (isset($locales) && count($locales) > 1) {
$templateMgr->assign('enableLanguageToggle', true);
$templateMgr->assign('languageToggleLocales', $locales);
}
$templateMgr->assign('enableLanguageToggle', count($locales) > 1);
$templateMgr->assign('languageToggleLocales', $locales);

return parent::getContents($templateMgr, $request);
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/blocks/languageToggle/templates/block.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<ul>
{foreach from=$languageToggleLocales item=localeName key=localeKey}
<li class="locale_{$localeKey|escape}{if $localeKey == $currentLocale} current{/if}" lang="{$localeKey|replace:"_":"-"}">
<a href="{url router=PKPApplication::ROUTE_PAGE page="user" op="setLocale" path=$localeKey source=$smarty.server.REQUEST_URI}">
<a href="{url router=PKPApplication::ROUTE_PAGE page="user" op="setLocale" path=$localeKey}">
{$localeName}
</a>
</li>
Expand Down
2 changes: 1 addition & 1 deletion plugins/generic/crossref
2 changes: 1 addition & 1 deletion plugins/generic/googleScholar
4 changes: 2 additions & 2 deletions plugins/metadata/dc11/filter/Dc11SchemaPreprintAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function &extractMetadataFromDataObject(&$submission)
// Identifier: URL
$request = Application::get()->getRequest();
$includeUrls = $server->getSetting('publishingMode') != \APP\server\Server::PUBLISHING_MODE_NONE;
$dc11Description->addStatement('dc:identifier', $request->url($server->getPath(), 'preprint', 'view', [$submission->getBestId()]));
$dc11Description->addStatement('dc:identifier', $request->getDispatcher()->url($request, Application::ROUTE_PAGE, $server->getPath(), 'preprint', 'view', [$submission->getBestId()], urlLocaleForPage: ''));

// Language
collect($galleys)
Expand All @@ -156,7 +156,7 @@ public function &extractMetadataFromDataObject(&$submission)
// full text URLs
if ($includeUrls) {
foreach ($galleys as $galley) {
$relation = $request->url($server->getPath(), 'preprint', 'view', [$submission->getBestId(), $galley->getBestGalleyId()]);
$relation = $request->getDispatcher()->url($request, Application::ROUTE_PAGE, $server->getPath(), 'preprint', 'view', [$submission->getBestId(), $galley->getBestGalleyId()], urlLocaleForPage: '');
$dc11Description->addStatement('dc:relation', $relation);
}
}
Expand Down
15 changes: 14 additions & 1 deletion plugins/oaiMetadataFormats/dc/tests/OAIMetadataFormat_DCTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use APP\submission\Submission;
use Illuminate\Support\LazyCollection;
use PHPUnit\Framework\MockObject\MockObject;
use PKP\core\Dispatcher;
use PKP\core\Registry;
use PKP\db\DAORegistry;
use PKP\doi\Doi;
Expand Down Expand Up @@ -184,13 +185,25 @@ public function testToXml()
->method('url')
->will($this->returnCallback(fn ($request, $newContext = null, $handler = null, $op = null, $path = null) => $handler . '-' . $op . '-' . implode('-', $path)));

// Dispatcher
/** @var Dispatcher|MockObject */
$dispatcher = $this->getMockBuilder(Dispatcher::class)
->onlyMethods(['url'])
->getMock();
$dispatcher->expects($this->any())
->method('url')
->will($this->returnCallback(fn ($request, $shortcut, $newContext = null, $handler = null, $op = null, $path = null) => $handler . '-' . $op . '-' . implode('-', $path)));

// Request
$requestMock = $this->getMockBuilder(Request::class)
->onlyMethods(['getRouter'])
->onlyMethods(['getRouter', 'getDispatcher'])
->getMock();
$requestMock->expects($this->any())
->method('getRouter')
->will($this->returnValue($router));
$requestMock->expects($this->any())
->method('getDispatcher')
->will($this->returnValue($dispatcher));
Registry::set('request', $requestMock);


Expand Down

0 comments on commit 89fe381

Please sign in to comment.