xref: /plugin/spatialhelper/admin/purge.php (revision 7c452997f52bfd76fc61ccdd3f030c613ccc92fb) !
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 */
17if (! defined ( 'DOKU_INC' ))
18	die ();
19if (! defined ( 'DOKU_PLUGIN' ))
20	define ( 'DOKU_PLUGIN', DOKU_INC . 'lib/plugins/' );
21require_once DOKU_PLUGIN . 'admin.php';
22/**
23 * DokuWiki Plugin spatialhelper (Admin Component).
24 * This component purges the spatial index.
25 *
26 * @author Mark Prins
27 */
28class admin_plugin_spatialhelper_purge extends DokuWiki_Admin_Plugin {
29	/**
30	 * (non-PHPdoc)
31	 *
32	 * @see DokuWiki_Admin_Plugin::getMenuSort()
33	 */
34	public function getMenuSort() {
35		return 801;
36	}
37	/**
38	 * (non-PHPdoc)
39	 *
40	 * @see DokuWiki_Admin_Plugin::forAdminOnly()
41	 */
42	public function forAdminOnly() {
43		return true;
44	}
45
46	/**
47	 * (non-PHPdoc)
48	 *
49	 * @see DokuWiki_Admin_Plugin::handle()
50	 */
51	public function handle() {
52		global $conf;
53		if (isset ( $_REQUEST ['purgeindex'] )) {
54			global $conf;
55			$path = $conf ['indexdir'] . '/spatial.idx';
56			if (file_exists ( $path )) {
57				if (unlink ( $path )) {
58					msg ( $this->getLang ( 'admin_purged_tiles' ), 0 );
59				}
60			}
61		}
62	}
63
64	/**
65	 * (non-PHPdoc)
66	 *
67	 * @see DokuWiki_Admin_Plugin::html()
68	 */
69	public function html() {
70		echo $this->locale_xhtml ( 'admin_purge_intro' );
71
72		$form = new Doku_Form ( array (
73				'id' => 'spatialhelper__purgeform',
74				'method' => 'post'
75		) );
76		$form->addHidden ( 'purgeindex', 'true' );
77
78		$form->addElement ( form_makeButton ( 'submit', 'admin', $this->getLang ( 'admin_submit' ), array (
79				'title' => $this->getLang ( 'admin_submit' )
80		) ) );
81		$form->printForm ();
82	}
83}
84