ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilDclDetailedViewGUI Class Reference
+ Collaboration diagram for ilDclDetailedViewGUI:

Public Member Functions

 __construct (ilObjDataCollectionGUI $a_dcl_object)
 
 executeCommand ()
 
 renderRecord ($editComments=false)
 
 doReplace ($found)
 
 doExtReplace ($found)
 

Protected Member Functions

 offerAlternativeViews ()
 
 renderComments ($edit=false)
 
 determineNextPrevRecords ()
 Find the previous/next record from the current position. More...
 
 renderPrevNextLinks ()
 Determine and return the markup for the previous/next records. More...
 
 renderSelectOptions ()
 Render select options. More...
 
 checkAccess ()
 

Protected Attributes

 $dcl_gui_object
 
 $notes_gui
 
 $table
 
 $tableview_id
 
 $record_obj
 
 $next_record_id = 0
 
 $prev_record_id = 0
 
 $current_record_position = 0
 
 $record_ids = array()
 
 $is_enabled_paging = true
 
 $lng
 

Private Member Functions

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

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilDclDetailedViewGUI::__construct ( ilObjDataCollectionGUI  $a_dcl_object)
Parameters
ilObjDataCollectionGUI$a_dcl_object

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

References $_GET, $DIC, $ilCtrl, $lng, $tpl, determineNextPrevRecords(), ilObjStyleSheet\getContentStylePath(), ilDclCache\getRecordCache(), ilObjStyleSheet\getSyntaxStylePath(), and ilUtil\sendFailure().

68  {
69  global $DIC;
70  $tpl = $DIC['tpl'];
71  $ilCtrl = $DIC['ilCtrl'];
72  $lng = $DIC['lng'];
73  $this->dcl_gui_object = $a_dcl_object;
74  $this->lng = $lng;
75 
76  $this->record_id = (int) $_REQUEST['record_id'];
77  $this->record_obj = ilDclCache::getRecordCache($this->record_id);
78 
79  if (!$this->record_obj->hasPermissionToView((int) $_GET['ref_id'])) {
80  ilUtil::sendFailure('dcl_msg_no_perm_view', true);
81  $ilCtrl->redirectByClass('ildclrecordlistgui', 'listRecords');
82  }
83 
84  // content style (using system defaults)
85  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
86 
87  $tpl->setCurrentBlock("SyntaxStyle");
88  $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
89  $tpl->parseCurrentBlock();
90 
91  $tpl->setCurrentBlock("ContentStyle");
92  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
93  $tpl->parseCurrentBlock();
94 
95  $this->table = $this->record_obj->getTable();
96 
97  // Comments
98  include_once("./Services/Notes/classes/class.ilNoteGUI.php");
99  $repId = $this->dcl_gui_object->getDataCollectionObject()->getId();
100  $objId = (int) $this->record_id;
101  $this->notesGUI = new ilNoteGUI($repId, $objId);
102  $this->notesGUI->enablePublicNotes(true);
103  $this->notesGUI->enablePublicNotesDeletion(true);
104  $ilCtrl->setParameterByClass("ilnotegui", "record_id", $this->record_id);
105  $ilCtrl->setParameterByClass("ilnotegui", "rep_id", $repId);
106 
107  if (isset($_GET['disable_paging']) && $_GET['disable_paging']) {
108  $this->is_enabled_paging = false;
109  }
110  // Find current, prev and next records for navigation
111  if ($this->is_enabled_paging) {
112  $this->determineNextPrevRecords();
113  }
114  }
global $DIC
Definition: saml.php:7
$_GET["client_id"]
$tpl
Definition: ilias.php:10
Notes GUI class.
global $ilCtrl
Definition: ilias.php:18
static getRecordCache($record_id=0)
static getSyntaxStylePath()
get syntax style path
static getContentStylePath($a_style_id, $add_random=true)
get content style path
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
determineNextPrevRecords()
Find the previous/next record from the current position.
+ Here is the call graph for this function:

Member Function Documentation

◆ checkAccess()

ilDclDetailedViewGUI::checkAccess ( )
protected
Returns
bool

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

References $tableview_id, and ilDclDetailedViewDefinition\isActive().

Referenced by executeCommand().

