ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilDataCollectionDatatype Class Reference

Class ilDataCollectionDatatype. More...

+ Collaboration diagram for ilDataCollectionDatatype:

Public Member Functions

 __construct ($a_id=0)
 Constructor. More...
 
 getId ()
 Get field id. More...
 
 setTitle ($a_title)
 Set title. More...
 
 getTitle ()
 Get title. More...
 
 setStorageLocation ($a_id)
 Set Storage Location. More...
 
 getStorageLocation ()
 Get Storage Location. More...
 
 getDbType ()
 
 doRead ()
 Read Datatype. More...
 
 parseValue ($value, ilDataCollectionRecordField $record_field)
 Function to parse incoming data from form input value $value. More...
 
 parseExportValue ($value)
 Function to parse incoming data from form input value $value. More...
 
 parseSortingValue ($value, ilDataCollectionRecordField $record_field, $link=true)
 
 parseHTML ($value, ilDataCollectionRecordField $record_field, $link=true)
 function parses stored value in database to a html output for eg. More...
 
 parseFormInput ($value, ilDataCollectionRecordField $record_field)
 function parses stored value to the variable needed to fill into the form for editing. More...
 

Static Public Member Functions

static getAllDatatypes ()
 Get all possible Datatypes. More...
 
static getProperties ($a_id)
 Get all properties of a Datatype. More...
 
static checkValidity ($type_id, $value)
 now only distinguishes between number and text values More...
 
static getInputField (ilDataCollectionField $field)
 
static addFilterInputFieldToTable (ilDataCollectionField $field, ilTable2GUI &$table)
 addFilterInputFieldToTable This function adds the according filter item to the table gui passed as argument. More...
 
static passThroughFilter (ilDataCollectionRecord $record, ilDataCollectionField $field, $filter)
 

Data Fields

const INPUTFORMAT_NONE = 0
 
const INPUTFORMAT_NUMBER = 1
 
const INPUTFORMAT_TEXT = 2
 
const INPUTFORMAT_REFERENCE = 3
 
const INPUTFORMAT_BOOLEAN = 4
 
const INPUTFORMAT_DATETIME = 5
 
const INPUTFORMAT_FILE = 6
 
const INPUTFORMAT_RATING = 7
 
const INPUTFORMAT_ILIAS_REF = 8
 
const INPUTFORMAT_MOB = 9
 
const INPUTFORMAT_REFERENCELIST = 10
 
const INPUTFORMAT_FORMULA = 11
 
const INPUTFORMAT_NON_EDITABLE_VALUE = 12
 
const LINK_MAX_LENGTH = 40
 

Static Public Attributes

static $mob_suffixes = array('jpg', 'jpeg', 'gif', 'png', 'mp3', 'flx', 'mp4', 'm4v', 'mov', 'wmv')
 

Protected Member Functions

 formatDate ($value, $format)
 

Protected Attributes

 $id
 
 $title
 
 $storageLocation
 
 $dbType
 

Private Member Functions

 shortenLink ($value)
 This method shortens a link. More...
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilDataCollectionDatatype::__construct (   $a_id = 0)

Constructor.

@access public

Parameters
integerdatatype_id

Definition at line 75 of file class.ilDataCollectionDatatype.php.

75 {
76 if ($a_id != 0) {
77 $this->id = $a_id;
78 $this->doRead();
79 }
80 }

References doRead().

+ Here is the call graph for this function:

Member Function Documentation

◆ addFilterInputFieldToTable()

static ilDataCollectionDatatype::addFilterInputFieldToTable ( ilDataCollectionField  $field,
ilTable2GUI $table 
)
static

addFilterInputFieldToTable This function adds the according filter item to the table gui passed as argument.

Parameters
$fieldilDataCollectionField The field which should be filterable.
&$tableilTable2GUI The table you want the filter to be added to.
Returns
null|object

Definition at line 307 of file class.ilDataCollectionDatatype.php.

