17 require_once SQ_LIB_PATH.
'/config/prefs.inc';
18 require_once SQ_ATTRIBUTES_PATH.
'/css_dimension/css_dimension.inc';
19 require_once SQ_ATTRIBUTES_PATH.
'/int/int.inc';
20 require_once SQ_ATTRIBUTES_PATH.
'/boolean/boolean.inc';
21 require_once SQ_ATTRIBUTES_PATH.
'/url/url.inc';
24 if (!defined(
'SQ_COMMENT_HTML_ALLOW')) {
25 define (
'SQ_COMMENT_HTML_ALLOW', 0);
28 if (!defined(
'SQ_COMMENT_HTML_ESCAPE')) {
29 define (
'SQ_COMMENT_HTML_ESCAPE', 1);
32 if (!defined(
'SQ_COMMENT_HTML_STRIP')) {
33 define (
'SQ_COMMENT_HTML_STRIP', 2);
58 var $pref_vars = Array(
59 'SQ_COMMENT_INPUT_SIZE' => Array(
60 'name' =>
'comment_pref_input_size',
61 'description' =>
'This preference allows you to change the size of the Comment Input Box',
68 'SQ_COMMENT_MAX_LENGTH' => Array(
69 'name' =>
'comment_pref_max_length',
70 'description' =>
'This preferences allows you to set the maximum number of characters that can be entered in the Comment Input Box',
74 'SQ_COMMENT_HTML_CONF' => Array(
75 'name' =>
'comment_pref_html_conf_label',
76 'description' =>
'Determines whether HTML is allowed, escaped or removed',
77 'default' => SQ_COMMENT_HTML_ESCAPE,
80 'SQ_COMMENT_MAX_RATING' => Array(
81 'name' =>
'maximum_rating',
82 'description' =>
'This preference sets the upper bound for ratings',
86 'SQ_COMMENT_IMG_RATED' => Array(
87 'name' =>
'rated_image',
88 'description' =>
'Rated Image to be used instead of the default',
92 'SQ_COMMENT_IMG_BLANK' => Array(
93 'name' =>
'blank_image',
94 'description' =>
'Blank Image to be used instead of the default',
98 'SQ_COMMENT_DISABLE_KEYWORD_REPLACEMENTS' => Array(
99 'name' =>
'comment_disable_keyword_replacements',
100 'description' =>
'Whether to replace the keywords in the comment',
102 'protected' => FALSE,
112 var $css_dimension_width;
121 var $css_dimension_height;
151 var $html_conf_options = Array();
160 $this->
Prefs($pref_file);
168 $this->int_max_length->setParam(
'allow_negative', FALSE);
172 $this->int_max_rating->setParam(
'allow_negative', FALSE);
173 $this->int_max_rating->setParam(
'allow_empty', FALSE);
176 $this->url_processor->_edit_params[
'protocols'] = Array(
'http',
'https');
177 $this->url_processor->_edit_params[
'width'] =
'60';
179 $this->disable_keyword_replacements = Array(
184 $this->html_conf_options = Array(
185 SQ_COMMENT_HTML_ALLOW => translate(
'allow'),
186 SQ_COMMENT_HTML_ESCAPE => translate(
'escape'),
187 SQ_COMMENT_HTML_STRIP => translate(
'strip'),
205 $is_root = $GLOBALS[
'SQ_SYSTEM']->userRoot();
206 $is_admin = ($is_root || $GLOBALS[
'SQ_SYSTEM']->userSystemAdmin());
207 $print_sub_title = TRUE;
208 if (!is_null($pref)) $print_sub_title = FALSE;
210 $prefs = array_keys($this->pref_vars);
211 if (!is_null($pref) && in_array($pref, array_keys($this->pref_vars))) {
212 $prefs = Array($pref);
215 foreach ($prefs as $pref_value) {
216 $fn =
'paint'.str_replace(
' ',
'', ucwords(str_replace(
'_',
' ', strtolower($pref_value)))).
'Backend';
217 if (!method_exists($this, $fn))
continue;
220 if (is_null($pref) || $pref == $pref_value) {
221 $this->$fn($o, $have_lock, $pref_value, $print_sub_title, $is_root, $is_admin);
243 if ($print_sub_title) {
244 $o->openField(translate($this->pref_vars[
'SQ_COMMENT_INPUT_SIZE'][
'name']));
246 $o->openField(
' ');
249 $comment_size = $this->pref_vars[
'SQ_COMMENT_INPUT_SIZE'][
'default'];
251 ?><table
class=
"sq-backend-table" style=
"width: 350px;">
253 <td
class=
"sq-backend-table-header" nowrap=
"nowrap"><?php echo translate(
'width') ?></td>
254 <td
class=
"sq-backend-table-cell" style=
"width: 100%;">
256 if ($have_lock && $is_admin) {
257 $this->css_dimension_width->paint($pref_name.
'_width', $have_lock, $comment_size[
'width']);
259 echo $comment_size[
'width'];
265 <td
class=
"sq-backend-table-header" nowrap=
"nowrap"><?php echo translate(
'height') ?></td>
266 <td
class=
"sq-backend-table-cell" style=
"width: 100%;">
268 if ($have_lock && $is_admin) {
269 $this->css_dimension_height->paint($pref_name.
'_height', $have_lock, $comment_size[
'height']);
271 echo $comment_size[
'height'];
298 if ($print_sub_title) {
299 $o->openField(translate($this->pref_vars[
'SQ_COMMENT_MAX_LENGTH'][
'name']));
301 $o->openField(
' ');
304 $comment_length = $this->pref_vars[
'SQ_COMMENT_MAX_LENGTH'][
'default'];
306 if ($have_lock && $is_admin) {
307 $this->int_max_length->value = $comment_length;
308 $this->int_max_length->paint($pref_name.
'_max_length', !$have_lock);
310 echo $comment_length;
312 $o->note(translate(
'comment_pref_max_length_note'));
334 if ($print_sub_title) {
335 $o->openField(translate($this->pref_vars[$pref_name][
'name']));
337 $o->openField(
' ');
340 $current_conf = $this->pref_vars[$pref_name][
'default'];
342 $readonly = !($have_lock && $is_admin);
345 echo array_get_index($this->html_conf_options, $current_conf);
347 combo_box($pref_name, $this->html_conf_options, FALSE, $current_conf);
370 if ($print_sub_title) {
371 $o->openField(translate($this->pref_vars[$pref_name][
'name']));
373 $o->openField(
' ');
376 $current_conf = $this->pref_vars[$pref_name][
'default'];
378 $readonly = !($have_lock && $is_admin);
381 echo array_get_index($this->disable_keyword_replacements, $current_conf);
383 combo_box($pref_name, $this->disable_keyword_replacements, FALSE, $current_conf);
406 if ($print_sub_title) {
407 $o->openField(translate($this->pref_vars[$pref_name][
'name']));
409 $o->openField(
' ');
412 $max_rating = $this->pref_vars[$pref_name][
'default'];
414 $readonly = !($have_lock && $is_admin);
416 $this->int_max_rating->value = $max_rating;
417 $this->int_max_rating->paint($pref_name, $readonly);
436 $is_root = $GLOBALS[
'SQ_SYSTEM']->userRoot();
437 $is_admin = ($is_root || $GLOBALS[
'SQ_SYSTEM']->userSystemAdmin());
438 if (!$is_admin || !$have_lock) {
442 $prefs = array_keys($this->pref_vars);
443 if (!is_null($pref) && in_array($pref, array_keys($this->pref_vars))) {
444 $prefs = Array($pref);
449 foreach ($prefs as $pref) {
450 $fn =
'process'.str_replace(
' ',
'', ucwords(str_replace(
'_',
' ', strtolower($pref)))).
'Backend';
451 if (!method_exists($this, $fn))
continue;
454 if (!$this->$fn($o, $have_lock, $pref, $is_root, $is_admin)) {
478 if (isset($_POST[$pref.
'_width']) && isset($_POST[$pref.
'_height'])) {
480 $this->css_dimension_width->process($pref.
'_width');
481 $this->css_dimension_height->process($pref.
'_height');
483 $this->pref_vars[
'SQ_COMMENT_INPUT_SIZE'][
'default'][
'width'] = $this->css_dimension_width->getContent();
484 $this->pref_vars[
'SQ_COMMENT_INPUT_SIZE'][
'default'][
'height'] = $this->css_dimension_height->getContent();
507 if (isset($_POST[$pref.
'_max_length'])) {
509 $this->int_max_length->process($pref.
'_max_length');
510 $this->pref_vars[
'SQ_COMMENT_MAX_LENGTH'][
'default'] = $this->int_max_length->value;
533 $new_setting = array_get_index($_POST, $pref);
535 if (!is_null($new_setting)) {
536 $this->pref_vars[$pref][
'default'] = $new_setting;
559 $new_setting = array_get_index($_POST, $pref);
561 if (!is_null($new_setting)) {
562 $this->pref_vars[$pref][
'default'] = $new_setting;
585 $this->int_max_rating->process($pref);
586 if (!$this->int_max_rating->processed)
return FALSE;
588 $this->pref_vars[$pref][
'default'] = $this->int_max_rating->value;
610 if ($print_sub_title) {
611 $o->openField(translate($this->pref_vars[$pref_name][
'name']));
613 $o->openField(
' ');
616 $current_setting = $this->pref_vars[$pref_name][
'default'];
618 $read_only = !($have_lock && $is_admin);
620 $image_location_prefix = sq_web_path(
'data').
'/asset_types/comment/files';
622 if (empty($current_setting)) {
623 $current_image = sq_web_path(
'data').
'/asset_types/comment/files/star.png';
625 $current_image = $current_setting;
628 echo
'Current Image: <img src="'.htmlspecialchars($current_image).
'" />';
631 $url = $this->url_processor;
632 $url->value = $current_setting;
633 $url->paint($pref_name, $read_only);
637 $o->note($this->pref_vars[$pref_name][
'description']);
638 $o->note(
'Empty means default');
660 $url = $this->url_processor;
662 $url->process($pref);
663 $new_setting = $url->value;
665 $this->pref_vars[$pref][
'default'] = $new_setting;
687 if ($print_sub_title) {
688 $o->openField(translate($this->pref_vars[$pref_name][
'name']));
690 $o->openField(
' ');
693 $current_setting = $this->pref_vars[$pref_name][
'default'];
695 $read_only = !($have_lock && $is_admin);
697 $image_location_prefix = sq_web_path(
'data').
'/asset_types/comment/files';
699 if (empty($current_setting)) {
700 $current_image = sq_web_path(
'data').
'/asset_types/comment/files/star_grey.png';
702 $current_image = $current_setting;
705 echo
'Current Image: <img src="'.htmlspecialchars($current_image).
'" />';
708 $url = $this->url_processor;
709 $url->value = $current_setting;
710 $url->paint($pref_name, $read_only);
713 $o->note($this->pref_vars[$pref_name][
'description']);
714 $o->note(
'Empty means default');
736 $url = $this->url_processor;
738 $url->process($pref);
739 $new_setting = $url->value;
741 $this->pref_vars[$pref][
'default'] = $new_setting;