ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilQuestionUsagesTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/Table/classes/class.ilTable2GUI.php';
5 require_once 'Services/Tree/classes/class.ilPathGUI.php';
6 require_once 'Services/Link/classes/class.ilLink.php';
7 
13 {
17  protected $question;
18 
25  public function __construct($controller, $cmd, $template_context, assQuestion $question)
26  {
27  $this->question = $question;
28  $this->setId('qst_usage_' . $question->getId());
29  parent::__construct($controller, $cmd);
30 
31  $this->setRowTemplate('tpl.il_as_qpl_question_usage_table_row.html', 'Modules/TestQuestionPool');
32  $this->setLimit(PHP_INT_MAX);
33 
34  $this->setDefaultOrderField('title');
35  $this->setDefaultOrderDirection('ASC');
36 
37  $this->setTitle($this->lng->txt('question_instances_title'));
38 
39  $this->disable('sort');
40  $this->disable('hits');
41  $this->disable('numinfo');
42 
43  $this->initColumns();
44  $this->initData();
45  }
46 
50  protected function initColumns()
51  {
52  $this->addColumn($this->lng->txt('title'), 'title');
53  $this->addColumn($this->lng->txt('author'), 'author');
54  $this->addColumn($this->lng->txt('path'), '');
55  }
56 
60  protected function initData()
61  {
65  global $tree;
66 
67  $path = new ilPathGUI();
68 
69  $rows = array();
70  foreach($this->question->getInstances() as $instance)
71  {
72  foreach($instance['refs'] as $ref_id)
73  {
74  $trashed = $tree->isDeleted($ref_id);
75  $rows[] = array(
76  'title' => $instance['title'],
77  'author' => $instance['author'],
78  'ref_id' => $ref_id,
79  'is_trashed' => $trashed,
80  'path' => $trashed ? $this->lng->txt('deleted') : $path->getPath(ROOT_FOLDER_ID, $ref_id)
81  );
82  }
83  }
84  $this->setData($rows);
85  }
86 
90  public function fillRow(array $row)
91  {
95  global $ilAccess;
96 
97  $this->tpl->setVariable('USAGE_INSTANCE_TITLE', $row['title']);
98  $this->tpl->setVariable('USAGE_AUTHOR', $row['author']);
99  $this->tpl->setVariable('USAGE_PATH', $row['path']);
100 
101  if($ilAccess->checkAccess('read', '', $row['ref_id']) && !$row['is_trashed'])
102  {
103  $link = new ilLink();
104 
105  $this->tpl->setVariable('USAGE_INSTANCE_LINKTED_TITLE', $row['title']);
106  $this->tpl->setVariable('USAGE_INSTANCE_HREF', $link->_getStaticLink($row['ref_id'], 'tst'));
107 
108  $this->tpl->setCurrentBlock('linked_title_b');
109  $this->tpl->touchBlock('linked_title_b');
110  $this->tpl->parseCurrentBlock();
111  }
112  }
113 }