ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 66 of file class.ilDclDetailedViewGUI.php.

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

67  {
68  global $DIC;
69  $tpl = $DIC['tpl'];
70  $ilCtrl = $DIC['ilCtrl'];
71  $lng = $DIC['lng'];
72  $this->dcl_gui_object = $a_dcl_object;
73  $this->lng = $lng;
74 
75  $this->record_id = (int) $_REQUEST['record_id'];
76  $this->record_obj = ilDclCache::getRecordCache($this->record_id);
77 
78  if (!$this->record_obj->hasPermissionToView((int) $_GET['ref_id'])) {
79  ilUtil::sendFailure('dcl_msg_no_perm_view', true);
80  $ilCtrl->redirectByClass('ildclrecordlistgui', 'listRecords');
81  }
82 
83  // content style (using system defaults)
84  $tpl->setCurrentBlock("SyntaxStyle");
85  $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
86  $tpl->parseCurrentBlock();
87 
88  $tpl->setCurrentBlock("ContentStyle");
89  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
90  $tpl->parseCurrentBlock();
91 
92  $this->table = $this->record_obj->getTable();
93 
94  // Comments
95  $repId = $this->dcl_gui_object->getDataCollectionObject()->getId();
96  $objId = (int) $this->record_id;
97  $this->notesGUI = new ilNoteGUI($repId, $objId);
98  $this->notesGUI->enablePublicNotes(true);
99  $this->notesGUI->enablePublicNotesDeletion(true);
100  $ilCtrl->setParameterByClass("ilnotegui", "record_id", $this->record_id);
101  $ilCtrl->setParameterByClass("ilnotegui", "rep_id", $repId);
102 
103  if (isset($_GET['disable_paging']) && $_GET['disable_paging']) {
104  $this->is_enabled_paging = false;
105  }
106  // Find current, prev and next records for navigation
107  if ($this->is_enabled_paging) {
108  $this->determineNextPrevRecords();
109  }
110  }
static getContentStylePath($a_style_id, $add_random=true, $add_token=true)
get content style path
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
$_GET["client_id"]
$objId
Definition: xapitoken.php:41
Notes GUI class.
global $ilCtrl
Definition: ilias.php:18
static getRecordCache($record_id=0)
static getSyntaxStylePath()
get syntax style path
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$DIC
Definition: xapitoken.php:46
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 428 of file class.ilDclDetailedViewGUI.php.

References $tableview_id, and ilDclDetailedViewDefinition\isActive().

Referenced by executeCommand().

429  {
430  return ilObjDataCollectionAccess::hasAccessTo(filter_input(INPUT_GET, 'ref_id'), $this->table->getId(), $this->tableview_id)
431  && ilDclDetailedViewDefinition::isActive($this->tableview_id);
432  }
+ 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 334 of file class.ilDclDetailedViewGUI.php.

References $_SESSION, and loadSession().

Referenced by __construct().

335  {
336  if (!isset($_SESSION['dcl_record_ids']) || $_SESSION['dcl_table_id'] != $this->table->getId()) {
337  $this->loadSession();
338  }
339 
340  if (isset($_SESSION['dcl_record_ids']) && count($_SESSION['dcl_record_ids'])) {
341  $this->record_ids = $_SESSION['dcl_record_ids'];
342  foreach ($this->record_ids as $k => $recId) {
343  if ($recId == $this->record_id) {
344  if ($k != 0) {
345  $this->prev_record_id = $this->record_ids[$k - 1];
346  }
347  if (($k + 1) < count($this->record_ids)) {
348  $this->next_record_id = $this->record_ids[$k + 1];
349  }
350  $this->current_record_position = $k + 1;
351  break;
352  }
353  }
354  }
355  }
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 282 of file class.ilDclDetailedViewGUI.php.

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

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

◆ doReplace()

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

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

References setOptions().

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

◆ executeCommand()

ilDclDetailedViewGUI::executeCommand ( )

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

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

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

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  }
+ Here is the caller graph for this function:

◆ offerAlternativeViews()

ilDclDetailedViewGUI::offerAlternativeViews ( )
protected

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

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

Referenced by executeCommand().

163  {
164  global $DIC;
165  $tpl = $DIC['tpl'];
166  ilUtil::sendInfo($this->lng->txt('dcl_msg_info_alternatives'));
167  $table_gui = new ilDclTableViewTableGUI($this, 'renderRecord', $this->table);
168  $tpl->setContent($table_gui->getHTML());
169  }
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
Class ilDclTableViewTableGUI.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$DIC
Definition: xapitoken.php:46
+ 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 321 of file class.ilDclDetailedViewGUI.php.

Referenced by renderRecord().

322  {
323  if (!$edit) {
324  return $this->notesGUI->getOnlyCommentsHtml();
325  } else {
326  return $this->notesGUI->editNoteForm();
327  }
328  }
+ 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 363 of file class.ilDclDetailedViewGUI.php.

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

Referenced by renderRecord().

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

◆ renderRecord()

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

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

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

