ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 76 of file class.ilDataCollectionDatatype.php.

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

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 318 of file class.ilDataCollectionDatatype.php.

318 {
319 global $lng;
320
321 $type_id = $field->getDatatypeId();
322 $input = NULL;
323
324 switch ($type_id) {
326 $input = $table->addFilterItemByMetaType("filter_" . $field->getId(), ilTable2GUI::FILTER_TEXT, false, $field->getId());
327 $input->setSubmitFormOnEnter(true);
328 break;
330 $input = $table->addFilterItemByMetaType("filter_" . $field->getId(), ilTable2GUI::FILTER_NUMBER_RANGE, false, $field->getId());
331 $input->setSubmitFormOnEnter(true);
332 break;
334 $input = $table->addFilterItemByMetaType("filter_" . $field->getId(), ilTable2GUI::FILTER_SELECT, false, $field->getId());
335 $input->setOptions(array(
336 "" => $lng->txt("dcl_any"),
337 "not_checked" => $lng->txt("dcl_not_checked"),
338 "checked" => $lng->txt("dcl_checked")
339 ));
340 break;
342 $input = $table->addFilterItemByMetaType("filter_" . $field->getId(), ilTable2GUI::FILTER_DATE_RANGE, false, $field->getId());
343 $input->setSubmitFormOnEnter(true);
344 $input->setStartYear(date("Y") - 100);
345 break;
347 $input = $table->addFilterItemByMetaType("filter_" . $field->getId(), ilTable2GUI::FILTER_TEXT, false, $field->getId());
348 $input->setSubmitFormOnEnter(true);
349 break;
351 $input = $table->addFilterItemByMetaType("filter_" . $field->getId(), ilTable2GUI::FILTER_SELECT, false, $field->getId());
352 $ref_field_id = $field->getFieldRef();
353 $ref_field = ilDataCollectionCache::getFieldCache($ref_field_id);
354 $ref_table = ilDataCollectionCache::getTableCache($ref_field->getTableId());
355 $options = array();
356 foreach ($ref_table->getRecords() as $record) {
357 $options[$record->getId()] = $record->getRecordFieldValue($ref_field_id);
358 }
359 // Sort by values ASC
360 asort($options);
361 $options = array('' => $lng->txt('dcl_any')) + $options;
362 $input->setOptions($options);
363 break;
365 $input = $table->addFilterItemByMetaType("filter_" . $field->getId(), ilTable2GUI::FILTER_SELECT, false, $field->getId());
366 $options = array("" => $lng->txt("dcl_any"), 1 => ">1", 2 => ">2", 3 => ">3", 4 => ">4", 5 => "5");
367 $input->setOptions($options);
368 break;
370 $input = $table->addFilterItemByMetaType("filter_" . $field->getId(), ilTable2GUI::FILTER_TEXT, false, $field->getId());
371 $input->setSubmitFormOnEnter(true);
372 break;
374 $input = $table->addFilterItemByMetaType("filter_" . $field->getId(), ilTable2GUI::FILTER_TEXT, false, $field->getId());
375 $input->setSubmitFormOnEnter(true);
376 break;
378 //FIXME
379 $input = $table->addFilterItemByMetaType("filter_" . $field->getId(), ilTable2GUI::FILTER_SELECT, false, $field->getId());
380 $ref_field_id = $field->getFieldRef();
381 $ref_field = ilDataCollectionCache::getFieldCache($ref_field_id);
382 $ref_table = ilDataCollectionCache::getTableCache($ref_field->getTableId());
383 $options = array();
384 foreach ($ref_table->getRecords() as $record) {
385 $options[$record->getId()] = $record->getRecordFieldValue($ref_field_id);
386 }
387 // Sort by values ASC
388 asort($options);
389 $options = array('' => $lng->txt('dcl_any')) + $options;
390 $input->setOptions($options);
391 break;
392 }
393
394 if ($input != NULL) {
395 $input->setTitle($field->getTitle());
396 }
397
398 return $input;
399 }
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 209 of file class.ilDataCollectionDatatype.php.

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

