1<?php
2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
3//
4// All Rights Reserved. See copyright.txt for details and a complete list of authors.
5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6// $Id$
7
8require_once('lib/wizard/wizard.php');
9
10/**
11 * Set up the wysiwyg editor, including inline editing
12 */
13class AdminWizardWysiwyg extends Wizard
14{
15	function pageTitle()
16	{
17		return tra('Set up Wysiwyg editor');
18	}
19	function isEditable()
20	{
21		return true;
22	}
23	function isVisible()
24	{
25		global	$prefs;
26		return $prefs['feature_wysiwyg'] === 'y';
27	}
28
29	function onSetupPage($homepageUrl)
30	{
31		global $prefs;
32		$smarty = TikiLib::lib('smarty');
33
34		// Run the parent first
35		parent::onSetupPage($homepageUrl);
36
37		if (! $this->isVisible()) {
38			return false;
39		}
40
41		// Setup initial wizard screen
42		$smarty->assign('useHighlighter', isset($prefs['feature_syntax_highlighter']) && $prefs['feature_syntax_highlighter'] === 'y' ? 'y' : 'n');
43		$smarty->assign('useWysiwyg', isset($prefs['feature_wysiwyg']) && $prefs['feature_wysiwyg'] === 'y' ? 'y' : 'n');
44		$smarty->assign('useWysiwygDefault', isset($prefs['wysiwyg_default']) && $prefs['wysiwyg_default'] === 'y' ? 'y' : 'n');
45		$smarty->assign('useInlineEditing', isset($prefs['wysiwyg_inline_editing']) && $prefs['wysiwyg_inline_editing'] === 'y' ? 'y' : 'n');
46		$smarty->assign('editorType', isset($prefs['wysiwyg_htmltowiki']) && $prefs['wysiwyg_htmltowiki'] === 'y' ? 'wiki' : 'html');
47
48		return true;
49	}
50
51	function getTemplate()
52	{
53		$wizardTemplate = 'wizard/admin_wysiwyg.tpl';
54		return $wizardTemplate;
55	}
56
57	function onContinue($homepageUrl)
58	{
59		$tikilib = TikiLib::lib('tiki');
60
61		// Run the parent first
62		parent::onContinue($homepageUrl);
63
64		$editorType = $_REQUEST['editorType'];
65		switch ($editorType) {
66			case 'wiki':
67				// Wysiwyg in wiki mode is always optional (or?).
68				//	The setting is presented under HTML mode, and the user can change it there.
69				//	Unaware that it affects the wiki mode also, where it is safe to switch between wysiwyg and text mode.
70				$tikilib->set_preference('wysiwyg_optional', 'y');
71				$tikilib->set_preference('wysiwyg_htmltowiki', 'y');	// Use wiki syntax
72				break;
73
74			case 'html':
75				// Always use Wysiwyg mode as default
76				//  The setting is presented under WIKI mode, and the user can change it there.
77				//	Unaware that it affects the HTML mode also, where Wysiwyg always should be the default.
78				$tikilib->set_preference('wysiwyg_default', 'y');
79				$tikilib->set_preference('wysiwyg_htmltowiki', 'n');	// No not use wiki syntax
80				break;
81		}
82	}
83}
84