ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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->setType(ilModalGUI::TYPE_LARGE);
107  $modal->setId('tos_' . $unique_id);
108  $modal->setBody('');
109  $row['modal'] = $modal->getHTML();
110  }
111  else
112  {
113  $row['missing_agreement_css_class'] = 'warning';
114  }
115  }
116 
120  protected function getStaticData()
121  {
122  return array('modal', 'id', 'language', 'agreement', 'missing_agreement_css_class', 'agreement_document', 'content_link', 'img_down', 'language_key');
123  }
124 
130  protected function formatCellValue($column, array $row)
131  {
132  if($column == 'agreement_document')
133  {
134  if(!is_string($row[$column]) || !strlen($row[$column]))
135  {
136  return $this->lng->txt('tos_agreement_document_missing');
137  }
138  }
139  else if($column == 'agreement')
140  {
141  if($row[$column])
142  {
143  return $this->lng->txt('tos_agreement_exists');
144  }
145  else
146  {
147  return $this->lng->txt('tos_agreement_missing');
148  }
149  }
150  else if($column == 'agreement_document_modification_ts')
151  {
152  return ilDatePresentation::formatDate(new ilDateTime($row[$column], IL_CAL_UNIX));
153  }
154 
155  return $row[$column];
156  }
157 
162  public function numericOrdering($column)
163  {
164  if('agreement_document_modification_ts' == $column)
165  {
166  return true;
167  }
168 
169  return false;
170  }
171 }
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.
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
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.
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.
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.