References INPUTFORMAT_NUMBER.

Referenced by ilDataCollectionField\checkValidity().

+ Here is the caller graph for this function:

◆ doRead()

ilDataCollectionDatatype::doRead ( )

Read Datatype.

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

145 {
146 global $ilDB;
147
148 $query = "SELECT * FROM il_dcl_datatype WHERE id = " . $ilDB->quote($this->getId(), "integer") . " ORDER BY sort";
149 $set = $ilDB->query($query);
150 $rec = $ilDB->fetchAssoc($set);
151
152 $this->setTitle($rec["title"]);
153 $this->dbType = $rec["ildb_type"];
154 $this->setStorageLocation($rec["storage_location"]);
155 }
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 708 of file class.ilDataCollectionDatatype.php.

708 {
709 if ($value == '0000-00-00 00:00:00' OR !$value) {
710 return '';
711 }
712 $timestamp = strtotime($value);
713 switch($format)
714 {
716 return date("d.m.Y", $timestamp);
718 return date("Y-m-d", $timestamp);
720 return date("m/d/Y", $timestamp);
721 }
722 return '';
723 }
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 163 of file class.ilDataCollectionDatatype.php.

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

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 137 of file class.ilDataCollectionDatatype.php.

References $dbType.

◆ getId()

ilDataCollectionDatatype::getId ( )

Get field id.

Returns
int

Definition at line 89 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 233 of file class.ilDataCollectionDatatype.php.

233 {
234 global $lng;
235 $type_id = $field->getDatatypeId();
236 $title = $field->getTitle();
237 $input = NULL;
238 switch ($type_id) {
240 $input = new ilDclTextInputGUI($title, 'field_' . $field->getId());
241 if ($field->getTextArea()) {
242 $input = new ilTextAreaInputGUI($title, 'field_' . $field->getId());
243 }
244 if ($field->getLength()) {
245 $input->setInfo($lng->txt("dcl_max_text_length") . ": " . $field->getLength());
246 if (!$field->getTextArea()) {
247 $input->setMaxLength($field->getLength());
248 }
249 }
250 $properties = $field->getProperties();
251 if ($properties[ilDataCollectionField::PROPERTYID_URL]) {
252 $input->setInfo($lng->txt('dcl_text_email_detail_desc'));
253 $title_field = new ilTextInputGUI($lng->txt('dcl_text_email_title'), 'field_' . $field->getId() . '_title');
254 $title_field->setInfo($lng->txt('dcl_text_email_title_info'));
255 $input->addSubItem($title_field);
256 }
257 break;
259 $input = new ilNumberInputGUI($title, 'field_' . $field->getId());
260 break;
262 $input = new ilDclCheckboxInputGUI($title, 'field_' . $field->getId());
263 break;
265 $input = new ilDateTimeInputGUI($title, 'field_' . $field->getId());
266 $input->setMode(ilDateTimeInputGUI::MODE_INPUT);
267 $input->setStartYear(date("Y") - 100);
268 break;
270 $input = new ilFileInputGUI($title, 'field_' . $field->getId());
271 $input->setAllowDeletion(true);
272 break;
274 if (!$field->isNRef()) {
275 $input = new ilSelectInputGUI($title, 'field_' . $field->getId());
276 } else {
277 $input = new ilMultiSelectInputGUI($title, 'field_' . $field->getId());
278 $input->setWidth(100);
279 $input->setWidthUnit('%');
280 }
281 break;
283 $input = new ilTextInputGUI($title, 'field_' . $field->getId());
284 $input->setValue($lng->txt("dcl_editable_in_table_gui"));
285 $input->setDisabled(true);
286 break;
288 $input = new ilDataCollectionTreePickInputGUI($title, 'field_' . $field->getId());
289 break;
291 $input = new ilFileInputGUI($title, 'field_' . $field->getId());
292 $input->setSuffixes(self::$mob_suffixes);
293 $input->setAllowDeletion(true);
294 break;
296 $input = new ilTextInputGUI($title, 'field_' . $field->getId());
297 $input->setDisabled(true);
298 $input->setValue('-');
299 $input->setInfo($lng->txt('dcl_formula_detail_desc'));
300 break;
301 }
302 if ($field->getDescription() && $input !== NULL) {
303 $input->setInfo($field->getDescription() . ($input->getInfo() ? "<br>" . $input->getInfo() : ""));
304 }
305
306 return $input;
307 }
getProperties()
Get all properties of a field.
This class represents a date/time property in a property form.
Class ilDclCheckboxInputGUI.
Class ilDclTextInputGUI.
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 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\getProperties(), 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(), ilDateTimeInputGUI\MODE_INPUT, and ilDataCollectionField\PROPERTYID_URL.

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 185 of file class.ilDataCollectionDatatype.php.

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

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 129 of file class.ilDataCollectionDatatype.php.

