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 2015-03-09 22:32:31 +07:00
parent b178f0dde8
commit bed6265c47
3 changed files with 26 additions and 6 deletions

View file

@ -81,13 +81,24 @@ class ModuleTopic extends Module
*
* @param string $sType
*
* @return null
* @return ModuleTopic_EntityTopicType|null
*/
public function GetTopicType($sType)
{
return isset($this->aTopicTypes[$sType]) ? $this->aTopicTypes[$sType] : null;
}
/**
* Возвращает первый доступные тип топика
*
* @return ModuleTopic_EntityTopicType|null
*/
public function GetTopicTypeFirst()
{
$oType = reset($this->aTopicTypes);
return $oType ?: null;
}
/**
* Проверяет разрешен ли данный тип топика
*

View file

@ -20,10 +20,13 @@
{* Написать в блог *}
{if $oUserCurrent && ( ( $blog->getUserIsJoin() && $oUserCurrent->getRating() >= $blog->getLimitRatingTopic() ) || $blog->isAllowEdit() )}
{$actions[] = [
'url' => "{$LS->Topic_GetTopicType('topic')->getUrlForAdd()}?blog_id={$blog->getId()}",
'text' => {lang 'blog.actions.write'}
]}
{$topicType=$LS->Topic_GetTopicTypeFirst()}
{if $topicType}
{$actions[] = [
'url' => "{$topicType->getUrlForAdd()}?blog_id={$blog->getId()}",
'text' => {lang 'blog.actions.write'}
]}
{/if}
{/if}
{* Подписаться через RSS *}

View file

@ -25,6 +25,7 @@
{if ! $smarty.local.skipBlogs}
{$blogsSelect = []}
{$blogsSelectId = []}
{$blogsSelectedId=[]}
{foreach $smarty.local.blogs as $blogType => $blogs}
{$blogsSelectOptions = []}
@ -45,6 +46,11 @@
{if $topic}
{json var=array_intersect($topic->getBlogsId(),$blogsSelectId) assign='chosenOrder'}
{$blogsSelectedId = $topic->getBlogsId()}
{else}
{if $_aRequest.blog_id}
{$blogsSelectedId[] = $_aRequest.blog_id}
{/if}
{/if}
{component 'field' template='select'
@ -53,7 +59,7 @@
placeholder = 'Выберите блоги для публикации'
inputClasses = 'js-topic-add-blogs'
isMultiple = true
selectedValue = ( ( $topic ) ? $topic->getBlogsId() : [] )
selectedValue = $blogsSelectedId
inputAttributes = [ 'data-chosen-order' => {$chosenOrder} ]
items = $blogsSelect}
{/if}