mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-26 03:30:48 +03:00
Фикс дополнительнгых полей
This commit is contained in:
parent
ee73bd47d2
commit
ef5004fff8
|
@ -86,6 +86,18 @@ class ModuleProperty extends ModuleORM {
|
|||
public function IsAllowTargetType($sTargetType) {
|
||||
return in_array($sTargetType,array_keys($this->aTargetTypes));
|
||||
}
|
||||
/**
|
||||
* Возвращает парметры нужного типа
|
||||
*
|
||||
* @param string $sTargetType
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function GetTargetTypeParams($sTargetType) {
|
||||
if ($this->IsAllowTargetType($sTargetType)) {
|
||||
return $this->aTargetTypes[$sTargetType];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Проверяет разрешен ли тип поля
|
||||
*
|
||||
|
|
|
@ -25,6 +25,13 @@ class ModuleProperty_EntityValue extends EntityORM {
|
|||
|
||||
);
|
||||
|
||||
protected function beforeSave() {
|
||||
if ($bResult=parent::beforeSave()) {
|
||||
$oValueType=$this->getValueTypeObject();
|
||||
$oValueType->beforeSaveValue();
|
||||
}
|
||||
return $bResult;
|
||||
}
|
||||
|
||||
public function getValueForDisplay() {
|
||||
$oValueType=$this->getValueTypeObject();
|
||||
|
|
|
@ -83,6 +83,10 @@ class ModuleProperty_EntityValueType extends Entity {
|
|||
return array();
|
||||
}
|
||||
|
||||
public function beforeSaveValue() {
|
||||
|
||||
}
|
||||
|
||||
public function removeValue() {
|
||||
|
||||
}
|
||||
|
|
|
@ -93,17 +93,26 @@ class ModuleProperty_EntityValueTypeSelect extends ModuleProperty_EntityValueTyp
|
|||
$aValues[$oSelect->getId()]=$oSelect->getValue();
|
||||
}
|
||||
}
|
||||
foreach($aValues as $k=>$v) {
|
||||
$oSelect=Engine::GetEntity('ModuleProperty_EntityValueSelect');
|
||||
$oSelect->setPropertyId($oValue->getPropertyId());
|
||||
$oSelect->setTargetType($oValue->getTargetType());
|
||||
$oSelect->setTargetId($oValue->getTargetId());
|
||||
$oSelect->setSelectId($k);
|
||||
$oSelect->Add();
|
||||
}
|
||||
$oValue->setData($aValues ? array('values'=>$aValues) : array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Дополнительная обработка перед сохранением значения
|
||||
*/
|
||||
public function beforeSaveValue() {
|
||||
$oValue=$this->getValueObject();
|
||||
if ($aValues=$oValue->getData()) {
|
||||
foreach($aValues['values'] as $k=>$v) {
|
||||
$oSelect=Engine::GetEntity('ModuleProperty_EntityValueSelect');
|
||||
$oSelect->setPropertyId($oValue->getPropertyId());
|
||||
$oSelect->setTargetType($oValue->getTargetType());
|
||||
$oSelect->setTargetId($oValue->getTargetId());
|
||||
$oSelect->setSelectId($k);
|
||||
$oSelect->Add();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function prepareValidateRulesRaw($aRulesRaw) {
|
||||
$aRules=array();
|
||||
$aRules['allowEmpty']=isset($aRulesRaw['allowEmpty']) ? false : true;
|
||||
|
|
|
@ -33,10 +33,17 @@ class ModuleProperty_EntityValueTypeTags extends ModuleProperty_EntityValueType
|
|||
$this->resetAllValue();
|
||||
$oValue=$this->getValueObject();
|
||||
$oValue->setValueVarchar($mValue ? $mValue : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Дополнительная обработка перед сохранением значения
|
||||
*/
|
||||
public function beforeSaveValue() {
|
||||
/**
|
||||
* Заливаем теги в отдельную таблицу
|
||||
*/
|
||||
if ($aTags=$this->getTagsArray()) {
|
||||
$oValue=$this->getValueObject();
|
||||
foreach($aTags as $sTag) {
|
||||
$oTag=Engine::GetEntity('ModuleProperty_EntityValueTag');
|
||||
$oTag->setPropertyId($oValue->getPropertyId());
|
||||
|
|
Loading…
Reference in a new issue