ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilDataCollectionNReferenceField Class Reference

Class ilDataCollectionNReferenceField. More...

+ Inheritance diagram for ilDataCollectionNReferenceField:
+ Collaboration diagram for ilDataCollectionNReferenceField:

Public Member Functions

 doUpdate ()
 Update object in database.
 getSingleHTML ($options=NULL)
 this funciton is used to in the viewdefinition of a single record.
 buildTemplate ($record_field, $values, $options)
 getHTML ()
 getExportValue ()
- Public Member Functions inherited from ilDataCollectionReferenceField
 __construct (ilDataCollectionRecord $record, ilDataCollectionField $field)
- Public Member Functions inherited from ilDataCollectionRecordField
 delete ()
 Delete record field in database.
 getValue ()
 setValue ($value, $omit_parsing=false)
 Set value for record field.
 getFormInput ()
 getPlainText ()
 getHTML ($link=true)
 getSortingValue ($link=true)
 getSingleHTML ()
 getField ()
 getId ()
 getRecord ()

Protected Member Functions

 loadValue ()
 Load the value.
 getLinkHTML ($link, $value)

Protected Attributes

 $max_reference_length = 20
- Protected Attributes inherited from ilDataCollectionReferenceField
 $dcl_obj_id
 $properties = array()
- Protected Attributes inherited from ilDataCollectionRecordField
 $id
 $field
 $record
 $value
 $lng
 $user
 $ctrl
 $db

Detailed Description

Member Function Documentation

ilDataCollectionNReferenceField::buildTemplate (   $record_field,
  $values,
  $options 
)
Parameters
$record_field
$values
$options
Returns
ilTemplate

Definition at line 88 of file class.ilDataCollectionNReferenceField.php.

References $options, $tpl, ilDataCollectionRecordField\$value, getLinkHTML(), and ilDataCollectionCache\getRecordCache().

Referenced by getSingleHTML().

