public static function objectsByValue($v0f728ec6147eaec54f5f45e37bce8ddd, $v2ef4385ee1f18f02679161fef2b094d9 = NULL, $v95fc2db4375309c569794b723adc3972 = false, $vf80384e7987156531edaa3afd549957d = true, $v8ef57923ab3049b18fb75541ff476ff7 = NULL) { $v30a7d3f52b5af853f2a7bba352210a34 = array(); if (!(is_null($v2ef4385ee1f18f02679161fef2b094d9) || is_array($v2ef4385ee1f18f02679161fef2b094d9) || intval($v2ef4385ee1f18f02679161fef2b094d9) === -1 || strval($v2ef4385ee1f18f02679161fef2b094d9) === 'all' || strval($v2ef4385ee1f18f02679161fef2b094d9) == 'Все')) { $v2ef4385ee1f18f02679161fef2b094d9 = array($v2ef4385ee1f18f02679161fef2b094d9); } $v9effabcdaed14aab9cb00acddfa00fc9 = NULL; if ($v95fc2db4375309c569794b723adc3972) { if (is_null($v8ef57923ab3049b18fb75541ff476ff7)) { $v9effabcdaed14aab9cb00acddfa00fc9 = array(cmsController::getInstance()->getCurrentDomain()->getId()); } elseif (intval($v8ef57923ab3049b18fb75541ff476ff7) === -1 || strval($v8ef57923ab3049b18fb75541ff476ff7) === 'all' || strval($v8ef57923ab3049b18fb75541ff476ff7) == 'Все') { $v9effabcdaed14aab9cb00acddfa00fc9 = array(); } elseif (is_array($v8ef57923ab3049b18fb75541ff476ff7)) { $v9effabcdaed14aab9cb00acddfa00fc9 = array_map('intval', $v8ef57923ab3049b18fb75541ff476ff7); } else { $v9effabcdaed14aab9cb00acddfa00fc9 = array(intval($v8ef57923ab3049b18fb75541ff476ff7)); } } $v06e3d36fa30cea095545139854ad1fb9 = umiFieldsCollection::getInstance()->getField($v0f728ec6147eaec54f5f45e37bce8ddd); if ($v06e3d36fa30cea095545139854ad1fb9 instanceof umiField) { $v5fd6df40d7c4dd7f503475344d8c145c = $v06e3d36fa30cea095545139854ad1fb9->getFieldType()->getDataType(); $v8ae9391858dfdc11dbd8f15cf9b04a26 = umiFieldType::getDataTypeDB($v5fd6df40d7c4dd7f503475344d8c145c); } else { throw new coreException("Field #{$v945100186b119048837b9859c2c46410} not found"); } $v6301cee35ea764a1e241978f93f01069 = umiSelectionsParser::getObjectTypeByFieldId($v0f728ec6147eaec54f5f45e37bce8ddd); $v80071f37861c360a27b7327e132c911a = umiBranch::getBranchedTableByTypeId($v6301cee35ea764a1e241978f93f01069); $v01b41e749613a642fc384ed8af3245fc = "{$v80071f37861c360a27b7327e132c911a} `o`"; if ($v95fc2db4375309c569794b723adc3972) { $v01b41e749613a642fc384ed8af3245fc .= ", cms3_hierarchy `h`"; } if ($v95fc2db4375309c569794b723adc3972) { $v7dd0d06edf4c4299ce1a5978eb469fd8 = "h.id"; } else { $v7dd0d06edf4c4299ce1a5978eb469fd8 = "o.obj_id"; } $vc3a74cf64b6ccb62fa49a21123cbc72f = $v95fc2db4375309c569794b723adc3972 ? " AND h.obj_id = o.obj_id AND h.is_active=1 AND h.is_deleted=0" : ""; if ($v95fc2db4375309c569794b723adc3972 && is_array($v9effabcdaed14aab9cb00acddfa00fc9) && count($v9effabcdaed14aab9cb00acddfa00fc9)) { $vc3a74cf64b6ccb62fa49a21123cbc72f .= " AND h.domain_id IN ('" . implode("', '", $v9effabcdaed14aab9cb00acddfa00fc9) . "')"; } $v86f6d00b1c7dbb44f4cd5edf49c29aa0 = ""; if (!(intval($v2ef4385ee1f18f02679161fef2b094d9) === -1 || strval($v2ef4385ee1f18f02679161fef2b094d9) === 'all' || strval($v2ef4385ee1f18f02679161fef2b094d9) === 'Âñå')) { $v86f6d00b1c7dbb44f4cd5edf49c29aa0 = " AND o.{$v8ae9391858dfdc11dbd8f15cf9b04a26} " . (is_null($v2ef4385ee1f18f02679161fef2b094d9) ? "IS NULL" : "IN ('" . implode("', '", $v2ef4385ee1f18f02679161fef2b094d9) . "')"); } if ($vf80384e7987156531edaa3afd549957d) { $vf3e7552257b4e44beacffb073506f43d = "SELECT o." . $v8ae9391858dfdc11dbd8f15cf9b04a26 . " as `value`, COUNT(" . $v7dd0d06edf4c4299ce1a5978eb469fd8 . ") as `items` FROM " . $v01b41e749613a642fc384ed8af3245fc . " WHERE o.field_id = " . $v0f728ec6147eaec54f5f45e37bce8ddd . $v86f6d00b1c7dbb44f4cd5edf49c29aa0 . $vc3a74cf64b6ccb62fa49a21123cbc72f . " GROUP BY o." . $v8ae9391858dfdc11dbd8f15cf9b04a26 . " ORDER BY `items`"; } else { $vf3e7552257b4e44beacffb073506f43d = "SELECT DISTINCT " . $v7dd0d06edf4c4299ce1a5978eb469fd8 . " as `item` FROM " . $v01b41e749613a642fc384ed8af3245fc . " WHERE o.field_id = " . $v0f728ec6147eaec54f5f45e37bce8ddd . $v86f6d00b1c7dbb44f4cd5edf49c29aa0 . $vc3a74cf64b6ccb62fa49a21123cbc72f; } $ve7d010371cfd5717d3d0b7d8e4c87803 = array(); $v98291d7af1e21c41194125137e4f90ec = l_mysql_query($vf3e7552257b4e44beacffb073506f43d); $ved05f7aecf3d274bef532a3ade31ad02 = mysql_errno(); $v89d8e64b77430ce4f0fe8ead989285bd = l_mysql_error(); if ($v98291d7af1e21c41194125137e4f90ec === false || $ved05f7aecf3d274bef532a3ade31ad02) { throw new coreException("Error executing db query (errno " . $ved05f7aecf3d274bef532a3ade31ad02 . ", error " . $v89d8e64b77430ce4f0fe8ead989285bd . ", query " . $vf3e7552257b4e44beacffb073506f43d . ")"); } else { while ($v7b93a31f8c7688c32c5a551b0e4937ee = mysql_fetch_assoc($v98291d7af1e21c41194125137e4f90ec)) { $ve7d010371cfd5717d3d0b7d8e4c87803[] = $v7b93a31f8c7688c32c5a551b0e4937ee; } } if ($vf80384e7987156531edaa3afd549957d) { $v30a7d3f52b5af853f2a7bba352210a34['values'] = array(); $vae886317ab0305e3e6a1638659ea03fa = 0; $v663ccf380acaf3f549f1612654dc109d = 0; foreach ($ve7d010371cfd5717d3d0b7d8e4c87803 as $vabd12a9143f26fa85e562e69c01c48db) { $v97023380f9705264978115e6ce880ca5 = intval($vabd12a9143f26fa85e562e69c01c48db['items']); $v30a7d3f52b5af853f2a7bba352210a34['values'][] = array('value' => $vabd12a9143f26fa85e562e69c01c48db['value'], 'cnt' => $v97023380f9705264978115e6ce880ca5); if ($v97023380f9705264978115e6ce880ca5 > $vae886317ab0305e3e6a1638659ea03fa) { $vae886317ab0305e3e6a1638659ea03fa = $v97023380f9705264978115e6ce880ca5; } $v663ccf380acaf3f549f1612654dc109d += $v97023380f9705264978115e6ce880ca5; } $v30a7d3f52b5af853f2a7bba352210a34['max'] = $vae886317ab0305e3e6a1638659ea03fa; $v30a7d3f52b5af853f2a7bba352210a34['sum'] = $v663ccf380acaf3f549f1612654dc109d; } else { foreach ($ve7d010371cfd5717d3d0b7d8e4c87803 as $vabd12a9143f26fa85e562e69c01c48db) { $v30a7d3f52b5af853f2a7bba352210a34[] = $vabd12a9143f26fa85e562e69c01c48db['item']; } } return $v30a7d3f52b5af853f2a7bba352210a34; }
/** * Сформировать массив со значениями, необходимыми для построения sql-запросов для работы с полями * * @return array Массив: array($sColumn, $iFieldId, $sActivePagesSubquery, $sCustomFiltersSubquery) */ protected function getPreparedSQLValues($oField) { $sColumn = umiFieldType::getDataTypeDB($oField->getFieldType()->getDataType()); $iFieldId = $oField->getId(); $sActivePagesSubquery = kFilters::getInstance($this->catalogId)->getSQL_activePages(); $sActivePagesSubquery = $sActivePagesSubquery == "" ? "" : "AND `obj_id` IN ({$sActivePagesSubquery})"; $sCustomFiltersSubquery = kFilters::getInstance($this->catalogId)->getSQL_customFilters(); $sCustomFiltersSubquery = $sCustomFiltersSubquery == "" ? "" : "AND `obj_id` IN ({$sCustomFiltersSubquery})"; return array($sColumn, $iFieldId, $sActivePagesSubquery, $sCustomFiltersSubquery); }
private function getDataByFieldId($v3aabf39f2d943fa886d86dcbbee4d910) { if ($v06e3d36fa30cea095545139854ad1fb9 = umiFieldsCollection::getInstance()->getField($v3aabf39f2d943fa886d86dcbbee4d910)) { $v1e3f04102267eaf5e8d0ca424fd5c561 = $v06e3d36fa30cea095545139854ad1fb9->getFieldTypeId(); if ($v519504d7d4beb745dac24ccfb6c1d7c9 = umiFieldTypesCollection::getInstance()->getFieldType($v1e3f04102267eaf5e8d0ca424fd5c561)) { if ($v17f71d965fe9589ddbd11caf7182243e = $v519504d7d4beb745dac24ccfb6c1d7c9->getDataType()) { return umiFieldType::getDataTypeDB($v17f71d965fe9589ddbd11caf7182243e); } else { return false; } } else { return false; } } else { return false; } }
/** * SQL-запрос, соответствующий кастомной логике для фильтров * * @return string */ public function getSQL_customFilters() { $sSQL = <<<SQL \t\t\tSELECT `coc`.`obj_id` \t\t\tFROM `{$this->sContentTable}` AS `coc` \t\t\tWHERE 1 SQL; $arCustomFilters = $this->customLogic->filters(); if (empty($arCustomFilters)) { return ""; } $oType = umiObjectTypesCollection::getInstance()->getType($this->objectsTypeId); if (!$oType) { return ""; } foreach ($arCustomFilters as $i => $arCustomFilter) { $iFieldId = $oType->getFieldId($arCustomFilter[0]); $sCustomOperator = $arCustomFilter[1]; $sOperator = ""; $sValue = $arCustomFilter[2]; switch ($sCustomOperator) { case "eq": $sOperator = "IN"; $sValue = is_array($sValue) ? join("','", $sValue) : $sValue; $sValue = "('" . $sValue . "')"; break; case "noteq": $sOperator = "NOT IN"; $sValue = is_array($sValue) ? join("','", $sValue) : $sValue; $sValue = "('" . $sValue . "')"; break; case "null": $sOperator = "IS"; $sValue = "NULL"; break; case "notnull": $sOperator = "IS NOT"; $sValue = "NULL"; break; case "gt": $sOperator = ">="; $sValue = trim($sValue); break; case "lt": $sOperator = "<="; $sValue = trim($sValue); break; case "like": $sOperator = "LIKE"; break; } $oField = umiFieldsCollection::getField($iFieldId); if (!$oField) { continue; } $sColumn = umiFieldType::getDataTypeDB($oField->getFieldType()->getDataType()); if (!$sColumn) { continue; } $sCustomExpression = "{$sColumn} {$sOperator} {$sValue}"; if (in_array($sColumn, array("int_val", "float_val", "rel_val", "tree_val")) && $sValue == 0) { $sCustomExpression = "({$sCustomExpression} OR {$sColumn} IS NULL)"; } $sSQL .= " AND `coc`.`obj_id` IN (SELECT `coc{$i}`.`obj_id` FROM `{$this->sContentTable}` AS `coc{$i}` WHERE `coc{$i}`.`field_id` = {$iFieldId} AND {$sCustomExpression})"; } return $sSQL; }