ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 {
17  protected $ctrl;
18 
23  public function __construct(ilObjectGUI $a_parent_obj, $a_parent_cmd)
24  {
28  global $DIC;
29 
30  $this->ctrl = $DIC['ilCtrl'];
31 
32  $this->setId('tos_agreement_by_lng');
33 
34  $this->setDefaultOrderDirection('ASC');
35  $this->setDefaultOrderField('language');
36  $this->setExternalSorting(false);
37  $this->setExternalSegmentation(false);
38 
39  parent::__construct($a_parent_obj, $a_parent_cmd);
40 
41  $this->setTitle($this->lng->txt('tos_agreement_by_lng'));
42 
43  $this->addColumn($this->lng->txt('language'), 'language');
44  $this->addColumn($this->lng->txt('tos_agreement'), 'agreement');
45  $this->addColumn($this->lng->txt('tos_agreement_document'), 'agreement_document');
46  $this->optionalColumns = (array)$this->getSelectableColumns();
47  $this->visibleOptionalColumns = (array)$this->getSelectedColumns();
48  foreach($this->visibleOptionalColumns as $column)
49  {
50  $this->addColumn($this->optionalColumns[$column]['txt'], $column);
51  }
52 
53  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, 'applyAgreementByLanguageFilter'));
54 
55  $this->setRowTemplate('tpl.tos_agreement_by_lng_table_row.html', 'Services/TermsOfService');
56 
57  $this->setShowRowsSelector(true);
58 
59  require_once 'Services/jQuery/classes/class.iljQueryUtil.php';
60  require_once 'Services/YUI/classes/class.ilYuiUtil.php';
64 
65  $this->initFilter();
66  $this->setFilterCommand('applyAgreementByLanguageFilter');
67  $this->setResetCommand('resetAgreementByLanguageFilter');
68  }
69 
73  public function getSelectableColumns()
74  {
75  $cols = array('agreement_document_modification_ts' => array('txt' => $this->lng->txt('tos_last_modified'), 'default' => true));
76 
77  return $cols;
78  }
79 
84  protected function prepareData(array &$data)
85  {
86  foreach($data['items'] as &$row)
87  {
88  $row['language'] = $this->lng->txt('meta_l_' . $row['language']);
89  }
90  }
91 
96  protected function prepareRow(array &$row)
97  {
98  if(is_string($row['agreement_document']) && strlen($row['agreement_document']))
99  {
100  $unique_id = md5($row['language']);
101 
102  $this->ctrl->setParameter($this->getParentObject(), 'agreement_document', rawurlencode($row['agreement_document']));
103  $row['content_link'] = $this->ctrl->getLinkTarget($this->getParentObject(), 'getAgreementTextByFilenameAsynch', '', true, false);
104  $this->ctrl->setParameter($this->getParentObject(), 'agreement_document', '');
105  $row['img_down'] = ilGlyphGUI::get(ilGlyphGUI::SEARCH);
106  $row['id'] = $unique_id;
107 
108  $modal = ilModalGUI::getInstance();
109  $modal->setHeading($this->lng->txt('tos_agreement_document'));
110  $modal->setType(ilModalGUI::TYPE_LARGE);
111  $modal->setId('tos_' . $unique_id);
112  $modal->setBody('');
113  $row['modal'] = $modal->getHTML();
114  }
115  else
116  {
117  $row['missing_agreement_css_class'] = 'warning';
118  }
119  }
120 
124  protected function getStaticData()
125  {
126  return array('modal', 'id', 'language', 'agreement', 'missing_agreement_css_class', 'agreement_document', 'content_link', 'img_down', 'language_key');
127  }
128 
134  protected function formatCellValue($column, array $row)
135  {
136  if($column == 'agreement_document')
137  {
138  if(!is_string($row[$column]) || !strlen($row[$column]))
139  {
140  return $this->lng->txt('tos_agreement_document_missing');
141  }
142  }
143  else if($column == 'agreement')
144  {
145  if($row[$column])
146  {
147  return $this->lng->txt('tos_agreement_exists');
148  }
149  else
150  {
151  return $this->lng->txt('tos_agreement_missing');
152  }
153  }
154  else if($column == 'agreement_document_modification_ts')
155  {
157  }
158 
159  return $row[$column];
160  }
161 
166  public function numericOrdering($column)
167  {
168  if('agreement_document_modification_ts' == $column)
169  {
170  return true;
171  }
172 
173  return false;
174  }
175 }
initFilter()
Init filter.
setExternalSorting($a_val)
Set external sorting.
__construct($a_parent_obj, $a_parent_cmd="", $a_template_context="")
Constructor.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setExternalSegmentation($a_val)
Set external segmentation.
static get($a_glyph, $a_text="")
Get glyph html.
const IL_CAL_UNIX
getParentObject()
Get parent object.
setId($a_val)
Set id.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
$column
Definition: 39dropdown.php:62
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
Class ilObjectGUI Basic methods of all Output classes.
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
getSelectedColumns()
Get selected columns.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
static initPanel($a_resize=false)
Init yui panel.
static getInstance()
Get instance.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
static initOverlay()
Init YUI Overlay module.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
static initjQuery($a_tpl=null)
Init jQuery.
global $DIC
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setFilterCommand($a_val, $a_caption=null)
Set filter command.