Skip to content
Snippets Groups Projects
Commit 693610a8 authored by Demian Katz's avatar Demian Katz
Browse files

Refactored for readability.

parent 40925edf
No related merge requests found
...@@ -135,6 +135,31 @@ class SearchRequestModel ...@@ -135,6 +135,31 @@ class SearchRequestModel
$this->setParameters($parameters); $this->setParameters($parameters);
} }
/**
* Format a date limiter
*
* @param string $filter Filter value
*
* @return string
*/
protected function formatDateLimiter($filter)
{
// PublicationDate:[xxxx TO xxxx]
$dates = substr($filter, 17);
$dates = substr($dates, 0, strlen($dates)-1);
$parts = explode(' TO ', $dates, 2);
if (count($parts) == 2) {
$start = trim($parts[0]);
$end = trim($parts[1]);
}
if ('*' == $start || null == $start) {
$start = '0000';
}
if ('*' == $end || null == $end) {
$end = date('Y') + 1;
}
return "DT1:$start-01/$end-12";
}
/** /**
* Set properties from parameters * Set properties from parameters
...@@ -157,21 +182,7 @@ class SearchRequestModel ...@@ -157,21 +182,7 @@ class SearchRequestModel
} else if (substr($filter, 0, 11) == 'SEARCHMODE:') { } else if (substr($filter, 0, 11) == 'SEARCHMODE:') {
$this->searchMode = substr($filter, 11, null); $this->searchMode = substr($filter, 11, null);
} else if (substr($filter, 0, 15) == 'PublicationDate') { } else if (substr($filter, 0, 15) == 'PublicationDate') {
// PublicationDate:[xxxx TO xxxx] $this->addLimiter($this->formatDateLimiter($filter));
$dates = substr($filter, 17);
$dates = substr($dates, 0, strlen($dates)-1);
$parts = explode(' TO ', $dates, 2);
if (count($parts) == 2) {
$start = trim($parts[0]);
$end = trim($parts[1]);
}
if ('*' == $start || null == $start) {
$start = '0000';
}
if ('*' == $end || null == $end) {
$end = $end = date('Y');
}
$this->addLimiter("DT1:$start-01/$end-12");
} else { } else {
$this->addFilter("$cnt,$filter"); $this->addFilter("$cnt,$filter");
$cnt++; $cnt++;
...@@ -186,7 +197,6 @@ class SearchRequestModel ...@@ -186,7 +197,6 @@ class SearchRequestModel
} }
} }
/** /**
* Converts properties to a querystring to send to the EdsAPI * Converts properties to a querystring to send to the EdsAPI
* *
...@@ -247,7 +257,6 @@ class SearchRequestModel ...@@ -247,7 +257,6 @@ class SearchRequestModel
$qs .= 'highlight='.$highlightVal.'&'; $qs .= 'highlight='.$highlightVal.'&';
} }
if (isset($this->actions) && 0 < sizeof($this->actions)) { if (isset($this->actions) && 0 < sizeof($this->actions)) {
for ($x=0; $x<sizeof($this->actions); $x++) { for ($x=0; $x<sizeof($this->actions); $x++) {
$qs .= 'action-'.($x+1).'='.$this->actions[$x].'&'; $qs .= 'action-'.($x+1).'='.$this->actions[$x].'&';
...@@ -399,7 +408,6 @@ class SearchRequestModel ...@@ -399,7 +408,6 @@ class SearchRequestModel
$this->limiters[] = $limiter; $this->limiters[] = $limiter;
} }
/** /**
* Add a new expander * Add a new expander
* *
...@@ -424,7 +432,6 @@ class SearchRequestModel ...@@ -424,7 +432,6 @@ class SearchRequestModel
$this->facetFilters[] = $facetFilter; $this->facetFilters[] = $facetFilter;
} }
/** /**
* Escape characters that may be present in the parameter syntax * Escape characters that may be present in the parameter syntax
* *
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment