Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
content_type_structure_tree.inc
1 <?php
18 require_once SQ_CORE_PACKAGE_PATH.'/content_type/content_type.inc';
19 
32 {
33 
34 
41  function __construct($assetid=0)
42  {
43  $this->_ser_attrs = TRUE;
44  parent::__construct($assetid);
45 
46  }//end constructor
47 
48 
57  function drawTree($show_trailers=FALSE)
58  {
59  $tree_string = '';
60  $classes = $GLOBALS['SQ_SYSTEM']->getUserPrefs($this->type(), 'SQ_STRUCTURE_TREE_NODE_CLASSES');
61 
62  $tree_data = $this->attr('structure');
63  $current_trailers = Array();
64  ob_start();
65  for ($treecount=0; $treecount < count($tree_data); $treecount++) {
66  $data = $tree_data[$treecount];
67  $indent = 0;
68  for ($i = 0; $i < $data['indent']; $i++) {
69  if ($i == ($data['indent'] - 1)) {
70  // Check out whats after to see what to output
71  if (($treecount == count($tree_data) - 1) || ($tree_data[$treecount + 1]['indent'] != $data['indent'])) {
72  ?>
73  <span class="<?php echo $classes['node_branches']; ?>" style="margin-left: 10px;">|_</span>
74  <?php
75  } else {
76  ?>
77  <span class="<?php echo $classes['node_branches']; ?>" style="margin-left: 10px;">|_</span>
78  <?php
79  }
80  } else {
81  $span_text = '&nbsp;';
82  $class_text = '';
83  if ($show_trailers && isset($current_trailers[$i])) {
84  $span_text = '|';
85  $class_text = 'class="'.$classes['node_branches'].'" ';
86  }
87  ?>
88  <span <?php echo $class_text; ?>style="margin-left: 10px;"><?php echo $span_text; ?></span>
89  <?php
90  }
91  }
92 
93  // Get the styles for the content text
94  $style_text = '';
95  if ($data['bold'] != '0') {
96  if ($style_text == '') $style_text = ' style="';
97  $style_text .= 'font-weight: bold;';
98  }
99  if ($data['italic'] != '0') {
100  if ($style_text == '') $style_text = ' style="';
101  $style_text .= 'font-style: italic;';
102  }
103  if ($data['underline'] != '0') {
104  if ($style_text == '') $style_text = ' style="';
105  $style_text .= 'text-decoration: underline;';
106  }
107  if ($style_text != '') $style_text .= '"';
108  ?>
109  <span class="<?php echo $classes['node_text']; ?>" <?php echo $style_text; ?>><?php echo $data['content']; ?></span><br />
110  <?php
111  // Below is a mess, but it unsets any trailers, then searches for new ones based on this
112  if ($show_trailers) {
113  unset($current_trailers[$data['indent'] - 1]);
114  // Now we check to see if we should add some trailers, so this is linked to later instances
115  if (isset($tree_data[$treecount + 1]) && ($tree_data[$treecount + 1]['indent'] > $data['indent'])) {
116  for ($ja = $treecount + 2; $ja < count($tree_data); $ja++) {
117  $next_data = $tree_data[$ja];
118  if ($next_data['indent'] < $data['indent']) break;
119  if ($next_data['indent'] == $data['indent']) {
120  $current_trailers[$data['indent'] - 1] = 'true';
121  }
122  }
123  }
124  }
125  }//end for
126  $tree_string = ob_get_contents();
127  ob_end_clean();
128 
129  return $tree_string;
130 
131  }//end drawTree()
132 
133 
134 }//end class
135 
136 ?>