ILIAS  trunk Revision v11.0_alpha-1851-ga8564da6fed
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilDclDetailedViewGUI Class Reference

ilDclDetailedViewGUI: ilDclDetailedViewDefinitionGUI, ilEditClipboardGUI, ilCommentGUI More...

+ Collaboration diagram for ilDclDetailedViewGUI:

Public Member Functions

 __construct (ilObjDataCollectionGUI $a_dcl_object, int $tableview_id)
 
 executeCommand ()
 
 jumpToRecord ()
 
 renderRecord (bool $editComments=false)
 
 doReplace (array $found)
 
 doExtReplace (array $found)
 

Protected Member Functions

 renderComments (bool $edit=false)
 
 checkAccess ()
 

Protected Attributes

ILIAS UI Factory $ui_factory
 
ILIAS UI Renderer $renderer
 
ilObjDataCollectionGUI $dcl_gui_object
 
ilDclTable $table
 
int $tableview_id
 
ilDclBaseRecordModel $record_obj
 
bool $is_enabled_paging = true
 
ilLanguage $lng
 
ilCtrlInterface $ctrl
 
ILIAS HTTP Services $http
 
ILIAS Refinery Factory $refinery
 
int $record_id
 
ilCommentGUI $commentGUI
 
ilDclBaseFieldModel $currentField
 

Private Member Functions

 setOptions (string $link_name)
 
 loadSession ()
 If we come from a goto Link we need to build up the session data. More...
 

Private Attributes

ilGlobalTemplateInterface $main_tpl
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilDclDetailedViewGUI::__construct ( ilObjDataCollectionGUI  $a_dcl_object,
int  $tableview_id 
)

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

References $DIC, $objId, $record_id, $tableview_id, ILIAS\Repository\ctrl(), ilSession\get(), ilObjStyleSheet\getContentStylePath(), ilDclCache\getRecordCache(), ilObjStyleSheet\getSyntaxStylePath(), ilDclCache\getTableCache(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), loadSession(), null, ILIAS\Repository\refinery(), and renderer().

44  {
45  global $DIC;
46 
47  $tpl = $DIC->ui()->mainTemplate();
48  $this->ctrl = $DIC->ctrl();
49  $this->dcl_gui_object = $a_dcl_object;
50  $this->lng = $DIC->language();
51  $this->http = $DIC->http();
52  $this->refinery = $DIC->refinery();
53  $this->main_tpl = $DIC->ui()->mainTemplate();
54  $this->ui_factory = $DIC->ui()->factory();
55  $this->renderer = $DIC->ui()->renderer();
56 
57  if (
58  !$this->http->wrapper()->query()->has('table_id') ||
59  !$this->http->wrapper()->query()->has('tableview_id')
60  ) {
61  $this->main_tpl->setOnScreenMessage($this->main_tpl::MESSAGE_TYPE_FAILURE, 'Table not found', true);
62  $this->ctrl->redirectByClass(ilDclRecordListGUI::class, "show");
63  }
64 
65  $this->tableview_id = $this->http->wrapper()->query()->retrieve('tableview_id', $this->refinery->kindlyTo()->int());
66  $table_id = $this->http->wrapper()->query()->retrieve('table_id', $this->refinery->kindlyTo()->int());
67  $this->table = ilDclCache::getTableCache($table_id);
68  $this->loadSession();
69 
70  $this->record_id = null;
71  if ($this->http->wrapper()->query()->has('record_id')) {
72  $this->record_id = $this->http->wrapper()->query()->retrieve(
73  'record_id',
74  $this->refinery->kindlyTo()->int()
75  );
76  } elseif ($this->http->wrapper()->query()->has('record_pos')) {
77  $record_ids = ilSession::get('dcl_record_ids');
78  $pos = $this->http->wrapper()->query()->retrieve('record_pos', $this->refinery->kindlyTo()->int());
79  if ($record_ids === [] || !array_key_exists($pos, $record_ids)) {
80  $this->ctrl->redirectToURL($this->http->request()->getServerParams()['HTTP_REFERER']);
81  }
82  $this->record_id = $record_ids[$pos];
83  }
84  if ($this->http->wrapper()->post()->has('record_id')) {
85  $this->record_id = $this->http->wrapper()->post()->retrieve(
86  'record_id',
87  $this->refinery->kindlyTo()->int()
88  );
89  }
90 
91  if ($this->record_id) {
92  $this->record_obj = ilDclCache::getRecordCache($this->record_id);
93  if (!$this->record_obj->hasPermissionToView($this->dcl_gui_object->getRefId())) {
94  $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt('dcl_msg_no_perm_view'), true);
95  $this->ctrl->redirectByClass(ilDclRecordListGUI::class, "show");
96  }
97  }
98 
99  // content style (using system defaults)
100  $tpl->setCurrentBlock("SyntaxStyle");
101  $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
102  $tpl->parseCurrentBlock();
103 
104  $tpl->setCurrentBlock("ContentStyle");
105  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
106  $tpl->parseCurrentBlock();
107 
108  // Comments
109  $repId = $this->dcl_gui_object->getDataCollectionObject()->getId();
111  $this->commentGUI = new ilCommentGUI($repId, $objId);
112  $this->commentGUI->enablePublicNotes();
113  $this->commentGUI->enablePublicNotesDeletion();
114  $this->ctrl->setParameterByClass(ilCommentGUI::class, "record_id", $this->record_id);
115  $this->ctrl->setParameterByClass(ilCommentGUI::class, "rep_id", $repId);
116 
117  $this->tableview_id = $tableview_id;
118 
119  if ($this->http->wrapper()->query()->has('disable_paging')
120  && $this->http->wrapper()->query()->retrieve('disable_paging', $this->refinery->kindlyTo()->bool())) {
121  $this->is_enabled_paging = false;
122  }
123  }
static get(string $a_var)
loadSession()
If we come from a goto Link we need to build up the session data.
renderer()
$objId
Definition: xapitoken.php:57
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:22
static getTableCache(?int $table_id=null)
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
static getRecordCache(?int $record_id)
Comment GUI.
+ Here is the call graph for this function:

