ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\MediaPool\MediaPoolTableBuilder Class Reference
+ Inheritance diagram for ILIAS\MediaPool\MediaPoolTableBuilder:
+ Collaboration diagram for ILIAS\MediaPool\MediaPoolTableBuilder:

Public Member Functions

 __construct (protected InternalDomainService $domain, protected InternalGUIService $gui, protected ThumbsGUI $thumbs_gui, protected MediaPoolRepository $media_pool_repository, protected ServicesInterface $advanced_metadata, protected \ilObjMediaPool $media_pool, protected string $folder_par, protected string $mode, protected bool $all_objects, protected ?string $filter_command, protected ?string $reset_command, protected string $insert_command, object $parent_gui, string $parent_cmd, protected ?string $filter_title=null)
 
 render ()
 
- Public Member Functions inherited from ILIAS\Repository\Table\CommonTableBuilder
 __construct (protected object $parent_gui, protected string $parent_cmd, bool $numeric_ids=true)
 
 getTable ()
 

Protected Member Functions

 getId ()
 
 getTitle ()
 
 getRetrieval ()
 
 transformRow (array $data_row)
 transform raw data array to table row data array More...
 
 build (TableAdapterGUI $table)
 
 activeAction (string $action, array $data_row)
 
 getFilterData ()
 
 getFilter ()
 
 getTitleColumnTitle ()
 
 getIcon (\ILIAS\UI\Factory $factory, string $type)
 
- Protected Member Functions inherited from ILIAS\Repository\Table\CommonTableBuilder
 getId ()
 
 getTitle ()
 
 getRetrieval ()
 
 getNamespace ()
 
 getOrderingCommand ()
 
 activeAction (string $action, array $data_row)
 
 transformRow (array $data_row)
 transform raw data array to table row data array More...
 
 build (TableAdapterGUI $table)
 

Protected Attributes

ilTree $tree
 
int $current_folder
 
FilterAdapterGUI $filter = null
 
- Protected Attributes inherited from ILIAS\Repository\Table\CommonTableBuilder
TableAdapterGUI $table
 

Detailed Description

Definition at line 30 of file MediaPoolTableBuilder.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\MediaPool\MediaPoolTableBuilder::__construct ( protected InternalDomainService  $domain,
protected InternalGUIService  $gui,
protected ThumbsGUI  $thumbs_gui,
protected MediaPoolRepository  $media_pool_repository,
protected ServicesInterface  $advanced_metadata,
protected \ilObjMediaPool  $media_pool,
protected string  $folder_par,
protected string  $mode,
protected bool  $all_objects,
protected ?string  $filter_command,
protected ?string  $reset_command,
protected string  $insert_command,
object  $parent_gui,
string  $parent_cmd,
protected ?string  $filter_title = null 
)

Definition at line 36 of file MediaPoolTableBuilder.php.

52 {
53 $this->tree = \ilObjMediaPool::_getPoolTree($media_pool->getId());
54 $request = $this->gui->standardRequest();
55 $current_folder = $this->domain->clipboard()->getFolder();
56 $requested_folder = $request->getFolderId($folder_par);
57
58 if ($requested_folder > 0) {
59 $this->current_folder = $requested_folder;
60 } elseif ($current_folder > 0 && $this->tree->isInTree($current_folder)) {
61 $this->current_folder = $current_folder;
62 } else {
63 $this->current_folder = $this->tree->getRootId();
64 }
65 $this->domain->clipboard()->setFolder($this->current_folder);
66
67 parent::__construct($parent_gui, $parent_cmd);
68 }
static _getPoolTree(int $a_obj_id)
$request
@ilCtrl_Calls ilObjLearningSequenceContentGUI: ilObjLearningSequenceConditionsGUI
Definition: ltiauth.php:39
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\MediaPool\MediaPoolTableBuilder\$current_folder, $request, ILIAS\GlobalScreen\Provider\__construct(), ilObjMediaPool\_getPoolTree(), and ilObject\getId().

+ Here is the call graph for this function:

Member Function Documentation

◆ activeAction()

ILIAS\MediaPool\MediaPoolTableBuilder::activeAction ( string  $action,
array  $data_row 
)
protected

Reimplemented from ILIAS\Repository\Table\CommonTableBuilder.

Definition at line 210 of file MediaPoolTableBuilder.php.