References $storageLocation.

◆ getTitle()

ilDataCollectionDatatype::getTitle ( )

Get title.

Returns
string

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

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

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 626 of file class.ilDataCollectionDatatype.php.

626 {
627 $return = false;
628
630 if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "file") {
631 return;
632 }
633
634 $file = $value;
635 if ($file != "-") {
636 $file_obj = new ilObjFile($file, false);
637 $file_name = $file_obj->getFileName();
638
639 $return = $file_name;
640 } else {
641 $return = $file;
642 }
643 } elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_MOB) {
644 $file = $value;
645 if ($file != "-") {
646 $mob = new ilObjMediaObject($file, false);
647 $mob_name = $mob->getTitle();
648
649 $return = $mob_name;
650 } else {
651 $return = $file;
652 }
653 } elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_DATETIME) {
654 $return = substr($value, 0, 10);
655 } elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_BOOLEAN) {
656 $return = $value ? 1 : 0;
657 } elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_TEXT && $json = json_decode($value)) {
658 $return = $json;
659 } else {
660 $return = $value;
661 }
662
663 return $return;
664 }
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, INPUTFORMAT_MOB, and INPUTFORMAT_TEXT.

+ 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 909 of file class.ilDataCollectionDatatype.php.

909 {
910 switch ($this->id) {
912 if (!$value || $value == "-") {
913 return NULL;
914 }
915 //$datetime = new DateTime();
916 $input = array(
917 "date" => substr($value, 0, -9),
918 "time" => "00:00:00"
919 );
920 break;
922
923 if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "file") {
924 $input = "";
925 break;
926 }
927
928 $file_obj = new ilObjFile($value, false);
929 //$input = ilObjFile::_lookupAbsolutePath($value);
930 $input = $file_obj->getFileName();
931 break;
933 if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "mob") {
934 $input = "";
935 break;
936 }
937
938 $media_obj = new ilObjMediaObject($value, false);
939 //$input = ilObjFile::_lookupAbsolutePath($value);
940 $input = $value;
941 break;
942 default:
943 $input = $value;
944 break;
945 }
946
947 return $input;
948 }

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

+ 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 734 of file class.ilDataCollectionDatatype.php.