307 {
308 global $lng;
309
310 $type_id = $field->getDatatypeId();
311 $input = NULL;
312
313 switch ($type_id) {
315 $input = $table->addFilterItemByMetaType("filter_" . $field->getId(), ilTable2GUI::FILTER_TEXT, false, $field->getId());
316 $input->setSubmitFormOnEnter(true);
317 break;
319 $input = $table->addFilterItemByMetaType("filter_" . $field->getId(), ilTable2GUI::FILTER_NUMBER_RANGE, false, $field->getId());
320 $input->setSubmitFormOnEnter(true);
321 break;
323 $input = $table->addFilterItemByMetaType("filter_" . $field->getId(), ilTable2GUI::FILTER_SELECT, false, $field->getId());
324 $input->setOptions(array(
325 "" => $lng->txt("dcl_any"),
326 "not_checked" => $lng->txt("dcl_not_checked"),
327 "checked" => $lng->txt("dcl_checked")
328 ));
329 break;
331 $input = $table->addFilterItemByMetaType("filter_" . $field->getId(), ilTable2GUI::FILTER_DATE_RANGE, false, $field->getId());
332 $input->setSubmitFormOnEnter(true);
333 $input->setStartYear(date("Y") - 100);
334 break;
336 $input = $table->addFilterItemByMetaType("filter_" . $field->getId(), ilTable2GUI::FILTER_TEXT, false, $field->getId());
337 $input->setSubmitFormOnEnter(true);
338 break;
340 $input = $table->addFilterItemByMetaType("filter_" . $field->getId(), ilTable2GUI::FILTER_SELECT, false, $field->getId());
341 $ref_field_id = $field->getFieldRef();
342 $ref_field = ilDataCollectionCache::getFieldCache($ref_field_id);
343 $ref_table = ilDataCollectionCache::getTableCache($ref_field->getTableId());
344 $options = array();
345 foreach ($ref_table->getRecords() as $record) {
346 $options[$record->getId()] = $record->getRecordFieldValue($ref_field_id);
347 }
348 // Sort by values ASC
349 asort($options);
350 $options = array('' => $lng->txt('dcl_any')) + $options;
351 $input->setOptions($options);
352 break;
354 $input = $table->addFilterItemByMetaType("filter_" . $field->getId(), ilTable2GUI::FILTER_SELECT, false, $field->getId());
355 $options = array("" => $lng->txt("dcl_any"), 1 => ">1", 2 => ">2", 3 => ">3", 4 => ">4", 5 => "5");
356 $input->setOptions($options);
357 break;
359 $input = $table->addFilterItemByMetaType("filter_" . $field->getId(), ilTable2GUI::FILTER_TEXT, false, $field->getId());
360 $input->setSubmitFormOnEnter(true);
361 break;
363 $input = $table->addFilterItemByMetaType("filter_" . $field->getId(), ilTable2GUI::FILTER_TEXT, false, $field->getId());
364 $input->setSubmitFormOnEnter(true);
365 break;
367 //FIXME
368 $input = $table->addFilterItemByMetaType("filter_" . $field->getId(), ilTable2GUI::FILTER_SELECT, false, $field->getId());
369 $ref_field_id = $field->getFieldRef();
370 $ref_field = ilDataCollectionCache::getFieldCache($ref_field_id);
371 $ref_table = ilDataCollectionCache::getTableCache($ref_field->getTableId());
372 $options = array();
373 foreach ($ref_table->getRecords() as $record) {
374 $options[$record->getId()] = $record->getRecordFieldValue($ref_field_id);
375 }
376 // Sort by values ASC
377 asort($options);
378 $options = array('' => $lng->txt('dcl_any')) + $options;
379 $input->setOptions($options);
380 break;
381 }
382
383 if ($input != NULL) {
384 $input->setTitle($field->getTitle());
385 }
386
387 return $input;
388 }
addFilterItemByMetaType($id, $type=self::FILTER_TEXT, $a_optional=false, $caption=NULL)
Add filter by standard type.
const FILTER_NUMBER_RANGE
global $lng
Definition: privfeed.php:40
if(!is_array($argv)) $options

References $lng, $options, ilTable2GUI\addFilterItemByMetaType(), ilTable2GUI\FILTER_DATE_RANGE, ilTable2GUI\FILTER_NUMBER_RANGE, ilTable2GUI\FILTER_SELECT, ilTable2GUI\FILTER_TEXT, ilDataCollectionField\getDatatypeId(), ilDataCollectionCache\getFieldCache(), ilDataCollectionField\getFieldRef(), ilDataCollectionField\getId(), ilDataCollectionCache\getTableCache(), ilDataCollectionField\getTitle(), INPUTFORMAT_BOOLEAN, INPUTFORMAT_DATETIME, INPUTFORMAT_FILE, INPUTFORMAT_ILIAS_REF, INPUTFORMAT_MOB, INPUTFORMAT_NUMBER, INPUTFORMAT_RATING, INPUTFORMAT_REFERENCE, INPUTFORMAT_REFERENCELIST, and INPUTFORMAT_TEXT.

Referenced by ilDataCollectionRecordListTableGUI\initFilter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkValidity()

static ilDataCollectionDatatype::checkValidity (   $type_id,
  $value 
)
static

now only distinguishes between number and text values

Parameters
$type_idint
$valuemixed
Returns
bool

Definition at line 208 of file class.ilDataCollectionDatatype.php.

208 {
209 //required is checked by form. so null input is valid.
210 if ($value == NULL) {
211 return true;
212 }
213
214 switch ($type_id) {
216 $return = is_numeric($value);
217 break;
218 default:
219 $return = true;
220 break;
221 }
222
223 return $return;
224 }

References INPUTFORMAT_NUMBER.

Referenced by ilDataCollectionField\checkValidity().

+ Here is the caller graph for this function:

◆ doRead()

ilDataCollectionDatatype::doRead ( )

Read Datatype.

Definition at line 144 of file class.ilDataCollectionDatatype.php.

144 {
145 global $ilDB;
146
147 $query = "SELECT * FROM il_dcl_datatype WHERE id = " . $ilDB->quote($this->getId(), "integer") . " ORDER BY sort";
148 $set = $ilDB->query($query);
149 $rec = $ilDB->fetchAssoc($set);
150
151 $this->setTitle($rec["title"]);
152 $this->dbType = $rec["ildb_type"];
153 $this->setStorageLocation($rec["storage_location"]);
154 }
setStorageLocation($a_id)
Set Storage Location.
global $ilDB

References $ilDB, $query, getId(), setStorageLocation(), and setTitle().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ formatDate()

ilDataCollectionDatatype::formatDate (   $value,
  $format 
)
protected
Parameters
$value
$format
Returns
false|string

Definition at line 691 of file class.ilDataCollectionDatatype.php.

691 {
692 if ($value == '0000-00-00 00:00:00' OR !$value) {
693 return '';
694 }
695 $timestamp = strtotime($value);
696 switch($format)
697 {
699 return date("d.m.Y", $timestamp);
701 return date("Y-m-d", $timestamp);
703 return date("m/d/Y", $timestamp);
704 }
705 return '';
706 }
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:81

References $timestamp, ilCalendarSettings\DATE_FORMAT_DMY, ilCalendarSettings\DATE_FORMAT_MDY, and ilCalendarSettings\DATE_FORMAT_YMD.

