ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilLanguageStatisticsTable Class Reference
+ Inheritance diagram for ilLanguageStatisticsTable:
+ Collaboration diagram for ilLanguageStatisticsTable:

Public Member Functions

 __construct (?ilObject $object, ILIAS\UI\Factory $ui_factory, ilLanguage $lng,)
 
 getTable ()
 
 getItems (?Range $range=null, ?Order $order=null)
 
 getRows (\ILIAS\UI\Component\Table\DataRowBuilder $row_builder, array $visible_column_ids, \ILIAS\Data\Range $range, \ILIAS\Data\Order $order, ?array $filter_data, ?array $additional_parameters)
 
 getTotalRowCount (?array $filter_data, ?array $additional_parameters)
 
- 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 ()
 

Protected Attributes

ilObject $object = null
 
ILIAS UI Factory $ui_factory
 
ilLanguage $lng
 

Detailed Description

Definition at line 26 of file class.ilLanguageStatisticsTable.php.

Constructor & Destructor Documentation

◆ __construct()

ilLanguageStatisticsTable::__construct ( ?ilObject  $object,
ILIAS\UI\Factory  $ui_factory,
ilLanguage  $lng 
)

Definition at line 32 of file class.ilLanguageStatisticsTable.php.

References $lng, $object, $ui_factory, and ILIAS\Repository\lng().

36  {
37  $this->object = $object;
38  $this->ui_factory = $ui_factory;
39  $this->lng = $lng;
40  }
+ Here is the call graph for this function:

Member Function Documentation

◆ getColums()

ilLanguageStatisticsTable::getColums ( )
protected

Definition at line 51 of file class.ilLanguageStatisticsTable.php.

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

Referenced by getTable().

51  : array
52  {
53  $f = $this->ui_factory->table()->column();
54  return [
55  'module' => $f->text(ucfirst($this->lng->txt("module"))),
56  'all' => $f->number($this->lng->txt("language_scope_global")),
57  'changed' => $f->number($this->lng->txt("language_scope_local")),
58  'unchanged' => $f->number($this->lng->txt("language_scope_unchanged")),
59  ];
60  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getItems()

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

Definition at line 62 of file class.ilLanguageStatisticsTable.php.

References Vendor\Package\$a, Vendor\Package\$b, $data, ILIAS\UI\Implementation\Component\Table\$range, ilObjLanguageExt\_getModules(), ILIAS\Data\Range\getLength(), ILIAS\Data\Range\getStart(), ILIAS\Repository\lng(), and ILIAS\Repository\object().

Referenced by getRows(), and getTotalRowCount().

62  : array
63  {
64  $modules = ilObjLanguageExt::_getModules($this->object->key);
65 
66  $data = [];
67  $total = [];
68  foreach ($modules as $module) {
69  $row = [];
70  $row["module"] = $module;
71  $row["all"] = count($this->object->getAllValues([$module]));
72  $row["changed"] = count($this->object->getChangedValues([$module]));
73  $row["unchanged"] = $row["all"] - $row["changed"];
74  isset($total["all"]) ? $total["all"] += $row["all"] : $total["all"] = $row["all"];
75  isset($total["changed"]) ? $total["changed"] += $row["changed"] : $total["changed"] = $row["changed"];
76  isset($total["unchanged"]) ? $total["unchanged"] += $row["unchanged"] : $total["unchanged"] = $row["unchanged"];
77  $data[] = $row;
78  }
79  $total["module"] = $this->lng->txt("language_all_modules");
80  $total["all"] = $total["all"];
81  $total["changed"] = $total["changed"];
82  $total["unchanged"] = $total["unchanged"];
83  array_unshift($data, $total);
84 
85  if($order) {
86  list($order_field, $order_direction) = $order->join([], fn($ret, $key, $value) => [$key, $value]);
87  usort(
88  $data,
89  static function ($a, $b) use ($order_field) {
90  switch ($order_field) {
91  case 'module':
92  $a_aspect = $a["module"];
93  $b_aspect = $b["module"];
94  break;
95  case 'all':
96  $a_aspect = $a["all"];
97  $b_aspect = $b["all"];
98  break;
99  case 'changed':
100  $a_aspect = $a["changed"];
101  $b_aspect = $b["changed"];
102  break;
103  case 'unchanged':
104  $a_aspect = $a["unchanged"];
105  $b_aspect = $b["unchanged"];
106  break;
107  }
108  return $a_aspect <=> $b_aspect;
109  }
110  );
111  if ($order_direction === 'DESC') {
112  $data = array_reverse($data);
113  }
114  }
115 
116  if ($range) {
117  $data = array_slice($data, $range->getStart(), $range->getLength());
118  }
119 
120  return $data;
121  }
static _getModules(string $a_lang_key)
Get all modules of a language.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRows()

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

Definition at line 126 of file class.ilLanguageStatisticsTable.php.

References getItems().

133  : Generator {
134  foreach ($this->getItems($range, $order) as $idx => $record) {
135  $obj_id = (string) $idx;
136  $record['module'] = $record['module'];
137  $record['all'] = $record['all'];
138  $record['changed'] = $record['changed'];
139  $record['unchanged'] = $record['unchanged'];
140 
141  yield $row_builder->buildDataRow($obj_id, $record);
142  }
143  }
getItems(?Range $range=null, ?Order $order=null)
+ Here is the call graph for this function:

◆ getTable()

ilLanguageStatisticsTable::getTable ( )

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

References getColums().

42  : DataTable\Data
43  {
44  return $this->ui_factory->table()->data(
45  $this,
46  '',
47  $this->getColums(),
48  );
49  }
+ Here is the call graph for this function:

◆ getTotalRowCount()

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

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 148 of file class.ilLanguageStatisticsTable.php.

References getItems().

148  : ?int
149  {
150  return count($this->getItems());
151  }
getItems(?Range $range=null, ?Order $order=null)
+ Here is the call graph for this function:

Field Documentation

◆ $lng

ilLanguage ilLanguageStatisticsTable::$lng
protected

Definition at line 30 of file class.ilLanguageStatisticsTable.php.

Referenced by __construct().

◆ $object

ilObject ilLanguageStatisticsTable::$object = null
protected

Definition at line 28 of file class.ilLanguageStatisticsTable.php.

Referenced by __construct().

◆ $ui_factory

ILIAS UI Factory ilLanguageStatisticsTable::$ui_factory
protected

Definition at line 29 of file class.ilLanguageStatisticsTable.php.

Referenced by __construct().


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