Referenced by executeCommand().

176  {
177  global $DIC;
178  $ilTabs = $DIC->tabs();
179  $tpl = $DIC->ui()->mainTemplate();
180  $ilCtrl = $DIC->ctrl();
181 
182  $rctpl = new ilDataCollectionGlobalTemplate("tpl.record_view.html", false, true, "Modules/DataCollection");
183 
184  $ilTabs->setTabActive("id_content");
185 
186  if (!$this->tableview_id) {
187  $ilCtrl->redirectByClass("ildclrecordlistgui", "listRecords");
188  }
189 
190  // see ilObjDataCollectionGUI->executeCommand about instantiation
191  $pageObj = new ilDclDetailedViewDefinitionGUI($this->tableview_id);
192  $pageObj->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(0, "dcl"));
193 
194  $html = $pageObj->getHTML();
195  $rctpl->addCss("./Services/COPage/css/content.css");
196  $rctpl->fillCssFiles();
197  $table = ilDclCache::getTableCache($this->record_obj->getTableId());
198  foreach ($table->getRecordFields() as $field) {
199  //ILIAS_Ref_Links
200  $pattern = '/\[dcliln field="' . preg_quote($field->getTitle(), "/") . '"\](.*?)\[\/dcliln\]/';
201  if (preg_match($pattern, $html)) {
202  $html = preg_replace($pattern, $this->record_obj->getRecordFieldSingleHTML($field->getId(), $this->setOptions("$1")), $html);
203  }
204 
205  //DataCollection Ref Links
206  $pattern = '/\[dclrefln field="' . preg_quote($field->getTitle(), "/") . '"\](.*?)\[\/dclrefln\]/';
207  if (preg_match($pattern, $html)) {
208  $this->currentField = $field;
209  $html = preg_replace_callback($pattern, array($this, "doReplace"), $html);
210  }
211 
212  $pattern = '/\[ext tableOf="' . preg_quote($field->getTitle(), "/") . '" field="(.*?)"\]/';
213  if (preg_match($pattern, $html)) {
214  $this->currentField = $field;
215  $html = preg_replace_callback($pattern, array($this, "doExtReplace"), $html);
216  }
217 
218  $html = str_ireplace("[" . $field->getTitle() . "]", $this->record_obj->getRecordFieldSingleHTML($field->getId()), $html);
219  }
220  foreach ($table->getStandardFields() as $field) {
221  $html = str_ireplace("[" . $field->getId() . "]", $this->record_obj->getRecordFieldSingleHTML($field->getId()), $html);
222  }
223  $rctpl->setVariable("CONTENT", $html);
224 
225  //Permanent Link
226  $tpl->setPermanentLink(
227  'dcl',
228  filter_input(INPUT_GET, 'ref_id', FILTER_VALIDATE_INT),
229  '_' . $this->tableview_id . '_' . $this->record_obj->getId()
230  );
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  // Comments
258  if ($this->table->getPublicCommentsEnabled()) {
259  $rctpl->setVariable('COMMENTS', $this->renderComments($editComments));
260  }
261 
262  $tpl->setContent($rctpl->get());
263  }
special template class to simplify handling of ITX/PEAR
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
renderSelectOptions()
Render select options.
$_GET["client_id"]
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.
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
$DIC
Definition: xapitoken.php:46
+ 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 387 of file class.ilDclDetailedViewGUI.php.

References $out.

Referenced by renderRecord().

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

◆ setOptions()

ilDclDetailedViewGUI::setOptions (   $link_name)
private

setOptions string $link_name

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

Referenced by doReplace(), and renderRecord().

404  {
405  $options = array();
406  $options['link']['display'] = true;
407  $options['link']['name'] = $link_name;
408 
409  return $options;
410  }
+ Here is the caller graph for this function:

Field Documentation

◆ $current_record_position

ilDclDetailedViewGUI::$current_record_position = 0
protected

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

Referenced by renderRecord().

◆ $dcl_gui_object

ilDclDetailedViewGUI::$dcl_gui_object
protected

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

◆ $is_enabled_paging

ilDclDetailedViewGUI::$is_enabled_paging = true
protected

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

◆ $lng

ilDclDetailedViewGUI::$lng
protected

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

Referenced by __construct().

◆ $next_record_id

ilDclDetailedViewGUI::$next_record_id = 0
protected

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

Referenced by renderPrevNextLinks().

◆ $notes_gui

ilDclDetailedViewGUI::$notes_gui
protected

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

◆ $prev_record_id

ilDclDetailedViewGUI::$prev_record_id = 0
protected

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

Referenced by renderPrevNextLinks().

◆ $record_ids

ilDclDetailedViewGUI::$record_ids = array()
protected

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

◆ $record_obj

ilDclDetailedViewGUI::$record_obj
protected

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

◆ $table

ilDclDetailedViewGUI::$table
protected

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

Referenced by renderRecord().

◆ $tableview_id

ilDclDetailedViewGUI::$tableview_id
protected

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

Referenced by checkAccess().


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