{
$tpl = new ilTemplate("tpl.reference_list.html", true, true, "Modules/DataCollection");
$tpl->setCurrentBlock("reference_list");
foreach ($values as $value) {
if (!$ref_record->getTableId() || !$record_field->getField() || !$record_field->getField()->getTableId()) {
//the referenced record_field does not seem to exist.
$record_field->setValue(0);
$record_field->doUpdate();
} else {
$tpl->setCurrentBlock("reference");
if (!$options) {
$tpl->setVariable("CONTENT", $ref_record->getRecordFieldHTML($this->getField()->getFieldRef()));
} else {
$tpl->setVariable("CONTENT", $this->getLinkHTML($options['link']['name'], $value));
}
$tpl->parseCurrentBlock();
}
}
$tpl->parseCurrentBlock();
return $tpl;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilDataCollectionNReferenceField::doUpdate ( )

Update object in database.

Reimplemented from ilDataCollectionRecordField.

Definition at line 17 of file class.ilDataCollectionNReferenceField.php.

References $ilDB, $query, ilDataCollectionRecordField\$value, and ilDataCollectionRecordField\getValue().

{
global $ilDB;
$values = $this->getValue();
if (!is_array($values)) {
$values = array( $values );
}
$datatype = $this->field->getDatatype();
$query = "DELETE FROM il_dcl_stloc" . $datatype->getStorageLocation() . "_value WHERE record_field_id = "
. $ilDB->quote($this->id, "integer");
$ilDB->manipulate($query);
if (!count($values) || $values[0] == 0) {
return;
}
$query = "INSERT INTO il_dcl_stloc" . $datatype->getStorageLocation() . "_value (value, record_field_id, id) VALUES";
foreach ($values as $value) {
$next_id = $ilDB->nextId("il_dcl_stloc" . $datatype->getStorageLocation() . "_value");
$query .= " (" . $ilDB->quote($value, $datatype->getDbType()) . ", " . $ilDB->quote($this->getId(), "integer") . ", "
. $ilDB->quote($next_id, "integer") . "),";
}
$query = substr($query, 0, - 1);
$ilDB->manipulate($query);
}

+ Here is the call graph for this function:

ilDataCollectionNReferenceField::getExportValue ( )
Returns
int|string

Reimplemented from ilDataCollectionReferenceField.

Definition at line 194 of file class.ilDataCollectionNReferenceField.php.

References ilDataCollectionRecordField\$value, ilDataCollectionRecordField\getField(), ilDataCollectionCache\getRecordCache(), and ilDataCollectionRecordField\getValue().

{
$values = $this->getValue();
$names = array();
foreach ($values as $value) {
if ($value) {
$names[] = $ref_rec->getRecordField($this->getField()->getFieldRef())->getValue();
}
}
$string = "";
foreach ($names as $name) {
$string .= $name . ", ";
}
if (!count($names)) {
return "";
}
$string = substr($string, 0, - 2);
return $string;
}

+ Here is the call graph for this function:

ilDataCollectionNReferenceField::getHTML ( )
Returns
array|mixed|string

Definition at line 131 of file class.ilDataCollectionNReferenceField.php.

References $tpl, ilDataCollectionRecordField\$value, ilDataCollectionRecordField\getId(), ilDataCollectionRecordField\getRecord(), ilDataCollectionCache\getRecordCache(), ilDataCollectionRecordField\getValue(), ilDataCollectionDatatype\INPUTFORMAT_DATETIME, ilDataCollectionDatatype\INPUTFORMAT_NUMBER, and ilUtil\sortArray().

{
$values = $this->getValue();
$record_field = $this;
if (!$values OR !count($values)) {
return "";
}
$html = "";
$cut = false;
$tpl = new ilTemplate("tpl.reference_hover.html", true, true, "Modules/DataCollection");
$tpl->setCurrentBlock("reference_list");
$elements = array();
foreach ($values as $value) {
if (!$ref_record->getTableId() OR !$record_field->getField() OR !$record_field->getField()->getTableId()) {
//the referenced record_field does not seem to exist.
$record_field->setValue(NULL);
$record_field->doUpdate();
} else {
$elements[] = array('value' => $ref_record->getRecordFieldHTML($this->getField()->getFieldRef()),
'sort' => $ref_record->getRecordFieldSortingValue($this->getField()->getFieldRef()));
}
}
//sort fetched elements
$is_numeric = false;
$ref_field = new ilDataCollectionField($record_field->getField()->getFieldRef());
switch ($ref_field->getDatatypeId()) {
$is_numeric = true;
break;
}
$elements = ilUtil::sortArray($elements, 'sort', 'asc', $is_numeric);
//concat
foreach($elements as $element) {
if ((strlen($html) < $this->max_reference_length)) {
$html .= $element['value'] . ", ";
} else {
$cut = true;
}
$tpl->setCurrentBlock("reference");
$tpl->setVariable("CONTENT", $element['value']);
$tpl->parseCurrentBlock();
}
$html = substr($html, 0, - 2);
if ($cut) {
$html .= "...";
}
$tpl->setVariable("RECORD_ID", $this->getRecord()->getId());
$tpl->setVariable("ALL", $html);
$tpl->parseCurrentBlock();
return $tpl->get();
}

+ Here is the call graph for this function:

ilDataCollectionNReferenceField::getLinkHTML (   $link,
  $value 
)
protected
Parameters
null$link
$value
Returns
string

Reimplemented from ilDataCollectionReferenceField.

Definition at line 119 of file class.ilDataCollectionNReferenceField.php.

References ilDataCollectionRecordField\$value, and ilDataCollectionRecordField\getField().

Referenced by buildTemplate().

{
if ($link == "[" . $this->getField()->getTitle() . "]") {
$link = NULL;
}
return parent::getLinkHTML($link, $value);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilDataCollectionNReferenceField::getSingleHTML (   $options = NULL)

this funciton is used to in the viewdefinition of a single record.

Returns
mixed

Definition at line 65 of file class.ilDataCollectionNReferenceField.php.

References $options, $tpl, buildTemplate(), and ilDataCollectionRecordField\getValue().

{
// if we are in a record view and the n-ref should be displayed as a link to it's reference
$values = $this->getValue();
$record_field = $this;
if (!$values || !count($values)) {
return "";
}
$tpl = $this->buildTemplate($record_field, $values, $options);
return $tpl->get();
}

+ Here is the call graph for this function:

ilDataCollectionNReferenceField::loadValue ( )
protected

Load the value.

Reimplemented from ilDataCollectionRecordField.

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

References $ilDB, and $query.

{
if ($this->value === NULL) {
global $ilDB;
$datatype = $this->field->getDatatype();
$query = "SELECT * FROM il_dcl_stloc" . $datatype->getStorageLocation() . "_value WHERE record_field_id = "
. $ilDB->quote($this->id, "integer");
$set = $ilDB->query($query);
$this->value = array();
while ($rec = $ilDB->fetchAssoc($set)) {
$this->value[] = $rec['value'];
}
}
}

Field Documentation

ilDataCollectionNReferenceField::$max_reference_length = 20
protected

Definition at line 14 of file class.ilDataCollectionNReferenceField.php.


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