18 require_once SQ_LIB_PATH.
'/config/prefs.inc';
19 require_once SQ_ATTRIBUTES_PATH.
'/css_dimension/css_dimension.inc';
35 var $pref_vars = Array (
36 'SQ_CODE_EDITOR_SIZE' => Array(
37 'name' =>
'code_editor_size',
38 'description' =>
'This preference allows you to change the size of the Raw HTML editor',
39 'default' => Array(
'width' =>
'400',
'height' =>
'400'),
42 'SQ_CODE_EDITOR_HTML_CLASSES' => Array(
43 'name' =>
'html_code_classes',
44 'description' =>
'Changes the CSS classes used to display the code of Highlighted HTML',
46 'attribute_names' =>
'html_attribute',
47 'attribute_value' =>
'html_attribute_values',
48 'tag_brackets' =>
'html_tag_brackets',
49 'tag_name' =>
'html_tag_names',
50 'html_comment' =>
'html_comment',
54 'SQ_CODE_EDITOR_PHP_CLASSES' => Array(
55 'name' =>
'php_code_classes',
56 'description' =>
'Changes the CSS classes used to display the code of Highlighted PHP',
58 'background' =>
'php_background',
59 'default' =>
'php_default',
61 'comment' =>
'php_comment',
62 'keyword' =>
'php_keyword',
63 'string' =>
'php_string',
67 'SQ_CODE_EDITOR_JS_CLASSES' => Array(
68 'name' =>
'javascript_code_classes',
69 'description' =>
'Changes the CSS classes used to display the code of Highlighted Javascript',
71 'reserved' =>
'js_reserved',
72 'function' =>
'js_function',
73 'brackets' =>
'js_brackets',
74 'comment' =>
'js_comment',
75 'default' =>
'js_default',
76 'string' =>
'js_string',
80 'SQ_CODE_EDITOR_LINE_NUMBERS' => Array(
81 'name' =>
'line_numbers',
82 'description' =>
'Whether to use line numbers, and what options to use',
84 'use_line_numbers' => FALSE,
85 'line_number_left' => TRUE,
86 'line_number_style' =>
'span',
87 'line_number_class' =>
'line_numbers',
92 var $css_dimension_width;
93 var $css_dimension_height;
102 $this->
Prefs($pref_file);
121 $is_root = $GLOBALS[
'SQ_SYSTEM']->userRoot();
122 $is_admin = ($is_root || $GLOBALS[
'SQ_SYSTEM']->userSystemAdmin());
125 if (is_null($pref) || $pref ==
'SQ_CODE_EDITOR_SIZE') {
126 if (is_null($pref)) {
127 $o->openField(translate($this->pref_vars[
'SQ_CODE_EDITOR_SIZE'][
'name']));
129 $code_editor_size = $this->pref_vars[
'SQ_CODE_EDITOR_SIZE'][
'default'];
131 <table
class=
"sq-backend-table" style=
"width: 350px;">
133 <td
class=
"sq-backend-table-header" nowrap=
"nowrap"><?php echo translate(
'width') ?></td>
134 <td
class=
"sq-backend-table-cell" style=
"width: 100%;">
136 if ($have_lock && $is_admin) {
137 $this->css_dimension_width->paint(
'code_width', $have_lock, $code_editor_size[
'width']);
139 echo $code_editor_size[
'width'];
145 <td
class=
"sq-backend-table-header" nowrap=
"nowrap"><?php echo translate(
'height') ?></td>
146 <td
class=
"sq-backend-table-cell" style=
"width: 100%;">
148 if ($have_lock && $is_admin) {
149 $this->css_dimension_height->paint(
'code_height', $have_lock, $code_editor_size[
'height']);
151 echo $code_editor_size[
'height'];
158 if (is_null($pref)) $o->closeField();
162 if (is_null($pref)) {
163 $o->openField(translate($this->pref_vars[
'SQ_CODE_EDITOR_HTML_CLASSES'][
'name']));
165 if (is_null($pref) || $pref ==
'SQ_CODE_EDITOR_HTML_CLASSES') {
166 $html_classes = $this->pref_vars[
'SQ_CODE_EDITOR_HTML_CLASSES'][
'default'];
168 <table
class=
"sq-backend-table" style=
"width: 350px;">
170 foreach ($html_classes as $class_name => $choice) {
173 <td
class=
"sq-backend-table-header" nowrap=
"nowrap" style=
"width: 100px;">
174 <?php echo ucwords(str_replace(
'_',
' ', $class_name)); ?>
176 <td
class=
"sq-backend-table-cell" style=
"width: 100%;">
178 if ($have_lock && $is_admin) {
179 text_box(
'SQ_CODE_EDITOR_HTML_CLASSES['.$class_name.
']', $choice);
191 if (is_null($pref)) $o->closeField();
193 if (is_null($pref)) {
194 $o->openField(translate($this->pref_vars[
'SQ_CODE_EDITOR_PHP_CLASSES'][
'name']));
197 if (is_null($pref) || $pref ==
'SQ_CODE_EDITOR_PHP_CLASSES') {
198 $php_classes = $this->pref_vars[
'SQ_CODE_EDITOR_PHP_CLASSES'][
'default'];
200 <table
class=
"sq-backend-table" style=
"width: 350px;">
202 foreach ($php_classes as $class_name => $choice) {
205 <td
class=
"sq-backend-table-header" nowrap=
"nowrap" style=
"width: 100px;">
206 <?php echo ucwords(str_replace(
'_',
' ', $class_name)); ?>
208 <td
class=
"sq-backend-table-cell" style=
"width: 100%;">
210 if ($have_lock && $is_admin) {
211 text_box(
'SQ_CODE_EDITOR_PHP_CLASSES['.$class_name.
']', $choice);
223 if (is_null($pref)) $o->closeField();
225 if (is_null($pref)) {
226 $o->openField(translate($this->pref_vars[
'SQ_CODE_EDITOR_JS_CLASSES'][
'name']));
228 if (is_null($pref) || $pref ==
'SQ_CODE_EDITOR_JS_CLASSES') {
229 $js_classes = $this->pref_vars[
'SQ_CODE_EDITOR_JS_CLASSES'][
'default'];
231 <table
class=
"sq-backend-table" style=
"width: 350px;">
233 foreach ($js_classes as $class_name => $choice) {
236 <td
class=
"sq-backend-table-header" nowrap=
"nowrap" style=
"width: 100px;">
237 <?php echo ucwords(str_replace(
'_',
' ', $class_name)); ?>
239 <td
class=
"sq-backend-table-cell" style=
"width: 100%;">
241 if ($have_lock && $is_admin) {
242 text_box(
'SQ_CODE_EDITOR_JS_CLASSES['.$class_name.
']', $choice);
257 if (is_null($pref)) {
258 $o->openField(translate($this->pref_vars[
'SQ_CODE_EDITOR_LINE_NUMBERS'][
'name']));
260 if (is_null($pref) || $pref ==
'SQ_CODE_EDITOR_LINE_NUMBERS') {
261 $line_prefs = $this->pref_vars[
'SQ_CODE_EDITOR_LINE_NUMBERS'][
'default'];
263 <table
class=
"sq-backend-table" style=
"width: 350px;">
265 <td
class=
"sq-backend-table-header" nowrap=
"nowrap" style=
"width: 100px;">
266 <?php echo translate(
'show_line_numbers'); ?>
268 <td
class=
"sq-backend-table-cell" style=
"width: 100%;">
270 if ($have_lock && $is_admin) {
271 check_box(
'SQ_CODE_show_line_numbers',
'1', $line_prefs[
'use_line_numbers']);
273 echo ($line_prefs[
'use_line_numbers'] == TRUE) ? translate(
'yes') : translate(
'no');
279 <td
class=
"sq-backend-table-header" nowrap=
"nowrap" style=
"width: 100px;">
280 <?php echo translate(
'line_number_orientation'); ?>
282 <td
class=
"sq-backend-table-cell" style=
"width: 100%;">
284 if ($have_lock && $is_admin) {
285 radio_button(
'SQ_CODE_line_number_left',
'left', $line_prefs[
'line_number_left'] == TRUE);
286 label(translate(
'left'),
'SQ_CODE_line_number_left');
287 radio_button(
'SQ_CODE_line_number_left',
'right', $line_prefs[
'line_number_left'] == FALSE);
288 label(translate(
'right'),
'SQ_CODE_line_number_left');
290 echo ($line_prefs[
'line_number_left'] == TRUE) ? translate(
'left') : translate(
'right');
296 <td
class=
"sq-backend-table-header" nowrap=
"nowrap" style=
"width: 100px;">
297 <?php echo translate(
'line_number_style'); ?>
299 <td
class=
"sq-backend-table-cell" style=
"width: 100%;">
301 if ($have_lock && $is_admin) {
302 combo_box(
'SQ_CODE_line_style', Array(
'span'=>
'Span',
'list'=>
'List'), FALSE, $line_prefs[
'line_number_style']);
304 echo ucwords($line_prefs[
'line_number_style']);
310 <td
class=
"sq-backend-table-header" nowrap=
"nowrap" style=
"width: 100px;">
311 <?php echo translate(
'line_number_class'); ?>
313 <td
class=
"sq-backend-table-cell" style=
"width: 100%;">
315 if ($have_lock && $is_admin) {
316 text_box(
'SQ_CODE_line_class', $line_prefs[
'line_number_class']);
318 echo $line_prefs[
'line_number_class'];
326 if (is_null($pref)) $o->closeField();
345 $is_root = $GLOBALS[
'SQ_SYSTEM']->userRoot();
346 $is_admin = ($is_root || $GLOBALS[
'SQ_SYSTEM']->userSystemAdmin());
347 if (!$is_admin)
return FALSE;
348 if (is_null($pref) || $pref ==
'SQ_CODE_EDITOR_SIZE') {
349 $this->css_dimension_width->process(
'code_width');
350 $this->css_dimension_height->process(
'code_height');
351 $this->pref_vars[
'SQ_CODE_EDITOR_SIZE'][
'default'][
'width'] = $this->css_dimension_width->getContent();
352 $this->pref_vars[
'SQ_CODE_EDITOR_SIZE'][
'default'][
'height'] = $this->css_dimension_height->getContent();
355 if (is_null($pref) || $pref ==
'SQ_CODE_EDITOR_HTML_CLASSES') {
356 $this->pref_vars[
'SQ_CODE_EDITOR_HTML_CLASSES'][
'default'] = $_POST[
'SQ_CODE_EDITOR_HTML_CLASSES'];
358 if (is_null($pref) || $pref ==
'SQ_CODE_EDITOR_PHP_CLASSES') {
359 $this->pref_vars[
'SQ_CODE_EDITOR_PHP_CLASSES'][
'default'] = $_POST[
'SQ_CODE_EDITOR_PHP_CLASSES'];
361 if (is_null($pref) || $pref ==
'SQ_CODE_EDITOR_JS_CLASSES') {
362 $this->pref_vars[
'SQ_CODE_EDITOR_JS_CLASSES'][
'default'] = $_POST[
'SQ_CODE_EDITOR_JS_CLASSES'];
364 if (is_null($pref) || $pref ==
'SQ_CODE_EDITOR_LINE_NUMBERS') {
365 $line_prefs = $this->pref_vars[
'SQ_CODE_EDITOR_LINE_NUMBERS'][
'default'];
366 $line_prefs[
'use_line_numbers'] = isset($_POST[
'SQ_CODE_show_line_numbers']);
367 $line_prefs[
'line_number_style'] = $_POST[
'SQ_CODE_line_style'];
368 $line_prefs[
'line_number_class'] = $_POST[
'SQ_CODE_line_class'];
369 $line_prefs[
'line_number_left'] = ($_POST[
'SQ_CODE_line_number_left'] ==
'right') ? FALSE : TRUE;
370 $this->pref_vars[
'SQ_CODE_EDITOR_LINE_NUMBERS'][
'default'] = $line_prefs;