Skip to content

Commit

Permalink
Support 3.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ajnyga committed Dec 18, 2024
0 parents commit 4a54b98
Show file tree
Hide file tree
Showing 11 changed files with 405 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.htaccess
.project
.buildpath
.settings
.DS_Store
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# themeIssues

OJS 3.3.0

Plugin for tagging theme issues and presenting them on a simple archive page.

After enabling the plugin see Issue settings and Issue Data tab. Use the checbox in the bottom to tag the issue as a theme issue.

All marked theme issues listed in: *journalpath/themeissues* which you can add to your navigation menu.

***
Plugin created by The Federation of Finnish Learned Societies (https://tsv.fi/en/).
***
125 changes: 125 additions & 0 deletions ThemeIssuesPlugin.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?php

/**
* @file plugins/generic/themeIssues/ThemeIssuesPlugin.inc.php
*
* Copyright (c) 2014-2020 Simon Fraser University
* Copyright (c) 2003-2020 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class ThemeIssuesPlugin
* @ingroup plugins_generic_themeIssues
*
* @brief ThemeIssues plugin class
*/

import('lib.pkp.classes.plugins.GenericPlugin');

class ThemeIssuesPlugin extends GenericPlugin {

/**
* Called as a plugin is registered to the registry
* @param $category String Name of category plugin was registered to
* @return boolean True if plugin initialized successfully; if false,
* the plugin will not be registered.
*/
function register($category, $path, $mainContextId = NULL) {
$success = parent::register($category, $path);
if ($success && $this->getEnabled()) {

HookRegistry::register('LoadHandler', array($this, 'loadPageHandler'));

// Handle issue form
HookRegistry::register('Templates::Editor::Issues::IssueData::AdditionalMetadata', array($this, 'addIssueFormFields'));
HookRegistry::register('issuedao::getAdditionalFieldNames', array($this, 'addIssueDAOFieldNames'));
HookRegistry::register('issueform::readuservars', array($this, 'readIssueFormFields'));
HookRegistry::register('issueform::initdata', array($this, 'initDataIssueFormFields'));
HookRegistry::register('issueform::execute', array($this, 'executeIssueFormFields'));
}
return $success;
}

/**
* @copydoc Plugin::getDisplayName()
*/
function getDisplayName() {
return __('plugins.generic.themeIssues.displayName');
}

/**
* @copydoc Plugin::getDescription()
*/
function getDescription() {
return __('plugins.generic.themeIssues.description');
}

/**
* Load the handler to deal with browse by section page requests
*/
public function loadPageHandler($hookName, $args) {
$page = $args[0];
if ($this->getEnabled() && $page === 'themeissues') {
$this->import('pages/ThemeIssuesHandler');
define('HANDLER_CLASS', 'ThemeIssuesHandler');
return true;
}

return false;
}

/**
* Add fields to the issue editing form
*/
public function addIssueFormFields($hookName, $args) {
$smarty =& $args[1];
$output =& $args[2];
$output .= $smarty->fetch($this->getTemplateResource('themeIssuesEdit.tpl'));
return false;
}

/**
* Read user input from additional fields in the issue editing form
*/
public function readIssueFormFields($hookName, $args) {
$issueForm =& $args[0];
$request = $this->getRequest();
$issueForm->setData('isThemeIssue', $request->getUserVar('isThemeIssue'));
}

/**
* Save additional fields in the issue editing form
*/
public function executeIssueFormFields($hookName, $args) {
$issueForm = $args[0];
$issue = $args[1];

// The issueform::execute hook fires twice, once at the start of the
// method when no issue exists. Only update the object during the
// second request
if (!$issue) {
return;
}

$issue->setData('isThemeIssue', $issueForm->getData('isThemeIssue'));
$issueDao = DAORegistry::getDAO('IssueDAO');
$issueDao->updateObject($issue);
}

/**
* Initialize data when form is first loaded
*/
public function initDataIssueFormFields($hookName, $args) {
$issueForm = $args[0];
$issueForm->setData('isThemeIssue', $issueForm->issue->getData('isThemeIssue'));
}

/**
* Add section settings to IssueDAO
*/
public function addIssueDAOFieldNames($hookName, $args) {
$fields =& $args[1];
$fields[] = 'isThemeIssue';
}

}
?>
22 changes: 22 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/**
* @defgroup plugins_generic_themeIssues themeIssues Plugin
*/

/**
* @file plugins/generic/themeIssues/index.php
*
* Copyright (c) 2014-2020 Simon Fraser University
* Copyright (c) 2003-2020 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @ingroup plugins_generic_themeIssues
* @brief Wrapper for themeIssues plugin.
*
*/
require_once('ThemeIssuesPlugin.inc.php');

return new ThemeIssuesPlugin();

?>
24 changes: 24 additions & 0 deletions locale/en_US/locale.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2024-12-18T13:43:40+00:00\n"
"PO-Revision-Date: 2024-12-18T13:43:40+00:00\n"
"Language: \n"

msgid "plugins.generic.themeIssues.displayName"
msgstr "Theme Issues"

msgid "plugins.generic.themeIssues.description"
msgstr "Theme Issues plugin enables editors to tag published theme issues and list them all in an archive page."

msgid "plugins.generic.themeIssues.title"
msgstr "Theme Issues"

msgid "plugins.generic.themeIssues.label"
msgstr "This is a theme issue"
24 changes: 24 additions & 0 deletions locale/fi_FI/locale.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2024-12-18T13:43:40+00:00\n"
"PO-Revision-Date: 2024-12-18T13:43:40+00:00\n"
"Language: \n"

msgid "plugins.generic.themeIssues.displayName"
msgstr "Teemanumerot-lisäosa"

msgid "plugins.generic.themeIssues.description"
msgstr "Lisäosan avulla toimittaja voi merkitä teemanumerot ja esittää ne koottuna yhdellä arkistosivulla."

msgid "plugins.generic.themeIssues.title"
msgstr "Teemanumerot"

msgid "plugins.generic.themeIssues.label"
msgstr "Tämä on teemanumero"
24 changes: 24 additions & 0 deletions locale/sv_SE/locale.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2024-12-18T13:43:40+00:00\n"
"PO-Revision-Date: 2024-12-18T13:43:40+00:00\n"
"Language: \n"

msgid "plugins.generic.themeIssues.displayName"
msgstr "Teemanumerot-lisäosa"

msgid "plugins.generic.themeIssues.description"
msgstr "Lisäosan avulla toimittaja voi merkitä teemanumerot ja esittää ne koottuna yhdellä arkistosivulla."

msgid "plugins.generic.themeIssues.title"
msgstr "Teemanumerot"

msgid "plugins.generic.themeIssues.label"
msgstr "Tämä on teemanumero"
65 changes: 65 additions & 0 deletions pages/ThemeIssuesHandler.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

/**
* @file plugins/generic/themeIssues/pages/BrowseBySectionHandler.inc.php
*
* Copyright (c) 2014-2020 Simon Fraser University
* Copyright (c) 2003-2020 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class ThemeIssuesHandler
* @ingroup plugins_generic_themeIssues
*
* @brief Handle reader-facing router requests
*/

import('classes.handler.Handler');

class ThemeIssuesHandler extends Handler {

/**
* @copydoc PKPHandler::authorize()
*/
function authorize($request, &$args, $roleAssignments) {
import('lib.pkp.classes.security.authorization.ContextRequiredPolicy');
$this->addPolicy(new ContextRequiredPolicy($request));

import('classes.security.authorization.OjsJournalMustPublishPolicy');
$this->addPolicy(new OjsJournalMustPublishPolicy($request));

return parent::authorize($request, $args, $roleAssignments);
}

/**
* View theme issues
*/
public function index($args, $request) {
$this->setupTemplate($request);
$templateMgr = TemplateManager::getManager($request);
$context = $request->getContext();
$plugin = PluginRegistry::getPlugin('generic', 'themeissuesplugin');

$params = array(
'contextId' => $context->getId(),
'orderBy' => 'seq',
'orderDirection' => 'ASC',
'count' => $count,
'offset' => $offset,
'isPublished' => true,
);
$issues = iterator_to_array(Services::get('issue')->getMany($params));

$themeIssues = [];
foreach ($issues as $issue) {
if ($issue->getData('isThemeIssue')){
$themeIssues[] = $issue;
}
}

$templateMgr->assign(array(
'issues' => $themeIssues,
));

return $templateMgr->display($plugin->getTemplateResource('themeIssues.tpl'));
}
}
68 changes: 68 additions & 0 deletions templates/themeIssues.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{**
* plugins/generic/themeIssues/themeIssues.tpl
*
* Copyright (c) 2014-2020 Simon Fraser University
* Copyright (c) 2003-2020 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* Edit themeIssues
*
*}
{capture assign="pageTitle"}{translate key="plugins.generic.themeIssues.title"}{/capture}
{include file="frontend/components/header.tpl" pageTitleTranslated=$pageTitle}

<div class="page page_issue_archive">
{include file="frontend/components/breadcrumbs.tpl" currentTitle=$pageTitle}
<h1>
{$pageTitle|escape}
</h1>

{* No issues have been published *}
{if empty($issues)}
<p>{translate key="current.noCurrentIssueDesc"}</p>

{* List issues *}
{else}
<ul class="issues_archive">
{foreach from=$issues item="issue"}
<li>
{if $issue->getShowTitle()}
{assign var=issueTitle value=$issue->getLocalizedTitle()}
{/if}
{assign var=issueSeries value=$issue->getIssueSeries()}
{assign var=issueCover value=$issue->getLocalizedCoverImageUrl()}

<div class="obj_issue_summary">

{if $issueCover}
<a class="cover" href="{url op="view" path=$issue->getBestIssueId()}">
<img src="{$issueCover|escape}" alt="{$issue->getLocalizedCoverImageAltText()|escape|default:''}">
</a>
{/if}

<h2>
<a class="title" href="{url page="issue" op="view" path=$issue->getBestIssueId()}">
{if $issueTitle}
{$issueTitle|escape}
{else}
{$issueSeries|escape}
{/if}
</a>
{if $issueTitle && $issueSeries}
<div class="series">
{$issueSeries|escape}
</div>
{/if}
</h2>

<div class="description">
{$issue->getLocalizedDescription()|strip_unsafe_html}
</div>
</div><!-- .obj_issue_summary -->
</li>
{/foreach}
</ul>
{/if}
</div>

{include file="frontend/components/footer.tpl"}
15 changes: 15 additions & 0 deletions templates/themeIssuesEdit.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{**
* plugins/generic/themeIssues/themeIssuesEdit.tpl
*
* Copyright (c) 2014-2020 Simon Fraser University
* Copyright (c) 2003-2020 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* Edit themeIssues
*
*}
{fbvFormArea id="themeIssues"}
{fbvFormSection list="true"}
{fbvElement type="checkbox" id="isThemeIssue" label="plugins.generic.themeIssues.label" checked=$isThemeIssue|compare:true}
{/fbvFormSection}
{/fbvFormArea}
Loading

0 comments on commit 4a54b98

Please sign in to comment.