734 {
735 global $ilAccess, $ilCtrl, $lng, $ilUser;
736
737 switch ($this->id) {
739 $html = $this->formatDate($value, $ilUser->getDateFormat());
740 break;
741
743
744 if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "file") {
745 $html = "";
746 break;
747 }
748
749 $file_obj = new ilObjFile($value, false);
750 $ilCtrl->setParameterByClass("ildatacollectionrecordlistgui", "record_id", $record_field->getRecord()->getId());
751 $ilCtrl->setParameterByClass("ildatacollectionrecordlistgui", "field_id", $record_field->getField()->getId());
752
753 $html = '<a href="' . $ilCtrl->getLinkTargetByClass("ildatacollectionrecordlistgui", "sendFile") . '">' . $file_obj->getFileName()
754 . '</a>';
755 if (ilPreview::hasPreview($file_obj->getId())) {
756 ilPreview::createPreview($file_obj); // Create preview if not already existing
757 $preview = new ilPreviewGUI((int)$_GET['ref_id'], ilPreviewGUI::CONTEXT_REPOSITORY, $file_obj->getId(), $ilAccess);
758 $preview_status = ilPreview::lookupRenderStatus($file_obj->getId());
759 $preview_status_class = "";
760 $preview_text_topic = "preview_show";
761 if ($preview_status == ilPreview::RENDER_STATUS_NONE) {
762 $preview_status_class = "ilPreviewStatusNone";
763 $preview_text_topic = "preview_none";
764 }
765 $wrapper_html_id = 'record_field_' . $record_field->getId();
766 $script_preview_click = $preview->getJSCall($wrapper_html_id);
767 $preview_title = $lng->txt($preview_text_topic);
768 $preview_icon = ilUtil::getImagePath("preview.png", "Services/Preview");
769 $html = '<div id="' . $wrapper_html_id . '">' . $html;
770 $html .= '<span class="il_ContainerItemPreview ' . $preview_status_class . '"><a href="javascript:void(0);" onclick="'
771 . $script_preview_click . '" title="' . $preview_title . '"><img src="' . $preview_icon
772 . '" height="16" width="16"></a></span></div>';
773 }
774 break;
775
777
778 $mob = new ilObjMediaObject($value, false);
779 $med = $mob->getMediaItem('Standard');
780 if (!$med->location) {
781 $html = "";
782 break;
783 }
784 $arr_properties = $record_field->getField()->getProperties();
785 $is_linked_field = $arr_properties[ilDataCollectionField::PROPERTYID_LINK_DETAIL_PAGE_MOB];
786 $has_view = ilDataCollectionRecordViewViewdefinition::getIdByTableId($record_field->getRecord()->getTableId());
787 if (in_array($med->getSuffix(), array('jpg', 'jpeg', 'png', 'gif'))) {
788 // Image
789 $dir = ilObjMediaObject::_getDirectory($mob->getId());
790 $width = (int)$arr_properties[ilDataCollectionField::PROPERTYID_WIDTH];
791 $height = (int)$arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT];
792 $html = ilUtil::img($dir . "/" . $med->location, '', $width, $height);
793
794 if ($is_linked_field AND $has_view AND $link) {
795 $ilCtrl->setParameterByClass('ildatacollectionrecordviewgui', 'record_id', $record_field->getRecord()->getId());
796 $html = '<a href="' . $ilCtrl->getLinkTargetByClass("ildatacollectionrecordviewgui", 'renderRecord') . '">' . $html . '</a>';
797 }
798 } else {
799 // Video/Audio
800 $mpl = new ilMediaPlayerGUI($med->getId(), '');
801 $mpl->setFile(ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation());
802 $mpl->setMimeType($med->getFormat());
803 $mpl->setDisplayWidth((int)$arr_properties[ilDataCollectionField::PROPERTYID_WIDTH] . 'px');
804 $mpl->setDisplayHeight((int)$arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT] . 'px');
805 $mpl->setVideoPreviewPic($mob->getVideoPreviewPic());
806 $html = $mpl->getPreviewHtml();
807
808 if ($is_linked_field AND $has_view) {
809 global $lng;
810 $ilCtrl->setParameterByClass('ildatacollectionrecordviewgui', 'record_id', $record_field->getRecord()->getId());
811 $html = $html . '<a href="' . $ilCtrl->getLinkTargetByClass("ildatacollectionrecordviewgui", 'renderRecord') . '">'
812 . $lng->txt('details') . '</a>';
813 }
814 }
815 break;
816
818 switch ($value) {
819 case 0:
820 $im = ilUtil::getImagePath('icon_not_ok.svg');
821 break;
822 case 1:
823 $im = ilUtil::getImagePath('icon_ok.svg');
824 break;
825 }
826 $html = "<img src='" . $im . "'>";
827 break;
828
830 //Property URL
831 $arr_properties = $record_field->getField()->getProperties();
832 if ($arr_properties[ilDataCollectionField::PROPERTYID_URL]) {
833 if ($json = json_decode($value)) {
834 $link = $json->link;
835 $link_value = $json->title ? $json->title : $this->shortenLink($link);
836 } else {
837 $link = $value;
838 $link_value = $this->shortenLink($value);
839 }
840
841 if (substr($link, 0, 3) === 'www') {
842 $link = 'http://' . $link;
843 }
844 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", $link)) {
845 $link = "mailto:" . $link;
846 } elseif (!(preg_match('~(^(news|(ht|f)tp(s?)\://){1}\S+)~i', $link))) {
847 return $link;
848 }
849
850 $html = "<a rel='noopener' target='_blank' href='" . $link . "'>" . $link_value . "</a>";
851
853 $link AND ilDataCollectionRecordViewViewdefinition::getIdByTableId($record_field->getRecord()->getTableId())
854 ) {
855 $ilCtrl->setParameterByClass('ildatacollectionrecordviewgui', 'record_id', $record_field->getRecord()->getId());
856 $html = '<a href="' . $ilCtrl->getLinkTargetByClass("ildatacollectionrecordviewgui", 'renderRecord') . '">' . $value . '</a>';
857 } else {
858 $html = $value;
859 }
860 break;
861
862 default:
863 $html = $value;
864 break;
865 }
866
867 return $html;
868 }
$_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)
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)
$html
Definition: example_001.php:87
global $ilCtrl
Definition: ilias.php:18
$preview
global $ilUser
Definition: imgupload.php:15

