summaryrefslogtreecommitdiff
path: root/sitemap.php
blob: 89f0940fd02cbaceffdb20304a05d43269809933 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
/**
 * @package wiki
 * @subpackage functions
 */

require_once '../kernel/includes/setup_inc.php';
use Bitweaver\Wiki\BitPage;

$gSiteMapHash = [];
$page = new BitPage();
$listHash = [ 'max_records' => -1, 'sort_mode' => 'last_modified_desc' ];

if( $pageList = $page->getList( $listHash ) ) {
	foreach( $pageList as $row ) {
		if( empty( $row['display_url'] ) ) continue;
		$age = time() - $row['last_modified'];
		if( $age < 86400 )           $freq = 'daily';
		elseif( $age < 86400 * 7 )   $freq = 'weekly';
		else                          $freq = 'monthly';
		$gSiteMapHash[$row['content_id']] = [
			'loc'        => BIT_BASE_URI . $row['display_url'],
			'lastmod'    => date( 'Y-m-d', $row['last_modified'] ),
			'changefreq' => $freq,
			'priority'   => 0.8,
		];
	}
}

$gBitSmarty->assign( 'gSiteMapHash', $gSiteMapHash );
$gBitThemes->setFormatHeader( 'xml' );
header( 'Content-Type: application/xml; charset=utf-8' );
$gBitSystem->display( 'bitpackage:kernel/sitemap.tpl' );