1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-26 03:30:48 +03:00

Фикс дополнительнгых полей

This commit is contained in:
Mzhelskiy Maxim 2013-12-06 15:32:39 +07:00
parent ee73bd47d2
commit ef5004fff8
5 changed files with 47 additions and 8 deletions

View file

@ -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];
}
}
/**
* Проверяет разрешен ли тип поля
*

View file

@ -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();

View file

@ -83,6 +83,10 @@ class ModuleProperty_EntityValueType extends Entity {
return array();
}
public function beforeSaveValue() {
}
public function removeValue() {
}

View file

@ -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;

View file

@ -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());