mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-16 23:00:51 +03:00
Компонент feed
This commit is contained in:
parent
8f2914b96b
commit
f103e281b1
|
@ -61,23 +61,16 @@ class ActionUserfeed extends Action {
|
|||
*
|
||||
*/
|
||||
protected function EventIndex() {
|
||||
/**
|
||||
* Получаем топики
|
||||
*/
|
||||
// Получаем топики
|
||||
$aTopics = $this->Userfeed_read($this->oUserCurrent->getId());
|
||||
/**
|
||||
* Вызов хуков
|
||||
*/
|
||||
$this->Hook_Run('topics_list_show',array('aTopics'=>$aTopics));
|
||||
$this->Viewer_Assign('aTopics', $aTopics);
|
||||
if (count($aTopics)) {
|
||||
$this->Viewer_Assign('iUserfeedLastId', end($aTopics)->getId());
|
||||
}
|
||||
if (count($aTopics) < Config::Get('module.userfeed.count_default')) {
|
||||
$this->Viewer_Assign('bDisableGetMoreButton', true);
|
||||
} else {
|
||||
$this->Viewer_Assign('bDisableGetMoreButton', false);
|
||||
}
|
||||
|
||||
// Вызов хуков
|
||||
$this->Hook_Run('topics_list_show', array('aTopics' => $aTopics));
|
||||
|
||||
$this->Viewer_Assign('feedTopics', $aTopics);
|
||||
// TODO: Добавить метод возвращающий общее кол-во топиков в ленте (нужно для нормальной работы блока подгрузки)
|
||||
$this->Viewer_Assign('feedTopicsAllCount', 0);
|
||||
|
||||
$this->SetTemplateAction('list');
|
||||
}
|
||||
/**
|
||||
|
@ -109,7 +102,7 @@ class ActionUserfeed extends Action {
|
|||
* Загружаем данные в ajax ответ
|
||||
*/
|
||||
$oViewer=$this->Viewer_GetLocalViewer();
|
||||
$oViewer->Assign('aTopics', $aTopics);
|
||||
$oViewer->Assign('aTopics', $aTopics);
|
||||
$this->Viewer_AssignAjax('html', $oViewer->Fetch('topics/topic_list.tpl'));
|
||||
$this->Viewer_AssignAjax('count_loaded', count($aTopics));
|
||||
|
||||
|
|
|
@ -45,8 +45,8 @@ class BlockUserfeedBlogs extends Block {
|
|||
/**
|
||||
* Выводим в шаблон
|
||||
*/
|
||||
$this->Viewer_Assign('aUserfeedSubscribedBlogs', $aUserSubscribes['blogs']);
|
||||
$this->Viewer_Assign('aUserfeedBlogs', $aBlogs);
|
||||
$this->Viewer_Assign('blogsSubscribed', $aUserSubscribes['blogs']);
|
||||
$this->Viewer_Assign('blogsJoined', $aBlogs);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
/*-------------------------------------------------------
|
||||
*
|
||||
* LiveStreet Engine Social Networking
|
||||
* Copyright © 2008 Mzhelskiy Maxim
|
||||
*
|
||||
*--------------------------------------------------------
|
||||
*
|
||||
* Official site: www.livestreet.ru
|
||||
* Contact e-mail: rus.engine@gmail.com
|
||||
*
|
||||
* GNU General Public License, version 2:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
---------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Блок настройки списка пользователей в ленте
|
||||
*
|
||||
* @package blocks
|
||||
* @since 1.0
|
||||
*/
|
||||
class BlockUserfeedFriends extends Block {
|
||||
/**
|
||||
* Запуск обработки
|
||||
*/
|
||||
public function Exec() {
|
||||
/**
|
||||
* Пользователь авторизован?
|
||||
*/
|
||||
if ($oUserCurrent = $this->User_getUserCurrent()) {
|
||||
/**
|
||||
* Получаем необходимые переменные и прогружаем в шаблон
|
||||
*/
|
||||
$aFriends = $this->User_getUsersFriend($oUserCurrent->getId());
|
||||
$aUserSubscribes = $this->Userfeed_getUserSubscribes($oUserCurrent->getId());
|
||||
$this->Viewer_Assign('aUserfeedSubscribedUsers', $aUserSubscribes['users']);
|
||||
$this->Viewer_Assign('aUserfeedFriends', $aFriends['collection']);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -33,10 +33,7 @@ class BlockUserfeedUsers extends Block {
|
|||
/**
|
||||
* Получаем необходимые переменные и прогружаем в шаблон
|
||||
*/
|
||||
$aFriends = $this->User_getUsersFriend($oUserCurrent->getId());
|
||||
$aUserSubscribes = $this->Userfeed_getUserSubscribes($oUserCurrent->getId());
|
||||
$this->Viewer_Assign('aUserfeedSubscribedUsers', $aUserSubscribes['users']);
|
||||
$this->Viewer_Assign('aUserfeedFriends', $aFriends['collection']);
|
||||
$this->Viewer_Assign('users', $this->Userfeed_getUserSubscribes($oUserCurrent->getId())['users']);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -534,7 +534,8 @@ $config['head']['default']['js'] = array(
|
|||
"___path.application.web___/frontend/common/js/comments.js",
|
||||
"___path.application.web___/frontend/common/js/blog.js",
|
||||
"___path.application.web___/frontend/common/js/user.js",
|
||||
"___path.application.web___/frontend/common/js/userfeed.js",
|
||||
"___path.application.web___/frontend/common/js/feed.js",
|
||||
"___path.application.web___/frontend/common/js/feed-blogs.js",
|
||||
"___path.application.web___/frontend/common/js/activity.js",
|
||||
"___path.application.web___/frontend/common/js/activity-settings.js",
|
||||
"___path.application.web___/frontend/common/js/toolbar.comments.js",
|
||||
|
|
70
application/frontend/common/js/feed-blogs.js
Normal file
70
application/frontend/common/js/feed-blogs.js
Normal file
|
@ -0,0 +1,70 @@
|
|||
/**
|
||||
* Управление блогами в ленте
|
||||
*
|
||||
* @module ls/feed/blogs
|
||||
*
|
||||
* @license GNU General Public License, version 2
|
||||
* @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com}
|
||||
* @author Denis Shakhov <denis.shakhov@gmail.com>
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
"use strict";
|
||||
|
||||
$.widget( "livestreet.lsFeedBlogs", {
|
||||
/**
|
||||
* Дефолтные опции
|
||||
*/
|
||||
options: {
|
||||
// Ссылки
|
||||
urls: {
|
||||
subscribe: null,
|
||||
unsubscribe: null
|
||||
},
|
||||
|
||||
// Селекторы
|
||||
selectors: {
|
||||
checkbox: '.js-feed-blogs-subscribe'
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Конструктор
|
||||
*
|
||||
* @constructor
|
||||
* @private
|
||||
*/
|
||||
_create: function () {
|
||||
var _this = this;
|
||||
|
||||
this.elements = {
|
||||
checkboxes: this.element.find( this.option( 'selectors.checkbox' ) )
|
||||
};
|
||||
|
||||
this.type = 'blogs';
|
||||
|
||||
this._on( this.elements.checkboxes, { change: this.toggleSubscribe } );
|
||||
},
|
||||
|
||||
/**
|
||||
* Сохранение настроек
|
||||
*/
|
||||
toggleSubscribe: function( event ) {
|
||||
var checkbox = $( event.target ),
|
||||
id = checkbox.data( 'id' );
|
||||
|
||||
ls.ajax.load(
|
||||
this.option( 'urls.' + ( checkbox.is(':checked') ? 'subscribe' : 'unsubscribe' ) ),
|
||||
{
|
||||
type: this.type,
|
||||
id: id
|
||||
},
|
||||
function( response ) {
|
||||
if ( ! response.bStateError ) {
|
||||
ls.msg.notice( response.sMsgTitle, response.sMsg );
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
56
application/frontend/common/js/feed.js
Normal file
56
application/frontend/common/js/feed.js
Normal file
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
* Лента
|
||||
*
|
||||
* @module ls/feed
|
||||
*
|
||||
* @license GNU General Public License, version 2
|
||||
* @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com}
|
||||
* @author Denis Shakhov <denis.shakhov@gmail.com>
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
"use strict";
|
||||
|
||||
$.widget( "livestreet.lsFeed", {
|
||||
/**
|
||||
* Дефолтные опции
|
||||
*/
|
||||
options: {
|
||||
// Ссылки
|
||||
urls: {
|
||||
// Подгрузка топиков
|
||||
more: null
|
||||
},
|
||||
|
||||
// Селекторы
|
||||
selectors: {
|
||||
// Список топиков
|
||||
list: '.js-feed-topic-list',
|
||||
|
||||
// Кнопка подгрузки
|
||||
more: '.js-feed-more'
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Конструктор
|
||||
*
|
||||
* @constructor
|
||||
* @private
|
||||
*/
|
||||
_create: function () {
|
||||
var _this = this;
|
||||
|
||||
this.elements = {
|
||||
list: this.element.find( this.option( 'selectors.list' ) ),
|
||||
more: this.element.find( this.option( 'selectors.more' ) )
|
||||
};
|
||||
|
||||
// Подгрузка топиков
|
||||
this.elements.more.more({
|
||||
url: this.option( 'urls.more' ),
|
||||
target: this.elements.list,
|
||||
});
|
||||
},
|
||||
});
|
||||
})(jQuery);
|
|
@ -995,6 +995,26 @@ return array(
|
|||
)
|
||||
),
|
||||
|
||||
/**
|
||||
* Лента
|
||||
*/
|
||||
'feed' => array(
|
||||
'title' => 'Лента',
|
||||
|
||||
// Блоги
|
||||
'blogs' => array(
|
||||
'title' => 'Блоги',
|
||||
'note' => 'Выберите блоги которые вы хотели бы читать',
|
||||
'empty' => 'Вы не вступили ни в один блог'
|
||||
),
|
||||
|
||||
// Пользователи
|
||||
'users' => array(
|
||||
'title' => 'Пользователи',
|
||||
'note' => 'Добавьте людей, топики которых вы хотели бы читать'
|
||||
)
|
||||
),
|
||||
|
||||
// TODO: Удалить, используется в ActionSubscribe
|
||||
'registration_mail_error' => 'Неверный формат e-mail',
|
||||
|
||||
|
@ -1447,15 +1467,6 @@ return array(
|
|||
'block_blog_navigator_button' => 'Смотреть',
|
||||
'site_history_back' => 'Вернуться назад',
|
||||
'site_go_main' => 'перейти на главную',
|
||||
/**
|
||||
* Userfeed
|
||||
*/
|
||||
'userfeed_block_blogs_title' => 'Блоги',
|
||||
'userfeed_block_users_title' => 'Люди',
|
||||
'userfeed_title' => 'Лента',
|
||||
'userfeed_settings_note_follow_blogs' => 'Выберите блоги которые вы хотели бы читать',
|
||||
'userfeed_settings_note_follow_user' => 'Добавьте людей, топики которых вы хотели бы читать',
|
||||
'userfeed_no_blogs' => 'Вы не вступили ни в один блог',
|
||||
/**
|
||||
* Админка
|
||||
*/
|
||||
|
|
|
@ -9,15 +9,5 @@
|
|||
{/block}
|
||||
|
||||
{block name='layout_content'}
|
||||
{if $aTopics}
|
||||
<div id="userfeed-topic-list">
|
||||
{include 'topics/topic_list.tpl'}
|
||||
</div>
|
||||
|
||||
{if ! $bDisableGetMoreButton}
|
||||
{include 'components/more/more.tpl' sClasses="js-more-userfeed" sAttributes="data-proxy-last_id=\"{$iUserfeedLastId}\""}
|
||||
{/if}
|
||||
{else}
|
||||
{include 'components/alert/alert.tpl' mAlerts=$aLang.common.empty sMods='empty'}
|
||||
{/if}
|
||||
{include 'components/feed/feed.tpl' topics=$feedTopics count=$feedTopicsAllCount classes='js-feed'}
|
||||
{/block}
|
|
@ -111,7 +111,7 @@ jQuery(document).ready(function($){
|
|||
|
||||
|
||||
/**
|
||||
* Activity
|
||||
* Активность
|
||||
*/
|
||||
$('.js-activity--all').lsActivity({ urls: { more: aRouter.stream + 'get_more_all' } });
|
||||
$('.js-activity--user').lsActivity({ urls: { more: aRouter.stream + 'get_more_user' } });
|
||||
|
@ -139,9 +139,30 @@ jQuery(document).ready(function($){
|
|||
|
||||
|
||||
/**
|
||||
* Userfeed
|
||||
* Лента
|
||||
*/
|
||||
ls.userfeed.init();
|
||||
$('.js-feed').lsFeed({
|
||||
urls: {
|
||||
more: aRouter.feed + 'get_more'
|
||||
},
|
||||
create: function() {
|
||||
// Блоги
|
||||
$('.js-feed-blogs').lsFeedBlogs({
|
||||
urls: {
|
||||
subscribe: aRouter.feed + 'subscribe',
|
||||
unsubscribe: aRouter.feed + 'unsubscribe'
|
||||
}
|
||||
});
|
||||
|
||||
// Добавление пользователей в свою ленту
|
||||
$('.js-feed-users').user_list_add({
|
||||
urls: {
|
||||
add: aRouter.feed + 'ajaxadduser',
|
||||
remove: aRouter.feed + 'unsubscribe'
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
|
@ -354,14 +375,6 @@ jQuery(document).ready(function($){
|
|||
}
|
||||
});
|
||||
|
||||
// Добавление пользователей в свою ленту
|
||||
$('.js-user-list-add-userfeed').user_list_add({
|
||||
urls: {
|
||||
add: aRouter['feed'] + 'ajaxadduser/',
|
||||
remove: aRouter['feed'] + 'unsubscribe/'
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Лайтбокс
|
||||
*/
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
{extends 'blocks/block.aside.base.tpl'}
|
||||
|
||||
{block 'block_title'}{$aLang.activity.settings.title}{/block}
|
||||
{block 'block_type'}activity{/block}
|
||||
{block 'block_type'}activity-settings{/block}
|
||||
|
||||
{block 'block_content'}
|
||||
{include 'components/activity/settings.tpl' typesActive=$typesActive types=$types}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
{extends 'blocks/block.aside.base.tpl'}
|
||||
|
||||
{block 'block_title'}{$aLang.activity.users.title}{/block}
|
||||
{block 'block_type'}activity{/block}
|
||||
{block 'block_type'}activity-users{/block}
|
||||
|
||||
{block 'block_content'}
|
||||
{include 'components/activity/users.tpl' users=$users}
|
||||
|
|
|
@ -6,21 +6,9 @@
|
|||
|
||||
{extends 'blocks/block.aside.base.tpl'}
|
||||
|
||||
{block 'block_title'}{$aLang.userfeed_block_blogs_title}{/block}
|
||||
{block 'block_type'}activity{/block}
|
||||
{block 'block_title'}{$aLang.feed.blogs.title}{/block}
|
||||
{block 'block_type'}feed-blogs{/block}
|
||||
|
||||
{block 'block_content'}
|
||||
<small class="note mb-15">{$aLang.userfeed_settings_note_follow_blogs}</small>
|
||||
|
||||
{if $aUserfeedBlogs}
|
||||
{foreach $aUserfeedBlogs as $oBlog}
|
||||
{include 'components/field/field.checkbox.tpl'
|
||||
sInputClasses = 'js-userfeed-subscribe'
|
||||
sInputAttributes = "data-id=\"{$oBlog->getId()}\""
|
||||
bChecked = isset($aUserfeedSubscribedBlogs[$oBlog->getId()])
|
||||
sLabel = "<a href=\"{$oBlog->getUrlFull()}\">{$oBlog->getTitle()|escape}</a>"}
|
||||
{/foreach}
|
||||
{else}
|
||||
{include 'components/alert/alert.tpl' mAlerts=$aLang.userfeed_no_blogs sMods='info'}
|
||||
{/if}
|
||||
{include 'components/feed/blogs.tpl' blogsJoined=$blogsJoined blogsSubscribed=$blogsSubscribed}
|
||||
{/block}
|
|
@ -6,13 +6,9 @@
|
|||
|
||||
{extends 'blocks/block.aside.base.tpl'}
|
||||
|
||||
{block 'block_title'}{$aLang.userfeed_block_users_title}{/block}
|
||||
{block 'block_type'}activity{/block}
|
||||
{block 'block_title'}{$aLang.feed.users.title}{/block}
|
||||
{block 'block_type'}feed-users{/block}
|
||||
|
||||
{block 'block_content'}
|
||||
{include 'components/user_list_add/user_list_add.tpl'
|
||||
sUserListAddClasses = 'js-user-list-add-userfeed'
|
||||
aUserList = $aUserfeedSubscribedUsers
|
||||
sUserListAddAttributes = 'data-param-type="users"'
|
||||
sUserListNote = $aLang.userfeed_settings_note_follow_user}
|
||||
{include 'components/feed/users.tpl' users=$users}
|
||||
{/block}
|
|
@ -8,11 +8,13 @@
|
|||
|
||||
{$component = 'activity'}
|
||||
|
||||
{$events = $smarty.local.events}
|
||||
|
||||
<div class="{$component} {mod name=$component mods=$smarty.local.mods} {$smarty.local.classes}" {$smarty.local.attributes}>
|
||||
{if $smarty.local.events}
|
||||
{if $events}
|
||||
{* Список *}
|
||||
<ul class="activity-event-list js-activity-event-list">
|
||||
{include './event-list.tpl' events=$smarty.local.events}
|
||||
{include './event-list.tpl' events=$events}
|
||||
</ul>
|
||||
|
||||
{* Кнопка подгрузки *}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
{**
|
||||
* Выбор блогов для чтения в ленте
|
||||
*
|
||||
* @param array $types
|
||||
* @param array $typesActive
|
||||
*}
|
||||
|
||||
{if $oUserCurrent}
|
||||
<div class="feed-blogs js-feed-blogs">
|
||||
{$blogsSubscribed = $smarty.local.blogsSubscribed}
|
||||
|
||||
<small class="note mb-15">
|
||||
{$aLang.feed.blogs.note}
|
||||
</small>
|
||||
|
||||
{if $smarty.local.blogsJoined}
|
||||
{foreach $smarty.local.blogsJoined as $blog}
|
||||
{include 'components/field/field.checkbox.tpl'
|
||||
sInputClasses = 'js-feed-blogs-subscribe'
|
||||
sInputAttributes = "data-id=\"{$blog->getId()}\""
|
||||
bChecked = isset($blogsSubscribed[ $blog->getId() ])
|
||||
sLabel = "<a href=\"{$blog->getUrlFull()}\">{$blog->getTitle()|escape}</a>"}
|
||||
{/foreach}
|
||||
{else}
|
||||
{include 'components/alert/alert.tpl' mAlerts=$aLang.feed.blogs.empty sMods='info'}
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
32
application/frontend/skin/developer/components/feed/feed.tpl
Normal file
32
application/frontend/skin/developer/components/feed/feed.tpl
Normal file
|
@ -0,0 +1,32 @@
|
|||
{**
|
||||
* Лента
|
||||
*
|
||||
* @param array $topics
|
||||
* @param integer $count
|
||||
*}
|
||||
|
||||
{$component = 'feed'}
|
||||
|
||||
{$topics = $smarty.local.topics}
|
||||
|
||||
<div class="{$component} {mod name=$component mods=$smarty.local.mods} {$smarty.local.classes}" {$smarty.local.attributes}>
|
||||
{if $topics}
|
||||
{* Список *}
|
||||
<ul class="{$component}-topic-list js-{$component}-topic-list">
|
||||
{include 'topics/topic_list.tpl' aTopics=$topics}
|
||||
</ul>
|
||||
|
||||
{* Кнопка подгрузки *}
|
||||
{* TODO: if $smarty.local.count > Config::Get('module.userfeed.count_default') *}
|
||||
{if count($topics) == Config::Get('module.userfeed.count_default')}
|
||||
{$last = end($topics)}
|
||||
|
||||
{include 'components/more/more.tpl'
|
||||
iCount = $smarty.local._count
|
||||
sClasses = "js-{$component}-more"
|
||||
sAttributes = "data-proxy-last_id=\"{$last->getId()}\""}
|
||||
{/if}
|
||||
{else}
|
||||
{include 'components/alert/alert.tpl' mAlerts=$aLang.common.empty sMods='empty'}
|
||||
{/if}
|
||||
</div>
|
|
@ -0,0 +1,11 @@
|
|||
{**
|
||||
* Выбор пользователей для чтения в ленте
|
||||
*
|
||||
* @param array $users
|
||||
*}
|
||||
|
||||
{include 'components/user_list_add/user_list_add.tpl'
|
||||
sUserListAddClasses = 'js-feed-users'
|
||||
aUserList = $smarty.local.users
|
||||
sUserListAddAttributes = 'data-param-type="users"'
|
||||
sUserListNote = $aLang.feed.users.note}
|
|
@ -8,7 +8,7 @@
|
|||
sMods = 'pills'
|
||||
aItems = [
|
||||
[ 'name' => 'index', 'url' => {router page='/'}, 'text' => {lang name='blog.menu.all'}, 'count' => $iCountTopicsNew ],
|
||||
[ 'name' => 'feed', 'url' => {router page='feed'}, 'text' => $aLang.userfeed_title, 'is_enabled' => !! $oUserCurrent ]
|
||||
[ 'name' => 'feed', 'url' => {router page='feed'}, 'text' => $aLang.feed.title, 'is_enabled' => !! $oUserCurrent ]
|
||||
]}
|
||||
|
||||
{include file='navs/nav.topics.sub.tpl'}
|
Loading…
Reference in a new issue