ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilDclStandardField Class Reference

Class ilDclBaseFieldModel. More...

+ Inheritance diagram for ilDclStandardField:
+ Collaboration diagram for ilDclStandardField:

Public Member Functions

 doRead ()
 
 doCreate ()
 
 doUpdate ()
 
 cloneStructure ($original_record)
 
 getLocked ()
 
 isStandardField ()
 
 isUnique ()
 
 getRecordQuerySortObject ($direction="asc", $sort_by_status=false)
 Returns a query-object for building the record-loader-sql-query. More...
 
 getRecordQueryFilterObject ($filter_value="", ilDclBaseFieldModel $sort_field=null)
 Returns a query-object for building the record-loader-sql-query. More...
 
 getSortField ()
 
 hasNumericSorting ()
 
 allowFilterInListView ()
 
 fillHeaderExcel (ilExcel $worksheet, &$row, &$col)
 
 getValueFromExcel ($excel, $row, $col)
 
 afterClone ($records)
 
- Public Member Functions inherited from ilDclBaseFieldModel
 __construct ($a_id=0)
 
 setId ($a_id)
 Set field id. More...
 
 getId ()
 Get field id. More...
 
 setTableId ($a_id)
 Set table id. More...
 
 getTableId ()
 Get table id. More...
 
 setTitle ($a_title)
 Set title. More...
 
 getTitle ()
 Get title. More...
 
 setDescription ($a_desc)
 Set description. More...
 
 getDescription ()
 Get description. More...
 
 setDatatypeId ($a_id)
 Set datatype id. More...
 
 getDatatypeId ()
 Get datatype_id. More...
 
 setRequired ($a_required)
 Set Required. More...
 
 getRequired ()
 Get Required Required. More...
 
 isUnique ()
 
 setUnique ($unique)
 
 getDatatype ()
 
 getDatatypeTitle ()
 
 getStorageLocation ()
 Get storage location for the model. More...
 
 getExportable ()
 
 toArray ()
 
 isStandardField ()
 
 doRead ()
 Read field. More...
 
 buildFromDBRecord ($rec)
 Builds model from db record. More...
 
 doCreate ()
 Create new field. More...
 
 doUpdate ()
 Update field. More...
 
 updateProperties ()
 Update properties of this field in Database. More...
 
 doDelete ()
 Remove field and properties. More...
 
 getFieldSettings ()
 
 getOrder ()
 
 setOrder ($order)
 
 hasProperty ($key)
 Checks if a certain property for a field is set. More...
 
 getProperty ($key)
 Returns a certain property of a field. More...
 
 getPropertyInstance ($key)
 Return ActiveRecord of property. More...
 
 setProperty ($key, $value)
 Set a property for a field (does not save) More...
 
 getValidFieldProperties ()
 Returns all valid properties for a field-type. More...
 
 setLocked ($locked)
 
 getLocked ()
 
 checkValidityFromForm (ilPropertyFormGUI &$form, $record_id=null)
 
 checkValidity ($value, $record_id=null)
 Check if input is valid. More...
 
 cloneStructure ($original_id)
 
 afterClone ($records)
 
 cloneProperties (ilDclBaseFieldModel $originalField)
 
 setExportable ($exportable)
 
 allowFilterInListView ()
 
 getRecordQuerySortObject ($direction="asc", $sort_by_status=false)
 Returns a query-object for building the record-loader-sql-query. More...
 
 getRecordQueryFilterObject ($filter_value="", ilDclBaseFieldModel $sort_field=null)
 Returns a query-object for building the record-loader-sql-query. More...
 
 getSortField ()
 Returns the sort-field id. More...
 
 hasNumericSorting ()
 Set to true, when the sorting should be handled numerical. More...
 
 checkFieldCreationInput (ilPropertyFormGUI $form)
 Checks input of specific fields befor saving. More...
 
 getStorageLocationOverride ()
 
 setStorageLocationOverride ($storage_location_override)
 
 fillHeaderExcel (ilExcel $worksheet, &$row, &$col)
 
 checkTitlesForImport (array &$titles, array &$import_fields)
 
 storePropertiesFromForm (ilPropertyFormGUI $form)
 called when saving the 'edit field' form More...
 
 fillPropertiesForm (ilPropertyFormGUI &$form)
 called to fill the 'edit field' form More...
 
 isConfirmationRequired (ilPropertyFormGUI $form)
 called by ilDclFieldEditGUI when updating field properties if you overwrite this method, remember to also overwrite getConfirmationGUI More...
 
 getConfirmationGUI (ilPropertyFormGUI $form)
 called by ilDclFieldEditGUI if isConfirmationRequired returns true More...
 

