Skip to content

Commit

Permalink
Resources: index: remplace recordID column by ISBN, ISSN, etc coral-e…
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxayo committed Jul 21, 2016
1 parent 7e9319a commit 6478d54
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 27 deletions.
38 changes: 16 additions & 22 deletions resources/admin/classes/domain/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ public function getIsbnOrIssn() {
}

}

return $objects;

}
Expand Down Expand Up @@ -1325,41 +1324,36 @@ public function searchQuery($whereAdd, $orderBy = '', $limit = '', $count = fals
}

//returns array based on search
public function search($whereAdd, $orderBy, $limit){
public function search($whereAdd, $orderBy, $limit) {
$query = $this->searchQuery($whereAdd, $orderBy, $limit, false);

$result = $this->db->processQuery($query, 'assoc');

$searchArray = array();
$resultArray = array();

//need to do this since it could be that there's only one result and this is how the dbservice returns result
if (isset($result['resourceID'])){

foreach (array_keys($result) as $attributeName) {
$resultArray[$attributeName] = $result[$attributeName];
}

array_push($searchArray, $resultArray);
}else{
foreach ($result as $row) {
$resultArray = array();
foreach (array_keys($row) as $attributeName) {
$resultArray[$attributeName] = $row[$attributeName];
}
array_push($searchArray, $resultArray);
}
if (isset($result['resourceID'])) { $result = [$result]; }
foreach ($result as $row) {
$row = static::addIdsToResourcesRow($row);
array_push($searchArray, $row);
}

return $searchArray;
}

private static function addIdsToResourcesRow($row) {
$resource = new Resource(new NamedArguments(array('primaryKey' => $row['resourceID'])));
$isbnOrIssns = $resource->getIsbnOrIssn();
$row['isbnOrIssns'] = [];
foreach ($isbnOrIssns as $isbnOrIssn) {
array_push($row['isbnOrIssns'], $isbnOrIssn->isbnOrIssn);
}
return $row;
}

public function searchCount($whereAdd) {
$query = $this->searchQuery($whereAdd, '', '', true);
$result = $this->db->processQuery($query, 'assoc');

//echo $query;


return $result['count'];
}

Expand Down
15 changes: 12 additions & 3 deletions resources/ajax_htmldata/getSearchResources.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@
?>
<table class='dataTable' style='width:840px'>
<tr>
<th><table class='noBorderTable' style='width:100%'><tr><td><?php echo _("ID");?></td><td style='width:10px;'><a href='javascript:setOrder("R.resourceID + 0","asc");'><img src='images/arrowup.png' border=0></a></td><td style='width:10px;'><a href='javascript:setOrder("R.resourceID + 0","desc");'><img src='images/arrowdown.png' border=0></a></td></tr></table></th>
<th><table class='noBorderTable' style='width:100%'><tr><td><?php echo _("Name");?></td><td style='width:10px;'><a href='javascript:setOrder("R.titleText","asc");'><img src='images/arrowup.png' border=0></a></td><td style='width:10px;'><a href='javascript:setOrder("R.titleText","desc");'><img src='images/arrowdown.png' border=0></a></td></tr></table></th>
<th><table class='noBorderTable' style='width:100%'><tr><td><?php echo _("ID");?></td><td style='width:10px;'><a href='javascript:setOrder("R.resourceID + 0","asc");'><img src='images/arrowup.png' border=0></a></td><td style='width:10px;'><a href='javascript:setOrder("R.resourceID + 0","desc");'><img src='images/arrowdown.png' border=0></a></td></tr></table></th>
<th><table class='noBorderTable' style='width:100%'><tr><td><?php echo _("Creator");?></td><td style='width:10px;'><a href='javascript:setOrder("CU.loginID","asc");'><img src='images/arrowup.png' border=0></a></td><td style='width:10px;'><a href='javascript:setOrder("CU.loginID","desc");'><img src='images/arrowdown.png' border=0></a></td></tr></table></th>
<th><table class='noBorderTable' style='width:100%'><tr><td><?php echo _("Date Created");?></td><td style='width:10px;vertical-align:top;'><a href='javascript:setOrder("R.createDate","asc");'><img src='images/arrowup.png' border=0></a></td><td style='width:10px;vertical-align:top;'><a href='javascript:setOrder("R.createDate","desc");'><img src='images/arrowdown.png' border=0></a></td></tr></table></th>
<th><table class='noBorderTable' style='width:100%'><tr><td><?php echo _("Acquisition Type");?></td><td style='width:10px;vertical-align:top;'><a href='javascript:setOrder("acquisitionType","asc");'><img src='images/arrowup.png' border=0></a></td><td style='width:10px;vertical-align:top;'><a href='javascript:setOrder("acquisitionType","desc");'><img src='images/arrowdown.png' border=0></a></td></tr></table></th>
Expand All @@ -130,8 +130,17 @@
$classAdd="class='alt'";
}
echo "<tr>";
echo "<td $classAdd><a href='resource.php?resourceID=" . $resource['resourceID'] . "'>" . $resource['resourceID'] . "</a></td>";
echo "<td $classAdd><a href='resource.php?resourceID=" . $resource['resourceID'] . "'>" . $resource['titleText'] . "</a></td>";
echo "<td $classAdd>"
. "<a href='resource.php?resourceID=" . $resource['resourceID'] . "'>"
. $resource['titleText']
. "</a></td>";

echo "<td $classAdd>";
$isbnOrIssns = $resource['isbnOrIssns'];
foreach ($isbnOrIssns as $isbnOrIssn) {
echo $isbnOrIssn . "<br />";
}
echo"</a></td>";

if ($resource['firstName'] || $resource['lastName']){
echo "<td $classAdd>" . $resource['firstName'] . " " . $resource['lastName'] ."</td>";
Expand Down
4 changes: 2 additions & 2 deletions resources/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1147,11 +1147,11 @@ img[src*="arrowup.png"] {
/*--- Table Column Widths ---*/

table.dataTable th:nth-of-type(1) {
min-width: 36px;
min-width: 250px;
}

table.dataTable th:nth-of-type(2) {
min-width: 250px;
min-width: 36px;
}

table.dataTable th:nth-of-type(3) {
Expand Down

0 comments on commit 6478d54

Please sign in to comment.