Referenced by parseHTML().

+ Here is the caller graph for this function:

◆ getAllDatatypes()

static ilDataCollectionDatatype::getAllDatatypes ( )
static

Get all possible Datatypes.

Returns
array

Definition at line 162 of file class.ilDataCollectionDatatype.php.

162 {
163 global $ilDB;
164
165 $query = "SELECT * FROM il_dcl_datatype ORDER BY sort";
166 $set = $ilDB->query($query);
167
168 $all = array();
169 while ($rec = $ilDB->fetchAssoc($set)) {
170 $all[$rec[id]] = $rec;
171 }
172
173 return $all;
174 }

References $ilDB, and $query.

Referenced by ilDataCollectionFieldEditGUI\getValues(), and ilDataCollectionFieldEditGUI\initForm().

+ Here is the caller graph for this function:

◆ getDbType()

ilDataCollectionDatatype::getDbType ( )

Definition at line 136 of file class.ilDataCollectionDatatype.php.

References $dbType.

◆ getId()

ilDataCollectionDatatype::getId ( )

Get field id.

Returns
int

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

References $id.

Referenced by doRead().

+ Here is the caller graph for this function:

◆ getInputField()

static ilDataCollectionDatatype::getInputField ( ilDataCollectionField  $field)
static
Parameters
ilDataCollectionField$field
Returns
ilCheckboxInputGUI|ilDateTimeInputGUI|ilFileInputGUI|ilTextInputGUI|NULL

Definition at line 232 of file class.ilDataCollectionDatatype.php.

232 {
233 global $lng;
234 $type_id = $field->getDatatypeId();
235 $title = $field->getTitle();
236 $input = NULL;
237 switch ($type_id) {
239 $input = new ilTextInputGUI($title, 'field_' . $field->getId());
240 if ($field->getTextArea()) {
241 $input = new ilTextAreaInputGUI($title, 'field_' . $field->getId());
242 }
243 if ($field->getLength()) {
244 $input->setInfo($lng->txt("dcl_max_text_length") . ": " . $field->getLength());
245 if (!$field->getTextArea()) {
246 $input->setMaxLength($field->getLength());
247 }
248 }
249 break;
251 $input = new ilNumberInputGUI($title, 'field_' . $field->getId());
252 break;
254 $input = new ilDclCheckboxInputGUI($title, 'field_' . $field->getId());
255 break;
257 $input = new ilDateTimeInputGUI($title, 'field_' . $field->getId());
258 $input->setMode(ilDateTimeInputGUI::MODE_INPUT);
259 $input->setStartYear(date("Y") - 100);
260 break;
262 $input = new ilFileInputGUI($title, 'field_' . $field->getId());
263 break;
265 if (!$field->isNRef()) {
266 $input = new ilSelectInputGUI($title, 'field_' . $field->getId());
267 } else {
268 $input = new ilMultiSelectInputGUI($title, 'field_' . $field->getId());
269 $input->setWidth(100);
270 $input->setWidthUnit('%');
271 }
272 break;
274 $input = new ilTextInputGUI($title, 'field_' . $field->getId());
275 $input->setValue($lng->txt("dcl_editable_in_table_gui"));
276 $input->setDisabled(true);
277 break;
279 $input = new ilDataCollectionTreePickInputGUI($title, 'field_' . $field->getId());
280 break;
282 $input = new ilFileInputGUI($title, 'field_' . $field->getId());
283 $input->setSuffixes(self::$mob_suffixes);
284 $input->setAllowDeletion(true);
285 break;
287 $input = new ilNonEditableValueGUI($title, 'field_' . $field->getId());
288 $input->setValue('-');
289 break;
290 }
291 if ($field->getDescription() && $input !== NULL) {
292 $input->setInfo($field->getDescription() . ($input->getInfo() ? "<br>" . $input->getInfo() : ""));
293 }
294
295 return $input;
296 }
This class represents a date/time property in a property form.
Class ilDclCheckboxInputGUI.
This class represents a file property in a property form.
This class represents a multi selection list property in a property form.
This class represents a non editable value in a property form.
This class represents a number property in a property form.
This class represents a selection list property in a property form.
This class represents a text area property in a property form.
This class represents a text property in a property form.

References $lng, $title, ilDataCollectionField\getDatatypeId(), ilDataCollectionField\getDescription(), ilDataCollectionField\getId(), ilDataCollectionField\getLength(), ilDataCollectionField\getTextArea(), ilDataCollectionField\getTitle(), INPUTFORMAT_BOOLEAN, INPUTFORMAT_DATETIME, INPUTFORMAT_FILE, INPUTFORMAT_FORMULA, INPUTFORMAT_ILIAS_REF, INPUTFORMAT_MOB, INPUTFORMAT_NUMBER, INPUTFORMAT_RATING, INPUTFORMAT_REFERENCE, INPUTFORMAT_TEXT, ilDataCollectionField\isNRef(), and ilDateTimeInputGUI\MODE_INPUT.

Referenced by ilDataCollectionRecordEditGUI\initForm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getProperties()

static ilDataCollectionDatatype::getProperties (   $a_id)
static

Get all properties of a Datatype.

Parameters
int$a_iddatatype_id
Returns
array

Definition at line 184 of file class.ilDataCollectionDatatype.php.

184 {
185 global $ilDB;
186
187 $query = "SELECT * FROM il_dcl_datatype_prop
188 WHERE datatype_id = " . $ilDB->quote($a_id, "integer");
189 $set = $ilDB->query($query);
190
191 $all = array();
192 while ($rec = $ilDB->fetchAssoc($set)) {
193 $all[] = $rec;
194 }
195
196 return $all;
197 }

