ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules 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. More...
 
 buildTemplate ($record_field, $values, $options)
 
 getHTML (array $options=array())
 
 getExportValue ()
 
- Public Member Functions inherited from ilDataCollectionReferenceField
 __construct (ilDataCollectionRecord $record, ilDataCollectionField $field)
 
 getHTML (array $options=array())
 
 getExportValue ()
 
- Public Member Functions inherited from ilDataCollectionRecordField
 __construct (ilDataCollectionRecord $record, ilDataCollectionField $field)
 
 doUpdate ()
 
 delete ()
 
 getValue ()
 
 setValue ($value)
 
 getFormInput ()
 
 getExportValue ()
 
 getPlainText ()
 
 getHTML ()
 
 getSingleHTML ($link=null)
 this funciton is used to in the viewdefinition of a single record. More...
 
 getField ()
 
 getId ()
 
 getRecord ()
 

Protected Member Functions

 loadValue ()
 
 getLinkHTML ($link, $value)
 
- Protected Member Functions inherited from ilDataCollectionReferenceField
 getLinkHTML ($link_name=NULL, $value)
 
- Protected Member Functions inherited from ilDataCollectionRecordField
 loadValue ()
 

Private Attributes

 $max_reference_length = 20
 

Additional Inherited Members

- Protected Attributes inherited from ilDataCollectionReferenceField
 $dcl_obj_id
 
- Protected Attributes inherited from ilDataCollectionRecordField
 $id
 
 $field
 
 $record
 
 $value
 

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

◆ buildTemplate()

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

75  {
76  $tpl = new ilTemplate("tpl.reference_list.html", true, true, "Modules/DataCollection");
77  $tpl->setCurrentBlock("reference_list");
78  foreach ($values as $value) {
79  $ref_record = ilDataCollectionCache::getRecordCache($value);
80  if (!$ref_record->getTableId() || !$record_field->getField() || !$record_field->getField()->getTableId()) {
81  //the referenced record_field does not seem to exist.
82  $record_field->setValue(0);
83  $record_field->doUpdate();
84  } else {
85  $tpl->setCurrentBlock("reference");
86  if (!$options)
87  $tpl->setVariable("CONTENT", $ref_record->getRecordFieldHTML($this->getField()->getFieldRef()));
88  else
89  $tpl->setVariable("CONTENT", $this->getLinkHTML($options['link']['name'], $value));
90  $tpl->parseCurrentBlock();
91  }
92  }
93  $tpl->parseCurrentBlock();
94  return $tpl;
95  }
static getRecordCache($record_id=0)
if(!is_array($argv)) $options
special template class to simplify handling of ITX/PEAR
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doUpdate()

ilDataCollectionNReferenceField::doUpdate ( )

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

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

16  {
17  global $ilDB;
18 
19  $values = $this->getValue();
20  if(!is_array($values))
21  $values = array($values);
22  $datatype = $this->field->getDatatype();
23 
24  $query = "DELETE FROM il_dcl_stloc".$datatype->getStorageLocation()."_value WHERE record_field_id = ".$ilDB->quote($this->id, "integer");
25  $ilDB->manipulate($query);
26 
27  if(!count($values)|| $values[0] == 0)
28  return;
29 
30  $query = "INSERT INTO il_dcl_stloc".$datatype->getStorageLocation()."_value (value, record_field_id, id) VALUES";
31  foreach($values as $value){
32  $next_id = $ilDB->nextId("il_dcl_stloc".$datatype->getStorageLocation()."_value");
33  $query .= " (".$ilDB->quote($value, $datatype->getDbType()).", ".$ilDB->quote($this->getId(), "integer").", ".$ilDB->quote($next_id, "integer")."),";
34  }
35  $query = substr($query, 0, -1);
36  $ilDB->manipulate($query);
37  }
+ Here is the call graph for this function:

◆ getExportValue()