210 : bool
211 {
212 $type = (string) ($data_row['type'] ?? '');
213 if ($action === 'editFolder') {
214 return $type === 'fold';
215 }
216 if ($action === 'editObject') {
217 return $type === 'mob';
218 }
219 if ($action === 'editPage') {
220 return $type === 'pg';
221 }
222 if ($this->mode === 'select' && $type !== 'mob') {
223 return false;
224 }
225 if ($this->mode === 'selectc' && $type !== 'pg') {
226 return false;
227 }
228 if ($this->mode === 'selectsingle' && $type !== 'mob') {
229 return false;
230 }
231 if ($this->mode === 'edit' && $this->all_objects && $type !== 'mob') {
232 return $action !== 'editObject';
233 }
234 return true;
235 }

◆ build()

ILIAS\MediaPool\MediaPoolTableBuilder::build ( TableAdapterGUI  $table)
protected

Reimplemented from ILIAS\Repository\Table\CommonTableBuilder.

Definition at line 135 of file MediaPoolTableBuilder.php.

135 : TableAdapterGUI
136 {
137 $lng = $this->domain->lng();
138 $table = $table
139 ->filterData($this->getFilterData())
140 ->textColumn('thumbnail', $lng->txt('mep_thumbnail'))
141 ->textColumn('title', $this->getTitleColumnTitle(), true);
142
143 if ($this->all_objects) {
144 $advanced_metadata = $this->advanced_metadata
145 ->forSubObjects('mep', $this->media_pool->getRefId(), 'mob', 'mpg')
146 ->inDataTable();
147 foreach ($advanced_metadata->getColumns() as $key => $column) {
148 $table->column($key, $column);
149 }
150 }
151
152 if ($this->all_objects && $this->mode === 'edit') {
153 $table = $table
154 ->multiAction('copyToClipboard', $lng->txt('cont_copy_to_clipboard'))
155 ->multiAction('move', $lng->txt('move'))
156 ->multiAction('confirmRemove', $lng->txt('remove'))
157 ->singleRedirectAction(
158 'editObject',
159 $lng->txt('edit'),
160 [\ilObjMediaObjectGUI::class],
161 'edit',
162 'mepitem_id'
163 )
164 ->singleRedirectAction(
165 'editPage',
166 $lng->txt('edit'),
167 [\ilMediaPoolPageGUI::class],
168 'edit',
169 'mepitem_id'
170 );
171 } elseif ($this->mode === 'edit') {
172 $table = $table
173 ->multiAction('copyToClipboard', $lng->txt('cont_copy_to_clipboard'))
174 ->multiAction('move', $lng->txt('move'))
175 ->multiAction('confirmRemove', $lng->txt('remove'))
176 ->singleRedirectAction(
177 'editFolder',
178 $lng->txt('edit'),
179 [get_class($this->parent_gui)],
180 'editFolder',
181 'mepitem_id'
182 )
183 ->singleRedirectAction(
184 'editObject',
185 $lng->txt('edit'),
186 [\ilObjMediaObjectGUI::class],
187 'edit',
188 'mepitem_id'
189 )
190 ->singleRedirectAction(
191 'editPage',
192 $lng->txt('edit'),
193 [\ilMediaPoolPageGUI::class],
194 'edit',
195 'mepitem_id'
196 );
197 } elseif ($this->mode === 'selectsingle') {
198 $table = $table->multiAction('selectObjectReference', $lng->txt('cont_select'));
199 } elseif ($this->mode === 'selectc') {
200 $table = $table
201 ->multiAction($this->insert_command, $lng->txt('insert'))
202 ->singleAction($this->insert_command . 'Single', $lng->txt('insert'));
203 } else {
204 $table = $table->multiAction($this->insert_command, $lng->txt('insert'));
205 }
206
207 return $table;
208 }
filterData(array $filter_data)
Not applied if the table supports ordering.
multiAction(string $action, string $title, bool $async=false)
column(string $key, Column $column)
global $lng
Definition: privfeed.php:26

◆ getFilter()

ILIAS\MediaPool\MediaPoolTableBuilder::getFilter ( )
protected

Definition at line 271 of file MediaPoolTableBuilder.php.