Static Public Member Functions

static _getStandardFieldsAsArray ()
 
static _getStandardFields ($table_id)
 
static _getNonImportableStandardFieldTitles ()
 
static _getImportableStandardFieldTitle ()
 
static _isStandardField ($field_id)
 
static _getDatatypeForId ($id)
 gives you the datatype id of a specified standard field. More...
 
- Static Public Member Functions inherited from ilDclBaseFieldModel
static _getTitleInvalidChars ($a_as_regex=true)
 All valid chars for filed titles. More...
 
static _getFieldIdByTitle ($title, $table_id)
 

Additional Inherited Members

- Data Fields inherited from ilDclBaseFieldModel
const PROP_LENGTH = "lenght"
 General properties. More...
 
const PROP_REGEX = "regex"
 
const PROP_REFERENCE = "table_id"
 
const PROP_URL = "url"
 
const PROP_TEXTAREA = "text_area"
 
const PROP_REFERENCE_LINK = "reference_link"
 
const PROP_WIDTH = "width"
 
const PROP_HEIGHT = "height"
 
const PROP_LEARNING_PROGRESS = "learning_progress"
 
const PROP_ILIAS_REFERENCE_LINK = "ILIAS_reference_link"
 
const PROP_N_REFERENCE = "multiple_selection"
 
const PROP_FORMULA_EXPRESSION = "expression"
 
const PROP_DISPLAY_COPY_LINK_ACTION_MENU = "display_action_menu"
 
const PROP_LINK_DETAIL_PAGE_TEXT = "link_detail_page"
 
const PROP_SUPPORTED_FILE_TYPES = "supported_file_types"
 
const PROP_PLUGIN_HOOK_NAME = "plugin_hook_name"
 
const PROP_TEXT_SELECTION_OPTIONS = "text_selection_options"
 
const PROP_TEXT_SELECTION_TYPE = "text_selection_type"
 
const PROP_DATE_SELECTION_OPTIONS = "date_selection_options"
 
const PROP_DATE_SELECTION_TYPE = "date_selection_type"
 
const EDIT_VIEW = 2
 
const EXPORTABLE_VIEW = 4
 
- Protected Member Functions inherited from ilDclBaseFieldModel
 loadDatatype ()
 Load datatype for model. More...
 
 loadTableFieldSetting ()
 loadTableFieldSetting More...
 
 addToTableViews ()
 create ilDclTableViewFieldSettings for this field in each tableview More...
 
 updateTableFieldSetting ()
 update exportable and fieldorder More...
 
 loadProperties ()
 Get all properties of a field. More...
 
 normalizeValue ($value)
 
- Protected Attributes inherited from ilDclBaseFieldModel
 $id
 
 $table_id
 
 $title
 
 $description
 
 $datatypeId
 
 $required
 
 $order
 
 $unique
 
 $locked
 
 $property = array()
 
 $exportable
 
 $datatype
 
 $storage_location_override = null
 

Detailed Description

Member Function Documentation

◆ _getDatatypeForId()

static ilDclStandardField::_getDatatypeForId (   $id)
static

gives you the datatype id of a specified standard field.

Parameters
int$idthe id of the standardfield eg. "create_date"
Returns
int|null

Definition at line 230 of file class.ilDclStandardField.php.

References ilDclBaseFieldModel\$datatype, and ilDclBaseFieldModel\$id.

