1<?php 2/* 3 * Copyright (c) 2014 Mark C. Prins <mprins@users.sf.net> 4 * 5 * Permission to use, copy, modify, and distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18/** 19 * DokuWiki Plugin spatialhelper (Admin Component). 20 * This component purges and recreates the spatial index and sitemaps. 21 * 22 * @author Mark Prins 23 */ 24class admin_plugin_spatialhelper_purge extends DokuWiki_Admin_Plugin { 25 26 /** 27 * 28 * @see DokuWiki_Admin_Plugin::getMenuSort() 29 */ 30 public function getMenuSort(): int { 31 return 801; 32 } 33 34 public function getMenuIcon(): string { 35 $plugin = $this->getPluginName(); 36 return DOKU_PLUGIN . $plugin . '/admin/purge.svg'; 37 } 38 39 /** 40 * purge and regenerate the index and sitemaps. 41 * 42 * @see DokuWiki_Admin_Plugin::handle() 43 */ 44 public function handle(): void { 45 if(isset ($_REQUEST ['purgeindex'])) { 46 global $conf; 47 $path = $conf ['indexdir'] . '/spatial.idx'; 48 if(file_exists($path) && unlink($path)) { 49 msg($this->getLang('admin_purged_tiles'), 0); 50 } 51 } 52 53 $indexer = plugin_load('helper', 'spatialhelper_index'); 54 $indexer->generateSpatialIndex(); 55 56 $sitemapper = plugin_load('helper', 'spatialhelper_sitemap'); 57 $sitemapper->createKMLSitemap($this->getConf('media_kml')); 58 $sitemapper->createGeoRSSSitemap($this->getConf('media_georss')); 59 } 60 61 /** 62 * render the form for this plugin. 63 * 64 * @see DokuWiki_Admin_Plugin::html() 65 */ 66 public function html(): void { 67 echo $this->locale_xhtml('admin_purge_intro'); 68 69 $form = new Doku_Form( 70 array( 71 'id' => 'spatialhelper__purgeform', 72 'method' => 'post' 73 ) 74 ); 75 $form->addHidden('purgeindex', 'true'); 76 77 $form->addElement( 78 form_makeButton( 79 'submit', 'admin', $this->getLang('admin_submit'), array( 80 'title' => $this->getLang('admin_submit') 81 ) 82 ) 83 ); 84 $form->printForm(); 85 } 86} 87