271 : FilterAdapterGUI
272 {
273 if ($this->filter === null) {
274 $mset = new \ilSetting('mobs');
275 $options = ['' => $this->domain->lng()->txt('mep_all')];
276 if ($mset->get('mep_activate_pages')) {
277 $options['mob'] = $this->domain->lng()->txt('mep_mob');
278 $options['pg'] = $this->domain->lng()->txt('mep_mpg');
279 }
280 $options = array_merge($options, $this->media_pool->getUsedFormats());
281 $this->filter = $this->gui->filter(
282 'mep_filter',
283 [get_class($this->parent_gui)],
284 $this->filter_command ?? $this->parent_cmd
285 );
286 $this->filter
287 ->text('title', $this->domain->lng()->txt('title'), true, $this->filter_title)
288 ->text('keyword', $this->domain->lng()->txt('meta_keyword'))
289 ->text('caption', $this->domain->lng()->txt('cont_caption'))
290 ->select('format', $this->domain->lng()->txt('mep_format'), $options);
291
292 $advanced_metadata = $this->advanced_metadata
293 ->forSubObjects('mep', $this->media_pool->getRefId(), 'mob', 'mpg')
294 ->inFilter();
295 foreach ($advanced_metadata->getFilterInputs() as $key => $input) {
296 $this->filter->input($key, $input, false);
297 }
298 }
299 return $this->filter;
300 }
filter(string $filter_id, array $class_path, string $cmd, bool $activated=true, bool $expanded=true)

◆ getFilterData()

ILIAS\MediaPool\MediaPoolTableBuilder::getFilterData ( )
protected

Definition at line 263 of file MediaPoolTableBuilder.php.

263 : array
264 {
265 if (!$this->all_objects || $this->filter_command === null) {
266 return [];
267 }
268 return $this->getFilter()->getData() ?? [];
269 }

Referenced by ILIAS\MediaPool\MediaPoolTableBuilder\getRetrieval().

+ Here is the caller graph for this function:

◆ getIcon()

ILIAS\MediaPool\MediaPoolTableBuilder::getIcon ( \ILIAS\UI\Factory  $factory,
string  $type 
)
protected

Definition at line 307 of file MediaPoolTableBuilder.php.

307 : string
308 {
309 $path = $type === 'fold' ? 'standard/icon_fold.svg' : 'standard/icon_pg.svg';
310 return $this->gui->ui()->renderer()->render(
311 $factory->symbol()->icon()->custom(
312 \ilUtil::getImagePath($path),
313 $this->domain->lng()->txt($type === 'fold' ? 'folder' : 'page')
314 )->withSize('large')
315 );
316 }
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)

◆ getId()

ILIAS\MediaPool\MediaPoolTableBuilder::getId ( )
protected

Reimplemented from ILIAS\Repository\Table\CommonTableBuilder.

Definition at line 70 of file MediaPoolTableBuilder.php.

70 : string
71 {
72 return $this->all_objects ? 'mepall' : 'mepfold';
73 }

◆ getRetrieval()

ILIAS\MediaPool\MediaPoolTableBuilder::getRetrieval ( )
protected

Reimplemented from ILIAS\Repository\Table\CommonTableBuilder.

Definition at line 82 of file MediaPoolTableBuilder.php.

82 : RetrievalInterface
83 {
84 return new MediaPoolTableRetrieval(
85 $this->media_pool,
86 $this->current_folder,
87 $this->mode,
88 $this->all_objects,
89 $this->media_pool_repository,
90 $this->advanced_metadata,
91 $this->getFilterData()
92 );
93 }

References ILIAS\MediaPool\MediaPoolTableBuilder\getFilterData().

+ Here is the call graph for this function:

◆ getTitle()

ILIAS\MediaPool\MediaPoolTableBuilder::getTitle ( )
protected

Reimplemented from ILIAS\Repository\Table\CommonTableBuilder.

Definition at line 75 of file MediaPoolTableBuilder.php.

75 : string
76 {
77 return $this->mode === 'edit'
78 ? ''
79 : $this->domain->lng()->txt('mep_choose_from_mep');
80 }

◆ getTitleColumnTitle()

ILIAS\MediaPool\MediaPoolTableBuilder::getTitleColumnTitle ( )
protected

Definition at line 302 of file MediaPoolTableBuilder.php.

302 : string
303 {
304 return $this->domain->lng()->txt('mep_title_and_description');
305 }

◆ render()

