mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-05-04 09:58:19 +03:00
Поддержка sitemap
This commit is contained in:
parent
212ecde64d
commit
0aa67825d2
|
@ -58,6 +58,23 @@ 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(), '1', 'hourly'),
|
||||
$this->Sitemap_GetDataForSitemapRow(Router::GetPath('stream/all'), time(), '0.7', 'hourly'),
|
||||
);
|
||||
}
|
||||
));
|
||||
$this->Topic_RegisterSitemap();
|
||||
$this->Blog_RegisterSitemap();
|
||||
$this->User_RegisterSitemap();
|
||||
/**
|
||||
* Запуск обработки сборщика
|
||||
*/
|
||||
|
|
|
@ -1195,4 +1195,31 @@ 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, '0.8', 'weekly');
|
||||
}
|
||||
return $aData;
|
||||
},
|
||||
'callback_counters' => function () use ($aFilter) {
|
||||
$aBlogs = $this->GetBlogsByFilter($aFilter, array(), 1, 1, array());
|
||||
$iCount = (int)$aBlogs['count'];
|
||||
return ceil($iCount / 500);
|
||||
}
|
||||
));
|
||||
}
|
||||
}
|
|
@ -2002,4 +2002,37 @@ 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(),
|
||||
'0.9', 'weekly'
|
||||
);
|
||||
}
|
||||
return $aData;
|
||||
},
|
||||
'callback_counters' => function () use ($aFilter) {
|
||||
$iCount = (int)$this->GetCountTopicsByFilter($aFilter);
|
||||
return ceil($iCount / 500);
|
||||
}
|
||||
));
|
||||
}
|
||||
}
|
|
@ -1985,4 +1985,30 @@ 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(), '0.5', 'weekly');
|
||||
}
|
||||
return $aData;
|
||||
},
|
||||
'callback_counters' => function () use ($aFilter) {
|
||||
$aUsers = $this->GetUsersByFilter($aFilter, array(), 1, 1, array());
|
||||
$iCount = (int)$aUsers['count'];
|
||||
return ceil($iCount / 500);
|
||||
}
|
||||
));
|
||||
}
|
||||
}
|
|
@ -422,6 +422,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';
|
||||
|
@ -445,6 +447,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;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit c3b04d7992dc227971c8c0f9e1a46f21f3860c41
|
||||
Subproject commit 955619fcd2139f549e8cc2ab0f34df029b1ca652
|
|
@ -13,3 +13,4 @@ Disallow: /error/$
|
|||
Disallow: /settings/$
|
||||
Disallow: /content/$
|
||||
Disallow: /talk/$
|
||||
# Sitemap: http://example.com/sitemap.xml
|
Loading…
Reference in a new issue