Skip to content
Permalink
Browse files

Initial release of code.

  • Loading branch information...
gamma committed Feb 11, 2014
1 parent 5ea589b commit 6a7e6f84e4c13594e8fea67fbb4b552a3bd9ab51
Showing with 80 additions and 0 deletions.
  1. +73 −0 action.php
  2. +7 −0 plugin.info.txt
@@ -0,0 +1,73 @@
<?php
/**
* Script to put indexed documents into the sitemap Plugin
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author i-net software <tools@inetsoftware.de>
* @author Gerry Weissbach <gweissbach@inetsoftware.de>
*/
if(!defined('DOKU_INC')) die();
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
if(!defined('DOKU_DATA')) define('DOKU_DATA',DOKU_INC.'data/');
require_once(DOKU_PLUGIN.'action.php');
require_once(DOKU_INC . 'inc/fulltext.php');
class action_plugin_docsearchsitemap extends DokuWiki_Action_Plugin {
var $data = array();
/**
* Register to the content display event to place the results under it.
*/
function register(&$controller) {
$controller->register_hook('SITEMAP_GENERATE', 'BEFORE', $this, 'runSitemapper', array());
}
/**
* Builds a Google Sitemap of all public documents known to the indexer
*
* The map is placed in the root directory named sitemap.xml.gz - This
* file needs to be writable!
*
* @autohr Gerry Weissbach
* @link https://www.google.com/webmasters/sitemaps/docs/en/about.html
*/
function runSitemapper(&$event, $param){
global $conf;
// backup the config array
$cp = $conf;
// change index/pages folder for DocSearch
$conf['indexdir'] = init_path($conf['savedir'] . '/docsearch/index');
$conf['datadir'] = init_path($conf['savedir'] . '/docsearch/pages');
$pages = idx_get_indexer()->getPages();
// build the sitemap
foreach($pages as $id){
//skip hidden, non existing and restricted files
if(isHiddenPage($id)) continue;
if(auth_aclcheck($id,'','') < AUTH_READ) continue;
// $item = SitemapItem::createFromID($id);
$id = trim($id);
$date = @filemtime(mediaFN($id));
if(!$date) continue;
$item = new SitemapItem(ml($id, '', true, '', true), $date, $changefreq, $priority);
if ($item !== null) {
$event->data['items'][] = $item;
}
}
$conf = $cp;
return true;
}
}
?>
@@ -0,0 +1,7 @@
base docsearchsitemap
author Gerry Weissbach
email gweissbach@inetsoftware.de
date 2014-02-11
name DocSearch Sitemap
desc Create an additional Sitemap for documents found by the docsearch plugin
url https://github.com/i-net-software/dokuwiki-plugin-docsearchsitemap

0 comments on commit 6a7e6f8

Please sign in to comment.
You can’t perform that action at this time.