18 require_once SQ_CORE_PACKAGE_PATH.
'/designs/design_area/design_area.inc';
43 parent::__construct($assetid);
60 if (!parent::_createAdditional($link))
return FALSE;
64 $fv = $GLOBALS[
'SQ_SYSTEM']->getFileVersioning();
65 if (!is_dir($this->data_path)) {
66 create_directory($this->data_path);
68 $parse_file = $this->data_path.
'/parse.txt';
70 if (!$fv->add($this->data_path_suffix, $parse_file,
'')) {
71 trigger_localised_error(
'CORE1057', E_USER_WARNING);
73 if (!$fv->checkOut($this->data_path_suffix.
'/parse.txt', $this->data_path)) {
74 trigger_localised_error(
'CORE0158', E_USER_WARNING);
107 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
111 if (($this->
type() ==
'design' || $this->
type() ==
'design_css') && !isset($this->_tmp[
'custom'])) {
112 $orig_parse = $this->data_path.
'/parse.txt';
113 $clone_parse = $clone->data_path.
'/parse.txt';
116 if (!is_dir($clone->data_path) || !is_writable($clone->data_path)) {
117 if (!create_directory($clone->data_path)) {
126 if (copy($orig_parse, $clone_parse)) {
129 $fv = $GLOBALS[
'SQ_SYSTEM']->getFileVersioning();
132 $clone->_tmp[
'update_customisations'] = TRUE;
133 $clone->_tmp[
'generate_design'] = TRUE;
134 $changes = $edit_fns->parseAndProcessFile($clone);
137 if (!$fv->add($clone->data_path_suffix, $clone_parse,
'')) {
138 trigger_localised_error(
'CORE1057', E_USER_WARNING);
142 if (!$fv->checkOut($clone->data_path_suffix.
'/parse.txt', $clone->data_path)) {
143 trigger_localised_error(
'CORE0158', E_USER_WARNING);
147 if (!$clone->generateDesignFile()){
154 return parent::cloneComponentsAdditional($clone, $components);
167 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
168 $return_value = TRUE;
172 $components = $GLOBALS[
'SQ_SYSTEM']->am->getChildren($clone->id);
173 foreach ($components as $componentid => $component) {
175 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($componentid);
177 $initial_path = strtolower($asset->name);
178 $valid_paths = make_valid_web_paths(Array($initial_path));
179 $good_paths = $GLOBALS[
'SQ_SYSTEM']->am->webPathsInUse($clone, $valid_paths, $asset->id, TRUE);
180 $GLOBALS[
'SQ_SYSTEM']->acquireLock($asset->id,
'all');
181 $return_value = $asset->saveWebPaths($good_paths);
182 $value = (!$return_value) ? FALSE : TRUE;
184 $return_value = $asset->updateLookups(FALSE);
185 $value = (!$return_value) ? FALSE : TRUE;
186 $GLOBALS[
'SQ_SYSTEM']->releaseLock($asset->id,
'all');
187 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($asset);
205 SQ_LINK_TYPE_1 => Array(
206 'design_css' => Array(
'card' =>
'M',
'exclusive' => FALSE),
208 SQ_LINK_TYPE_2 => Array(
209 'design_customisation' => Array(
'card' =>
'M',
'exclusive' => FALSE),
210 'design_css' => Array(
'card' =>
'M',
'exclusive' => FALSE),
211 'file' => Array(
'card' =>
'M',
'exclusive' => FALSE),
213 SQ_LINK_TYPE_3 => Array(
214 'design_area' => Array(
'card' =>
'M',
'exclusive' => FALSE),
216 SQ_LINK_NOTICE => Array(),
248 trigger_localised_error(
'CORE0168', E_USER_WARNING);
264 parent::linksUpdated();
265 if (isset($this->_tmp[
'design_areas'])) {
266 foreach (array_keys($this->_tmp[
'design_areas']) as $id_name) {
267 unset($this->_tmp[
'design_areas'][$id_name]);
294 public function prepareLink(
Asset $asset, $side_of_link, &$link_type, &$value, &$sort_order, &$dependant, &$exclusive)
298 if ($side_of_link ==
'major' && ($asset instanceof
File)) {
299 if ($dependant !=
'1') {
304 if ($link_type == SQ_LINK_TYPE_1) {
305 $link_type = SQ_LINK_TYPE_2;
332 public function createLink(
Asset $minor, $link_type, $value=
'', $sort_order=NULL, $dependant=
'0', $exclusive=
'0')
334 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
335 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
337 $linkid = parent::createLink($minor, $link_type, $value, $sort_order, $dependant, $exclusive);
339 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
340 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
345 if (($minor instanceof
File)) {
347 $am =& $GLOBALS[
'SQ_SYSTEM']->am;
349 $customisation_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_TYPE_2,
'design_customisation', TRUE,
'major',
'customisation');
350 foreach ($customisation_links as $link) {
351 $customisation = $am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
352 if (is_null($customisation))
continue;
354 $file_link_ids = Array();
355 $file_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($customisation->id, SQ_LINK_TYPE_2,
'file', FALSE);
356 foreach ($file_links as $link) {
357 $file_link_ids[] = $link[
'minorid'];
359 $file_link_info = $am->getAssetInfo(array_unique($file_link_ids));
365 $new_file_name = make_valid_web_paths(Array($minor->
attr(
'name')));
366 $new_file_name = array_shift($new_file_name);
368 foreach ($file_link_info as $info) {
369 if ($info[
'name'] == $new_file_name) {
370 $insert_link = FALSE;
375 if (!$customisation->createLink($minor, SQ_LINK_TYPE_3,
'', NULL, 1)) {
376 trigger_localised_error(
'CORE0162', E_USER_WARNING);
377 $am->forgetAsset($customisation);
378 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
379 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
384 $am->forgetAsset($customisation);
390 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
391 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
408 $delete_link = $GLOBALS[
'SQ_SYSTEM']->am->getLinkById($linkid, $this->
id);
409 if (empty($delete_link)) {
410 trigger_localised_error(
'CORE0155', E_USER_WARNING, $linkid);
414 $am =& $GLOBALS[
'SQ_SYSTEM']->am;
415 $minor = $am->getAsset($delete_link[
'minorid'], $delete_link[
'minor_type_code']);
417 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
418 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
421 if ($minor instanceof
File) {
423 $customisation_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_TYPE_2,
'design_customisation', TRUE,
'major',
'customisation');
424 foreach ($customisation_links as $link) {
425 $customisation = $am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
426 if (is_null($customisation))
continue;
428 $file_link_ids = Array();
429 $file_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($customisation->id, SQ_LINK_TYPE_3,
'file', FALSE);
431 foreach ($file_links as $link) {
432 if ($link[
'minorid'] == $delete_link[
'minorid']) {
434 if (!$customisation->deleteLink($link[
'linkid'])) {
435 trigger_localised_error(
'CORE1065', E_USER_WARNING);
436 $am->forgetAsset($customisation);
437 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
438 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
444 $am->forgetAsset($customisation);
449 if (!parent::deleteLink($linkid)) {
450 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
451 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
455 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
456 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
472 $file_link_ids = Array();
473 $file_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_TYPE_2 | SQ_LINK_TYPE_3,
'file', FALSE);
474 foreach ($file_links as $link) {
475 $file_link_ids[] = $link[
'minorid'];
477 $file_link_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(array_unique($file_link_ids));
479 foreach ($file_link_info as $assetid => $file_info) {
480 if ($file_info[
'name'] == $filename) {
481 return $GLOBALS[
'SQ_SYSTEM']->am->getAsset($assetid, $file_info[
'type_code']);
501 $file_link_ids = Array();
502 $file_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_TYPE_2 | SQ_LINK_TYPE_3,
'file', FALSE);
503 foreach ($file_links as $link) {
504 $file_link_ids[] = $link[
'minorid'];
506 $file_link_info = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(array_unique($file_link_ids));
508 $return_values = Array();
509 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
510 foreach ($file_link_info as $assetid => $file_info) {
511 if (get_file_type($file_info[
'name']) ==
'css') {
512 $return_values[$assetid] = $file_info[
'name'];
516 return $return_values;
533 return @$GLOBALS[
'SQ_SYSTEM']->am->getLink($this->
id, SQ_LINK_TYPE_3,
'design_area', FALSE, $id_name);
536 $all_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_TYPE_3,
'design_area', FALSE);
537 $return_links = Array();
538 foreach ($all_links as $link) {
539 if ($link[
'minor_type_code'] !=
'design_css') {
540 $return_links[] = $link;
543 return $return_links;
559 if (empty($this->_tmp[
'design_areas'][$id_name])) {
560 if (!isset($this->_tmp[
'design_areas'])) {
561 $this->_tmp[
'design_areas'] = Array();
566 $this->_tmp[
'design_areas'][$id_name] = NULL;
568 $this->_tmp[
'design_areas'][$id_name] = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
571 return $this->_tmp[
'design_areas'][$id_name];
600 switch ($_POST[
'asset_action']) {
602 if (parent::processBackend($o, $link)) {
604 if (isset($this->_tmp[
'generate_design']) && $this->_tmp[
'generate_design']) {
605 $hh = $GLOBALS[
'SQ_SYSTEM']->getHipoHerder();
607 'assetid' =>$this->
id,
609 $hh->queueHipo(
'hipo_job_regenerate_design', $vars);
620 return parent::processBackend($o, $link);
635 $customisation_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($this->
id, SQ_LINK_TYPE_2,
'design_customisation', TRUE,
'major',
'customisation');
636 $am = $GLOBALS[
'SQ_SYSTEM']->am;
637 foreach ($customisation_links as $link) {
638 $customisation = $am->getAsset($link[
'minorid'], $link[
'minor_type_code']);
639 if (is_null($customisation))
continue;
640 if ($acquired = $GLOBALS[
'SQ_SYSTEM']->am->acquireLock($customisation->id,
'all')) {
641 $customisation->updateFromParent($this);
642 if ($acquired != 2) {
643 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($customisation->id,
'all');
667 Developed by Squiz - http://www.squiz.net
668 Squiz, Squiz Matrix, MySource, MySource Matrix and Squiz.net are registered Trademarks of Squiz Pty Ltd
669 Page generated: <?php echo date(\'d F Y H:i:s\')."\n"; ?>
673 if (!empty($SQ_PRIMARY_URL)) {
675 <script type="text/javascript" src="<?php echo sq_web_path(\'lib\'); ?>/js/JsHttpConnector.js"></script>
676 <script type="text/javascript" src="<?php echo $SQ_PRIMARY_URL; ?>/__lib/session/session.php?in_primary=<?php echo (sq_web_path(\'root_url\') == $SQ_PRIMARY_URL) ? 1 : 0; ?>&site_network=<?php echo $SQ_SITE_NETWORK->id; ?>"></script>
678 if (sq_web_path(\'root_url\') != $SQ_PRIMARY_URL) {
680 <script type="text/javascript">
681 start_session_handler("<?php echo sq_web_path(\'lib\'); ?>/session/session.php?site_network=<?php echo $SQ_SITE_NETWORK->id; ?>");
685 }//end if primary URL available
688 if (SQ_IN_LIMBO && !is_null($GLOBALS[\'SQ_SYSTEM\']->backend) && !is_null($GLOBALS[\'SQ_SYSTEM\']->backend->out)) $GLOBALS[\'SQ_SYSTEM\']->backend->out->_paintHeader();
689 if (SQ_ROLLBACK_VIEW) $GLOBALS[\'SQ_SYSTEM\']->printRollbackWarning();
697 <?php echo SQ_CONF_SYSTEM_NAME."\n"; ?>
698 Content (c) Copyright <?php echo SQ_CONF_SYSTEM_OWNER."\n"; ?>
699 Running <?php echo SQ_SYSTEM_LONG_NAME; ?> - <?php echo SQ_SYSTEM_URL."\n"; ?>
700 Developed by Squiz - http://www.squiz.net
701 (c) Copyright <?php echo date(\'Y\') ?>. All rights reserved.
702 Page generated: <?php echo date(\'d F Y H:i:s\')."\n"; ?>
703 Warranty key: <?php echo (defined("SQ_LICENCE_WARRANTY_KEY") ? SQ_LICENCE_WARRANTY_KEY : "None")."\n"; ?>
712 case 'content_type' :
713 if (!empty($args[
'content_type'])) {
714 echo
'<',
'?php header('.$this->_safeStringLiteral(
'Content-type: '.$args[
'content_type']).
'); ?',
'>';
719 if (!empty($args[
'pragma'])) {
720 echo
'<',
'?php header('.$this->_safeStringLiteral(
'Pragma: '.$args[
'pragma']).
'); ?',
'>';
724 case 'content_attachment' :
725 if (!empty($args[
'extension'])) {
726 echo
'<',
'?php $asset_name = htmlspecialchars($ASSET->name).\'.'.$args[
'extension'].
'\'; ?
'.'>
';
727 echo '<
'.'?php header(
"Content-Disposition: attachment; filename=$asset_name"); ?
'.'>
';
732 if (!empty($args['full_url
']) && in_array($args['full_url
'], Array('yes
', 'true', '1
'))) {
733 $res_exp = '$ASSET_LINEAGE[0][\
'protocol\'].\'://\'.$ASSET_LINEAGE[0][\'url\']';
735 $res_exp =
'substr($ASSET_LINEAGE[0][\'url\'], strpos($ASSET_LINEAGE[0][\'url\'], \'/\'))';
738 $aqs = (!empty($args[
'append_query_string']) && in_array($args[
'append_query_string'], Array(
'yes',
'true',
'1')));
739 $sqs = (!empty($args[
'start_query_string']) && in_array($args[
'start_query_string'], Array(
'yes',
'true',
'1')));
742 $res_exp .=
'.((!empty($_SERVER[\'QUERY_STRING\'])) ? \'?\'.$_SERVER[\'QUERY_STRING\'] : \'\')';
746 $res_exp .=
'.\'?\'';
748 $res_exp .=
'.((!empty($_SERVER[\'QUERY_STRING\'])) ? \'&\' : \'?\');';
751 echo
'<',
'?php echo '.htmlentities($res_exp, ENT_COMPAT, SQ_CONF_DEFAULT_CHARACTER_SET).
'; ?',
'>';
755 echo
'<',
'?php echo htmlspecialchars($ASSET_LINEAGE[0][\'short_name\']); ?',
'>';
759 echo
'<',
'?php echo ', $this->
_escapeVar(
'$ASSET->id', $args),
'; ?',
'>';
763 $asset_name = $this->
_escapeVar(
'htmlspecialchars($ASSET->name)', $args);
764 echo
'<',
'?php echo ', $asset_name,
'; ?',
'>';
767 case 'asset_short_name' :
768 $asset_short_name = $this->
_escapeVar(
'htmlspecialchars($ASSET->short_name)', $args);
769 echo
'<',
'?php echo ', $asset_short_name,
'; ?',
'>';
773 $link_fn =
'getHref';
774 if (!empty($args[
'full_url'])) {
775 switch ($args[
'full_url']) {
785 if (!empty($args[
'append_query_string'])) {
786 switch ($args[
'append_query_string']) {
796 if (!empty($args[
'start_query_string'])) {
797 switch ($args[
'start_query_string']) {
807 if (!empty($args[
'clean_query_string'])) {
808 switch ($args[
'clean_query_string']) {
817 $additional =
'$query_string = $_SERVER[\'QUERY_STRING\'];';
819 $additional .=
'if (!empty($query_string)) $query_string = preg_replace("/[?&]?SQ_[^&]+/",\'\',$query_string);';
824 $additional .=
'echo htmlentities((!empty($query_string)) ? \'?\'.$query_string : \'\');'.
"\n";
828 $additional .=
'echo \'?\';';
830 $additional .=
'echo htmlentities((!empty($query_string)) ? \'&\' : \'?\');';
834 echo
'<',
'?php echo htmlentities(', $this->
_escapeVar(
'$ASSET->'.$link_fn.
'()', $args),
");\n", $additional,
' ?',
'>';
837 case 'current_asset' :
838 case 'current_user' :
839 if ($var ==
'current_user') {
841 if (!$GLOBALS["SQ_SYSTEM"]->userPublic()) {
843 $base =
'$GLOBALS["SQ_SYSTEM"]->user';
848 if (!empty($args[
'keyword'])) {
849 $args[
'keyword'] = trim($args[
'keyword'],
'% ');
851 $keyword_val = '.$base.
'->getKeywordReplacement('.$this->
_safeStringLiteral($args[
'keyword']).
');
857 if (empty($args[
'attr'])) $args[
'attr'] =
'name';
858 switch ($args[
'attr']) {
862 echo '.$base.
'->'.$args[
'attr'].
';
871 echo @'.$base.
'->attr('.$attr_name.
');
878 if ($var ==
'current_user') {
879 if (!empty($args[
'default'])) {
888 }//end if not public user
895 echo
'<',
'?php echo $FILE_URLS['.$this->_safeStringLiteral($args[
'filename']).
'];?',
'>';
899 echo
'<',
'?php echo $CSS_URLS['.$this->_safeStringLiteral($args[
'filename']).
'];?',
'>';
902 case 'asset_thumbnail' :
904 echo
'$thumbnail = NULL;'.
"\n";
905 echo
'if ($ASSET->useSystemVersion()) {'.
"\n";
906 echo
' $notice_links = unserialize(file_to_string($ASSET->data_path.\'/.sq_notice_links\'));'.
"\n";
907 echo
' foreach ($notice_links as $link) {'.
"\n";
908 echo
' if ($link[\'value\'] == \'thumbnail\') {'.
"\n";
909 echo
' $thumbnail = $GLOBALS[\'SQ_SYSTEM\']->am->getAsset($link[\'minorid\']);'.
"\n";
913 echo
'} else {'.
"\n";
914 echo
' $link = $GLOBALS[\'SQ_SYSTEM\']->am->getLink('.$this->_escapeVar(
'$ASSET->id', $args).
', SQ_LINK_NOTICE, \'image\', FALSE, \'thumbnail\');'.
"\n";
915 echo
' if (!empty($link)) {'.
"\n";
916 echo
' $thumbnail = $GLOBALS[\'SQ_SYSTEM\']->am->getAsset($link[\'minorid\']);'.
"\n";
919 echo
'if ($thumbnail) echo $thumbnail->printImageTag(\'\', \'\', TRUE);'.
"\n";
923 case 'asset_thumbnail_url' :
925 echo
'$thumbnail = NULL;'.
"\n";
926 echo
'if ($ASSET->useSystemVersion()) {'.
"\n";
927 echo
' $notice_links = unserialize(file_to_string($ASSET->data_path.\'/.sq_notice_links\'));'.
"\n";
928 echo
' foreach ($notice_links as $link) {'.
"\n";
929 echo
' if ($link[\'value\'] == \'thumbnail\') {'.
"\n";
930 echo
' $thumbnail = $GLOBALS[\'SQ_SYSTEM\']->am->getAsset($link[\'minorid\']);'.
"\n";
934 echo
'} else {'.
"\n";
935 echo
' $link = $GLOBALS[\'SQ_SYSTEM\']->am->getLink('.$this->_escapeVar(
'$ASSET->id', $args).
', SQ_LINK_NOTICE, \'image\', FALSE, \'thumbnail\');'.
"\n;";
936 echo
' if (!empty($link)) {'.
"\n";
937 echo
' $thumbnail = $GLOBALS[\'SQ_SYSTEM\']->am->getAsset($link[\'minorid\']);'.
"\n";
940 echo
'if ($thumbnail) echo $thumbnail->getURL('.$this->_escapeVar(
'$ASSET->getUrl()', $args).
');'.
"\n";
944 case (preg_match(
'/^asset_/i', $var) ? $var : !$var):
946 echo
'$keyword = \'',$var,
'\';
';
947 echo '$replacement =
'.$this->_escapeVar('$ASSET->getKeywordReplacement($keyword)
', $args).';
';
948 echo 'if ($replacement == $keyword) {
';
951 echo ' echo $replacement;
';
957 parent::printVar($var, $args);
978 public function paint(Asset $ASSET, Array $FILE_URLS=Array(), Array $CSS_URLS=Array())
980 // start performance mode timer
981 $GLOBALS['SQ_SYSTEM
']->pm->startTimer($this);
983 // generate an array of all the URLs we are going to need for the files in this design
984 $file_link_ids = Array();
985 $file_links = $GLOBALS['SQ_SYSTEM
']->am->getLinks($this->id, SQ_LINK_TYPE_2, 'file
', FALSE);
986 foreach ($file_links as $link) {
987 $file_link_ids[] = $link['minorid
'];
990 $file_link_info = $GLOBALS['SQ_SYSTEM
']->am->getAssetInfo(array_unique($file_link_ids));
991 $file_link_urls = $GLOBALS['SQ_SYSTEM
']->am->getAssetURL(array_unique($file_link_ids));
993 $system_root_url = sq_web_path('root_url
');
994 foreach ($file_link_info as $minorid => $file_info) {
995 $file_url = $file_link_urls[$minorid];
996 if ($file_url == '') {
997 $file_url = $system_root_url.'/?a=
'.$minorid;
998 } else if ($this->attr('static_url_versioning
')){
999 $served_by_apache = strpos($file_url, '/__data/
') !== FALSE || (SQ_CONF_STATIC_ROOT_URL && strpos($file_url, SQ_CONF_STATIC_ROOT_URL.'/
') !== FALSE);
1000 if ($served_by_apache) $file_url .= '?v=
'.$file_info['version
'];
1002 $FILE_URLS[$file_info['name
']] = $file_url;
1005 $DATA_PATH = sq_web_path('data
'); // this works because we know that all design areas are not going to be restricted
1006 $LIB_PATH = sq_web_path('lib
');
1008 // work out where the design file is
1009 if (SQ_ROLLBACK_VIEW) {
1010 // get an older version of our design file
1011 $fv = $GLOBALS['SQ_SYSTEM
']->getFileVersioning();
1012 $rep_file = $this->data_path_suffix.'/design_file.php
';
1013 $then = iso8601_ts($_SESSION['sq_rollback_view
']['rollback_time
']);
1014 $info = $fv->_checkOutCheck($rep_file, NULL, $then);
1015 $file_path = $info['source_file
'];
1017 $file_path = $this->data_path.'/design_file.php
';
1018 if (!file_exists($file_path)) {
1020 // If the design file does not exist, find from the parent design asset
1021 $arr['majorid
'] = $this->id;
1023 $arr = $GLOBALS['SQ_SYSTEM
']->am->getLink($arr['majorid
'], NULL, 'design
', FALSE, NULL,'minor
', FALSE);
1025 trigger_localised_error('CORE0259
', E_USER_WARNING, $ASSET->id);
1028 $design = $GLOBALS['SQ_SYSTEM
']->am->getAsset($arr['majorid
']);
1029 $file_path = dirname(dirname($design->data_path)).'/
'.get_asset_hash($design->id).'/
'.$arr['majorid
'].'/design_file.php
';
1030 } while(!file_exists($file_path));
1034 // Now we just include the design file to get it to print
1038 // start performance mode timer
1039 $GLOBALS['SQ_SYSTEM
']->pm->stopTimer($this);
1051 public function generateDesignFile($do_customisations=TRUE)
1053 $this->_setupVarReferences();
1054 $pre_str = $this->_getDesignFileHeader();
1057 $GLOBALS['DESIGN_BEING_GENERATED
'] =& $this;
1059 foreach ($this->attr('contents
') as $item) {
1060 if ($item['_type
'] == 'HTML
') {
1061 // just some HTML content to echo out
1062 echo $item['contents
'];
1063 } else if ($item['_type
'] == 'TAG
') {
1064 if ($item['operation
'] == 'area
') {
1065 // defining a design area
1066 $da = $this->getDesignArea($item['attributes
']['id_name
']);
1068 trigger_localised_error('CORE0234
', E_USER_WARNING, $item['attributes
']['id_name
']);
1070 $da->printAreaCode();
1072 } else if ($item['operation
'] == 'print
') {
1073 if ((!isset($item['attributes
']['id_name
'])) || ($item['attributes
']['id_name
'] == '__global__
')) {
1074 // printing a global var
1075 $args = $item['attributes
'];
1076 unset($args['id_name
']);
1077 unset($args['var
']);
1078 $this->printVar($item['attributes
']['var
'], $args);
1080 $da = $this->getDesignArea($item['attributes
']['id_name
']);
1082 trigger_localised_error('CORE0153
', E_USER_NOTICE, $item['attributes
']['id_name
']);
1084 if (isset($item['attributes
']['var
'])) {
1085 // printing a var from a certain design area
1086 $args = $item['attributes
'];
1087 unset($args['id_name
']);
1088 unset($args['var
']);
1089 $da->printVar($item['attributes
']['var
'], $args);
1091 // printing a whole design area (which should already have been defined)
1092 $da->printPaintingCode();
1097 }//end if Item = TAG
1098 }//end foreach contents
1099 $str = str_replace('?
'.'><
'.'?php
', '', ob_get_contents());
1100 unset($GLOBALS['DESIGN_BEING_GENERATED
']);
1103 if (empty($str)) return FALSE;
1105 if (!$this->_writeDesignFile($pre_str."\n".$str)) {
1110 if ($do_customisations) {
1111 $customisation_links = $GLOBALS['SQ_SYSTEM
']->am->getLinks($this->id, SQ_LINK_TYPE_2, 'design_customisation
', TRUE, 'major
', 'customisation
');
1112 $am =& $GLOBALS['SQ_SYSTEM
']->am;
1113 foreach ($customisation_links as $link) {
1114 $customisation = $am->getAsset($link['minorid
'], $link['minor_type_code
']);
1115 if (is_null($customisation)) continue;
1116 $customisation->generateDesignFile(TRUE);
1122 }//end generateDesignFile()
1131 protected function _getDesignFileHeader()
1133 // we are checking to see if there is a global $ASSET_LINEAGE here
1134 // because we need other assets to be able to modify the lineage, for
1135 // instance 404 pages.
1137 global $ASSET_LINEAGE;
1138 $am =& $GLOBALS[\
'SQ_SYSTEM\']->am;
1139 if (!isset($ASSET_LINEAGE) || empty($ASSET_LINEAGE)) $ASSET_LINEAGE = @$am->getLineageFromURL(null, null);
1140 if (empty($ASSET_LINEAGE)) {
1141 $asset_url = $ASSET->getURL();
1142 $protocol_pos = strpos($asset_url, "://");
1143 if ($protocol_pos !== FALSE) {
1144 $asset_url = substr($asset_url, $protocol_pos + 3);
1147 $ASSET_LINEAGE = @$am->getLineageFromURL(null, $asset_url);
1150 global $SQ_SITE_NETWORK, $SQ_PRIMARY_URL;
1151 $SQ_PRIMARY_URL = \'\';
1152 $SQ_SITE_NETWORK = NULL;
1154 if (isset($ASSET_LINEAGE[0])) {
1155 $site = $GLOBALS[\'SQ_SYSTEM\']->am->getAsset($ASSET_LINEAGE[0][\'assetid\'], $ASSET_LINEAGE[0][\'type_code\']);
1156 if (!is_null($site)) {
1157 $SQ_SITE_NETWORK = $site->getSiteNetwork();
1158 if (!is_null($SQ_SITE_NETWORK)) {
1159 $SQ_PRIMARY_URL = $SQ_SITE_NETWORK->getPrimaryURL();
1160 if (!empty($SQ_PRIMARY_URL)) {
1161 if (sq_web_path(\'root_url\') != $SQ_PRIMARY_URL) {
1162 require_once SQ_LIB_PATH.\'/session/pre_session.php\';
1169 if (!defined(\'SQ_LIMBO_EDITING\')) define(\'SQ_LIMBO_EDITING\', (SQ_IN_LIMBO && (!isset($_REQUEST[\'ignore_frames\']) || !$_REQUEST[\'ignore_frames\'])));
1185 $str = preg_replace(
'|\?>([\s]+)?<\?php|',
'', $str);
1186 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
1187 create_directory($this->data_path);
1188 $file = $this->data_path.
'/design_file.php';
1189 $new_file = !file_exists($file);
1190 if (!string_to_file($str, $file)) {
1196 $fv = $GLOBALS[
'SQ_SYSTEM']->getFileVersioning();
1200 if (!$fv->add($this->data_path_suffix, $file,
'')) {
1201 trigger_localised_error(
'CORE0156', E_USER_WARNING);
1206 $file_status = $fv->upToDate($file);
1207 if (FUDGE_FV_MODIFIED & $file_status) {
1208 if (!$fv->commit($file,
'')) {
1209 trigger_localised_error(
'CORE0159', E_USER_WARNING);
1216 if (!$fv->checkOut($this->data_path_suffix.
'/design_file.php', $this->data_path)) {
1217 trigger_localised_error(
'CORE0031', E_USER_WARNING);
1235 $var_ref_values = Array();
1237 foreach ($design_area_links as $link) {
1239 if (is_null($da))
continue;
1241 $da_var_refs = $da->getVarReferences();
1242 for (reset($da_var_refs); NULL !== ($id_name = key($da_var_refs)); next($da_var_refs)) {
1244 if (is_null($var_da))
continue;
1245 if (!isset($var_ref_values[$id_name])) {
1246 $var_ref_values[$id_name] = Array();
1248 foreach ($da_var_refs[$id_name] as $var) {
1251 $da_refs[] = $id_name;
1253 }
else if (!isset($var_ref_values[$id_name][$var])) {
1254 $var_ref_values[$id_name][$var] = $var_da->attr($var);
1265 foreach ($design_area_links as $link) {
1267 if (is_null($da))
continue;
1268 $da->setVarReferenceValues($var_ref_values);