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_CONTENT_TYPE_IMAGE_DEFAULTS' => Array(
37 'name' =>
'image_defaults_title',
38 'description' =>
'This preference allows you to change the default values',
40 'caption' =>
'Caption',
41 'caption_position' =>
'bottom',
42 'use_caption_attr' => FALSE,
45 'fit_dimensions' => TRUE,
46 'constrain_proportions' => TRUE,
48 'html_layout' =>
'table',
52 'SQ_CONTENT_TYPE_IMAGE_FIELDS' => Array(
53 'name' =>
'image_fields_title',
54 'description' =>
'This preference allows you to specify which fields are displayed',
56 'caption_options' => TRUE,
57 'caption_position' => TRUE,
58 'dimension_options' => TRUE,
60 'html_layout' => TRUE,
64 'SQ_CONTENT_TYPE_IMAGE_CLASSES' => Array(
65 'name' =>
'image_css_classes',
66 'description' =>
'This preference allows you to specify how the image is displayed',
68 'surrounding_container' =>
'image_table',
69 'image_table_cell' =>
'image_table_cell',
70 'caption_table_cell' =>
'caption_table_cell',
71 'image_tag' =>
'inline_image',
72 'image_div' =>
'image_div',
73 'caption_div' =>
'caption_div',
77 'SQ_CONTENT_TYPE_IMAGE_PREVIEW' => Array(
78 'name' =>
'image_preview_css_classes',
79 'description' =>
'This preference allows you to specify how the image is displayed',
81 'surrounding_container' =>
'preview_container',
82 'preview_image_table' =>
'preview_image_table',
83 'image_table_cell' =>
'image_table_cell',
84 'image_tag' =>
'preview_image',
85 'close_preview_cell' =>
'close_cell',
86 'image_div' =>
'preview_image_div',
87 'close_preview_div' =>
'close_preview_div',
101 $this->
Prefs($pref_file);
118 $is_root = $GLOBALS[
'SQ_SYSTEM']->userRoot();
119 $is_admin = ($is_root || $GLOBALS[
'SQ_SYSTEM']->userSystemAdmin());
121 $tick =
'<img src="'.sq_web_path(
'lib').
'/web/images/tick.gif" alt="Yes" style="position: relative; right: 0px;"/>';
122 $cross =
'<img src="'.sq_web_path(
'lib').
'/web/images/cross.gif" alt="Yes" />';
123 if (is_null($pref) || $pref ==
'SQ_CONTENT_TYPE_IMAGE_DEFAULTS') {
124 if (is_null($pref)) {
125 $o->openField(translate($this->pref_vars[
'SQ_CONTENT_TYPE_IMAGE_DEFAULTS'][
'name']));
127 $value_defaults = $this->pref_vars[
'SQ_CONTENT_TYPE_IMAGE_DEFAULTS'][
'default'];
129 <table
class=
"sq-backend-table" style=
"width: 350px;">
131 <td
class=
"sq-backend-table-header" nowrap=
"nowrap"><?php echo translate(
'caption'); ?>:</td>
132 <td
class=
"sq-backend-table-cell" nowrap=
"nowrap">
134 if ($have_lock && $is_admin) {
135 text_box(
'SQ_CONTENT_TYPE_IMAGE_DEFAULTS[caption]', array_get_index($value_defaults,
'caption',
''),
'30');
137 echo $value_defaults[
'caption'];
143 <td
class=
"sq-backend-table-header" nowrap=
"nowrap"><?php echo translate(
'caption_position'); ?>:</td>
144 <td
class=
"sq-backend-table-cell" nowrap=
"nowrap">
146 if ($have_lock && $is_admin) {
147 combo_box(
'SQ_CONTENT_TYPE_IMAGE_DEFAULTS[caption_position]', Array(
'bottom' =>
'Bottom',
'top' =>
'Top'), FALSE, array_get_index($value_defaults,
'caption_position',
''));
149 echo ucwords($value_defaults[
'caption_position']);
155 <td
class=
"sq-backend-table-header" nowrap=
"nowrap"><?php echo translate(
'use_caption_attribute'); ?>:</td>
156 <td
class=
"sq-backend-table-cell" nowrap=
"nowrap">
158 if ($have_lock && $is_admin) {
159 check_box(
'SQ_CONTENT_TYPE_IMAGE_DEFAULTS[use_caption_attr]',
'1', array_get_index($value_defaults,
'use_caption_attr', FALSE));
161 echo ($value_defaults[
'use_caption_attr'] == TRUE) ? $tick : $cross;
167 <td
class=
"sq-backend-table-header" nowrap=
"nowrap"><?php echo translate(
'width'); ?>:</td>
168 <td
class=
"sq-backend-table-cell" nowrap=
"nowrap">
170 if ($have_lock && $is_admin) {
171 text_box(
'SQ_CONTENT_TYPE_IMAGE_DEFAULTS[width]', array_get_index($value_defaults,
'width',
''),
'10');
173 echo $value_defaults[
'width'];
179 <td
class=
"sq-backend-table-header" nowrap=
"nowrap"><?php echo translate(
'height'); ?>:</td>
180 <td
class=
"sq-backend-table-cell" nowrap=
"nowrap">
182 if ($have_lock && $is_admin) {
183 text_box(
'SQ_CONTENT_TYPE_IMAGE_DEFAULTS[height]', array_get_index($value_defaults,
'height',
''),
'10');
185 echo $value_defaults[
'height'];
191 <td
class=
"sq-backend-table-header" nowrap=
"nowrap"><?php echo translate(
'constrain_proportions'); ?>:</td>
192 <td
class=
"sq-backend-table-cell" nowrap=
"nowrap">
194 if ($have_lock && $is_admin) {
195 check_box(
'SQ_CONTENT_TYPE_IMAGE_DEFAULTS[constrain_proportions]',
'1', array_get_index($value_defaults,
'constrain_proportions', FALSE));
197 echo (array_get_index($value_defaults,
'constrain_proportions', FALSE) == TRUE) ? $tick : $cross;
203 <td
class=
"sq-backend-table-header" nowrap=
"nowrap"><?php echo translate(
'fit_dimensions'); ?>:</td>
204 <td
class=
"sq-backend-table-cell" nowrap=
"nowrap">
206 if ($have_lock && $is_admin) {
207 check_box(
'SQ_CONTENT_TYPE_IMAGE_DEFAULTS[fit_dimensions]',
'1', array_get_index($value_defaults,
'fit_dimensions', FALSE));
209 echo (array_get_index($value_defaults,
'fit_dimensions', FALSE) == TRUE) ? $tick : $cross;
215 <td
class=
"sq-backend-table-header" nowrap=
"nowrap"><?php echo translate(
'on_click'); ?>:</td>
216 <td
class=
"sq-backend-table-cell" nowrap=
"nowrap">
218 if ($have_lock && $is_admin) {
219 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'content_type_image');
221 $onclick = $dummy_asset->getAttribute(
'on_click');
222 $onclick->value = $value_defaults[
'on_click'];
223 $onclick->paint(
'content_type_image_on_click');
225 echo ucwords($value_defaults[
'on_click']);
231 <td
class=
"sq-backend-table-header" nowrap=
"nowrap"><?php echo translate(
'html_layout'); ?>:</td>
232 <td
class=
"sq-backend-table-cell" nowrap=
"nowrap">
234 if ($have_lock && $is_admin) {
235 combo_box(
'SQ_CONTENT_TYPE_IMAGE_DEFAULTS[html_layout]', Array(
'table' =>
'Table',
'div' =>
'Div'), FALSE, array_get_index($value_defaults,
'html_layout',
''));
237 echo ucwords($value_defaults[
'html_layout']);
244 if (is_null($pref)) $o->closeField();
246 if (is_null($pref) || $pref ==
'SQ_CONTENT_TYPE_IMAGE_FIELDS') {
247 if (is_null($pref)) {
248 $o->openField(translate($this->pref_vars[
'SQ_CONTENT_TYPE_IMAGE_FIELDS'][
'name']));
250 $fields = $this->pref_vars[
'SQ_CONTENT_TYPE_IMAGE_FIELDS'][
'default'];
252 <table
class=
"sq-backend-table" style=
"width: 200px;">
254 foreach ($fields as $field_name => $value) {
257 <td
class=
"sq-backend-table-cell" nowrap=
"nowrap">
259 if ($have_lock && $is_admin) {
260 check_box(
'SQ_CONTENT_TYPE_IMAGE_FIELDS['.$field_name.
']',
'1', $value,
'',
'id="image_content_'.$field_name.
'"');
261 label(ucwords(str_replace(
'_',
' ', $field_name)),
'image_content_'.$field_name);
263 echo ($value == TRUE) ? $tick : $cross;
267 echo ucwords(str_replace(
'_',
' ', $field_name));
278 if (is_null($pref)) $o->closeField();
279 if (is_null($pref) || $pref ==
'SQ_CONTENT_TYPE_IMAGE_CLASSES') {
280 if (is_null($pref)) {
281 $o->openField(translate($this->pref_vars[
'SQ_CONTENT_TYPE_IMAGE_CLASSES'][
'name']));
283 $classes = $this->pref_vars[
'SQ_CONTENT_TYPE_IMAGE_CLASSES'][
'default'];
285 <table
class=
"sq-backend-table" style=
"width: 350px;">
287 foreach ($classes as $name => $class) {
290 <td
class=
"sq-backend-table-header"><?php echo ucwords(str_replace(
'_',
' ', $name)); ?></td>
291 <td
class=
"sq-backend-table-cell" nowrap=
"nowrap">
293 if ($have_lock && $is_admin) {
294 text_box(
'SQ_CONTENT_TYPE_IMAGE_CLASSES['.$name.
']', $class);
307 if (is_null($pref)) $o->closeField();
309 if (is_null($pref) || $pref ==
'SQ_CONTENT_TYPE_IMAGE_PREVIEW') {
310 if (is_null($pref)) {
311 $o->openField(translate($this->pref_vars[
'SQ_CONTENT_TYPE_IMAGE_PREVIEW'][
'name']));
313 $classes = $this->pref_vars[
'SQ_CONTENT_TYPE_IMAGE_PREVIEW'][
'default'];
315 <table
class=
"sq-backend-table" style=
"width: 350px;">
317 foreach ($classes as $name => $class) {
320 <td
class=
"sq-backend-table-header"><?php echo ucwords(str_replace(
'_',
' ', $name)); ?></td>
321 <td
class=
"sq-backend-table-cell" nowrap=
"nowrap">
323 if ($have_lock && $is_admin) {
324 text_box(
'SQ_CONTENT_TYPE_IMAGE_PREVIEW['.$name.
']', $class);
337 if (is_null($pref)) $o->closeField();
357 $is_root = $GLOBALS[
'SQ_SYSTEM']->userRoot();
358 $is_admin = ($is_root || $GLOBALS[
'SQ_SYSTEM']->userSystemAdmin());
359 if (!$is_admin)
return FALSE;
361 if (is_null($pref) || $pref ==
'SQ_CONTENT_TYPE_IMAGE_DEFAULTS') {
362 $posted_values = $_POST[
'SQ_CONTENT_TYPE_IMAGE_DEFAULTS'];
363 if (!isset($posted_values[
'use_caption_attr'])) {
364 $posted_values[
'use_caption_attr'] = FALSE;
366 if (!isset($posted_values[
'fit_dimensions'])) {
367 $posted_values[
'fit_dimensions'] = FALSE;
369 if (!isset($posted_values[
'constrain_proportions'])) {
370 $posted_values[
'constrain_proportions'] = FALSE;
372 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'content_type_image');
374 $onclick = $dummy_asset->getAttribute(
'on_click');
375 $onclick->process(
'content_type_image_on_click');
376 $posted_values[
'on_click'] = $onclick->value;
377 $this->pref_vars[
'SQ_CONTENT_TYPE_IMAGE_DEFAULTS'][
'default'] = $posted_values;
379 if (is_null($pref) || $pref ==
'SQ_CONTENT_TYPE_IMAGE_FIELDS') {
380 foreach ($this->pref_vars[
'SQ_CONTENT_TYPE_IMAGE_FIELDS'][
'default'] as $name => $val) {
381 $this->pref_vars[
'SQ_CONTENT_TYPE_IMAGE_FIELDS'][
'default'][$name] = isset($_POST[
'SQ_CONTENT_TYPE_IMAGE_FIELDS'][$name]);
384 if (is_null($pref) || $pref ==
'SQ_CONTENT_TYPE_IMAGE_CLASSES') {
385 $this->pref_vars[
'SQ_CONTENT_TYPE_IMAGE_CLASSES'][
'default'] = $_POST[
'SQ_CONTENT_TYPE_IMAGE_CLASSES'];
387 if (is_null($pref) || $pref ==
'SQ_CONTENT_TYPE_IMAGE_PREVIEW') {
388 $this->pref_vars[
'SQ_CONTENT_TYPE_IMAGE_PREVIEW'][
'default'] = $_POST[
'SQ_CONTENT_TYPE_IMAGE_PREVIEW'];