Commit 4f584dd2 authored by Ad Schellevis's avatar Ad Schellevis

(mvc) check for uuid before using it.

parent 94d946c7
...@@ -70,46 +70,48 @@ class UIModelGrid ...@@ -70,46 +70,48 @@ class UIModelGrid
$recordIndex = 0; $recordIndex = 0;
foreach ($this->DataField->sortedBy($sortBy, $sortDescending) as $record) { foreach ($this->DataField->sortedBy($sortBy, $sortDescending) as $record) {
// parse rows, because we may need to convert some (list) items we need to know the actual content if (array_key_exists("uuid", $record->getAttributes())) {
// before searching. // parse rows, because we may need to convert some (list) items we need to know the actual content
$row = array(); // before searching.
$row['uuid'] = $record->getAttributes()['uuid']; $row = array();
foreach ($fields as $fieldname) { $row['uuid'] = $record->getAttributes()['uuid'];
$row[$fieldname] = $record->$fieldname->getNodeData(); foreach ($fields as $fieldname) {
if (is_array($row[$fieldname])) { $row[$fieldname] = $record->$fieldname->getNodeData();
foreach ($row[$fieldname] as $fieldKey => $fieldValue) {
if ($fieldValue['selected'] == 1) {
$row[$fieldname] = $fieldValue['value'];
}
}
if (is_array($row[$fieldname])) { if (is_array($row[$fieldname])) {
$row[$fieldname] = "##Unlinked"; foreach ($row[$fieldname] as $fieldKey => $fieldValue) {
if ($fieldValue['selected'] == 1) {
$row[$fieldname] = $fieldValue['value'];
}
}
if (is_array($row[$fieldname])) {
$row[$fieldname] = "##Unlinked";
}
} }
} }
}
// if a search phrase is provided, use it to search in all requested fields // if a search phrase is provided, use it to search in all requested fields
if ($searchPhrase != '') { if ($searchPhrase != '') {
$searchFound = false; $searchFound = false;
foreach ($fields as $fieldname) { foreach ($fields as $fieldname) {
if (strpos(strtolower($row[$fieldname]), strtolower($searchPhrase)) !== false) { if (strpos(strtolower($row[$fieldname]), strtolower($searchPhrase)) !== false) {
$searchFound = true; $searchFound = true;
break; break;
}
} }
} else {
$searchFound = true;
} }
} else {
$searchFound = true;
}
// if result is relevant, count total and add (max number of) items to result. // if result is relevant, count total and add (max number of) items to result.
// $itemsPerPage = -1 is used as wildcard for "all results" // $itemsPerPage = -1 is used as wildcard for "all results"
if ($searchFound) { if ($searchFound) {
if ((count($result['rows']) < $itemsPerPage && if ((count($result['rows']) < $itemsPerPage &&
$recordIndex >= ($itemsPerPage*($currentPage-1)) || $itemsPerPage == -1) $recordIndex >= ($itemsPerPage*($currentPage-1)) || $itemsPerPage == -1)
) { ) {
$result['rows'][] = $row; $result['rows'][] = $row;
}
$recordIndex++;
} }
$recordIndex++;
} }
} }
......
Markdown is supported
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