18 require_once SQ_CORE_PACKAGE_PATH.
'/content_type/content_type_edit_fns.inc';
41 parent::__construct();
57 if ($asset->writeAccess(
'attributes')) {
58 $size = $GLOBALS[
'SQ_SYSTEM']->getUserPrefs($asset->type(),
'SQ_CODE_EDITOR_SIZE');
59 $html = $asset->attr(
'edit_content');
60 $html = str_replace(
'<?php',
'<?php', $html);
61 $html = str_replace(
'<script',
'<script', $html);
62 text_area($prefix.
'_html', $html,
'',
'', 0,
'style="width: '.$size[
'width'].
'; height: '.$size[
'height'].
'; font-family: \'Courier New\', Courier, monospace; display: block"');
63 $line_number_prefs = $GLOBALS[
'SQ_SYSTEM']->getUserPrefs($asset->type(),
'SQ_CODE_EDITOR_LINE_NUMBERS');
64 $current_line_settings = $asset->attr(
'line_numbers');
65 foreach ($current_line_settings as $name => $value) {
66 $line_number_prefs[$name] = $value;
69 <table
class=
"sq-backend-table" style=
"width: 350px;">
71 <td
class=
"sq-backend-table-header" nowrap=
"nowrap" style=
"width: 100px;">
72 <?php echo translate(
'show_line_numbers'); ?>
74 <td
class=
"sq-backend-table-cell" style=
"width: 100%;">
76 check_box($prefix.
'_show_line_numbers',
'1', $line_number_prefs[
'use_line_numbers']);
81 <td
class=
"sq-backend-table-header" nowrap=
"nowrap" style=
"width: 100px;">
82 <?php echo translate(
'line_number_orientation'); ?>
84 <td
class=
"sq-backend-table-cell" style=
"width: 100%;">
86 radio_button($prefix.
'_line_number_left',
'left', $line_number_prefs[
'line_number_left'] == TRUE);
87 label(translate(
'left'), $prefix.
'_line_number_left');
88 radio_button($prefix.
'_line_number_left',
'right', $line_number_prefs[
'line_number_left'] == FALSE);
89 label(translate(
'right'), $prefix.
'_line_number_left');
94 <td
class=
"sq-backend-table-header" nowrap=
"nowrap" style=
"width: 100px;">
95 <?php echo translate(
'line_number_style'); ?>
97 <td
class=
"sq-backend-table-cell" style=
"width: 100%;">
99 combo_box($prefix.
'_line_style', Array(
'span'=>
'Span',
'list'=>
'List'), FALSE, $line_number_prefs[
'line_number_style']);
104 <td
class=
"sq-backend-table-header" nowrap=
"nowrap" style=
"width: 100px;">
105 <?php echo translate(
'line_number_class'); ?>
107 <td
class=
"sq-backend-table-cell" style=
"width: 100%;">
109 text_box($prefix.
'_line_class', $line_number_prefs[
'line_number_class']);
133 if ($asset->writeAccess(
'attributes')) {
134 $line_number_prefs = $GLOBALS[
'SQ_SYSTEM']->getUserPrefs($asset->type(),
'SQ_CODE_EDITOR_LINE_NUMBERS');
135 $new_line_data = Array();
137 if (isset($_POST[$prefix.
'_show_line_numbers']) != $line_number_prefs[
'use_line_numbers']) {
138 $new_line_data[
'use_line_numbers'] = isset($_POST[$prefix.
'_show_line_numbers']);
141 if (isset($_POST[$prefix.
'_line_number_left']) && $_POST[$prefix.
'_line_number_left'] ==
'left') {
144 if ($side != $line_number_prefs[
'line_number_left']) {
145 $new_line_data[
'line_number_left'] = $side;
147 if (isset($_POST[$prefix.
'_line_style']) && $_POST[$prefix.
'_line_style'] != $line_number_prefs[
'line_number_style']) {
148 $new_line_data[
'line_number_style'] = $_POST[$prefix.
'_line_style'];
150 $new_line_data[
'line_number_style'] =
'span';
152 $new_line_data[
'line_number_class'] =
'';
153 if (isset($_POST[$prefix.
'_line_class']) && $_POST[$prefix.
'_line_class'] != $line_number_prefs[
'line_number_class']) {
154 $new_line_data[
'line_number_class'] = $_POST[$prefix.
'_line_class'];
156 $asset->setAttrValue(
'line_numbers', $new_line_data);
158 if (isset($_POST[$prefix.
'_html'])) {
159 $html = $_POST[$prefix.
'_html'];
161 $asset->setAttrValue(
'edit_content', str_replace(Array(
'<script',
'<?php'), Array(
'<script',
'<?php'), $html));
163 $html = $asset->syntaxHighlight($html);
165 $current_html = $asset->attr(
'html');
166 if ($html != $current_html) {
167 if (!$asset->setAttrValue(
'html', $html))
return FALSE;
172 return $asset->writeAccess(
'attributes');
187 function paint(&$asset, $editing=FALSE, $generating=FALSE)
191 $output = $asset->attr(
'html');
194 require_once SQ_FUDGE_PATH.
'/general/text.inc';