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 2014-11-20 11:57:37 +07:00
parent 2f2fc5c8c8
commit e0dbd6a62e
10 changed files with 43 additions and 24 deletions

View file

@ -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();
}
/**
* Валидируем необходимые поля топика
*/

View file

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

View file

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

View file

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

View file

@ -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 'Необходимо выбрать файл';

View file

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

View file

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

View file

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

View file

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