ILIAS\MediaPool\MediaPoolTableBuilder::render ( )

Definition at line 237 of file MediaPoolTableBuilder.php.

237 : string
238 {
239 $html = '';
240 if ($this->filter !== null) {
241 $html .= $this->filter->render();
242 }
243 if (!$this->all_objects && $this->current_folder !== $this->tree->getRootId()) {
244 $locator = $this->gui->locator();
245 foreach ($this->tree->getPathFull($this->current_folder) as $path) {
246 $this->gui->ctrl()->setParameter($this->parent_gui, $this->folder_par, $path['child']);
247 $title = htmlspecialchars((string) $path['title'], ENT_QUOTES, 'UTF-8');
248 if ($path['child'] == $this->tree->getRootId()) {
249 $title = \ilObject::_lookupTitle($this->media_pool->getId());
250 }
251 $locator->addItem($title, $this->gui->ctrl()->getLinkTarget($this->parent_gui, $this->parent_cmd));
252 }
253 $html .= '<div class="small" style="margin-bottom: 7px;">' . $locator->getHTML() . '</div>';
254 }
255 $html .= $this->table->render();
257 $this->media_pool->getRefId(),
258 $this->gui->ui()->mainTemplate()
259 );
260 return $html;
261 }
static getPreviewModalHTML(int $a_mpool_ref_id, ilGlobalTemplateInterface $a_tpl)
Get preview modal html.
static _lookupTitle(int $obj_id)

◆ transformRow()

ILIAS\MediaPool\MediaPoolTableBuilder::transformRow ( array  $data_row)
protected

transform raw data array to table row data array

Reimplemented from ILIAS\Repository\Table\CommonTableBuilder.

Definition at line 95 of file MediaPoolTableBuilder.php.

95 : array
96 {
97 $ctrl = $this->gui->ctrl();
98 $factory = $this->gui->ui()->factory();
99 $type = (string) ($data_row['type'] ?? '');
100 $child = (int) ($data_row['child'] ?? $data_row['obj_id'] ?? 0);
101 $title = htmlspecialchars((string) ($data_row['title'] ?? ''), ENT_QUOTES, 'UTF-8');
102
103 if ($type === 'fold') {
104 $ctrl->setParameter($this->parent_gui, $this->folder_par, $child);
105 $ctrl->setParameter($this->parent_gui, 'id', $child);
106 $target = $ctrl->getLinkTarget($this->parent_gui, $this->parent_cmd);
107 $ctrl->setParameter($this->parent_gui, $this->folder_par, $this->current_folder);
108 $title = $this->gui->ui()->renderer()->render(
109 $factory->link()->standard(
110 $title,
111 htmlspecialchars($target, ENT_QUOTES, 'UTF-8')
112 )
113 );
114 } elseif (!in_array($this->mode, ['select', 'selectsingle', 'selectc'], true)) {
115 $ctrl->setParameterByClass('ilobjmediapoolgui', 'mepitem_id', $child);
116 $title = '<a href="#" onclick="il.MediaPool.preview(\'' . $child . '\'); return false;">' .
117 $title . '</a>';
118 }
119
120 $thumbnail = $this->getIcon($factory, $type);
121 if ($type === 'mob') {
122 $mob_id = (int) ($data_row['foreign_id'] ?? 0);
123 $thumbnail = $this->thumbs_gui->getThumbHtml($mob_id);
124 $mob = new \ilObjMediaObject($mob_id);
125 $title .= \ilObjMediaObjectGUI::_getMediaInfoHTML($mob);
126 }
127
128 $data_row['id'] = $child;
129 $data_row['thumbnail'] = $thumbnail;
130 $data_row['title'] = $title;
131
132 return $data_row;
133 }

References ILIAS\Scripts\PHPStan\$target, and ILIAS\Repository\int().

+ Here is the call graph for this function:

Field Documentation

◆ $current_folder

int ILIAS\MediaPool\MediaPoolTableBuilder::$current_folder
protected

◆ $filter

FilterAdapterGUI ILIAS\MediaPool\MediaPoolTableBuilder::$filter = null
protected

Definition at line 34 of file MediaPoolTableBuilder.php.

◆ $tree

ilTree ILIAS\MediaPool\MediaPoolTableBuilder::$tree
protected

Definition at line 32 of file MediaPoolTableBuilder.php.


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