References $ilDB, and $query.

Referenced by ilDataCollectionFieldEditGUI\getValues(), ilDataCollectionFieldEditGUI\initForm(), and ilDataCollectionFieldEditGUI\save().

+ Here is the caller graph for this function:

◆ getStorageLocation()

ilDataCollectionDatatype::getStorageLocation ( )

Get Storage Location.

Returns
int

Definition at line 128 of file class.ilDataCollectionDatatype.php.

References $storageLocation.

◆ getTitle()

ilDataCollectionDatatype::getTitle ( )

Get title.

Returns
string

Definition at line 108 of file class.ilDataCollectionDatatype.php.

108 {
109 return $this->title;
110 }

References $title.

◆ parseExportValue()

ilDataCollectionDatatype::parseExportValue (   $value)

Function to parse incoming data from form input value $value.

returns the strin/number/etc. to store in the database.

Parameters
$value
Returns
int|string

Definition at line 611 of file class.ilDataCollectionDatatype.php.

611 {
612 $return = false;
613
615 if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "file") {
616 return;
617 }
618
619 $file = $value;
620 if ($file != "-") {
621 $file_obj = new ilObjFile($file, false);
622 $file_name = $file_obj->getFileName();
623
624 $return = $file_name;
625 } else {
626 $return = $file;
627 }
628 } elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_MOB) {
629 $file = $value;
630 if ($file != "-") {
631 $mob = new ilObjMediaObject($file, false);
632 $mob_name = $mob->getTitle();
633
634 $return = $mob_name;
635 } else {
636 $return = $file;
637 }
638 } elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_DATETIME) {
639 $return = substr($value, 0, 10);
640 } elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_BOOLEAN) {
641 $return = $value ? 1 : 0;
642 } else {
643 $return = $value;
644 }
645
646 return $return;
647 }
print $file
Class ilObjFile.
Class ilObjMediaObject.
static _exists($a_id, $a_reference=false)
static _lookupType($a_id, $a_reference=false)
lookup object type

References $file, ilObject2\_exists(), ilObject2\_lookupType(), INPUTFORMAT_BOOLEAN, INPUTFORMAT_DATETIME, INPUTFORMAT_FILE, and INPUTFORMAT_MOB.

+ Here is the call graph for this function:

◆ parseFormInput()

ilDataCollectionDatatype::parseFormInput (   $value,
ilDataCollectionRecordField  $record_field 
)

function parses stored value to the variable needed to fill into the form for editing.

Parameters
$value
Returns
mixed

Definition at line 882 of file class.ilDataCollectionDatatype.php.

882 {
883 switch ($this->id) {
885 if (!$value || $value == "-") {
886 return NULL;
887 }
888 //$datetime = new DateTime();
889 $input = array(
890 "date" => substr($value, 0, -9),
891 "time" => "00:00:00"
892 );
893 break;
895
896 if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "file") {
897 $input = "";
898 break;
899 }
900
901 $file_obj = new ilObjFile($value, false);
902 //$input = ilObjFile::_lookupAbsolutePath($value);
903 $input = $file_obj->getFileName();
904 break;
906 if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "mob") {
907 $input = "";
908 break;
909 }
910
911 $media_obj = new ilObjMediaObject($value, false);
912 //$input = ilObjFile::_lookupAbsolutePath($value);
913 $input = $value;
914 break;
916 $arr_properties = $record_field->getField()->getProperties();
917 if ($arr_properties[ilDataCollectionField::PROPERTYID_TEXTAREA]) {
918 $breaks = array( "<br />" );
919 $input = str_ireplace($breaks, "", $value);
920 } else {
921 $input = $value;
922 }
923 break;
924 default:
925 $input = $value;
926 break;
927 }
928
929 return $input;
930 }

References ilObject2\_exists(), ilObject2\_lookupType(), ilDataCollectionRecordField\getField(), INPUTFORMAT_DATETIME, INPUTFORMAT_FILE, INPUTFORMAT_MOB, INPUTFORMAT_TEXT, and ilDataCollectionField\PROPERTYID_TEXTAREA.

+ Here is the call graph for this function:

◆ parseHTML()

ilDataCollectionDatatype::parseHTML (   $value,
ilDataCollectionRecordField  $record_field,
  $link = true 
)

function parses stored value in database to a html output for eg.

the record list gui.

Parameters
$value
ilDataCollectionRecordField$record_field
Returns
mixed

Definition at line 717 of file class.ilDataCollectionDatatype.php.

