| Server IP : 195.130.67.5 / Your IP : 216.73.217.154 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/Old Sites/Civilgeo/ojs/classes/author/form/submit/ |
Upload File : |
<?php
/**
* @file classes/author/form/submit/AuthorSubmitStep3Form.inc.php
*
* Copyright (c) 2003-2012 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class AuthorSubmitStep3Form
* @ingroup author_form_submit
*
* @brief Form for Step 3 of author article submission.
*/
import('classes.author.form.submit.AuthorSubmitForm');
class AuthorSubmitStep3Form extends AuthorSubmitForm {
/**
* Constructor.
*/
function AuthorSubmitStep3Form(&$article, &$journal) {
parent::AuthorSubmitForm($article, 3, $journal);
// Validation checks for this form
$this->addCheck(new FormValidatorCustom($this, 'authors', 'required', 'author.submit.form.authorRequired', create_function('$authors', 'return count($authors) > 0;')));
$this->addCheck(new FormValidatorArray($this, 'authors', 'required', 'author.submit.form.authorRequiredFields', array('firstName', 'lastName')));
$this->addCheck(new FormValidatorArrayCustom($this, 'authors', 'required', 'author.submit.form.authorRequiredFields', create_function('$email, $regExp', 'return String::regexp_match($regExp, $email);'), array(ValidatorEmail::getRegexp()), false, array('email')));
$this->addCheck(new FormValidatorArrayCustom($this, 'authors', 'required', 'user.profile.form.urlInvalid', create_function('$url, $regExp', 'return empty($url) ? true : String::regexp_match($regExp, $url);'), array(ValidatorUrl::getRegexp()), false, array('url')));
$this->addCheck(new FormValidatorLocale($this, 'title', 'required', 'author.submit.form.titleRequired', $this->getRequiredLocale()));
$sectionDao =& DAORegistry::getDAO('SectionDAO');
$section = $sectionDao->getSection($article->getSectionId());
$abstractWordCount = $section->getAbstractWordCount();
if (isset($abstractWordCount) && $abstractWordCount > 0) {
$this->addCheck(new FormValidatorCustom($this, 'abstract', 'required', 'author.submit.form.wordCountAlert', create_function('$abstract, $wordCount', 'foreach ($abstract as $localizedAbstract) {return count(explode(" ",$localizedAbstract)) < $wordCount; }'), array($abstractWordCount)));
}
}
/**
* Initialize form data from current article.
*/
function initData() {
$sectionDao =& DAORegistry::getDAO('SectionDAO');
if (isset($this->article)) {
$article =& $this->article;
$this->_data = array(
'authors' => array(),
'title' => $article->getTitle(null), // Localized
'abstract' => $article->getAbstract(null), // Localized
'discipline' => $article->getDiscipline(null), // Localized
'subjectClass' => $article->getSubjectClass(null), // Localized
'subject' => $article->getSubject(null), // Localized
'coverageGeo' => $article->getCoverageGeo(null), // Localized
'coverageChron' => $article->getCoverageChron(null), // Localized
'coverageSample' => $article->getCoverageSample(null), // Localized
'type' => $article->getType(null), // Localized
'language' => $article->getLanguage(),
'sponsor' => $article->getSponsor(null), // Localized
'section' => $sectionDao->getSection($article->getSectionId()),
'citations' => $article->getCitations()
);
$authors =& $article->getAuthors();
for ($i=0, $count=count($authors); $i < $count; $i++) {
array_push(
$this->_data['authors'],
array(
'authorId' => $authors[$i]->getId(),
'firstName' => $authors[$i]->getFirstName(),
'middleName' => $authors[$i]->getMiddleName(),
'lastName' => $authors[$i]->getLastName(),
'affiliation' => $authors[$i]->getAffiliation(null),
'country' => $authors[$i]->getCountry(),
'email' => $authors[$i]->getEmail(),
'url' => $authors[$i]->getUrl(),
'competingInterests' => $authors[$i]->getCompetingInterests(null),
'biography' => $authors[$i]->getBiography(null)
)
);
if ($authors[$i]->getPrimaryContact()) {
$this->setData('primaryContact', $i);
}
}
}
return parent::initData();
}
/**
* Assign form data to user-submitted data.
*/
function readInputData() {
$this->readUserVars(
array(
'authors',
'deletedAuthors',
'primaryContact',
'title',
'abstract',
'discipline',
'subjectClass',
'subject',
'coverageGeo',
'coverageChron',
'coverageSample',
'type',
'language',
'sponsor',
'citations'
)
);
// Load the section. This is used in the step 3 form to
// determine whether or not to display indexing options.
$sectionDao =& DAORegistry::getDAO('SectionDAO');
$this->_data['section'] =& $sectionDao->getSection($this->article->getSectionId());
if ($this->_data['section']->getAbstractsNotRequired() == 0) {
$this->addCheck(new FormValidatorLocale($this, 'abstract', 'required', 'author.submit.form.abstractRequired', $this->getRequiredLocale()));
}
}
/**
* Get the names of fields for which data should be localized
* @return array
*/
function getLocaleFieldNames() {
return array('title', 'abstract', 'subjectClass', 'subject', 'coverageGeo', 'coverageChron', 'coverageSample', 'type', 'sponsor');
}
/**
* Display the form.
*/
function display() {
$templateMgr =& TemplateManager::getManager();
$countryDao =& DAORegistry::getDAO('CountryDAO');
$countries =& $countryDao->getCountries();
$templateMgr->assign_by_ref('countries', $countries);
if (Request::getUserVar('addAuthor') || Request::getUserVar('delAuthor') || Request::getUserVar('moveAuthor')) {
$templateMgr->assign('scrollToAuthor', true);
}
parent::display();
}
/**
* Save changes to article.
* @param $request Request
* @return int the article ID
*/
function execute(&$request) {
$articleDao =& DAORegistry::getDAO('ArticleDAO');
$authorDao =& DAORegistry::getDAO('AuthorDAO');
$article =& $this->article;
// Retrieve the previous citation list for comparison.
$previousRawCitationList = $article->getCitations();
// Update article
$article->setTitle($this->getData('title'), null); // Localized
$article->setAbstract($this->getData('abstract'), null); // Localized
$article->setDiscipline($this->getData('discipline'), null); // Localized
$article->setSubjectClass($this->getData('subjectClass'), null); // Localized
$article->setSubject($this->getData('subject'), null); // Localized
$article->setCoverageGeo($this->getData('coverageGeo'), null); // Localized
$article->setCoverageChron($this->getData('coverageChron'), null); // Localized
$article->setCoverageSample($this->getData('coverageSample'), null); // Localized
$article->setType($this->getData('type'), null); // Localized
$article->setLanguage($this->getData('language'));
$article->setSponsor($this->getData('sponsor'), null); // Localized
$article->setCitations($this->getData('citations'));
if ($article->getSubmissionProgress() <= $this->step) {
$article->stampStatusModified();
$article->setSubmissionProgress($this->step + 1);
}
// Update authors
$authors = $this->getData('authors');
for ($i=0, $count=count($authors); $i < $count; $i++) {
if ($authors[$i]['authorId'] > 0) {
// Update an existing author
$author =& $article->getAuthor($authors[$i]['authorId']);
$isExistingAuthor = true;
} else {
// Create a new author
$author = new Author();
$isExistingAuthor = false;
}
if ($author != null) {
$author->setSubmissionId($article->getId());
$author->setFirstName($authors[$i]['firstName']);
$author->setMiddleName($authors[$i]['middleName']);
$author->setLastName($authors[$i]['lastName']);
$author->setAffiliation($authors[$i]['affiliation'], null);
$author->setCountry($authors[$i]['country']);
$author->setEmail($authors[$i]['email']);
$author->setUrl($authors[$i]['url']);
if (array_key_exists('competingInterests', $authors[$i])) {
$author->setCompetingInterests($authors[$i]['competingInterests'], null);
}
$author->setBiography($authors[$i]['biography'], null);
$author->setPrimaryContact($this->getData('primaryContact') == $i ? 1 : 0);
$author->setSequence($authors[$i]['seq']);
if ($isExistingAuthor == false) {
$article->addAuthor($author);
}
}
unset($author);
}
// Remove deleted authors
$deletedAuthors = explode(':', $this->getData('deletedAuthors'));
for ($i=0, $count=count($deletedAuthors); $i < $count; $i++) {
$article->removeAuthor($deletedAuthors[$i]);
}
parent::execute();
// Save the article
$articleDao->updateArticle($article);
// Update references list if it changed.
$citationDao =& DAORegistry::getDAO('CitationDAO');
$rawCitationList = $article->getCitations();
if ($previousRawCitationList != $rawCitationList) {
$citationDao->importCitations($request, ASSOC_TYPE_ARTICLE, $article->getId(), $rawCitationList);
}
return $this->articleId;
}
}
?>