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

Created by JetBrains PhpStorm. More...

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

Public Member Functions

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

Protected Member Functions

 loadValue ()
 getLinkHTML ($link, $value)

Private Attributes

 $max_reference_length = 20

Additional Inherited Members

- Protected Attributes inherited from ilDataCollectionReferenceField
 $dcl_obj_id

Detailed Description

Created by JetBrains PhpStorm.

Author
: Oskar Truffer ot@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch Date: 21/02/13 Time: 3:16 PM To change this template use File | Settings | File Templates.

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

Member Function Documentation

ilDataCollectionNReferenceField::buildTemplate (   $record_field,
  $values,
  $options 
)

Definition at line 74 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 ( )

Reimplemented from ilDataCollectionRecordField.

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

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

Reimplemented from ilDataCollectionReferenceField.

Definition at line 153 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 ( array  $options = array())

Reimplemented from ilDataCollectionReferenceField.

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

References $ilCtrl, $tpl, ilDataCollectionRecordField\$value, ilDataCollectionRecordField\getField(), ilDataCollectionRecordField\getId(), ilDataCollectionRecordField\getRecord(), ilDataCollectionCache\getRecordCache(), and ilDataCollectionRecordField\getValue().

{
global $ilCtrl;
$values = $this->getValue();
$record_field = $this;
if(!$values || !count($values)){
return "";
}
$html = "";
$tpl = new ilTemplate("tpl.reference_hover.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(NULL);
$record_field->doUpdate();
}else{
if((strlen($html) < $this->max_reference_length))
$html .= $ref_record->getRecordFieldHTML($this->getField()->getFieldRef()).", ";
else
$cut = true;
$tpl->setCurrentBlock("reference");
$tpl->setVariable("CONTENT", $ref_record->getRecordFieldHTML($this->getField()->getFieldRef()));
$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

Reimplemented from ilDataCollectionReferenceField.

Definition at line 97 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

Reimplemented from ilDataCollectionRecordField.

Definition at line 59 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

Reimplemented from ilDataCollectionRecordField.

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

References $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);
while($rec = $ilDB->fetchAssoc($set))
$this->value[] = $rec['value'];
}
}

Field Documentation

ilDataCollectionNReferenceField::$max_reference_length = 20
private

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


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