717 {
718 global $ilAccess, $ilCtrl, $lng, $ilUser;
719
720 switch ($this->id) {
722 $html = $this->formatDate($value, $ilUser->getDateFormat());
723 break;
724
726
727 if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "file") {
728 $html = "";
729 break;
730 }
731
732 $file_obj = new ilObjFile($value, false);
733 $ilCtrl->setParameterByClass("ildatacollectionrecordlistgui", "record_id", $record_field->getRecord()->getId());
734 $ilCtrl->setParameterByClass("ildatacollectionrecordlistgui", "field_id", $record_field->getField()->getId());
735
736 $html = '<a href="' . $ilCtrl->getLinkTargetByClass("ildatacollectionrecordlistgui", "sendFile") . '">' . $file_obj->getFileName()
737 . '</a>';
738 if (ilPreview::hasPreview($file_obj->getId())) {
739 ilPreview::createPreview($file_obj); // Create preview if not already existing
740 $preview = new ilPreviewGUI((int)$_GET['ref_id'], ilPreviewGUI::CONTEXT_REPOSITORY, $file_obj->getId(), $ilAccess);
741 $preview_status = ilPreview::lookupRenderStatus($file_obj->getId());
742 $preview_status_class = "";
743 $preview_text_topic = "preview_show";
744 if ($preview_status == ilPreview::RENDER_STATUS_NONE) {
745 $preview_status_class = "ilPreviewStatusNone";
746 $preview_text_topic = "preview_none";
747 }
748 $wrapper_html_id = 'record_field_' . $record_field->getId();
749 $script_preview_click = $preview->getJSCall($wrapper_html_id);
750 $preview_title = $lng->txt($preview_text_topic);
751 $preview_icon = ilUtil::getImagePath("preview.png", "Services/Preview");
752 $html = '<div id="' . $wrapper_html_id . '">' . $html;
753 $html .= '<span class="il_ContainerItemPreview ' . $preview_status_class . '"><a href="javascript:void(0);" onclick="'
754 . $script_preview_click . '" title="' . $preview_title . '"><img src="' . $preview_icon
755 . '" height="16" width="16"></a></span></div>';
756 }
757 break;
758
760
761 $mob = new ilObjMediaObject($value, false);
762 $med = $mob->getMediaItem('Standard');
763 if (!$med->location) {
764 $html = "";
765 break;
766 }
767 $arr_properties = $record_field->getField()->getProperties();
768 $is_linked_field = $arr_properties[ilDataCollectionField::PROPERTYID_LINK_DETAIL_PAGE_MOB];
769 $has_view = ilDataCollectionRecordViewViewdefinition::getIdByTableId($record_field->getRecord()->getTableId());
770 if (in_array($med->getSuffix(), array('jpg', 'jpeg', 'png', 'gif'))) {
771 // Image
772 $dir = ilObjMediaObject::_getDirectory($mob->getId());
773 $width = (int)$arr_properties[ilDataCollectionField::PROPERTYID_WIDTH];
774 $height = (int)$arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT];
775 $html = ilUtil::img($dir . "/" . $med->location, '', $width, $height);
776
777 if ($is_linked_field AND $has_view AND $link) {
778 $ilCtrl->setParameterByClass('ildatacollectionrecordviewgui', 'record_id', $record_field->getRecord()->getId());
779 $html = '<a href="' . $ilCtrl->getLinkTargetByClass("ildatacollectionrecordviewgui", 'renderRecord') . '">' . $html . '</a>';
780 }
781 } else {
782 // Video/Audio
783 $mpl = new ilMediaPlayerGUI($med->getId(), '');
784 $mpl->setFile(ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation());
785 $mpl->setMimeType($med->getFormat());
786 $mpl->setDisplayWidth((int)$arr_properties[ilDataCollectionField::PROPERTYID_WIDTH] . 'px');
787 $mpl->setDisplayHeight((int)$arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT] . 'px');
788 $mpl->setVideoPreviewPic($mob->getVideoPreviewPic());
789 $html = $mpl->getPreviewHtml();
790
791 if ($is_linked_field AND $has_view) {
792 global $lng;
793 $ilCtrl->setParameterByClass('ildatacollectionrecordviewgui', 'record_id', $record_field->getRecord()->getId());
794 $html = $html . '<a href="' . $ilCtrl->getLinkTargetByClass("ildatacollectionrecordviewgui", 'renderRecord') . '">'
795 . $lng->txt('details') . '</a>';
796 }
797 }
798 break;
799
801 switch ($value) {
802 case 0:
803 $im = ilUtil::getImagePath('icon_not_ok.svg');
804 break;
805 case 1:
806 $im = ilUtil::getImagePath('icon_ok.svg');
807 break;
808 }
809 $html = "<img src='" . $im . "'>";
810 break;
811
813 //Property URL
814 $arr_properties = $record_field->getField()->getProperties();
815 if ($arr_properties[ilDataCollectionField::PROPERTYID_URL]) {
816 $link = $value;
817 if (preg_match("/^[a-z0-9!#$%&'*+=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i", $value)) {
818 $value = "mailto:" . $value;
819 } elseif (!(preg_match('~(^(news|(ht|f)tp(s?)\://){1}\S+)~i', $value))) {
820 return $link;
821 }
822
823 $link = $this->shortenLink($link);
824 $html = "<a target='_blank' href='" . $value . "'>" . $link . "</a>";
826 $link AND ilDataCollectionRecordViewViewdefinition::getIdByTableId($record_field->getRecord()->getTableId())
827 ) {
828 $ilCtrl->setParameterByClass('ildatacollectionrecordviewgui', 'record_id', $record_field->getRecord()->getId());
829 $html = '<a href="' . $ilCtrl->getLinkTargetByClass("ildatacollectionrecordviewgui", 'renderRecord') . '">' . $value . '</a>';
830 } else {
831 $html = $value;
832 }
833 break;
834
835 default:
836 $html = $value;
837 break;
838 }
839
840 return $html;
841 }
$_GET["client_id"]
shortenLink($value)
This method shortens a link.
static getIdByTableId($a_table_id)
Get view definition id by table id.
User interface for media player.
_getDirectory($a_mob_id)
get directory for files of media object (static)
_getURL($a_mob_id)
get directory for files of media object (static)
static hasPreview($a_obj_id, $a_type="")
Determines whether the object with the specified reference id has a preview.
const RENDER_STATUS_NONE
static createPreview($a_obj, $a_force=false)
Creates the preview for the object with the specified id.
static lookupRenderStatus($a_obj_id)
Gets the render status for the object with the specified id.
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
global $ilCtrl
Definition: ilias.php:18
$preview
global $ilUser
Definition: imgupload.php:15

