Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into 1861-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kaschioudi committed Jan 12, 2017
2 parents 207c8da + 6cf3342 commit 13e8808
Show file tree
Hide file tree
Showing 278 changed files with 2,319 additions and 6,975 deletions.
17 changes: 17 additions & 0 deletions classes/article/Article.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,24 @@ function setCoverImageAltText($coverImageAltText, $locale) {
$this->setData('coverImageAltText', $coverImageAltText, $locale);
}

/**
* Get a full URL to the localized cover image
*
* @return string
*/
function getLocalizedCoverImageUrl() {
$coverImage = $this->getLocalizedCoverImage();
if (!$coverImage) {
return '';
}

$request = Application::getRequest();

import('classes.file.PublicFileManager');
$publicFileManager = new PublicFileManager();

return $request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($this->getContextId()) . '/' . $coverImage;
}
}

?>
7 changes: 6 additions & 1 deletion classes/article/ArticleGalley.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ function __construct() {
*/
function getViews() {
$application = PKPApplication::getApplication();
return $application->getPrimaryMetricByAssoc(ASSOC_TYPE_GALLEY, $this->getId());
$fileId = $this->getFileId();
if ($fileId) {
return $application->getPrimaryMetricByAssoc(ASSOC_TYPE_SUBMISSION_FILE, $fileId);
} else {
return 0;
}
}

/**
Expand Down
1 change: 0 additions & 1 deletion classes/core/Application.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ function getDAOMap() {
'ArticleGalleyDAO' => 'classes.article.ArticleGalleyDAO',
'ArticleSearchDAO' => 'classes.search.ArticleSearchDAO',
'AuthorDAO' => 'classes.article.AuthorDAO',
'EditorSubmissionDAO' => 'classes.submission.editor.EditorSubmissionDAO',
'EmailTemplateDAO' => 'classes.mail.EmailTemplateDAO',
'GiftDAO' => 'classes.gift.GiftDAO',
'IndividualSubscriptionDAO' => 'classes.subscription.IndividualSubscriptionDAO',
Expand Down
2 changes: 1 addition & 1 deletion classes/file/IssueFileManager.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class IssueFileManager extends FileManager {
function __construct($issueId) {
$issueDao = DAORegistry::getDAO('IssueDAO');
$issue = $issueDao->getById($issueId);
assert($issue);
assert(isset($issue));

$this->setIssueId($issueId);
$this->setFilesDir(Config::getVar('files', 'files_dir') . '/journals/' . $issue->getJournalId() . '/issues/' . $issueId . '/');
Expand Down
206 changes: 169 additions & 37 deletions classes/install/Upgrade.inc.php

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions classes/issue/Issue.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,25 @@ function getCoverImageAltText($locale) {
return $this->getData('coverImageAltText', $locale);
}

/**
* Get a full URL to the localized cover image
*
* @return string
*/
function getLocalizedCoverImageUrl() {
$coverImage = $this->getLocalizedCoverImage();
if (!$coverImage) {
return '';
}

$request = Application::getRequest();

import('classes.file.PublicFileManager');
$publicFileManager = new PublicFileManager();

return $request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($this->getJournalId()) . '/' . $coverImage;
}

/**
* Set issue cover image alternate text
* @param $coverImageAltText string
Expand Down
16 changes: 0 additions & 16 deletions classes/journal/Section.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,22 +194,6 @@ function setHideAuthor($hideAuthor) {
return $this->setData('hideAuthor', $hideAuthor);
}

/**
* Return boolean indicating if title should be hidden in About.
* @return boolean
*/
function getHideAbout() {
return $this->getData('hideAbout');
}

/**
* Set if title should be hidden in About.
* @param $hideAbout boolean
*/
function setHideAbout($hideAbout) {
return $this->setData('hideAbout', $hideAbout);
}

/**
* Get localized section policy.
* @return string
Expand Down
21 changes: 5 additions & 16 deletions classes/journal/SectionDAO.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ function _fromRow($row) {
$section->setAbstractsNotRequired($row['abstracts_not_required']);
$section->setHideTitle($row['hide_title']);
$section->setHideAuthor($row['hide_author']);
$section->setHideAbout($row['hide_about']);
$section->setAbstractWordCount($row['abstract_word_count']);

$this->getDataObjectSettings('section_settings', 'section_id', $row['section_id'], $section);
Expand Down Expand Up @@ -193,9 +192,9 @@ function updateLocaleFields($section) {
function insertObject($section) {
$this->update(
'INSERT INTO sections
(journal_id, review_form_id, seq, meta_indexed, meta_reviewed, abstracts_not_required, editor_restricted, hide_title, hide_author, hide_about, abstract_word_count)
(journal_id, review_form_id, seq, meta_indexed, meta_reviewed, abstracts_not_required, editor_restricted, hide_title, hide_author, abstract_word_count)
VALUES
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
array(
(int)$section->getJournalId(),
(int)$section->getReviewFormId(),
Expand All @@ -206,7 +205,6 @@ function insertObject($section) {
$section->getEditorRestricted() ? 1 : 0,
$section->getHideTitle() ? 1 : 0,
$section->getHideAuthor() ? 1 : 0,
$section->getHideAbout() ? 1 : 0,
(int) $section->getAbstractWordCount()
)
);
Expand All @@ -232,7 +230,6 @@ function updateObject($section) {
editor_restricted = ?,
hide_title = ?,
hide_author = ?,
hide_about = ?,
abstract_word_count = ?
WHERE section_id = ?',
array(
Expand All @@ -244,7 +241,6 @@ function updateObject($section) {
(int)$section->getEditorRestricted(),
(int)$section->getHideTitle(),
(int)$section->getHideAuthor(),
(int)$section->getHideAbout(),
$this->nullOrInt($section->getAbstractWordCount()),
(int)$section->getId()
)
Expand Down Expand Up @@ -394,20 +390,13 @@ function getEmptyByJournalId($journalId) {
* Retrieve the IDs and titles of the sections for a journal in an associative array.
* @return array
*/
function &getSectionTitles($journalId, $submittableOnly = false) {
function getTitles($journalId, $submittableOnly = false) {
$sections = array();

$sectionsIterator = $this->getByJournalId($journalId);
while ($section = $sectionsIterator->next()) {
if ($submittableOnly) {
if (!$section->getEditorRestricted()) {
$sections[$section->getId()] = $section->getLocalizedTitle();
}
} else {
$sections[$section->getId()] = $section->getLocalizedTitle();
}
if ($submittableOnly && $section->getEditorRestricted()) continue;
$sections[$section->getId()] = $section->getLocalizedTitle();
}

return $sections;
}

Expand Down
10 changes: 6 additions & 4 deletions classes/plugins/CitationPlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ function loadJavaScript($hookName, $args) {
*/
function fetchCitation($article, $issue, $journal) {
$templateMgr = TemplateManager::getManager($this->getRequest());
$templateMgr->assign('citationPlugin', $this);
$templateMgr->assign('article', $article);
$templateMgr->assign('issue', $issue);
$templateMgr->assign('journal', $journal);
$templateMgr->assign(array(
'citationPlugin' => $this,
'article' => $article,
'issue' => $issue,
'journal' => $journal,
));
return $templateMgr->fetch($this->getTemplatePath() . '/citation.tpl');
}

Expand Down
24 changes: 2 additions & 22 deletions classes/plugins/PubObjectsExportPlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,38 +275,18 @@ function exportXML($objects, $filter, $context) {
libxml_use_internal_errors(true);
$exportXml = $exportFilter->execute($objects, true);
$xml = $exportXml->saveXml();
$errors = array_filter(libxml_get_errors(), create_function('$a', 'return $a->level == LIBXML_ERR_ERROR || $a->level == LIBXML_ERR_FATAL;'));
$errors = array_filter(libxml_get_errors(), create_function('$a', 'return $a->level == LIBXML_ERR_ERROR || $a->level == LIBXML_ERR_FATAL;'));
if (!empty($errors)) {
$charset = Config::getVar('i18n', 'client_charset');
header('Content-type: text/html; charset=' . $charset);
echo '<html><body>';
$this->displayXMLValidationErrors($errors, $xml);
fatalError(__('plugins.importexport.common.error.validation'));
echo '</body></html>';
fatalError(__('plugins.importexport.common.error.validation'));
}
return $xml;
}

/**
* Display XML validation errors.
* @param $errors array
* @param $xml string
*/
function displayXMLValidationErrors($errors, $xml) {
echo '<h2>' . __('plugins.importexport.common.validationErrors') .'</h2>';

foreach ($errors as $error) {
switch ($error->level) {
case LIBXML_ERR_ERROR:
case LIBXML_ERR_FATAL:
echo '<p>' .trim($error->message) .'</p>';
}
}
libxml_clear_errors();
echo '<h3>' . __('plugins.importexport.common.invalidXML') .'</h3>';
echo '<p><pre>' .htmlspecialchars($xml) .'</pre></p>';
}

/**
* Mark selected submissions or issues as registered.
* @param $context Context
Expand Down
3 changes: 2 additions & 1 deletion classes/search/ArticleSearchIndex.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,10 @@ static function submissionFilesChanged($article) {
// default database search implementation.
if ($hookResult === false || is_null($hookResult)) {
$fileDao = DAORegistry::getDAO('SubmissionFileDAO');
import('lib.pkp.classes.submission.SubmissionFile'); // Constants
// Index galley files
$files = $fileDao->getLatestRevisions(
$article->getId(), WORKFLOW_STAGE_ID_PRODUCTION
$article->getId(), SUBMISSION_FILE_PROOF
);
foreach ($files as $file) {
if ($file->getFileId()) {
Expand Down
2 changes: 0 additions & 2 deletions classes/security/RoleDAO.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
/** ID codes for all user roles */
define('ROLE_ID_SECTION_EDITOR', 0x00000011);
define('ROLE_ID_SUBSCRIPTION_MANAGER', 0x00200000);
define('ROLE_ID_GUEST_EDITOR', 0x00000201);

/** Fill in the blanks for roles used in PKP lib */
define('ROLE_ID_SUB_EDITOR', ROLE_ID_SECTION_EDITOR);
Expand All @@ -44,7 +43,6 @@ static function getRoleNames($contextOnly = false, $roleIds = null) {

$journalRoleNames = array(
ROLE_ID_MANAGER => 'user.role.manager',
ROLE_ID_GUEST_EDITOR => 'user.role.guestEditor',
ROLE_ID_ASSISTANT => 'user.role.journalAssistant',
ROLE_ID_SECTION_EDITOR => 'user.role.sectionEditor',
ROLE_ID_SUBSCRIPTION_MANAGER => 'user.role.subscriptionManager',
Expand Down
10 changes: 7 additions & 3 deletions classes/submission/form/SubmissionSubmitStep1Form.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ function __construct($context, $submission = null) {
* Fetch the form.
*/
function fetch($request) {
$templateMgr = TemplateManager::getManager($request);
$roleDao = DAORegistry::getDAO('RoleDAO');
$user = $request->getUser();
$canSubmitAll = $roleDao->userHasRole($this->context->getId(), $user->getId(), ROLE_ID_MANAGER) ||
$roleDao->userHasRole($this->context->getId(), $user->getId(), ROLE_ID_SUB_EDITOR);

// Get section for this context
// Get section options for this context
$sectionDao = DAORegistry::getDAO('SectionDAO');
$sectionOptions = array('0' => '') + $sectionDao->getSectionTitles($this->context->getId());
$sectionOptions = array('0' => '') + $sectionDao->getTitles($this->context->getId(), !$canSubmitAll);
$templateMgr = TemplateManager::getManager($request);
$templateMgr->assign('sectionOptions', $sectionOptions);

return parent::fetch($request);
Expand Down
12 changes: 7 additions & 5 deletions classes/tasks/OpenAccessNotification.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ function sendNotification ($users, $journal, $issue) {
$mimeBoundary = '==boundary_' . md5(microtime());

$templateMgr = TemplateManager::getManager();
$templateMgr->assign('body', $email->getBody($journal->getPrimaryLocale()));
$templateMgr->assign('templateSignature', $journal->getSetting('emailSignature'));
$templateMgr->assign('mimeBoundary', $mimeBoundary);
$templateMgr->assign('issue', $issue);
$templateMgr->assign('publishedArticles', $publishedArticles);
$templateMgr->assign(array(
'body' => $email->getBody($journal->getPrimaryLocale()),
'templateSignature' => $journal->getSetting('emailSignature'),
'mimeBoundary' => $mimeBoundary,
'issue' => $issue,
'publishedArticles' => $publishedArticles,
));

$email->addHeader('MIME-Version', '1.0');
$email->setContentType('multipart/alternative; boundary="'.$mimeBoundary.'"');
Expand Down
54 changes: 27 additions & 27 deletions classes/template/TemplateManager.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,21 @@ function __construct($request) {
}
if (isset($context)) {

$this->assign('currentJournal', $context);
$this->assign('siteTitle', $context->getLocalizedName());
$this->assign('publicFilesDir', $request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($context->getId()));

$this->assign('primaryLocale', $context->getPrimaryLocale());
$this->assign('supportedLocales', $context->getSupportedLocaleNames());

// Assign page header
$this->assign('displayPageHeaderTitle', $context->getLocalizedPageHeaderTitle());
$this->assign('displayPageHeaderLogo', $context->getLocalizedPageHeaderLogo());
$this->assign('displayPageHeaderLogoAltText', $context->getLocalizedSetting('pageHeaderLogoImageAltText'));
$this->assign('numPageLinks', $context->getSetting('numPageLinks'));
$this->assign('itemsPerPage', $context->getSetting('itemsPerPage'));
$this->assign('enableAnnouncements', $context->getSetting('enableAnnouncements'));
$this->assign('contextSettings', $context->getSettingsDAO()->getSettings($context->getId()));
$this->assign('disableUserReg', $context->getSetting('disableUserReg'));
$this->assign(array(
'currentJournal' => $context,
'siteTitle' => $context->getLocalizedName(),
'publicFilesDir' => $request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($context->getId()),
'primaryLocale' => $context->getPrimaryLocale(),
'supportedLocales' => $context->getSupportedLocaleNames(),
'displayPageHeaderTitle' => $context->getLocalizedPageHeaderTitle(),
'displayPageHeaderLogo' => $context->getLocalizedPageHeaderLogo(),
'displayPageHeaderLogoAltText' => $context->getLocalizedSetting('pageHeaderLogoImageAltText'),
'numPageLinks' => $context->getSetting('numPageLinks'),
'itemsPerPage' => $context->getSetting('itemsPerPage'),
'enableAnnouncements' => $context->getSetting('enableAnnouncements'),
'contextSettings' => $context->getSettingsDAO()->getSettings($context->getId()),
'disableUserReg' => $context->getSetting('disableUserReg'),
));

// Assign meta tags
$favicon = $context->getLocalizedFavicon();
Expand Down Expand Up @@ -118,15 +117,6 @@ function __construct($request) {
$this->assign('journalPaymentsEnabled', $paymentManager->isConfigured());
$this->assign('pageFooter', $context->getLocalizedSetting('pageFooter'));
} else {
// Add the site-wide logo, if set for this locale or the primary locale
$this->assign('displayPageHeaderTitle', $site->getLocalizedPageHeaderTitle());
$this->assign('displayPageHeaderLogo', $site->getLocalizedSetting('pageHeaderTitleImage'));

$this->assign('siteTitle', $site->getLocalizedTitle());
$this->assign('primaryLocale', $site->getPrimaryLocale());
$this->assign('supportedLocales', $site->getSupportedLocaleNames());
$this->assign('pageFooter', $site->getLocalizedSetting('pageFooter'));

// Check if registration is open for any contexts
$contextDao = Application::getContextDAO();
$contexts = $contextDao->getAll(true)->toArray();
Expand All @@ -136,8 +126,18 @@ function __construct($request) {
$contextsForRegistration[] = $context;
}
}
$this->assign('contexts', $contextsForRegistration);
$this->assign('disableUserReg', empty($contextsForRegistration));

$this->assign(array(
'contexts' => $contextsForRegistration,
'disableUserReg' => empty($contextsForRegistration),
'displayPageHeaderTitle' => $site->getLocalizedPageHeaderTitle(),
'displayPageHeaderLogo' => $site->getLocalizedSetting('pageHeaderTitleImage'),
'siteTitle' => $site->getLocalizedTitle(),
'primaryLocale' => $site->getPrimaryLocale(),
'supportedLocales' => $site->getSupportedLocaleNames(),
'pageFooter' => $site->getLocalizedSetting('pageFooter'),
));

}
}
}
Expand Down
4 changes: 1 addition & 3 deletions controllers/grid/settings/sections/form/SectionForm.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ function initData($args, $request) {
'editorRestriction' => $section->getEditorRestricted(),
'hideTitle' => $section->getHideTitle(),
'hideAuthor' => $section->getHideAuthor(),
'hideAbout' => $section->getHideAbout(),
'policy' => $section->getPolicy(null), // Localized
'wordCount' => $section->getAbstractWordCount()
);
Expand Down Expand Up @@ -99,7 +98,7 @@ function fetch($request) {
*/
function readInputData() {
parent::readInputData();
$this->readUserVars(array('abbrev', 'policy', 'reviewFormId', 'identifyType', 'metaIndexed', 'metaReviewed', 'abstractsNotRequired', 'editorRestriction', 'hideTitle', 'hideAuthor', 'hideAbout', 'wordCount'));
$this->readUserVars(array('abbrev', 'policy', 'reviewFormId', 'identifyType', 'metaIndexed', 'metaReviewed', 'abstractsNotRequired', 'editorRestriction', 'hideTitle', 'hideAuthor', 'wordCount'));
}

/**
Expand Down Expand Up @@ -142,7 +141,6 @@ function execute($args, $request) {
$section->setEditorRestricted($this->getData('editorRestriction') ? 1 : 0);
$section->setHideTitle($this->getData('hideTitle') ? 1 : 0);
$section->setHideAuthor($this->getData('hideAuthor') ? 1 : 0);
$section->setHideAbout($this->getData('hideAbout') ? 1 : 0);
$section->setPolicy($this->getData('policy'), null); // Localized
$section->setAbstractWordCount($this->getData('wordCount'));

Expand Down
Loading

0 comments on commit 13e8808

Please sign in to comment.