ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilLanguageFolderTable Class Reference

Table class for. More...

+ Inheritance diagram for ilLanguageFolderTable:
+ Collaboration diagram for ilLanguageFolderTable:

Public Member Functions

 __construct (ilObjLanguageFolder $a_folder, URLBuilder $url_builder, URLBuilderToken $action_token, URLBuilderToken $row_id_token)
 
 getTable ()
 
 getItems (?Range $range=null, ?Order $order=null)
 Get language data. More...
 
 getRows (\ILIAS\UI\Component\Table\DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters)
 
 getTotalRowCount (?array $filter_data, ?array $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 
- Public Member Functions inherited from ILIAS\UI\Component\Table\DataRetrieval
 getRows (DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters)
 This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g. More...
 

Protected Member Functions

 getColums ()
 
 getActions ()
 
 buildAction (string $act, string $type, bool $async=false)
 
 getURIWithTargetClass (string $target_gui, string $command)
 

Protected Attributes

URLBuilder $url_builder
 
URLBuilderToken $action_token
 
URLBuilderToken $row_id_token
 
ILIAS UI Factory $ui_factory
 
ilLanguage $lng
 
ilObjLanguageFolder $folder
 
ilCtrlInterface $ctrl
 
ilSetting $ilSetting
 
ilAccessHandler $access
 

Detailed Description

Table class for.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 37 of file class.ilLanguageFolderTable.php.

Constructor & Destructor Documentation

◆ __construct()

ilLanguageFolderTable::__construct ( ilObjLanguageFolder  $a_folder,
URLBuilder  $url_builder,
URLBuilderToken  $action_token,
URLBuilderToken  $row_id_token 
)

Definition at line 49 of file class.ilLanguageFolderTable.php.

References $action_token, $DIC, $row_id_token, $url_builder, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

54  {
55  global $DIC;
56  $this->ui_factory = $DIC['ui.factory'];
57  $this->lng = $DIC->language();
58  $this->folder = $a_folder;
59  $this->url_builder = $url_builder;
60  $this->action_token = $action_token;
61  $this->row_id_token = $row_id_token;
62  $this->ctrl = $DIC->ctrl();
63  $this->ilSetting = $DIC->settings();
64  $this->access = $DIC->access();
65  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ buildAction()

ilLanguageFolderTable::buildAction ( string  $act,
string  $type,
bool  $async = false 
)
protected

Definition at line 117 of file class.ilLanguageFolderTable.php.

References $row_id_token, and ILIAS\Repository\lng().

Referenced by getActions().

117  : array
118  {
119  $action = $this->ui_factory->table()->action()
120  ->$type(
121  $this->lng->txt($act),
122  $this->url_builder->withParameter($this->action_token, $act),
124  );
125  if ($async) {
126  $action = $action->withAsync(true);
127  }
128 
129  return [$act => $action];
130  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActions()

ilLanguageFolderTable::getActions ( )
protected

Definition at line 103 of file class.ilLanguageFolderTable.php.

References buildAction().

Referenced by getTable().

103  : array
104  {
105  $actions = array_merge(
106  $this->buildAction('refresh', 'standard', true),
107  $this->buildAction('install', 'standard'),
108  $this->buildAction('install_local', 'standard'),
109  $this->buildAction('uninstall', 'standard', true),
110  $this->buildAction('lang_uninstall_changes', 'standard', true),
111  $this->buildAction('setSystemLanguage', 'single'),
112  $this->buildAction('setUserLanguage', 'single'),
113  );
114  return $actions;
115  }
buildAction(string $act, string $type, bool $async=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getColums()

ilLanguageFolderTable::getColums ( )
protected

Definition at line 80 of file class.ilLanguageFolderTable.php.

References Vendor\Package\$f, $ui_factory, and ILIAS\Repository\lng().

Referenced by getTable().

80  : array
81  {
83  $icon_yes = $f->symbol()->icon()->custom(
84  'assets/images/standard/icon_checked.svg',
85  $this->lng->txt('yes'),
86  'small'
87  );
88  $icon_no = $f->symbol()->icon()->custom(
89  'assets/images/standard/icon_unchecked.svg',
90  $this->lng->txt('no'),
91  'small'
92  );
93  return [
94  'language' => $f->table()->column()->link($this->lng->txt("language"))->withIsSortable(false),
95  'status' => $f->table()->column()->text($this->lng->txt("status"))->withIsSortable(false),
96  'users' => $f->table()->column()->text($this->lng->txt("users"))->withIsSortable(false),
97  'page_translation' => $f->table()->column()->boolean($this->lng->txt("language_translation"), $icon_yes, $icon_no)->withIsSortable(false),
98  'last_refresh' => $f->table()->column()->text($this->lng->txt("last_refresh"))->withIsSortable(false),
99  'last_change' => $f->table()->column()->text($this->lng->txt("last_change"))->withIsSortable(false)
100  ];
101  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getItems()

ilLanguageFolderTable::getItems ( ?Range  $range = null,
?Order  $order = null 
)

Get language data.

Definition at line 135 of file class.ilLanguageFolderTable.php.

References $data, ILIAS\UI\Implementation\Component\Table\$range, ILIAS\Data\Range\getLength(), and ILIAS\Data\Range\getStart().

Referenced by getRows().

135  : array
136  {
137  $languages = $this->folder->getLanguages();
138  $data = [];
139  $names = [];
140  $installed = [];
141 
142  foreach ($languages as $k => $l) {
143  $data[] = array_merge($l, ["key" => $k]);
144  $names[] = $l['name'];
145  $installed[] = str_starts_with($l["desc"], 'installed') ? 1 : 2;
146  }
147 
148  // sort alphabetically but show installed languages first
149  array_multisort($installed, SORT_ASC, $names, SORT_ASC, $data);
150 
151  if ($range) {
152  $data = array_slice($data, $range->getStart(), $range->getLength());
153  }
154 
155  return $data;
156  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRows()

ilLanguageFolderTable::getRows ( \ILIAS\UI\Component\Table\DataRowBuilder  $row_builder,
array  $visible_column_ids,
Range  $range,
Order  $order,
?array  $filter_data,
?array  $additional_parameters 
)

Definition at line 158 of file class.ilLanguageFolderTable.php.

References ilObjLanguage\_getLastLocalChange(), ILIAS\Repository\access(), ilObjLanguage\countUsers(), ilDatePresentation\formatDate(), getItems(), getURIWithTargetClass(), IL_CAL_DATETIME, and ILIAS\Repository\lng().

165  : Generator {
166  foreach ($this->getItems($range, $order) as $idx => $record) {
167  $obj_id = (string) $record['obj_id'];
168  $language = $record['name'];
169  if ($record["status"]) {
170  $language .= ' (' . $this->lng->txt($record["status"]) . ')';
171  }
172  $to_language = $this->url_builder
173  ->withParameter($this->action_token, 'view')
174  ->withParameter($this->row_id_token, $obj_id)
175  ->withURI($this->getURIWithTargetClass(ilObjLanguageExtGUI::class, 'view'))
176  ->buildURI()->__toString();
177 
178  $record['language'] = $this->ui_factory->link()->standard($language, $to_language)->withDisabled();
179 
180  $record['status'] = $this->lng->txt($record['desc']);
181 
182  $record['page_translation'] = false;
183  if ($this->ilSetting->get("lang_translate_" . $record["key"])) {
184  $record['page_translation'] = true;
185  }
186 
187  $record['users'] = ilObjLanguage::countUsers($record["key"]);
188  if ($record["desc"] !== "not_installed") {
189  if ($this->access->checkAccess('write', '', $this->folder->getId())) {
190  $record['language'] = $record['language']->withDisabled(false);
191  }
192  $record['last_refresh'] = ilDatePresentation::formatDate(new ilDateTime($record["last_update"], IL_CAL_DATETIME));
193 
194  $last_change = ilObjLanguage::_getLastLocalChange($record["key"]);
195  $record['last_change'] = ilDatePresentation::formatDate(new ilDateTime($last_change, IL_CAL_DATETIME));
196  }
197 
198  yield $row_builder->buildDataRow($obj_id, $record)
199  ->withDisabledAction('setSystemLanguage', ($record['desc'] === 'not_installed') || ($record['key'] === $this->lng->getDefaultLanguage()))
200  ->withDisabledAction('setUserLanguage', ($record['desc'] === 'not_installed') || ($record['key'] === $this->lng->getUserLanguage()))
201  ->withDisabledAction('refresh', ($record['desc'] === 'not_installed'))
202  ->withDisabledAction('uninstall', ($record['desc'] === 'not_installed'))
203  ->withDisabledAction('lang_uninstall_changes', ($record['desc'] === 'not_installed'))
204  ->withDisabledAction('install', ($record['desc'] !== 'not_installed'))
205  ->withDisabledAction('install_local', ($record['desc'] !== 'not_installed'));
206  }
207  }
const IL_CAL_DATETIME
static countUsers(string $a_lang)
Count number of users that use a language.
getURIWithTargetClass(string $target_gui, string $command)
getItems(?Range $range=null, ?Order $order=null)
Get language data.
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
static _getLastLocalChange(string $a_key)
get the date of the last local change $a_key language key Return change_date "yyyy-mm-dd hh:mm:ss" ...
+ Here is the call graph for this function:

◆ getTable()

ilLanguageFolderTable::getTable ( )

Definition at line 67 of file class.ilLanguageFolderTable.php.

References ILIAS\Repository\access(), getActions(), and getColums().

67  : DataTable\Data
68  {
69  $table = $this->ui_factory->table()->data(
70  $this,
71  '',
72  $this->getColums(),
73  );
74  if ($this->access->checkAccess('write', '', $this->folder->getId())) {
75  $table = $table->withActions($this->getActions());
76  }
77  return $table;
78  }
+ Here is the call graph for this function:

◆ getTotalRowCount()

ilLanguageFolderTable::getTotalRowCount ( ?array  $filter_data,
?array  $additional_parameters 
)

Mainly for the purpose of pagination-support, it is important to know about the total number of records available.

Given the nature of a DataTable, which is, opposite to a PresentationTable, rather administrative than explorative, this information will increase user experience quite a bit. However, you may return null, if the call is to costly, but expect the View Control to look a little different in this case.

Make sure that potential filters or user restrictions are being applied to the count.

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 219 of file class.ilLanguageFolderTable.php.

219  : ?int
220  {
221  return 1;
222  }

◆ getURIWithTargetClass()

ilLanguageFolderTable::getURIWithTargetClass ( string  $target_gui,
string  $command 
)
protected

Definition at line 209 of file class.ilLanguageFolderTable.php.

References ILIAS\Repository\ctrl().

Referenced by getRows().

209  : URI
210  {
211  return new URI(
212  ILIAS_HTTP_PATH . "/" . $this->ctrl->getLinkTargetByClass(
213  $target_gui,
214  $command
215  )
216  );
217  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilLanguageFolderTable::$access
protected

Definition at line 47 of file class.ilLanguageFolderTable.php.

◆ $action_token

URLBuilderToken ilLanguageFolderTable::$action_token
protected

Definition at line 40 of file class.ilLanguageFolderTable.php.

Referenced by __construct().

◆ $ctrl

ilCtrlInterface ilLanguageFolderTable::$ctrl
protected

Definition at line 45 of file class.ilLanguageFolderTable.php.

◆ $folder

ilObjLanguageFolder ilLanguageFolderTable::$folder
protected

Definition at line 44 of file class.ilLanguageFolderTable.php.

◆ $ilSetting

ilSetting ilLanguageFolderTable::$ilSetting
protected

Definition at line 46 of file class.ilLanguageFolderTable.php.

◆ $lng

ilLanguage ilLanguageFolderTable::$lng
protected

Definition at line 43 of file class.ilLanguageFolderTable.php.

◆ $row_id_token

URLBuilderToken ilLanguageFolderTable::$row_id_token
protected

Definition at line 41 of file class.ilLanguageFolderTable.php.

Referenced by __construct(), and buildAction().

◆ $ui_factory

ILIAS UI Factory ilLanguageFolderTable::$ui_factory
protected

Definition at line 42 of file class.ilLanguageFolderTable.php.

Referenced by getColums().

◆ $url_builder

URLBuilder ilLanguageFolderTable::$url_builder
protected

Definition at line 39 of file class.ilLanguageFolderTable.php.

Referenced by __construct().


The documentation for this class was generated from the following file: