18 require_once SQ_CORE_PACKAGE_PATH.
'/designs/design/design_edit_fns.inc';
41 parent::__construct();
42 $this->static_screens[
'details'][
'force_unlock'] = FALSE;
61 $file_contents=
'<'.$this->tag_name.
"_PRINT id_name='__global__' var='css_header' />\n"
64 return parent::_parseString($asset, $file_contents);
82 $existing_ids = Array();
83 $existing = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_3,
'file', FALSE);
84 foreach ($existing as $link) {
85 $existing_ids[$link[
'minorid']] = $link[
'linkid'];
88 $existing_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(array_keys($existing_ids));
89 foreach ($existing_info as $assetid => $existing_info) {
91 if ($existing_info[
'name'] == $info[
'name']) {
92 $linkid = $existing_ids[$assetid];
93 $asset->deleteExistingLink($linkid);
98 return parent::_processUploadedFile($asset, $info);
115 if (!$asset->writeAccess(
'links'))
return FALSE;
116 check_box($prefix.
'_new_customisation');
117 text_box($prefix.
'_new_customisation_name', $asset->name.
'.css', 40);
135 if (empty($_POST[$prefix.
'_new_customisation']) || !($new_name = trim($_POST[$prefix.
'_new_customisation_name']))) {
139 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
140 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
144 $create_link = Array();
147 if ($asset->writeAccess(
'all')) {
148 $GLOBALS[
'SQ_SYSTEM']->setRunLevel($GLOBALS[
'SQ_SYSTEM']->getRunLevel() & SQ_RUN_LEVEL_FORCED);
150 $asset->_tmp[
'custom'] = TRUE;
151 $clone = $GLOBALS[
'SQ_SYSTEM']->am->cloneAsset($asset, $create_link, $map, Array(
'attributes',
'permissions',
'roles'), FALSE);
152 unset ($asset->_tmp[
'custom']);
153 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();
158 if (is_null($clone)) {
159 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
160 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
164 $GLOBALS[
'SQ_SYSTEM']->am->rememberAsset($da);
167 if (!$GLOBALS[
'SQ_SYSTEM']->am->acquireLock($clone->id,
'all')) {
168 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
169 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
174 $clone = $clone->morph(
'design_css_customisation');
177 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
178 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
183 if (!$asset->createLink($clone, SQ_LINK_TYPE_2,
'customisation', NULL,
'1')) {
184 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
185 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
188 if (!($clone->setAttrValue(
'id_name', $new_name) && $clone->saveAttributes())) {
189 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
190 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
194 $am = $GLOBALS[
'SQ_SYSTEM']->am;
197 $da_links = $asset->getDesignAreaLink();
198 foreach ($da_links as $link) {
199 $da = $am->getAsset($link[
'minorid'], $link[
'minor_type_code'], TRUE);
200 if (is_null($da))
continue;
201 if (!$clone->createLink($da, SQ_LINK_TYPE_3, $link[
'value'], NULL,
'1')) {
202 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
203 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
209 $initial_path = strtolower($new_name);
210 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
211 $valid_paths = make_valid_web_paths(Array($initial_path));
212 $good_paths = $GLOBALS[
'SQ_SYSTEM']->am->webPathsInUse($asset, $valid_paths, $clone->id, TRUE);
213 if (!$clone->saveWebPaths($good_paths)) {
214 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
215 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
220 $file_link_ids = Array();
221 $file_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_2 | SQ_LINK_TYPE_3,
'file', FALSE);
222 foreach ($file_links as $link) {
223 $minor = $am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
224 if (!$clone->createLink($minor, SQ_LINK_TYPE_3,
'', NULL, 1)) {
225 trigger_localised_error(
'CORE0162', E_USER_WARNING);
226 $am->forgetAsset($minor);
227 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
228 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
232 $am->forgetAsset($minor);
235 if (!$GLOBALS[
'SQ_SYSTEM']->am->releaseLock($clone->id,
'all')) {
236 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
237 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
241 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
242 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
261 $customisation_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_2,
'design_css_customisation', TRUE,
'major',
'customisation');
262 if ($customisation_links) {
263 $am = $GLOBALS[
'SQ_SYSTEM']->am;
264 foreach ($customisation_links as $link) {
265 $customisation = $am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
266 if (is_null($customisation))
continue;
267 echo
'# ', $customisation->id,
' <a href="', $customisation->getBackendHref(),
'">', $customisation->name,
'</a><br>';
272 echo translate(
'core_no_customisation_created');