Referenced by ilDclBaseFieldModel\getDatatypeId(), and ilDclTableViewFieldSetting\getFieldObject().

231  {
232  $datatype = null;
233  foreach (self::_getStandardFieldsAsArray() as $fields_data) {
234  if ($id == $fields_data['id']) {
235  $datatype = $fields_data['datatype_id'];
236  break;
237  }
238  }
239 
240  return $datatype;
241  }
+ Here is the caller graph for this function:

◆ _getImportableStandardFieldTitle()

static ilDclStandardField::_getImportableStandardFieldTitle ( )
static
Returns
array all possible titles of importable (excel import) standardfields (atm exclusively owner), in all languages;

Definition at line 183 of file class.ilDclStandardField.php.

References $DIC, ilDclBaseFieldModel\$id, and $ilDB.

Referenced by ilDclContentImporter\getImportFieldsFromTitles().

184  {
185  global $DIC;
186  $ilDB = $DIC['ilDB'];
187  $identifiers = '';
188  foreach (array('dcl_owner') as $id) {
189  $identifiers .= $ilDB->quote($id, 'text') . ',';
190  }
191  $identifiers = rtrim($identifiers, ',');
192  $sql = $ilDB->query(
193  'SELECT value, identifier FROM lng_data WHERE identifier IN ('
194  . $identifiers . ')'
195  );
196  $titles = array();
197  while ($rec = $ilDB->fetchAssoc($sql)) {
198  $titles[$rec['identifier']][] = $rec['value'];
199  }
200 
201  return $titles;
202  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ _getNonImportableStandardFieldTitles()

static ilDclStandardField::_getNonImportableStandardFieldTitles ( )
static
Returns
array all possible titles of non-importable (excel import) standardfields (atm all except owner), in all languages;

Definition at line 149 of file class.ilDclStandardField.php.

References $DIC, ilDclBaseFieldModel\$id, and $ilDB.

Referenced by ilDclContentImporter\getImportFieldsFromTitles().

150  {
151  global $DIC;
152  $ilDB = $DIC['ilDB'];
153  $identifiers = '';
154  foreach (
155  array(
156  'dcl_id',
157  'dcl_creation_date',
158  'dcl_last_update',
159  'dcl_last_edited_by',
160  'dcl_comments',
161  ) as $id
162  ) {
163  $identifiers .= $ilDB->quote($id, 'text') . ',';
164  }
165  $identifiers = rtrim($identifiers, ',');
166  $sql = $ilDB->query(
167  'SELECT value FROM lng_data WHERE identifier IN (' . $identifiers
168  . ')'
169  );
170  $titles = array();
171  while ($rec = $ilDB->fetchAssoc($sql)) {
172  $titles[] = $rec['value'];
173  }
174 
175  return $titles;
176  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ _getStandardFields()

static ilDclStandardField::_getStandardFields (   $table_id)
static
Parameters
$table_id
Returns
array

Definition at line 130 of file class.ilDclStandardField.php.

References ilDclBaseFieldModel\$table_id.

Referenced by ilDclTable\getFirstTableViewId().

131  {
132  $stdFields = array();
133  foreach (self::_getStandardFieldsAsArray() as $array) {
134  $array["table_id"] = $table_id;
135  //$array["datatype_id"] = self::_getDatatypeForId($array["id"]);
136  $field = new ilDclStandardField();
137  $field->buildFromDBRecord($array);
138  $stdFields[] = $field;
139  }
140 
141  return $stdFields;
142  }
Class ilDclBaseFieldModel.
+ Here is the caller graph for this function:

◆ _getStandardFieldsAsArray()

static ilDclStandardField::_getStandardFieldsAsArray ( )
static
Returns
array

Definition at line 70 of file class.ilDclStandardField.php.

References $DIC, $lng, ilDclDatatype\INPUTFORMAT_DATETIME, ilDclDatatype\INPUTFORMAT_NONE, ilDclDatatype\INPUTFORMAT_NUMBER, and ilDclDatatype\INPUTFORMAT_TEXT.

71  {
72 
73  //TODO: this isn't particularly pretty especially as $lng is used in the model. On the long run the standard fields should be refactored into "normal" fields.
74  global $DIC;
75  $lng = $DIC['lng'];
76  $stdfields = array(
77  array(
78  "id" => "id",
79  "title" => $lng->txt("dcl_id"),
80  "description" => $lng->txt("dcl_id_description"),
81  "datatype_id" => ilDclDatatype::INPUTFORMAT_NUMBER,
82  "required" => true,
83  ),
84  array(
85  "id" => "create_date",
86  "title" => $lng->txt("dcl_creation_date"),
87  "description" => $lng->txt("dcl_creation_date_description"),
88  "datatype_id" => ilDclDatatype::INPUTFORMAT_DATETIME,
89  "required" => true,
90  ),
91  array(
92  "id" => "last_update",
93  "title" => $lng->txt("dcl_last_update"),
94  "description" => $lng->txt("dcl_last_update_description"),
95  "datatype_id" => ilDclDatatype::INPUTFORMAT_DATETIME,
96  "required" => true,
97  ),
98  array(
99  "id" => "owner",
100  "title" => $lng->txt("dcl_owner"),
101  "description" => $lng->txt("dcl_owner_description"),
102  "datatype_id" => ilDclDatatype::INPUTFORMAT_TEXT,
103  "required" => true,
104  ),
105  array(
106  "id" => "last_edit_by",
107  "title" => $lng->txt("dcl_last_edited_by"),
108  "description" => $lng->txt("dcl_last_edited_by_description"),
109  "datatype_id" => ilDclDatatype::INPUTFORMAT_TEXT,
110  "required" => true,
111  ),
112  array(
113  'id' => 'comments',
114  'title' => $lng->txt('dcl_comments'),
115  'description' => $lng->txt('dcl_comments_desc'),
116  'datatype_id' => ilDclDatatype::INPUTFORMAT_NONE,
117  'required' => false,
118  ),
119  );
120 
121  return $stdfields;
122  }
global $DIC
Definition: saml.php:7
$lng

◆ _isStandardField()

static ilDclStandardField::_isStandardField (   $field_id)
static

◆ afterClone()

ilDclStandardField::afterClone (   $records)
Parameters
$records

Definition at line 427 of file class.ilDclStandardField.php.

428  {
429  }

◆ allowFilterInListView()

ilDclStandardField::allowFilterInListView ( )
Returns
bool

Definition at line 380 of file class.ilDclStandardField.php.

References ilDclCache\getTableCache(), and ilDclBaseFieldModel\getTableId().

381  {
382  //comments are filterable if they are enabled in the tables settings
383  return $this->id != 'comments'
384  || ilDclCache::getTableCache($this->getTableId())->getPublicCommentsEnabled();
385  }
static getTableCache($table_id=0)
+ Here is the call graph for this function:

◆ cloneStructure()

ilDclStandardField::cloneStructure (   $original_record)
Parameters
ilDclStandardField$original_record

Definition at line 46 of file class.ilDclStandardField.php.

References doUpdate(), ilDclBaseFieldModel\setExportable(), ilDclBaseFieldModel\setLocked(), ilDclBaseFieldModel\setOrder(), ilDclBaseFieldModel\setRequired(), and ilDclBaseFieldModel\setUnique().

47  {
48  $this->setLocked($original_record->getLocked());
49  $this->setOrder($original_record->getOrder());
50  $this->setRequired($original_record->getRequired());
51  $this->setUnique($original_record->isUnique());
52  $this->setExportable($original_record->getExportable());
53 
54  $this->doUpdate();
55  }
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:

◆ doCreate()

ilDclStandardField::doCreate ( )

Definition at line 27 of file class.ilDclStandardField.php.

References $DIC, $ilLog, $message, and ilUtil\sendFailure().

28  {
29  global $DIC;
30  $ilLog = $DIC['ilLog'];
31  $message = "Standard fields cannot be written to DB";
33  $ilLog->write("[ilDclStandardField] " . $message);
34  }
global $DIC
Definition: saml.php:7
catch(Exception $e) $message
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ doRead()

ilDclStandardField::doRead ( )

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

References $DIC, $ilLog, $message, and ilUtil\sendFailure().

18  {
19  global $DIC;
20  $ilLog = $DIC['ilLog'];
21  $message = "Standard fields cannot be read from DB";
23  $ilLog->write("[ilDclStandardField] " . $message);
24  }
global $DIC
Definition: saml.php:7
catch(Exception $e) $message
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ doUpdate()

ilDclStandardField::doUpdate ( )

Definition at line 37 of file class.ilDclStandardField.php.

References ilDclBaseFieldModel\updateTableFieldSetting().

Referenced by cloneStructure().

38  {
39  $this->updateTableFieldSetting();
40  }
updateTableFieldSetting()
update exportable and fieldorder
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fillHeaderExcel()

ilDclStandardField::fillHeaderExcel ( ilExcel  $worksheet,
$row,
$col 
)
Parameters
\ilExcel$worksheet
$row
$col

Definition at line 393 of file class.ilDclStandardField.php.

References $DIC, $lng, $row, ilDclBaseFieldModel\getId(), and ilExcel\setCell().

394  {
395  parent::fillHeaderExcel($worksheet, $row, $col);
396  if ($this->getId() == 'owner') {
397  global $DIC;
398  $lng = $DIC['lng'];
399  $worksheet->setCell($row, $col, $lng->txt("dcl_owner_name"));
400  $col++;
401  }
402  }
global $DIC
Definition: saml.php:7
$lng
setCell($a_row, $a_col, $a_value, $a_datatype=null)
Set cell value.
$row
+ Here is the call graph for this function:

◆ getLocked()

ilDclStandardField::getLocked ( )
Returns
bool

Definition at line 61 of file class.ilDclStandardField.php.

62  {
63  return true;
64  }

◆ getRecordQueryFilterObject()

ilDclStandardField::getRecordQueryFilterObject (   $filter_value = "",
ilDclBaseFieldModel  $sort_field = null 
)

Returns a query-object for building the record-loader-sql-query.

Parameters
string$filter_value
ilDclBaseFieldModel$sort_field
Returns
ilDclRecordQueryObject|null

Definition at line 301 of file class.ilDclStandardField.php.

References $DIC, $from, $ilDB, ilDclBaseFieldModel\getDatatypeId(), ilDclDatatype\INPUTFORMAT_DATETIME, ilDclDatatype\INPUTFORMAT_NUMBER, and ilDclDatatype\INPUTFORMAT_TEXT.

302  {
303  global $DIC;
304  $ilDB = $DIC['ilDB'];
305 
306  $where_additions = "";
307  $join_str = "";
309  $join_str = "INNER JOIN usr_data AS filter_usr_data_{$this->getId()} ON (filter_usr_data_{$this->getId()}.usr_id = record.{$this->getId()} AND filter_usr_data_{$this->getId()}.login LIKE "
310  . $ilDB->quote("%$filter_value%", 'text') . ") ";
311  } else {
313  $from = (isset($filter_value['from'])) ? $filter_value['from'] : null;
314  $to = (isset($filter_value['to'])) ? $filter_value['to'] : null;
315  if (is_numeric($from)) {
316  $where_additions .= " AND record.{$this->getId()} >= "
317  . $ilDB->quote($from, 'integer');
318  }
319  if (is_numeric($to)) {
320  $where_additions .= " AND record.{$this->getId()} <= "
321  . $ilDB->quote($to, 'integer');
322  }
323  } else {
325  $date_from = (isset($filter_value['from'])
326  && is_object($filter_value['from'])) ? $filter_value['from'] : null;
327  $date_to = (isset($filter_value['to'])
328  && is_object($filter_value['to'])) ? $filter_value['to'] : null;
329 
330  // db->quote(.. date) at some point invokes ilDate->_toString, which adds a <br /> to the string,
331  // that's why strip_tags is used
332  if ($date_from) {
333  $where_additions .= " AND (record.{$this->getId()} >= "
334  . strip_tags($ilDB->quote($date_from, 'date')) . ")";
335  }
336  if ($date_to) {
337  $where_additions .= " AND (record.{$this->getId()} <= "
338  . strip_tags($ilDB->quote($date_to, 'date')) . ")";
339  }
340  }
341  }
342  }
343 
344  $sql_obj = new ilDclRecordQueryObject();
345  $sql_obj->setJoinStatement($join_str);
346  $sql_obj->setWhereStatement($where_additions);
347 
348  return $sql_obj;
349  }
Class ilDclRecordQueryObject.
global $DIC
Definition: saml.php:7
$from
global $ilDB
getDatatypeId()
Get datatype_id.
+ Here is the call graph for this function:

