mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-17 07:10:48 +03:00
Дополнительные поля: новый метод isEmpty
This commit is contained in:
parent
74028f4072
commit
2574199101
|
@ -100,11 +100,11 @@ class ModuleProperty_EntityProperty extends EntityORM
|
|||
* Валидация зависит от типа
|
||||
*/
|
||||
$oValue = Engine::GetEntity('ModuleProperty_EntityValue', array(
|
||||
'property_type' => $this->getType(),
|
||||
'property_id' => $this->getId(),
|
||||
'target_type' => $this->getTargetType(),
|
||||
'target_id' => $this->getId()
|
||||
));
|
||||
'property_type' => $this->getType(),
|
||||
'property_id' => $this->getId(),
|
||||
'target_type' => $this->getTargetType(),
|
||||
'target_id' => $this->getId()
|
||||
));
|
||||
$oValueType = $oValue->getValueTypeObject();
|
||||
$aRules = $oValueType->prepareValidateRulesRaw($aRulesRaw);
|
||||
$this->setValidateRules($aRules);
|
||||
|
@ -118,11 +118,11 @@ class ModuleProperty_EntityProperty extends EntityORM
|
|||
* Валидация зависит от типа
|
||||
*/
|
||||
$oValue = Engine::GetEntity('ModuleProperty_EntityValue', array(
|
||||
'property_type' => $this->getType(),
|
||||
'property_id' => $this->getId(),
|
||||
'target_type' => $this->getTargetType(),
|
||||
'target_id' => $this->getId()
|
||||
));
|
||||
'property_type' => $this->getType(),
|
||||
'property_id' => $this->getId(),
|
||||
'target_type' => $this->getTargetType(),
|
||||
'target_id' => $this->getId()
|
||||
));
|
||||
$oValueType = $oValue->getValueTypeObject();
|
||||
$aParams = $oValueType->prepareParamsRaw($aParamsRaw);
|
||||
$this->setParams($aParams);
|
||||
|
@ -141,11 +141,11 @@ class ModuleProperty_EntityProperty extends EntityORM
|
|||
$this->setDateCreate(date("Y-m-d H:i:s"));
|
||||
|
||||
$oValue = Engine::GetEntity('ModuleProperty_EntityValue', array(
|
||||
'property_type' => $this->getType(),
|
||||
'property_id' => $this->getId(),
|
||||
'target_type' => $this->getTargetType(),
|
||||
'target_id' => $this->getId()
|
||||
));
|
||||
'property_type' => $this->getType(),
|
||||
'property_id' => $this->getId(),
|
||||
'target_type' => $this->getTargetType(),
|
||||
'target_id' => $this->getId()
|
||||
));
|
||||
$oValueType = $oValue->getValueTypeObject();
|
||||
/**
|
||||
* Выставляем дефолтные значения параметров
|
||||
|
@ -328,4 +328,11 @@ class ModuleProperty_EntityProperty extends EntityORM
|
|||
return Config::Get('path.uploads.base') . '/property/' . $this->getTargetType() . '/' . $this->getType() . '/' . date('Y/m/d/H/') . ($sPostfix ? "{$sPostfix}/" : '');
|
||||
}
|
||||
|
||||
public function isEmpty()
|
||||
{
|
||||
if (!$oValue = $this->getValue()) {
|
||||
return true;
|
||||
}
|
||||
return $oValue->isEmpty();
|
||||
}
|
||||
}
|
|
@ -47,6 +47,12 @@ class ModuleProperty_EntityValue extends EntityORM
|
|||
return $oValueType->getValueForDisplay();
|
||||
}
|
||||
|
||||
public function isEmpty()
|
||||
{
|
||||
$oValueType = $this->getValueTypeObject();
|
||||
return $oValueType->isEmpty();
|
||||
}
|
||||
|
||||
public function getValueForForm()
|
||||
{
|
||||
$oValueType = $this->getValueTypeObject();
|
||||
|
|
|
@ -41,6 +41,11 @@ class ModuleProperty_EntityValueType extends Entity
|
|||
return htmlspecialchars($this->getValueObject()->getValue());
|
||||
}
|
||||
|
||||
public function isEmpty()
|
||||
{
|
||||
return $this->getValueObject()->getValueVarchar() ? false : true;
|
||||
}
|
||||
|
||||
public function validate()
|
||||
{
|
||||
return 'Неверное значение';
|
||||
|
|
|
@ -40,6 +40,11 @@ class ModuleProperty_EntityValueTypeCheckbox extends ModuleProperty_EntityValueT
|
|||
return $oValue->_isNew() ? $oProperty->getParam('default') : $oValue->getValueInt();
|
||||
}
|
||||
|
||||
public function isEmpty()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function validate()
|
||||
{
|
||||
$sValue = $this->getValueForValidate();
|
||||
|
|
|
@ -40,6 +40,11 @@ class ModuleProperty_EntityValueTypeDate extends ModuleProperty_EntityValueType
|
|||
strtotime($oValue->getValueDate())) : '';
|
||||
}
|
||||
|
||||
public function isEmpty()
|
||||
{
|
||||
return $this->getValueObject()->getValueDate() ? false : true;
|
||||
}
|
||||
|
||||
public function getValueForForm()
|
||||
{
|
||||
$oValue = $this->getValueObject();
|
||||
|
|
|
@ -33,6 +33,11 @@ class ModuleProperty_EntityValueTypeFile extends ModuleProperty_EntityValueType
|
|||
return $this->getFileFullName();
|
||||
}
|
||||
|
||||
public function isEmpty()
|
||||
{
|
||||
return $this->getFileFullName() ? false : true;
|
||||
}
|
||||
|
||||
public function validate()
|
||||
{
|
||||
$oValue = $this->getValueObject();
|
||||
|
|
|
@ -33,6 +33,11 @@ class ModuleProperty_EntityValueTypeFloat extends ModuleProperty_EntityValueType
|
|||
return $this->getValueObject()->getValueFloat();
|
||||
}
|
||||
|
||||
public function isEmpty()
|
||||
{
|
||||
return is_null($this->getValueObject()->getValueFloat()) ? true : false;
|
||||
}
|
||||
|
||||
public function getValueForForm()
|
||||
{
|
||||
$oValue = $this->getValueObject();
|
||||
|
|
|
@ -33,6 +33,11 @@ class ModuleProperty_EntityValueTypeInt extends ModuleProperty_EntityValueType
|
|||
return $this->getValueObject()->getValueInt();
|
||||
}
|
||||
|
||||
public function isEmpty()
|
||||
{
|
||||
return is_null($this->getValueObject()->getValueInt()) ? true : false;
|
||||
}
|
||||
|
||||
public function getValueForForm()
|
||||
{
|
||||
$oValue = $this->getValueObject();
|
||||
|
|
|
@ -35,6 +35,13 @@ class ModuleProperty_EntityValueTypeSelect extends ModuleProperty_EntityValueTyp
|
|||
return is_array($aValues) ? join(', ', $aValues) : '';
|
||||
}
|
||||
|
||||
public function isEmpty()
|
||||
{
|
||||
$oValue = $this->getValueObject();
|
||||
$aValues = $oValue->getDataOne('values');
|
||||
return $aValues ? false : true;
|
||||
}
|
||||
|
||||
public function getValueForForm()
|
||||
{
|
||||
$oValue = $this->getValueObject();
|
||||
|
|
|
@ -33,6 +33,11 @@ class ModuleProperty_EntityValueTypeText extends ModuleProperty_EntityValueType
|
|||
return $this->getValueObject()->getValueText();
|
||||
}
|
||||
|
||||
public function isEmpty()
|
||||
{
|
||||
return $this->getValueObject()->getValueText() ? false : true;
|
||||
}
|
||||
|
||||
public function getValueForForm()
|
||||
{
|
||||
$oValue = $this->getValueObject();
|
||||
|
|
Loading…
Reference in a new issue