1<?php
2/**
3 * modified for GroURL by Krzysztof Burghardt <krzysztof@burghardt.pl>
4 */
5/**
6 * Google Analytics for DokuWiki
7 *
8 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
9 * @author     Terence J. Grant<tjgrant@tatewake.com>
10 */
11
12if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
13if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
14require_once(DOKU_PLUGIN.'admin.php');
15
16//--- Exported code
17include_once(DOKU_PLUGIN.'geourl/code.php');
18//--- Exported code
19
20/**
21 * All DokuWiki plugins to extend the admin function
22 * need to inherit from this class
23 */
24class admin_plugin_geourl extends DokuWiki_Admin_Plugin
25{
26var $state = 0;
27var $geourl = '';
28
29	/**
30	 * Constructor
31	 */
32	function admin_plugin_geourl()
33	{
34		$this->setupLocale();
35	}
36
37	/**
38	 * return some info
39	 */
40	function getInfo()
41	{
42		return array(
43			'author' => 'Terence J. Grant and Krzysztof Burghardt',
44			'email'  => 'krzysztof@burghardt.pl',
45			'date'   => '2006-09-14',
46			'name'   => 'GeoURL Plugin',
47			'desc'   => 'Plugin to embed your location into GeoURL.',
48			'url'    => 'http://www.burghardt.pl/wiki/software/geourl_for_dokuwiki',
49		);
50	}
51
52	/**
53	 * return sort order for position in admin menu
54	 */
55	function getMenuSort()
56	{
57		return 998;
58	}
59
60	/**
61	 *  return a menu prompt for the admin menu
62	 *  NOT REQUIRED - its better to place $lang['menu'] string in localised string file
63	 *  only use this function when you need to vary the string returned
64	 */
65	function getMenuText()
66	{
67		return 'GeoURL';
68	}
69
70	/**
71	 * handle user request
72	 */
73	function handle()
74	{
75		$this->state = 0;
76
77		if (!isset($_REQUEST['cmd'])) return;   // first time - nothing to do
78
79		if (!is_array($_REQUEST['cmd'])) return;
80
81		$this->geourl = $_REQUEST['geourl'];
82
83		if (is_array($this->geourl))
84		{
85			$this->state = 1;
86		}
87	}
88
89	/**
90	 * output appropriate html
91	 */
92	function html()
93	{
94		global $conf;
95		global $gu_loaded, $gu_settings;
96
97		if ($this->state != 0)	//If we are to save now...
98		{
99			$gu_settings['latitude'] = $this->geourl['latitude'];
100			$gu_settings['longitude'] = $this->geourl['longitude'];
101
102			gu_save();
103		}
104
105		print $this->plugin_locale_xhtml('intro');
106
107		ptln("<form action=\"".wl($ID)."\" method=\"post\">");
108		ptln('  <input type="hidden" name="do"   value="admin" />');
109		ptln('  <input type="hidden" name="page" value="'.$this->getPluginName().'" />');
110		ptln('  <input type="hidden" name="cmd[geourl]" value="true" />');
111		print '<center><table class="inline">';
112		print '	<tr><th> '.$this->getLang('gu_item_type').' </th><th> '.$this->getLang('gu_item_option').' </th></tr>';
113		print '	<tr><td> '.$this->getLang('gu_geourl_latitude').' </td><td><input type="text" name="geourl[latitude]" value="'.$gu_settings['latitude'].'"/></td></tr>';
114		print '	<tr><td> '.$this->getLang('gu_geourl_longitude').' </td><td><input type="text" name="geourl[longitude]" value="'.$gu_settings['longitude'].'"/></td></tr>';
115		print '</table>';
116		print '<br />';
117		print '<p><input type="submit" value="'.$this->getLang('gu_save').'"></p></center>';
118		print '</form>';
119	}
120}
121
122