1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-16 14:50:48 +03:00
This commit is contained in:
Alexander Yakovlev 2017-04-16 15:43:17 +07:00
commit 62dc59bc79
13 changed files with 181 additions and 3 deletions

View file

@ -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();
/**
* Запуск обработки сборщика
*/

View file

@ -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);
}
));
}
}

View file

@ -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;
}
}
/**
* Создает превью у файла для определенного типа
*

View file

@ -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);
}

View file

@ -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);
}
));
}
}

View file

@ -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);
}
));
}
}

View file

@ -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;

View file

@ -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

View file

@ -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 ]

View file

@ -20,6 +20,8 @@
{if $oUserCurrent}
<div class="ls-userbar-notifications">
{hook run='userbar_notifications_items_before'}
{* Новые сообщения *}
{if $iUserCurrentCountTalkNew}
<a href="{router page='talk'}" class="ls-userbar-notifications-item ls-userbar-messages" title="{lang 'talk.new_messages'}">

View file

@ -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 ],

View file

@ -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}

View file

@ -12,4 +12,5 @@ Disallow: /page/$
Disallow: /error/$
Disallow: /settings/$
Disallow: /content/$
Disallow: /talk/$
Disallow: /talk/$
# Sitemap: http://example.com/sitemap.xml