Browse Source

Поддержка sitemap

master
Mzhelskiy Maxim 3 years ago
parent
commit
0aa67825d2
7 changed files with 111 additions and 2 deletions
  1. +17
    -0
      application/classes/hooks/HookMain.class.php
  2. +27
    -0
      application/classes/modules/blog/Blog.class.php
  3. +33
    -0
      application/classes/modules/topic/Topic.class.php
  4. +26
    -0
      application/classes/modules/user/User.class.php
  5. +5
    -0
      application/config/config.php
  6. +1
    -1
      framework
  7. +2
    -1
      robots.txt

+ 17
- 0
application/classes/hooks/HookMain.class.php View File

@@ -59,6 +59,23 @@ class HookMain extends Hook
{
$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();
/**
* Запуск обработки сборщика
*/
$this->Ls_SenderRun();


+ 27
- 0
application/classes/modules/blog/Blog.class.php View File

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

+ 33
- 0
application/classes/modules/topic/Topic.class.php View File

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

+ 26
- 0
application/classes/modules/user/User.class.php View File

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

+ 5
- 0
application/config/config.php View File

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

@@ -1 +1 @@
Subproject commit c3b04d7992dc227971c8c0f9e1a46f21f3860c41
Subproject commit 955619fcd2139f549e8cc2ab0f34df029b1ca652

+ 2
- 1
robots.txt View File

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

Loading…
Cancel
Save