ilDataCollectionNReferenceField::getExportValue ( )

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

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

154  {
155  $values = $this->getValue();
156  $names = array();
157  foreach($values as $value){
158  if($value){
159  $ref_rec = ilDataCollectionCache::getRecordCache($value);
160  $names[] = $ref_rec->getRecordField($this->getField()->getFieldRef())->getValue();
161  }
162  }
163  $string = "";
164  foreach($names as $name){
165  $string.=$name.", ";
166  }
167  if(!count($names))
168  return "";
169  $string = substr($string, 0, -2);
170  return $string;
171  }
static getRecordCache($record_id=0)
+ Here is the call graph for this function:

◆ getHTML()

ilDataCollectionNReferenceField::getHTML ( array  $options = array())

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

110  {
111  global $ilCtrl;
112 
113  $values = $this->getValue();
114  $record_field = $this;
115 
116  if(!$values || !count($values)){
117  return "";
118  }
119 
120  $html = "";
121  $tpl = new ilTemplate("tpl.reference_hover.html",true, true, "Modules/DataCollection");
122  $tpl->setCurrentBlock("reference_list");
123  foreach($values as $value){
124  $ref_record = ilDataCollectionCache::getRecordCache($value);
125  if(!$ref_record->getTableId() || !$record_field->getField() || !$record_field->getField()->getTableId()){
126  //the referenced record_field does not seem to exist.
127  $record_field->setValue(NULL);
128  $record_field->doUpdate();
129  }else{
130  if((strlen($html) < $this->max_reference_length))
131  $html .= $ref_record->getRecordFieldHTML($this->getField()->getFieldRef()).", ";
132  else
133  $cut = true;
134  $tpl->setCurrentBlock("reference");
135  $tpl->setVariable("CONTENT", $ref_record->getRecordFieldHTML($this->getField()->getFieldRef()));
136  $tpl->parseCurrentBlock();
137  }
138  }
139  $html = substr($html, 0, -2);
140  if($cut){
141  $html .= "...";
142  }
143  $tpl->setVariable("RECORD_ID", $this->getRecord()->getId());
144  $tpl->setVariable("ALL", $html);
145  $tpl->parseCurrentBlock();
146 
147  return $tpl->get();
148  }
static getRecordCache($record_id=0)
global $ilCtrl
Definition: ilias.php:18
special template class to simplify handling of ITX/PEAR
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
+ Here is the call graph for this function:

◆ getLinkHTML()

ilDataCollectionNReferenceField::getLinkHTML (   $link,
  $value 
)
protected

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

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

Referenced by buildTemplate().

97  {
98  if($link == "[".$this->getField()->getTitle()."]"){
99  $link = null;
100  }
101  return parent::getLinkHTML($link, $value);
102  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSingleHTML()

ilDataCollectionNReferenceField::getSingleHTML (   $options = NULL)

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

Returns
mixed

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

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

59  {
60 
61  // if we are in a record view and the n-ref should be displayed as a link to it's reference
62  $values = $this->getValue();
63  $record_field = $this;
64 
65  if(!$values || !count($values)){
66  return "";
67  }
68 
69  $tpl = $this->buildTemplate($record_field, $values, $options);
70 
71  return $tpl->get();
72  }
if(!is_array($argv)) $options
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
+ Here is the call graph for this function:

◆ loadValue()

ilDataCollectionNReferenceField::loadValue ( )
protected

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

References $query.

43  {
44  if($this->value === NULL)
45  {
46  global $ilDB;
47  $datatype = $this->field->getDatatype();
48  $query = "SELECT * FROM il_dcl_stloc".$datatype->getStorageLocation()."_value WHERE record_field_id = ".$ilDB->quote($this->id, "integer");
49  $set = $ilDB->query($query);
50  while($rec = $ilDB->fetchAssoc($set))
51  $this->value[] = $rec['value'];
52  }
53  }

Field Documentation

◆ $max_reference_length

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: