17 require_once SQ_CORE_PACKAGE_PATH.
'/report/report_edit_fns.inc';
18 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
19 require_once SQ_INCLUDE_PATH.
'/general_occasional.inc';
43 parent::__construct();
60 $types = $asset->
attr(
'types');
63 $display_values = Array(
64 'type_code' => Array(),
67 foreach ($types as $type => $inherit) {
68 $display_values[
'type_code'][] = $type;
69 $display_values[
'inherit'][] = $inherit;
71 asset_type_chooser($prefix.
'_types', TRUE, $display_values, NULL, TRUE, TRUE);
76 echo
'<p class="sq-backend-warning">'.translate(
'no_types_chosen').
'</p>';
78 $type_names = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo(array_keys($types),
'name');
80 <table
class=
"sq-backend-table">
82 <th><?php echo translate(
'type') ?></th>
83 <th><?php echo translate(
'inherit_question') ?></th>
86 $inherit_image_path = sq_web_path(
'lib').
'/web/images/';
87 foreach ($types as $type => $inherit) {
88 $inherit_image = $inherit_image_path.($inherit ?
'tick' :
'cross').
'.gif';
89 $inherit_alt = $inherit ? translate(
'yes') : translate(
'no');
92 <td><?php echo $type_names[$type]; ?></td>
93 <td><img src=
"<?php echo $inherit_image; ?>" alt=
"<?php echo $inherit_alt; ?>" /></td>
119 if (isset($_POST[$prefix.
'_types'])) {
120 $existing_types = $asset->
attr(
'types');
121 $submitted_types = Array();
122 foreach ($_POST[$prefix.
'_types'][
'type_code'] as $i => $type_code) {
123 if (!empty($type_code)) {
124 $submitted_types[$type_code] = $_POST[$prefix.
'_types'][
'inherit'][$i];
146 return $this->
_cData($asset_info[
'assetid']);
161 return $asset_info[
'status'];
176 return $this->
_cData($asset_info[
'type_code']);
191 return $this->
_cData($asset_info[
'name']);
206 return $asset_info[
'created'];
221 return $asset_info[
'created_userid'];
236 return $asset_info[
'updated'];
251 return $asset_info[
'updated_userid'];
266 return $asset_info[
'published'];
281 return $asset_info[
'published_userid'];
296 return $asset_info[
'status_changed'];
311 return $asset_info[
'status_changed_userid'];
327 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($asset_info[
'assetid']);
328 $urls = $asset->getLookups();
330 usort($urls, create_function(
'$a, $b',
'return strcmp($a[\'url\'], $b[\'url\']);'));
331 foreach ($urls as $data) {
333 $value .=
'<url>http://'.$data[
'url'].
'</url>'.
"\n";
335 if ($data[
'https']) {
336 $value .=
'<url>https://'.$data[
'url'].
'</url>'.
"\n";
356 $asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($asset_info[
'assetid']);
357 $designs = $asset->getDesignLookups();
378 foreach ($designs as $url => $data) {
380 $value .=
'<design url="'.$url.
'">'.
"\n";
381 foreach ($data as $type => $id) {
382 $value .=
'<design_type>';
383 $value .=
'<type>'.$this->_cData($type).
'</type>';
384 $value .=
'<id>'.$this->_cData($id).
'</id>';
385 $value .=
'</design_type>'.
"\n";
387 $value .=
"</design>\n";
405 $mm = $GLOBALS[
'SQ_SYSTEM']->getMetadataManager();
406 $schemas = $mm->getSchemas($asset_info[
'assetid'], TRUE);
407 foreach ($schemas as $schemaid) {
409 $value .=
'<schema>'.$schemaid.
'</schema>'.
"\n";
427 $wm = $GLOBALS[
'SQ_SYSTEM']->getWorkflowManager();
428 $schemas = $wm->getSchemas($asset_info[
'assetid'], TRUE);
429 foreach ($schemas as $schemaid) {
431 $value .=
'<schema>'.$schemaid.
'</schema>'.
"\n";
449 if (!empty($assetid)) {
450 $value = get_asset_tag_line($assetid);
465 protected function _cData($character_data)
467 return '<![CDATA['.$character_data.
']]>';
484 $am = $GLOBALS[
'SQ_SYSTEM']->am;
486 $owner = $am->getAsset($job->_running_vars[
'assetid']);
488 if (!isset($job->_running_vars[
'assets_to_list'])) {
492 if ($owner->attr(
'selected_asset_fields') ==
'') {
493 trigger_localised_error(
'RPRT0003', E_USER_WARNING);
495 $job->_running_vars[
'selected_asset_fields'] = explode(
'|', $owner->attr(
'selected_asset_fields'));
499 $assets_to_list = Array();
503 trigger_localised_error(
'RPRT0004', E_USER_WARNING);
507 $child_links = $am->getLinks($root_id, SQ_SC_LINK_BACKEND_NAV);
508 foreach (array_reverse($child_links) as $link) {
509 if (($link[
'linkid'] !=
'0') && FALSE == strpos($link[
'linkid'],
':')) {
510 array_unshift($assets_to_list, $link[
'minorid']);
514 $job->_running_vars[
'assets_to_list'] = $assets_to_list;
515 $job->_running_vars[
'assets_open'] = Array();
516 $job->_running_vars[
'assets_skipped'] = Array();
519 $asset_treeids = $am->getAssetTreeids($root_id);
520 $root_treeid = reset($asset_treeids);
521 $root_treeid = $root_treeid ===
'-' ?
'' : $root_treeid;
524 $bind_vars[
'treeid'] = $root_treeid.
'_%';
526 }
catch (Exception $e) {
527 throw new Exception(
'Unable to get link tree count for "'.$root_treeid.
'": '.$e->getMessage());
532 $job->_running_vars[
'total'] = $total*2;
533 $job->_running_vars[
'done'] = 0;
537 $report_dir = $owner->data_path;
538 $xml_file_name = $report_dir.
'/report.tmp';
540 if (!is_dir($report_dir)) {
541 if (!create_directory($report_dir)) {
542 trigger_localised_error(
'CORE0198', E_USER_WARNING);
548 $temp_file = fopen($xml_file_name,
'w');
549 if ($temp_file === FALSE) {
550 trigger_localised_error(
'CORE0017', E_USER_WARNING);
553 fwrite($temp_file,
'<?xml version="1.0" encoding="'.SQ_CONF_DEFAULT_CHARACTER_SET.
'"?>'.
"\n");
554 fwrite($temp_file,
'<assets root_treeid="'.$root_treeid.
'">'.
"\n");
557 $temp_file = fopen($owner->data_path.
'/report.tmp',
'a');
558 if ($temp_file === FALSE) {
559 trigger_localised_error(
'RPRT0000', E_USER_WARNING);
564 $assets_per_step = 50;
565 $target_this_step = $job->_running_vars[
'done'] + $assets_per_step;
567 $nothing_open = Array(
572 while (!empty($job->_running_vars[
'assets_to_list']) && $job->_running_vars[
'done'] < $target_this_step) {
573 $asset_info = Array();
575 $assets_to_list = $job->_running_vars[
'assets_to_list'];
576 $assets_open = $job->_running_vars[
'assets_open'];
577 $selected_asset_fields = $job->_running_vars[
'selected_asset_fields'];
578 $assets_skipped = $job->_running_vars[
'assets_skipped'];
579 $current_assetid = $assets_to_list[0];
582 $open_asset = array_get_index($assets_open, 0, $nothing_open);
584 if ($current_assetid == $open_asset[
'assetid']) {
586 array_shift($assets_to_list);
587 array_shift($assets_open);
588 if ($current_assetid == array_get_index($assets_skipped, 0)) {
589 array_shift($assets_skipped);
591 $contents .=
'</children>'.
"\n";
592 $contents .=
'</asset>'.
"\n";
598 $asset_info = $am->getAssetInfo(Array($current_assetid));
599 if (isset($asset_info[$current_assetid])) {
601 $asset_info = $asset_info[$current_assetid];
603 $asset_info[
'treeid'] = $this->
getTreeid($current_assetid, $open_asset[
'treeid']);
604 $asset_info[
'assetid'] = $current_assetid;
606 if (!isset($asset_info[
'type_code']) || !$this->
checkType($asset_info[
'type_code'], $owner->attr(
'types'))) {
608 array_unshift($assets_skipped, $current_assetid);
612 $contents .=
'<asset>'.
"\n";
615 $contents .=
'<fields>'.
"\n";
616 $contents .=
'<short_name><![CDATA['.$asset_info[
'short_name'].
']]></short_name>';
617 $contents .=
'<treeid>'.$asset_info[
'treeid'].
'</treeid>';
618 if (!in_array(
'asset_type', $selected_asset_fields)) {
620 $contents .=
'<asset_type><![CDATA['.$asset_info[
'type_code'].
']]></asset_type>';
622 foreach ($selected_asset_fields as $name) {
623 $contents .=
'<'.$name.
'>';
624 $function_name =
'_generateField'.str_replace(
' ',
'', ucwords(str_replace(
'_',
' ', $name)));
626 $contents .= $this->$function_name($asset_info);
627 $contents .=
'</'.$name.
'>'.
"\n";
629 $contents .=
'</fields>'.
"\n";
632 $contents .=
'<children>'.
"\n";
634 $child_links = $am->getLinks($current_assetid, SQ_SC_LINK_BACKEND_NAV);
636 foreach (array_reverse($child_links) as $link) {
637 if (($link[
'linkid'] !=
'0') && FALSE == strpos($link[
'linkid'],
':')) {
638 array_unshift($assets_to_list, $link[
'minorid']);
641 $new_open_asset = Array(
642 'assetid' => $asset_info[
'assetid'],
643 'treeid' => $asset_info[
'treeid'],
645 array_unshift($assets_open, $new_open_asset);
648 $job->_running_vars[
'assets_to_list'] = $assets_to_list;
649 $job->_running_vars[
'assets_open'] = $assets_open;
650 $job->_running_vars[
'assets_skipped'] = $assets_skipped;
652 fwrite($temp_file, $contents);
654 $job->_running_vars[
'done']++;
658 if (empty($job->_running_vars[
'assets_to_list'])) {
659 $step_data[
'percent_done'] = 100;
660 $step_data[
'complete'] = TRUE;
661 $job->_running_vars[
'complete'] = TRUE;
662 fwrite($temp_file,
'</assets>'.
"\n");
664 if (!copy($owner->data_path.
'/report.tmp', $owner->data_path.
'/report.xml')) {
665 trigger_localised_error(
'RPRT0001', E_USER_WARNING);
668 if (!unlink($owner->data_path.
'/report.tmp')) {
669 trigger_localised_error(
'RPRT0002', E_USER_WARNING);
672 $total = $job->_running_vars[
'total'];
673 $step_data[
'percent_done'] = ($job->_running_vars[
'done'] / $total) * 100;
674 $step_data[
'complete'] = FALSE;
696 $stack =& $this->_tmp[
'paint_stack'];
697 $current_asset =& $this->_tmp[
'current_asset'];
698 $depth =& $this->_tmp[
'depth'];
703 $this->_tmp[
'root_treeid'] = $attrs[
'root_treeid'];
707 $current_asset = Array();
714 $this->_tmp[
'current_design_url'] = $attrs[
'url'];
721 array_unshift($stack, $tag);
738 $stack =& $this->_tmp[
'paint_stack'];
739 $current_asset =& $this->_tmp[
'current_asset'];
740 $depth =& $this->_tmp[
'depth'];
742 $open_tag = array_get_index($stack, 0);
743 $parent_tag = array_get_index($stack, 1);
744 $grandparent_tag = array_get_index($stack, 2);
747 if ($data ==
"\n")
return;
749 if ($parent_tag ==
'fields') {
751 $current_asset[$open_tag] = $data;
753 }
else if ($grandparent_tag ==
'fields') {
756 if (!is_array(array_get_index($current_asset,$parent_tag))) {
757 $current_asset[$parent_tag] = Array();
759 array_push($current_asset[$parent_tag], $data);
761 }
else if ($parent_tag ==
'design_type') {
763 if ($open_tag ==
'type') {
764 $this->_tmp[
'current_design_type'] = $data;
765 }
else if ($open_tag ==
'id') {
766 if (!isset($current_asset[
'designs'][$this->_tmp[
'current_design_url']])) {
767 $current_asset[
'designs'][$this->_tmp[
'current_design_url']] = Array();
769 $current_asset[
'designs'][$this->_tmp[
'current_design_url']][$this->_tmp[
'current_design_type']] = $data;
770 unset($this->_tmp[
'current_design_type']);
788 $stack =& $this->_tmp[
'paint_stack'];
789 $current_asset =& $this->_tmp[
'current_asset'];
790 $depth =& $this->_tmp[
'depth'];
824 echo
'<table class="sq-backend-table">';
828 $field_selector = $GLOBALS[
'SQ_SYSTEM']->am->getAttribute($asset->vars[
'selected_asset_fields'][
'attrid']);
829 $field_name_translation = $field_selector->getOptions();
833 echo
'<td class="sq-backend-table-header">Asset</td>';
834 $selected_asset_fields = explode(
'|', $asset->
attr(
'selected_asset_fields'));
835 $this->_tmp[
'selected_asset_fields'] = $selected_asset_fields;
836 foreach ($selected_asset_fields as $field) {
837 echo
'<td class="sq-backend-table-header">'.str_replace(
' ',
' ', $field_name_translation[$field]).
'</td>';
841 $this->_tmp[
'paint_stack'] = Array();
842 $this->_tmp[
'current_asset'] = Array();
843 $this->_tmp[
'depth'] = 0;
846 $xml_parser = xml_parser_create();
848 xml_parser_set_option ($xml_parser, XML_OPTION_CASE_FOLDING, 0);
849 xml_set_character_data_handler ( $xml_parser, Array(&$this,
'tagContent') );
850 xml_set_element_handler($xml_parser, Array(&$this,
'startElement'), Array(&$this,
'endElement'));
853 $report_path = $asset->data_path.
'/report.xml';
857 if (!xml_parse($xml_parser, file_get_contents($report_path), TRUE)) {
858 trigger_localised_error(
'CORE0257', E_USER_WARNING, $report_path);
883 echo
'<td class="sq-backend-table-cell">';
884 $this->
_paintFieldShortName($current_asset[
'short_name'], $current_asset[
'asset_type'], $current_asset[
'treeid']);
887 unset($current_asset[
'short_name']);
890 $selected_asset_fields = $this->_tmp[
'selected_asset_fields'];
891 foreach ($selected_asset_fields as $selected_field) {
892 $field = array_get_index($current_asset, $selected_field);
893 echo
'<td class="sq-backend-table-cell">';
894 $paint_function =
'_paintField'.str_replace(
' ',
'', ucwords(str_replace(
'_',
' ', $selected_field)));
895 $this->$paint_function($field);
915 $depth = strlen($treeid)/SQ_CONF_ASSET_TREE_SIZE - strlen($this->_tmp[
'root_treeid'])/SQ_CONF_ASSET_TREE_SIZE ;
916 $type_name = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($type_code,
'name');
917 echo
'<div style="margin-left: '.($depth * 10).
'px">
918 <script type="text/javascript">sq_print_icon("'.$GLOBALS[
'SQ_SYSTEM']->am->getAssetIconURL($type_code).
'", "16", "16", "'.$type_name.
'");</script> '.str_replace(
' ',
' ', $data).
'
949 $status_names = get_status_names();
950 ?><div style=
"text-align: center; padding: 0 1ex 0 1ex; background: #<?php echo get_status_colour($data); ?>">
951 <?php echo $status_names[$data]; ?>
967 $type_name = $GLOBALS[
'SQ_SYSTEM']->am->getTypeInfo($data,
'name');
969 <script type=
"text/javascript">sq_print_icon(
"<?php echo $GLOBALS['SQ_SYSTEM']->am->getAssetIconURL($data); ?>",
"16",
"16",
"<?php echo $type_name; ?>");</script>
1121 if (!empty($data)) echo implode(
"<br />\n", $data);
1136 if (!empty($data)) {
1147 foreach ($data as $url => $designs) {
1148 echo
'<fieldset><legend>'.$url.
'</legend>';
1149 foreach ($designs as $design_name => $design_id) {
1152 preg_match(
'/^design::(system|user)::(.*)$/', $design_name, $matches);
1153 $design_type = $matches[1];
1154 $design_code = $matches[2];
1155 $display_name = translate(
'config_display_name', ucwords($design_type), ucwords(str_replace(
'_',
' ', $design_code)));
1158 echo
'</fieldset><br>';
1175 if (!empty($data)) {
1176 foreach ($data as $schemaid) {
1194 if (!empty($data)) {
1195 foreach ($data as $schemaid) {
1214 $whitelist =& $this->_tmp[
'whitelist'];
1215 if (!isset($whitelist[$type])) {
1217 foreach ($allowed_types as $allowed_type => $inherit) {
1219 $type_desc = $GLOBALS[
'SQ_SYSTEM']->am->getTypeDescendants($allowed_type, TRUE);
1220 if (in_array($type, $type_desc)) {
1221 $whitelist[$type] = TRUE;
1222 foreach ($type_desc as $descendant) {
1223 $whitelist[$descendant] = TRUE;
1227 if ($type == $allowed_type) $whitelist[$type] = TRUE;
1231 return array_get_index($whitelist, $type, FALSE);
1249 'assetid' => $assetid,
1250 'treeid' => $parent_treeid.
'_%',
1253 }
catch (Exception $e) {