Skip to content

Commit

Permalink
Check for valid URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-meyer committed Dec 20, 2017
1 parent 06de542 commit 39ad464
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
12 changes: 8 additions & 4 deletions dlf/common/class.tx_dlf_document.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ final class tx_dlf_document {
* @access protected
*/
protected $formats = array (
'OAI' => array (
'rootElement' => 'OAI-PMH',
'namespaceURI' => 'http://www.openarchives.org/OAI/2.0/',
),
'METS' => array (
'rootElement' => 'mets',
'namespaceURI' => 'http://www.loc.gov/METS/',
Expand Down Expand Up @@ -853,7 +857,7 @@ public function getMetadata($id, $cPid = 0) {
}

// Set default value if applicable.
if (empty($metadata[$resArray['index_name']][0]) && $resArray['default_value']) {
if (empty($metadata[$resArray['index_name']][0])) {

$metadata[$resArray['index_name']] = array ($resArray['default_value']);

Expand Down Expand Up @@ -945,7 +949,7 @@ public function getPhysicalPage($logicalPage) {
return 1;

}

/**
* This determines a title for the given document
*
Expand Down Expand Up @@ -1029,7 +1033,7 @@ public function getTitledata($cPid = 0) {
// Set record identifier for METS file if not present.
if (is_array($titledata) && array_key_exists('record_id', $titledata)) {

if (!in_array($this->recordId, $titledata['record_id'])) {
if (!empty($this->recordId) && !in_array($this->recordId, $titledata['record_id'])) {

array_unshift($titledata['record_id'], $this->recordId);

Expand Down Expand Up @@ -2418,7 +2422,7 @@ protected function __construct($uid, $pid) {
$location = (string) $uid;

// Try to load METS file.
if ($this->load($location)) {
if (\TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($location) && $this->load($location)) {

// Initialize core METS object.
$this->init();
Expand Down
2 changes: 1 addition & 1 deletion dlf/hooks/class.tx_dlf_hacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function construct_postProcessRecordId(SimpleXMLElement &$xml, &$record_i
$xml->registerXPathNamespace('mods', 'http://www.loc.gov/mods/v3');

// Get all logical structure nodes with metadata, but without associated METS-Pointers.
if (($divs = $xml->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID and not(./mets:mptr)]'))) {
if (($divs = $xml->xpath('//mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID and not(./mets:mptr)]'))) {

$smLinks = $xml->xpath('//mets:structLink/mets:smLink');

Expand Down
9 changes: 2 additions & 7 deletions dlf/modules/indexing/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ public function main() {

case 'indexFile':

if (!empty($this->data['id']) && isset($this->data['core'])) {
if (!empty($this->data['id']) && isset($this->data['core'])
&& \TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($this->data['id'])) {

// Save document to database and index.
$doc =& tx_dlf_document::getInstance($this->data['id'], $this->id, TRUE);
Expand Down Expand Up @@ -338,12 +339,6 @@ public function main() {

break;

case 'reindexDoc':

$this->markerArray['CONTENT'] .= $this->getDocList();

break;

case 'reindexDocs':

$this->markerArray['CONTENT'] .= $this->getCollList();
Expand Down

3 comments on commit 39ad464

@frank-ulrich-weber
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this commit && $resArray['default_value'] within class.tx_dlf_document.php has been removed. Why? The problem now is that this creates many empty fields within the index while indexing. This empty fields are then shown within the search facets as empty. Can I reintroduce a check like '!empty($resArray['default_value'])' or is there any other side-effect?

@sebastian-meyer
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the check, because sometimes the default value should be '0', which would be interpreted as 'empty' and therefore ignored.
So we should reintroduce a check for empty values, but maybe do something like strlen() == 0.

@frank-ulrich-weber
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, then I think && strlen($resArray['default_value']) > 0 should work.

Please sign in to comment.