ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilOrgUnitTreeExplorerGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 
15 {
16  private $tpl = null;
17 
18  public function __construct(ilOrgUnit $a_root_unit)
19  {
20  $this->root_unit = $a_root_unit;
21 
22  $this->tpl = new ilTemplate('tpl.org_unit_tree_explorer.html', true, true, 'Services/OrgUnit');
23  }
24 
25  private function renderUnit(ilOrgUnit $a_unit, $a_depth)
26  {
27  global $lng;
28 
29  $a_unit->initAssigns();
30 
31  $this->tpl->setCurrentBlock('exp_item_begin');
32  $this->tpl->setVariable('CLASSNAME', 'depth_'.$a_depth);
33  $this->tpl->parseCurrentBlock();
34 
35  for($i = 1; $i < $a_depth; $i++)
36  {
37  $this->tpl->setCurrentBlock('exp_item_indent');
38  $this->tpl->touchBlock('exp_item_indent');
39  $this->tpl->parseCurrentBlock();
40  }
41 
42  $this->tpl->setCurrentBlock('exp_item_icon');
43  $this->tpl->setVariable('ITEM_ICON_SRC', ilUtil::getImagePath('icon_root_s.gif'));
44  $this->tpl->parseCurrentBlock();
45 
46  if($a_unit->getId() == ilOrgUnitTree::ROOT_UNIT_ID)
47  {
48  $this->tpl->setCurrentBlock('exp_item_title');
49  $this->tpl->setVariable('ITEM_TITLE', $lng->txt('org_unit_tree_root'));
50  $this->tpl->parseCurrentBlock();
51  }
52  else
53  {
54  $this->tpl->setCurrentBlock('exp_item_title');
55  $this->tpl->setVariable('ITEM_TITLE', $a_unit->getTitle());
56  $this->tpl->parseCurrentBlock();
57 
58  $this->tpl->setCurrentBlock('exp_item_subtitle');
59  $this->tpl->setVariable('ITEM_SUBTITLE', $a_unit->getSubTitle());
60  $this->tpl->parseCurrentBlock();
61  }
62 
63  $this->tpl->setCurrentBlock('explorer');
64  $this->tpl->parseCurrentBlock();
65 
66  #$assigned_users = $a_unit->getAssignedUsers();
67  $assigned_users = array();
68  if( count($assigned_users) )
69  {
70  $this->tpl->setCurrentBlock('exp_list_begin');
71  $this->tpl->setVariable('CLASSNAME', 'depth_'.($a_depth + 1));
72  $this->tpl->parseCurrentBlock();
73 
74  $this->tpl->setCurrentBlock('explorer');
75  $this->tpl->parseCurrentBlock();
76 
77  foreach($assigned_users as $user_id => $properties)
78  {
79  $user = ilObjectFactory::getInstanceByObjId($user_id);
80 
81  $this->tpl->setCurrentBlock('exp_item_begin');
82  $this->tpl->setVariable('CLASSNAME', 'depth_'.($a_depth + 1));
83  $this->tpl->parseCurrentBlock();
84 
85  for($i = 1; $i < ($a_depth + 1); $i++)
86  {
87  $this->tpl->setCurrentBlock('exp_item_indent');
88  $this->tpl->touchBlock('exp_item_indent');
89  $this->tpl->parseCurrentBlock();
90  }
91 
92  $this->tpl->setCurrentBlock('exp_item_icon');
93  $this->tpl->setVariable('ITEM_ICON_SRC', ilUtil::getImagePath('icon_usr_s.gif'));
94  $this->tpl->parseCurrentBlock();
95 
96  $this->tpl->setCurrentBlock('exp_item_title');
97  $this->tpl->setVariable('ITEM_TITLE', $user->getLastName().', '.$user->getFirstName());
98  $this->tpl->parseCurrentBlock();
99 
100  $this->tpl->setCurrentBlock('exp_item_end');
101  $this->tpl->touchBlock('exp_item_end');
102  $this->tpl->parseCurrentBlock();
103 
104  $this->tpl->setCurrentBlock('explorer');
105  $this->tpl->parseCurrentBlock();
106  }
107 
108  $this->tpl->setCurrentBlock('exp_list_end');
109  $this->tpl->touchBlock('exp_list_end');
110  $this->tpl->parseCurrentBlock();
111 
112  $this->tpl->setCurrentBlock('explorer');
113  $this->tpl->parseCurrentBlock();
114  }
115 
116  if( $a_unit->hasChilds() )
117  {
118  $this->tpl->setCurrentBlock('exp_list_begin');
119  $this->tpl->setVariable('CLASSNAME', 'depth_'.($a_depth + 1));
120  $this->tpl->parseCurrentBlock();
121 
122  $this->tpl->setCurrentBlock('explorer');
123  $this->tpl->parseCurrentBlock();
124 
125  foreach($a_unit->getChilds() as $child_unit)
126  {
127  $this->renderUnit( $child_unit, ($a_depth + 1) );
128  }
129 
130  $this->tpl->setCurrentBlock('exp_list_end');
131  $this->tpl->touchBlock('exp_list_end');
132  $this->tpl->parseCurrentBlock();
133 
134  $this->tpl->setCurrentBlock('explorer');
135  $this->tpl->parseCurrentBlock();
136  }
137 
138  $this->tpl->setCurrentBlock('exp_item_end');
139  $this->tpl->touchBlock('exp_item_end');
140  $this->tpl->parseCurrentBlock();
141 
142  $this->tpl->setCurrentBlock('explorer');
143  $this->tpl->parseCurrentBlock();
144  }
145 
146  public function getHTML()
147  {
148  $depth = 1;
149 
150  $this->tpl->setCurrentBlock('exp_list_begin');
151  $this->tpl->setVariable('CLASSNAME', 'depth_'.$depth);
152  $this->tpl->parseCurrentBlock();
153 
154  $this->tpl->setCurrentBlock('explorer');
155  $this->tpl->parseCurrentBlock();
156 
157  $this->renderUnit($this->root_unit, $depth);
158 
159  $this->tpl->setCurrentBlock('exp_list_end');
160  $this->tpl->touchBlock('exp_list_end');
161  $this->tpl->parseCurrentBlock();
162 
163  $this->tpl->setCurrentBlock('explorer');
164  $this->tpl->parseCurrentBlock();
165 
166  $html = $this->tpl->get();
167 
168  return $html;
169  }
170 }
171 
172 ?>