Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
structured_asset_info_edit_fns.inc
1 <?php
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';
20 
34 {
35 
36 
41  function __construct()
42  {
43  parent::__construct();
44 
45  }//end constructor
46 
47 
58  public function paintAssetTypes(Structured_Asset_Info $asset, Backend_Outputter $o, $prefix)
59  {
60  $types = $asset->attr('types');
61  if ($asset->writeAccess('attributes')) {
62  // print the form fields
63  $display_values = Array(
64  'type_code' => Array(),
65  'inherit' => Array(),
66  );
67  foreach ($types as $type => $inherit) {
68  $display_values['type_code'][] = $type;
69  $display_values['inherit'][] = $inherit;
70  }
71  asset_type_chooser($prefix.'_types', TRUE, $display_values, NULL, TRUE, TRUE);
72  return TRUE;
73  } else {
74  // print the read-only version
75  if (empty($types)) {
76  echo '<p class="sq-backend-warning">'.translate('no_types_chosen').'</p>';
77  } else {
78  $type_names = $GLOBALS['SQ_SYSTEM']->am->getTypeInfo(array_keys($types), 'name');
79  ?>
80  <table class="sq-backend-table">
81  <tr>
82  <th><?php echo translate('type') ?></th>
83  <th><?php echo translate('inherit_question') ?></th>
84  </tr>
85  <?php
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');
90  ?>
91  <tr>
92  <td><?php echo $type_names[$type]; ?></td>
93  <td><img src="<?php echo $inherit_image; ?>" alt="<?php echo $inherit_alt; ?>" /></td>
94  </tr>
95  <?php
96  }
97  ?>
98  </table>
99  <?php
100  }
101  return FALSE;
102  }
103 
104  }//end paintAssetTypes()
105 
106 
117  public function processAssetTypes(Structured_Asset_Info $asset, Backend_Outputter $o, $prefix)
118  {
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];
125  }
126  }
127  $asset->setAttrValue('types', $submitted_types);
128  return TRUE;
129  } else {
130  return FALSE;
131  }
132 
133  }//end processAssetTypes()
134 
135 
144  protected function _generateFieldAssetid(Array $asset_info)
145  {
146  return $this->_cData($asset_info['assetid']);
147 
148  }//end _generateFieldAssetid()
149 
150 
159  protected function _generateFieldStatus(Array $asset_info)
160  {
161  return $asset_info['status'];
162 
163  }//end _generateFieldStatus()
164 
165 
174  protected function _generateFieldAssetType(Array $asset_info)
175  {
176  return $this->_cData($asset_info['type_code']);
177 
178  }//end _generateFieldAssetType()
179 
180 
189  protected function _generateFieldName(Array $asset_info)
190  {
191  return $this->_cData($asset_info['name']);
192 
193  }//end _generateFieldName()
194 
195 
204  protected function _generateFieldCreatedDate(Array $asset_info)
205  {
206  return $asset_info['created'];
207 
208  }//end _generateFieldCreatedDate()
209 
210 
219  protected function _generateFieldCreatedUser(Array $asset_info)
220  {
221  return $asset_info['created_userid'];
222 
223  }//end _generateFieldCreatedUser()
224 
225 
234  protected function _generateFieldLastUpdatedDate(Array $asset_info)
235  {
236  return $asset_info['updated'];
237 
238  }//end _generateFieldLastUpdatedDate()
239 
240 
249  protected function _generateFieldLastUpdatedUser(Array $asset_info)
250  {
251  return $asset_info['updated_userid'];
252 
253  }//end _generateFieldLastUpdatedUser()
254 
255 
264  protected function _generateFieldLastPublishedDate(Array $asset_info)
265  {
266  return $asset_info['published'];
267 
268  }//end _generateFieldLastPublishedDate()
269 
270 
279  protected function _generateFieldLastPublishedUser(Array $asset_info)
280  {
281  return $asset_info['published_userid'];
282 
283  }//end _generateFieldLastPublishedUser()
284 
285 
294  protected function _generateFieldLastStatusChangeDate(Array $asset_info)
295  {
296  return $asset_info['status_changed'];
297 
298  }//end _generateFieldLastStatusChangeDate()
299 
300 
309  protected function _generateFieldLastStatusChangeUser(Array $asset_info)
310  {
311  return $asset_info['status_changed_userid'];
312 
313  }//end _generateFieldLastStatusChangeUser()
314 
315 
324  protected function _generateFieldUrls(Array $asset_info)
325  {
326  $value = '';
327  $asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($asset_info['assetid']);
328  $urls = $asset->getLookups();
329  if (!empty($urls)) {
330  usort($urls, create_function('$a, $b', 'return strcmp($a[\'url\'], $b[\'url\']);'));
331  foreach ($urls as $data) {
332  if ($data['http']) {
333  $value .= '<url>http://'.$data['url'].'</url>'."\n";
334  }
335  if ($data['https']) {
336  $value .= '<url>https://'.$data['url'].'</url>'."\n";
337  }
338  }
339  }
340  return $value;
341 
342  }//end _generateFieldUrls()
343 
344 
353  protected function _generateFieldDesigns(Array $asset_info)
354  {
355  $value = '';
356  $asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($asset_info['assetid']);
357  $designs = $asset->getDesignLookups();
358  ksort($designs);
359  /*
360  example xml, see _paintFieldDesigns() for example data
361  <designs>
362  <design url="url_one">
363  <design_type>
364  <type><![CDATA[design::user::printer friendly]]></type>
365  <id><![CDATA[88]]></id>
366  </design_type>
367  <design_type>
368  <type><![CDATA[design::system::frontend]]></type>
369  <id><![CDATA[91]]></id>
370  </design_type>
371  <design_type>
372  <type><![CDATA[design::system::login]]></type>
373  <id><![CDATA[41]]></id>
374  <design_type>
375  </design>
376  </designs>
377  */
378  foreach ($designs as $url => $data) {
379  // store all design applied to this URL to the report
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";
386  }
387  $value .= "</design>\n";
388  }
389  return $value;
390 
391  }//end _generateFieldDesigns()
392 
393 
402  protected function _generateFieldMetadataSchemas(Array $asset_info)
403  {
404  $value = '';
405  $mm = $GLOBALS['SQ_SYSTEM']->getMetadataManager();
406  $schemas = $mm->getSchemas($asset_info['assetid'], TRUE);
407  foreach ($schemas as $schemaid) {
408  // get the name of the schema, put it into the tag pre-formatted
409  $value .= '<schema>'.$schemaid.'</schema>'."\n";
410  }
411  return $value;
412 
413  }//end _generateFieldMetadataSchemas()
414 
415 
424  protected function _generateFieldWorkflowSchemas(Array $asset_info)
425  {
426  $value = '';
427  $wm = $GLOBALS['SQ_SYSTEM']->getWorkflowManager();
428  $schemas = $wm->getSchemas($asset_info['assetid'], TRUE);
429  foreach ($schemas as $schemaid) {
430  // get the name of the schema, put it into the tag pre-formatted
431  $value .= '<schema>'.$schemaid.'</schema>'."\n";
432  }
433  return $value;
434 
435  }//end _generateFieldWorkflowSchemas()
436 
437 
446  protected function _printAssetTagLine($assetid)
447  {
448  $value = '';
449  if (!empty($assetid)) {
450  $value = get_asset_tag_line($assetid);
451  }
452  return $value;
453 
454  }//end _printAssetTagLine()
455 
456 
465  protected function _cData($character_data)
466  {
467  return '<![CDATA['.$character_data.']]>';
468 
469  }//end _cData()
470 
471 
482  public function generateReport(HIPO_Job $job, Array &$step_data, $prefix)
483  {
484  $am = $GLOBALS['SQ_SYSTEM']->am;
485 
486  $owner = $am->getAsset($job->_running_vars['assetid']);
487 
488  if (!isset($job->_running_vars['assets_to_list'])) {
489  // this is the first step
490 
491  // get the selected fields and store them in the running vars
492  if ($owner->attr('selected_asset_fields') == '') {
493  trigger_localised_error('RPRT0003', E_USER_WARNING);
494  }
495  $job->_running_vars['selected_asset_fields'] = explode('|', $owner->attr('selected_asset_fields'));
496 
497 
498  // get the immediate children of the root to start the stack
499  $assets_to_list = Array();
500 
501  $root_id = $this->getRootAssetid($owner);
502  if (!$root_id) {
503  trigger_localised_error('RPRT0004', E_USER_WARNING);
504  return FALSE;
505  }
506 
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']);
511  }
512  }
513 
514  $job->_running_vars['assets_to_list'] = $assets_to_list;
515  $job->_running_vars['assets_open'] = Array();
516  $job->_running_vars['assets_skipped'] = Array();
517 
518  // find the total number of children that we will eventually process
519  $asset_treeids = $am->getAssetTreeids($root_id);
520  $root_treeid = reset($asset_treeids);
521  $root_treeid = $root_treeid === '-' ? '' : $root_treeid;
522 
523  try {
524  $bind_vars['treeid'] = $root_treeid.'_%';
525  $total = MatrixDAL::executeOne('structured_asset_info', 'linkTreeCount', $bind_vars);
526  } catch (Exception $e) {
527  throw new Exception('Unable to get link tree count for "'.$root_treeid.'": '.$e->getMessage());
528  $total = 0;
529  }
530 
531  // double the number of steps to-do because two steps are required for each asset
532  $job->_running_vars['total'] = $total*2;
533  $job->_running_vars['done'] = 0;
534 
535 
536  // prepare a directory in which to write the log file
537  $report_dir = $owner->data_path;
538  $xml_file_name = $report_dir.'/report.tmp';
539 
540  if (!is_dir($report_dir)) {
541  if (!create_directory($report_dir)) {
542  trigger_localised_error('CORE0198', E_USER_WARNING);
543  return FALSE;
544  }
545  }
546 
547  // file manipulation section
548  $temp_file = fopen($xml_file_name, 'w');
549  if ($temp_file === FALSE) {
550  trigger_localised_error('CORE0017', E_USER_WARNING);
551  return FALSE;
552  }
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");
555  } else {
556 
557  $temp_file = fopen($owner->data_path.'/report.tmp', 'a');
558  if ($temp_file === FALSE) {
559  trigger_localised_error('RPRT0000', E_USER_WARNING);
560  return FALSE;
561  }
562  }
563 
564  $assets_per_step = 50;
565  $target_this_step = $job->_running_vars['done'] + $assets_per_step;
566 
567  $nothing_open = Array(
568  'assetid' => '',
569  'treeid' => '',
570  );
571 
572  while (!empty($job->_running_vars['assets_to_list']) && $job->_running_vars['done'] < $target_this_step) {
573  $asset_info = Array();
574  $contents = '';
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];
580  // generate XML contents
581 
582  $open_asset = array_get_index($assets_open, 0, $nothing_open);
583 
584  if ($current_assetid == $open_asset['assetid']) {
585  // closing - look up the tree one level
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);
590  } else {
591  $contents .= '</children>'."\n";
592  $contents .= '</asset>'."\n";
593  }
594 
595  } else {
596 
597 
598  $asset_info = $am->getAssetInfo(Array($current_assetid));
599  if (isset($asset_info[$current_assetid])) {
600  // if getAssetInfo returns empty array, then might be a problem with the shadow asset bridge
601  $asset_info = $asset_info[$current_assetid];
602  }
603  $asset_info['treeid'] = $this->getTreeid($current_assetid, $open_asset['treeid']);
604  $asset_info['assetid'] = $current_assetid;
605 
606  if (!isset($asset_info['type_code']) || !$this->checkType($asset_info['type_code'], $owner->attr('types'))) {
607  // skip this asset - don't display it in the XML, but do check it's children, so add it to the stack
608  array_unshift($assets_skipped, $current_assetid);
609  } else {
610 
611  // starting a new asset
612  $contents .= '<asset>'."\n";
613 
614  // generate the fields for this asset
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)) {
619  // add in asset type code as it will be used for other fields
620  $contents .= '<asset_type><![CDATA['.$asset_info['type_code'].']]></asset_type>';
621  }
622  foreach ($selected_asset_fields as $name) {
623  $contents .= '<'.$name.'>';
624  $function_name = '_generateField'.str_replace(' ', '', ucwords(str_replace('_', ' ', $name)));
625 
626  $contents .= $this->$function_name($asset_info);
627  $contents .= '</'.$name.'>'."\n";
628  }
629  $contents .= '</fields>'."\n";
630 
631  // open the children section of this asset and prepare to start listing our children on the next iteration
632  $contents .= '<children>'."\n";
633  }
634  $child_links = $am->getLinks($current_assetid, SQ_SC_LINK_BACKEND_NAV);
635  // get more assets to list and stack em
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']);
639  }
640  }
641  $new_open_asset = Array(
642  'assetid' => $asset_info['assetid'],
643  'treeid' => $asset_info['treeid'],
644  );
645  array_unshift($assets_open, $new_open_asset);
646 
647  }//end else
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;
651 
652  fwrite($temp_file, $contents);
653 
654  $job->_running_vars['done']++;
655 
656  }//end while there are still assets to list
657 
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");
663  // move the temp file to become the real report XML file
664  if (!copy($owner->data_path.'/report.tmp', $owner->data_path.'/report.xml')) {
665  trigger_localised_error('RPRT0001', E_USER_WARNING);
666  return FALSE;
667  }
668  if (!unlink($owner->data_path.'/report.tmp')) {
669  trigger_localised_error('RPRT0002', E_USER_WARNING);
670  }
671  } else {
672  $total = $job->_running_vars['total'];
673  $step_data['percent_done'] = ($job->_running_vars['done'] / $total) * 100;
674  $step_data['complete'] = FALSE;
675  }
676 
677  fclose($temp_file);
678  return TRUE;
679 
680  }//end generateReport()
681 
682 
693  public function startElement($parser, $tag, $attrs)
694  {
695 
696  $stack =& $this->_tmp['paint_stack'];
697  $current_asset =& $this->_tmp['current_asset'];
698  $depth =& $this->_tmp['depth'];
699 
700  switch ($tag) {
701  case 'assets':
702  // set any attributes that apply to the whole report
703  $this->_tmp['root_treeid'] = $attrs['root_treeid'];
704  break;
705  case 'fields':
706  // reset the current asset
707  $current_asset = Array();
708  break;
709  case 'children':
710  $depth++;
711  break;
712  case 'design':
713  // store the url attribute that will be applied to all design types
714  $this->_tmp['current_design_url'] = $attrs['url'];
715  break;
716 
717  default:
718  // ignore tag
719  }
720  // add the open tag to the stack
721  array_unshift($stack, $tag);
722 
723  }//end startElement()
724 
725 
735  public function tagContent($parser, $data)
736  {
737 
738  $stack =& $this->_tmp['paint_stack'];
739  $current_asset =& $this->_tmp['current_asset'];
740  $depth =& $this->_tmp['depth'];
741 
742  $open_tag = array_get_index($stack, 0);
743  $parent_tag = array_get_index($stack, 1);
744  $grandparent_tag = array_get_index($stack, 2);
745 
746  // the parser treats newlines as character data, in which we're not interested.
747  if ($data == "\n") return;
748 
749  if ($parent_tag == 'fields') {
750  // we're a string
751  $current_asset[$open_tag] = $data;
752 
753  } else if ($grandparent_tag == 'fields') {
754  // we're an array
755  // use the name of our parent tag because the open tag is only the name of the array element, not the whole array
756  if (!is_array(array_get_index($current_asset,$parent_tag))) {
757  $current_asset[$parent_tag] = Array();
758  }
759  array_push($current_asset[$parent_tag], $data);
760 
761  } else if ($parent_tag == 'design_type') {
762  // construct the design data array
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();
768  }
769  $current_asset['designs'][$this->_tmp['current_design_url']][$this->_tmp['current_design_type']] = $data;
770  unset($this->_tmp['current_design_type']);
771  }
772  }
773 
774  }//end tagContent()
775 
776 
786  public function endElement($parser, $tag)
787  {
788  $stack =& $this->_tmp['paint_stack'];
789  $current_asset =& $this->_tmp['current_asset'];
790  $depth =& $this->_tmp['depth'];
791 
792  switch ($tag) {
793  case 'fields':
794  // paint the current asset
795  $this->_paintAsset($current_asset);
796  break;
797  case 'children':
798  $depth--;
799  break;
800 
801  default:
802  // ignore tag
803  }
804  // remove the closing tag from the stack
805  array_shift($stack);
806 
807  }//end endElement()
808 
809 
820  public function paintReport(Structured_Asset_Info $asset, Backend_Outputter $o, $prefix)
821  {
822 
823  // start the page - <table> etc
824  echo '<table class="sq-backend-table">';
825 
826  // print the table header row
827 
828  $field_selector = $GLOBALS['SQ_SYSTEM']->am->getAttribute($asset->vars['selected_asset_fields']['attrid']);
829  $field_name_translation = $field_selector->getOptions();
830 
831  echo '<tr>';
832  // first cell contains the short name
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(' ','&nbsp;', $field_name_translation[$field]).'</td>';
838  }
839  echo '</tr>';
840 
841  $this->_tmp['paint_stack'] = Array();
842  $this->_tmp['current_asset'] = Array();
843  $this->_tmp['depth'] = 0;
844 
845 
846  $xml_parser = xml_parser_create();
847  // stop the parser ucasing everything
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'));
851 
852  // initialise the file pointer
853  $report_path = $asset->data_path.'/report.xml';
854 
855  // Parse the file
856 
857  if (!xml_parse($xml_parser, file_get_contents($report_path), TRUE)) {
858  trigger_localised_error('CORE0257', E_USER_WARNING, $report_path);
859  return FALSE;
860  }
861 
862  // finish the page
863  echo '</table>';
864 
865  return TRUE;
866 
867  }//end paintReport()
868 
869 
878  protected function _paintAsset(Array $current_asset)
879  {
880  echo '<tr>';
881 
882  // first cell contains the short name indented to indicate the tree structure
883  echo '<td class="sq-backend-table-cell">';
884  $this->_paintFieldShortName($current_asset['short_name'], $current_asset['asset_type'], $current_asset['treeid']);
885  echo '</td>';
886 
887  unset($current_asset['short_name']);
888 
889  // paint the rest of the fields
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);
896  echo '</td>';
897  }
898  echo '</tr>';
899 
900  }//end _paintAsset()
901 
902 
913  protected function _paintFieldShortName($data, $type_code, $treeid)
914  {
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>&nbsp;'.str_replace(' ', '&nbsp;', $data).'
919  </div>';
920 
921  }//end _paintFieldShortName()
922 
923 
932  protected function _paintFieldAssetid($data)
933  {
934  echo $data;
935 
936  }//end _paintFieldAssetid()
937 
938 
947  protected function _paintFieldStatus($data)
948  {
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]; ?>
952  </div><?php
953 
954  }//end _paintFieldStatus()
955 
956 
965  protected function _paintFieldAssetType($data)
966  {
967  $type_name = $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($data, 'name');
968  ?>
969  <script type="text/javascript">sq_print_icon("<?php echo $GLOBALS['SQ_SYSTEM']->am->getAssetIconURL($data); ?>", "16", "16", "<?php echo $type_name; ?>");</script>
970  <?php echo $data; ?>
971  <?php
972 
973  }//end _paintFieldAssetType()
974 
975 
984  protected function _paintFieldName($data)
985  {
986  echo $data;
987 
988  }//end _paintFieldName()
989 
990 
999  protected function _paintFieldCreatedDate($data)
1000  {
1001  echo $data;
1002 
1003  }//end _paintFieldCreatedDate()
1004 
1005 
1014  protected function _paintFieldCreatedUser($data)
1015  {
1016  echo $this->_printAssetTagLine($data);
1017 
1018  }//end _paintFieldCreatedUser()
1019 
1020 
1029  protected function _paintFieldLastUpdatedDate($data)
1030  {
1031  echo $data;
1032 
1033  }//end _paintFieldLastUpdatedDate()
1034 
1035 
1044  protected function _paintFieldLastUpdatedUser($data)
1045  {
1046  echo $this->_printAssetTagLine($data);
1047 
1048  }//end _paintFieldLastUpdatedUser()
1049 
1050 
1059  protected function _paintFieldLastPublishedDate($data)
1060  {
1061  echo $data;
1062 
1063  }//end _paintFieldLastPublishedDate()
1064 
1065 
1074  protected function _paintFieldLastPublishedUser($data)
1075  {
1076  echo $this->_printAssetTagLine($data);
1077 
1078  }//end _paintFieldLastPublishedUser()
1079 
1080 
1089  protected function _paintFieldLastStatusChangeDate($data)
1090  {
1091  echo $data;
1092 
1093  }//end _paintFieldLastStatusChangeDate()
1094 
1095 
1104  protected function _paintFieldLastStatusChangeUser($data)
1105  {
1106  echo $this->_printAssetTagLine($data);
1107 
1108  }//end _paintFieldLastStatusChangeUser()
1109 
1110 
1119  protected function _paintFieldUrls($data)
1120  {
1121  if (!empty($data)) echo implode("<br />\n", $data);
1122 
1123  }//end _paintFieldUrls()
1124 
1125 
1134  protected function _paintFieldDesigns($data)
1135  {
1136  if (!empty($data)) {
1137  /*
1138  example data, see _generateFieldDesigns() for example xml
1139  array(
1140  "url_one" => array (
1141  "design::user::printer friendly" => "88",
1142  "design::system::frontend" => "91",
1143  "design::system::login" => "41"
1144  )
1145  )
1146  */
1147  foreach ($data as $url => $designs) {
1148  echo '<fieldset><legend>'.$url.'</legend>';
1149  foreach ($designs as $design_name => $design_id) {
1150  // work out the display name of this design
1151  $matches = Array();
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)));
1156  echo $display_name.': '.$this->_printAssetTagLine($design_id)."<br>\n";
1157  }
1158  echo '</fieldset><br>';
1159  }
1160  }
1161 
1162  }//end _paintFieldDesigns()
1163 
1164 
1173  protected function _paintFieldMetadataSchemas($data)
1174  {
1175  if (!empty($data)) {
1176  foreach ($data as $schemaid) {
1177  echo $this->_printAssetTagLine($schemaid)."<br />\n";
1178  }
1179  }
1180 
1181  }//end _paintFieldMetadataSchemas()
1182 
1183 
1192  protected function _paintFieldWorkflowSchemas($data)
1193  {
1194  if (!empty($data)) {
1195  foreach ($data as $schemaid) {
1196  echo $this->_printAssetTagLine($schemaid)."<br />\n";
1197  }
1198  }
1199 
1200  }//end _paintFieldWorkflowSchemas()
1201 
1202 
1212  public function checkType($type, Array $allowed_types)
1213  {
1214  $whitelist =& $this->_tmp['whitelist'];
1215  if (!isset($whitelist[$type])) {
1216  // build a whitelist if this is the first check
1217  foreach ($allowed_types as $allowed_type => $inherit) {
1218  if ($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;
1224  }
1225  }
1226  } else {
1227  if ($type == $allowed_type) $whitelist[$type] = TRUE;
1228  }
1229  }
1230  }
1231  return array_get_index($whitelist, $type, FALSE);
1232 
1233  }//end checkType()
1234 
1235 
1245  public function getTreeid($assetid, $parent_treeid)
1246  {
1247  try {
1248  $bind_vars = Array(
1249  'assetid' => $assetid,
1250  'treeid' => $parent_treeid.'_%',
1251  );
1252  $treeid = MatrixDAL::executeOne('structured_asset_info', 'getTreeid', $bind_vars);
1253  } catch (Exception $e) {
1254  $treeid = '';
1255  }
1256 
1257  return $treeid;
1258 
1259  }//end getTreeid()
1260 
1261 
1262 }//end class
1263 
1264 ?>