$this->elementStart('sitemapindex', array('xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9'));
- $this->showUserSitemaps();
$this->showNoticeSitemaps();
+ $this->showUserSitemaps();
$this->elementEnd('sitemapindex');
function showUserSitemaps()
{
- $userCounts = $this->getUserCounts();
+ $userCounts = Sitemap_user_count::getAll();
foreach ($userCounts as $dt => $cnt) {
$cnt = $cnt+0;
- assert($cnt != 0);
+
+ if ($cnt == 0) {
+ continue;
+ }
+
$n = (int)$cnt / (int)SitemapPlugin::USERS_PER_MAP;
if (($cnt % SitemapPlugin::USERS_PER_MAP) != 0) {
$n++;
function showNoticeSitemaps()
{
- $noticeCounts = $this->getNoticeCounts();
+ $noticeCounts = Sitemap_notice_count::getAll();
foreach ($noticeCounts as $dt => $cnt) {
- assert($cnt != 0);
+ if ($cnt == 0) {
+ continue;
+ }
$n = $cnt / SitemapPlugin::NOTICES_PER_MAP;
if ($cnt % SitemapPlugin::NOTICES_PER_MAP) {
$n++;
}
}
- function getUserCounts()
- {
- // XXX: cachemeplease
-
- $user = new User();
-
- $user->selectAdd();
- $user->selectAdd('date(created) as regdate, count(*) as regcount');
- $user->groupBy('regdate');
-
- $user->find();
-
- $userCounts = array();
-
- while ($user->fetch()) {
- $userCounts[$user->regdate] = $user->regcount;
- }
-
- return $userCounts;
- }
-
- function getNoticeCounts()
- {
- // XXX: cachemeplease
-
- $notice = new Notice();
-
- $notice->selectAdd();
- $notice->selectAdd('date(created) as postdate, count(*) as postcount');
- $notice->groupBy('postdate');
-
- $notice->find();
-
- $noticeCounts = array();
-
- while ($notice->fetch()) {
- $noticeCounts[$notice->postdate] = $notice->postcount;
- }
-
- return $noticeCounts;
- }
-
function showSitemap($prefix, $dt, $i)
{
list($y, $m, $d) = explode('-', $dt);