18 require_once SQ_ATTRIBUTES_PATH.
'/text/text.inc';
19 require_once SQ_FUDGE_PATH.
'/wysiwyg/wysiwyg.inc';
51 $wysiwyg_style = $GLOBALS[
'SQ_SYSTEM']->getUserPrefs(
'content_type_wysiwyg',
'SQ_WYSIWYG_STYLE');
53 if (is_numeric($wysiwyg_style[
'width']) && isset($wysiwyg_style[
'units'][
'width'])) {
54 $size_unit = $wysiwyg_style[
'units'][
'width'];
58 $this->_edit_params[
'style'] = $wysiwyg_style[
'body_type'];
59 $this->_edit_params[
'width'] = $wysiwyg_style[
'width'].$size_unit;
60 $this->_edit_params[
'height'] = $wysiwyg_style[
'height'].$size_unit;
61 $this->_edit_params[
'tidy_status'] =
'wait';
62 $this->_edit_params[
'tidy_errors'] =
'';
77 if (!parent::setEditParams($node))
return false;
79 if (isset($node->attributes()->style)) $this->_edit_params[
'style'] = (string)$node->attributes()->style;
80 if (isset($node->attributes()->width)) $this->_edit_params[
'width'] = (string)$node->attributes()->width;
81 if (isset($node->attributes()->height)) $this->_edit_params[
'height'] = (string)$node->attributes()->height;
99 $ap = explode(
'|', $GLOBALS[
'SQ_SYSTEM']->getUserPrefs(
'content_type_wysiwyg',
'SQ_WYSIWYG_PLUGINS'));
101 $iap = in_array(
'all', $ap);
103 $wysiwyg =
new wysiwyg($prefix, sq_web_path(
'fudge').
'/wysiwyg/');
105 $wysiwyg->set_body_type($this->_edit_params[
'style']);
106 $wysiwyg->set_init_onload(
false);
107 $wysiwyg->set_show_status_bar(
false);
108 $wysiwyg->set_width($this->_edit_params[
'width']);
109 $wysiwyg->set_height($this->_edit_params[
'height']);
113 $base_php_self = str_replace(
'/'.SQ_CONF_BACKEND_SUFFIX,
'', $_SERVER[
'PHP_SELF']);
114 $base_php_self = str_replace(
'/'.SQ_CONF_LIMBO_SUFFIX,
'', $base_php_self);
115 $base_php_self = str_replace(
'/'.SQ_CONF_NOCACHE_SUFFIX,
'', $base_php_self);
116 $base_php_self = str_replace(
'/'.SQ_CONF_RECACHE_SUFFIX,
'', $base_php_self);
117 $base_php_self = rtrim($base_php_self,
'/ ');
119 $wysiwyg->add_relative_href_check(
'(http[s]?://'.$_SERVER[
'HTTP_HOST'].
')'.$_SERVER[
'PHP_SELF'],
'$1'.$base_php_self);
120 $wysiwyg->add_relative_href_check(
'http[s]?://'.$_SERVER[
'HTTP_HOST'].$base_php_self.
'/?(\?a=[0-9]+)',
'./$1');
121 $wysiwyg->add_relative_href_check(
'([^.][^/])(\?a=[0-9]+)',
'$1./$2');
122 $wysiwyg->add_relative_href_check(
'http[s]?://'.$_SERVER[
'HTTP_HOST'].$base_php_self.
'/?%([a-zA-Z_\-0-9]+)%',
'%$1%');
123 $wysiwyg->add_absolute_url_check(
'\./\?(a=[0-9]+)',
'http://'.$_SERVER[
'HTTP_HOST'].$base_php_self.
'/?$1');
126 $em = $GLOBALS[
'SQ_SYSTEM']->getEventManager();
128 $keyword_vars = Array(
'keywords' => &$keywords);
129 $em->broadcastEvent($asset,
'requestKeywords', $keyword_vars);
131 $wysiwyg->open_group();
132 if ($iap || in_array(
'format_text', $ap)) {
133 $wysiwyg->add_plugin(
'format_text');
135 if ($iap || in_array(
'replace_text', $ap)) {
136 $wysiwyg->add_plugin(
'replace_text');
138 if ($iap || in_array(
'search_and_replace', $ap)) {
139 $wysiwyg->add_plugin(
'search_and_replace');
141 if ($iap || in_array(
'format_font', $ap)) {
142 $wysiwyg->add_plugin(
'format_font');
144 if ($iap || in_array(
'general', $ap)) {
145 $wysiwyg->add_plugin(
'general');
147 if ($iap || in_array(
's_script', $ap)) {
148 $wysiwyg->add_plugin(
's_script');
150 $wysiwyg->close_group();
152 $wysiwyg->open_group();
153 if ($iap || in_array(
'matrix_apply_style', $ap)) {
154 $wysiwyg->add_plugin(
'matrix_apply_style');
156 $wysiwyg->close_group();
158 if ($iap || in_array(
'justify_text', $ap)) {
159 $wysiwyg->add_plugin(
'justify_text');
161 if (($iap || in_array(
'keyword_replace', $ap)) && !empty($keywords)) {
162 $wysiwyg->add_plugin(
'keyword_replace');
163 $keyword_replace =& $wysiwyg->get_plugin(
'keyword_replace');
164 $keyword_replace->keyword_tag =
'%';
165 $keyword_replace->keywords = $keywords;
170 $snippets = $GLOBALS[
'SQ_SYSTEM']->am->getSnippetKeywords();
171 if ((SQ_IN_BACKEND || SQ_IN_LIMBO) && ($iap || in_array(
'snippet_keyword_replace', $ap)) && !empty($snippets)) {
172 $wysiwyg->add_plugin(
'snippet_keyword_replace');
173 $snippet_keyword_replace =& $wysiwyg->get_plugin(
'snippet_keyword_replace');
174 $snippet_keyword_replace->keyword_tag =
'%';
175 $snippet_keyword_replace->keywords = $snippets;
178 if ($iap || in_array(
'history', $ap)) {
179 $wysiwyg->add_plugin(
'history');
181 if ($iap || in_array(
'indenting', $ap)) {
182 $wysiwyg->add_plugin(
'indenting');
184 if ($iap || in_array(
'listing', $ap)) {
185 $wysiwyg->add_plugin(
'listing');
187 if ($iap || in_array(
'table_editing', $ap)) {
188 $wysiwyg->add_plugin(
'table_editing');
190 if ($iap || in_array(
'select_color', $ap)) {
191 $wysiwyg->add_plugin(
'select_color');
194 $wysiwyg->open_group();
195 if ($iap || in_array(
'matrix_insert_link', $ap) || in_array(
'insert_link', $ap)) {
196 $wysiwyg->add_plugin(
'matrix_insert_link');
198 if ($iap || in_array(
'matrix_insert_quick_link', $ap)) {
199 $wysiwyg->add_plugin(
'matrix_insert_quick_link');
201 if ($iap || in_array(
'matrix_insert_anchor', $ap) || in_array(
'insert_anchor', $ap)) {
202 $wysiwyg->add_plugin(
'matrix_insert_anchor');
204 if ($iap || in_array(
'matrix_insert_image', $ap) || in_array(
'insert_image', $ap)) {
205 $wysiwyg->add_plugin(
'matrix_insert_image');
207 if ($iap || in_array(
'matrix_embed_movie', $ap)) {
208 $wysiwyg->add_plugin(
'matrix_embed_movie');
210 if ($iap || in_array(
'matrix_embed_youtube', $ap)) {
211 $wysiwyg->add_plugin(
'matrix_embed_youtube');
213 $wysiwyg->close_group();
215 $wysiwyg->open_group();
216 if ($iap || in_array(
'matrix_accessibility', $ap)) {
217 $wysiwyg->add_plugin(
'matrix_accessibility');
219 $wysiwyg->close_group();
222 if ($iap || in_array(
'html_tidy', $ap)) {
223 $wysiwyg->add_plugin(
'html_tidy');
226 if ($iap || in_array(
'matrix_expand_keywords', $ap)) {
227 $wysiwyg->add_plugin(
'matrix_expand_keywords');
230 $wysiwyg->open_group();
231 if ($iap || in_array(
'special_chars', $ap)) {
232 $wysiwyg->add_plugin(
'special_chars');
234 $wysiwyg->close_group();
236 $wysiwyg->open_group();
237 if ($iap || in_array(
'choose_language', $ap)) {
238 $wysiwyg->add_plugin(
'choose_language');
240 $wysiwyg->close_group();
242 $wysiwyg->open_group();
243 if ($iap || in_array(
'definition_list', $ap)) {
244 $wysiwyg->add_plugin(
'definition_list');
246 $wysiwyg->close_group();
248 $wysiwyg->open_group();
249 if ($iap || in_array(
'misc_accessibility', $ap)) {
250 $wysiwyg->add_plugin(
'misc_accessibility');
252 if ($iap || in_array(
'quotation', $ap)) {
253 $wysiwyg->add_plugin(
'quotation');
255 $wysiwyg->close_group();
257 $wysiwyg->open_group();
258 if ($iap || in_array(
'visual_aid', $ap)) {
259 $wysiwyg->add_plugin(
'visual_aid');
261 $wysiwyg->close_group();
263 $wysiwyg->open_group();
264 if ($iap || in_array(
'spell_checker', $ap)) {
265 $wysiwyg->add_plugin(
'spell_checker');
267 if ($iap || in_array(
'text_indicator', $ap)) {
268 $wysiwyg->add_plugin(
'text_indicator');
270 if ($iap || in_array(
'view_source', $ap)) {
271 $wysiwyg->add_plugin(
'view_source');
273 $wysiwyg->close_group();
275 $wysiwyg->set_contents($this->value);
290 function paint($prefix, $read_only=
false)
299 if (!(SQ_IN_BACKEND || SQ_IN_LIMBO)) echo
'<script type="text/javascript" src="'.sq_web_path(
'lib').
'/js/edit.js"></script>';
302 <script
type=
"text/javascript">
303 var bodycopy_initialised =
true;
305 <div style=
"border: 1px dashed #C0C0C0;" id=
"<?php echo $prefix.'_switch_option_div'; ?>">
309 <div style=
"width: 16px; height: 16px; background: url(<?php echo sq_web_path('lib')?>/web/images/icons/edit_mode.png);background: expression('none');filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='<?php echo sq_web_path('lib')?>/web/images/icons/edit_mode.png', sizingMethod='scale'); font-size:10px; cursor:pointer;"
310 onclick=
"switchEditingMode('<?php echo $prefix; ?>_contents_div','<?php echo $prefix; ?>_wysiwyg_div', editor_<?php echo $prefix; ?>);">
319 <div style=
"border-left: 1px dashed #C0C0C0; border-right: 1px dashed #C0C0C0; border-bottom: 1px dashed #C0C0C0;">
320 <div style=
"display:none;" id=
"<?php echo $prefix?>_wysiwyg_div"><?php echo $wysiwyg->paint()?></div>
321 <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 $this->value?></div>
337 function process($prefix, $owner_id=NULL, $cmp_value=TRUE)
341 $html = $wysiwyg->process();
343 $this->processed = FALSE;
344 if ($html !== FALSE && (!$cmp_value || $html !== $this->value) && $this->
setValue($html, $owner_id)) {
345 $this->processed = TRUE;
347 $this->_edit_params[
'tidy_status'] = isset($wysiwyg->_loaded_plugins[
'html_tidy']->htmltidy_status) ? $wysiwyg->_loaded_plugins[
'html_tidy']->htmltidy_status :
'wait';
348 $this->_edit_params[
'tidy_errors'] = isset($wysiwyg->_loaded_plugins[
'html_tidy']->htmltidy_errors) ? $wysiwyg->_loaded_plugins[
'html_tidy']->htmltidy_errors :
'';
363 if (!in_array($format, Array(
'',
'disableurls',
'disablekeywords',
'disableall'))) {
367 $output = $this->value;
369 if (!in_array($format, Array(
'disableurls',
'disableall'))) {
371 preg_match_all(
'|\\./\\?a=([0-9]+)([^0-9:])|', $output, $matches);
372 $normal_assetids = empty($matches[1]) ? Array() : $matches[1];
374 preg_match_all(
'|\\./\\?a=([0-9]+:[^$]*)\\$|', $output, $matches, PREG_PATTERN_ORDER);
375 $shadow_assetids = empty($matches[1]) ? Array() : $matches[1];
376 $assetids = array_unique(array_merge($normal_assetids, $shadow_assetids));
377 $urls = $GLOBALS[
'SQ_SYSTEM']->am->getAssetUrl($assetids);
378 $output = $this->value;
379 foreach ($urls as $id => $url) {
380 if (FALSE === strpos($id,
':')) {
382 $output = str_replace(
'./?a='.$id, $url, $output);
386 $output = str_replace(
'./?a='.$id.
'$', $url, $output);
388 $output = str_replace(
'./?a='.$id.
'$',
'./?a='.$id, $output);
394 if (in_array($format, Array(
'disablekeywords',
'disableall'))) {
397 $keywords = retrieve_keywords_replacements($output);
398 foreach ($keywords as $keyword) {
399 $output = str_replace(
"%$keyword%",
"%{$keyword}%", $output);
419 if (!empty($owner_id)) {
420 $live_link_only = $GLOBALS[
'SQ_SYSTEM']->getUserPrefs(
'content_type_wysiwyg',
'SQ_LIVE_LINK_ONLY');
421 $asset_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo($owner_id);
422 if ($asset_info[$owner_id][
'status'] == SQ_STATUS_LIVE && $live_link_only) {
423 require_once SQ_FUDGE_PATH.
'/general/www.inc';
424 $outcome = check_non_live_link($value, $owner_id);
425 if ($outcome !== FALSE) $value = $outcome;
429 return parent::setValue($value);
445 require_once SQ_DATA_PATH.
'/private/conf/tools.inc';
446 require_once SQ_CORE_PACKAGE_PATH.
'/bodycopy/bodycopy/bodycopy_edit_fns.inc';
449 if (!SQ_TOOL_HTML_TIDY_ENABLED || !file_exists(SQ_TOOL_HTML_TIDY_PATH)) {
451 Bodycopy_Edit_Fns::printBodycopyIcon(
'',
'HTMLTidy Status', translate(
'wysiwyg_htmltidy_status_disabled'),
'htmltidy_disabled',
'[HTMLTidy Status]');
454 $status = $this->_edit_params[
'tidy_status'];
455 $status_msg = translate(
'wysiwyg_htmltidy_status_wait');
456 $image_filename =
'htmltidy_'.$status;
459 $status_msg = translate(
'wysiwyg_htmltidy_status_pass');
462 $status_msg = translate(
'wysiwyg_htmltidy_status_fail');
465 $status_msg = translate(
'wysiwyg_htmltidy_status_wait');
469 Bodycopy_Edit_Fns::printBodycopyIcon(
'',
'HTMLTidy Status', $status_msg, $image_filename,
'[HTMLTidy Status]');
471 $res = (str_replace(
'
472 ',
'<br />', htmlentities($this->_edit_params[
'tidy_errors'], ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET)));
474 $htmltidy_accessibility_filename =
'accessibility_'.(empty($res) ?
'pass' :
'fail');
475 Bodycopy_Edit_Fns::printBodycopyIcon(
'',
'HTMLTidy Accessibility', !empty($res) ? $res : translate(
'wysiwyg_htmltidy_accessibility_no_warning'), $htmltidy_accessibility_filename,
'[HTMLTidy Status]');