qa-mouseover-admin-form.php 2.15 KB
Newer Older
Scott committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
<?php
/*
	Question2Answer by Gideon Greenspan and contributors
	http://www.question2answer.org/

	File: qa-plugin/mouseover-layer/qa-mouseover-admin-form.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.

	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
*/

Scott committed
23 24 25 26 27 28 29
class qa_mouseover_admin_form
{
	public function option_default($option)
	{
		if ($option === 'mouseover_content_max_len')
			return 480;
	}
Scott committed
30 31


Scott committed
32 33 34
	public function admin_form(&$qa_content)
	{
		$saved = qa_clicked('mouseover_save_button');
Scott committed
35

Scott committed
36 37 38 39
		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'));
		}
Scott committed
40

Scott committed
41 42 43
		qa_set_display_rules($qa_content, array(
			'mouseover_content_max_len_display' => 'mouseover_content_on_field',
		));
Scott committed
44

Scott committed
45
		return array(
46
			'ok' => $saved ? qa_lang_html('admin/options_saved') : null,
Scott committed
47

Scott committed
48 49
			'fields' => array(
				array(
Scott committed
50
					'label' => qa_lang_html('mouseover/show_content_preview'),
Scott committed
51 52 53
					'type' => 'checkbox',
					'value' => qa_opt('mouseover_content_on'),
					'tags' => 'name="mouseover_content_on_field" id="mouseover_content_on_field"',
Scott committed
54 55
				),

Scott committed
56 57
				array(
					'id' => 'mouseover_content_max_len_display',
Scott committed
58
					'label' => qa_lang_html('mouseover/max_length'),
59
					'suffix' => qa_lang_html('mouseover/characters'),
Scott committed
60 61 62
					'type' => 'number',
					'value' => (int) qa_opt('mouseover_content_max_len'),
					'tags' => 'name="mouseover_content_max_len_field"',
Scott committed
63
				),
Scott committed
64
			),
Scott committed
65

Scott committed
66 67
			'buttons' => array(
				array(
68
					'label' => qa_lang_html('main/save_button'),
Scott committed
69 70 71 72
					'tags' => 'name="mouseover_save_button"',
				),
			),
		);
Scott committed
73
	}
Scott committed
74
}