References $_GET, $ilCtrl, $ilUser, $lng, $preview, ilObject2\_exists(), ilObjMediaObject\_getDirectory(), ilObjMediaObject\_getURL(), ilObject2\_lookupType(), ilPreviewGUI\CONTEXT_REPOSITORY, ilPreview\createPreview(), formatDate(), ilDataCollectionRecordField\getField(), ilDataCollectionRecordField\getId(), ilDataCollectionRecordViewViewdefinition\getIdByTableId(), ilUtil\getImagePath(), ilDataCollectionRecordField\getRecord(), ilPreview\hasPreview(), ilUtil\img(), INPUTFORMAT_BOOLEAN, INPUTFORMAT_DATETIME, INPUTFORMAT_FILE, INPUTFORMAT_MOB, INPUTFORMAT_TEXT, ilPreview\lookupRenderStatus(), ilDataCollectionField\PROPERTYID_HEIGHT, ilDataCollectionField\PROPERTYID_LINK_DETAIL_PAGE_MOB, ilDataCollectionField\PROPERTYID_LINK_DETAIL_PAGE_TEXT, ilDataCollectionField\PROPERTYID_URL, ilDataCollectionField\PROPERTYID_WIDTH, ilPreview\RENDER_STATUS_NONE, and shortenLink().

+ Here is the call graph for this function:

◆ parseSortingValue()

ilDataCollectionDatatype::parseSortingValue (   $value,
ilDataCollectionRecordField  $record_field,
  $link = true 
)
Parameters
$value
ilDataCollectionRecordField$record_field
bool | true$link
Returns
int|string

Definition at line 655 of file class.ilDataCollectionDatatype.php.

655 {
656 switch ($this->id) {
658 return strtotime($value);
660 if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "file") {
661 return '';
662 }
663 $file_obj = new ilObjFile($value, false);
664 return $file_obj->getTitle();
666 $mob = new ilObjMediaObject($value, false);
667 return $mob->getTitle();
669 $arr_properties = $record_field->getField()->getProperties();
670 if ($arr_properties[ilDataCollectionField::PROPERTYID_URL]) {
671 if ($json = json_decode($value)) {
672 return $json->title ? $json->title : $json->link;
673 } else {
674 return $value;
675 }
676 } else {
677 return $value;
678 }
679 default:
680 return $value;
681 }
682 }

References ilObject2\_exists(), ilObject2\_lookupType(), ilDataCollectionRecordField\getField(), INPUTFORMAT_DATETIME, INPUTFORMAT_FILE, INPUTFORMAT_MOB, INPUTFORMAT_TEXT, and ilDataCollectionField\PROPERTYID_URL.

+ Here is the call graph for this function:

◆ parseValue()

ilDataCollectionDatatype::parseValue (   $value,
ilDataCollectionRecordField  $record_field 
)

Function to parse incoming data from form input value $value.

returns the string/number/etc. to store in the database.

Parameters
$value
ilDataCollectionRecordField$record_field
Returns
int|string

Definition at line 487 of file class.ilDataCollectionDatatype.php.

