diff --git a/application/classes/hooks/HookMain.class.php b/application/classes/hooks/HookMain.class.php index fa48f0b8..d482183f 100644 --- a/application/classes/hooks/HookMain.class.php +++ b/application/classes/hooks/HookMain.class.php @@ -58,6 +58,25 @@ class HookMain extends Hook public function StartAction() { $this->LoadDefaultJsVarAndLang(); + /** + * Обработка сайтмапа + */ + $this->Sitemap_AddTargetType('general', array( + 'callback_counters' => function () { + return 1; + }, + 'callback_data' => function () { + return array( + $this->Sitemap_GetDataForSitemapRow(Router::GetPath('/'), time(), Config::Get('module.sitemap.index.priority'), + Config::Get('module.sitemap.index.changefreq')), + $this->Sitemap_GetDataForSitemapRow(Router::GetPath('stream/all'), time(), Config::Get('module.sitemap.stream.priority'), + Config::Get('module.sitemap.stream.changefreq')), + ); + } + )); + $this->Topic_RegisterSitemap(); + $this->Blog_RegisterSitemap(); + $this->User_RegisterSitemap(); /** * Запуск обработки сборщика */ diff --git a/application/classes/modules/blog/Blog.class.php b/application/classes/modules/blog/Blog.class.php index eae96d92..2a549f14 100644 --- a/application/classes/modules/blog/Blog.class.php +++ b/application/classes/modules/blog/Blog.class.php @@ -1195,4 +1195,35 @@ class ModuleBlog extends Module ) ); } + + /** + * Регистрация сайтмапа для блогов + */ + public function RegisterSitemap() + { + $aFilter = array( + 'type' => array( + 'open', + ), + ); + $this->Sitemap_AddTargetType('blogs', array( + 'callback_data' => function ($iPage) use ($aFilter) { + $aBlogs = $this->GetBlogsByFilter($aFilter, array('blog_id' => 'asc'), $iPage, 500, array()); + $aData = array(); + foreach ($aBlogs['collection'] as $oBlog) { + $aData[] = $this->Sitemap_GetDataForSitemapRow( + $oBlog->getUrlFull(), null, + Config::Get('module.sitemap.blog.priority'), + Config::Get('module.sitemap.blog.changefreq') + ); + } + return $aData; + }, + 'callback_counters' => function () use ($aFilter) { + $aBlogs = $this->GetBlogsByFilter($aFilter, array(), 1, 1, array()); + $iCount = (int)$aBlogs['count']; + return ceil($iCount / 500); + } + )); + } } \ No newline at end of file diff --git a/application/classes/modules/media/Media.class.php b/application/classes/modules/media/Media.class.php index 0a815ea9..ddc2131c 100644 --- a/application/classes/modules/media/Media.class.php +++ b/application/classes/modules/media/Media.class.php @@ -1149,6 +1149,38 @@ class ModuleMedia extends ModuleORM return false; } + /** + * Перегенерация всех превью + * + * @param array|string|null $aTypes Список типов для перегенерации + */ + public function ReCreateFilePreviewAll($aTypes = null) + { + $iPage = 1; + $aFilter = array( + 'is_preview' => 1, + 'target_id <>' => null, + '#with' => array('media'), + '#page' => array($iPage, 100) + ); + if ($aTypes) { + if (!is_array($aTypes)) { + $aTypes = array($aTypes); + } + $aFilter['target_type in'] = $aTypes; + } + + while ($aRes = $this->GetTargetItemsByFilter($aFilter) and $aRes['collection']) { + foreach ($aRes['collection'] as $oTarget) { + if ($oMedia = $oTarget->getMedia()) { + $this->CreateFilePreview($oMedia, $oTarget); + } + } + $iPage++; + $aFilter['#page'][0] = $iPage; + } + } + /** * Создает превью у файла для определенного типа * diff --git a/application/classes/modules/talk/mapper/Talk.mapper.class.php b/application/classes/modules/talk/mapper/Talk.mapper.class.php index e68fdf03..9ac32469 100644 --- a/application/classes/modules/talk/mapper/Talk.mapper.class.php +++ b/application/classes/modules/talk/mapper/Talk.mapper.class.php @@ -402,7 +402,7 @@ class ModuleTalk_MapperTalk extends Mapper WHERE talk_id = ? { AND user_id NOT IN (?a) }"; - $res = $this->oDb->select($sql, $sTalkId, !is_null($aExcludeId) ? $aExcludeId : DBSIMPLE_SKIP); + $res = $this->oDb->query($sql, $sTalkId, !is_null($aExcludeId) ? $aExcludeId : DBSIMPLE_SKIP); return $this->IsSuccessful($res); } diff --git a/application/classes/modules/topic/Topic.class.php b/application/classes/modules/topic/Topic.class.php index b315fc99..45c821b1 100644 --- a/application/classes/modules/topic/Topic.class.php +++ b/application/classes/modules/topic/Topic.class.php @@ -2002,4 +2002,38 @@ class ModuleTopic extends Module ); return true; } + + /** + * Регистрация сайтмапа для топиков + */ + public function RegisterSitemap() + { + $aFilter = array( + 'blog_type' => array( + 'open', + 'personal', + ), + 'topic_publish' => 1, + 'order' => 't.topic_id asc' + ); + $this->Sitemap_AddTargetType('topics', array( + 'callback_data' => function ($iPage) use ($aFilter) { + $aTopics = $this->GetTopicsByFilter($aFilter, $iPage, 500, array('blog' => array())); + $aData = array(); + foreach ($aTopics['collection'] as $oTopic) { + $aData[] = $this->Sitemap_GetDataForSitemapRow( + $oTopic->getUrl(), + is_null($oTopic->getDateEdit()) ? $oTopic->getDatePublish() : $oTopic->getDateEdit(), + Config::Get('module.sitemap.topic.priority'), + Config::Get('module.sitemap.topic.changefreq') + ); + } + return $aData; + }, + 'callback_counters' => function () use ($aFilter) { + $iCount = (int)$this->GetCountTopicsByFilter($aFilter); + return ceil($iCount / 500); + } + )); + } } \ No newline at end of file diff --git a/application/classes/modules/user/User.class.php b/application/classes/modules/user/User.class.php index 789b3d68..c35772c0 100644 --- a/application/classes/modules/user/User.class.php +++ b/application/classes/modules/user/User.class.php @@ -1985,4 +1985,34 @@ class ModuleUser extends Module { return true; } + + /** + * Регистрация сайтмапа для пользователей + */ + public function RegisterSitemap() + { + $aFilter = array( + 'activate' => 1, + ); + $this->Sitemap_AddTargetType('users', array( + 'callback_data' => function ($iPage) use ($aFilter) { + $aUsers = $this->GetUsersByFilter($aFilter, array('user_id' => 'asc'), $iPage, 500, array()); + $aData = array(); + foreach ($aUsers['collection'] as $oUser) { + $aData[] = $this->Sitemap_GetDataForSitemapRow( + $oUser->getUserWebPath(), + is_null($oUser->getProfileDate()) ? $oUser->getDateRegister() : $oUser->getProfileDate(), + Config::Get('module.sitemap.user.priority'), + Config::Get('module.sitemap.user.changefreq') + ); + } + return $aData; + }, + 'callback_counters' => function () use ($aFilter) { + $aUsers = $this->GetUsersByFilter($aFilter, array(), 1, 1, array()); + $iCount = (int)$aUsers['count']; + return ceil($iCount / 500); + } + )); + } } \ No newline at end of file diff --git a/application/config/config.php b/application/config/config.php index dfa8401b..5f068cda 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -271,6 +271,27 @@ $config['module']['wall']['count_last_reply'] = 3; // Число послед $config['module']['wall']['per_page'] = 10; // Число сообщений на стене на одну страницу $config['module']['wall']['text_max'] = 250; // Ограничение на максимальное количество символов в одном сообщении на стене $config['module']['wall']['text_min'] = 1; // Ограничение на минимальное количество символов в одном сообщении на стене +// Модуль Sitemap +$config['module']['sitemap']['index'] = array( // Главная страница + 'priority' => '1', + 'changefreq' => 'hourly' // Вероятная частота изменения этой страницы (https://www.sitemaps.org/ru/protocol.html#changefreqdef) +); +$config['module']['sitemap']['stream'] = array( // Вся активность + 'priority' => '0.7', + 'changefreq' => 'hourly' +); +$config['module']['sitemap']['topic'] = array( // Топики + 'priority' => '0.9', + 'changefreq' => 'weekly' +); +$config['module']['sitemap']['blog'] = array( // Блоги + 'priority' => '0.8', + 'changefreq' => 'weekly' +); +$config['module']['sitemap']['user'] = array( // Пользователи + 'priority' => '0.5', + 'changefreq' => 'weekly' +); /** * Модуль опросов (Poll) @@ -424,6 +445,8 @@ $config['router']['rewrite'] = array(); $config['router']['uri'] = array( // короткий вызов топиков из личных блогов '~^(\d+)\.html~i' => "blog/\\1.html", + '~^sitemap\.xml~i' => "sitemap", + '~^sitemap_(\w+)_(\d+)\.xml~i' => "sitemap/\\1/\\2", ); // Распределение action $config['router']['page']['error'] = 'ActionError'; @@ -447,6 +470,9 @@ $config['router']['page']['subscribe'] = 'ActionSubscribe'; $config['router']['page']['content'] = 'ActionContent'; $config['router']['page']['property'] = 'ActionProperty'; $config['router']['page']['wall'] = 'ActionWall'; +$config['router']['page']['sitemap'] = function() { + return LS::Sitemap_ShowSitemap(); +}; // Глобальные настройки роутинга $config['router']['config']['default']['action'] = 'index'; $config['router']['config']['default']['event'] = null; diff --git a/application/frontend/components/activity/blocks/block.activity-recent.tpl b/application/frontend/components/activity/blocks/block.activity-recent.tpl index 33be334e..b7dfc09b 100644 --- a/application/frontend/components/activity/blocks/block.activity-recent.tpl +++ b/application/frontend/components/activity/blocks/block.activity-recent.tpl @@ -11,7 +11,7 @@ {component 'block' mods = 'primary activity-recent' - classes = 'js-block-default' + classes = 'js-block-default js-activity-block-recent' title = {lang 'activity.block_recent.title'} titleUrl = {router 'stream'} footer = $smarty.capture.block_footer diff --git a/application/frontend/skin/developer/layouts/layout.activity.tpl b/application/frontend/skin/developer/layouts/layout.activity.tpl index 86d004c8..8fc70711 100644 --- a/application/frontend/skin/developer/layouts/layout.activity.tpl +++ b/application/frontend/skin/developer/layouts/layout.activity.tpl @@ -8,6 +8,7 @@ {$layoutNav = [[ hook => 'activity', activeItem => $sMenuItemSelect, + showSingle => false, items => [ [ '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 ] diff --git a/application/frontend/skin/synio/components/userbar/userbar.tpl b/application/frontend/skin/synio/components/userbar/userbar.tpl index 28dced8a..d3ffaedc 100644 --- a/application/frontend/skin/synio/components/userbar/userbar.tpl +++ b/application/frontend/skin/synio/components/userbar/userbar.tpl @@ -20,6 +20,8 @@ {if $oUserCurrent}
+ {hook run='userbar_notifications_items_before'} + {* Новые сообщения *} {if $iUserCurrentCountTalkNew} diff --git a/application/frontend/skin/synio/layouts/layout.activity.tpl b/application/frontend/skin/synio/layouts/layout.activity.tpl index 86d004c8..8a7eae72 100644 --- a/application/frontend/skin/synio/layouts/layout.activity.tpl +++ b/application/frontend/skin/synio/layouts/layout.activity.tpl @@ -7,6 +7,7 @@ {block 'layout_options' append} {$layoutNav = [[ hook => 'activity', + showSingle => false, activeItem => $sMenuItemSelect, items => [ [ 'name' => 'user', 'url' => "{router page='stream'}personal/", 'text' => $aLang.activity.nav.personal, 'is_enabled' => !! $oUserCurrent ], diff --git a/application/frontend/skin/synio/layouts/layout.base.tpl b/application/frontend/skin/synio/layouts/layout.base.tpl index d155ca67..373b60b2 100644 --- a/application/frontend/skin/synio/layouts/layout.base.tpl +++ b/application/frontend/skin/synio/layouts/layout.base.tpl @@ -180,6 +180,7 @@ {layout_footer_links title=$oUserCurrent->getLogin() hook='layout_footer_links_user' items=[ [ text => {lang 'user.profile.nav.info'}, url => $oUserCurrent->getUserWebPath() ], [ text => {lang 'user.profile.nav.settings'}, url => {router page='settings'} ], + [ text => {lang 'modal_create.title'}, url => '#', classes => 'js-modal-toggle-default', attributes => [ 'data-lsmodaltoggle-modal' => 'syn-create-modal' ] ], [ text => {lang 'auth.logout'}, url => "{router page='auth'}logout/?security_ls_key={$LIVESTREET_SECURITY_KEY}" ] ]} {else} diff --git a/robots.txt b/robots.txt index 2054d7f1..dd4d8b49 100644 --- a/robots.txt +++ b/robots.txt @@ -12,4 +12,5 @@ Disallow: /page/$ Disallow: /error/$ Disallow: /settings/$ Disallow: /content/$ -Disallow: /talk/$ \ No newline at end of file +Disallow: /talk/$ +# Sitemap: http://example.com/sitemap.xml \ No newline at end of file