ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
ilDataCollectionRecordViewGUI Class Reference

Class ilDataCollectionRecordViewGUI. More...

+ Collaboration diagram for ilDataCollectionRecordViewGUI:

Public Member Functions

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

Static Public Member Functions

static _getViewDefinitionId (ilDataCollectionRecord $record_obj)
 
static hasValidViewDefinition (ilDataCollectionRecord $record_obj)
 
static hasTableValidViewDefinition (ilDataCollectionTable $table)
 

Protected Member Functions

 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...
 

Protected Attributes

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

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()

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

Definition at line 69 of file class.ilDataCollectionRecordViewGUI.php.

References $_GET, $_REQUEST, $ilCtrl, $tpl, determineNextPrevRecords(), ilObjStyleSheet\getContentStylePath(), ilDataCollectionCache\getRecordCache(), ilObjStyleSheet\getSyntaxStylePath(), and ilUtil\sendFailure().

69  {
70  global $tpl, $ilCtrl;
71  $this->dcl_gui_object = $a_dcl_object;
72 
73  $this->record_id = (int)$_REQUEST['record_id'];
74  $this->record_obj = ilDataCollectionCache::getRecordCache($this->record_id);
75 
76  if (!$this->record_obj->hasPermissionToView((int)$_GET['ref_id'])) {
77  ilUtil::sendFailure('dcl_msg_no_perm_view', true);
78  $ilCtrl->redirectByClass('ildatacollectionrecordlistgui', 'listRecords');
79  }
80 
81  // content style (using system defaults)
82  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
83 
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  include_once("./Services/Notes/classes/class.ilNoteGUI.php");
96  $repId = $this->dcl_gui_object->getDataCollectionObject()->getId();
97  $objId = (int)$this->record_id;
98  $this->notesGUI = new ilNoteGUI($repId, $objId);
99  $this->notesGUI->enablePublicNotes(true);
100  $this->notesGUI->enablePublicNotesDeletion(true);
101  $ilCtrl->setParameterByClass("ilnotegui", "record_id", $this->record_id);
102  $ilCtrl->setParameterByClass("ilnotegui", "rep_id", $repId);
103 
104  if (isset($_GET['disable_paging']) && $_GET['disable_paging']) {
105  $this->is_enabled_paging = false;
106  }
107  // Find current, prev and next records for navigation
108  if ($this->is_enabled_paging) {
109  $this->determineNextPrevRecords();
110  }
111  }
static getRecordCache($record_id=0)
$_GET["client_id"]
getSyntaxStylePath()
get syntax style path
global $tpl
Definition: ilias.php:8
Notes GUI class.
global $ilCtrl
Definition: ilias.php:18
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
getContentStylePath($a_style_id)
get content style path
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
determineNextPrevRecords()
Find the previous/next record from the current position.
+ Here is the call graph for this function:

Member Function Documentation

◆ _getViewDefinitionId()

static ilDataCollectionRecordViewGUI::_getViewDefinitionId ( ilDataCollectionRecord  $record_obj)
static
Parameters
$record_objilDataCollectionRecord
Deprecated:
Returns
int|NULL returns the id of the viewdefinition if one is declared and NULL otherwise

Definition at line 155 of file class.ilDataCollectionRecordViewGUI.php.

References ilDataCollectionRecordViewViewdefinition\getIdByTableId(), and ilDataCollectionRecord\getTableId().

155  {
157  }
static getIdByTableId($a_table_id)
Get view definition id by table id.
+ Here is the call graph for this function:

◆ determineNextPrevRecords()

ilDataCollectionRecordViewGUI::determineNextPrevRecords ( )
protected

Find the previous/next record from the current position.

Also determine position of current record in whole set.

Definition at line 342 of file class.ilDataCollectionRecordViewGUI.php.

References $_SESSION, and loadSession().

Referenced by __construct().

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

◆ doExtReplace()

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

Definition at line 291 of file class.ilDataCollectionRecordViewGUI.php.

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

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

◆ doReplace()

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

Definition at line 281 of file class.ilDataCollectionRecordViewGUI.php.

References setOptions().

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

◆ executeCommand()

ilDataCollectionRecordViewGUI::executeCommand ( )

Definition at line 114 of file class.ilDataCollectionRecordViewGUI.php.

References $cmd, $ilCtrl, and renderRecord().

114  {
115  global $ilCtrl;
116 
117  $cmd = $ilCtrl->getCmd();
118  $cmdClass = $ilCtrl->getCmdClass();
119  switch ($cmdClass) {
120  case 'ilnotegui':
121  switch ($cmd) {
122  case 'editNoteForm':
123  $this->renderRecord(true);
124  break;
125  case 'showNotes':
126  $this->renderRecord(false);
127  break;
128  case 'deleteNote':
129  $this->notesGUI->deleteNote();
130  $this->renderRecord();
131  break;
132  case 'cancelDelete':
133  $this->notesGUI->cancelDelete();
134  $this->renderRecord();
135  break;
136  default:
137  $this->notesGUI->$cmd();
138  break;
139  }
140  break;
141  default:
142  $this->$cmd();
143  break;
144  }
145  }
$cmd
Definition: sahs_server.php:35
global $ilCtrl
Definition: ilias.php:18
+ Here is the call graph for this function:

◆ hasTableValidViewDefinition()

static ilDataCollectionRecordViewGUI::hasTableValidViewDefinition ( ilDataCollectionTable  $table)
static
Parameters
ilDataCollectionTable$table
Returns
bool

Definition at line 178 of file class.ilDataCollectionRecordViewGUI.php.

References ilDataCollectionTable\getId(), and ilDataCollectionRecordViewViewdefinition\getInstanceByTableId().

