From 9815083af7a1642b6f65c1c3d6b0a261866f6e7e Mon Sep 17 00:00:00 2001 From: Victor Grousset/tuxayo Date: Tue, 12 Jul 2016 15:02:31 +0200 Subject: [PATCH] Resources: index: remplace recordID column by ISBN, ISSN, etc #3 --- resources/admin/classes/domain/Resource.php | 35 ++++++++----------- .../ajax_htmldata/getSearchResources.php | 18 +++++++--- resources/css/style.css | 4 +-- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/resources/admin/classes/domain/Resource.php b/resources/admin/classes/domain/Resource.php index d3cde8db1..a7628a70d 100644 --- a/resources/admin/classes/domain/Resource.php +++ b/resources/admin/classes/domain/Resource.php @@ -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 @@ -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']; } diff --git a/resources/ajax_htmldata/getSearchResources.php b/resources/ajax_htmldata/getSearchResources.php index 4e267a1c7..e8eb6c8ed 100644 --- a/resources/ajax_htmldata/getSearchResources.php +++ b/resources/ajax_htmldata/getSearchResources.php @@ -106,12 +106,12 @@ }else{ echo "
 
"; } - ?> + ?> - + @@ -130,8 +130,17 @@ $classAdd="class='alt'"; } echo ""; - echo ""; - echo ""; + echo ""; + + echo ""; if ($resource['firstName'] || $resource['lastName']){ echo ""; @@ -221,4 +230,3 @@ } ?> - diff --git a/resources/css/style.css b/resources/css/style.css index 6495bdc67..22e983d57 100644 --- a/resources/css/style.css +++ b/resources/css/style.css @@ -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) {
" . $resource['resourceID'] . "" . $resource['titleText'] . "" + . "" + . $resource['titleText'] + . ""; + $isbnOrIssns = $resource['isbnOrIssns']; + foreach ($isbnOrIssns as $isbnOrIssn) { + echo $isbnOrIssn . "
"; + } + echo"
" . $resource['firstName'] . " " . $resource['lastName'] ."