Skip to content

Commit

Permalink
#10692 Structured Citations
Browse files Browse the repository at this point in the history
  • Loading branch information
GaziYucel committed Jan 31, 2025
1 parent 80ca552 commit d9788eb
Show file tree
Hide file tree
Showing 22 changed files with 1,343 additions and 352 deletions.
Binary file not shown.
1 change: 1 addition & 0 deletions classes/citation/.project/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://tug.ctan.org/info/biblatex-cheatsheet/biblatex-cheatsheet.pdf
51 changes: 23 additions & 28 deletions classes/citation/Citation.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
/**
* @file classes/citation/Citation.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Copyright (c) 2014-2024 Simon Fraser University
* Copyright (c) 2000-2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class Citation
Expand All @@ -20,29 +20,33 @@

namespace PKP\citation;

class Citation extends \PKP\core\DataObject
use PKP\core\DataObject;

class Citation extends DataObject
{
/**
* Constructor.
*
* @param string $rawCitation an unparsed citation string
* @param string|null $rawCitation an unparsed citation string
*/
public function __construct($rawCitation = null)
public function __construct(string $rawCitation = null)
{
parent::__construct();
$this->setRawCitation($rawCitation);
}

//
// Getters and Setters
//
/**
* Get publication id.
*/
public function getPublicationId()
{
return $this->getData('publicationId');
}

/**
* Replace URLs through HTML links, if the citation does not already contain HTML links
*
* @return string
* Replace URLs through HTML links, if the citation does not already contain HTML links.
*/
public function getCitationWithLinks()
public function getCitationWithLinks(): string
{
$citation = $this->getRawCitation();
if (stripos($citation, '<a href=') === false) {
Expand All @@ -60,51 +64,42 @@ function ($matches) {
}

/**
* Get the rawCitation
*
* @return string
* Get the rawCitation.
*/
public function getRawCitation()
public function getRawCitation(): string
{
return $this->getData('rawCitation');
}

/**
* Set the rawCitation
* Set the rawCitation.
*/
public function setRawCitation(?string $rawCitation)
public function setRawCitation(?string $rawCitation): void
{
$rawCitation = $this->_cleanCitationString($rawCitation ?? '');
$this->setData('rawCitation', $rawCitation);
}

/**
* Get the sequence number
*
* @return int
*/
public function getSequence()
public function getSequence(): int
{
return $this->getData('seq');
}

/**
* Set the sequence number
*
* @param int $seq
*/
public function setSequence($seq)
public function setSequence(int $seq): void
{
$this->setData('seq', $seq);
}

//
// Private methods
//
/**
* Take a citation string and clean/normalize it
*/
public function _cleanCitationString(string $citationString) : string
private function cleanCitationString(string $citationString = null): string
{
// 1) Strip slashes and whitespace
$citationString = trim(stripslashes($citationString));
Expand Down
253 changes: 0 additions & 253 deletions classes/citation/CitationDAO.php

This file was deleted.

Loading

0 comments on commit d9788eb

Please sign in to comment.