487 {
488 $return = false;
489
491 $file = $value;
492
493 if (is_array($file) && $file['tmp_name']) {
494 $file_obj = new ilObjFile();
495
496 $file_obj->setType("file");
497 $file_obj->setTitle($file["name"]);
498 $file_obj->setFileName($file["name"]);
499 $file_obj->setFileType(ilMimeTypeUtil::getMimeType("", $file["name"], $file["type"]));
500 $file_obj->setFileSize($file["size"]);
501 $file_obj->setMode("object");
502 $file_obj->create();
503 $file_obj->getUploadFile($file["tmp_name"], $file["name"]);
504 $file_id = $file_obj->getId();
505 $return = $file_id;
506 } else {
507 $return = $record_field->getValue();
508 }
509 } elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_MOB) {
510 if ($value == -1) //marked for deletion.
511 {
512 return 0;
513 }
514
515 $media = $value;
516 if (is_array($media) && $media['tmp_name']) {
517 $mob = new ilObjMediaObject();
518 $mob->setTitle($media['name']);
519 $mob->create();
520 $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
521 if (!is_dir($mob_dir)) {
522 $mob->createDirectory();
523 }
524 $media_item = new ilMediaItem();
525 $mob->addMediaItem($media_item);
526 $media_item->setPurpose("Standard");
527 $file_name = ilUtil::getASCIIFilename($media['name']);
528 $file_name = str_replace(" ", "_", $file_name);
529 $file = $mob_dir . "/" . $file_name;
530 $title = $file_name;
531 $location = $file_name;
532 ilUtil::moveUploadedFile($media['tmp_name'], $file_name, $file);
534 // Check image/video
536 if ($format == 'image/jpeg') {
537 list($width, $height, $type, $attr) = getimagesize($file);
538 $arr_properties = $record_field->getField()->getProperties();
539 $new_width = $arr_properties[ilDataCollectionField::PROPERTYID_WIDTH];
540 $new_height = $arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT];
541 if ($new_width || $new_height) {
542 //only resize if it is bigger, not if it is smaller
543 if ($new_height < $height && $new_width < $width) {
544 //resize proportional
545 if (!$new_height || !$new_width) {
547 $wh = ilObjMediaObject::_determineWidthHeight("", "", $format, "File", $file, "", true, false, $arr_properties[ilDataCollectionField::PROPERTYID_WIDTH], (int)$arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT]);
548 } else {
549 $wh['width'] = (int)$arr_properties[ilDataCollectionField::PROPERTYID_WIDTH];
550 $wh['height'] = (int)$arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT];
551 }
552
553 $location = ilObjMediaObject::_resizeImage($file, $wh['width'], $wh['height'], false);
554 }
555 }
556 }
557
558 ilObjMediaObject::_saveUsage($mob->getId(), "dcl:html", $record_field->getRecord()->getTable()->getCollectionObject()->getId());
559 $media_item->setFormat($format);
560 $media_item->setLocation($location);
561 $media_item->setLocationType("LocalFile");
562
563 // FSX MediaPreview
564 include_once("./Services/MediaObjects/classes/class.ilFFmpeg.php");
566 $med = $mob->getMediaItem("Standard");
567 $mob_file = ilObjMediaObject::_getDirectory($mob->getId()) . "/" . $med->getLocation();
568 $a_target_dir = ilObjMediaObject::_getDirectory($mob->getId());
569 try {
570 $new_file = ilFFmpeg::extractImage($mob_file, "mob_vpreview.png", $a_target_dir, 1);
571 } catch (ilFFmpegException $e) {
572 ilUtil::sendFailure($e->getMessage(), true);
573 }
574 }
575
576 $mob->update();
577 $return = $mob->getId();
578 } else {
579 $return = $record_field->getValue();
580 }
581 } elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_DATETIME) {
582 return $value["date"] . " " . $value["time"];
583 } elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_BOOLEAN) {
584 $return = $value ? 1 : 0;
585 } elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_TEXT) {
586 $arr_properties = $record_field->getField()->getProperties();
587 if ($arr_properties[ilDataCollectionField::PROPERTYID_TEXTAREA]) {
588 $return = nl2br($value);
589 } else {
590 $return = $value;
591 }
592 } else {
594 $return = ($value == '') ? NULL : $value; //SW, Ilias Mantis #0011799: Return null otherwise '' is casted to 0 in DB
595 } else {
596 $return = $value;
597 }
598 }
599
600 return $return;
601 }
$location
Definition: buildRTE.php:44
Class for ffmpeg exception handling in ILIAS.
static extractImage($a_file, $a_target_filename, $a_target_dir="", $a_sec=1)
Extract image from video file.
static enabled()
Checks, whether FFmpeg support is enabled (path is set in the setup)
static supportsImageExtraction($a_mime)
Check if mime type supports image extraction.
Class ilMediaItem.
static getMimeType($a_file="", $a_filename="", $a_mime="")
Get Mime type.
static _determineWidthHeight($a_def_width, $a_def_height, $a_format, $a_type, $a_file, $a_reference, $a_constrain_proportions, $a_use_original, $a_user_width, $a_user_height)
Determine width and height.
static getMimeType($a_file)
get mime type for file
_resizeImage($a_file, $a_width, $a_height, $a_constrain_prop=false)
resize image and return new image file ("_width_height" string appended)
_saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Save usage of mob within another container (e.g.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.

References $file, $location, $title, ilObjMediaObject\_determineWidthHeight(), ilObjMediaObject\_getDirectory(), ilObjMediaObject\_resizeImage(), ilObjMediaObject\_saveUsage(), ilFFmpeg\enabled(), ilFFmpeg\extractImage(), ilUtil\getASCIIFilename(), ilDataCollectionRecordField\getField(), ilObjMediaObject\getMimeType(), ilMimeTypeUtil\getMimeType(), ilDataCollectionRecordField\getRecord(), ilDataCollectionRecordField\getValue(), INPUTFORMAT_BOOLEAN, INPUTFORMAT_DATETIME, INPUTFORMAT_FILE, INPUTFORMAT_MOB, INPUTFORMAT_NUMBER, INPUTFORMAT_TEXT, ilUtil\moveUploadedFile(), ilDataCollectionField\PROPERTYID_HEIGHT, ilDataCollectionField\PROPERTYID_TEXTAREA, ilDataCollectionField\PROPERTYID_WIDTH, ilUtil\renameExecutables(), ilUtil\sendFailure(), and ilFFmpeg\supportsImageExtraction().

+ Here is the call graph for this function:

◆ passThroughFilter()

static ilDataCollectionDatatype::passThroughFilter ( ilDataCollectionRecord  $record,
ilDataCollectionField  $field,
  $filter 
)
static
Parameters
ilDataCollectionRecord$record
ilDataCollectionField$field
$filter
Returns
bool

Definition at line 398 of file class.ilDataCollectionDatatype.php.

398 {
399 $pass = false;
400 $type_id = $field->getDatatypeId();
401 $value = $record->getRecordFieldValue($field->getId());
402
403 switch ($type_id) {
405 if (!$filter || strpos(strtolower($value), strtolower($filter)) !== false) {
406 $pass = true;
407 }
408 break;
410 if ((!$filter['from'] || $value >= $filter['from']) && (!$filter['to'] || $value <= $filter['to'])) {
411 $pass = true;
412 }
413 break;
415 if ((($filter == "checked" && $value == 1) || ($filter == "not_checked" && $value == 0)) || $filter == '' || !$filter) {
416 $pass = true;
417 }
418 break;
420 if ((!$filter['from'] || $value >= $filter['from']) && (!$filter['to'] || $value <= $filter['to'])) {
421 $pass = true;
422 }
423 break;
425 if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "file") {
426
427 $pass = true;
428 break;
429 }
430
431 $file_obj = new ilObjFile($value, false);
432 $file_name = $file_obj->getTitle();
433 if (!$filter || strpos(strtolower($file_name), strtolower($filter)) !== false) {
434 $pass = true;
435 }
436 break;
438 $props = $field->getProperties();
439 if ($filter && $props[ilDataCollectionField::PROPERTYID_N_REFERENCE] && is_array($value) && in_array($filter, $value)) {
440 $pass = true;
441 }
442 if (!$filter || $filter == $value) {
443 $pass = true;
444 }
445 break;
447 if (!$filter || $filter <= $value['avg']) {
448 $pass = true;
449 }
450 break;
452 $obj_id = ilObject::_lookupObjId($value);
453 if (!$filter || strpos(strtolower(ilObject::_lookupTitle($obj_id)), strtolower($filter)) !== false) {
454 $pass = true;
455 }
456 break;
458 $m_obj = new ilObjMediaObject($value, false);
459 $file_name = $m_obj->getTitle();
460 if (!$filter || strpos(strtolower($file_name), strtolower($filter)) !== false) {
461 $pass = true;
462 }
463 break;
464 }
465
466 //for the fields owner and last edit by, we check the name, not the ID
467 if (($field->getId() == "owner" || $field->getId() == "last_edit_by") && $filter) {
468 $pass = false;
469 $user = new ilObjUser($value);
470 if (strpos($user->getFullname(), $filter) !== false) {
471 $pass = true;
472 }
473 }
474
475 return $pass;
476 }
getProperties()
Get all properties of a field.
getRecordFieldValue($field_id)
Get Field Value.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title

