18 require_once SQ_CORE_PACKAGE_PATH.
'/designs/design_css/design_css_edit_fns.inc';
41 parent::__construct();
42 $this->static_screens[
'details'][
'lock_type'] =
'all';
59 $customised_areas = $asset->getCustomisedAreas();
60 if (empty($customised_areas)) {
61 echo translate(
'core_design_customisation_no_design_areas_customised');
63 $this->
_paintDesignAreaList($customised_areas, translate(
'core_remove_customisation_question'), $prefix.
'_remove_customisation', $asset->writeAccess(
'links'), TRUE, TRUE);
81 if (empty($_POST[$prefix.
'_remove_customisation'])) {
85 $parent_design = $asset->getParentDesign();
86 if (is_null($parent_design))
return FALSE;
90 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
91 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
93 foreach ($_POST[$prefix.
'_remove_customisation'] as $id_name) {
94 $parents_link = $parent_design->getDesignAreaLink($id_name);
95 if (empty($parents_link))
continue;
97 $data[$id_name] = Array($parents_link[
'minorid'], $parents_link[
'minor_type_code']);
101 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
102 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
106 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
107 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
111 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
113 'assetid' => $asset->id,
114 'parentid' => $parent_design->id,
116 $hh->queueHipo(
'hipo_job_regenerate_design', $vars);
135 $uncustomised_areas = $asset->getUnCustomisedAreas();
136 if (empty($uncustomised_areas)) {
137 echo translate(
'core_design_customisation_all_design_areas_customised');
139 $this->
_paintDesignAreaList($uncustomised_areas, translate(
'core_customise_question'), $prefix.
'_customise', $asset->writeAccess(
'links'));
157 if (empty($_POST[$prefix.
'_customise']))
return FALSE;
161 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
162 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
165 foreach ($_POST[$prefix.
'_customise'] as $id_name) {
166 $link = $asset->getDesignAreaLink($id_name);
167 if (is_null($link))
continue;
168 $da = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code'], FALSE);
169 if (is_null($da))
continue;
171 $create_link = Array (
173 'link_type' => SQ_LINK_TYPE_3,
174 'value' => $link[
'value'],
175 'sort_order' => NULL,
180 $GLOBALS[
'SQ_SYSTEM']->am->acquireLock($da->id,
'all');
183 $clone = $GLOBALS[
'SQ_SYSTEM']->am->cloneAsset($da, $create_link, $map, Array(
'attributes',
'permissions',
'roles'), TRUE);
185 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($da->id,
'all');
186 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($clone->id,
'all');
188 if (is_null($clone)) {
189 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
190 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
194 $data[$id_name] = Array($clone->id, $clone->type());
199 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
200 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
204 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
205 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
224 $existing_ids = Array();
225 $existing = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_3,
'file', FALSE);
226 foreach ($existing as $link) {
227 $existing_ids[$link[
'minorid']] = $link[
'linkid'];
229 $existing_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(array_keys($existing_ids));
230 foreach ($existing_info as $assetid => $existing_info) {
232 if ($existing_info[
'name'] == strtolower($info[
'name'])) {
233 $linkid = $existing_ids[$assetid];
234 $asset->deleteExistingLink($linkid);
237 $minor_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid);
238 $minor_asset->updateLookups();
239 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($minor_asset);
243 return parent::_processUploadedFile($asset, $info);
261 $da_links = $asset->getDesignAreaLink();
262 $old_da_ids = Array();
263 foreach ($da_links as $da_link) {
264 $id_name = $da_link[
'value'];
266 if (empty($data[$id_name]))
continue;
270 if ($data[$id_name][0] == $da_link[
'minorid']) {
274 $old_da_ids[] = $da_link[
'minorid'];
277 if (!$asset->
deleteLink($da_link[
'linkid'])) {
282 $existing_link = $GLOBALS[
'SQ_SYSTEM']->am->getLinkByAsset($asset->id, $data[$id_name][0]);
283 if (empty($existing_link)) {
285 $da = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($data[$id_name][0], $data[$id_name][1]);
286 if (is_null($da))
return FALSE;
287 if (!$asset->
createLink($da, SQ_LINK_TYPE_3, $id_name, NULL,
'1')) {
293 if (isset($asset->_tmp[
'design_areas'])) {
294 unset($asset->_tmp[
'design_areas'][$id_name]);
300 $customisation_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_2,
'design_css_customisation', TRUE,
'major',
'customisation');
301 foreach ($customisation_links as $customisation_link) {
302 $customisation = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($customisation_link[
'minorid'], $customisation_link[
'minor_type_code']);
303 if (is_null($customisation))
continue;
309 $cust_update_data = $data;
310 foreach ($customisation->getCustomisedAreas() as $link) {
311 if (isset($cust_update_data[$link[
'value']])) {
312 if (!in_array($link[
'minorid'], $old_da_ids)) {
315 unset($cust_update_data[$link[
'value']]);
341 protected function _paintDesignAreaList(Array $links, $check_box_col, $check_box_name, $write_access, $link_name=FALSE)
343 $am = $GLOBALS[
'SQ_SYSTEM']->am;
345 <table
class=
"sq-backend-table">
347 <th
class=
"sq-backend-table-header" width=
"33%"><?php echo translate(
'type'); ?></th>
348 <th
class=
"sq-backend-table-header" width=
"33%"><?php echo translate(
'core_design_area'); ?></th>
352 <th
class=
"sq-backend-table-header" width=
"34%" style=
"text-align: center;"><?php echo $check_box_col; ?></th>
358 uasort($links, Array(get_class($this),
'linkCompare'));
360 foreach ($links as $link) {
361 $da = $am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
363 if ($da->attr(
'id_name') ==
'') {
364 trigger_localised_error(
'CORE0154', E_USER_NOTICE, $da->id);
365 foreach ($links as $link) {
366 if ($link[
'minorid'] == $da->id) {
367 if (!empty($link[
'value'])) {
368 $da->setAttrValue(
'id_name', $link[
'value']);
369 $da->saveAttributes();
371 trigger_localised_error(
'CORE0149', E_USER_WARNING, $da->id);
378 if (is_null($da))
continue;
381 <td
class=
"sq-backend-table-cell">
383 if ($current_type != $da->type()) {
384 $current_type = $da->type();
385 echo
'<i>', substr($current_type, 12),
'</i>';
391 <td
class=
"sq-backend-table-cell" style=
"white-space: nowrap;">
394 echo get_asset_tag_line($da->id,
'details');
396 echo get_asset_tag_line($da->id,
'');
403 <td
class=
"sq-backend-table-cell" style=
"text-align: center;">
404 <input type=
"checkbox" name=
"<?php echo $check_box_name; ?>[]" value=
"<?php echo $da->attr('id_name');; ?>">
432 if ($c = strcmp($a[
'minor_type_code'], $b[
'minor_type_code'])) {
436 return strcmp(strtolower($a[
'value']), strtolower($b[
'value']));