18 require_once SQ_CORE_PACKAGE_PATH.
'/designs/design_css/design_css.inc';
43 parent::__construct($assetid);
57 $links = parent::_getAllowedLinks();
58 $links[SQ_LINK_TYPE_3][
'file'] = Array(
'card' =>
'M',
'exclusive' => FALSE);
75 $delete_link = $GLOBALS[
'SQ_SYSTEM']->am->getLinkById($linkid, $this->
id);
76 if (empty($delete_link)) {
77 trigger_localised_error(
'CORE0155', E_USER_WARNING, $linkid);
81 $am = $GLOBALS[
'SQ_SYSTEM']->am;
82 $minor = $am->getAsset($delete_link[
'minorid'], $delete_link[
'minor_type_code']);
84 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
85 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
88 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
89 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
94 if ($delete_link[
'link_type'] == SQ_LINK_TYPE_2 && ($minor instanceof
File)) {
100 $file_link_ids = Array();
101 $file_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($design->id, SQ_LINK_TYPE_2,
'file', FALSE);
102 foreach ($file_links as $link) {
103 $file_link_ids[$link[
'minorid']] = $link[
'linkid'];
105 $file_link_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(array_keys($file_link_ids));
107 foreach ($file_link_info as $info) {
108 if ($info[
'name'] == $minor->name) {
110 $new_minor = $am->getAsset($info[
'assetid']);
111 if (!$this->
createLink($new_minor, SQ_LINK_TYPE_3,
'', NULL,
'1')) {
112 trigger_localised_error(
'CORE0162', E_USER_WARNING);
113 $am->forgetAsset($design);
114 $am->forgetAsset($new_minor);
115 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
116 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
119 $am->forgetAsset($new_minor);
123 $am->forgetAsset($design);
126 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
127 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
148 $delete_link = $GLOBALS[
'SQ_SYSTEM']->am->getLinkById($linkid, $this->
id);
149 if (empty($delete_link)) {
150 trigger_localised_error(
'CORE0155', E_USER_WARNING, $linkid);
154 $am = $GLOBALS[
'SQ_SYSTEM']->am;
155 $minor = $am->getAsset($delete_link[
'minorid'], $delete_link[
'minor_type_code']);
157 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
158 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
160 if (!parent::deleteLink($linkid)) {
161 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
162 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
166 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
167 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
184 parent::linksUpdated();
185 unset($this->_tmp[
'parent_design']);
186 unset($this->_tmp[
'customised_areas']);
187 unset($this->_tmp[
'uncustomised_areas']);
200 if (empty($this->_tmp[
'parent_design'])) {
201 $parent_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($this->
id, SQ_LINK_TYPE_2,
'design_css', FALSE,
'customisation',
'minor');
202 $this->_tmp[
'parent_design'] = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($parent_link[
'majorid'], $parent_link[
'major_type_code']);
204 return $this->_tmp[
'parent_design'];
217 if (!isset($this->_tmp[
'customised_areas'])) {
219 if (!is_null($parent)) {
222 $parents_links = $parent->getDesignAreaLink();
223 $this->_tmp[
'customised_areas'] = Array();
227 foreach ($our_links as $our_link) {
228 foreach ($parents_links as $parents_link) {
230 if ($our_link[
'value'] == $parents_link[
'value']) {
232 if ($parents_link[
'minorid'] == $our_link[
'minorid']) {
233 $this->_tmp[
'uncustomised_areas'][] = $our_link;
235 $this->_tmp[
'customised_areas'][] = $our_link;
244 if (!isset($this->_tmp[
'customised_areas'])) {
245 $this->_tmp[
'customised_areas'] = Array();
247 if (!isset($this->_tmp[
'uncustomised_areas'])) {
248 $this->_tmp[
'uncustomised_areas'] = Array();
251 return $this->_tmp[
'customised_areas'];
264 if (!isset($this->_tmp[
'uncustomised_areas'])) {
268 return $this->_tmp[
'uncustomised_areas'];
285 $am = $GLOBALS[
'SQ_SYSTEM']->am;
294 $tmp = $parent->getDesignAreaLink();
295 $parent_da_links = Array();
296 foreach ($tmp as $link) {
297 $parent_da_links[$link[
'value']] = $link;
301 $this_da_links = Array();
302 foreach ($tmp as $link) {
303 $this_da_links[$link[
'value']] = $link;
306 $remove_id_names = array_diff(array_keys($this_da_links), array_keys($parent_da_links));
307 $added_id_names = array_diff(array_keys($parent_da_links), array_keys($this_da_links));
310 foreach ($remove_id_names as $id_name) {
311 if (!$this->
deleteLink($this_da_links[$id_name][
'linkid'])) {
316 foreach ($added_id_names as $id_name) {
317 $da = $am->getAsset($parent_da_links[$id_name][
'minorid'], $parent_da_links[$id_name][
'minor_type_code'], TRUE);
318 if (is_null($da))
continue;
319 $this->
createLink($da, SQ_LINK_TYPE_3, $id_name, NULL,
'1');
325 foreach ($links as $link) {
326 $da = $am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
327 if (is_null($da))
continue;
329 $parent_da = $parent->getDesignArea($link[
'value']);
330 if (is_null($parent_da))
continue;
332 $da->setAttrValue(
'contents', $parent_da->attr(
'contents'));
333 $da->saveAttributes();
358 public function paint(
Asset $ASSET, Array $FILE_URLS=Array())
362 $file_link_ids = Array();
363 $file_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_TYPE_2 | SQ_LINK_TYPE_3,
'file', FALSE);
364 foreach ($file_links as $link) {
365 $file_link_ids[] = $link[
'minorid'];
368 $file_link_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(array_unique($file_link_ids));
369 $file_link_urls = $GLOBALS[
'SQ_SYSTEM']->am->getAssetURL(array_unique($file_link_ids));
371 foreach ($file_link_info as $minorid => $file_info) {
372 $file_url = $file_link_urls[$minorid];
373 if ($file_url ==
'') {
374 $file_url =
"Javascript: alert(js_translate('no_url_found', '".addslashes($file_info[
'name']).
"', '".addslashes($this->
attr(
'id_name')).
"'));";
375 }
else if ($this->
attr(
'static_url_versioning')){
376 $served_by_apache = strpos($file_url,
'/__data/') !== FALSE || (SQ_CONF_STATIC_ROOT_URL && strpos($file_url, SQ_CONF_STATIC_ROOT_URL.
'/') !== FALSE);
377 if ($served_by_apache) $file_url .=
'?v='.$file_info[
'version'];
379 $FILE_URLS[$file_info[
'name']] = $file_url;
382 return parent::paint($ASSET, $FILE_URLS);