References $pass, ilObject2\_exists(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilObject2\_lookupType(), ilDataCollectionField\getDatatypeId(), ilDataCollectionField\getId(), ilDataCollectionField\getProperties(), ilDataCollectionRecord\getRecordFieldValue(), INPUTFORMAT_BOOLEAN, INPUTFORMAT_DATETIME, INPUTFORMAT_FILE, INPUTFORMAT_ILIAS_REF, INPUTFORMAT_MOB, INPUTFORMAT_NUMBER, INPUTFORMAT_RATING, INPUTFORMAT_REFERENCE, INPUTFORMAT_TEXT, and ilDataCollectionField\PROPERTYID_N_REFERENCE.

Referenced by ilDataCollectionRecord\passThroughFilter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setStorageLocation()

ilDataCollectionDatatype::setStorageLocation (   $a_id)

Set Storage Location.

Parameters
int$a_id

Definition at line 118 of file class.ilDataCollectionDatatype.php.

118 {
119 $this->storageLocation = $a_id;
120 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setTitle()

ilDataCollectionDatatype::setTitle (   $a_title)

Set title.

Parameters
string$a_title

Definition at line 98 of file class.ilDataCollectionDatatype.php.

98 {
99 $this->title = $a_title;
100 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ shortenLink()

ilDataCollectionDatatype::shortenLink (   $value)
private

This method shortens a link.

The http(s):// and the www part are taken away. The rest will be shortened to sth similar to: "somelink.de/lange...gugus.html".

Parameters
$valueThe link in it's original form.
Returns
string The shortened link

Definition at line 852 of file class.ilDataCollectionDatatype.php.

852 {
853 if (strlen($value) > self::LINK_MAX_LENGTH) {
854 if (substr($value, 0, 7) == "http://") {
855 $value = substr($value, 7);
856 }
857 if (substr($value, 0, 8) == "https://") {
858 $value = substr($value, 8);
859 }
860 if (substr($value, 0, 4) == "www.") {
861 $value = substr($value, 4);
862 }
863 }
864 $link = $value;
865 if (strlen($value) > self::LINK_MAX_LENGTH) {
866 $link = substr($value, 0, (self::LINK_MAX_LENGTH - 3) / 2);
867 $link .= "...";
868 $link .= substr($value, -(self::LINK_MAX_LENGTH - 3) / 2);
869 }
870
871 return $link;
872 }

Referenced by parseHTML().

+ Here is the caller graph for this function:

Field Documentation

◆ $dbType

ilDataCollectionDatatype::$dbType
protected

Definition at line 64 of file class.ilDataCollectionDatatype.php.

Referenced by getDbType().

◆ $id

ilDataCollectionDatatype::$id
protected

Definition at line 52 of file class.ilDataCollectionDatatype.php.

Referenced by getId().

◆ $mob_suffixes

ilDataCollectionDatatype::$mob_suffixes = array('jpg', 'jpeg', 'gif', 'png', 'mp3', 'flx', 'mp4', 'm4v', 'mov', 'wmv')
static

◆ $storageLocation

ilDataCollectionDatatype::$storageLocation
protected

Definition at line 60 of file class.ilDataCollectionDatatype.php.

Referenced by getStorageLocation().

◆ $title

ilDataCollectionDatatype::$title
protected

Definition at line 56 of file class.ilDataCollectionDatatype.php.

Referenced by getInputField(), getTitle(), and parseValue().

◆ INPUTFORMAT_BOOLEAN

◆ INPUTFORMAT_DATETIME

◆ INPUTFORMAT_FILE

◆ INPUTFORMAT_FORMULA

const ilDataCollectionDatatype::INPUTFORMAT_FORMULA = 11

◆ INPUTFORMAT_ILIAS_REF

◆ INPUTFORMAT_MOB

◆ INPUTFORMAT_NON_EDITABLE_VALUE

const ilDataCollectionDatatype::INPUTFORMAT_NON_EDITABLE_VALUE = 12

◆ INPUTFORMAT_NONE

const ilDataCollectionDatatype::INPUTFORMAT_NONE = 0

◆ INPUTFORMAT_NUMBER

◆ INPUTFORMAT_RATING

◆ INPUTFORMAT_REFERENCE

◆ INPUTFORMAT_REFERENCELIST

const ilDataCollectionDatatype::INPUTFORMAT_REFERENCELIST = 10

◆ INPUTFORMAT_TEXT

◆ LINK_MAX_LENGTH

const ilDataCollectionDatatype::LINK_MAX_LENGTH = 40

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


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