17 require_once SQ_CORE_PACKAGE_PATH.
'/lookup_value/lookup_value.inc';
43 return 'Paint Layout';
57 return 'paint_layout';
83 public static function paintInterface(&$owner, &$o, $lookups, $lookup_values, $prefix)
85 $wa = ($owner->writeAccess(
'lookups') && $owner->writeAccess(
'links'));
88 $o->openSection(translate(
'asset_definitions'));
90 if (!empty($lookup_values)) {
91 $o->openField(translate(
'summary'));
93 <table
class=
"sq-backend-table">
95 <td
class=
"sq-backend-table-header"><?php echo translate(
'url'); ?></td>
96 <td
class=
"sq-backend-table-header"><?php echo
'Effective Paint Layout'; ?></td>
99 foreach ($lookups as $url) {
101 if (empty($lookup_values[$url][$name_prefix.
'::system::frontend'])) {
102 $lookup_values[$url][$name_prefix.
'::system::frontend'] = Array(
'value' =>
'',
'inhd' =>
'0');
105 foreach ($lookup_values[$url] as $layout_name => $data) {
108 preg_match(
'/^'.$name_prefix.
'::(system|user)::(.*)$/', $layout_name, $matches);
111 $lookup_values[$url][$layout_name][
'type'] = $matches[1];
112 $lookup_values[$url][$layout_name][
'code'] = $matches[2];
115 if ($matches[1] ===
'user')
continue;
117 $effective_layout = $data[
'value'];
119 $override_suffix =
'';
121 if (isset($lookup_values[$url.
'/'])) {
122 foreach ($lookup_values[$url.
'/'] as $override_layout_name => $override_data) {
123 $effective_layout = $override_data[
'value'];
124 $effective_layout_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(Array($effective_layout));
126 $suffix =
' - <strong style="font-size:11px"><i>'.translate(
'override').
'</i></strong>';
128 $effective_layout_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(Array($effective_layout));
129 $suffix = self::_getSuffix($data[
'inhd'], FALSE);
134 <td
class=
"sq-backend-table-cell"><?php echo $url; ?></td>
135 <td
class=
"sq-backend-table-cell"><?php echo !empty($effective_layout_info) ? get_asset_tag_line($effective_layout).$suffix :
'<i>'.translate(
'none').
'</i>'; ?></td>
146 $asset_layout = $GLOBALS[
'SQ_SYSTEM']->am->getLink($owner->id, SQ_LINK_NOTICE,
'paint_layout_page', FALSE,
'paint_layout::system::frontend');
147 $o->openField(translate(
'layout'));
149 asset_finder($prefix.
'[asset][paint_layout][value]', empty($asset_layout[
'minorid']) ?
'' : $asset_layout[
'minorid'], Array(
'paint_layout_page' =>
'D'),
'sq_sidenav', FALSE,
'null', empty($asset_layout) ? Array(
'clear') : Array(
'clear',
'reset'));
151 echo empty($asset_layout) ?
'<i>'.translate(
'none').
'</i>' : get_asset_tag_line($asset_layout[
'minorid']);
155 $asset_override = $GLOBALS[
'SQ_SYSTEM']->am->getLink($owner->id, SQ_LINK_NOTICE,
'paint_layout_page', FALSE,
'override::paint_layout::system::frontend');
156 $o->openField(translate(
'override_layout'));
158 asset_finder($prefix.
'[asset][override::paint_layout][value]', empty($asset_override) ?
'' : $asset_override[
'minorid'], Array(
'paint_layout_page' =>
'D'),
'sq_sidenav', FALSE,
'null', empty($asset_override) ? Array(
'clear') : Array(
'clear',
'reset'));
160 echo empty($asset_override) ?
'<i>'.translate(
'none').
'</i>' : get_asset_tag_line($asset_override[
'minorid']);
162 $design_info = $owner->getDesignLookups();
163 if (empty($design_info) && !empty($lookup_values)) {
164 echo
'<br/><span style="color:#FF0000">'.translate(
'asset_has_no_design').
'</span>';
176 $lookups_user = Array();
178 $o->openSection(translate(
'url_specific_definitions'));
179 foreach ($lookups as $url) {
181 $o->openSection($url);
182 $o->openField(translate(
'current'));
184 <table
class=
"sq-backend-table">
186 <td
class=
"sq-backend-table-header"><?php echo
'Layout'; ?></td>
187 <td
class=
"sq-backend-table-header"><?php echo
'Paint Layout'; ?></td>
191 if (!isset($lookup_values[$url])) {
192 $lookup_values[$url] = Array(0);
195 foreach ($lookup_values[$url] as $layout_name => $data) {
196 if ($data[
'type'] ===
'user') {
198 $lookups_user[] = $url;
202 $layout_name = empty($layout_name) ?
'paint_layout::system::frontend' : $layout_name;
204 $display_name = translate(
'defined_layout_display', empty($data[
'type']) ? translate(
'system') : ucwords($data[
'type']), ucwords(str_replace(
'_',
' ', $data[
'code'])));
205 $display_override_name = translate(
'defined_override_layout_display', empty($data[
'type']) ? translate(
'system') : ucwords($data[
'type']), ucwords(str_replace(
'_',
' ', $data[
'code'])));
208 hidden_field($prefix.
'['.$url.
']['.$layout_name.
'][value][original]', $data[
'value']);
210 $url_override_layout = 0;
211 $url_override_info = Array();
213 if (isset($lookup_values[$url.
'/'])) {
214 foreach ($lookup_values[$url.
'/'] as $override_layout_name => $override_data) {
215 $url_override_layout = $override_data[
'value'];
216 $url_override_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(Array($url_override_layout));
221 if (!empty($asset_layout) && isset($asset_layout[
'minorid']) && ($asset_layout[
'minorid'] === $data[
'value'])) {
223 $url_layout_info =
'0';
225 $layout_value = $data[
'value'];
226 $url_layout_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(Array($data[
'value']));
228 if (!empty($asset_override) && isset($asset_override[
'minorid']) && ($asset_override[
'minorid'] === $url_override_layout)) {
229 $url_override_layout =
'0';
230 $url_override_info =
'0';
232 hidden_field($prefix.
'['.$url.
'/]['.$layout_name.
'][value][original]', $url_override_layout);
235 $normal_buttons = empty($layout_value) ? Array(
'clear') : Array(
'reset');
237 $normal_buttons = empty($layout_value) ? Array(
'clear') : Array(
'clear',
'reset');
239 $override_buttons = empty($url_override_layout) ? Array(
'clear') : Array(
'clear',
'reset');
243 <td
class=
"sq-backend-table-cell"><?php echo
'<i>'.$display_name.
'</i>'; echo $wa ? self::_getSuffix($data[
'inhd'], TRUE) :
''; ?></td>
245 <td
class=
"sq-backend-table-cell"><?php asset_finder($prefix.
'['.$url.
']['.$layout_name.
'][value]', $layout_value, Array(
'paint_layout_page' =>
'D'),
'sq_sidenav', FALSE,
'null', $normal_buttons);?></td>
247 <td
class=
"sq-backend-table-cell"><?php echo empty($url_layout_info) ?
'<i>'.translate(
'not_customised').
'</i>' : get_asset_tag_line($layout_value).self::_getSuffix($data[
'inhd'], FALSE); ?></td>
251 <td
class=
"sq-backend-table-cell"><?php echo
'<i>'.$display_override_name.
'</i>'; ?></td>
253 <td
class=
"sq-backend-table-cell"><?php asset_finder($prefix.
'['.$url.
'/]['.$layout_name.
'][value]', $url_override_layout, Array(
'paint_layout_page' =>
'D'),
'sq_sidenav', FALSE,
'null', $override_buttons);?></td>
255 <td
class=
"sq-backend-table-cell"><?php echo empty($url_override_info) ?
'<i>'.translate(
'not_customised').
'</i>': get_asset_tag_line($url_override_layout); ?></td>
261 unset($lookup_values[$url][$layout_name]);
262 if (empty($lookup_values[$url])) {
264 $lookup_values[$url][$name_prefix.
'::user::'] = Array();
281 $o->openSection(translate(
'user_defined_layouts'));
283 foreach ($lookups as $url) {
285 $o->openSection($url);
287 $o->openField(translate(
'current'));
288 if (in_array($url, $lookups_user)) {
290 <table
class=
"sq-backend-table">
292 <td
class=
"sq-backend-table-header"><?php echo
'Layout code'; ?></td>
293 <td
class=
"sq-backend-table-header"><?php echo
'Paint layout'; ?></td>
296 foreach ($lookup_values[$url] as $layout_name => $data) {
297 $effective_layout_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(Array($data[
'value']));
298 $buttons = Array(
'reset');
299 if (!$data[
'inhd']) $buttons[] =
'clear';
303 <td
class=
"sq-backend-table-cell"><?php echo $data[
'inhd'] ? $data[
'code'] : text_box($prefix.
'['.$url.
']['.$layout_name.
'][name]', $data[
'code'], 20, 30).self::_getSuffix($data[
'inhd'], TRUE); ?></td>
305 <td
class=
"sq-backend-table-cell"><?php echo $data[
'code']; ?></td>
308 <td
class=
"sq-backend-table-cell"><?php echo $data[
'inhd'] ? get_asset_tag_line($data[
'value']).self::_getSuffix($data[
'inhd'], FALSE) : asset_finder($prefix.
'['.$url.
']['.$layout_name.
'][value]', $data[
'value'], Array(
'paint_layout_page' =>
'D'),
'sq_sidenav', FALSE,
'null', $buttons);?></td>
310 <td
class=
"sq-backend-table-cell"><?php echo empty($effective_layout_info) ? translate(
'none') : get_asset_tag_line($data[
'value']).self::_getSuffix($data[
'inhd'], FALSE); ?></td>
321 echo
'<i>'.translate(
'none').
'</i>';
326 $o->openSection(translate(
'create_user_defined_layout'));
327 $o->openField(translate(
'layout_code'));
328 text_box($prefix.
'['.$url.
']['.$name_prefix.
'::user::][name]',
'', 20, 30);
329 $o->openField(translate(
'new_question'));
330 asset_finder($prefix.
'['.$url.
']['.$name_prefix.
'::user::][value]', 0, Array(
'paint_layout_page' =>
'D'),
'sq_sidenav', FALSE,
'null', Array(
'clear'));
358 private static function _getSuffix($inhd, $parentheses)
361 return $inhd ?
' <strong style="font-size:11px"><i>('.translate(
'inherited').
')</i></strong>' :
'';
363 return $inhd ?
' - <strong style="font-size:11px"><i>'.translate(
'inherited').
'</i></strong>' :
'';
392 if (!isset($_POST[$prefix]) || !is_array($_POST[$prefix])) {
396 $lookup_values = Array();
399 foreach ($_POST[$prefix] as $resource => $layouts) {
401 foreach ($layouts as $layout_name => $layout_data) {
402 if ($layout_name === $name_prefix.
'::user::') {
404 if (empty($layout_data[
'name']))
continue;
405 if (empty($layout_data[
'value'][
'assetid']))
continue;
406 $layout_name .= strtolower($layout_data[
'name']);
407 if (isset($lookup_values[$resource][$layout_name])) {
408 trigger_error(
'Layout Name "'.$layout_data[
'name'].
'" already in use for "'.$resource.
'"', E_USER_WARNING);
411 }
else if (!is_bool(strstr($layout_name, $name_prefix.
'::user::'))) {
414 $new_layout_name = $name_prefix.
'::user::'.strtolower($layout_data[
'name']);
417 if (empty($layout_data[
'name'])) {
418 $lookup_values[$resource][$layout_name][
'value'] =
'';
423 if ($new_layout_name !== $layout_name) {
424 if (isset($_POST[$prefix][$resource][$new_layout_name])) {
425 trigger_error(
'Layout Name "'.$new_layout_name.
'" already in use for "'.$resource.
'"', E_USER_WARNING);
428 $lookup_values[$resource][$layout_name][
'value'] =
'';
430 $layout_name = $new_layout_name;
431 }
else if (!is_bool(strstr($layout_name, $name_prefix.
'::system::frontend'))) {
434 if ($layout_data[
'value'][
'assetid'] === $layout_data[
'value'][
'original']) {
441 if (preg_match(
'/.+\/$/', $resource)) {
443 if (isset($_POST[$prefix][
'asset'][
'override::paint_layout'][
'value'][
'assetid']) && (empty($layout_data[
'value'][
'assetid']))) {
444 if ($layout_data[
'value'][
'original'] === $_POST[$prefix][
'asset'][
'override::paint_layout'][
'value'][
'assetid']) {
450 if (isset($_POST[$prefix][
'asset'][
'paint_layout'][
'value'][
'assetid']) && (empty($layout_data[
'value'][
'assetid']))) {
451 if ($layout_data[
'value'][
'original'] === $_POST[$prefix][
'asset'][
'paint_layout'][
'value'][
'assetid']) {
460 if (empty($layout_data[
'value'][
'assetid'])) {
462 $lookup_values[$resource][$layout_name][
'value'] =
'';
465 $layout = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($layout_data[
'value'][
'assetid']);
467 $lookup_values[$resource][$layout_name][
'value'] = $layout_data[
'value'][
'assetid'];
469 trigger_error(
'Assetid provided, #'.$layout_data[
'value'][
'assetid'].
', is not of asset type Paint Layout Page', E_USER_WARNING);