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 Aug 12, 2016
1 parent b175f80 commit 9815083
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 28 deletions.
35 changes: 14 additions & 21 deletions resources/admin/classes/domain/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,9 @@ public function getIsbnOrIssn() {
$object = new IsbnOrIssn(new NamedArguments(array('primaryKey' => $row['isbnOrIssnID'])));
array_push($objects, $object);
}

}

return $objects;

}

//returns array of parent resource objects
Expand Down Expand Up @@ -1324,35 +1322,30 @@ public function search($whereAdd, $orderBy, $limit) {
$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
18 changes: 13 additions & 5 deletions resources/ajax_htmldata/getSearchResources.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@
}else{
echo "<div style='vertical-align:bottom;text-align:left;clear:both;'>&nbsp;</div>";
}
?>
?>

<table id='resource_table' class='dataTable' style='width:840px'>
<thead><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 Expand Up @@ -221,4 +230,3 @@
}

?>

4 changes: 2 additions & 2 deletions resources/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1146,11 +1146,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 9815083

Please sign in to comment.