Referenced by ilDataCollectionRecordListTableGUI\buildData().

178  {
180 
181  return $view->getActive() AND $view->getId() !== NULL;
182  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasValidViewDefinition()

static ilDataCollectionRecordViewGUI::hasValidViewDefinition ( ilDataCollectionRecord  $record_obj)
static
Parameters
ilDataCollectionRecord$record_obj
Deprecated:
Returns
bool

Definition at line 166 of file class.ilDataCollectionRecordViewGUI.php.

References ilDataCollectionRecordViewViewdefinition\getInstanceByTableId(), and ilDataCollectionRecord\getTableId().

166  {
168 
169  return $view->getActive() AND $view->getId() !== NULL;
170  }
+ Here is the call graph for this function:

◆ loadSession()

ilDataCollectionRecordViewGUI::loadSession ( )
private

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

Definition at line 417 of file class.ilDataCollectionRecordViewGUI.php.

Referenced by determineNextPrevRecords().

418  {
419  // We need the default sorting etc. to dertermine on which position we currently are, thus we instantiate the table gui.
420  $list = new ilDataCollectionRecordListTableGUI(new ilDataCollectionRecordListGUI($this->dcl_gui_object, $this->table->getId()), "listRecords", $this->table);
421  //we then partially load the records. note that this also fills up session data.
422  $this->table->getPartialRecords($list->getOrderField(), $list->getOrderDirection(), $list->getLimit(), $list->getOffset(), $list->getFilter());
423  }
Class ilDataCollectionRecordListGUI.
+ Here is the caller graph for this function:

◆ renderComments()

ilDataCollectionRecordViewGUI::renderComments (   $edit = false)
protected

Definition at line 329 of file class.ilDataCollectionRecordViewGUI.php.

Referenced by renderRecord().

329  {
330 
331  if (!$edit) {
332  return $this->notesGUI->getOnlyCommentsHtml();
333  } else {
334  return $this->notesGUI->editNoteForm();
335  }
336  }
+ Here is the caller graph for this function:

◆ renderPrevNextLinks()

ilDataCollectionRecordViewGUI::renderPrevNextLinks ( )
protected

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

Returns
string

Definition at line 370 of file class.ilDataCollectionRecordViewGUI.php.

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

Referenced by renderRecord().

370  {
371  global $ilCtrl, $lng;
372  $prevStr = $lng->txt('dcl_prev_record');
373  $nextStr = $lng->txt('dcl_next_record');
374  $ilCtrl->setParameter($this, 'record_id', $this->prev_record_id);
375  $url = $ilCtrl->getLinkTarget($this, 'renderRecord');
376  $out = ($this->prev_record_id) ? "<a href='{$url}'>{$prevStr}</a>" : "<span class='light'>{$prevStr}</span>";
377  $out .= " | ";
378  $ilCtrl->setParameter($this, 'record_id', $this->next_record_id);
379  $url = $ilCtrl->getLinkTarget($this, 'renderRecord');
380  $out .= ($this->next_record_id) ? "<a href='{$url}'>{$nextStr}</a>" : "<span class='light'>{$nextStr}</span>";
381 
382  return $out;
383  }
$url
Definition: shib_logout.php:72
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
+ Here is the caller graph for this function:

◆ renderRecord()

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

Definition at line 188 of file class.ilDataCollectionRecordViewGUI.php.

References $_GET, $current_record_position, $html, $ilCtrl, $lng, $table, $tpl, ilObjStyleSheet\getEffectiveContentStyleId(), ilLinkButton\getInstance(), ilDataCollectionCache\getTableCache(), ilDataCollectionRecordEditGUI\REDIRECT_DETAIL, renderComments(), renderPrevNextLinks(), renderSelectOptions(), and setOptions().

Referenced by executeCommand().

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

◆ renderSelectOptions()

ilDataCollectionRecordViewGUI::renderSelectOptions ( )
protected

Render select options.

Returns
string

Definition at line 391 of file class.ilDataCollectionRecordViewGUI.php.

References $out.

Referenced by renderRecord().

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

◆ setOptions()

ilDataCollectionRecordViewGUI::setOptions (   $link_name)
private

setOptions string $link_name

Definition at line 406 of file class.ilDataCollectionRecordViewGUI.php.

References $options.

Referenced by doReplace(), and renderRecord().

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

Field Documentation

◆ $current_record_position

ilDataCollectionRecordViewGUI::$current_record_position = 0
protected

Definition at line 55 of file class.ilDataCollectionRecordViewGUI.php.

Referenced by renderRecord().

◆ $dcl_gui_object

ilDataCollectionRecordViewGUI::$dcl_gui_object
protected

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

◆ $is_enabled_paging

ilDataCollectionRecordViewGUI::$is_enabled_paging = true
protected

Definition at line 63 of file class.ilDataCollectionRecordViewGUI.php.

◆ $next_record_id

ilDataCollectionRecordViewGUI::$next_record_id = 0
protected

Definition at line 47 of file class.ilDataCollectionRecordViewGUI.php.

Referenced by renderPrevNextLinks().

◆ $notes_gui

ilDataCollectionRecordViewGUI::$notes_gui
protected

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

◆ $prev_record_id

ilDataCollectionRecordViewGUI::$prev_record_id = 0
protected

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

Referenced by renderPrevNextLinks().

◆ $record_ids

ilDataCollectionRecordViewGUI::$record_ids = array()
protected

Definition at line 59 of file class.ilDataCollectionRecordViewGUI.php.

◆ $record_obj

ilDataCollectionRecordViewGUI::$record_obj
protected

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

◆ $table

ilDataCollectionRecordViewGUI::$table
protected

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

Referenced by renderRecord().


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