18 require_once SQ_FUDGE_PATH.
'/wysiwyg/wysiwyg.inc';
19 require_once SQ_CORE_PACKAGE_PATH.
'/content_type/content_type_edit_fns.inc';
42 parent::__construct();
59 $ap = explode(
'|', $GLOBALS[
'SQ_SYSTEM']->getUserPrefs($asset->
type(),
'SQ_WYSIWYG_PLUGINS'));
61 $iap = in_array(
'all', $ap);
63 $html = $asset->
attr(
'html');
65 if (empty($this->_tmp[
'wysiwg_object'])) {
67 $wysiwyg =
new WYSIWYG($prefix, sq_web_path(
'fudge').
'/wysiwyg/');
69 $wysiwyg_style = $GLOBALS[
'SQ_SYSTEM']->getUserPrefs($asset->
type(),
'SQ_WYSIWYG_STYLE');
70 $wysiwyg->set_body_type($wysiwyg_style[
'body_type']);
71 $wysiwyg->set_init_onload(FALSE);
72 $wysiwyg->set_show_status_bar(FALSE);
74 if (is_numeric($wysiwyg_style[
'width']) && isset($wysiwyg_style[
'units'][
'width'])) {
75 $size_unit = $wysiwyg_style[
'units'][
'width'];
77 $wysiwyg->set_width($wysiwyg_style[
'width'].$size_unit);
79 if (is_numeric($wysiwyg_style[
'height']) && isset($wysiwyg_style[
'units'][
'height'])) {
80 $size_unit = $wysiwyg_style[
'units'][
'height'];
82 $wysiwyg->set_height($wysiwyg_style[
'height'].$size_unit);
84 $base_php_self = str_replace(
'/'.SQ_CONF_BACKEND_SUFFIX,
'', $_SERVER[
'PHP_SELF']);
85 $base_php_self = str_replace(
'/'.SQ_CONF_LIMBO_SUFFIX,
'', $base_php_self);
86 $base_php_self = rtrim($base_php_self,
'/ ');
88 $wysiwyg->add_relative_href_check(
'(http[s]?://'.$_SERVER[
'HTTP_HOST'].
')'.$_SERVER[
'PHP_SELF'],
'$1'.$base_php_self);
89 $wysiwyg->add_relative_href_check(
'http[s]?://'.$_SERVER[
'HTTP_HOST'].$base_php_self.
'/?(\?a=[0-9]+)',
'./$1');
90 $wysiwyg->add_relative_href_check(
'([^.][^/])(\?a=[0-9]+)',
'$1./$2');
91 $wysiwyg->add_relative_href_check(
'http[s]?://'.$_SERVER[
'HTTP_HOST'].$base_php_self.
'/?%([a-zA-Z_\-0-9]+)%',
'%$1%');
92 $wysiwyg->add_absolute_url_check(
'\./\?(a=[0-9]+)',
'http://'.$_SERVER[
'HTTP_HOST'].$base_php_self.
'/?$1');
95 $em = $GLOBALS[
'SQ_SYSTEM']->getEventManager();
97 $keyword_vars = Array(
'keywords' => &$keywords);
99 $em->broadcastEvent($asset,
'requestKeywords', $keyword_vars);
101 $wysiwyg->open_group();
103 if ($iap || in_array(
'format_text', $ap)) {
104 $wysiwyg->add_plugin(
'format_text');
106 if ($iap || in_array(
'replace_text', $ap)) {
107 $wysiwyg->add_plugin(
'replace_text');
109 if ($iap || in_array(
'search_and_replace', $ap)) {
110 $wysiwyg->add_plugin(
'search_and_replace');
112 if ($iap || in_array(
'format_font', $ap)) {
113 $wysiwyg->add_plugin(
'format_font');
115 if ($iap || in_array(
'general', $ap)) {
116 $wysiwyg->add_plugin(
'general');
118 if ($iap || in_array(
's_script', $ap)) {
119 $wysiwyg->add_plugin(
's_script');
121 $wysiwyg->close_group();
123 $wysiwyg->open_group();
124 if ($iap || in_array(
'matrix_apply_style', $ap)) {
125 $wysiwyg->add_plugin(
'matrix_apply_style');
127 $wysiwyg->close_group();
129 if ($iap || in_array(
'justify_text', $ap)) {
130 $wysiwyg->add_plugin(
'justify_text');
132 if (($iap || in_array(
'keyword_replace', $ap)) && !empty($keywords)) {
133 $wysiwyg->add_plugin(
'keyword_replace');
134 $keyword_replace =& $wysiwyg->get_plugin(
'keyword_replace');
135 $keyword_replace->keyword_tag =
'%';
136 $keyword_replace->keywords = $keywords;
140 $snippets = $GLOBALS[
'SQ_SYSTEM']->am->getSnippetKeywords();
141 if (($iap || in_array(
'snippet_keyword_replace', $ap)) && !empty($snippets)) {
142 $wysiwyg->add_plugin(
'snippet_keyword_replace');
143 $snippet_keyword_replace =& $wysiwyg->get_plugin(
'snippet_keyword_replace');
144 $snippet_keyword_replace->keyword_tag =
'%';
145 $snippet_keyword_replace->keywords = $snippets;
148 if ($iap || in_array(
'history', $ap)) {
149 $wysiwyg->add_plugin(
'history');
151 if ($iap || in_array(
'indenting', $ap)) {
152 $wysiwyg->add_plugin(
'indenting');
154 if ($iap || in_array(
'listing', $ap)) {
155 $wysiwyg->add_plugin(
'listing');
157 if ($iap || in_array(
'table_editing', $ap)) {
158 $wysiwyg->add_plugin(
'table_editing');
160 if ($iap || in_array(
'select_color', $ap)) {
161 $wysiwyg->add_plugin(
'select_color');
164 $wysiwyg->open_group();
165 if ($iap || in_array(
'matrix_insert_link', $ap) || in_array(
'insert_link', $ap)) {
166 $wysiwyg->add_plugin(
'matrix_insert_link');
168 if ($iap || in_array(
'matrix_insert_quick_link', $ap)) {
169 $wysiwyg->add_plugin(
'matrix_insert_quick_link');
171 if ($iap || in_array(
'matrix_insert_anchor', $ap) || in_array(
'insert_anchor', $ap)) {
172 $wysiwyg->add_plugin(
'matrix_insert_anchor');
174 if ($iap || in_array(
'matrix_insert_image', $ap) || in_array(
'insert_image', $ap)) {
175 $wysiwyg->add_plugin(
'matrix_insert_image');
177 if ($iap || in_array(
'matrix_embed_movie', $ap)) {
178 $wysiwyg->add_plugin(
'matrix_embed_movie');
180 if ($iap || in_array(
'matrix_embed_youtube', $ap)) {
181 $wysiwyg->add_plugin(
'matrix_embed_youtube');
183 $wysiwyg->close_group();
185 $wysiwyg->open_group();
186 if ($iap || in_array(
'matrix_accessibility', $ap)) {
187 $wysiwyg->add_plugin(
'matrix_accessibility');
189 $wysiwyg->close_group();
192 if ($iap || in_array(
'html_tidy', $ap)) {
193 $wysiwyg->add_plugin(
'html_tidy');
196 if ($iap || in_array(
'matrix_expand_keywords', $ap)) {
197 $wysiwyg->add_plugin(
'matrix_expand_keywords');
200 $wysiwyg->open_group();
201 if ($iap || in_array(
'special_chars', $ap)) {
202 $wysiwyg->add_plugin(
'special_chars');
204 $wysiwyg->close_group();
206 $wysiwyg->open_group();
207 if ($iap || in_array(
'choose_language', $ap)) {
208 $wysiwyg->add_plugin(
'choose_language');
210 $wysiwyg->close_group();
212 $wysiwyg->open_group();
213 if ($iap || in_array(
'definition_list', $ap)) {
214 $wysiwyg->add_plugin(
'definition_list');
216 $wysiwyg->close_group();
218 $wysiwyg->open_group();
219 if ($iap || in_array(
'misc_accessibility', $ap)) {
220 $wysiwyg->add_plugin(
'misc_accessibility');
222 if ($iap || in_array(
'quotation', $ap)) {
223 $wysiwyg->add_plugin(
'quotation');
225 $wysiwyg->close_group();
227 $wysiwyg->open_group();
228 if ($iap || in_array(
'visual_aid', $ap)) {
229 $wysiwyg->add_plugin(
'visual_aid');
231 $wysiwyg->close_group();
233 $wysiwyg->open_group();
234 if ($iap || in_array(
'spell_checker', $ap)) {
235 $wysiwyg->add_plugin(
'spell_checker');
237 if ($iap || in_array(
'text_indicator', $ap)) {
238 $wysiwyg->add_plugin(
'text_indicator');
240 if ($iap || in_array(
'view_source', $ap)) {
241 $wysiwyg->add_plugin(
'view_source');
243 $wysiwyg->close_group();
245 $this->_tmp[
'wysiwg_object'] =& $wysiwyg;
250 $this->_tmp[
'wysiwg_object']->set_contents($html);
253 if(!empty($this->_tmp[
'dir_attr']))
254 $this->_tmp[
'wysiwg_object']->set_dir_attr($this->_tmp[
'dir_attr']);
256 return $this->_tmp[
'wysiwg_object'];
275 <div style=
"display:none;" id=
"<?php echo $prefix?>_wysiwyg_div"><?php echo $wysiwyg->paint(); ?></div>
276 <div
id=
"<?php echo $prefix?>_contents_div" onclick=
"editDiv=document.getElementById('<?php echo $prefix ?>_wysiwyg_div'); if (editDiv.style.display == 'none') {switchEditingMode('<?php echo $prefix ?>_contents_div','<?php echo $prefix ?>_wysiwyg_div', editor_<?php echo $prefix ?>);}"><?php echo $wysiwyg->contents ?></div>
295 Bodycopy_Edit_Fns::printBodycopyIcon(
"switchEditingMode('".$prefix.
"_contents_div','".$prefix.
"_wysiwyg_div', editor_".$prefix.
');',
'Edit Contents',
'Switch between preview and edit mode',
'edit_mode',
'[Edit Contents]');
311 require_once SQ_DATA_PATH.
'/private/conf/tools.inc';
314 if (!SQ_TOOL_HTML_TIDY_ENABLED || !file_exists(SQ_TOOL_HTML_TIDY_PATH)) {
316 Bodycopy_Edit_Fns::printBodycopyIcon(
'',
'HTMLTidy Status', translate(
'wysiwyg_htmltidy_status_disabled'),
'htmltidy_disabled',
'[HTMLTidy Status]');
319 $status = $asset->
attr(
'htmltidy_status');
320 $status_msg = translate(
'wysiwyg_htmltidy_status_wait');
321 $image_filename =
'htmltidy_'.$status;
324 $status_msg = translate(
'wysiwyg_htmltidy_status_pass');
327 $status_msg = translate(
'wysiwyg_htmltidy_status_fail');
330 $status_msg = translate(
'wysiwyg_htmltidy_status_wait');
333 Bodycopy_Edit_Fns::printBodycopyIcon(
'',
'HTMLTidy Status', $status_msg, $image_filename,
'[HTMLTidy Status]');
336 $res = (str_replace(
'
337 ',
'<br />', htmlentities($asset->
attr(
'htmltidy_errors'), ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET)));
339 $htmltidy_accessibility_filename =
'accessibility_'.(empty($res) ?
'pass' :
'fail');
340 Bodycopy_Edit_Fns::printBodycopyIcon(
'',
'HTMLTidy Accessibility', !empty($res) ? $res : translate(
'wysiwyg_htmltidy_accessibility_no_warning'), $htmltidy_accessibility_filename,
'[HTMLTidy Status]');
359 $html = $asset->
attr(
'html');
360 $html = preg_replace(
'|(<htmlarea_special[^>]*?>)(.*?)(</htmlarea_special>)|si',
'$2', $html);
363 require_once SQ_FUDGE_PATH.
'/general/text.inc';
392 if (!$asset->
writeAccess(
'attributes'))
return FALSE;
395 $html = $wysiwyg->process();
396 if ($html === FALSE)
return FALSE;
398 if (!isset($_POST[
'ees_content_no_filter'])) {
401 $html_tidy =& $wysiwyg->get_plugin(
'html_tidy');
402 if (!is_null($html_tidy)) {
403 $asset->
setAttrValue(
'htmltidy_status', $html_tidy->htmltidy_status);
404 $asset->
setAttrValue(
'htmltidy_errors', $html_tidy->htmltidy_errors);
423 $this->_tmp[
'dir_attr'] = $dir_attribute;