Skip to content
This repository was archived by the owner on Dec 12, 2018. It is now read-only.

Ignore field if fieldValue is an empty string in docment list #20

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions mongodbadmin.php
Original file line number Diff line number Diff line change
@@ -537,38 +537,38 @@ function findMongoDbDocument($id, $db, $collection, $forceCustomId = false)
<?php foreach ($cursor as $document): ?>
<tr>
<?php if (is_object($document['_id']) && $document['_id'] instanceof MongoId): ?>
<td><a href="<?php echo $_SERVER['PHP_SELF'] . '?db=' . urlencode($_REQUEST['db']) . '&collection=' . $_REQUEST['collection'] ?>&id=<?php echo (string) $document['_id'] ?>"><?php echo (string) $document['_id'] ?></a></td>
<td><a title="<?php echo htmlspecialchars($jsonEncodedDocument) ?>" href="<?php echo $_SERVER['PHP_SELF'] . '?db=' . urlencode($_REQUEST['db']) . '&collection=' . $_REQUEST['collection'] ?>&id=<?php echo (string) $document['_id'] ?>"><?php echo (string) $document['_id'] ?></a></td>
<?php else: ?>
<td><a href="<?php echo $_SERVER['PHP_SELF'] . '?db=' . urlencode($_REQUEST['db']) . '&collection=' . $_REQUEST['collection'] ?>&id=<?php echo (string) $document['_id'] ?>&custom_id=1"><?php echo (string) $document['_id'] ?></a></td>
<td><a title="<?php echo htmlspecialchars($jsonEncodedDocument) ?>" href="<?php echo $_SERVER['PHP_SELF'] . '?db=' . urlencode($_REQUEST['db']) . '&collection=' . $_REQUEST['collection'] ?>&id=<?php echo (string) $document['_id'] ?>&custom_id=1"><?php echo (string) $document['_id'] ?></a></td>
<?php endif; ?>
<td>
<?php
if (isset($search)) {
$displayValues = array();
if (isset($search)) {
$displayValues = array();

$searchKeys = isset($search['$query']) ? $search['$query'] : $search;
$searchKeys = isset($search['$query']) ? $search['$query'] : $search;

foreach ($searchKeys as $fieldName => $searchQuery) {
if ($fieldName != '_id' && $fieldName[0] != '$' && isset($document[$fieldName])) {
$fieldValue = $document[$fieldName];
foreach ($searchKeys as $fieldName => $searchQuery) {
if ($fieldName != '_id' && $fieldName[0] != '$' && isset($document[$fieldName])) {
$fieldValue = $document[$fieldName];

if (!is_array($fieldValue) && !is_object($fieldValue)) {
$displayValues[] = $fieldName . ': ' . substr(str_replace("\n", '', htmlspecialchars($fieldValue)), 0, 100);
}
if (!is_array($fieldValue) && !is_object($fieldValue)) {
$displayValues[] = $fieldName . ': ' . substr(str_replace("\n", '', htmlspecialchars($fieldValue)), 0, 100);
}
}

echo implode(' - ', $displayValues);
}

if (!isset($displayValues) || !count($displayValues)) {
foreach ($document as $fieldName => $fieldValue) {
if ($fieldName != '_id' && !is_array($fieldValue) && !is_object($fieldValue)) {
echo $fieldName . ': ' . substr(str_replace("\n", '', htmlspecialchars($fieldValue)), 0, 100);
break;
}
echo implode(' - ', $displayValues);
}

if (!isset($displayValues) || !count($displayValues)) {
foreach ($document as $fieldName => $fieldValue) {
if ($fieldName != '_id' && !is_array($fieldValue) && !is_object($fieldValue) && $fieldValue !== '') {
echo '<span title="' . htmlspecialchars($jsonEncodedDocument) . '">' . $fieldName . ': ' . substr(str_replace("\n", '', htmlspecialchars($fieldValue)), 0, 100) . '</span>';
break;
}
}
}
?>
</td>
<?php if (is_object($document['_id']) && $document['_id'] instanceof MongoId && $readOnly !== true): ?>