1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-16 14:50:48 +03:00

Компонент activity

This commit is contained in:
Denis Shakhov 2014-07-18 22:45:16 +07:00
parent a50a3546eb
commit 8f2914b96b
27 changed files with 528 additions and 573 deletions

View file

@ -170,20 +170,13 @@ class ActionProfile extends Action {
* Чтение активности пользователя (stream)
*/
protected function EventStream() {
if (!$this->CheckUserProfile()) {
if ( ! $this->CheckUserProfile() ) {
return parent::EventNotFound();
}
/**
* Читаем события
*/
$aEvents = $this->Stream_ReadByUserId($this->oUserProfile->getId());
$this->Viewer_Assign('bDisableGetMoreButton', $this->Stream_GetCountByUserId($this->oUserProfile->getId()) < Config::Get('module.stream.count_default'));
$this->Viewer_Assign('aStreamEvents', $aEvents);
if (count($aEvents)) {
$oEvenLast=end($aEvents);
$this->Viewer_Assign('iStreamLastId', $oEvenLast->getId());
$this->Viewer_Assign('sDateLast', $oEvenLast->getDateAdded());
}
$this->Viewer_Assign('activityEvents', $this->Stream_ReadByUserId($this->oUserProfile->getId()));
$this->Viewer_Assign('activityEventsAllCount', $this->Stream_GetCountByUserId($this->oUserProfile->getId()));
$this->SetTemplateAction('activity');
}
/**

View file

@ -28,6 +28,7 @@ class ActionStream extends Action {
* @var ModuleUser_EntityUser|null
*/
protected $oUserCurrent;
/**
* Какое меню активно
*
@ -37,230 +38,161 @@ class ActionStream extends Action {
/**
* Инициализация
*
*/
public function Init() {
/**
* Личная лента доступна только для авторизованных, для гостей показываем общую ленту
*/
$this->oUserCurrent = $this->User_getUserCurrent();
// Личная лента доступна только для авторизованных, гостям показываем общую ленту
if ($this->oUserCurrent) {
$this->SetDefaultEvent('user');
$this->SetDefaultEvent('personal');
} else {
$this->SetDefaultEvent('all');
}
$this->Viewer_Assign('aStreamEventTypes', $this->Stream_getEventTypes());
$this->Viewer_Assign('sMenuHeadItemSelect', 'stream');
/**
* Загружаем в шаблон JS текстовки
*/
$this->Lang_AddLangJs(array(
'stream_subscribes_already_subscribed','error'
));
'activity.notices.error_already_subscribed', 'error'
));
}
/**
* Регистрация евентов
*
*/
protected function RegisterEvent() {
$this->AddEvent('user', 'EventUser');
$this->AddEvent('personal', 'EventPersonal');
$this->AddEvent('all', 'EventAll');
$this->AddEvent('subscribe', 'EventSubscribe'); // TODO: возможно нужно удалить
$this->AddEvent('ajaxadduser', 'EventAjaxAddUser');
$this->AddEvent('ajaxremoveuser', 'EventAjaxRemoveUser');
$this->AddEvent('switchEventType', 'EventSwitchEventType');
$this->AddEvent('get_more_custom', 'EventGetMore');
$this->AddEvent('get_more_user', 'EventGetMoreUser');
$this->AddEvent('get_more_all', 'EventGetMoreAll');
$this->AddEvent('get_more_personal', 'EventGetMore');
$this->AddEvent('get_more_user', 'EventGetMoreUser');
}
/**
* Список событий в ленте активности пользователя
*
* Персональная активность
*/
protected function EventUser() {
/**
* Пользователь авторизован?
*/
if (!$this->oUserCurrent) {
protected function EventPersonal() {
if ( ! $this->oUserCurrent ) {
return parent::EventNotFound();
}
$this->Viewer_AddBlock('right','activitySettings');
$this->Viewer_AddBlock('right','activityUsers');
/**
* Читаем события
*/
$aEvents = $this->Stream_Read();
$this->Viewer_Assign('bDisableGetMoreButton', $this->Stream_GetCountByReaderId($this->oUserCurrent->getId()) < Config::Get('module.stream.count_default'));
$this->Viewer_Assign('aStreamEvents', $aEvents);
if (count($aEvents)) {
$oEvenLast=end($aEvents);
$this->Viewer_Assign('iStreamLastId', $oEvenLast->getId());
$this->Viewer_Assign('sDateLast', $oEvenLast->getDateAdded());
}
$this->Viewer_AddBlock('right', 'activitySettings');
$this->Viewer_AddBlock('right', 'activityUsers');
$this->Viewer_Assign('activityEvents', $this->Stream_Read());
$this->Viewer_Assign('activityEventsAllCount', $this->Stream_GetCountByReaderId( $this->oUserCurrent->getId()) );
}
/**
* Список событий в общей ленте активности сайта
*
* Общая активность
*/
protected function EventAll() {
$this->sMenuItemSelect='all';
/**
* Читаем события
*/
$aEvents = $this->Stream_ReadAll();
$this->Viewer_Assign('bDisableGetMoreButton', $this->Stream_GetCountAll() < Config::Get('module.stream.count_default'));
$this->Viewer_Assign('aStreamEvents', $aEvents);
if (count($aEvents)) {
$oEvenLast=end($aEvents);
$this->Viewer_Assign('iStreamLastId', $oEvenLast->getId());
$this->Viewer_Assign('sDateLast', $oEvenLast->getDateAdded());
}
$this->sMenuItemSelect = 'all';
$this->Viewer_Assign('activityEvents', $this->Stream_ReadAll());
$this->Viewer_Assign('activityEventsAllCount', $this->Stream_GetCountAll());
}
/**
* Активаци/деактивация типа события
*
*/
protected function EventSwitchEventType() {
/**
* Устанавливаем формат Ajax ответа
*/
$this->Viewer_SetResponseAjax('json');
/**
* Пользователь авторизован?
*/
if (!$this->oUserCurrent) {
if ( ! $this->oUserCurrent ) {
return parent::EventNotFound();
}
if (!getRequest('type')) {
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
if ( ! getRequest('type') ) {
$this->Message_AddError($this->Lang_Get('system_error'), $this->Lang_Get('error'));
}
/**
* Активируем/деактивируем тип
*/
$this->Stream_switchUserEventType($this->oUserCurrent->getId(), getRequestStr('type'));
$this->Message_AddNotice($this->Lang_Get('stream_subscribes_updated'), $this->Lang_Get('attention'));
$this->Message_AddNotice($this->Lang_Get('common.success.save'), $this->Lang_Get('attention'));
}
/**
* Погрузка событий (замена постраничности)
*
* Подгрузка событий (замена постраничности)
*/
protected function EventGetMore() {
/**
* Устанавливаем формат Ajax ответа
*/
$this->Viewer_SetResponseAjax('json');
/**
* Пользователь авторизован?
*/
if (!$this->oUserCurrent) {
if ( ! $this->oUserCurrent ) {
return parent::EventNotFound();
}
/**
* Необходимо передать последний просмотренный ID событий
*/
$iFromId = getRequestStr('last_id');
if (!$iFromId) {
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
return;
}
/**
* Получаем события
*/
$aEvents = $this->Stream_Read(null, $iFromId);
$oViewer=$this->Viewer_GetLocalViewer();
$oViewer->Assign('aStreamEvents', $aEvents);
$oViewer->Assign('sDateLast', getRequestStr('sDateLast'));
$this->Viewer_AssignAjax('count_loaded', count($aEvents));
if (count($aEvents)) {
$oEvenLast=end($aEvents);
$this->Viewer_AssignAjax('last_id', $oEvenLast->getId());
}
/**
* Возвращаем данные в ajax ответе
*/
$this->Viewer_AssignAjax('html', $oViewer->Fetch('actions/ActionStream/events.tpl'));
$this->GetMore(function($lastId) {
return $this->Stream_Read(null, $lastId);
});
}
/**
* Погрузка событий для всего сайта
*
* Подгрузка событий для всего сайта
*/
protected function EventGetMoreAll() {
/**
* Устанавливаем формат Ajax ответа
*/
$this->Viewer_SetResponseAjax('json');
/**
* Необходимо передать последний просмотренный ID событий
*/
$iFromId = getRequestStr('last_id');
if (!$iFromId) {
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
return;
}
/**
* Получаем события
*/
$aEvents = $this->Stream_ReadAll(null, $iFromId);
$oViewer=$this->Viewer_GetLocalViewer();
$oViewer->Assign('aStreamEvents', $aEvents);
$oViewer->Assign('sDateLast', getRequestStr('sDateLast'));
$this->Viewer_AssignAjax('count_loaded', count($aEvents));
if (count($aEvents)) {
$oEvenLast=end($aEvents);
$this->Viewer_AssignAjax('last_id', $oEvenLast->getId());
}
/**
* Возвращаем данные в ajax ответе
*/
$this->Viewer_AssignAjax('html', $oViewer->Fetch('actions/ActionStream/events.tpl'));
$this->GetMore(function($lastId) {
return $this->Stream_ReadAll(null, $lastId);
});
}
/**
* Подгрузка событий для пользователя
*
*/
protected function EventGetMoreUser() {
/**
* Устанавливаем формат Ajax ответа
*/
$this->Viewer_SetResponseAjax('json');
/**
* Необходимо передать последний просмотренный ID событий
*/
$iFromId = getRequestStr('last_id');
if (!$iFromId) {
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
return;
}
if (!($oUser=$this->User_GetUserById(getRequestStr('iTargetId')))) {
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
return;
}
/**
* Получаем события
*/
$aEvents = $this->Stream_ReadByUserId($oUser->getId(), null, $iFromId);
$this->GetMore(function($lastId) {
if ( ! ( $oUser = $this->User_GetUserById(getRequestStr('target_id')) ) ) {
return false;
}
$oViewer=$this->Viewer_GetLocalViewer();
$oViewer->Assign('aStreamEvents', $aEvents);
$oViewer->Assign('sDateLast', getRequestStr('sDateLast'));
$this->Viewer_AssignAjax('count_loaded', count($aEvents));
if (count($aEvents)) {
$oEvenLast=end($aEvents);
$this->Viewer_AssignAjax('last_id', $oEvenLast->getId());
}
/**
* Возвращаем данные в ajax ответе
*/
$this->Viewer_AssignAjax('html', $oViewer->Fetch('actions/ActionStream/events.tpl'));
return $this->Stream_ReadByUserId($oUser->getId(), null, $lastId);
});
}
/**
* Общий метод подгрузки событий
*
* @param callback $getEvents Метод возвращающий список событий
*/
protected function GetMore( $getEvents ) {
$this->Viewer_SetResponseAjax('json');
// Необходимо передать последний просмотренный ID событий
$iLastId = getRequestStr('last_id');
if ( ! $iLastId ) {
$this->Message_AddError($this->Lang_Get('system_error'), $this->Lang_Get('error'));
return;
}
// Получаем события
$aEvents = $getEvents( $iLastId );
if ( $aEvents === false ) {
return $this->EventErrorDebug();
}
$oViewer = $this->Viewer_GetLocalViewer();
$oViewer->Assign('events', $aEvents, true);
$oViewer->Assign('dateLast', getRequestStr('date_last'), true);
if ( count($aEvents) ) {
$this->Viewer_AssignAjax('last_id', end($aEvents)->getId(), true);
}
$this->Viewer_AssignAjax('count_loaded', count($aEvents));
$this->Viewer_AssignAjax('html', $oViewer->Fetch('components/activity/event-list.tpl'));
}
/**
* Подписка на пользователя по ID
*
@ -292,9 +224,9 @@ class ActionStream extends Action {
$this->Stream_subscribeUser($this->oUserCurrent->getId(), getRequestStr('id'));
$this->Message_AddNotice($this->Lang_Get('stream_subscribes_updated'), $this->Lang_Get('attention'));
}
/**
* Подписка на пользователя по логину
*
*/
protected function EventAjaxAddUser() {
/**
@ -302,12 +234,14 @@ class ActionStream extends Action {
*/
$this->Viewer_SetResponseAjax('json');
$aUsers=getRequest('aUserList',null,'post');
/**
* Валидация
*/
if ( ! is_array($aUsers) ) {
return $this->EventErrorDebug();
}
/**
* Если пользователь не авторизирован, возвращаем ошибку
*/
@ -360,7 +294,6 @@ class ActionStream extends Action {
}
/**
* Отписка от пользователя
*
*/
protected function EventAjaxRemoveUser() {
/**
@ -385,9 +318,9 @@ class ActionStream extends Action {
$this->Stream_unsubscribeUser($this->oUserCurrent->getId(), getRequestStr('iUserId'));
$this->Message_AddNotice($this->Lang_Get('stream_subscribes_updated'), $this->Lang_Get('attention'));
}
/**
* Выполняется при завершении работы экшена
*
*/
public function EventShutdown() {
/**

View file

@ -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 BlockActivityFriends extends Block {
/**
* Запуск обработки
*/
public function Exec() {
/**
* пользователь авторизован?
*/
if ($oUserCurrent = $this->User_getUserCurrent()) {
/**
* Получаем и прогружаем необходимые переменные в шаблон
*/
$aFriends = $this->User_getUsersFriend($oUserCurrent->getId());
$aUserSubscribes = $this->Stream_getUserSubscribes($oUserCurrent->getId());
$this->Viewer_Assign('aStreamSubscribedUsers', $aUserSubscribes);
$this->Viewer_Assign('aStreamFriends', $aFriends['collection']);
}
}
}

View file

@ -30,11 +30,8 @@ class BlockActivitySettings extends Block {
* пользователь авторизован?
*/
if ($oUserCurrent = $this->User_getUserCurrent()) {
/**
* Получаем и прогружаем необходимые переменные в шаблон
*/
$aTypesList = $this->Stream_getTypesList($oUserCurrent->getId());
$this->Viewer_Assign('aStreamTypesList', $aTypesList);
$this->Viewer_Assign('types', $this->Stream_getEventTypes());
$this->Viewer_Assign('typesActive', $this->Stream_getTypesList($oUserCurrent->getId()));
}
}
}

View file

@ -30,13 +30,7 @@ class BlockActivityUsers extends Block {
* пользователь авторизован?
*/
if ($oUserCurrent = $this->User_getUserCurrent()) {
/**
* Получаем и прогружаем необходимые переменные в шаблон
*/
$aFriends = $this->User_getUsersFriend($oUserCurrent->getId());
$aUserSubscribes = $this->Stream_getUserSubscribes($oUserCurrent->getId());
$this->Viewer_Assign('aStreamSubscribedUsers', $aUserSubscribes);
$this->Viewer_Assign('aStreamFriends', $aFriends['collection']);
$this->Viewer_Assign('users', $this->Stream_getUserSubscribes($oUserCurrent->getId()));
}
}
}

View file

@ -536,6 +536,7 @@ $config['head']['default']['js'] = array(
"___path.application.web___/frontend/common/js/user.js",
"___path.application.web___/frontend/common/js/userfeed.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",
"___path.application.web___/frontend/common/js/toolbar.topics.js",
"___path.application.web___/frontend/common/js/toolbar.scrollup.js",

View file

@ -0,0 +1,61 @@
/**
* Activity settings
*
* @module ls/activity/settings
*
* @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.lsActivitySettings", {
/**
* Дефолтные опции
*/
options: {
// Ссылки
urls: {
toggle_type: null
},
// Селекторы
selectors: {
type_checkbox: '.js-activity-settings-type-checkbox'
}
},
/**
* Конструктор
*
* @constructor
* @private
*/
_create: function () {
var _this = this;
this.elements = {
type_checkboxes: this.element.find( this.option( 'selectors.type_checkbox' ) )
};
this._on( this.elements.type_checkboxes, { change: this.toggleEventType } );
},
/**
* Сохранение настроек
*/
toggleEventType: function( event ) {
var type = $( event.target ).data( 'type' );
ls.ajax.load( this.option( 'urls.toggle_type' ), { 'type': type }, function( response ) {
if ( ! response.bStateError ) {
ls.msg.notice( response.sMsgTitle, response.sMsg );
ls.hook.run( 'ls_activity_toggle_event_type_after', [ type, response ] );
}
});
}
});
})(jQuery);

View file

@ -8,62 +8,62 @@
* @author Denis Shakhov <denis.shakhov@gmail.com>
*/
var ls = ls || {};
ls.activity = (function ($) {
(function($) {
"use strict";
/**
* Дефолтные опции
*
* @private
*/
var _defaults = {
};
$.widget( "livestreet.lsActivity", {
/**
* Дефолтные опции
*/
options: {
// Ссылки
urls: {
// Подгрузка событий
more: null
},
/**
* Инициализация
*
* @param {Object} options Опции
*/
this.init = function(options) {
var _this = this;
// Селекторы
selectors: {
// Список событий
list: '.js-activity-event-list',
this.options = $.extend({}, _defaults, options);
// Событие
event: '.js-activity-event',
// Настройки
$('.js-activity-settings-toggle').on('click', function () {
_this.toggleEvent($(this).data('type'));
});
// Кнопка подгрузки событий
more: '.js-activity-more'
}
},
// Подгрузка контента
$.each([ 'all', 'user', 'custom' ], function (iIndex, sValue) {
$('.js-more-activity-' + sValue).more({
url: aRouter['stream'] + 'get_more_' + sValue,
target: '#activity-event-list',
/**
* Конструктор
*
* @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,
beforeload: function (e, context) {
context.options.params.sDateLast=$('.js-activity-event-item').last().data('dateLast');
context.options.params.date_last = _this.getDateLast();
}
});
});
};
},
/**
*
*/
this.toggleEvent = function (sType) {
var sUrl = aRouter['stream'] + 'switchEventType/',
oParams = {'type': sType};
ls.hook.marker('switchEventTypeBefore');
ls.ajax.load(sUrl, oParams, function(oResponse) {
if ( ! oResponse.bStateError) {
ls.msg.notice(oResponse.sMsgTitle, oResponse.sMsg);
ls.hook.run('ls_stream_switch_event_type_after',[oParams, oResponse]);
}
});
};
return this;
}).call(ls.activity || {}, jQuery);
/**
* Получает дату последнего подгруженного события
*/
getDateLast: function() {
return this.elements.list.find( this.option( 'selectors.event' ) ).last().find( 'time' ).attr( 'datetime' );
}
});
})(jQuery);

View file

@ -921,6 +921,80 @@ return array(
),
),
/**
* Активность
*/
'activity' => array(
'title' => 'Активность',
// Навигация
'nav' => array(
'all' => 'Вся',
'personal' => 'Персональная'
),
// Настройки
'settings' => array(
'title' => 'Настройка событий',
'note' => 'Выберите действия которые будут отслеживаться',
'options' => array(
'add_wall' => 'Добавление записи на стену',
'add_topic' => 'Добавление топика',
'add_comment' => 'Добавление комментария',
'add_blog' => 'Добавление блога',
'vote_topic' => 'Голосование за топик',
'vote_comment_topic' => 'Голосование за комментарий к топику',
'vote_blog' => 'Голосование за блог',
'vote_user' => 'Голосование за пользователя',
'add_friend' => 'Добавление в друзья',
'join_blog' => 'Вступление в блог',
)
),
// Пользователи
'users' => array(
'title' => 'Пользователи',
'note' => 'Добавьте людей за активностью которых вы хотели бы следить',
),
'events' => array(
'add_wall_male' => 'добавил запись на стену',
'add_wall_female' => 'добавила запись на стену',
'add_topic_male' => 'добавил новый топик',
'add_topic_female' => 'добавила новый топик',
'add_comment_male' => 'прокомментировал топик',
'add_comment_female' => 'прокомментировала топик',
'add_blog_male' => 'добавил новый блог',
'add_blog_female' => 'добавила новый блог',
'vote_topic_male' => 'оценил топик',
'vote_topic_female' => 'оценила топик',
'vote_comment_topic_male' => 'оценил комментарий к топику',
'vote_comment_topic_female' => 'оценила комментарий к топику',
'vote_blog_male' => 'оценил блог',
'vote_blog_female' => 'оценила блог',
'vote_user_male' => 'оценил пользователя',
'vote_user_female' => 'оценила пользователя',
'join_blog_male' => 'вступил в блог',
'join_blog_female' => 'вступила в блог',
'add_friend_male' => 'добавил в друзья пользователя',
'add_friend_female' => 'добавила в друзья пользователя'
),
// Сообщения
'notices' => array(
'error_already_subscribed' => 'Вы уже подписаны на этого пользователя',
)
),
// TODO: Удалить, используется в ActionSubscribe
'registration_mail_error' => 'Неверный формат e-mail',
@ -1382,55 +1456,6 @@ return array(
'userfeed_settings_note_follow_blogs' => 'Выберите блоги которые вы хотели бы читать',
'userfeed_settings_note_follow_user' => 'Добавьте людей, топики которых вы хотели бы читать',
'userfeed_no_blogs' => 'Вы не вступили ни в один блог',
/**
* Stream
*/
'stream_block_config_title' => 'Настройка событий',
'stream_block_users_title' => 'Люди',
'stream_block_config_append' => 'Добавить',
'stream_block_users_friends' => 'Друзья',
'stream_subscribes_already_subscribed' => 'Вы уже подписаны на этого пользователя',
'stream_subscribes_updated' => 'Настройки ленты сохранены',
'stream_event_type_add_wall' => 'Добавление записи на стену',
'stream_event_type_add_topic' => 'Добавление топика',
'stream_event_type_add_comment' => 'Добавление комментария',
'stream_event_type_add_blog' => 'Добавление блога',
'stream_event_type_vote_topic' => 'Голосование за топик',
'stream_event_type_vote_comment_topic' => 'Голосование за комментарий к топику',
'stream_event_type_vote_blog' => 'Голосование за блог',
'stream_event_type_vote_user' => 'Голосование за пользователя',
'stream_event_type_add_friend' => 'Добавление в друзья',
'stream_event_type_join_blog' => 'Вступление в блог',
'stream_no_events' => 'Лента активности пуста',
'stream_list_user' => 'Пользователь',
'stream_list_event_add_wall' => 'добавил запись на стену',
'stream_list_event_add_topic' => 'добавил новый топик',
'stream_list_event_add_blog' => 'добавил новый блог',
'stream_list_event_add_comment' => 'прокомментировал топик',
'stream_list_event_vote_topic' => 'оценил топик',
'stream_list_event_vote_blog' => 'оценил блог',
'stream_list_event_vote_user' => 'оценил пользователя',
'stream_list_event_vote_comment' => 'оценил комментарий к топику',
'stream_list_event_join_blog' => 'вступил в блог',
'stream_list_event_add_friend' => 'добавил в друзья пользователя',
'stream_list_event_add_wall_female' => 'добавила запись на стену',
'stream_list_event_add_topic_female' => 'добавила новый топик',
'stream_list_event_add_blog_female' => 'добавила новый блог',
'stream_list_event_add_comment_female' => 'прокомментировала топик',
'stream_list_event_vote_topic_female' => 'оценила топик',
'stream_list_event_vote_blog_female' => 'оценила блог',
'stream_list_event_vote_user_female' => 'оценила пользователя',
'stream_list_event_vote_comment_female' => 'оценила комментарий к топику',
'stream_list_event_join_blog_female' => 'вступила в блог',
'stream_list_event_add_friend_female' => 'добавила в друзья пользователя',
'stream_menu' => 'Активность',
'stream_menu_all' => 'Вся',
'stream_menu_user' => 'Я слежу',
'stream_settings_note_filter' => 'Выберите действия которые будут отслеживаться',
'stream_settings_note_follow_user' => 'Добавьте людей за активностью которых вы хотели бы следить',
'stream_settings_note_follow_friend' => 'Выберите друзей за активностью которых вы хотели бы следить',
/**
* Админка
*/

View file

@ -5,9 +5,13 @@
{extends 'layouts/layout.user.tpl'}
{block 'layout_user_page_title'}
{$aLang.user_menu_profile_stream}
{$aLang.activity.title}
{/block}
{block 'layout_content' append}
{include 'actions/ActionStream/event_list.tpl' iLoadTargetId=$oUserProfile->getId() sActivityType='user'}
{include 'components/activity/activity.tpl'
events = $activityEvents
count = $activityEventsAllCount
targetId = $oUserProfile->getId()
classes = 'js-activity--user'}
{/block}

View file

@ -2,15 +2,17 @@
* Вся активность
*}
{extends file='layouts/layout.base.tpl'}
{extends 'layouts/layout.base.tpl'}
{block name='layout_options'}
{block 'layout_options'}
{$bNoSidebar = true}
{$sNav = 'activity'}
{/block}
{block name='layout_page_title'}{$aLang.stream_menu}{/block}
{block 'layout_page_title'}
{$aLang.activity.title}
{/block}
{block name='layout_content'}
{include file='actions/ActionStream/event_list.tpl' sActivityType='all'}
{block 'layout_content'}
{include 'components/activity/activity.tpl' events=$activityEvents count=$activityEventsAllCount classes='js-activity--all'}
{/block}

View file

@ -1,23 +0,0 @@
{**
* Список событий активности
*
* @param string $sActivityType Тип активности
* all Вся активность
* user Активность пользователя
* custom Персональная (настраиваемая) активность
*}
{if $aStreamEvents}
<ul class="activity-event-list" id="activity-event-list">
{include file='actions/ActionStream/events.tpl'}
</ul>
{if ! $bDisableGetMoreButton}
{include 'components/more/more.tpl'
sClasses = "js-more-activity-$sActivityType"
sAttributes = " data-proxy-last_id=\"{$iStreamLastId}\" data-param-i-target-id=\"{$iLoadTargetId}\" "
}
{/if}
{else}
{include 'components/alert/alert.tpl' mAlerts=$aLang.common.empty sMods='empty'}
{/if}

View file

@ -1,164 +0,0 @@
{**
* События (добавлен комментарий, добавлен топик и т.д.)
*}
{$sDateLast = {date_format date=$sDateLast format="Y-m-d" notz=1}}
{if count($aStreamEvents)}
{foreach $aStreamEvents as $oStreamEvent}
{$oTarget = $oStreamEvent->getTarget()}
{$oUser = $oStreamEvent->getUser()}
{$bUserIsMale = $oUser->getProfileSex() != 'woman'}
{* Дата группы событий *}
{if {date_format date=$oStreamEvent->getDateAdded() format="Y-m-d" notz=1} != $sDateLast}
{$sDateLast = {date_format date=$oStreamEvent->getDateAdded() format="Y-m-d" notz=1}}
<li class="activity-date">
{if {date_format date=$smarty.now format="Y-m-d" notz=1} == $sDateLast}
{$aLang.today}
{else}
{date_format date=$oStreamEvent->getDateAdded() format="j F Y"}
{/if}
</li>
{/if}
<li class="activity-event activity-event-type-{$oStreamEvent->getEventType()} js-activity-event-item" data-date-last="{$sDateLast|escape:'html'}">
{* Аватар *}
<a href="{$oUser->getUserWebPath()}">
<img src="{$oUser->getProfileAvatarPath(48)}" alt="{$oUser->getDisplayName()}" class="activity-event-avatar" />
</a>
{* Дата *}
<time datetime="{date_format date=$oStreamEvent->getDateAdded() format='c'}"
class="activity-event-date"
title="{date_format date=$oStreamEvent->getDateAdded()}">
{date_format date=$oStreamEvent->getDateAdded() hours_back="12" minutes_back="60" now="60" day="day H:i" format="j F Y, H:i"}
</time>
{* Логин *}
<a href="{$oUser->getUserWebPath()}"><strong>{$oUser->getDisplayName()}</strong></a>
{*
* Текст события
*}
{if $oStreamEvent->getEventType() == 'add_topic'}
{* Добавлен топик *}
{if $bUserIsMale}
{$aLang.stream_list_event_add_topic}
{else}
{$aLang.stream_list_event_add_topic_female}
{/if}
<a href="{$oTarget->getUrl()}">{$oTarget->getTitle()|escape:'html'}</a>
{elseif $oStreamEvent->getEventType() == 'add_comment'}
{* Добавлен комментарий *}
{if $bUserIsMale}
{$aLang.stream_list_event_add_comment}
{else}
{$aLang.stream_list_event_add_comment_female}
{/if}
<a href="{$oTarget->getTarget()->getUrl()}#comment{$oTarget->getId()}">{$oTarget->getTarget()->getTitle()|escape:'html'}</a>
{$sTextEvent = $oTarget->getText()}
{if trim($sTextEvent)}
<div class="activity-event-text text">{$sTextEvent}</div>
{/if}
{elseif $oStreamEvent->getEventType() == 'add_blog'}
{* Создан блог *}
{if $bUserIsMale}
{$aLang.stream_list_event_add_blog}
{else}
{$aLang.stream_list_event_add_blog_female}
{/if}
<a href="{$oTarget->getUrlFull()}">{$oTarget->getTitle()|escape:'html'}</a>
{elseif $oStreamEvent->getEventType() == 'vote_blog'}
{* Проголосовали за блог *}
{if $bUserIsMale}
{$aLang.stream_list_event_vote_blog}
{else}
{$aLang.stream_list_event_vote_blog_female}
{/if}
<a href="{$oTarget->getUrlFull()}">{$oTarget->getTitle()|escape:'html'}</a>
{elseif $oStreamEvent->getEventType() == 'vote_topic'}
{* Проголосовали за топик *}
{if $bUserIsMale}
{$aLang.stream_list_event_vote_topic}
{else}
{$aLang.stream_list_event_vote_topic_female}
{/if}
<a href="{$oTarget->getUrl()}">{$oTarget->getTitle()|escape:'html'}</a>
{elseif $oStreamEvent->getEventType() == 'vote_comment_topic'}
{* Проголосовали за комментарий *}
{if $bUserIsMale}
{$aLang.stream_list_event_vote_comment}
{else}
{$aLang.stream_list_event_vote_comment_female}
{/if}
<a href="{$oTarget->getTarget()->getUrl()}#comment{$oTarget->getId()}">{$oTarget->getTarget()->getTitle()|escape:'html'}</a>
{elseif $oStreamEvent->getEventType() == 'vote_user'}
{* Проголосовали за пользователя *}
{if $bUserIsMale}
{$aLang.stream_list_event_vote_user}
{else}
{$aLang.stream_list_event_vote_user_female}
{/if}
<a href="{$oTarget->getUserWebPath()}">{$oTarget->getDisplayName()}</a>
{elseif $oStreamEvent->getEventType() == 'join_blog'}
{* Вступили в блог *}
{if $bUserIsMale}
{$aLang.stream_list_event_join_blog}
{else}
{$aLang.stream_list_event_join_blog_female}
{/if}
<a href="{$oTarget->getUrlFull()}">{$oTarget->getTitle()|escape:'html'}</a>
{elseif $oStreamEvent->getEventType() == 'add_friend'}
{* Добавили в друзья *}
{if $bUserIsMale}
{$aLang.stream_list_event_add_friend}
{else}
{$aLang.stream_list_event_add_friend_female}
{/if}
<a href="{$oTarget->getUserWebPath()}">{$oTarget->getDisplayName()}</a>
{elseif $oStreamEvent->getEventType() == 'add_wall'}
{* Написали на стене *}
{if $bUserIsMale}
{$aLang.stream_list_event_add_wall}
{else}
{$aLang.stream_list_event_add_wall_female}
{/if}
<a href="{$oTarget->getUrlWall()}">{$oTarget->getWallUser()->getDisplayName()}</a>
{$sTextEvent = $oTarget->getText()}
{if trim($sTextEvent)}
<div class="activity-event-text text">{$sTextEvent}</div>
{/if}
{else}
{hook run="stream_list_event_`$oStreamEvent->getEventType()`" oStreamEvent=$oStreamEvent}
{/if}
</li>
{/foreach}
{/if}

View file

@ -0,0 +1,17 @@
{**
* Настраиваемая, персональная страница активности
*}
{extends 'layouts/layout.base.tpl'}
{block 'layout_options'}
{$sNav = 'activity'}
{/block}
{block 'layout_page_title'}
{$aLang.activity.title}
{/block}
{block 'layout_content'}
{include 'components/activity/activity.tpl' events=$activityEvents count=$activityEventsAllCount classes='js-activity--personal'}
{/block}

View file

@ -1,15 +0,0 @@
{**
* Настраиваемая, персональная страница активности
*}
{extends file='layouts/layout.base.tpl'}
{block name='layout_options'}
{$sNav = 'activity'}
{/block}
{block name='layout_page_title'}{$aLang.stream_menu}{/block}
{block name='layout_content'}
{include file='actions/ActionStream/event_list.tpl' sActivityType='custom'}
{/block}

View file

@ -4,7 +4,7 @@
* @version 2.0.dev
* @template actions/ActionStream/*.tpl
* @scripts <frontend>/common/js/stream.js
*
*
* @license GNU General Public License, version 2
* @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com}
* @author Denis Shakhov <denis.shakhov@gmail.com>
@ -15,7 +15,7 @@
* Список событий
*/
.activity-event-list { margin: 0 0 20px; }
.activity-date { font-size: 15px; font-weight: bold; margin-top: 35px; padding-bottom: 5px; border-bottom: 1px solid #eee; }
.activity-date { font-family: 'Open Sans', sans-serif; font-size: 20px; margin-top: 45px; padding-bottom: 10px; border-bottom: 1px solid #eee; }
/**

View file

@ -113,7 +113,29 @@ jQuery(document).ready(function($){
/**
* Activity
*/
ls.activity.init();
$('.js-activity--all').lsActivity({ urls: { more: aRouter.stream + 'get_more_all' } });
$('.js-activity--user').lsActivity({ urls: { more: aRouter.stream + 'get_more_user' } });
$('.js-activity--personal').lsActivity({
urls: {
more: aRouter.stream + 'get_more_personal'
},
create: function() {
// Настройки активности
$('.js-activity-settings').lsActivitySettings({
urls: {
toggle_type: aRouter.stream + 'switchEventType'
}
});
// Добавление пользователей в персональную активность
$('.js-activity-users').user_list_add({
urls: {
add: aRouter.stream + 'ajaxadduser',
remove: aRouter.stream + 'ajaxremoveuser'
}
});
}
});
/**
@ -332,14 +354,6 @@ jQuery(document).ready(function($){
}
});
// Добавление пользователей в свою активность
$('.js-user-list-add-activity').user_list_add({
urls: {
add: aRouter['stream'] + 'ajaxadduser/',
remove: aRouter['stream'] + 'ajaxremoveuser/'
}
});
// Добавление пользователей в свою ленту
$('.js-user-list-add-userfeed').user_list_add({
urls: {

View file

@ -6,23 +6,9 @@
{extends 'blocks/block.aside.base.tpl'}
{block 'block_title'}{$aLang.stream_block_config_title}{/block}
{block 'block_title'}{$aLang.activity.settings.title}{/block}
{block 'block_type'}activity{/block}
{block 'block_content'}
{if $oUserCurrent}
<small class="note mb-15">{$aLang.stream_settings_note_filter}</small>
{foreach $aStreamEventTypes as $sType => $aEventType}
{if ! (Config::Get('module.stream.disable_vote_events') && substr($sType, 0, 4) == 'vote')}
{$sLangKey = "stream_event_type_`$sType`"}
{include 'components/field/field.checkbox.tpl'
sInputClasses = 'js-activity-settings-toggle'
sInputAttributes = "data-type=\"{$sType}\""
bChecked = in_array($sType, $aStreamTypesList)
sLabel = $aLang.$sLangKey}
{/if}
{/foreach}
{/if}
{include 'components/activity/settings.tpl' typesActive=$typesActive types=$types}
{/block}

View file

@ -6,12 +6,9 @@
{extends 'blocks/block.aside.base.tpl'}
{block 'block_title'}{$aLang.stream_block_users_title}{/block}
{block 'block_title'}{$aLang.activity.users.title}{/block}
{block 'block_type'}activity{/block}
{block 'block_content'}
{include 'components/user_list_add/user_list_add.tpl'
sUserListAddClasses = 'js-user-list-add-activity'
aUserList = $aStreamSubscribedUsers
sUserListNote = $aLang.stream_settings_note_follow_user}
{include 'components/activity/users.tpl' users=$users}
{/block}

View file

@ -6,7 +6,7 @@
{extends file='blocks/block.aside.base.tpl'}
{block name='block_title'}<a href="{router page='stream'}">{$aLang.stream_menu}</a>{/block}
{block name='block_title'}<a href="{router page='stream'}">{$aLang.activity.title}</a>{/block}
{block name='block_type'}stream{/block}
{block name='block_class'}block-nopadding{/block}

View file

@ -0,0 +1,30 @@
{**
* Список событий активности
*
* @param array $events
* @param integer $targetId
* @param integer $count
*}
{$component = 'activity'}
<div class="{$component} {mod name=$component mods=$smarty.local.mods} {$smarty.local.classes}" {$smarty.local.attributes}>
{if $smarty.local.events}
{* Список *}
<ul class="activity-event-list js-activity-event-list">
{include './event-list.tpl' events=$smarty.local.events}
</ul>
{* Кнопка подгрузки *}
{if $smarty.local.count > Config::Get('module.stream.count_default')}
{$last = end($events)}
{include 'components/more/more.tpl'
iCount = $smarty.local.count
sClasses = "js-activity-more"
sAttributes = "data-proxy-last_id=\"{$last->getId()}\" data-param-target_id=\"{$smarty.local.targetId}\""}
{/if}
{else}
{include 'components/alert/alert.tpl' mAlerts=$aLang.common.empty sMods='empty'}
{/if}
</div>

View file

@ -0,0 +1,30 @@
{**
* События
*
* @param array $events
* @param string $dateLast Дата предыдущего сообщения
*}
{* Дата последнего события *}
{$dateLast = ( $smarty.local.dateLast ) ? {date_format date=$smarty.local.dateLast format="Y-m-d" notz=1} : false}
{$dateNow = {date_format date=$smarty.now format="Y-m-d" notz=1}}
{foreach $smarty.local.events as $event}
{$dateAdded = {date_format date=$event->getDateAdded() format="Y-m-d" notz=1}}
{* Дата группы событий *}
{if $dateAdded != $dateLast}
{$dateLast = $dateAdded}
<li class="activity-date">
{if $dateNow == $dateLast}
{$aLang.today}
{else}
{date_format date=$event->getDateAdded() format="j F Y"}
{/if}
</li>
{/if}
{* Событие *}
{include './event.tpl' event=$event}
{/foreach}

View file

@ -0,0 +1,81 @@
{**
* Событие
*
* @param object $event
*}
{$component = 'activity-event'}
{$event = $smarty.local.event}
{$type = $event->getEventType()}
{$target = $event->getTarget()}
{$user = $event->getUser()}
{$gender = ( $user->getProfileSex() == 'woman' ) ? 'female' : 'male'}
<li class="{$component} {$component}--{$type} js-{$component}">
{* Аватар *}
<a href="{$user->getUserWebPath()}">
<img src="{$user->getProfileAvatarPath(48)}" alt="{$user->getDisplayName()}" class="activity-event-avatar" />
</a>
{* Дата *}
<time datetime="{date_format date=$event->getDateAdded() format='c' notz=1}"
class="{$component}-date"
title="{date_format date=$event->getDateAdded()}">
{date_format date=$event->getDateAdded() hours_back="12" minutes_back="60" now="60" day="day H:i" format="j F Y, H:i"}
</time>
{* Логин *}
<a href="{$user->getUserWebPath()}" class="{$component}-username">
{$user->getDisplayName()}
</a>
{* Текст события *}
{$aLang.activity.events["{$type}_{$gender}"]}
{if $type == 'add_topic'}
{* Добавлен топик *}
<a href="{$target->getUrl()}">{$target->getTitle()|escape}</a>
{elseif $type == 'add_comment'}
{* Добавлен комментарий *}
<a href="{$target->getTarget()->getUrl()}#comment{$target->getId()}">{$target->getTarget()->getTitle()|escape}</a>
{$sTextEvent = $target->getText()}
{if trim($sTextEvent)}
<div class="{$component}-text text">{$sTextEvent}</div>
{/if}
{elseif $type == 'add_blog'}
{* Создан блог *}
<a href="{$target->getUrlFull()}">{$target->getTitle()|escape}</a>
{elseif $type == 'vote_blog'}
{* Проголосовали за блог *}
<a href="{$target->getUrlFull()}">{$target->getTitle()|escape}</a>
{elseif $type == 'vote_topic'}
{* Проголосовали за топик *}
<a href="{$target->getUrl()}">{$target->getTitle()|escape}</a>
{elseif $type == 'vote_comment_topic'}
{* Проголосовали за комментарий *}
<a href="{$target->getTarget()->getUrl()}#comment{$target->getId()}">{$target->getTarget()->getTitle()|escape}</a>
{elseif $type == 'vote_user'}
{* Проголосовали за пользователя *}
<a href="{$target->getUserWebPath()}">{$target->getDisplayName()}</a>
{elseif $type == 'join_blog'}
{* Вступили в блог *}
<a href="{$target->getUrlFull()}">{$target->getTitle()|escape}</a>
{elseif $type == 'add_friend'}
{* Добавили в друзья *}
<a href="{$target->getUserWebPath()}">{$target->getDisplayName()}</a>
{elseif $type == 'add_wall'}
{* Написали на стене *}
<a href="{$target->getUrlWall()}">{$target->getWallUser()->getDisplayName()}</a>
{$sTextEvent = $target->getText()}
{if trim($sTextEvent)}
<div class="{$component}-text text">{$sTextEvent}</div>
{/if}
{else}
{hook run="activity_event_`$type`" event=$event}
{/if}
</li>

View file

@ -0,0 +1,24 @@
{**
* Список пользователей на которых подписан текущий пользователь
*
* @param array $types
* @param array $typesActive
*}
{if $oUserCurrent}
<div class="activity-settings js-activity-settings">
<small class="note mb-15">
{$aLang.activity.settings.note}
</small>
{foreach $smarty.local.types as $type => $data}
{if ! (Config::Get('module.stream.disable_vote_events') && substr($type, 0, 4) == 'vote')}
{include 'components/field/field.checkbox.tpl'
sInputClasses = 'js-activity-settings-type-checkbox'
sInputAttributes = "data-type=\"{$type}\""
bChecked = in_array( $type, $smarty.local.typesActive )
sLabel = $aLang.activity.settings.options[ $type ]}
{/if}
{/foreach}
</div>
{/if}

View file

@ -0,0 +1,10 @@
{**
* Список пользователей на которых подписан текущий пользователь
*
* @param array $users
*}
{include 'components/user_list_add/user_list_add.tpl'
sUserListAddClasses = 'js-activity-users'
aUserList = $smarty.local.users
sUserListNote = $aLang.activity.users.note}

View file

@ -7,6 +7,6 @@
sActiveItem = $sMenuItemSelect
sMods = 'pills'
aItems = [
[ 'name' => 'user', 'url' => "{router page='stream'}user/", 'text' => $aLang.stream_menu_user, 'is_enabled' => !! $oUserCurrent ],
[ 'name' => 'all', 'url' => "{router page='stream'}all/", 'text' => $aLang.stream_menu_all ]
[ 'name' => 'user', 'url' => "{router page='stream'}personal/", 'text' => $aLang.activity.nav.personal, 'is_enabled' => !! $oUserCurrent ],
[ 'name' => 'all', 'url' => "{router page='stream'}all/", 'text' => $aLang.activity.nav.all ]
]}

View file

@ -1,6 +1,6 @@
{include 'components/nav/nav.tpl' sName='main' sActiveItem=$sMenuHeadItemSelect sMods='main' aItems=[
[ 'text' => $aLang.topic_title, 'url' => {router page='/'}, 'name' => 'blog' ],
[ 'text' => $aLang.blog.blogs, 'url' => {router page='blogs'}, 'name' => 'blogs' ],
[ 'text' => $aLang.people, 'url' => {router page='people'}, 'name' => 'people' ],
[ 'text' => $aLang.stream_menu, 'url' => {router page='stream'}, 'name' => 'stream' ]
[ 'text' => $aLang.topic_title, 'url' => {router page='/'}, 'name' => 'blog' ],
[ 'text' => $aLang.blog.blogs, 'url' => {router page='blogs'}, 'name' => 'blogs' ],
[ 'text' => $aLang.people, 'url' => {router page='people'}, 'name' => 'people' ],
[ 'text' => $aLang.activity.title, 'url' => {router page='stream'}, 'name' => 'stream' ]
]}