$likeField = $searchByLinkField ? $linkFieldName : $displayFieldName; } else { $likeField = RunnerPage::_getFieldSQLDecrypt($searchByLinkField ? $linkFieldName : $displayFieldName, $lookupConnection, $lookupPSet, $cipherer); } } else { $likeField = $cipherer->GetFieldName($lwDisplayField, $f); } if ($searchByLinkField) { $likeConditionField = $LookupType == LT_QUERY ? $linkFieldName : $f; } else { $likeConditionField = $LookupType == LT_QUERY ? $displayFieldName : $f; } $likeWheres = array(); foreach ($values as $fieldValue) { if ($LookupType == LT_QUERY) { $likeWheres[] = $likeField . $lookupCipherer->GetLikeClause($likeConditionField, $fieldValue); } else { $likeWheres[] = $likeField . $cipherer->GetLikeClause($likeConditionField, $fieldValue); } } $strLookupWhere .= implode(' OR ', $likeWheres); if ($gSettings->useCategory($f) && ($isExistParent || postvalue('editMode') != MODE_SEARCH)) { $arLookupWhere = array(); foreach ($lookupCategory as $arLookupCategory) { $cvalue = make_db_value($gSettings->getCategoryControl($f), $arLookupCategory); $arLookupWhere[] = $lookupConnection->addFieldWrappers($gSettings->getCategoryFilter($f)) . "=" . $cvalue; } $arLookupWhereToStr = count($arLookupWhere) == 1 ? $arLookupWhere[0] : "(" . implode(" OR ", $arLookupWhere) . ")"; if (count($arLookupWhere)) { $strLookupWhere = whereAdd($strLookupWhere, $arLookupWhereToStr); }
$LookupSQLTable .= " FROM " . AddTableWrappers($lookupTable) . " "; } $strLookupWhere = GetLWWhere($f, $pageType, $strTableName); if ($strLookupWhere) { $strLookupWhere = " (" . $strLookupWhere . ") AND "; } if ($LookupType == LT_QUERY) { if ($gSettings->getCustomDisplay($f)) { $strLookupWhere .= $displayFieldName; } else { $strLookupWhere .= GetFullFieldName($displayFieldName, $lookupTable, false); } } else { $strLookupWhere .= $cipherer->GetFieldName($lwDisplayField, $f); } $strLookupWhere .= $cipherer->GetLikeClause($LookupType == LT_QUERY ? $displayFieldName : $f, $value); if ($gSettings->useCategory($f) && (postvalue("category") != '' || postvalue('editMode') != MODE_SEARCH)) { $cvalue = make_db_value($gSettings->getCategoryControl($f), postvalue("category")); $strLookupWhere .= " AND " . AddFieldWrappers($gSettings->getCategoryFilter($f)) . "=" . $cvalue; } $lookupOrderBy = $gSettings->getLookupOrderBy($f); if (strlen($lookupOrderBy)) { $lookupOrderBy = GetFullFieldName($lookupOrderBy, $lookupTable); if ($gSettings->isLookupDesc($f)) { $lookupOrderBy .= ' DESC'; } } if ($LookupType == LT_QUERY) { $LookupSQL = $lookupQueryObj->toSql(whereAdd($lookupQueryObj->m_where->toSql($lookupQueryObj), $strLookupWhere), strlen($lookupOrderBy) ? ' ORDER BY ' . $lookupOrderBy : null); } else { $LookupSQL = $LookupSQLTable . " where " . $strLookupWhere;