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

Доработка блогов

This commit is contained in:
Mzhelskiy Maxim 2014-11-20 18:07:09 +07:00
parent 82031a553a
commit 4f807bedf2
17 changed files with 366 additions and 240 deletions

View file

@ -114,7 +114,8 @@ class ActionBlog extends Action
'ajaxresponsecomment',
'ajaxrebloginvite',
'ajaxbloginfo',
'ajaxblogjoin'
'ajaxblogjoin',
'ajax',
);
/**
@ -177,6 +178,11 @@ class ActionBlog extends Action
$this->AddEvent('ajaxremovebloginvite', 'AjaxRemoveBlogInvite');
$this->AddEvent('ajaxbloginfo', 'AjaxBlogInfo');
$this->AddEvent('ajaxblogjoin', 'AjaxBlogJoin');
$this->AddEventPreg('/^ajax$/i', '/^upload-avatar$/i', '/^$/i', 'EventAjaxUploadAvatar');
$this->AddEventPreg('/^ajax$/i', '/^crop-avatar$/i', '/^$/i', 'EventAjaxCropAvatar');
$this->AddEventPreg('/^ajax$/i', '/^crop-cancel-avatar$/i', '/^$/i', 'EventAjaxCropCancelAvatar');
$this->AddEventPreg('/^ajax$/i', '/^remove-avatar$/i', '/^$/i', 'EventAjaxRemoveAvatar');
$this->AddEventPreg('/^ajax$/i', '/^modal-crop-avatar$/i', '/^$/i', 'EventAjaxModalCropAvatar');
$this->AddEventPreg('/^(\d+)\.html$/i', '/^$/i', array('EventShowTopic', 'topic'));
$this->AddEventPreg('/^[\w\-\_]+$/i', '/^(\d+)\.html$/i', array('EventShowTopic', 'topic'));
@ -260,16 +266,6 @@ class ActionBlog extends Action
$oBlog->setLimitRatingTopic(getRequestStr('blog_limit_rating_topic'));
$oBlog->setUrl(getRequestStr('blog_url'));
$oBlog->setAvatar(null);
/**
* Загрузка аватара, делаем ресайзы
*/
if (isset($_FILES['avatar']) and is_uploaded_file($_FILES['avatar']['tmp_name'])) {
if (true !== $sResult = $this->Blog_UploadBlogAvatar($_FILES['avatar'], $oBlog)) {
$this->Message_AddError(is_bool($sResult) ? $this->Lang_Get('blog.add.fields.avatar.error') : $sResult,
$this->Lang_Get('error'));
return false;
}
}
/**
* Создаём блог
*/
@ -384,23 +380,6 @@ class ActionBlog extends Action
if ($this->oUserCurrent->isAdministrator()) {
$oBlog->setUrl(getRequestStr('blog_url')); // разрешаем смену URL блога только админу
}
/**
* Загрузка аватара, делаем ресайзы
*/
if (isset($_FILES['avatar']) and is_uploaded_file($_FILES['avatar']['tmp_name'])) {
if (true !== $sResult = $this->Blog_UploadBlogAvatar($_FILES['avatar'], $oBlog)) {
$this->Message_AddError(is_bool($sResult) ? $this->Lang_Get('blog.add.fields.avatar.error') : $sResult,
$this->Lang_Get('error'));
return false;
}
}
/**
* Удалить аватар
*/
if (isset($_REQUEST['avatar_delete'])) {
$this->Blog_DeleteBlogAvatar($oBlog);
$oBlog->setAvatar(null);
}
/**
* Обновляем блог
*/
@ -483,10 +462,10 @@ class ActionBlog extends Action
* Увеличиваем число читателей блога
*/
if (in_array($sRank, array(
'administrator',
'moderator',
'reader'
)) and $oBlogUser->getUserRole() == ModuleBlog::BLOG_USER_ROLE_BAN
'administrator',
'moderator',
'reader'
)) and $oBlogUser->getUserRole() == ModuleBlog::BLOG_USER_ROLE_BAN
) {
$oBlog->setCountUser($oBlog->getCountUser() + 1);
}
@ -1283,12 +1262,12 @@ class ActionBlog extends Action
* Отправка уведомления автору топика
*/
$this->Subscribe_Send('topic_new_comment', $oTopic->getId(),
Config::Get('module.notify.prefix') . '.comment_new.tpl', $this->Lang_Get('emails.comment_new.subject'),
array(
'oTopic' => $oTopic,
'oComment' => $oCommentNew,
'oUserComment' => $this->oUserCurrent,
), $aExcludeMail);
Config::Get('module.notify.prefix') . '.comment_new.tpl', $this->Lang_Get('emails.comment_new.subject'),
array(
'oTopic' => $oTopic,
'oComment' => $oCommentNew,
'oUserComment' => $this->oUserCurrent,
), $aExcludeMail);
/**
* Добавляем событие в ленту
*/
@ -1598,7 +1577,7 @@ class ActionBlog extends Action
if ($oBlogUser->getUserRole() == ModuleBlog::BLOG_USER_ROLE_INVITE) {
$this->SendBlogInvite($oBlog, $oUser);
$this->Message_AddNoticeSingle($this->Lang_Get('blog.invite.notices.add',
array('login' => $oUser->getLogin())), $this->Lang_Get('attention'));
array('login' => $oUser->getLogin())), $this->Lang_Get('attention'));
} else {
return $this->EventErrorDebug();
}
@ -1651,7 +1630,7 @@ class ActionBlog extends Action
*/
$this->Blog_DeleteRelationBlogUser($oBlogUser);
$this->Message_AddNoticeSingle($this->Lang_Get('blog.invite.notices.remove',
array('login' => $oUser->getLogin())), $this->Lang_Get('attention'));
array('login' => $oUser->getLogin())), $this->Lang_Get('attention'));
} else {
return $this->EventErrorDebug();
}
@ -2021,6 +2000,172 @@ class ActionBlog extends Action
}
}
/**
* Загрузка аватара в блог
*/
protected function EventAjaxUploadAvatar()
{
/**
* Устанавливаем формат Ajax ответа
*/
$this->Viewer_SetResponseAjax('jsonIframe', false);
if (!isset($_FILES['photo']['tmp_name'])) {
return $this->EventErrorDebug();
}
if (!$oBlog = $this->Blog_GetBlogById(getRequestStr('target_id'))) {
return $this->EventErrorDebug();
}
if (!$oBlog->isAllowEdit()) {
return $this->EventErrorDebug();
}
/**
* Копируем загруженный файл
*/
$sFileTmp = Config::Get('sys.cache.dir') . func_generator();
if (!move_uploaded_file($_FILES['photo']['tmp_name'], $sFileTmp)) {
return false;
}
/**
* Если объект изображения не создан, возвращаем ошибку
*/
if (!$oImage = $this->Image_Open($sFileTmp)) {
$this->Fs_RemoveFileLocal($sFileTmp);
$this->Message_AddError($this->Image_GetLastError());
return;
}
/**
* Ресайзим и сохраняем именьшенную копию
* Храним две копии - мелкую для показа пользователю и крупную в качестве исходной для ресайза
*/
$sDir = Config::Get('path.uploads.images') . "/tmp/blog/{$oBlog->getId()}";
if ($sFileOriginal = $oImage->resize(1000, null)->saveSmart($sDir, 'original')) {
if ($sFilePreview = $oImage->resize(350, null)->saveSmart($sDir, 'preview')) {
list($iOriginalWidth, $iOriginalHeight) = @getimagesize($this->Fs_GetPathServer($sFileOriginal));
list($iWidth, $iHeight) = @getimagesize($this->Fs_GetPathServer($sFilePreview));
/**
* Сохраняем в сессии временный файл с изображением
*/
$this->Session_Set('sBlogAvatarFileTmp', $sFileOriginal);
$this->Session_Set('sBlogAvatarFilePreviewTmp', $sFilePreview);
$this->Viewer_AssignAjax('path', $this->Fs_GetPathWeb($sFilePreview));
$this->Viewer_AssignAjax('original_width', $iOriginalWidth);
$this->Viewer_AssignAjax('original_height', $iOriginalHeight);
$this->Viewer_AssignAjax('width', $iWidth);
$this->Viewer_AssignAjax('height', $iHeight);
$this->Fs_RemoveFileLocal($sFileTmp);
return;
}
}
$this->Message_AddError($this->Image_GetLastError());
$this->Fs_RemoveFileLocal($sFileTmp);
}
/**
* Обрезка аватара блога
*/
protected function EventAjaxCropAvatar()
{
/**
* Устанавливаем формат Ajax ответа
*/
$this->Viewer_SetResponseAjax('json');
if (!$oBlog = $this->Blog_GetBlogById(getRequestStr('target_id'))) {
return $this->EventErrorDebug();
}
if (!$oBlog->isAllowEdit()) {
return $this->EventErrorDebug();
}
$sFile = $this->Session_Get('sBlogAvatarFileTmp');
$sFilePreview = $this->Session_Get('sBlogAvatarFilePreviewTmp');
if (!$this->Image_IsExistsFile($sFile)) {
$this->Message_AddErrorSingle($this->Lang_Get('system_error'));
return;
}
if (true === ($res = $this->Blog_CreateAvatar($sFile, $oBlog, getRequest('size'),
getRequestStr('canvas_width')))
) {
$this->Image_RemoveFile($sFile);
$this->Image_RemoveFile($sFilePreview);
$this->Session_Drop('sBlogAvatarFileTmp');
$this->Session_Drop('sBlogAvatarFilePreviewTmp');
$this->Viewer_AssignAjax('upload_text', $this->Lang_Get('user.photo.actions.change_photo'));
$this->Viewer_AssignAjax('photo', $oBlog->getAvatarPath());
} else {
$this->Message_AddError(is_string($res) ? $res : $this->Lang_Get('error'));
}
}
/**
* Удаляет временные файлы кропа аватара
*/
protected function EventAjaxCropCancelAvatar()
{
/**
* Устанавливаем формат Ajax ответа
*/
$this->Viewer_SetResponseAjax('json');
if (!$oBlog = $this->Blog_GetBlogById(getRequestStr('target_id'))) {
return $this->EventErrorDebug();
}
if (!$oBlog->isAllowEdit()) {
return $this->EventErrorDebug();
}
$sFile = $this->Session_Get('sBlogAvatarFileTmp');
$sFilePreview = $this->Session_Get('sBlogAvatarFilePreviewTmp');
$this->Image_RemoveFile($sFile);
$this->Image_RemoveFile($sFilePreview);
$this->Session_Drop('sBlogAvatarFileTmp');
$this->Session_Drop('sBlogAvatarFilePreviewTmp');
}
/**
* Удаление аватара блога
*/
protected function EventAjaxRemoveAvatar()
{
$this->Viewer_SetResponseAjax('json');
if (!$oBlog = $this->Blog_GetBlogById(getRequestStr('target_id'))) {
return $this->EventErrorDebug();
}
if (!$oBlog->isAllowEdit()) {
return $this->EventErrorDebug();
}
$this->Blog_DeleteBlogAvatar($oBlog);
$this->Blog_UpdateBlog($oBlog);
$this->Viewer_AssignAjax('upload_text', $this->Lang_Get('user.photo.actions.upload_photo'));
$this->Viewer_AssignAjax('photo', $oBlog->getAvatarPath());
$this->Viewer_AssignAjax('avatars', $oBlog->GetProfileAvatarsPath());
}
/**
* Показывает модальное окно с кропом аватара
*/
protected function EventAjaxModalCropAvatar()
{
$this->Viewer_SetResponseAjax('json');
$oViewer = $this->Viewer_GetLocalViewer();
$oViewer->Assign('image', getRequestStr('image_src'), true);
$oViewer->Assign('originalWidth', (int)getRequest('original_width'), true);
$oViewer->Assign('originalHeight', (int)getRequest('original_height'), true);
$oViewer->Assign('width', (int)getRequest('width'), true);
$oViewer->Assign('height', (int)getRequest('height'), true);
$this->Viewer_AssignAjax('sText', $oViewer->Fetch("components/blog/modals/modal.crop-avatar.tpl"));
}
/**
* Выполняется при завершении работы экшена
*

View file

@ -27,6 +27,13 @@
*/
class ActionBlogs extends Action
{
/**
* Текущий пользователь
*
* @var ModuleUser_EntityUser|null
*/
protected $oUserCurrent = null;
/**
* Инициализация
*/
@ -39,6 +46,10 @@ class ActionBlogs extends Action
'blog.join.join',
'blog.join.leave'
));
/**
* Получаем текущего пользователя
*/
$this->oUserCurrent = $this->User_GetUserCurrent();
/**
* Устанавливаем title страницы
*/
@ -77,11 +88,11 @@ class ActionBlogs extends Action
);
$sOrderWay = in_array(getRequestStr('order'), array('desc', 'asc')) ? getRequestStr('order') : 'desc';
$sOrderField = in_array(getRequestStr('sort_by'), array(
'blog_id',
'blog_title',
'blog_count_user',
'blog_count_topic'
)) ? getRequestStr('sort_by') : 'blog_count_user';
'blog_id',
'blog_title',
'blog_count_user',
'blog_count_topic'
)) ? getRequestStr('sort_by') : 'blog_count_user';
if (is_numeric(getRequestStr('pageNext')) and getRequestStr('pageNext') > 0) {
$iPage = getRequestStr('pageNext');
} else {
@ -115,6 +126,16 @@ class ActionBlogs extends Action
if (in_array(getRequestStr('type'), array('open', 'close'))) {
$aFilter['type'] = getRequestStr('type');
}
/**
* Принадлежность
*/
if ($this->oUserCurrent) {
if (getRequestStr('relation') == 'my') {
$aFilter['user_owner_id'] = $this->oUserCurrent->getId();
} elseif (getRequestStr('relation') == 'join') {
$aFilter['roles']=array(ModuleBlog::BLOG_USER_ROLE_USER,ModuleBlog::BLOG_USER_ROLE_ADMINISTRATOR,ModuleBlog::BLOG_USER_ROLE_MODERATOR);
}
}
/**
* Ищем блоги
*/

View file

@ -1,42 +0,0 @@
<?php
/*
* LiveStreet CMS
* Copyright © 2013 OOO "ЛС-СОФТ"
*
* ------------------------------------------------------
*
* Official site: www.livestreetcms.com
* Contact e-mail: office@livestreetcms.com
*
* GNU General Public License, version 2:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* ------------------------------------------------------
*
* @link http://www.livestreetcms.com
* @copyright 2013 OOO "ЛС-СОФТ"
* @author Maxim Mzhelskiy <rus.engine@gmail.com>
*
*/
/**
* Обрабатывает блок с навигацией по блогам
*
* @package application.blocks
* @since 2.0
*/
class BlockBlogNav extends Block
{
/**
* Запуск обработки
*/
public function Exec()
{
if (!Config::Get('module.blog.category_allow')) {
return;
}
$aCategories = $this->Blog_GetCategoriesTree();
$this->Viewer_Assign("aNavigatorBlogCategories", $aCategories);
$this->SetTemplate('components/blog/blocks/block.blog-nav.tpl');
}
}

View file

@ -76,7 +76,7 @@ class ModuleBlog extends Module
protected $aBehaviors = array(
// Категории
'category' => array(
'class' => 'ModuleCategory_BehaviorModule',
'class' => 'ModuleCategory_BehaviorModule',
'target_type' => 'blog',
),
);
@ -424,9 +424,9 @@ class ModuleBlog extends Module
{
if ($this->oMapperBlog->AddRelationBlogUser($oBlogUser)) {
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array(
"blog_relation_change_{$oBlogUser->getUserId()}",
"blog_relation_change_blog_{$oBlogUser->getBlogId()}"
));
"blog_relation_change_{$oBlogUser->getUserId()}",
"blog_relation_change_blog_{$oBlogUser->getBlogId()}"
));
$this->Cache_Delete("blog_relation_user_{$oBlogUser->getBlogId()}_{$oBlogUser->getUserId()}");
return true;
}
@ -443,9 +443,9 @@ class ModuleBlog extends Module
{
if ($this->oMapperBlog->DeleteRelationBlogUser($oBlogUser)) {
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array(
"blog_relation_change_{$oBlogUser->getUserId()}",
"blog_relation_change_blog_{$oBlogUser->getBlogId()}"
));
"blog_relation_change_{$oBlogUser->getUserId()}",
"blog_relation_change_blog_{$oBlogUser->getBlogId()}"
));
$this->Cache_Delete("blog_relation_user_{$oBlogUser->getBlogId()}_{$oBlogUser->getUserId()}");
return true;
}
@ -725,9 +725,9 @@ class ModuleBlog extends Module
public function UpdateRelationBlogUser(ModuleBlog_EntityBlogUser $oBlogUser)
{
$this->Cache_Clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array(
"blog_relation_change_{$oBlogUser->getUserId()}",
"blog_relation_change_blog_{$oBlogUser->getBlogId()}"
));
"blog_relation_change_{$oBlogUser->getUserId()}",
"blog_relation_change_blog_{$oBlogUser->getBlogId()}"
));
$this->Cache_Delete("blog_relation_user_{$oBlogUser->getBlogId()}_{$oBlogUser->getUserId()}");
return $this->oMapperBlog->UpdateRelationBlogUser($oBlogUser);
}
@ -768,7 +768,8 @@ class ModuleBlog extends Module
*/
public function GetBlogsRating($iCurrPage, $iPerPage)
{
return $this->GetBlogsByFilter(array('exclude_type' => 'personal'), array('blog_count_user' => 'desc'), $iCurrPage,
return $this->GetBlogsByFilter(array('exclude_type' => 'personal'), array('blog_count_user' => 'desc'),
$iCurrPage,
$iPerPage);
}
@ -970,53 +971,70 @@ class ModuleBlog extends Module
}
/**
* Загружает аватар в блог
* Создает аватар пользователя на основе области из изображения
*
* @param $sFileFrom
* @param $oBlog
* @param $aSize
* @param null $iCanvasWidth
*
* @param array $aFile Массив $_FILES при загрузке аватара
* @param ModuleBlog_EntityBlog $oBlog Блог
* @return bool
*/
public function UploadBlogAvatar($aFile, $oBlog)
public function CreateAvatar($sFileFrom, $oBlog, $aSize = null, $iCanvasWidth = null)
{
if (!is_array($aFile) || !isset($aFile['tmp_name'])) {
return false;
}
$sFileTmp = Config::Get('sys.cache.dir') . func_generator();
if (!move_uploaded_file($aFile['tmp_name'], $sFileTmp)) {
return false;
}
$aParams = $this->Image_BuildParams('blog_avatar');
/**
* Если объект изображения не создан, возвращаем ошибку
*/
if (!$oImage = $this->Image_Open($sFileTmp, $aParams)) {
$this->Fs_RemoveFileLocal($sFileTmp);
if (!$oImage = $this->Image_OpenFrom($sFileFrom, $aParams)) {
return $this->Image_GetLastError();
}
$sPath = $this->Image_GetIdDir($oBlog->getOwnerId(), 'users');
/**
* Если нет области, то берем центральный квадрат
*/
if (!$aSize) {
$oImage->cropSquare();
} else {
/**
* Вырезаем область из исходного файла
*/
$oImage->cropFromSelected($aSize, $iCanvasWidth);
}
if ($sError = $this->Image_GetLastError()) {
return $sError;
}
/**
* Сохраняем во временный файл для дальнейшего ресайза
*/
if (false === ($sFileTmp = $oImage->saveTmp())) {
return $this->Image_GetLastError();
}
$sPath = $this->Image_GetIdDir($oBlog->getId(), 'blogs');
/**
* Удаляем старый аватар
*/
$this->DeleteBlogAvatar($oBlog);
/**
* Имя файла для сохранения
*/
$sFileName = 'avatar-blog-' . $oBlog->getId();
/**
* Сохраняем оригинальную копию
* Сохраняем оригинальный аватар
*/
if (!$sFileResult = $oImage->saveSmart($sPath, $sFileName)) {
$this->Fs_RemoveFileLocal($sFileTmp);
if (false === ($sFileResult = $oImage->saveSmart($sPath, $sFileName))) {
return $this->Image_GetLastError();
}
$aSizes = Config::Get('module.blog.avatar_size');
/**
* Генерируем варианты с необходимыми размерами
*/
$this->Media_GenerateImageBySizes($sFileTmp, $sPath, $sFileName, $aSizes, $aParams);
$this->Media_GenerateImageBySizes($sFileTmp, $sPath, $sFileName, Config::Get('module.blog.avatar_size'),
$aParams);
/**
* Теперь можно удалить временный файл
*/
$this->Fs_RemoveFileLocal($sFileTmp);
$oBlog->setAvatar($sFileResult);
$this->UpdateBlog($oBlog);
return true;
}

View file

@ -235,6 +235,22 @@ class ModuleBlog_EntityBlog extends Entity
}
}
/**
* Формирует массив с путями до аватаров
*
* @return array Массив с путями до аватаров
*/
public function getAvatarsPath()
{
$aAvatars = array();
foreach (Config::Get('module.blog.avatar_size') as $sSize) {
$aAvatars[ $sSize ] = $this->getAvatarPath( $sSize );
}
return $aAvatars;
}
/**
* Возвращает факт присоединения пользователя к блогу
*
@ -279,6 +295,16 @@ class ModuleBlog_EntityBlog extends Entity
}
}
public function isAllowEdit()
{
if ($oUser = $this->User_GetUserCurrent()) {
if ($oUser->getId() == $this->getOwnerId() or $oUser->isAdministrator() or $this->getUserIsAdministrator()) {
return true;
}
}
return false;
}
/**
* Устанавливает ID блога
*

View file

@ -560,12 +560,12 @@ class ModuleBlog_MapperBlog extends Mapper
if (!in_array($key, $aOrderAllow)) {
unset($aOrder[$key]);
} elseif (in_array($value, array('asc', 'desc'))) {
$sOrder .= " {$key} {$value},";
$sOrder .= " b.{$key} {$value},";
}
}
$sOrder = trim($sOrder, ',');
if ($sOrder == '') {
$sOrder = ' blog_id desc ';
$sOrder = ' b.blog_id desc ';
}
if (isset($aFilter['exclude_type']) and !is_array($aFilter['exclude_type'])) {
@ -578,23 +578,36 @@ class ModuleBlog_MapperBlog extends Mapper
$aFilter['id'] = array($aFilter['id']);
}
if ($oUserCurrent=$this->User_GetUserCurrent()) {
$iUserCurrentId=$oUserCurrent->getId();
} else {
$iUserCurrentId=0;
}
$sql = "SELECT
blog_id
b.blog_id
FROM
" . Config::Get('db.table.blog') . "
" . Config::Get('db.table.blog') . " as b
{
JOIN " . Config::Get('db.table.blog_user') . " as bu
ON ( bu.blog_id = b.blog_id and bu.user_id = '{$iUserCurrentId}'
and bu.user_role in (?a)
)
}
WHERE
1 = 1
{ AND blog_id IN (?a) }
{ AND user_owner_id = ?d }
{ AND blog_type IN (?a) }
{ AND blog_type not IN (?a) }
{ AND blog_url = ? }
{ AND blog_title LIKE ? }
{ AND b.blog_id IN (?a) }
{ AND b.user_owner_id = ?d }
{ AND b.blog_type IN (?a) }
{ AND b.blog_type not IN (?a) }
{ AND b.blog_url = ? }
{ AND b.blog_title LIKE ? }
ORDER by {$sOrder}
LIMIT ?d, ?d ;
";
$aResult = array();
if ($aRows = $this->oDb->selectPage($iCount, $sql,
(isset($aFilter['roles']) and count($aFilter['roles'])) ? $aFilter['roles'] : DBSIMPLE_SKIP,
(isset($aFilter['id']) and count($aFilter['id'])) ? $aFilter['id'] : DBSIMPLE_SKIP,
isset($aFilter['user_owner_id']) ? $aFilter['user_owner_id'] : DBSIMPLE_SKIP,
(isset($aFilter['type']) and count($aFilter['type'])) ? $aFilter['type'] : DBSIMPLE_SKIP,

View file

@ -105,7 +105,6 @@ $config['acl']['update']['comment']['rating'] = -5; // порог рейтин
$config['acl']['update']['comment']['limit_time'] = 60 * 3; // время в секундах после создания комментария, когда можно его отредактировать, если 0 то ограничение по времени не будет работать
$config['acl']['vote']['comment']['rating'] = -3; // порог рейтинга при котором юзер может голосовать за комментарии
$config['acl']['vote']['topic']['rating'] = -7; // порог рейтинга при котором юзер может голосовать за топик
$config['acl']['vote']['user']['rating'] = -1; // порог рейтинга при котором юзер может голосовать за пользователя
$config['acl']['vote']['topic']['limit_time'] = 60 * 60 * 24 * 20; // ограничение времени голосования за топик
$config['acl']['vote']['comment']['limit_time'] = 60 * 60 * 24 * 5; // ограничение времени голосования за комментарий
/**
@ -224,8 +223,8 @@ $config['module']['poll']['time_limit_update'] = 60 * 60 * 30; // Время в
/**
* Модуль Image
*/
$config['module']['image']['params']['blog_avatar']['size_max_width'] = 500;
$config['module']['image']['params']['blog_avatar']['size_max_height'] = 500;
$config['module']['image']['params']['blog_avatar']['size_max_width'] = 1000;
$config['module']['image']['params']['blog_avatar']['size_max_height'] = 1000;
/**
* Модуль Media
*/
@ -403,10 +402,6 @@ $config['block']['rule_index_blog'] = array(
),
'clear' => false,
);
$config['block']['rule_index'] = array(
'action' => array('index'),
'blocks' => array('right' => array('blogNav' => array('priority' => 500))),
);
$config['block']['rule_topic_type'] = array(
'action' => array(
'content' => array('add', 'edit'),
@ -447,15 +442,6 @@ $config['block']['userfeedUsers'] = array(
)
)
);
$config['block']['rule_blog_info'] = array(
'action' => array(
'blog' => array('{topic}')
),
'blocks' => array(
'right' => array('components/blog/blocks/block.blog.tpl' => array('priority' => 300))
),
'clear' => false,
);
$config['block']['rule_users'] = array(
'action' => array('people'),
'blocks' => array(

View file

@ -384,6 +384,9 @@ return array(
'type' => array(
'title' => 'Тип блога',
),
'relation' => array(
'title' => 'Принадлежность',
),
),
),
),

