summaryrefslogtreecommitdiff
path: root/sitemap.php
diff options
context:
space:
mode:
Diffstat (limited to 'sitemap.php')
-rwxr-xr-xsitemap.php68
1 files changed, 18 insertions, 50 deletions
diff --git a/sitemap.php b/sitemap.php
index 3a1f189..89f0940 100755
--- a/sitemap.php
+++ b/sitemap.php
@@ -1,65 +1,33 @@
<?php
/**
- * Copyright (c) 2004 bitweaver.org
- * Copyright (c) 2003 tikwiki.org
- * Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
- * All Rights Reserved. See below for details and a complete list of authors.
- * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details
- *
* @package wiki
* @subpackage functions
*/
-/**
- * required setup
- */
require_once '../kernel/includes/setup_inc.php';
-use Bitweaver\Wiki\BitBook;
-use Bitweaver\Liberty\LibertyContent;
-use Bitweaver\Liberty\LibertyStructure;
+use Bitweaver\Wiki\BitPage;
-$book = new BitBook();
$gSiteMapHash = [];
+$page = new BitPage();
+$listHash = [ 'max_records' => -1, 'sort_mode' => 'last_modified_desc' ];
-$listHash = [];
-
-if( $bookList = $book->getList( $listHash ) ) {
- foreach( $bookList['data'] as $bookHash ) {
- $bookStructure = new LibertyStructure( $bookHash['structure_id'] );
- if( $rootObject = LibertyContent::getLibertyObject( $bookStructure->getField( 'content_id' ), $bookStructure->getField( 'content_type_guid' ) ) ) {
- if( $rootObject->isPublic() ) {
- $listBook = $bookStructure->buildTreeToc( $bookHash['structure_id'] );
- process_book_list( $listBook );
- }
- }
- }
-}
-
-function process_book_list( $pList, $pDepth = 1 ) {
- global $gSiteMapHash;
- foreach( array_keys( $pList ) as $key ) {
- if( !empty( $pList[$key]['display_url'] ) ) {
- $hash = [];
- $hash['loc'] = BIT_BASE_URI.$pList[$key]['display_url'];
- $hash['lastmod'] = date( 'Y-m-d', $pList[$key]['last_modified'] );
- if( (time() - $pList[$key]['last_modified']) < 86400 ) {
- $freq = 'daily';
- } elseif( (time() - $pList[$key]['last_modified']) < (86400 * 7) ) {
- $freq = 'weekly';
- } else {
- $freq = 'monthly';
- }
-
- $hash['changefreq'] = $freq;
- $hash['priority'] = 1 - round( $pDepth * .5 ) * .1;
- $gSiteMapHash[$pList[$key]['content_id']] = $hash;
- }
- if( !empty( $pList[$key]['sub'] ) ) {
- process_book_list( $pList[$key]['sub'], $pDepth + 1 );
- }
+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' );
-print $gBitSmarty->display( 'bitpackage:kernel/sitemap.tpl' );
+header( 'Content-Type: application/xml; charset=utf-8' );
+$gBitSystem->display( 'bitpackage:kernel/sitemap.tpl' );