428  {
429  return ilObjDataCollectionAccess::hasAccessTo(filter_input(INPUT_GET, 'ref_id'), $this->table->getId(), $this->tableview_id)
430  && ilDclDetailedViewDefinition::isActive($this->tableview_id);
431  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ determineNextPrevRecords()

ilDclDetailedViewGUI::determineNextPrevRecords ( )
protected

Find the previous/next record from the current position.

Also determine position of current record in whole set.

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

References $_SESSION, and loadSession().

Referenced by __construct().

336  {
337  if (!isset($_SESSION['dcl_record_ids']) || $_SESSION['dcl_table_id'] != $this->table->getId()) {
338  $this->loadSession();
339  }
340 
341  if (isset($_SESSION['dcl_record_ids']) && count($_SESSION['dcl_record_ids'])) {
342  $this->record_ids = $_SESSION['dcl_record_ids'];
343  foreach ($this->record_ids as $k => $recId) {
344  if ($recId == $this->record_id) {
345  if ($k != 0) {
346  $this->prev_record_id = $this->record_ids[$k - 1];
347  }
348  if (($k + 1) < count($this->record_ids)) {
349  $this->next_record_id = $this->record_ids[$k + 1];
350  }
351  $this->current_record_position = $k + 1;
352  break;
353  }
354  }
355  }
356  }
loadSession()
If we come from a goto Link we need to build up the session data.
$_SESSION["AccountId"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doExtReplace()

ilDclDetailedViewGUI::doExtReplace (   $found)
Parameters
$found
Returns
string

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

References $tpl, array, ilDclCache\getRecordCache(), ilObjDataCollectionAccess\hasWriteAccess(), and ilUtil\sendInfo().

284  {
285  $ref_rec_ids = $this->record_obj->getRecordFieldValue($this->currentField->getId());
286  if (!is_array($ref_rec_ids)) {
287  $ref_rec_ids = array( $ref_rec_ids );
288  }
289  if (!count($ref_rec_ids) || !$ref_rec_ids) {
290  return;
291  }
292  $ref_recs = array();
293  foreach ($ref_rec_ids as $ref_rec_id) {
294  $ref_recs[] = ilDclCache::getRecordCache($ref_rec_id);
295  }
296  $field = $ref_recs[0]->getTable()->getFieldByTitle($found[1]);
297 
298  $tpl = new ilTemplate("tpl.reference_list.html", true, true, "Modules/DataCollection");
299  $tpl->setCurrentBlock("reference_list");
300 
301  if (!$field) {
302  if (ilObjDataCollectionAccess::hasWriteAccess($this->dcl_gui_object->ref_id)) {
303  ilUtil::sendInfo("Bad Viewdefinition at [ext tableOf=\"" . $found[1] . "\" ...]", true);
304  }
305 
306  return;
307  }
308 
309  foreach ($ref_recs as $ref_record) {
310  $tpl->setCurrentBlock("reference");
311  $tpl->setVariable("CONTENT", $ref_record->getRecordFieldHTML($field->getId()));
312  $tpl->parseCurrentBlock();
313  }
314 
315  //$ref_rec->getRecordFieldHTML($field->getId())
316  if ($field) {
317  return $tpl->get();
318  }
319  }
$tpl
Definition: ilias.php:10
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
special template class to simplify handling of ITX/PEAR
static getRecordCache($record_id=0)
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ doReplace()

ilDclDetailedViewGUI::doReplace (   $found)
Parameters
$found
Returns
array|string

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

References setOptions().

273  {
274  return $this->record_obj->getRecordFieldSingleHTML($this->currentField->getId(), $this->setOptions($found[1]));
275  }
setOptions($link_name)
setOptions string $link_name
+ Here is the call graph for this function:

◆ executeCommand()

ilDclDetailedViewGUI::executeCommand ( )

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

References $_GET, $DIC, $ilCtrl, checkAccess(), offerAlternativeViews(), renderRecord(), and ilUtil\sendFailure().

118  {
119  global $DIC;
120  $ilCtrl = $DIC['ilCtrl'];
121  $this->tableview_id = $_GET['tableview_id'] ? $_GET['tableview_id'] : $this->table->getFirstTableViewId($_GET['ref_id']);
122  $ilCtrl->setParameter($this, 'tableview_id', $this->tableview_id);
123  $ilCtrl->setParameter($this->dcl_gui_object, 'tableview_id', $_GET['back_tableview_id'] ? $_GET['back_tableview_id'] : $this->tableview_id);
124 
125  if (!$this->checkAccess()) {
126  if ($this->table->getVisibleTableViews($_GET['ref_id'], true)) {
127  $this->offerAlternativeViews();
128  } else {
129  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
130  }
131  return;
132  }
133 
134  $cmd = $ilCtrl->getCmd();
135  $cmdClass = $ilCtrl->getCmdClass();
136  switch ($cmdClass) {
137  case 'ilnotegui':
138  switch ($cmd) {
139  case 'editNoteForm':
140  $this->renderRecord(true);
141  break;
142  case 'showNotes':
143  $this->renderRecord(false);
144  break;
145  case 'deleteNote':
146  $this->notesGUI->deleteNote();
147  $this->renderRecord();
148  break;
149  case 'cancelDelete':
150  $this->notesGUI->cancelDelete();
151  $this->renderRecord();
152  break;
153  default:
154  $this->notesGUI->$cmd();
155  break;
156  }
157  break;
158  default:
159  $this->$cmd();
160  break;
161  }
162  }
global $DIC
Definition: saml.php:7
$_GET["client_id"]
global $ilCtrl
Definition: ilias.php:18
renderRecord($editComments=false)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ 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 416 of file class.ilDclDetailedViewGUI.php.

References $list.

Referenced by determineNextPrevRecords().

417  {
418  // We need the default sorting etc. to dertermine on which position we currently are, thus we instantiate the table gui.
419  $list = new ilDclRecordListTableGUI(new ilDclRecordListGUI($this->dcl_gui_object, $this->table->getId()), "listRecords", $this->table, $this->tableview_id);
420  //we then partially load the records. note that this also fills up session data.
421  $this->table->getPartialRecords($list->getOrderField(), $list->getOrderDirection(), $list->getLimit(), $list->getOffset(), $list->getFilter());
422  }
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
+ Here is the caller graph for this function:

◆ offerAlternativeViews()

ilDclDetailedViewGUI::offerAlternativeViews ( )
protected

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

References $DIC, $tpl, and ilUtil\sendInfo().

Referenced by executeCommand().

165  {
166  global $DIC;
167  $tpl = $DIC['tpl'];
168  ilUtil::sendInfo($this->lng->txt('dcl_msg_info_alternatives'));
169  $table_gui = new ilDclTableViewTableGUI($this, 'renderRecord', $this->table);
170  $tpl->setContent($table_gui->getHTML());
171  }
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
Class ilDclTableViewTableGUI.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderComments()

ilDclDetailedViewGUI::renderComments (   $edit = false)
protected

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

Referenced by renderRecord().

323  {
324  if (!$edit) {
325  return $this->notesGUI->getOnlyCommentsHtml();
326  } else {
327  return $this->notesGUI->editNoteForm();
328  }
329  }
+ Here is the caller graph for this function:

◆ renderPrevNextLinks()

ilDclDetailedViewGUI::renderPrevNextLinks ( )
protected

Determine and return the markup for the previous/next records.

Returns
string

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

References $DIC, $ilCtrl, $next_record_id, $out, $prev_record_id, and $url.

Referenced by renderRecord().

365  {
366  global $DIC;
367  $ilCtrl = $DIC['ilCtrl'];
368  $ilCtrl->setParameter($this, 'tableview_id', $this->tableview_id);
369  $prevStr = $this->lng->txt('dcl_prev_record');
370  $nextStr = $this->lng->txt('dcl_next_record');
371  $ilCtrl->setParameter($this, 'record_id', $this->prev_record_id);
372  $url = $ilCtrl->getLinkTarget($this, 'renderRecord');
373  $out = ($this->prev_record_id) ? "<a href='{$url}'>{$prevStr}</a>" : "<span class='light'>{$prevStr}</span>";
374  $out .= " | ";
375  $ilCtrl->setParameter($this, 'record_id', $this->next_record_id);
376  $url = $ilCtrl->getLinkTarget($this, 'renderRecord');
377  $out .= ($this->next_record_id) ? "<a href='{$url}'>{$nextStr}</a>" : "<span class='light'>{$nextStr}</span>";
378 
379  return $out;
380  }
global $DIC
Definition: saml.php:7
global $ilCtrl
Definition: ilias.php:18
$url
+ Here is the caller graph for this function:

◆ renderRecord()

ilDclDetailedViewGUI::renderRecord (   $editComments = false)
Parameters
bool$editComments

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

References $_GET, $current_record_position, $DIC, $html, $ilCtrl, $table, $tpl, array, ilObjStyleSheet\getEffectiveContentStyleId(), ilLinkButton\getInstance(), ilDclCache\getTableCache(), ilDclRecordEditGUI\REDIRECT_DETAIL, renderComments(), renderPrevNextLinks(), renderSelectOptions(), and setOptions().

Referenced by executeCommand().

177  {
178  global $DIC;
179  $ilTabs = $DIC['ilTabs'];
180  $tpl = $DIC['tpl'];
181  $ilCtrl = $DIC['ilCtrl'];
182 
183  $rctpl = new ilTemplate("tpl.record_view.html", false, true, "Modules/DataCollection");
184 
185  $ilTabs->setTabActive("id_content");
186 
187  if (!$this->tableview_id) {
188  $ilCtrl->redirectByClass("ildclrecordlistgui", "listRecords");
189  }
190 
191  // see ilObjDataCollectionGUI->executeCommand about instantiation
192  include_once("class.ilDclDetailedViewDefinitionGUI.php");
193  $pageObj = new ilDclDetailedViewDefinitionGUI($this->tableview_id);
194  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
195  $pageObj->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(0, "dcl"));
196 
197  $html = $pageObj->getHTML();
198  $rctpl->addCss("./Services/COPage/css/content.css");
199  $rctpl->fillCssFiles();
200  $table = ilDclCache::getTableCache($this->record_obj->getTableId());
201  foreach ($table->getRecordFields() as $field) {
202  //ILIAS_Ref_Links
203  $pattern = '/\[dcliln field="' . preg_quote($field->getTitle(), "/") . '"\](.*?)\[\/dcliln\]/';
204  if (preg_match($pattern, $html)) {
205  $html = preg_replace($pattern, $this->record_obj->getRecordFieldSingleHTML($field->getId(), $this->setOptions("$1")), $html);
206  }
207 
208  //DataCollection Ref Links
209  $pattern = '/\[dclrefln field="' . preg_quote($field->getTitle(), "/") . '"\](.*?)\[\/dclrefln\]/';
210  if (preg_match($pattern, $html)) {
211  $this->currentField = $field;
212  $html = preg_replace_callback($pattern, array( $this, "doReplace" ), $html);
213  }
214 
215  $pattern = '/\[ext tableOf="' . preg_quote($field->getTitle(), "/") . '" field="(.*?)"\]/';
216  if (preg_match($pattern, $html)) {
217  $this->currentField = $field;
218  $html = preg_replace_callback($pattern, array( $this, "doExtReplace" ), $html);
219  }
220 
221  $html = str_ireplace("[" . $field->getTitle() . "]", $this->record_obj->getRecordFieldSingleHTML($field->getId()), $html);
222  }
223  foreach ($table->getStandardFields() as $field) {
224  $html = str_ireplace("[" . $field->getId() . "]", $this->record_obj->getRecordFieldSingleHTML($field->getId()), $html);
225  }
226  $rctpl->setVariable("CONTENT", $html);
227 
228  //Permanent Link
229  $perma_link = new ilPermanentLinkGUI("dcl", $_GET["ref_id"], "_" . $this->tableview_id . "_" . $this->record_obj->getId());
230  $tpl->setVariable('PRMLINK', $perma_link->getHTML());
231 
232  // Buttons for previous/next records
233 
234  if ($this->is_enabled_paging) {
235  $prevNextLinks = $this->renderPrevNextLinks();
236  $rctpl->setVariable('PREV_NEXT_RECORD_LINKS', $prevNextLinks);
237  $ilCtrl->clearParameters($this); // #14083
238  $rctpl->setVariable('FORM_ACTION', $ilCtrl->getFormAction($this));
239  $rctpl->setVariable('RECORD', $this->lng->txt('dcl_record'));
240  $rctpl->setVariable('RECORD_FROM_TOTAL', sprintf($this->lng->txt('dcl_record_from_total'), $this->current_record_position, count($this->record_ids)));
241  $rctpl->setVariable('TABLEVIEW_ID', $this->tableview_id);
242  $rctpl->setVariable('SELECT_OPTIONS', $this->renderSelectOptions());
243  }
244 
245  // Edit Button
246  if ($this->record_obj->hasPermissionToEdit((int) $_GET['ref_id'])) {
247  $button = ilLinkButton::getInstance();
248  $ilCtrl->setParameterByClass('ildclrecordeditgui', 'table_id', $this->table->getId());
249  $ilCtrl->setParameterByClass('ildclrecordeditgui', 'tableview_id', $this->tableview_id);
250  $ilCtrl->setParameterByClass('ildclrecordeditgui', 'redirect', ilDclRecordEditGUI::REDIRECT_DETAIL);
251  $ilCtrl->saveParameterByClass('ildclrecordeditgui', 'record_id');
252  $button->setUrl($ilCtrl->getLinkTargetByClass('ildclrecordeditgui', 'edit'));
253  $button->setCaption($this->lng->txt('dcl_edit_record'), false);
254  $rctpl->setVariable('EDIT_RECORD_BUTTON', $button->render());
255  }
256 
257 
258  // Comments
259  if ($this->table->getPublicCommentsEnabled()) {
260  $rctpl->setVariable('COMMENTS', $this->renderComments($editComments));
261  }
262 
263  $tpl->setContent($rctpl->get());
264  }
Class for permanent links.
global $DIC
Definition: saml.php:7
renderSelectOptions()
Render select options.
$_GET["client_id"]
$tpl
Definition: ilias.php:10
Class ilDclDetailedViewDefinitionGUI.
static getTableCache($table_id=0)
global $ilCtrl
Definition: ilias.php:18
setOptions($link_name)
setOptions string $link_name
renderPrevNextLinks()
Determine and return the markup for the previous/next records.
special template class to simplify handling of ITX/PEAR
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
Create styles array
The data for the language used.
$html
Definition: example_001.php:87
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderSelectOptions()

ilDclDetailedViewGUI::renderSelectOptions ( )
protected

Render select options.

Returns
string

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

References $out.

Referenced by renderRecord().

389  {
390  $out = '';
391  foreach ($this->record_ids as $k => $recId) {
392  $selected = ($recId == $this->record_id) ? " selected" : "";
393  $out .= "<option value='{$recId}'{$selected}>" . ($k + 1) . "</option>";
394  }
395 
396  return $out;
397  }
+ Here is the caller graph for this function:

◆ setOptions()

ilDclDetailedViewGUI::setOptions (   $link_name)
private

setOptions string $link_name

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

References $options, and array.

Referenced by doReplace(), and renderRecord().

405  {
406  $options = array();
407  $options['link']['display'] = true;
408  $options['link']['name'] = $link_name;
409 
410  return $options;
411  }
Create styles array
The data for the language used.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
+ Here is the caller graph for this function:

Field Documentation

◆ $current_record_position

ilDclDetailedViewGUI::$current_record_position = 0
protected

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

Referenced by renderRecord().

◆ $dcl_gui_object

ilDclDetailedViewGUI::$dcl_gui_object
protected

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

◆ $is_enabled_paging

ilDclDetailedViewGUI::$is_enabled_paging = true
protected

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

◆ $lng

ilDclDetailedViewGUI::$lng
protected

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

Referenced by __construct().

◆ $next_record_id

ilDclDetailedViewGUI::$next_record_id = 0
protected

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

Referenced by renderPrevNextLinks().

◆ $notes_gui

ilDclDetailedViewGUI::$notes_gui
protected

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

◆ $prev_record_id

ilDclDetailedViewGUI::$prev_record_id = 0
protected

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

Referenced by renderPrevNextLinks().

◆ $record_ids

ilDclDetailedViewGUI::$record_ids = array()
protected

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

◆ $record_obj

ilDclDetailedViewGUI::$record_obj
protected

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

◆ $table

ilDclDetailedViewGUI::$table
protected

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

Referenced by renderRecord().

◆ $tableview_id

ilDclDetailedViewGUI::$tableview_id
protected

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

Referenced by checkAccess().


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