◆ getRecordQuerySortObject()

ilDclStandardField::getRecordQuerySortObject (   $direction = "asc",
  $sort_by_status = false 
)

Returns a query-object for building the record-loader-sql-query.

Parameters
string$direction
boolean$sort_by_statusThe specific sort object is a status field
Returns
null|ilDclRecordQueryObject

Definition at line 270 of file class.ilDclStandardField.php.

References ilDclBaseFieldModel\getId().

271  {
272  $sql_obj = new ilDclRecordQueryObject();
273 
274  $join_str = "";
275  if ($this->getId() == 'owner' || $this->getId() == 'last_edit_by') {
276  $join_str = "LEFT JOIN usr_data AS sort_usr_data_{$this->getId()} ON (sort_usr_data_{$this->getId()}.usr_id = record.{$this->getId()})";
277  $select_str = " sort_usr_data_{$this->getId()}.login AS field_{$this->getId()},";
278  } else {
279  $select_str = " record.{$this->getId()} AS field_{$this->getId()},";
280  }
281 
282  $sql_obj->setSelectStatement($select_str);
283  $sql_obj->setJoinStatement($join_str);
284 
285  if ($this->getId() !== "comments") {
286  $sql_obj->setOrderStatement("field_{$this->getId()} " . $direction);
287  }
288 
289  return $sql_obj;
290  }
Class ilDclRecordQueryObject.
+ Here is the call graph for this function:

