mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-26 03:30:48 +03:00
Доработка дополнительных полей
This commit is contained in:
parent
2f2fc5c8c8
commit
e0dbd6a62e
|
@ -530,12 +530,18 @@ class ActionContent extends Action
|
|||
$this->Message_AddErrorSingle($this->Lang_Get('topic.add.notices.error_type'), $this->Lang_Get('error'));
|
||||
return;
|
||||
}
|
||||
$aTopicRequest = getRequest('topic');
|
||||
/**
|
||||
* Проверка на ID при редактировании топика
|
||||
*/
|
||||
$iId=isset($aTopicRequest['id']) ? (int)$aTopicRequest['id'] : null;
|
||||
if ($iId and !($oTopicOriginal=$this->Topic_GetTopicById($iId))) {
|
||||
return $this->EventErrorDebug();
|
||||
}
|
||||
/**
|
||||
* Создаем объект топика для валидации данных
|
||||
*/
|
||||
$oTopic = Engine::GetEntity('ModuleTopic_EntityTopic');
|
||||
|
||||
$aTopicRequest = getRequest('topic');
|
||||
$oTopic->setTitle(isset($aTopicRequest['topic_title']) ? strip_tags($aTopicRequest['topic_title']) : '');
|
||||
$oTopic->setTextSource(isset($aTopicRequest['topic_text_source']) ? $aTopicRequest['topic_text_source'] : '');
|
||||
$oTopic->setTags(isset($aTopicRequest['topic_tags']) ? $aTopicRequest['topic_tags'] : '');
|
||||
|
@ -544,6 +550,13 @@ class ActionContent extends Action
|
|||
$oTopic->setType($sType);
|
||||
$oTopic->setPublish(1);
|
||||
$oTopic->setProperties(getRequest('property'));
|
||||
/**
|
||||
* Перед валидацией аттачим существующие свойста
|
||||
*/
|
||||
if ($iId) {
|
||||
$oTopic->setId($iId);
|
||||
$a=$oTopic->getPropertyList();
|
||||
}
|
||||
/**
|
||||
* Валидируем необходимые поля топика
|
||||
*/
|
||||
|
|
|
@ -282,7 +282,7 @@ class ModuleProperty extends ModuleORM
|
|||
$oValueType->setValue($oValueType->getValueForValidate());
|
||||
$aPropertiesResult[$oProperty->getId()] = $oProperty;
|
||||
} else {
|
||||
return $sRes ? $sRes : 'Неверное значение аттрибута: ' . $oProperty->getTitle();
|
||||
return 'Поле "'.$oProperty->getTitle().'": '.($sRes ? $sRes : 'неверное значение');
|
||||
}
|
||||
}
|
||||
$oTarget->setPropertiesObject($aPropertiesResult);
|
||||
|
|
|
@ -57,7 +57,7 @@ class ModuleProperty_EntityValueType extends Entity
|
|||
*/
|
||||
$aParams = $oProperty->getValidateRules();
|
||||
if (!isset($aParams['label'])) {
|
||||
$aParams['label'] = $oProperty->getTitle();
|
||||
$aParams['label'] = '';
|
||||
}
|
||||
$aParams = array_merge($aParams, $aParamsAdditional);
|
||||
|
||||
|
|
|
@ -42,14 +42,17 @@ class ModuleProperty_EntityValueTypeCheckbox extends ModuleProperty_EntityValueT
|
|||
|
||||
public function validate()
|
||||
{
|
||||
return $this->validateStandart('boolean');
|
||||
$sValue = $this->getValueForValidate();
|
||||
$this->setValueForValidate($sValue ? 1 : 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function setValue($mValue)
|
||||
{
|
||||
$this->resetAllValue();
|
||||
$oValue = $this->getValueObject();
|
||||
$oValue->setValueInt($mValue ? 1 : 0);
|
||||
$oProperty = $oValue->getProperty();
|
||||
$oValue->setValueInt($mValue ? $oProperty->getParam('default_value') : 0);
|
||||
}
|
||||
|
||||
public function prepareParamsRaw($aParamsRaw)
|
||||
|
|
|
@ -39,8 +39,10 @@ class ModuleProperty_EntityValueTypeFile extends ModuleProperty_EntityValueType
|
|||
$oProperty = $oValue->getProperty();
|
||||
$iPropertyId = $oProperty->getId();
|
||||
|
||||
$bNeedRemove=false;
|
||||
$mValue = $this->getValueForValidate();
|
||||
if (isset($mValue['remove']) and $mValue['remove']) {
|
||||
$bNeedRemove=true;
|
||||
$this->setValueForValidate(array('remove' => true));
|
||||
}
|
||||
|
||||
|
@ -52,7 +54,7 @@ class ModuleProperty_EntityValueTypeFile extends ModuleProperty_EntityValueType
|
|||
if (!$sFileTmpName) {
|
||||
if ($oProperty->getValidateRuleOne('allowEmpty')) {
|
||||
return true;
|
||||
} elseif ($aFilePrev = $oValue->getDataOne('file') and isset($aFilePrev['path'])) {
|
||||
} elseif ($aFilePrev = $oValue->getDataOne('file') and isset($aFilePrev['path']) and !$bNeedRemove) {
|
||||
return true;
|
||||
} else {
|
||||
return 'Необходимо выбрать файл';
|
||||
|
|
|
@ -34,12 +34,7 @@ class ModuleProperty_EntityValueTypeImage extends ModuleProperty_EntityValueType
|
|||
* Показываем превью, в качестве изображения берем первый ресайз из списка размеров
|
||||
*/
|
||||
if ($aFile = $this->oValue->getDataOne('file') and isset($aFile['path'])) {
|
||||
$sSize = null;
|
||||
if ($aSizes = $this->oValue->getDataOne('image_sizes')) {
|
||||
$sSize = array_shift($aSizes);
|
||||
}
|
||||
$sWebPath = $this->Media_GetImageWebPath($aFile['path'], $sSize);
|
||||
return '<a href=""><img src="' . $sWebPath . '" class="js-lbx" /></a>';
|
||||
return '<a href="'.$this->getImageWebPath().'" class="js-lbx"><img src="' . $this->getImageWebPath($this->getImageSizeFirst()) . '" /></a>';
|
||||
}
|
||||
return $this->getFileFullName();
|
||||
}
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
{* TODO: Viewer_TemplateExists не работает *}
|
||||
|
||||
{$property = $smarty.local.property}
|
||||
|
||||
{if $property}
|
||||
{* Проверяем наличие кастомного шаблона item.[type].[target_type].tpl *}
|
||||
{$template = "./property.{$property->getType()}.{$property->getTargetType()}.tpl"}
|
||||
{$template = $smarty.current_dir|cat:"/property.{$property->getType()}.{$property->getTargetType()}.tpl"}
|
||||
|
||||
{if $LS->Viewer_TemplateExists( $template )}
|
||||
{include "{$template}" property=$property}
|
||||
{else}
|
||||
{* Проверяем наличие кастомного шаблона item.[type].tpl *}
|
||||
{$template = "./property.{$property->getType()}.tpl"}
|
||||
{$template = $smarty.current_dir|cat:"/property.{$property->getType()}.tpl"}
|
||||
|
||||
{if $LS->Viewer_TemplateExists( $template )}
|
||||
{include "{$template}" property=$property}
|
||||
|
|
|
@ -5,9 +5,13 @@
|
|||
{$property->getTitle()}
|
||||
</div>
|
||||
|
||||
{if $oUserCurrent || ! $property->getParam('access_only_auth')}
|
||||
<a href="{router page="property/download"}{$value->getValueVarchar()}/">{$value->getValueForDisplay()}</a>
|
||||
{if $value->getValueVarchar()}
|
||||
{if $oUserCurrent || ! $property->getParam('access_only_auth')}
|
||||
<a href="{router page="property/download"}{$value->getValueVarchar()}/">{$value->getValueForDisplay()}</a>
|
||||
{else}
|
||||
Для доступа к файлу <a href="#" class="js-modal-toggle-login">необходимо авторизоваться</a>
|
||||
{/if}
|
||||
{else}
|
||||
Для доступа к файлу <a href="#" class="js-modal-toggle-login">необходимо авторизоваться</a>
|
||||
файла нет
|
||||
{/if}
|
||||
</div>
|
|
@ -5,7 +5,11 @@
|
|||
{$property->getTitle()}
|
||||
</div>
|
||||
|
||||
<a href="{$valueType->getImageWebPath()}" class="js-lbx" target="_blank">
|
||||
<img src="{$valueType->getImageWebPath( $valueType->getImageSizeFirst() )}" >
|
||||
</a>
|
||||
{if $valueType->getImageWebPath()}
|
||||
<a href="{$valueType->getImageWebPath()}" class="js-lbx" target="_blank">
|
||||
<img src="{$valueType->getImageWebPath( $valueType->getImageSizeFirst() )}" >
|
||||
</a>
|
||||
{else}
|
||||
изображения нет
|
||||
{/if}
|
||||
</div>
|
|
@ -1 +1 @@
|
|||
Subproject commit 52be8aa2273bbb23457131c2af37e9959143ca03
|
||||
Subproject commit 870c8f31c15df1ab33c178649b6a30c07a38ad57
|
Loading…
Reference in a new issue