18 require_once SQ_LIB_PATH.
'/config/prefs.inc';
33 public $pref_vars = Array(
34 'SQ_DEFAULT_CONTENT_TYPE' => Array(
35 'name' =>
'default_content_type',
36 'description' =>
'When bodycopy containers are created they will have this content type by default',
37 'default' =>
'content_type_wysiwyg',
40 'SQ_DEFAULT_PRESENTATION_TYPE' => Array(
41 'name' =>
'default_presentation_type',
42 'description' =>
'When bodycopy containers are created they will have this presentation type by default',
46 'SQ_DIV_DISABLE_CREATE' => Array(
47 'name' =>
'div_disable_create',
48 'description' =>
'If bodycopy containers are disabled for creating, they can not be created in Edit Content Screen',
52 'SQ_DIV_DISABLE_DELETE' => Array(
53 'name' =>
'div_disable_delete',
54 'description' =>
'If bodycopy containers are disabled for deleting, they can not be deleted in Edit Content Screen',
67 parent::__construct($pref_file);
84 $is_root = $GLOBALS[
'SQ_SYSTEM']->userRoot();
85 $is_admin = ($is_root || $GLOBALS[
'SQ_SYSTEM']->userSystemAdmin());
87 if (is_null($pref) || $pref ==
'SQ_DEFAULT_CONTENT_TYPE') {
89 $o->
openField(translate($this->pref_vars[
'SQ_DEFAULT_CONTENT_TYPE'][
'name']));
92 $default_content_type = $this->pref_vars[
'SQ_DEFAULT_CONTENT_TYPE'][
'default'];
94 $all_content_types = $GLOBALS[
'SQ_SYSTEM']->am->getTypeDescendants(
'content_type');
97 $markdown_key = array_search(
'content_type_markdown', $all_content_types);
98 if ($markdown_key !== FALSE) {
99 $disable_markdown = TRUE;
100 require_once SQ_DATA_PATH.
'/private/conf/tools.inc';
101 if (SQ_TOOL_MARKDOWN_ENABLED && is_file(SQ_TOOL_MARKDOWN_PATH)) {
102 include_once SQ_TOOL_MARKDOWN_PATH;
103 if (function_exists(
'Markdown')) {
104 $disable_markdown = FALSE;
107 if ($disable_markdown) {
108 unset($all_content_types[$markdown_key]);
112 $content_type_names = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($all_content_types,
'name');
113 combo_box(
'prefs[SQ_DEFAULT_CONTENT_TYPE]', $content_type_names, FALSE, $default_content_type);
114 echo
'<div class="sq-backend-note">'.translate(
'default_content_type_note').
'</div>';
116 echo $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($default_content_type,
'name');
122 if (is_null($pref) || $pref ==
'SQ_DEFAULT_PRESENTATION_TYPE') {
123 if (is_null($pref)) {
124 $o->
openField(translate($this->pref_vars[
'SQ_DEFAULT_PRESENTATION_TYPE'][
'name']));
127 $default_pres_type = $this->pref_vars[
'SQ_DEFAULT_PRESENTATION_TYPE'][
'default'];
128 $possible_types = Array(
129 'div' => translate(
'block-level'),
130 'span' => translate(
'inline'),
131 'none' => translate(
'raw_html'),
135 combo_box(
'prefs[SQ_DEFAULT_PRESENTATION_TYPE]', $possible_types, FALSE, $default_pres_type);
136 echo
'<div class="sq-backend-note">'.translate(
'default_presentation_type_note').
'</div>';
138 echo $possible_types[$default_pres_type];
145 if (is_null($pref) || $pref ==
'SQ_DIV_DISABLE_CREATE') {
146 if (is_null($pref)) {
147 $o->
openField(translate($this->pref_vars[
'SQ_DIV_DISABLE_CREATE'][
'name']));
149 $div_disable_create = $this->pref_vars[
'SQ_DIV_DISABLE_CREATE'][
'default'];
151 <table
class=
"sq-backend-table" style=
"width: 100px;">
153 <td
class=
"sq-backend-table-header" nowrap=
"nowrap">
155 echo translate(
'disable');
158 <td
class=
"sq-backend-table-cell" style=
"width: 100%;">
160 if ($have_lock && $is_admin) {
161 combo_box(
'prefs[SQ_DIV_DISABLE_CREATE][default]', Array(
'yes' =>
'Yes',
'no' =>
'No'), FALSE, $div_disable_create);
163 echo ucfirst($div_disable_create);
170 $o->
note(translate(
'div_disable_create_note'));
176 if (is_null($pref) || $pref ==
'SQ_DIV_DISABLE_DELETE') {
177 if (is_null($pref)) {
178 $o->
openField(translate($this->pref_vars[
'SQ_DIV_DISABLE_DELETE'][
'name']));
180 $div_disable_delete = $this->pref_vars[
'SQ_DIV_DISABLE_DELETE'][
'default'];
182 <table
class=
"sq-backend-table" style=
"width: 100px;">
184 <td
class=
"sq-backend-table-header" nowrap=
"nowrap">
186 echo translate(
'disable');
189 <td
class=
"sq-backend-table-cell" style=
"width: 100%;">
191 if ($have_lock && $is_admin) {
192 combo_box(
'prefs[SQ_DIV_DISABLE_DELETE][default]', Array(
'yes' =>
'Yes',
'no' =>
'No'), FALSE, $div_disable_delete);
194 echo ucfirst($div_disable_delete);
201 $o->
note(translate(
'div_disable_delete_note'));
225 $is_root = $GLOBALS[
'SQ_SYSTEM']->userRoot();
226 $is_admin = ($is_root || $GLOBALS[
'SQ_SYSTEM']->userSystemAdmin());
227 if (!$is_admin)
return FALSE;
229 if (is_null($pref) || $pref ==
'SQ_DEFAULT_CONTENT_TYPE') {
230 if (isset($_POST[
'prefs'][
'SQ_DEFAULT_CONTENT_TYPE'])) {
231 $this->pref_vars[
'SQ_DEFAULT_CONTENT_TYPE'][
'default'] = $_POST[
'prefs'][
'SQ_DEFAULT_CONTENT_TYPE'];
235 if (is_null($pref) || $pref ==
'SQ_DEFAULT_PRESENTATION_TYPE') {
236 if (isset($_POST[
'prefs'][
'SQ_DEFAULT_PRESENTATION_TYPE'])) {
237 $this->pref_vars[
'SQ_DEFAULT_PRESENTATION_TYPE'][
'default'] = $_POST[
'prefs'][
'SQ_DEFAULT_PRESENTATION_TYPE'];
242 if (is_null($pref) || $pref ==
'SQ_DIV_DISABLE_CREATE') {
243 if (isset($_POST[
'prefs'][
'SQ_DIV_DISABLE_CREATE'])) {
244 $this->pref_vars[
'SQ_DIV_DISABLE_CREATE'][
'default'] = $_POST[
'prefs'][
'SQ_DIV_DISABLE_CREATE'][
'default'];
249 if (is_null($pref) || $pref ==
'SQ_DIV_DISABLE_DELETE') {
250 if (isset($_POST[
'prefs'][
'SQ_DIV_DISABLE_DELETE'])) {
251 $this->pref_vars[
'SQ_DIV_DISABLE_DELETE'][
'default'] = $_POST[
'prefs'][
'SQ_DIV_DISABLE_DELETE'][
'default'];
271 $merged_prefs = Array();
272 $pref_vars = Array(
'SQ_DEFAULT_CONTENT_TYPE');
274 foreach ($pref_vars as $var_name) {
275 if (isset($prefs1[$var_name]) && !isset($prefs2[$var_name])) {
277 $merged_prefs[$var_name] = $prefs1[$var_name];
278 }
else if (isset($prefs2[$var_name]) && !isset($prefs1[$var_name])) {
280 $merged_prefs[$var_name] = $prefs2[$var_name];
281 }
else if (isset($prefs1[$var_name]) && isset($prefs2[$var_name])) {
284 case 'SQ_DEFAULT_CONTENT_TYPE' :
286 if ($prefs1[$var_name] ==
'content_type_wysiwyg') {
287 $merged_prefs[$var_name] = $prefs2[$var_name];
289 $merged_prefs[$var_name] = $prefs1[$var_name];
294 $merged_prefs[$var_name][
'name'] = $prefs1[$var_name][
'name'];
295 $merged_prefs[$var_name][
'description'] = $prefs1[$var_name][
'description'];
296 $merged_prefs[$var_name][
'protected'] = ($prefs1[$var_name][
'protected'] || $prefs2[$var_name][
'protected']);
300 return $merged_prefs;