mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-26 03:30:48 +03:00
fix #783
This commit is contained in:
parent
7425641e23
commit
c42b43a332
|
@ -179,11 +179,11 @@ class ModuleProperty extends ModuleORM
|
||||||
* Получаем список значений
|
* Получаем список значений
|
||||||
*/
|
*/
|
||||||
$aValues = $this->Property_GetValueItemsByFilter(array(
|
$aValues = $this->Property_GetValueItemsByFilter(array(
|
||||||
'target_id' => $iTargetId,
|
'target_id' => $iTargetId,
|
||||||
'target_type' => $sTargetType,
|
'target_type' => $sTargetType,
|
||||||
'property_id in' => $aPropertyIds,
|
'property_id in' => $aPropertyIds,
|
||||||
'#index-from' => 'property_id'
|
'#index-from' => 'property_id'
|
||||||
));
|
));
|
||||||
/**
|
/**
|
||||||
* Аттачим значения к свойствам
|
* Аттачим значения к свойствам
|
||||||
*/
|
*/
|
||||||
|
@ -192,11 +192,11 @@ class ModuleProperty extends ModuleORM
|
||||||
$oProperty->setValue($aValues[$oProperty->getId()]);
|
$oProperty->setValue($aValues[$oProperty->getId()]);
|
||||||
} else {
|
} else {
|
||||||
$oProperty->setValue(Engine::GetEntity('ModuleProperty_EntityValue', array(
|
$oProperty->setValue(Engine::GetEntity('ModuleProperty_EntityValue', array(
|
||||||
'property_id' => $oProperty->getId(),
|
'property_id' => $oProperty->getId(),
|
||||||
'property_type' => $oProperty->getType(),
|
'property_type' => $oProperty->getType(),
|
||||||
'target_type' => $sTargetType,
|
'target_type' => $sTargetType,
|
||||||
'target_id' => $iTargetId
|
'target_id' => $iTargetId
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
$oProperty->getValue()->setProperty($oProperty);
|
$oProperty->getValue()->setProperty($oProperty);
|
||||||
}
|
}
|
||||||
|
@ -282,7 +282,7 @@ class ModuleProperty extends ModuleORM
|
||||||
$oValueType->setValue($oValueType->getValueForValidate());
|
$oValueType->setValue($oValueType->getValueForValidate());
|
||||||
$aPropertiesResult[$oProperty->getId()] = $oProperty;
|
$aPropertiesResult[$oProperty->getId()] = $oProperty;
|
||||||
} else {
|
} else {
|
||||||
return 'Поле "'.$oProperty->getTitle().'": '.($sRes ? $sRes : 'неверное значение');
|
return 'Поле "' . $oProperty->getTitle() . '": ' . ($sRes ? $sRes : 'неверное значение');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$oTarget->setPropertiesObject($aPropertiesResult);
|
$oTarget->setPropertiesObject($aPropertiesResult);
|
||||||
|
@ -445,13 +445,16 @@ class ModuleProperty extends ModuleORM
|
||||||
*/
|
*/
|
||||||
if (isset($aFilter['#properties']) and $aFilter['#properties']) {
|
if (isset($aFilter['#properties']) and $aFilter['#properties']) {
|
||||||
$aEntitiesId = array();
|
$aEntitiesId = array();
|
||||||
|
$aTargetTypes = array();
|
||||||
foreach ($aEntitiesWork as $oEntity) {
|
foreach ($aEntitiesWork as $oEntity) {
|
||||||
$aEntitiesId[] = $oEntity->getId();
|
$aEntitiesId[] = $oEntity->getId();
|
||||||
|
$aTargetTypes[] = $oEntity->getPropertyTargetType();
|
||||||
}
|
}
|
||||||
|
$aTargetTypes = array_unique($aTargetTypes);
|
||||||
/**
|
/**
|
||||||
* Получаем все свойства со значениями для всех объектов
|
* Получаем все свойства со значениями для всех объектов
|
||||||
*/
|
*/
|
||||||
$aResult = $this->oMapper->GetPropertiesValueByTargetArray($sTargetType, $aEntitiesId);
|
$aResult = $this->oMapper->GetPropertiesValueByTargetArray($aTargetTypes, $aEntitiesId);
|
||||||
if ($aResult) {
|
if ($aResult) {
|
||||||
/**
|
/**
|
||||||
* Формируем список свойств и значений
|
* Формируем список свойств и значений
|
||||||
|
@ -490,11 +493,11 @@ class ModuleProperty extends ModuleORM
|
||||||
$oValue = $aValues[$sKey];
|
$oValue = $aValues[$sKey];
|
||||||
} else {
|
} else {
|
||||||
$oValue = Engine::GetEntity('ModuleProperty_EntityValue', array(
|
$oValue = Engine::GetEntity('ModuleProperty_EntityValue', array(
|
||||||
'property_type' => $oProperty->getType(),
|
'property_type' => $oProperty->getType(),
|
||||||
'property_id' => $oProperty->getId(),
|
'property_id' => $oProperty->getId(),
|
||||||
'target_type' => $oProperty->getTargetType(),
|
'target_type' => $oProperty->getTargetType(),
|
||||||
'target_id' => $oEntity->getId()
|
'target_id' => $oEntity->getId()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
$oPropertyNew->setValue($oValue);
|
$oPropertyNew->setValue($oValue);
|
||||||
$oValue->setProperty($oPropertyNew);
|
$oValue->setProperty($oPropertyNew);
|
||||||
|
@ -560,9 +563,9 @@ class ModuleProperty extends ModuleORM
|
||||||
if ($aPropFields) {
|
if ($aPropFields) {
|
||||||
$sTargetType = $oEntitySample->property->getPropertyTargetType();
|
$sTargetType = $oEntitySample->property->getPropertyTargetType();
|
||||||
$aProperties = $this->Property_GetPropertyItemsByFilter(array(
|
$aProperties = $this->Property_GetPropertyItemsByFilter(array(
|
||||||
'code in' => array_keys($aPropFields),
|
'code in' => array_keys($aPropFields),
|
||||||
'target_type' => $sTargetType
|
'target_type' => $sTargetType
|
||||||
));
|
));
|
||||||
$iPropNum = 0;
|
$iPropNum = 0;
|
||||||
foreach ($aProperties as $oProperty) {
|
foreach ($aProperties as $oProperty) {
|
||||||
/**
|
/**
|
||||||
|
@ -578,10 +581,10 @@ class ModuleProperty extends ModuleORM
|
||||||
$sFieldValue = "value_float";
|
$sFieldValue = "value_float";
|
||||||
$sConditionFull = $sCondition . ($bIsArray ? ' (?a) ' : ' ?f ');
|
$sConditionFull = $sCondition . ($bIsArray ? ' (?a) ' : ' ?f ');
|
||||||
} elseif (in_array($oProperty->getType(), array(
|
} elseif (in_array($oProperty->getType(), array(
|
||||||
ModuleProperty::PROPERTY_TYPE_VARCHAR,
|
ModuleProperty::PROPERTY_TYPE_VARCHAR,
|
||||||
ModuleProperty::PROPERTY_TYPE_TAGS,
|
ModuleProperty::PROPERTY_TYPE_TAGS,
|
||||||
ModuleProperty::PROPERTY_TYPE_VIDEO_LINK
|
ModuleProperty::PROPERTY_TYPE_VIDEO_LINK
|
||||||
))) {
|
))) {
|
||||||
$sFieldValue = "value_varchar";
|
$sFieldValue = "value_varchar";
|
||||||
$sConditionFull = $sCondition . ($bIsArray ? ' (?a) ' : ' ? ');
|
$sConditionFull = $sCondition . ($bIsArray ? ' (?a) ' : ' ? ');
|
||||||
} elseif ($oProperty->getType() == ModuleProperty::PROPERTY_TYPE_TEXT) {
|
} elseif ($oProperty->getType() == ModuleProperty::PROPERTY_TYPE_TEXT) {
|
||||||
|
@ -821,9 +824,9 @@ class ModuleProperty extends ModuleORM
|
||||||
* Получаем набор свойств
|
* Получаем набор свойств
|
||||||
*/
|
*/
|
||||||
$aProperties = $this->Property_GetPropertyItemsByFilter(array(
|
$aProperties = $this->Property_GetPropertyItemsByFilter(array(
|
||||||
'target_type' => $sTargetType,
|
'target_type' => $sTargetType,
|
||||||
'#order' => array('sort' => 'desc')
|
'#order' => array('sort' => 'desc')
|
||||||
));
|
));
|
||||||
$this->Property_AttachValueForProperties($aProperties, $sTargetType, $iTargetId);
|
$this->Property_AttachValueForProperties($aProperties, $sTargetType, $iTargetId);
|
||||||
return $aProperties;
|
return $aProperties;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,11 +75,14 @@ class ModuleProperty_MapperProperty extends Mapper
|
||||||
return $aResult;
|
return $aResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function GetPropertiesValueByTargetArray($sTargetType, $aTargetId)
|
public function GetPropertiesValueByTargetArray($aTargetType, $aTargetId)
|
||||||
{
|
{
|
||||||
if (!is_array($aTargetId)) {
|
if (!is_array($aTargetId)) {
|
||||||
$aTargetId = array($aTargetId);
|
$aTargetId = array($aTargetId);
|
||||||
}
|
}
|
||||||
|
if (!is_array($aTargetType)) {
|
||||||
|
$aTargetType = array($aTargetType);
|
||||||
|
}
|
||||||
if (!$aTargetId) {
|
if (!$aTargetId) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
@ -96,12 +99,12 @@ class ModuleProperty_MapperProperty extends Mapper
|
||||||
FROM " . Config::Get('db.table.property') . " AS p
|
FROM " . Config::Get('db.table.property') . " AS p
|
||||||
LEFT JOIN " . Config::Get('db.table.property_value') . " as v on ( v.property_id=p.id and v.target_id IN ( ?a ) )
|
LEFT JOIN " . Config::Get('db.table.property_value') . " as v on ( v.property_id=p.id and v.target_id IN ( ?a ) )
|
||||||
WHERE
|
WHERE
|
||||||
p.target_type = ?
|
p.target_type IN ( ?a )
|
||||||
ORDER BY
|
ORDER BY
|
||||||
p.sort desc ";
|
p.sort desc ";
|
||||||
|
|
||||||
$aResult = array();
|
$aResult = array();
|
||||||
if ($aRows = $this->oDb->select($sql, $aTargetId, $sTargetType)) {
|
if ($aRows = $this->oDb->select($sql, $aTargetId, $aTargetType)) {
|
||||||
return $aRows;
|
return $aRows;
|
||||||
}
|
}
|
||||||
return $aResult;
|
return $aResult;
|
||||||
|
|
Loading…
Reference in a new issue