diff --git a/application/classes/hooks/HookMain.class.php b/application/classes/hooks/HookMain.class.php index fa48f0b8..2f8368cf 100644 --- a/application/classes/hooks/HookMain.class.php +++ b/application/classes/hooks/HookMain.class.php @@ -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(); /** * Запуск обработки сборщика */ diff --git a/application/classes/modules/blog/Blog.class.php b/application/classes/modules/blog/Blog.class.php index eae96d92..cd3b77df 100644 --- a/application/classes/modules/blog/Blog.class.php +++ b/application/classes/modules/blog/Blog.class.php @@ -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); + } + )); + } } \ No newline at end of file diff --git a/application/classes/modules/topic/Topic.class.php b/application/classes/modules/topic/Topic.class.php index b315fc99..e04a37e3 100644 --- a/application/classes/modules/topic/Topic.class.php +++ b/application/classes/modules/topic/Topic.class.php @@ -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); + } + )); + } } \ 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..f158def7 100644 --- a/application/classes/modules/user/User.class.php +++ b/application/classes/modules/user/User.class.php @@ -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); + } + )); + } } \ No newline at end of file diff --git a/application/config/config.php b/application/config/config.php index f2f4e94d..e5d5ff55 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -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; diff --git a/framework b/framework index c3b04d79..955619fc 160000 --- a/framework +++ b/framework @@ -1 +1 @@ -Subproject commit c3b04d7992dc227971c8c0f9e1a46f21f3860c41 +Subproject commit 955619fcd2139f549e8cc2ab0f34df029b1ca652 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