ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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.
 renderPrevNextLinks ()
 Determine and return the markup for the previous/next records.
 renderSelectOptions ()
 Render select options.

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
 loadSession ()
 If we come from a goto Link we need to build up the session data.

Detailed Description

Constructor & Destructor Documentation

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

{
global $tpl, $ilCtrl;
$this->dcl_gui_object = $a_dcl_object;
$this->record_id = (int)$_REQUEST['record_id'];
$this->record_obj = ilDataCollectionCache::getRecordCache($this->record_id);
if (!$this->record_obj->hasPermissionToView((int)$_GET['ref_id'])) {
ilUtil::sendFailure('dcl_msg_no_perm_view', true);
$ilCtrl->redirectByClass('ildatacollectionrecordlistgui', 'listRecords');
}
// content style (using system defaults)
include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
$tpl->setCurrentBlock("SyntaxStyle");
$tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
$tpl->parseCurrentBlock();
$tpl->setCurrentBlock("ContentStyle");
$tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
$tpl->parseCurrentBlock();
$this->table = $this->record_obj->getTable();
// Comments
include_once("./Services/Notes/classes/class.ilNoteGUI.php");
$repId = $this->dcl_gui_object->getDataCollectionObject()->getId();
$objId = (int)$this->record_id;
$this->notesGUI = new ilNoteGUI($repId, $objId);
$this->notesGUI->enablePublicNotes(true);
$this->notesGUI->enablePublicNotesDeletion(true);
$ilCtrl->setParameterByClass("ilnotegui", "record_id", $this->record_id);
$ilCtrl->setParameterByClass("ilnotegui", "rep_id", $repId);
if (isset($_GET['disable_paging']) && $_GET['disable_paging']) {
$this->is_enabled_paging = false;
}
// Find current, prev and next records for navigation
if ($this->is_enabled_paging) {
}
}

+ Here is the call graph for this function:

Member Function Documentation

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

Referenced by renderRecord().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