View file

@ -293,7 +293,7 @@ jQuery(document).ready(function($){
crop_avatar: aRouter.settings + 'ajax-modal-crop-avatar',
save_photo: aRouter.settings + 'ajax-crop-photo',
save_avatar: aRouter.settings + 'ajax-change-avatar',
cancel_photo: aRouter.settings + 'ajax-crop-cancel-photo',
cancel_photo: aRouter.settings + 'ajax-crop-cancel-photo'
},
changeavatar: function ( event, _this, avatars ) {
$( '.js-user-profile-avatar, .js-wall-entry[data-user-id=' + _this.option( 'params.user_id' ) + '] .comment-avatar img' ).attr( 'src', avatars[ '64crop' ] + '?' + Math.random() );
@ -301,7 +301,6 @@ jQuery(document).ready(function($){
}
});
/**
* Talk
*/
@ -414,6 +413,11 @@ jQuery(document).ready(function($){
name: 'type',
selector: '.js-search-ajax-blog-type'
},
{
type: 'radio',
name: 'relation',
selector: '.js-search-ajax-blog-relation'
},
{
type: 'list',
name: 'category',
@ -427,6 +431,22 @@ jQuery(document).ready(function($){
]
});
// Аватар блога
$( '.js-blog-avatar' ).lsPhoto({
urls: {
upload: aRouter.blog + 'ajax/upload-avatar',
remove: aRouter.blog + 'ajax/remove-avatar',
crop_photo: aRouter.blog + 'ajax/modal-crop-avatar',
//crop_avatar: aRouter.settings + 'ajax-modal-crop-avatar',
save_photo: aRouter.blog + 'ajax/crop-avatar',
//save_avatar: aRouter.settings + 'ajax-change-avatar',
cancel_photo: aRouter.blog + 'ajax/crop-cancel-avatar'
},
changeavatar: function ( event, _this, avatars ) {
}
});
/**
* Topic

View file

@ -60,23 +60,6 @@
note = $aLang.blog.add.fields.rating.note
label = $aLang.blog.add.fields.rating.label}
{* Аватар *}
{if $blog && $blog->getAvatar()}
{$uploadedImages = []}
{foreach Config::Get('module.blog.avatar_size') as $size}
{if $image = $blog->getAvatarPath( $size )}
{$uploadedImages[] = $image}
{/if}
{/foreach}
{/if}
{include 'components/field/field.image.tpl'
name = 'avatar'
removeName = 'avatar_delete'
uploadedFiles = $uploadedImages
label = $aLang.blog.add.fields.avatar.label}
{hook run='form_add_blog_end'}

View file

@ -15,9 +15,6 @@
{$blog = $oBlog}
<ul class="profile-actions" id="profile_actions">
{* Является ли пользователь администратором или управляющим блога *}
{$isBlogAdmin = $oUserCurrent && ( $oUserCurrent->getId() == $blog->getOwnerId() || $oUserCurrent->isAdministrator() || $blog->getUserIsAdministrator() )}
{* Список экшенов *}
{$actions = []}
@ -31,7 +28,7 @@
{/if}
{* Написать в блог *}
{if $oUserCurrent && ( ( $blog->getUserIsJoin() && $oUserCurrent->getRating() >= $blog->getLimitRatingTopic() ) || $isBlogAdmin )}
{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'}
@ -44,7 +41,7 @@
'text' => {lang 'blog.actions.rss'}
]}
{if $oUserCurrent && $isBlogAdmin}
{if $blog->isAllowEdit()}
{* Редактировать *}
{$actions[] = [ 'icon' => 'icon-edit', 'url' => "{router page='blog'}edit/{$blog->getId()}/", 'text' => $aLang.common.edit ]}

View file

@ -1,38 +0,0 @@
{**
* Навигация по блогам с возможностью выбрать категорию и блог из этой категории
*}
{extends 'components/block/block.tpl'}
{block 'block_title'}
{lang 'blog.blocks.navigator.title'}
{/block}
{block 'block_options' append}
{$mods = "{$mods} blog-navigation"}
{/block}
{block 'block_content'}
{if $aNavigatorBlogCategories}
<p><select class="width-full js-blog-nav-categories">
<option value="0">{lang 'blog.blocks.navigator.category'}</option>
{foreach $aNavigatorBlogCategories as $aCategoryItem}
{$oCategoryItem=$aCategoryItem.entity}
<option style="margin-left: {$aCategoryItem.level*20}px;" value="{$oCategoryItem->getId()}">{$oCategoryItem->getTitle()}</option>
{/foreach}
</select></p>
<p><select class="width-full js-blog-nav-blogs" disabled>
<option value="0">{lang 'blog.blocks.navigator.blog'}</option>
{foreach $aNavigatorBlogs as $oBlogItem}
<option value="{$oBlogItem->getId()}" data-url="{$oBlogItem->getUrlFull()}">{$oBlogItem->getTitle()|escape}</option>
{/foreach}
</select></p>
{include 'components/button/button.tpl' text={lang 'blog.blocks.navigator.submit'} classes='js-blog-nav-submit' isDisabled=true}
{else}
{include 'components/alert/alert.tpl' text={lang 'blog.blocks.navigator.empty'} mods='empty'}
{/if}
{/block}

View file

@ -11,7 +11,12 @@
{/block}
{block 'block_content'}
<a href="{$oBlog->getUrlFull()}">
<img src="{$oBlog->getAvatarPath(500)}" alt="{$oBlog->getTitle()|escape}" class="avatar" />
</a>
{include 'components/photo/photo.tpl'
classes = 'js-blog-avatar'
hasPhoto = $oBlog->getAvatar()
editable = $oBlog->isAllowEdit()
targetId = $oBlog->getId()
url = $oBlog->getUrlFull()
photoPath = $oBlog->getAvatarPath(500)
photoAltText = $oBlog->getTitle()|escape}
{/block}

View file

@ -1,29 +0,0 @@
{**
* Краткая информация о блоге на странице топика
*}
{extends 'components/block/block.tpl'}
{block 'block_options' append}
{$mods = "{$mods} blog"}
{$oBlog = $oTopic->getBlog()}
{$show = $oTopic && $oBlog->getType() != 'personal'}
{/block}
{block 'block_title'}<a href="{$oBlog->getUrlFull()}">{$oBlog->getTitle()|escape}</a>{/block}
{block 'block_class'}block-type-blog{/block}
{block 'block_content'}
<span id="blog_user_count_{$oBlog->getId()}">{$oBlog->getCountUser()}</span>
{$oBlog->getCountUser()|declension:$aLang.blog.readers_declension}<br />
{$oBlog->getCountTopic()} {lang name=$aLang.topic.topic_plural count=$oBlog->getCountTopic() plural=true}
<br />
<br />
{* Подписаться через RSS *}
<a href="{router page='rss'}blog/{$oBlog->getUrl()}/" class="button">RSS</a>
{* Вступить / Покинуть блог *}
{include 'components/blog/join.tpl' blog=$oBlog}
{/block}

View file

@ -54,4 +54,11 @@
{include 'components/field/field.radio.tpl' inputClasses='js-search-ajax-blog-type' name='blog_search_type' value='' label='Любой' checked=true}
{include 'components/field/field.radio.tpl' inputClasses='js-search-ajax-blog-type' name='blog_search_type' value='open' label='Открытый'}
{include 'components/field/field.radio.tpl' inputClasses='js-search-ajax-blog-type' name='blog_search_type' value='close' label='Закрытый'}
{* Тип принадлежности блога *}
<h3>{lang 'blog.blocks.search.relation.title'}</h3>
{include 'components/field/field.radio.tpl' inputClasses='js-search-ajax-blog-relation' name='blog_search_relation' value='all' label='Все' checked=true}
{include 'components/field/field.radio.tpl' inputClasses='js-search-ajax-blog-relation' name='blog_search_relation' value='my' label='Мои'}
{include 'components/field/field.radio.tpl' inputClasses='js-search-ajax-blog-relation' name='blog_search_relation' value='join' label='Читаю'}
{/block}

View file

@ -21,7 +21,7 @@ ls.blog = (function ($) {
var _defaults = {
// Роутеры
routers: {
categories: aRouter['ajax'] + 'blogs/get-by-category/',
categories: aRouter['ajax'] + 'blogs/get-by-category/'
},
// Селекторы

View file

@ -0,0 +1,11 @@
{**
* Кроп фотографии
*}
{extends 'components/crop/crop.tpl'}
{block 'modal_options' append}
{$title = {lang 'user.photo.crop_avatar.title'}}
{$desc = {lang 'user.photo.crop_avatar.desc'}}
{$usePreview = true}
{/block}