2014-07-28 19:55:18 +03:00
|
|
|
|
{**
|
|
|
|
|
* Базовая форма создания топика
|
|
|
|
|
*
|
|
|
|
|
* @param object $topic
|
|
|
|
|
* @param object $type
|
|
|
|
|
* @param array $blogs
|
2014-11-19 14:07:42 +02:00
|
|
|
|
* @param array $blogId
|
2014-07-28 19:55:18 +03:00
|
|
|
|
*}
|
|
|
|
|
|
2016-08-30 07:28:40 +03:00
|
|
|
|
{component_define_params params=[ 'topic', 'type', 'skipBlogs', 'blogs', 'classes' ]}
|
2014-07-28 19:55:18 +03:00
|
|
|
|
|
2016-08-30 07:28:40 +03:00
|
|
|
|
<form action="" method="POST" enctype="multipart/form-data" id="topic-add-form" class="{$classes} js-form-validate" data-content-action="{( $topic ) ? 'edit' : 'add'}">
|
2017-03-21 23:12:46 +02:00
|
|
|
|
{hook run="form_add_topic_begin" topic=$topic}
|
2014-10-18 09:07:45 +03:00
|
|
|
|
{block 'add_topic_form_begin'}{/block}
|
2014-07-28 19:55:18 +03:00
|
|
|
|
|
2014-10-18 09:07:45 +03:00
|
|
|
|
{* Выбор блога *}
|
2016-04-07 12:40:28 +03:00
|
|
|
|
{if ! $skipBlogs}
|
2014-12-31 10:28:29 +02:00
|
|
|
|
{$blogsSelect = []}
|
2015-02-26 16:47:26 +02:00
|
|
|
|
{$blogsSelectId = []}
|
2015-03-09 17:32:31 +02:00
|
|
|
|
{$blogsSelectedId=[]}
|
2014-12-31 10:28:29 +02:00
|
|
|
|
|
2016-04-27 13:20:46 +03:00
|
|
|
|
{foreach $blogs as $blogType => $blogItems}
|
2014-12-31 10:28:29 +02:00
|
|
|
|
{$blogsSelectOptions = []}
|
|
|
|
|
|
2016-04-27 13:20:46 +03:00
|
|
|
|
{foreach $blogItems as $blog}
|
2014-12-31 10:28:29 +02:00
|
|
|
|
{$blogsSelectOptions[] = [
|
|
|
|
|
'text' => $blog->getTitle()|escape,
|
|
|
|
|
'value' => $blog->getId()
|
|
|
|
|
]}
|
2015-02-26 16:47:26 +02:00
|
|
|
|
{$blogsSelectId[]=$blog->getId()}
|
2014-12-30 18:38:04 +02:00
|
|
|
|
{/foreach}
|
2014-12-31 10:28:29 +02:00
|
|
|
|
|
|
|
|
|
{$blogsSelect[] = [
|
|
|
|
|
'text' => {lang "blog.types.{$blogType}"},
|
|
|
|
|
'value' => $blogsSelectOptions
|
|
|
|
|
]}
|
|
|
|
|
{/foreach}
|
|
|
|
|
|
2015-02-10 05:24:33 +02:00
|
|
|
|
{if $topic}
|
2015-02-26 16:47:26 +02:00
|
|
|
|
{json var=array_intersect($topic->getBlogsId(),$blogsSelectId) assign='chosenOrder'}
|
2015-03-09 17:32:31 +02:00
|
|
|
|
{$blogsSelectedId = $topic->getBlogsId()}
|
|
|
|
|
{else}
|
|
|
|
|
{if $_aRequest.blog_id}
|
|
|
|
|
{$blogsSelectedId[] = $_aRequest.blog_id}
|
|
|
|
|
{/if}
|
2015-02-10 05:24:33 +02:00
|
|
|
|
{/if}
|
|
|
|
|
|
2017-02-06 05:56:36 +02:00
|
|
|
|
{component 'field.autocomplete'
|
2014-12-31 10:28:29 +02:00
|
|
|
|
label = $aLang.topic.add.fields.blog.label
|
2015-02-04 10:53:29 +02:00
|
|
|
|
name = ''
|
2017-02-02 02:22:27 +02:00
|
|
|
|
placeholder = $aLang.topic.add.fields.blog.placeholder
|
2017-03-01 11:38:21 +02:00
|
|
|
|
inputClasses = 'js-topic-add-blogs ls-hidden'
|
2014-12-31 10:28:29 +02:00
|
|
|
|
isMultiple = true
|
2015-03-09 17:32:31 +02:00
|
|
|
|
selectedValue = $blogsSelectedId
|
2015-02-10 05:24:33 +02:00
|
|
|
|
inputAttributes = [ 'data-chosen-order' => {$chosenOrder} ]
|
2014-12-31 10:28:29 +02:00
|
|
|
|
items = $blogsSelect}
|
2014-12-30 18:38:04 +02:00
|
|
|
|
{/if}
|
2014-07-28 19:55:18 +03:00
|
|
|
|
|
|
|
|
|
|
2014-10-18 09:07:45 +03:00
|
|
|
|
{* Заголовок топика *}
|
2015-01-03 10:19:49 +02:00
|
|
|
|
{component 'field' template='text'
|
2014-10-18 09:07:45 +03:00
|
|
|
|
name = 'topic[topic_title]'
|
2015-06-16 07:29:41 +03:00
|
|
|
|
value = {(( $topic ) ? $topic->getTitle() : '')}
|
2014-10-18 09:07:45 +03:00
|
|
|
|
entityField = 'topic_title'
|
|
|
|
|
entity = 'ModuleTopic_EntityTopic'
|
|
|
|
|
label = $aLang.topic.add.fields.title.label}
|
2014-07-28 19:55:18 +03:00
|
|
|
|
|
2015-03-17 10:38:47 +02:00
|
|
|
|
{* URL топика *}
|
|
|
|
|
{if $oUserCurrent->isAdministrator()}
|
|
|
|
|
{component 'field' template='text'
|
|
|
|
|
name = 'topic[topic_slug_raw]'
|
2015-06-16 07:29:41 +03:00
|
|
|
|
value = {(( $topic ) ? $topic->getSlug() : '')}
|
2015-03-17 10:38:47 +02:00
|
|
|
|
note = {lang 'topic.add.fields.slug.note'}
|
|
|
|
|
label = {lang 'topic.add.fields.slug.label'}}
|
|
|
|
|
{/if}
|
|
|
|
|
|
2014-10-18 09:07:45 +03:00
|
|
|
|
{block 'add_topic_form_text_before'}{/block}
|
2014-07-28 19:55:18 +03:00
|
|
|
|
|
|
|
|
|
|
2014-10-18 09:07:45 +03:00
|
|
|
|
{* Текст топика *}
|
|
|
|
|
{if $type->getParam('allow_text')}
|
2015-01-03 10:19:49 +02:00
|
|
|
|
{component 'editor'
|
2014-10-18 09:07:45 +03:00
|
|
|
|
name = 'topic[topic_text_source]'
|
2015-06-16 07:29:41 +03:00
|
|
|
|
value = (( $topic ) ? $topic->getTextSource() : '')
|
2014-10-18 09:07:45 +03:00
|
|
|
|
label = $aLang.topic.add.fields.text.label
|
|
|
|
|
entityField = 'topic_text_source'
|
|
|
|
|
entity = 'ModuleTopic_EntityTopic'
|
2014-10-21 16:59:33 +03:00
|
|
|
|
inputClasses = 'js-editor-default'
|
2014-10-18 09:07:45 +03:00
|
|
|
|
mediaTargetType = 'topic'
|
|
|
|
|
mediaTargetId = ( $topic ) ? $topic->getId() : ''}
|
|
|
|
|
{/if}
|
2014-07-28 19:55:18 +03:00
|
|
|
|
|
2014-10-18 09:07:45 +03:00
|
|
|
|
{block 'add_topic_form_text_after'}{/block}
|
2014-07-28 19:55:18 +03:00
|
|
|
|
|
|
|
|
|
|
2014-10-18 09:07:45 +03:00
|
|
|
|
{* Теги *}
|
|
|
|
|
{if $type->getParam('allow_tags')}
|
2016-09-30 13:13:30 +03:00
|
|
|
|
{$tagsCountMin=Config::Get('module.topic.tags_count_min')}
|
|
|
|
|
{$tagsCountMax=Config::Get('module.topic.tags_count_max')}
|
2015-01-03 10:19:49 +02:00
|
|
|
|
{component 'field' template='text'
|
2014-10-18 09:07:45 +03:00
|
|
|
|
name = 'topic[topic_tags]'
|
2015-06-16 07:29:41 +03:00
|
|
|
|
value = {(( $topic ) ? $topic->getTags() : '')}
|
2016-09-30 13:13:30 +03:00
|
|
|
|
rules = [ 'required' => !Config::Get('module.topic.tags_allow_empty'), 'rangetags' => "[{$tagsCountMin},{$tagsCountMax}]" ]
|
2014-10-21 16:59:33 +03:00
|
|
|
|
label = {lang 'topic.add.fields.tags.label'}
|
|
|
|
|
note = {lang 'topic.add.fields.tags.note'}
|
2015-10-28 13:00:45 +02:00
|
|
|
|
inputClasses = 'ls-width-full autocomplete-tags-sep'}
|
2014-10-18 09:07:45 +03:00
|
|
|
|
{/if}
|
2014-07-28 19:55:18 +03:00
|
|
|
|
|
|
|
|
|
|
2014-10-18 09:07:45 +03:00
|
|
|
|
{* Показывает дополнительные поля *}
|
2014-10-21 16:59:33 +03:00
|
|
|
|
{insert name='block' block='propertyUpdate' params=[
|
|
|
|
|
'target' => $topic,
|
|
|
|
|
'entity' => 'ModuleTopic_EntityTopic',
|
|
|
|
|
'target_type' => "topic_{$type->getCode()}"
|
|
|
|
|
]}
|
2014-07-28 19:55:18 +03:00
|
|
|
|
|
|
|
|
|
|
2014-12-24 11:58:10 +02:00
|
|
|
|
{* Выбор превью *}
|
2015-02-06 12:20:25 +02:00
|
|
|
|
{if $type->getParam('allow_preview')}
|
|
|
|
|
{component 'field' template='image-ajax'
|
|
|
|
|
label = 'Превью'
|
|
|
|
|
modalTitle = 'Выбор превью для топика'
|
|
|
|
|
targetType = 'topic'
|
|
|
|
|
targetId = ( $topic ) ? $topic->getId() : ''
|
|
|
|
|
classes = 'js-topic-add-field-image-preview'}
|
|
|
|
|
{/if}
|
2014-12-24 11:58:10 +02:00
|
|
|
|
|
2014-10-18 09:07:45 +03:00
|
|
|
|
{* Вставка опросов *}
|
|
|
|
|
{if $type->getParam('allow_poll')}
|
2015-01-03 10:19:49 +02:00
|
|
|
|
{component 'poll' template='manage'
|
2014-10-18 09:07:45 +03:00
|
|
|
|
targetType = 'topic'
|
|
|
|
|
targetId = ( $topic ) ? $topic->getId() : ''}
|
|
|
|
|
{/if}
|
2014-07-28 19:55:18 +03:00
|
|
|
|
|
2017-07-24 10:16:59 +03:00
|
|
|
|
{if $type->isAllowCreateDeferredTopic($oUserCurrent)}
|
2017-07-24 10:10:24 +03:00
|
|
|
|
{if !$topic or !$topic->getPublishDraft() or ($topic->getDatePublish() and strtotime($topic->getDatePublish()) > time())}
|
|
|
|
|
{$iDatePublish = null}
|
|
|
|
|
{if $topic}
|
|
|
|
|
{$iDatePublish = strtotime($topic->getDatePublish())}
|
|
|
|
|
{if $iDatePublish < time()}
|
|
|
|
|
{$iDatePublish = null}
|
|
|
|
|
{/if}
|
|
|
|
|
{/if}
|
|
|
|
|
<div>
|
|
|
|
|
<div>{lang 'topic.add.fields.publish_date.label'}:</div>
|
|
|
|
|
{component 'field.date' mods = 'inline'
|
|
|
|
|
name = "topic[publish_date_raw][date]"
|
|
|
|
|
inputAttributes=[ "data-lsdate-format" => 'DD.MM.YYYY' ]
|
|
|
|
|
inputClasses = "js-field-date-default"
|
|
|
|
|
placeholder = {lang 'topic.add.fields.publish_date.label_date'}
|
|
|
|
|
value = ($iDatePublish) ? {date_format date=$iDatePublish format='d.m.Y'} : ''}
|
|
|
|
|
|
|
|
|
|
{component 'field.time' mods = 'inline'
|
|
|
|
|
name = "topic[publish_date_raw][time]"
|
|
|
|
|
inputAttributes=[ "data-lstime-time-format" => 'H:i' ]
|
|
|
|
|
inputClasses = "js-field-time-default"
|
|
|
|
|
placeholder = {lang 'topic.add.fields.publish_date.label_time'}
|
|
|
|
|
value = ($iDatePublish) ? {date_format date=$iDatePublish format='H:i'} : ''}
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
{/if}
|
2014-07-28 19:55:18 +03:00
|
|
|
|
|
2014-10-18 09:07:45 +03:00
|
|
|
|
{* Запретить комментарии *}
|
2015-01-03 10:19:49 +02:00
|
|
|
|
{component 'field' template='checkbox'
|
2014-10-18 09:07:45 +03:00
|
|
|
|
name = 'topic[topic_forbid_comment]'
|
|
|
|
|
checked = {( $topic && $topic->getForbidComment() ) ? true : false }
|
|
|
|
|
note = $aLang.topic.add.fields.forbid_comments.note
|
|
|
|
|
label = $aLang.topic.add.fields.forbid_comments.label}
|
2014-07-28 19:55:18 +03:00
|
|
|
|
|
|
|
|
|
|
2014-10-18 09:07:45 +03:00
|
|
|
|
{* Принудительный вывод топиков на главную (доступно только админам) *}
|
|
|
|
|
{if $oUserCurrent->isAdministrator()}
|
2015-01-03 10:19:49 +02:00
|
|
|
|
{component 'field' template='checkbox'
|
2014-10-18 09:07:45 +03:00
|
|
|
|
name = 'topic[topic_publish_index]'
|
|
|
|
|
checked = {($topic && $topic->getPublishIndex()) ? true : false }
|
|
|
|
|
note = $aLang.topic.add.fields.publish_index.note
|
|
|
|
|
label = $aLang.topic.add.fields.publish_index.label}
|
2014-12-28 16:59:55 +02:00
|
|
|
|
|
2015-01-03 10:19:49 +02:00
|
|
|
|
{component 'field' template='checkbox'
|
2014-12-28 16:59:55 +02:00
|
|
|
|
name = 'topic[topic_skip_index]'
|
|
|
|
|
checked = {($topic && $topic->getSkipIndex()) ? true : false }
|
|
|
|
|
note = $aLang.topic.add.fields.skip_index.note
|
|
|
|
|
label = $aLang.topic.add.fields.skip_index.label}
|
2014-10-18 09:07:45 +03:00
|
|
|
|
{/if}
|
2014-07-28 19:55:18 +03:00
|
|
|
|
|
|
|
|
|
|
2014-10-18 09:07:45 +03:00
|
|
|
|
{block 'add_topic_form_end'}{/block}
|
2017-03-21 23:12:46 +02:00
|
|
|
|
{hook run="form_add_topic_end" topic=$topic}
|
2014-07-28 19:55:18 +03:00
|
|
|
|
|
|
|
|
|
|
2014-10-18 09:07:45 +03:00
|
|
|
|
{* Скрытые поля *}
|
2015-01-12 17:50:04 +02:00
|
|
|
|
{component 'field' template='hidden' name='topic_type' value=$type->getCode()}
|
2014-07-28 19:55:18 +03:00
|
|
|
|
|
2014-10-18 09:07:45 +03:00
|
|
|
|
{if $topic}
|
2015-01-30 13:57:52 +02:00
|
|
|
|
{component 'field' template='hidden' name='topic[id]' value=$topic->getId()}
|
2014-10-18 09:07:45 +03:00
|
|
|
|
{/if}
|
2014-07-28 19:55:18 +03:00
|
|
|
|
|
|
|
|
|
|
2014-10-18 09:07:45 +03:00
|
|
|
|
{**
|
|
|
|
|
* Кнопки
|
|
|
|
|
*}
|
2014-07-28 19:55:18 +03:00
|
|
|
|
|
2014-10-18 09:07:45 +03:00
|
|
|
|
{* Опубликовать / Сохранить изменения *}
|
2015-01-03 10:19:49 +02:00
|
|
|
|
{component 'button'
|
2014-10-18 09:07:45 +03:00
|
|
|
|
id = {( $topic ) ? 'submit-edit-topic-publish' : 'submit-add-topic-publish' }
|
|
|
|
|
mods = 'primary'
|
2015-11-12 18:50:12 +02:00
|
|
|
|
classes = 'ls-fl-r'
|
2015-03-27 12:02:25 +02:00
|
|
|
|
text = $aLang.topic.add.button[ ( !$topic or ( $topic && $topic->getPublish() == 0 ) ) ? 'publish' : 'update' ]}
|
2014-07-28 19:55:18 +03:00
|
|
|
|
|
2014-10-18 09:07:45 +03:00
|
|
|
|
{* Превью *}
|
2015-01-03 10:19:49 +02:00
|
|
|
|
{component 'button' type='button' classes='js-topic-preview-text-button' text=$aLang.common.preview_text}
|
2014-07-28 19:55:18 +03:00
|
|
|
|
|
2014-10-18 09:07:45 +03:00
|
|
|
|
{* Сохранить в черновиках / Перенести в черновики *}
|
2015-03-27 12:02:25 +02:00
|
|
|
|
{if ! $topic}
|
|
|
|
|
{component 'button' type='button' classes='js-topic-draft-button' text=$aLang.topic.add.button.save_as_draft}
|
|
|
|
|
{else}
|
|
|
|
|
{component 'button' type='button' classes='js-topic-draft-button' text=$aLang.topic.add.button[ ( $topic->getPublish() != 0 ) ? 'mark_as_draft' : 'update' ]}
|
2014-10-18 09:07:45 +03:00
|
|
|
|
{/if}
|
2014-07-28 19:55:18 +03:00
|
|
|
|
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{* Блок с превью текста *}
|
2016-08-30 07:28:40 +03:00
|
|
|
|
{component 'topic' template='preview'}
|