18 require_once dirname(__FILE__).
'/../../metadata_field/metadata_field_edit_fns.inc';
19 require_once SQ_ATTRIBUTES_PATH.
'/wysiwyg/wysiwyg.inc';
42 parent::__construct();
66 $prefix = $asset->
getPrefix().
'_'.$type_code;
70 $value_components = $asset->
attr(
'value_components');
73 if (is_null($value_str)) {
74 $value_str = $asset->
attr(
'default_html');
79 $wysiwyg->value = $value;
80 $styles_common =
'"float: left;';
81 $wysiwyg_container_styles = $is_default ? $styles_common.
'display:none"' : $styles_common.
'display:block"';
82 echo
'<div id="'.$prefix.
'_wysiwyg_container'.
'" style='.$wysiwyg_container_styles.
'>';
83 $wysiwyg->paint($prefix, !$write_access);
85 $default_html_container_styles = $is_default ? $styles_common.
'display:block"' : $styles_common.
'display:none"';
86 echo
'<div id="'.$prefix.
'_default_html_container'.
'" style='.$default_html_container_styles.
'>';
87 echo $asset->
attr(
'default_html');
89 echo
' <em style="color: #666">('.strtolower(translate(
'default')).
')</em>';
94 echo
'<div style="float:left">';
95 echo
' ';
96 check_box($prefix.
'_default',
'1', $is_default,
'handleMetadataWYSIWYGDefaultClickFor'.$prefix.
'()');
97 label(translate(
'use_default'), $prefix.
'_default');
99 if ($print_cascade_values_option) {
100 echo
' ';
101 check_box($prefix.
'_cascade_value',
'1', FALSE);
102 label(translate(
'cascade_value'), $prefix.
'_cascade_value');
107 <script type=
"text/javascript"><!--
109 function handleMetadataWYSIWYGDefaultClickFor<?php echo $prefix; ?>() {
110 var wysiwyg_container = document.getElementById(
'<?php echo $prefix.'_wysiwyg_container
'; ?>');
111 var default_html_container = document.getElementById(
'<?php echo $prefix.'_default_html_container
'; ?>');
112 if (wysiwyg_container.style.display ==
'block') {
113 wysiwyg_container.style.display =
'none';
114 default_html_container.style.display =
'block';
116 wysiwyg_container.style.display =
'block';
117 default_html_container.style.display =
'none';
124 return $write_access;
142 if (!$asset->
attr(
'editable'))
return FALSE;
145 $prefix = $asset->
getPrefix().
'_'.$type_code;
147 if (!empty($_POST[$prefix.
'_default'])) {
149 $new_value_str = NULL;
154 $wysiwyg->process($prefix, NULL, FALSE);
155 if ($wysiwyg->processed) {
158 if(!SQ_IN_BACKEND && !SQ_IN_LIMBO && !SQ_IN_LOGIN && !SQ_IN_CRON && !SQ_PHP_CLI) {
159 $filter_enabled = $GLOBALS[
'SQ_SYSTEM']->getUserPrefs(
'user',
'SQ_USER_FILTER_FRONT_END_INPUT');
160 if(isset($GLOBALS[
'SQ_REVERT_TO_SYSTEM_VERSION'] ) && $GLOBALS[
'SQ_REVERT_TO_SYSTEM_VERSION']) {
161 $filter_enabled = FALSE;
162 }
else if (isset($GLOBALS[
'SQ_CLONE_COMPONENTS'] ) && $GLOBALS[
'SQ_CLONE_COMPONENTS']) {
163 $filter_enabled = FALSE;
166 if ($filter_enabled && !empty($new_value_str)) {
167 $new_value_str = filter_content($new_value_str);
168 if ($new_value_str === FALSE){
169 trigger_localised_error(
'SYS0347', E_USER_WARNING, $asset->name, $asset->
type());
178 if (isset($_POST[$prefix.
'_cascade_value'])) {
179 $field_cascade_value = TRUE;
203 if (is_null($value_str)) {
204 $value_str = $asset->
attr(
'default_html');
207 return parent::generateMetadata($asset, $value_str, $tag_value, $keywords);
231 if ((
boolean)$asset->
attr(
'is_contextable') === TRUE) {
232 $value_str = $asset->
attr(
'default_html');
234 $value_str = $GLOBALS[
'SQ_SYSTEM']->am->getAttributeValuesByName(
'default_html',
'metadata_field_wysiwyg', Array($asset->id), 0);
235 $value_str = array_get_index($value_str, $asset->id,
'');
239 $value_components = Array();
243 $wysiwyg->_edit_params[
'height'] =
'100';
244 $wysiwyg->value = $value;
245 $wysiwyg->paint($prefix, !$write_access);
269 $wysiwyg->process($prefix, NULL, FALSE);
270 if ($wysiwyg->processed) {
276 $is_contextable = (boolean)$asset->
attr(
'is_contextable');
279 if ($is_contextable === TRUE) {
280 $value = $asset->
attr(
'default_html');
282 $value = $GLOBALS[
'SQ_SYSTEM']->am->getAttributeValuesByName(
'default_html',
'metadata_field_wysiwyg', Array($asset->id), 0);
283 $value = array_get_index($value, $asset->id,
'');
286 if ($value !== $new_value) {
287 if ($is_contextable === TRUE) {
294 $GLOBALS[
'SQ_SYSTEM']->changeContext(0);
296 $default_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($asset->id);
297 $default_asset->setAttrValue(
'default_html', $new_value);
298 $default_asset->saveAttributes();
299 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($default_asset);
300 unset($default_asset);
302 $GLOBALS[
'SQ_SYSTEM']->restoreContext();