ILIAS  Release_5_0_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 require_once 'Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php';
6 require_once 'Services/UIComponent/Modal/classes/class.ilModalGUI.php';
7 
13 {
18  public function __construct(ilObjectGUI $a_parent_obj, $a_parent_cmd)
19  {
23  global $ilCtrl;
24 
25  $this->ctrl = $ilCtrl;
26 
27  // Call this immediately in constructor
28  $this->setId('tos_agreement_by_lng');
29 
30  $this->setDefaultOrderDirection('ASC');
31  $this->setDefaultOrderField('language');
32  $this->setExternalSorting(false);
33  $this->setExternalSegmentation(false);
34 
35  parent::__construct($a_parent_obj, $a_parent_cmd);
36 
37  $this->setTitle($this->lng->txt('tos_agreement_by_lng'));
38 
39  $this->addColumn($this->lng->txt('language'), 'language');
40  $this->addColumn($this->lng->txt('tos_agreement'), 'agreement');
41  $this->addColumn($this->lng->txt('tos_agreement_document'), 'agreement_document');
42  $this->optionalColumns = (array)$this->getSelectableColumns();
43  $this->visibleOptionalColumns = (array)$this->getSelectedColumns();
44  foreach($this->visibleOptionalColumns as $column)
45  {
46  $this->addColumn($this->optionalColumns[$column]['txt'], $column);
47  }
48 
49  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, 'applyAgreementByLanguageFilter'));
50 
51  $this->setRowTemplate('tpl.tos_agreement_by_lng_table_row.html', 'Services/TermsOfService');
52 
53  $this->setShowRowsSelector(true);
54 
55  require_once 'Services/jQuery/classes/class.iljQueryUtil.php';
56  require_once 'Services/YUI/classes/class.ilYuiUtil.php';
60 
61  $this->initFilter();
62  $this->setFilterCommand('applyAgreementByLanguageFilter');
63  $this->setResetCommand('resetAgreementByLanguageFilter');
64  }
65 
69  public function getSelectableColumns()
70  {
71  $cols = array('agreement_document_modification_ts' => array('txt' => $this->lng->txt('tos_last_modified'), 'default' => true));
72 
73  return $cols;
74  }
75 
80  protected function prepareData(array &$data)
81  {
82  foreach($data['items'] as &$row)
83  {
84  $row['language'] = $this->lng->txt('meta_l_' . $row['language']);
85  }
86  }
87 
92  protected function prepareRow(array &$row)
93  {
94  if(is_string($row['agreement_document']) && strlen($row['agreement_document']))
95  {
96  $unique_id = md5($row['language']);
97 
98  $this->ctrl->setParameter($this->getParentObject(), 'agreement_document', rawurlencode($row['agreement_document']));
99  $row['content_link'] = $this->ctrl->getLinkTarget($this->getParentObject(), 'getAgreementTextByFilenameAsynch', '', true, false);
100  $this->ctrl->setParameter($this->getParentObject(), 'agreement_document', '');
101  $row['img_down'] = ilGlyphGUI::get(ilGlyphGUI::SEARCH);
102  $row['id'] = $unique_id;
103 
104  $modal = ilModalGUI::getInstance();
105  $modal->setHeading($this->lng->txt('tos_agreement_document'));
106  $modal->setId('tos_' . $unique_id);
107  $modal->setBody('');
108  $row['modal'] = $modal->getHTML();
109  }
110  else
111  {
112  $row['missing_agreement_css_class'] = 'warning';
113  }
114  }
115 
119  protected function getStaticData()
120  {
121  return array('modal', 'id', 'language', 'agreement', 'missing_agreement_css_class', 'agreement_document', 'content_link', 'img_down', 'language_key');
122  }
123 
129  protected function formatCellValue($column, array $row)
130  {
131  if($column == 'agreement_document')
132  {
133  if(!is_string($row[$column]) || !strlen($row[$column]))
134  {
135  return $this->lng->txt('tos_agreement_document_missing');
136  }
137  }
138  else if($column == 'agreement')
139  {
140  if($row[$column])
141  {
142  return $this->lng->txt('tos_agreement_exists');
143  }
144  else
145  {
146  return $this->lng->txt('tos_agreement_missing');
147  }
148  }
149  else if($column == 'agreement_document_modification_ts')
150  {
151  return ilDatePresentation::formatDate(new ilDateTime($row[$column], IL_CAL_UNIX));
152  }
153 
154  return $row[$column];
155  }
156 
161  public function numericOrdering($column)
162  {
163  if('agreement_document_modification_ts' == $column)
164  {
165  return true;
166  }
167 
168  return false;
169  }
170 }