References $_GET, $html, $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 672 of file class.ilDataCollectionDatatype.php.

672 {
673 switch ($this->id) {
675 return strtotime($value);
677 if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "file") {
678 return '';
679 }
680 $file_obj = new ilObjFile($value, false);
681 return $file_obj->getTitle();
683 $mob = new ilObjMediaObject($value, false);
684 return $mob->getTitle();
686 $arr_properties = $record_field->getField()->getProperties();
687 if ($arr_properties[ilDataCollectionField::PROPERTYID_URL]) {
688 if ($json = json_decode($value)) {
689 return $json->title ? $json->title : $json->link;
690 } else {
691 return $value;
692 }
693 } else {
694 return $value;
695 }
696 default:
697 return $value;
698 }
699 }

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 498 of file class.ilDataCollectionDatatype.php.

498 {
499 $return = false;
500
502 if ($value == -1) //marked for deletion.
503 {
504 return 0;
505 }
506 $file = $value;
507
508 if (is_array($file) && $file['tmp_name']) {
509 $file_obj = new ilObjFile();
510
511 $file_obj->setType("file");
512 $file_obj->setTitle($file["name"]);
513 $file_obj->setFileName($file["name"]);
514 $file_obj->setFileType(ilMimeTypeUtil::getMimeType("", $file["name"], $file["type"]));
515 $file_obj->setFileSize($file["size"]);
516 $file_obj->setMode("object");
517 $file_obj->create();
518 $file_obj->getUploadFile($file["tmp_name"], $file["name"]);
519 $file_id = $file_obj->getId();
520 $return = $file_id;
521 } else {
522 $return = $record_field->getValue();
523 }
524 } elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_MOB) {
525 if ($value == -1) //marked for deletion.
526 {
527 return 0;
528 }
529
530 $media = $value;
531 if (is_array($media) && $media['tmp_name']) {
532 $mob = new ilObjMediaObject();
533 $mob->setTitle($media['name']);
534 $mob->create();
535 $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
536 if (!is_dir($mob_dir)) {
537 $mob->createDirectory();
538 }
539 $media_item = new ilMediaItem();
540 $mob->addMediaItem($media_item);
541 $media_item->setPurpose("Standard");
542 $file_name = ilUtil::getASCIIFilename($media['name']);
543 $file_name = str_replace(" ", "_", $file_name);
544 $file = $mob_dir . "/" . $file_name;
545 $title = $file_name;
546 $location = $file_name;
547 ilUtil::moveUploadedFile($media['tmp_name'], $file_name, $file);
549 // Check image/video
551 if ($format == 'image/jpeg') {
552 list($width, $height, $type, $attr) = getimagesize($file);
553 $arr_properties = $record_field->getField()->getProperties();
554 $new_width = $arr_properties[ilDataCollectionField::PROPERTYID_WIDTH];
555 $new_height = $arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT];
556 if ($new_width || $new_height) {
557 //only resize if it is bigger, not if it is smaller
558 if ($new_height < $height && $new_width < $width) {
559 //resize proportional
560 if (!$new_height || !$new_width) {
562 $wh = ilObjMediaObject::_determineWidthHeight($format, "File", $file, "", true, false, $arr_properties[ilDataCollectionField::PROPERTYID_WIDTH], (int)$arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT]);
563 } else {
564 $wh['width'] = (int)$arr_properties[ilDataCollectionField::PROPERTYID_WIDTH];
565 $wh['height'] = (int)$arr_properties[ilDataCollectionField::PROPERTYID_HEIGHT];
566 }
567
568 $location = ilObjMediaObject::_resizeImage($file, $wh['width'], $wh['height'], false);
569 }
570 }
571 }
572
573 ilObjMediaObject::_saveUsage($mob->getId(), "dcl:html", $record_field->getRecord()->getTable()->getCollectionObject()->getId());
574 $media_item->setFormat($format);
575 $media_item->setLocation($location);
576 $media_item->setLocationType("LocalFile");
577
578 // FSX MediaPreview
579 include_once("./Services/MediaObjects/classes/class.ilFFmpeg.php");
581 $med = $mob->getMediaItem("Standard");
582 $mob_file = ilObjMediaObject::_getDirectory($mob->getId()) . "/" . $med->getLocation();
583 $a_target_dir = ilObjMediaObject::_getDirectory($mob->getId());
584 try {
585 $new_file = ilFFmpeg::extractImage($mob_file, "mob_vpreview.png", $a_target_dir, 1);
586 } catch (Exception $e) {
587 ilUtil::sendFailure($e->getMessage(), true);
588 }
589 }
590
591 $mob->update();
592 $return = $mob->getId();
593 } else {
594 $return = $record_field->getValue();
595 }
596 } elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_DATETIME) {
597 return $value["date"] . " " . $value["time"];
598 } elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_BOOLEAN) {
599 $return = $value ? 1 : 0;
600 } elseif ($this->id == ilDataCollectionDatatype::INPUTFORMAT_TEXT) {
601 $arr_properties = $record_field->getField()->getProperties();
602 if ($arr_properties[ilDataCollectionField::PROPERTYID_TEXTAREA]) {
603 $return = nl2br($value);
604 } else {
605 $return = $value;
606 }
607 } else {
609 $return = ($value == '') ? NULL : $value; //SW, Ilias Mantis #0011799: Return null otherwise '' is casted to 0 in DB
610 } else {
611 $return = $value;
612 }
613 }
614
615 return $return;
616 }
$location
Definition: buildRTE.php:44
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='')
static getMimeType($a_file, $a_external=false)
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 _determineWidthHeight($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 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 409 of file class.ilDataCollectionDatatype.php.

409 {
410 $pass = false;
411 $type_id = $field->getDatatypeId();
412 $value = $record->getRecordFieldValue($field->getId());
413
414 switch ($type_id) {
416 if (!$filter || strpos(strtolower($value), strtolower($filter)) !== false) {
417 $pass = true;
418 }
419 break;
421 if ((!$filter['from'] || $value >= $filter['from']) && (!$filter['to'] || $value <= $filter['to'])) {
422 $pass = true;
423 }
424 break;
426 if ((($filter == "checked" && $value == 1) || ($filter == "not_checked" && $value == 0)) || $filter == '' || !$filter) {
427 $pass = true;
428 }
429 break;
431 if ((!$filter['from'] || $value >= $filter['from']) && (!$filter['to'] || $value <= $filter['to'])) {
432 $pass = true;
433 }
434 break;
436 if (!ilObject2::_exists($value) || ilObject2::_lookupType($value, false) != "file") {
437
438 $pass = true;
439 break;
440 }
441
442 $file_obj = new ilObjFile($value, false);
443 $file_name = $file_obj->getTitle();
444 if (!$filter || strpos(strtolower($file_name), strtolower($filter)) !== false) {
445 $pass = true;
446 }
447 break;
449 $props = $field->getProperties();
450 if ($filter && $props[ilDataCollectionField::PROPERTYID_N_REFERENCE] && is_array($value) && in_array($filter, $value)) {
451 $pass = true;
452 }
453 if (!$filter || $filter == $value) {
454 $pass = true;
455 }
456 break;
458 if (!$filter || $filter <= $value['avg']) {
459 $pass = true;
460 }
461 break;
463 $obj_id = ilObject::_lookupObjId($value);
464 if (!$filter || strpos(strtolower(ilObject::_lookupTitle($obj_id)), strtolower($filter)) !== false) {
465 $pass = true;
466 }
467 break;
469 $m_obj = new ilObjMediaObject($value, false);
470 $file_name = $m_obj->getTitle();
471 if (!$filter || strpos(strtolower($file_name), strtolower($filter)) !== false) {
472 $pass = true;
473 }
474 break;
475 }
476
477 //for the fields owner and last edit by, we check the name, not the ID
478 if (($field->getId() == "owner" || $field->getId() == "last_edit_by") && $filter) {
479 $pass = false;
480 $user = new ilObjUser($value);
481 if (strpos($user->getFullname(), $filter) !== false) {
482 $pass = true;
483 }
484 }
485
486 return $pass;
487 }
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 119 of file class.ilDataCollectionDatatype.php.

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

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 99 of file class.ilDataCollectionDatatype.php.

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

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 879 of file class.ilDataCollectionDatatype.php.

879 {
880 if (strlen($value) > self::LINK_MAX_LENGTH) {
881 if (substr($value, 0, 7) == "http://") {
882 $value = substr($value, 7);
883 }
884 if (substr($value, 0, 8) == "https://") {
885 $value = substr($value, 8);
886 }
887 if (substr($value, 0, 4) == "www.") {
888 $value = substr($value, 4);
889 }
890 }
891 $link = $value;
892 if (strlen($value) > self::LINK_MAX_LENGTH) {
893 $link = substr($value, 0, (self::LINK_MAX_LENGTH - 3) / 2);
894 $link .= "...";
895 $link .= substr($value, -(self::LINK_MAX_LENGTH - 3) / 2);
896 }
897
898 return $link;
899 }

Referenced by parseHTML().

+ Here is the caller graph for this function:

Field Documentation

◆ $dbType

ilDataCollectionDatatype::$dbType
protected

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

Referenced by getDbType().

◆ $id

ilDataCollectionDatatype::$id
protected

Definition at line 53 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 61 of file class.ilDataCollectionDatatype.php.

Referenced by getStorageLocation().

◆ $title

ilDataCollectionDatatype::$title
protected

Definition at line 57 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 48 of file class.ilDataCollectionDatatype.php.


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