◆ getSortField()

ilDclStandardField::getSortField ( )
Returns
string

Definition at line 355 of file class.ilDclStandardField.php.

References ilDclBaseFieldModel\getId().

356  {
357  if ($this->getId() == 'comments') {
358  return 'n_comments';
359  }
360  return parent::getSortField();
361  }
+ Here is the call graph for this function:

◆ getValueFromExcel()

ilDclStandardField::getValueFromExcel (   $excel,
  $row,
  $col 
)
Parameters
$excelilExcel
$row
$col
Returns
mixed

Definition at line 412 of file class.ilDclStandardField.php.

References $row, and ilObjUser\_lookupId().

413  {
414  $value = $excel->getCell($row, $col);
415  switch ($this->id) {
416  case 'owner':
417  return ilObjUser::_lookupId($value);
418  default:
419  return $value;
420  }
421  }
static _lookupId($a_user_str)
Lookup id by login.
$row
+ Here is the call graph for this function:

◆ hasNumericSorting()

ilDclStandardField::hasNumericSorting ( )
Returns
bool

Definition at line 367 of file class.ilDclStandardField.php.

References ilDclBaseFieldModel\getId().

368  {
369  if ($this->getId() == 'comments') {
370  return true;
371  }
372 
373  return parent::hasNumericSorting();
374  }
+ Here is the call graph for this function:

◆ isStandardField()

ilDclStandardField::isStandardField ( )
Returns
bool

Definition at line 247 of file class.ilDclStandardField.php.

248  {
249  return true;
250  }

◆ isUnique()

ilDclStandardField::isUnique ( )
Returns
bool

Definition at line 256 of file class.ilDclStandardField.php.

257  {
258  return false;
259  }

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