Skip to content

Commit

Permalink
pkp#4427# Fixed section setters/getters
Browse files Browse the repository at this point in the history
  • Loading branch information
asmecher committed Jan 27, 2010
1 parent 1ca0014 commit 26695e2
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 41 deletions.
8 changes: 5 additions & 3 deletions classes/journal/Section.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,17 @@ function getTrackAbbrev() {
* @return int
*/
function getSectionId() {
return $this->getData('sectionId');
if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
return $this->getId();
}

/**
* Set ID of section.
* @param $sectionId int
*/
function setSectionId($sectionId) {
return $this->setData('sectionId', $sectionId);
if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
return $this->setId($sectionId);
}

/**
Expand Down Expand Up @@ -138,7 +140,7 @@ function getAbbrev($locale) {
function setAbbrev($abbrev, $locale) {
return $this->setData('abbrev', $abbrev, $locale);
}

/**
* Get abstract word count limit.
* @return int
Expand Down
26 changes: 13 additions & 13 deletions classes/journal/SectionDAO.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function &getSectionByTitleAndAbbrev($sectionTitle, $sectionAbbrev, $journalId,
*/
function &_returnSectionFromRow(&$row) {
$section = new Section();
$section->setSectionId($row['section_id']);
$section->setId($row['section_id']);
$section->setJournalId($row['journal_id']);
$section->setReviewFormId($row['review_form_id']);
$section->setSequence($row['seq']);
Expand Down Expand Up @@ -168,7 +168,7 @@ function getLocaleFieldNames() {
*/
function updateLocaleFields(&$section) {
$this->updateDataObjectSettings('section_settings', $section, array(
'section_id' => $section->getSectionId()
'section_id' => $section->getId()
));
}

Expand Down Expand Up @@ -198,9 +198,9 @@ function insertSection(&$section) {
)
);

$section->setSectionId($this->getInsertSectionId());
$section->setId($this->getInsertSectionId());
$this->updateLocaleFields($section);
return $section->getSectionId();
return $section->getId();
}

/**
Expand Down Expand Up @@ -235,7 +235,7 @@ function updateSection(&$section) {
$section->getHideAbout(),
$section->getDisableComments(),
$section->getAbstractWordCount(),
$section->getSectionId()
$section->getId()
)
);
$this->updateLocaleFields($section);
Expand All @@ -247,7 +247,7 @@ function updateSection(&$section) {
* @param $section Section
*/
function deleteSection(&$section) {
return $this->deleteSectionById($section->getSectionId(), $section->getJournalId());
return $this->deleteSectionById($section->getId(), $section->getJournalId());
}

/**
Expand Down Expand Up @@ -367,10 +367,10 @@ function &getSectionTitles($journalId, $submittableOnly = false) {
while (($section =& $sectionsIterator->next())) {
if ($submittableOnly) {
if (!$section->getEditorRestricted()) {
$sections[$section->getSectionId()] = $section->getLocalizedTitle();
$sections[$section->getId()] = $section->getLocalizedTitle();
}
} else {
$sections[$section->getSectionId()] = $section->getLocalizedTitle();
$sections[$section->getId()] = $section->getLocalizedTitle();
}
unset($section);
}
Expand Down Expand Up @@ -441,20 +441,20 @@ function deleteCustomSectionOrdering($issueId) {
'DELETE FROM custom_section_orders WHERE issue_id = ?', $issueId
);
}

/**
* Delete a section from the custom section order table.
* @param $issueId int
* @param $sectionId int
* @param $sectionId int
*/
function deleteCustomSection($issueId, $sectionId) {
$sequence = $this->getCustomSectionOrder($issueId, $sectionId);

$this->update(
'DELETE FROM custom_section_orders WHERE issue_id = ? AND section_id = ?', array($issueId, $sectionId)
);
// Reduce the section order of every successive section by one

// Reduce the section order of every successive section by one
$this->update(
'UPDATE custom_section_orders SET seq = seq - 1 WHERE issue_id = ? AND seq > ?', array($issueId, $sequence)
);
Expand Down
4 changes: 2 additions & 2 deletions classes/manager/form/SectionForm.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ function execute() {
$section->setPolicy($this->getData('policy'), null); // Localized
$section->setAbstractWordCount($this->getData('wordCount'));

if ($section->getSectionId() != null) {
if ($section->getId() != null) {
$sectionDao->updateSection($section);
$sectionId = $section->getSectionId();
$sectionId = $section->getId();

} else {
$sectionId = $sectionDao->insertSection($section);
Expand Down
2 changes: 1 addition & 1 deletion classes/oai/ojs/OAIDAO.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ function getSetJournalSectionId($journalSpec, $sectionSpec, $restrictJournalId =
if (isset($sectionSpec)) {
$section =& $this->sectionDao->getSectionByAbbrev($sectionSpec, $journal->getId());
if (isset($section)) {
$sectionId = $section->getSectionId();
$sectionId = $section->getId();
} else {
$sectionId = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion pages/about/AboutHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ function editorialPolicies() {

$sectionEditorEntriesBySection = array();
foreach ($sections as $section) {
$sectionEditorEntriesBySection[$section->getSectionId()] =& $sectionEditorsDao->getEditorsBySectionId($journal->getId(), $section->getSectionId());
$sectionEditorEntriesBySection[$section->getId()] =& $sectionEditorsDao->getEditorsBySectionId($journal->getId(), $section->getId());
}
$templateMgr->assign_by_ref('sectionEditorEntriesBySection', $sectionEditorEntriesBySection);

Expand Down
2 changes: 1 addition & 1 deletion pages/editor/IssueManagementHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ function moveSectionToc($args) {
$sectionDao->setDefaultCustomSectionOrders($issueId);
}

$sectionDao->moveCustomSectionOrder($issueId, $section->getSectionId(), Request::getUserVar('newPos'), Request::getUserVar('d') == 'u');
$sectionDao->moveCustomSectionOrder($issueId, $section->getId(), Request::getUserVar('newPos'), Request::getUserVar('d') == 'u');
}

Request::redirect(null, null, 'issueToc', $issueId);
Expand Down
8 changes: 4 additions & 4 deletions plugins/gateways/metsGateway/MetsExportDom.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ function generateIssueDiv(&$doc, &$root, &$issue) {
function generateSectionDiv(&$doc, &$root, &$section, &$issue) {
$pDiv =& XMLCustomWriter::createElement($doc, 'METS:div');
XMLCustomWriter::setAttribute($pDiv, 'TYPE', 'section');
XMLCustomWriter::setAttribute($pDiv, 'DMDID', 'S-'.$section->getSectionId());
XMLCustomWriter::setAttribute($pDiv, 'DMDID', 'S-'.$section->getId());
$publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
$publishedArticleArray =& $publishedArticleDao->getPublishedArticlesBySectionId($section->getSectionId(),$issue->getIssueId());
$publishedArticleArray =& $publishedArticleDao->getPublishedArticlesBySectionId($section->getId(),$issue->getIssueId());
$i = 0;
while ($i < sizeof($publishedArticleArray)) {
MetsExportDom::generateArticleDiv($doc, $pDiv, $publishedArticleArray[$i], $issue);
Expand Down Expand Up @@ -216,7 +216,7 @@ function generateIssueDmdSecDom(&$doc, &$root, &$issue, &$journal) {
*/
function generateSectionDmdSecDom(&$doc, &$root, &$section, &$issue) {
$dmdSec =& XMLCustomWriter::createElement($doc, 'METS:dmdSec');
XMLCustomWriter::setAttribute($dmdSec, 'ID', 'S-'.$section->getSectionId());
XMLCustomWriter::setAttribute($dmdSec, 'ID', 'S-'.$section->getId());
$mdWrap =& XMLCustomWriter::createElement($doc, 'METS:mdWrap');
$xmlData =& XMLCustomWriter::createElement($doc, 'METS:xmlData');
XMLCustomWriter::setAttribute($mdWrap, 'MDTYPE', 'MODS');
Expand All @@ -238,7 +238,7 @@ function generateSectionDmdSecDom(&$doc, &$root, &$section, &$issue) {
XMLCustomWriter::appendChild($mdWrap,$xmlData);
XMLCustomWriter::appendChild($root, $dmdSec);
$publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
$publishedArticleArray =& $publishedArticleDao->getPublishedArticlesBySectionId($section->getSectionId(),$issue->getIssueId());
$publishedArticleArray =& $publishedArticleDao->getPublishedArticlesBySectionId($section->getId(),$issue->getIssueId());
$i = 0;
$i = 0;
while ($i < sizeof($publishedArticleArray)) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/importexport/crossref/CrossRefExportPlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ function exportIssues(&$journal, &$issues, $outputFile = null) {

foreach ($issues as $issue) {
foreach ($sectionDao->getSectionsForIssue($issue->getIssueId()) as $section) {
foreach ($publishedArticleDao->getPublishedArticlesBySectionId($section->getSectionId(), $issue->getIssueId()) as $article) {
foreach ($publishedArticleDao->getPublishedArticlesBySectionId($section->getId(), $issue->getIssueId()) as $article) {
// Create the metadata node
// this does not need to be repeated for every article
// but its allowed to be and its simpler to do so
Expand Down
8 changes: 4 additions & 4 deletions plugins/importexport/mets/MetsExportDom.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ function generateIssueDiv(&$doc, &$root, &$issue) {
function generateSectionDiv(&$doc, &$root, &$section, &$issue) {
$pDiv =& XMLCustomWriter::createElement($doc, 'METS:div');
XMLCustomWriter::setAttribute($pDiv, 'TYPE', 'section');
XMLCustomWriter::setAttribute($pDiv, 'DMDID', 'S-'.$section->getSectionId());
XMLCustomWriter::setAttribute($pDiv, 'DMDID', 'S-'.$section->getId());
$publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
$publishedArticleArray =& $publishedArticleDao->getPublishedArticlesBySectionId($section->getSectionId(),$issue->getIssueId());
$publishedArticleArray =& $publishedArticleDao->getPublishedArticlesBySectionId($section->getId(),$issue->getIssueId());
$i = 0;
while ($i < sizeof($publishedArticleArray)) {
MetsExportDom::generateArticleDiv($doc, $pDiv, $publishedArticleArray[$i], $issue);
Expand Down Expand Up @@ -212,7 +212,7 @@ function generateIssueDmdSecDom(&$doc, &$root, &$issue, &$journal) {
*/
function generateSectionDmdSecDom(&$doc, &$root, &$section, &$issue, &$journal) {
$dmdSec =& XMLCustomWriter::createElement($doc, 'METS:dmdSec');
XMLCustomWriter::setAttribute($dmdSec, 'ID', 'S-'.$section->getSectionId());
XMLCustomWriter::setAttribute($dmdSec, 'ID', 'S-'.$section->getId());
$mdWrap =& XMLCustomWriter::createElement($doc, 'METS:mdWrap');
$xmlData =& XMLCustomWriter::createElement($doc, 'METS:xmlData');
XMLCustomWriter::setAttribute($mdWrap, 'MDTYPE', 'MODS');
Expand All @@ -234,7 +234,7 @@ function generateSectionDmdSecDom(&$doc, &$root, &$section, &$issue, &$journal)
XMLCustomWriter::appendChild($mdWrap,$xmlData);
XMLCustomWriter::appendChild($root, $dmdSec);
$publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
$publishedArticleArray =& $publishedArticleDao->getPublishedArticlesBySectionId($section->getSectionId(),$issue->getIssueId());
$publishedArticleArray =& $publishedArticleDao->getPublishedArticlesBySectionId($section->getId(),$issue->getIssueId());
$i = 0;
$i = 0;
while ($i < sizeof($publishedArticleArray)) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/importexport/native/NativeExportDom.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function &generateSectionDom(&$doc, &$journal, &$issue, &$section) {
}

$publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
foreach ($publishedArticleDao->getPublishedArticlesBySectionId($section->getSectionId(), $issue->getIssueId()) as $article) {
foreach ($publishedArticleDao->getPublishedArticlesBySectionId($section->getId(), $issue->getIssueId()) as $article) {
$articleNode =& NativeExportDom::generateArticleDom($doc, $journal, $issue, $section, $article);
XMLCustomWriter::appendChild($root, $articleNode);
unset($articleNode);
Expand Down
8 changes: 4 additions & 4 deletions plugins/importexport/native/NativeImportDom.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ function handleSectionNode(&$journal, &$sectionNode, &$issue, &$errors, &$user,
foreach($titles as $locale => $title) {
$section = $sectionDao->getSectionByTitle($title, $journal->getId());
if ($section) {
$sectionId = $section->getSectionId();
$sectionId = $section->getId();
if ($foundSectionId) {
if ($foundSectionId != $sectionId) {
// Mismatching sections found. Throw an error.
Expand Down Expand Up @@ -611,7 +611,7 @@ function handleSectionNode(&$journal, &$sectionNode, &$issue, &$errors, &$user,

// Handle custom ordering, if necessary.
if ($sectionIndex !== null) {
$sectionDao->insertCustomSectionOrder($issue->getIssueId(), $section->getSectionId(), $sectionIndex);
$sectionDao->insertCustomSectionOrder($issue->getIssueId(), $section->getId(), $sectionIndex);
}

$hasErrors = false;
Expand All @@ -638,7 +638,7 @@ function handleArticleNode(&$journal, &$articleNode, &$issue, &$section, &$artic
$article = new Article();
$article->setJournalId($journal->getId());
$article->setUserId($user->getId());
$article->setSectionId($section->getSectionId());
$article->setSectionId($section->getId());
$article->setStatus(STATUS_PUBLISHED);
$article->setSubmissionProgress(0);
$article->setDateSubmitted(Core::getCurrentDate());
Expand Down Expand Up @@ -848,7 +848,7 @@ function handleArticleNode(&$journal, &$articleNode, &$issue, &$section, &$artic

$publishedArticle->setPubId($publishedArticleDao->insertPublishedArticle($publishedArticle));

$publishedArticleDao->resequencePublishedArticles($section->getSectionId(), $issue->getIssueId());
$publishedArticleDao->resequencePublishedArticles($section->getId(), $issue->getIssueId());

/* --- Galleys (html or otherwise handled simultaneously) --- */
import('file.ArticleFileManager');
Expand Down
2 changes: 1 addition & 1 deletion plugins/importexport/pubmed/PubMedExportPlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function exportIssues(&$journal, &$issues, $outputFile = null) {

foreach ($issues as $issue) {
foreach ($sectionDao->getSectionsForIssue($issue->getIssueId()) as $section) {
foreach ($publishedArticleDao->getPublishedArticlesBySectionId($section->getSectionId(), $issue->getIssueId()) as $article) {
foreach ($publishedArticleDao->getPublishedArticlesBySectionId($section->getId(), $issue->getIssueId()) as $article) {
$articleNode =& PubMedExportDom::generateArticleDom($doc, $journal, $issue, $section, $article);
XMLCustomWriter::appendChild($articleSetNode, $articleNode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function toXml(&$record, $format = null) {
"\t\t\t</pub-date>\n" .
($issue->getShowYear()?"\t\t\t<pub-date pub-type=\"collection\"><year>" . htmlspecialchars(Core::cleanVar($issue->getYear())) . "</year></pub-date>\n":'') .
($issue->getShowVolume()?"\t\t\t<volume>" . htmlspecialchars(Core::cleanVar($issue->getVolume())) . "</volume>\n":'') .
($issue->getShowNumber()?"\t\t\t<issue seq=\"" . htmlspecialchars(Core::cleanVar(($sectionSeq[$section->getSectionId()]*100) + $article->getSeq())) . "\">" . htmlspecialchars(Core::cleanVar($issue->getNumber())) . "</issue>\n":'') .
($issue->getShowNumber()?"\t\t\t<issue seq=\"" . htmlspecialchars(Core::cleanVar(($sectionSeq[$section->getId()]*100) + $article->getSeq())) . "\">" . htmlspecialchars(Core::cleanVar($issue->getNumber())) . "</issue>\n":'') .
"\t\t\t<issue-id pub-id-type=\"other\">" . htmlspecialchars(Core::cleanVar($issue->getBestIssueId())) . "</issue-id>\n" .
($issue->getShowTitle()?"\t\t\t<issue-title>" . htmlspecialchars(Core::cleanVar($issue->getIssueTitle())) . "</issue-title>\n":'');

Expand Down
2 changes: 1 addition & 1 deletion templates/about/editorialPolicies.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

{assign var="hasEditors" value=0}
{foreach from=$sectionEditorEntriesBySection item=sectionEditorEntries key=key}
{if $key == $section->getSectionId()}
{if $key == $section->getId()}
{foreach from=$sectionEditorEntries item=sectionEditorEntry}
{assign var=sectionEditor value=$sectionEditorEntry.user}
{if 0 == $hasEditors++}
Expand Down
4 changes: 2 additions & 2 deletions templates/manager/sections/sections.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ $(document).ready(function() { setupTableDND("#dragTable", "moveSection"); });
<td class="headseparator" colspan="3">&nbsp;</td>
</tr>
{iterate from=sections item=section name=sections}
<tr valign="top" id="section-{$section->getSectionId()}" class="data">
<tr valign="top" id="section-{$section->getId()}" class="data">
<td class="drag">{$section->getLocalizedTitle()|escape}</td>
<td class="drag">{$section->getLocalizedAbbrev()|escape}</td>
<td align="right" class="nowrap">
<a href="{url op="editSection" path=$section->getSectionId()}" class="action">{translate key="common.edit"}</a>&nbsp;|&nbsp;<a href="{url op="deleteSection" path=$section->getSectionId()}" onclick="return confirm('{translate|escape:"jsparam" key="manager.sections.confirmDelete"}')" class="action">{translate key="common.delete"}</a>&nbsp;|&nbsp;<a href="{url op="moveSection" d=u id=$section->getSectionId()}">&uarr;</a>&nbsp;<a href="{url op="moveSection" d=d id=$section->getSectionId()}">&darr;</a>
<a href="{url op="editSection" path=$section->getId()}" class="action">{translate key="common.edit"}</a>&nbsp;|&nbsp;<a href="{url op="deleteSection" path=$section->getId()}" onclick="return confirm('{translate|escape:"jsparam" key="manager.sections.confirmDelete"}')" class="action">{translate key="common.delete"}</a>&nbsp;|&nbsp;<a href="{url op="moveSection" d=u id=$section->getId()}">&uarr;</a>&nbsp;<a href="{url op="moveSection" d=d id=$section->getId()}">&darr;</a>
</td>
</tr>
{/iterate}
Expand Down
2 changes: 1 addition & 1 deletion templates/manager/statistics/statistics.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<form action="{url op="saveStatisticsSections"}" method="post">
<select name="sectionIds[]" class="selectMenu" multiple="multiple" size="5">
{foreach from=$sections item=section}
<option {if in_array($section->getSectionId(), $sectionIds)}selected="selected" {/if}value="{$section->getSectionId()}">{$section->getLocalizedTitle()}</option>
<option {if in_array($section->getId(), $sectionIds)}selected="selected" {/if}value="{$section->getId()}">{$section->getLocalizedTitle()}</option>
{/foreach}
</select><br/>&nbsp;<br/>
<input type="submit" value="{translate key="common.record"}" class="button defaultButton"/>
Expand Down

0 comments on commit 26695e2

Please sign in to comment.