Skip to content

Commit

Permalink
Merge branch 'addCompatibilityWithClassicTheme-886' into 'main'
Browse files Browse the repository at this point in the history
Adds compatibility with Classic Theme

See merge request softwares-pkp/plugins_ojs/authorAndSectionSearchFilters!4
  • Loading branch information
YvesLepidus committed Sep 17, 2024
2 parents bf0bf3a + 2aed13f commit 60f31e5
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ include:
ref: main
file:
- 'templates/groups/pkp_plugin.yml'
- 'templates/groups/ojs_3_4_plugins_cypress_tests_model.yml'
- 'templates/groups/ojs/cypress_tests.yml'

14 changes: 11 additions & 3 deletions AuthorAndSectionSearchFiltersPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,18 @@ public function replaceAuthorsFilter($hookName, $params)

public function replaceAuthorsInputFieldFilter($output, $templateMgr): string
{
$pattern = '/<input type="text" id="authors" [^>]+>/';
$context = Application::get()->getRequest()->getContext();
$pattern = '/<input type="text".*name="authors" [^>]+>/';
$templateName = $context->getData('themePluginPath') == "classic" ?
'newAuthorsFilterClassicTheme.tpl' : 'newAuthorsFilter.tpl';

if (preg_match($pattern, $output, $matches, PREG_OFFSET_CAPTURE)) {
$match = $matches[0][0];
$offset = $matches[0][1];

$templateMgr->assign('authorsList', $this->loadAuthors());
$newOutput = substr($output, 0, $offset);
$newOutput .= $templateMgr->fetch($this->getTemplateResource('newAuthorsFilter.tpl'));
$newOutput .= $templateMgr->fetch($this->getTemplateResource($templateName));
$newOutput .= substr($output, $offset + strlen($match));
$output = $newOutput;

Expand Down Expand Up @@ -117,7 +120,12 @@ public function createSectionsSearchFilter($hookName, $params): bool
$templateMgr->addStyleSheet('sectionSearchFilter', $styleUrl, ['contexts' => 'frontend']);

$templateMgr->assign('sectionsList', $this->loadSections());
$output .= $templateMgr->fetch($this->getTemplateResource('sectionSearchFilter.tpl'));

$context = Application::get()->getRequest()->getContext();
$templateName = $context->getData('themePluginPath') == "classic" ?
'sectionSearchFilterClassicTheme.tpl' : 'sectionSearchFilter.tpl';

$output .= $templateMgr->fetch($this->getTemplateResource($templateName));

return false;
}
Expand Down
4 changes: 4 additions & 0 deletions styles/sectionFilter.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@
width: 50%;
margin-top: 1.43rem;
}
}

#authorsClassicTheme, #sectionsClassicTheme {
width: -webkit-fill-available;
}
5 changes: 5 additions & 0 deletions templates/newAuthorsFilterClassicTheme.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="search-form-label">
<span>{translate key="search.author"}</span>
</div>

{fbvElement type="select" id="authorsClassicTheme" name="authors" defaultLabel="{translate key="plugins.generic.authorAndSectionSearchFilters.search.noneSelected"}" defaultValue="" selected=$authors from=$authorsList translate="0" size=$fbvStyles.size.MEDIUM}
6 changes: 6 additions & 0 deletions templates/sectionSearchFilterClassicTheme.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="search-form-label">
<span>{translate key="plugins.generic.authorAndSectionSearchFilters.search.sections"}</span>
</div>
{block name=searchSections}
{fbvElement type="select" id="sectionsClassicTheme" name="sections" defaultLabel="{translate key="plugins.generic.authorAndSectionSearchFilters.search.noneSelected"}" defaultValue="" selected=$sections from=$sectionsList translate="0" size=$fbvStyles.size.MEDIUM}
{/block}
4 changes: 2 additions & 2 deletions version.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ https://www.gnu.org/licenses/gpl-3.0.txt.
<version>
<application>authorAndSectionSearchFilters</application>
<type>plugins.generic</type>
<release>1.0.2.0</release>
<date>2024-02-19</date>
<release>1.0.2.1</release>
<date>2024-09-17</date>
<lazy-load>0</lazy-load>
<class>AuthorAndSectionSearchFiltersPlugin</class>
</version>

0 comments on commit 60f31e5

Please sign in to comment.