18 require_once SQ_CORE_PACKAGE_PATH.
'/designs/design/design_edit_fns.inc';
41 parent::__construct();
42 $this->static_screens[
'details'][
'lock_type'] =
'all';
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);
81 if (empty($_POST[$prefix.
'_remove_customisation'])) {
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,
'design');
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);
136 if (empty($uncustomised_areas)) {
137 echo translate(
'core_design_customisation_all_design_areas_customised');
157 if (empty($_POST[$prefix.
'_customise']))
return FALSE;
161 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
162 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
164 foreach ($_POST[$prefix.
'_customise'] as $id_name) {
166 if (is_null($link))
continue;
167 $da = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code'], FALSE);
168 if (is_null($da))
continue;
170 $create_link = Array (
172 'link_type' => SQ_LINK_TYPE_3,
173 'value' => $link[
'value'],
174 'sort_order' => NULL,
178 $GLOBALS[
'SQ_SYSTEM']->am->acquireLock($da->id,
'all');
181 $clone = $GLOBALS[
'SQ_SYSTEM']->am->cloneAsset($da, $create_link, $map, Array(
'attributes',
'permissions',
'roles'), TRUE);
182 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($da->id,
'all');
183 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($clone->id,
'all');
184 if (is_null($clone)) {
185 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
186 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
190 $data[$id_name] = Array($clone->id, $clone->type());
195 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
196 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
200 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
201 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
204 $GLOBALS[
'SQ_SYSTEM']->am->acquireLock($asset->id,
'links');
224 $existing_ids = Array();
225 $existing = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_3,
'file', FALSE);
227 foreach ($existing as $link) {
228 $existing_ids[$link[
'minorid']] = $link[
'linkid'];
230 $existing_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(array_keys($existing_ids));
231 foreach ($existing_info as $id => $existing_info) {
233 $new_file_name = make_valid_web_paths(Array($info[
'name']));
234 $new_file_name = array_shift($new_file_name);
236 if ($existing_info[
'name'] == $new_file_name) {
237 $linkid = $existing_ids[$id];
241 $minor_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($id);
243 $asset->deleteExistingLink($linkid);
249 return parent::_processUploadedFile($asset, $info);
267 $da_links = $asset->getDesignAreaLink();
268 $old_da_ids = Array();
269 foreach ($da_links as $da_link) {
270 $id_name = $da_link[
'value'];
272 if (empty($data[$id_name]))
continue;
276 if ($data[$id_name][0] == $da_link[
'minorid']) {
280 $old_da_ids[] = $da_link[
'minorid'];
283 if (!$asset->
deleteLink($da_link[
'linkid'])) {
288 $existing_link = $GLOBALS[
'SQ_SYSTEM']->am->getLinkByAsset($asset->id, $data[$id_name][0]);
289 if (empty($existing_link)) {
291 $da = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($data[$id_name][0], $data[$id_name][1]);
292 if (is_null($da))
return FALSE;
293 if (!$asset->
createLink($da, SQ_LINK_TYPE_3, $id_name, NULL,
'1')) {
299 if (isset($asset->_tmp[
'design_areas'])) {
300 unset($asset->_tmp[
'design_areas'][$id_name]);
306 $customisation_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_2,
'design_customisation', TRUE,
'major',
'customisation');
307 foreach ($customisation_links as $customisation_link) {
308 $customisation = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($customisation_link[
'minorid'], $customisation_link[
'minor_type_code']);
309 if (is_null($customisation))
continue;
315 $cust_update_data = $data;
316 foreach ($customisation->getCustomisedAreas() as $link) {
317 if (isset($cust_update_data[$link[
'value']])) {
318 if (!in_array($link[
'minorid'], $old_da_ids)) {
321 unset($cust_update_data[$link[
'value']]);
347 protected function _paintDesignAreaList(Array $links, $check_box_col, $check_box_name, $write_access, $link_name=FALSE)
349 $am = $GLOBALS[
'SQ_SYSTEM']->am;
351 <table
class=
"sq-backend-table">
353 <th
class=
"sq-backend-table-header" width=
"33%"><?php echo translate(
'type'); ?></th>
354 <th
class=
"sq-backend-table-header" width=
"33%"><?php echo translate(
'core_design_area'); ?></th>
358 <th
class=
"sq-backend-table-header" width=
"34%" style=
"text-align: center;"><?php echo $check_box_col; ?></th>
364 uasort($links, Array(get_class($this),
'linkCompare'));
366 foreach ($links as $link) {
367 $da = $am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
369 if ($da->attr(
'id_name') ==
'') {
370 trigger_localised_error(
'CORE0154', E_USER_NOTICE, $da->id);
371 foreach ($links as $link) {
372 if ($link[
'minorid'] == $da->id) {
373 if (!empty($link[
'value'])) {
374 $da->setAttrValue(
'id_name', $link[
'value']);
375 $da->saveAttributes();
377 trigger_localised_error(
'CORE0149', $da->id, E_USER_WARNING);
384 if (is_null($da))
continue;
387 <td
class=
"sq-backend-table-cell">
389 if ($current_type != $da->type()) {
390 $current_type = $da->type();
391 echo
'<i>', substr($current_type, 12),
'</i>';
397 <td
class=
"sq-backend-table-cell" style=
"white-space: nowrap;">
400 echo get_asset_tag_line($da->id,
'details');
402 echo $da->name.
' (Id: #'.$da->id.
')';
409 <td
class=
"sq-backend-table-cell" style=
"text-align: center;">
410 <input type=
"checkbox" name=
"<?php echo $check_box_name; ?>[]" value=
"<?php echo $da->attr('id_name');; ?>">
438 if ($c = strcmp($a[
'minor_type_code'], $b[
'minor_type_code'])) {
442 return strcmp(strtolower($a[
'value']), strtolower($b[
'value']));