ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTermsOfServiceAgreementByLanguageTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceTableGUI.php';
5 
11 {
16  public function __construct(ilObjectGUI $a_parent_obj, $a_parent_cmd)
17  {
21  global $ilCtrl;
22 
23  $this->ctrl = $ilCtrl;
24 
25  // Call this immediately in constructor
26  $this->setId('tos_agreement_by_lng');
27 
28  $this->setDefaultOrderDirection('ASC');
29  $this->setDefaultOrderField('language');
30  $this->setExternalSorting(false);
31  $this->setExternalSegmentation(false);
32 
33  parent::__construct($a_parent_obj, $a_parent_cmd);
34 
35  $this->setTitle($this->lng->txt('tos_agreement_by_lng'));
36 
37  $this->addColumn($this->lng->txt('language'), 'language');
38  $this->addColumn($this->lng->txt('tos_agreement'), 'agreement');
39  $this->addColumn($this->lng->txt('tos_agreement_document'), 'agreement_document');
40  $this->optionalColumns = (array)$this->getSelectableColumns();
41  $this->visibleOptionalColumns = (array)$this->getSelectedColumns();
42  foreach($this->visibleOptionalColumns as $column)
43  {
44  $this->addColumn($this->optionalColumns[$column]['txt'], $column);
45  }
46 
47  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, 'applyAgreementByLanguageFilter'));
48 
49  $this->setRowTemplate('tpl.tos_agreement_by_lng_table_row.html', 'Services/TermsOfService');
50 
51  $this->setShowRowsSelector(true);
52 
53  require_once 'Services/jQuery/classes/class.iljQueryUtil.php';
54  require_once 'Services/YUI/classes/class.ilYuiUtil.php';
58 
59  $this->initFilter();
60  $this->setFilterCommand('applyAgreementByLanguageFilter');
61  $this->setResetCommand('resetAgreementByLanguageFilter');
62  }
63 
67  public function getSelectableColumns()
68  {
69  $cols = array('agreement_document_modification_ts' => array('txt' => $this->lng->txt('tos_last_modified'), 'default' => true));
70 
71  return $cols;
72  }
73 
78  protected function prepareData(array &$data)
79  {
80  foreach($data['items'] as &$row)
81  {
82  $row['language'] = $this->lng->txt('meta_l_' . $row['language']);
83  }
84  }
85 
90  protected function prepareRow(array &$row)
91  {
92  if(is_string($row['agreement_document']) && strlen($row['agreement_document']))
93  {
94  $this->ctrl->setParameter($this->getParentObject(), 'agreement_document', rawurlencode($row['agreement_document']));
95  $row['content_link'] = $this->ctrl->getLinkTarget($this->getParentObject(), 'getAgreementTextByFilenameAsynch', '', true, false);
96  $this->ctrl->setParameter($this->getParentObject(), 'agreement_document', '');
97  $row['img_down'] = ilUtil::getImagePath('icon_preview.png');
98  $row['id'] = md5($row['language']);
99  }
100  else
101  {
102  $row['missing_agreement_css_class'] = 'warning';
103  }
104  }
105 
109  protected function getStaticData()
110  {
111  return array('id', 'language', 'agreement', 'missing_agreement_css_class', 'agreement_document', 'content_link', 'img_down', 'language_key');
112  }
113 
119  protected function formatCellValue($column, array $row)
120  {
121  if($column == 'agreement_document')
122  {
123  if(!is_string($row[$column]) || !strlen($row[$column]))
124  {
125  return $this->lng->txt('tos_agreement_document_missing');
126  }
127  }
128  else if($column == 'agreement')
129  {
130  if($row[$column])
131  {
132  return $this->lng->txt('tos_agreement_exists');
133  }
134  else
135  {
136  return $this->lng->txt('tos_agreement_missing');
137  }
138  }
139  else if($column == 'agreement_document_modification_ts')
140  {
141  return ilDatePresentation::formatDate(new ilDateTime($row[$column], IL_CAL_UNIX));
142  }
143 
144  return $row[$column];
145  }
146 
151  public function numericOrdering($column)
152  {
153  if('agreement_document_modification_ts' == $column)
154  {
155  return true;
156  }
157 
158  return false;
159  }
160 }