Member Function Documentation

◆ checkAccess()

ilDclDetailedViewGUI::checkAccess ( )
protected

Definition at line 306 of file class.ilDclDetailedViewGUI.php.

References $tableview_id.

Referenced by executeCommand().

306  : bool
307  {
308  $page = new ilDclDetailedViewDefinitionGUI($this->tableview_id);
309  $has_accass = ilObjDataCollectionAccess::hasAccessTo($this->dcl_gui_object->getRefId(), $this->table->getId(), $this->tableview_id);
310  $is_active = $page->getPageObject()->isActive();
311  return $has_accass && $is_active;
312  }
ilDclDetailedViewDefinitionGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMediaPoolTargetSelector ilDcl...
+ Here is the caller graph for this function:

◆ doExtReplace()

ilDclDetailedViewGUI::doExtReplace ( array  $found)

Definition at line 227 of file class.ilDclDetailedViewGUI.php.

References ilDclCache\getRecordCache(), ilObjDataCollectionAccess\hasWriteAccess(), and null.

227  : ?string
228  {
229  $ref_rec_ids = $this->record_obj->getRecordFieldValue($this->currentField->getId());
230  if (!is_array($ref_rec_ids)) {
231  $ref_rec_ids = [$ref_rec_ids];
232  }
233  if (!count($ref_rec_ids) || !$ref_rec_ids) {
234  return null;
235  }
236  $ref_recs = [];
237  foreach ($ref_rec_ids as $ref_rec_id) {
238  $ref_recs[] = ilDclCache::getRecordCache($ref_rec_id);
239  }
240  $field = $ref_recs[0]->getTable()->getFieldByTitle($found[1]);
241 
242  $tpl = new ilTemplate("tpl.reference_list.html", true, true, "components/ILIAS/DataCollection");
243  $tpl->setCurrentBlock("reference_list");
244 
245  if (!$field) {
246  if (ilObjDataCollectionAccess::hasWriteAccess($this->dcl_gui_object->getRefId())) {
247  $this->main_tpl->setOnScreenMessage(
248  'info',
249  "Bad Viewdefinition at [ext tableOf=\"" . $found[1] . "\" ...]",
250  true
251  );
252  }
253 
254  return null;
255  }
256 
257  foreach ($ref_recs as $ref_record) {
258  $tpl->setCurrentBlock("reference");
259  $tpl->setVariable("CONTENT", $ref_record->getRecordFieldHTML($field->getId()));
260  $tpl->parseCurrentBlock();
261  }
262  return $tpl->get();
263  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static hasWriteAccess(int $ref, ?int $user_id=0)
static getRecordCache(?int $record_id)
+ Here is the call graph for this function:

◆ doReplace()

ilDclDetailedViewGUI::doReplace ( array  $found)

Definition at line 222 of file class.ilDclDetailedViewGUI.php.

References setOptions().

222  : string
223  {
224  return $this->record_obj->getRecordFieldSingleHTML($this->currentField->getId(), $this->setOptions($found[1]));
225  }
+ Here is the call graph for this function:

◆ executeCommand()

ilDclDetailedViewGUI::executeCommand ( )

Definition at line 125 of file class.ilDclDetailedViewGUI.php.

References checkAccess(), ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

125  : void
126  {
127  $this->ctrl->setParameter($this, 'tableview_id', $this->tableview_id);
128 
129  if (!$this->checkAccess()) {
130  $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
131  return;
132  }
133 
134  $cmd = $this->ctrl->getCmd();
135  $cmdClass = $this->ctrl->getCmdClass();
136  switch (strtolower($cmdClass)) {
137  case 'ilcommentgui':
138  $this->commentGUI->executeCommand();
139  break;
140  default:
141  $this->$cmd();
142  break;
143  }
144  }
+ Here is the call graph for this function:

◆ jumpToRecord()

ilDclDetailedViewGUI::jumpToRecord ( )

Definition at line 146 of file class.ilDclDetailedViewGUI.php.

References ILIAS\Repository\ctrl().

146  : void
147  {
148  $this->ctrl->setParameterByClass(self::class, 'record_id', $this->record_id);
149  $this->ctrl->redirectByClass(self::class, 'renderRecord');
150  }
+ Here is the call graph for this function:

◆ loadSession()

ilDclDetailedViewGUI::loadSession ( )
private

If we come from a goto Link we need to build up the session data.

Definition at line 286 of file class.ilDclDetailedViewGUI.php.

References $tableview_id.

Referenced by __construct().

286  : void
287  {
288  $list = new ilDclRecordListTableGUI(
289  new ilDclRecordListGUI($this->dcl_gui_object, $this->table->getId(), $this->tableview_id),
290  "listRecords",
291  $this->table,
292  $this->tableview_id
293  );
294  $list->initFilter();
295  $list->determineOffsetAndOrder();
296  $this->table->getPartialRecords(
297  (string) $this->table->getId(),
298  $list->getOrderField(),
299  $list->getOrderDirection(),
300  $list->getLimit(),
301  $list->getOffset(),
302  $list->getFilter()
303  );
304  }
+ Here is the caller graph for this function:

◆ renderComments()

ilDclDetailedViewGUI::renderComments ( bool  $edit = false)
protected

Definition at line 265 of file class.ilDclDetailedViewGUI.php.

Referenced by renderRecord().

265  : string
266  {
267  if (!$edit) {
268  return $this->commentGUI->getListHTML();
269  } else {
270  return $this->commentGUI->addNoteForm();
271  }
272  }
+ Here is the caller graph for this function:

◆ renderRecord()

ilDclDetailedViewGUI::renderRecord ( bool  $editComments = false)

Definition at line 152 of file class.ilDclDetailedViewGUI.php.

References $DIC, ILIAS\Repository\ctrl(), ilSession\get(), ILIAS\Repository\lng(), ilDclRecordEditGUI\REDIRECT_DETAIL, and renderComments().

152  : void
153  {
154  global $DIC;
155  $x = $DIC->help();
156  $DIC->help()->setScreenId('dcl_record');
157  $ilTabs = $DIC->tabs();
158  $tpl = $DIC->ui()->mainTemplate();
159  $ilCtrl = $DIC->ctrl();
160 
161  $rctpl = new ilDataCollectionGlobalTemplate("tpl.record_view.html", false, true, "components/ILIAS/DataCollection");
162 
163  $ilTabs->setTabActive("id_content");
164 
165  if (!$this->tableview_id) {
166  $ilCtrl->redirectByClass(ilDclRecordListGUI::class, "listRecords");
167  }
168 
169  $pageObj = new ilDclDetailedViewDefinitionGUI($this->tableview_id);
170  $pageObj->setOutputMode($pageObj::PRESENTATION);
171  $pageObj->setRecord($this->record_obj);
172  $html = $pageObj->showPage();
173  $rctpl->addCss("./assets/css/content.css");
174  $rctpl->fillCssFiles();
175  $rctpl->setVariable("CONTENT", $html);
176 
177  //Permanent Link
178  $tpl->setPermanentLink(
179  'dcl',
180  filter_input(INPUT_GET, 'ref_id', FILTER_VALIDATE_INT),
181  $this->table->getId() . '_' . $this->tableview_id . '_' . $this->record_obj->getId()
182  );
183 
184  // Buttons for previous/next records
185 
186  if ($this->is_enabled_paging) {
187  $record_ids = ilSession::get('dcl_record_ids');
188  if ($record_ids !== [] && array_search($this->record_id, $record_ids) !== false) {
189  $DIC->toolbar()->addComponent(
190  $DIC->ui()->factory()->viewControl()->pagination()
191  ->withTargetURL($this->ctrl->getLinkTargetByClass(self::class, 'jumpToRecord'), 'record_pos')
192  ->withPageSize(1)
193  ->withDropdownAt(5)
194  ->withDropdownLabel($this->lng->txt('entry_of'))
195  ->withCurrentPage(array_search($this->record_id, $record_ids))
196  ->withTotalEntries(count($record_ids))
197  ->withMaxPaginationButtons(20)
198  );
199  }
200  }
201 
202  if ($this->record_obj->hasPermissionToEdit($this->dcl_gui_object->getRefId())) {
203  $DIC->toolbar()->addSpacer('100%');
204  $this->ctrl->setParameterByClass(ilDclRecordEditGUI::class, 'table_id', $this->table->getId());
205  $this->ctrl->setParameterByClass(ilDclRecordEditGUI::class, 'tableview_id', $this->tableview_id);
206  $this->ctrl->setParameterByClass(ilDclRecordEditGUI::class, 'redirect', ilDclRecordEditGUI::REDIRECT_DETAIL);
207  $this->ctrl->saveParameterByClass(ilDclRecordEditGUI::class, 'record_id');
208  $DIC->toolbar()->addComponent($DIC->ui()->factory()->button()->standard(
209  $this->lng->txt('dcl_edit_record'),
210  $this->ctrl->getLinkTargetByClass(ilDclRecordEditGUI::class, 'edit')
211  ));
212  }
213 
214  // Comments
215  if ($this->table->getPublicCommentsEnabled()) {
216  $rctpl->setVariable('COMMENTS', $this->renderComments($editComments));
217  }
218 
219  $tpl->setContent($rctpl->get());
220  }
static get(string $a_var)
ilDclDetailedViewDefinitionGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMediaPoolTargetSelector ilDcl...
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

◆ setOptions()

ilDclDetailedViewGUI::setOptions ( string  $link_name)
private

Definition at line 274 of file class.ilDclDetailedViewGUI.php.

Referenced by doReplace().

274  : array
275  {
276  $options = [];
277  $options['link']['display'] = true;
278  $options['link']['name'] = $link_name;
279 
280  return $options;
281  }
+ Here is the caller graph for this function:

Field Documentation

◆ $commentGUI

ilCommentGUI ilDclDetailedViewGUI::$commentGUI
protected

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

◆ $ctrl

ilCtrlInterface ilDclDetailedViewGUI::$ctrl
protected

Definition at line 34 of file class.ilDclDetailedViewGUI.php.

◆ $currentField

ilDclBaseFieldModel ilDclDetailedViewGUI::$currentField
protected

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

◆ $dcl_gui_object

ilObjDataCollectionGUI ilDclDetailedViewGUI::$dcl_gui_object
protected

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

◆ $http

ILIAS HTTP Services ilDclDetailedViewGUI::$http
protected

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

◆ $is_enabled_paging

bool ilDclDetailedViewGUI::$is_enabled_paging = true
protected

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

◆ $lng

ilLanguage ilDclDetailedViewGUI::$lng
protected

Definition at line 33 of file class.ilDclDetailedViewGUI.php.

◆ $main_tpl

ilGlobalTemplateInterface ilDclDetailedViewGUI::$main_tpl
private

Definition at line 35 of file class.ilDclDetailedViewGUI.php.

◆ $record_id

int ilDclDetailedViewGUI::$record_id
protected

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

Referenced by __construct().

◆ $record_obj

ilDclBaseRecordModel ilDclDetailedViewGUI::$record_obj
protected

Definition at line 31 of file class.ilDclDetailedViewGUI.php.

◆ $refinery

ILIAS Refinery Factory ilDclDetailedViewGUI::$refinery
protected

Definition at line 38 of file class.ilDclDetailedViewGUI.php.

◆ $renderer

ILIAS UI Renderer ilDclDetailedViewGUI::$renderer
protected

Definition at line 27 of file class.ilDclDetailedViewGUI.php.

◆ $table

ilDclTable ilDclDetailedViewGUI::$table
protected

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

◆ $tableview_id

int ilDclDetailedViewGUI::$tableview_id
protected

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

Referenced by __construct(), checkAccess(), and loadSession().

◆ $ui_factory

ILIAS UI Factory ilDclDetailedViewGUI::$ui_factory
protected

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


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