qa-mouseover-admin-form.php 2.34 KB
Newer Older
Gideon Greenspan committed
1 2 3
<?php

/*
Gideon Greenspan committed
4
	Question2Answer by Gideon Greenspan and contributors
Gideon Greenspan committed
5 6 7

	http://www.question2answer.org/

8

Gideon Greenspan committed
9 10 11 12 13 14 15 16 17
	File: qa-plugin/mouseover-layer/qa-mouseover-admin-form.php
	Version: See define()s at top of qa-include/qa-base.php
	Description: Generic module class for mouseover layer plugin to provide admin form and default option


	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.
18

Gideon Greenspan committed
19 20 21 22 23 24 25 26 27
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	More about this license: http://www.question2answer.org/license.php
*/

	class qa_mouseover_admin_form {
28

29
		public function option_default($option)
Gideon Greenspan committed
30
		{
31
			if ($option === 'mouseover_content_max_len')
Gideon Greenspan committed
32 33
				return 480;
		}
34 35


36
		public function admin_form(&$qa_content)
Gideon Greenspan committed
37
		{
38
			$saved = qa_clicked('mouseover_save_button');
39

40 41 42
			if ($saved) {
				qa_opt('mouseover_content_on', (int) qa_post_text('mouseover_content_on_field'));
				qa_opt('mouseover_content_max_len', (int) qa_post_text('mouseover_content_max_len_field'));
Gideon Greenspan committed
43
			}
44

Gideon Greenspan committed
45 46 47
			qa_set_display_rules($qa_content, array(
				'mouseover_content_max_len_display' => 'mouseover_content_on_field',
			));
48

Gideon Greenspan committed
49 50
			return array(
				'ok' => $saved ? 'Mouseover settings saved' : null,
51

Gideon Greenspan committed
52 53 54 55 56
				'fields' => array(
					array(
						'label' => 'Show content preview on mouseover in question lists',
						'type' => 'checkbox',
						'value' => qa_opt('mouseover_content_on'),
Gideon Greenspan committed
57
						'tags' => 'name="mouseover_content_on_field" id="mouseover_content_on_field"',
Gideon Greenspan committed
58
					),
59

Gideon Greenspan committed
60 61 62 63 64
					array(
						'id' => 'mouseover_content_max_len_display',
						'label' => 'Maximum length of preview:',
						'suffix' => 'characters',
						'type' => 'number',
65
						'value' => (int) qa_opt('mouseover_content_max_len'),
Gideon Greenspan committed
66
						'tags' => 'name="mouseover_content_max_len_field"',
Gideon Greenspan committed
67 68
					),
				),
69

Gideon Greenspan committed
70 71 72
				'buttons' => array(
					array(
						'label' => 'Save Changes',
Gideon Greenspan committed
73
						'tags' => 'name="mouseover_save_button"',
Gideon Greenspan committed
74 75 76 77
					),
				),
			);
		}
78

Gideon Greenspan committed
79
	}
80

Gideon Greenspan committed
81 82 83 84

/*
	Omit PHP closing tag to help avoid accidental output
*/