{
if(!isset($_SESSION['dcl_record_ids']) || $_SESSION['dcl_table_id'] != $this->table->getId()) {
$this->loadSession();
}
if (isset($_SESSION['dcl_record_ids']) && count($_SESSION['dcl_record_ids'])) {
$this->record_ids = $_SESSION['dcl_record_ids'];
foreach ($this->record_ids as $k => $recId) {
if ($recId == $this->record_id) {
if ($k != 0) {
$this->prev_record_id = $this->record_ids[$k - 1];
}
if (($k + 1) < count($this->record_ids)) {
$this->next_record_id = $this->record_ids[$k + 1];
}
$this->current_record_position = $k + 1;
break;
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

{
$ref_rec_ids = $this->record_obj->getRecordFieldValue($this->currentField->getId());
if (!is_array($ref_rec_ids)) {
$ref_rec_ids = array( $ref_rec_ids );
}
if (!count($ref_rec_ids) || !$ref_rec_ids) {
return;
}
$ref_recs = array();
foreach ($ref_rec_ids as $ref_rec_id) {
$ref_recs[] = ilDataCollectionCache::getRecordCache($ref_rec_id);
}
$field = $ref_recs[0]->getTable()->getFieldByTitle($found[1]);
$tpl = new ilTemplate("tpl.reference_list.html", true, true, "Modules/DataCollection");
$tpl->setCurrentBlock("reference_list");
if (!$field) {
if (ilObjDataCollectionAccess::hasWriteAccess($this->dcl_gui_object->ref_id)) {
ilUtil::sendInfo("Bad Viewdefinition at [ext tableOf=\"" . $found[1] . "\" ...]", true);
}
return;
}
foreach ($ref_recs as $ref_record) {
$tpl->setCurrentBlock("reference");
$tpl->setVariable("CONTENT", $ref_record->getRecordFieldHTML($field->getId()));
$tpl->parseCurrentBlock();
}
//$ref_rec->getRecordFieldHTML($field->getId())
if ($field) {
return $tpl->get();
}
}

+ Here is the call graph for this function:

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

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

References setOptions().

{
return $this->record_obj->getRecordFieldSingleHTML($this->currentField->getId(), $this->setOptions($found[1]));
}

+ Here is the call graph for this function:

ilDataCollectionRecordViewGUI::executeCommand ( )

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

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

{
global $ilCtrl;
$cmd = $ilCtrl->getCmd();
$cmdClass = $ilCtrl->getCmdClass();
switch ($cmdClass) {
case 'ilnotegui':
switch ($cmd) {
case 'editNoteForm':
$this->renderRecord(true);
break;
case 'showNotes':
$this->renderRecord(false);
break;
case 'deleteNote':
$this->notesGUI->deleteNote();
$this->renderRecord();
break;
case 'cancelDelete':
$this->notesGUI->cancelDelete();
$this->renderRecord();
break;
default:
$this->notesGUI->$cmd();
break;
}
break;
default:
$this->$cmd();
break;
}
}

+ Here is the call graph for this function:

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

{
return $view->getActive() AND $view->getId() !== NULL;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

{
return $view->getActive() AND $view->getId() !== NULL;
}

+ Here is the call graph for this function:

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

{
// We need the default sorting etc. to dertermine on which position we currently are, thus we instantiate the table gui.
$list = new ilDataCollectionRecordListTableGUI(new ilDataCollectionRecordListGUI($this->dcl_gui_object, $this->table->getId()), "listRecords", $this->table);
//we then partially load the records. note that this also fills up session data.
$this->table->getPartialRecords($list->getOrderField(), $list->getOrderDirection(), $list->getLimit(), $list->getOffset(), $list->getFilter());
}

+ Here is the caller graph for this function:

ilDataCollectionRecordViewGUI::renderComments (   $edit = false)
protected

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

Referenced by renderRecord().

{
if (!$edit) {
return $this->notesGUI->getOnlyCommentsHtml();
} else {
return $this->notesGUI->editNoteForm();
}
}

+ Here is the caller graph for this function:

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, and $prev_record_id.

Referenced by renderRecord().

{
global $ilCtrl, $lng;
$prevStr = $lng->txt('dcl_prev_record');
$nextStr = $lng->txt('dcl_next_record');
$ilCtrl->setParameter($this, 'record_id', $this->prev_record_id);
$url = $ilCtrl->getLinkTarget($this, 'renderRecord');
$out = ($this->prev_record_id) ? "<a href='{$url}'>{$prevStr}</a>" : "<span class='light'>{$prevStr}</span>";
$out .= " | ";
$ilCtrl->setParameter($this, 'record_id', $this->next_record_id);
$url = $ilCtrl->getLinkTarget($this, 'renderRecord');
$out .= ($this->next_record_id) ? "<a href='{$url}'>{$nextStr}</a>" : "<span class='light'>{$nextStr}</span>";
return $out;
}

+ Here is the caller graph for this function:

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

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

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

Referenced by executeCommand().

{
global $ilTabs, $tpl, $ilCtrl, $lng;
$rctpl = new ilTemplate("tpl.record_view.html", false, true, "Modules/DataCollection");
$ilTabs->setTabActive("id_content");
$view_id = self::_getViewDefinitionId($this->record_obj);
if (!$view_id) {
$ilCtrl->redirectByClass("ildatacollectionrecordlistgui", "listRecords");
}
// see ilObjDataCollectionGUI->executeCommand about instantiation
include_once("./Modules/DataCollection/classes/class.ilDataCollectionRecordViewViewdefinitionGUI.php");
$pageObj = new ilDataCollectionRecordViewViewdefinitionGUI($this->record_obj->getTableId(), $view_id);
include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
$pageObj->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(0, "dcl"));
$html = $pageObj->getHTML();
$rctpl->addCss("./Services/COPage/css/content.css");
$rctpl->fillCssFiles();
$table = ilDataCollectionCache::getTableCache($this->record_obj->getTableId());
foreach ($table->getRecordFields() as $field) {
//ILIAS_Ref_Links
$pattern = '/\[dcliln field="' . preg_quote($field->getTitle(), "/") . '"\](.*?)\[\/dcliln\]/';
if (preg_match($pattern, $html)) {
$html = preg_replace($pattern, $this->record_obj->getRecordFieldSingleHTML($field->getId(), $this->setOptions("$1")), $html);
}
//DataCollection Ref Links
$pattern = '/\[dclrefln field="' . preg_quote($field->getTitle(), "/") . '"\](.*?)\[\/dclrefln\]/';
if (preg_match($pattern, $html)) {
$this->currentField = $field;
$html = preg_replace_callback($pattern, array( $this, "doReplace" ), $html);
}
$pattern = '/\[ext tableOf="' . preg_quote($field->getTitle(), "/") . '" field="(.*?)"\]/';
if (preg_match($pattern, $html)) {
$this->currentField = $field;
$html = preg_replace_callback($pattern, array( $this, "doExtReplace" ), $html);
}
$html = str_ireplace("[" . $field->getTitle() . "]", $this->record_obj->getRecordFieldSingleHTML($field->getId()), $html);
}
foreach ($table->getStandardFields() as $field) {
$html = str_ireplace("[" . $field->getId() . "]", $this->record_obj->getRecordFieldSingleHTML($field->getId()), $html);
}
$rctpl->setVariable("CONTENT", $html);
//Permanent Link
$perma_link = new ilPermanentLinkGUI("dcl", $_GET["ref_id"], "_" . $this->record_obj->getId());
$tpl->setVariable('PRMLINK', $perma_link->getHTML());
// Buttons for previous/next records
if ($this->is_enabled_paging) {
$prevNextLinks = $this->renderPrevNextLinks();
$rctpl->setVariable('PREV_NEXT_RECORD_LINKS', $prevNextLinks);
$ilCtrl->clearParameters($this); // #14083
$rctpl->setVariable('FORM_ACTION', $ilCtrl->getFormAction($this));
$rctpl->setVariable('RECORD', $lng->txt('dcl_record'));
$rctpl->setVariable('RECORD_FROM_TOTAL', sprintf($lng->txt('dcl_record_from_total'), $this->current_record_position, count($this->record_ids)));
$rctpl->setVariable('SELECT_OPTIONS', $this->renderSelectOptions());
}
// Edit Button
if ($this->record_obj->hasPermissionToEdit((int)$_GET['ref_id'])) {
$ilCtrl->setParameterByClass('ildatacollectionrecordeditgui', 'table_id', $this->table->getId());
$ilCtrl->setParameterByClass('ildatacollectionrecordeditgui', 'redirect', ilDataCollectionRecordEditGUI::REDIRECT_DETAIL);
$ilCtrl->saveParameterByClass('ildatacollectionrecordeditgui', 'record_id');
$button->setUrl($ilCtrl->getLinkTargetByClass('ildatacollectionrecordeditgui', 'edit'));
$button->setCaption($lng->txt('dcl_edit_record'), false);
$rctpl->setVariable('EDIT_RECORD_BUTTON', $button->render());
}
// var_dump($_SESSION['dcl_record_ids']);
// Comments
if ($this->table->getPublicCommentsEnabled()) {
$rctpl->setVariable('COMMENTS', $this->renderComments($editComments));
}
$tpl->setContent($rctpl->get());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilDataCollectionRecordViewGUI::renderSelectOptions ( )
protected

Render select options.

Returns
string

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

References $out.

Referenced by renderRecord().

{
$out = '';
foreach ($this->record_ids as $k => $recId) {
$selected = ($recId == $this->record_id) ? " selected" : "";
$out .= "<option value='{$recId}'{$selected}>" . ($k + 1) . "</option>";
}
return $out;
}

+ Here is the caller graph for this function:

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

{
$options = array();
$options['link']['display'] = true;
$options['link']['name'] = $link_name;
return $options;
}

+ Here is the caller graph for this function:

Field Documentation

ilDataCollectionRecordViewGUI::$current_record_position = 0
protected

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

Referenced by renderRecord().

ilDataCollectionRecordViewGUI::$dcl_gui_object
protected

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

ilDataCollectionRecordViewGUI::$is_enabled_paging = true
protected

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

ilDataCollectionRecordViewGUI::$next_record_id = 0
protected

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

Referenced by renderPrevNextLinks().

ilDataCollectionRecordViewGUI::$notes_gui
protected

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

ilDataCollectionRecordViewGUI::$prev_record_id = 0
protected

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

Referenced by renderPrevNextLinks().

ilDataCollectionRecordViewGUI::$record_ids = array()
protected

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

ilDataCollectionRecordViewGUI::$record_obj
protected

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

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: