ILIAS  release_7 Revision v7.30-3-g800a261c036
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...
 
 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...
 
 getViewSettings ()
 
 getViewSetting (int $tableview_id)
 
 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...
 
 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
 
 $order
 
 $unique
 
 $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 222 of file class.ilDclStandardField.php.

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

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

223  {
224  $datatype = null;
225  foreach (self::_getStandardFieldsAsArray() as $fields_data) {
226  if ($id == $fields_data['id']) {
227  $datatype = $fields_data['datatype_id'];
228  break;
229  }
230  }
231 
232  return $datatype;
233  }
+ 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 175 of file class.ilDclStandardField.php.

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

Referenced by ilDclContentImporter\getImportFieldsFromTitles().

176  {
177  global $DIC;
178  $ilDB = $DIC['ilDB'];
179  $identifiers = '';
180  foreach (array('dcl_owner') as $id) {
181  $identifiers .= $ilDB->quote($id, 'text') . ',';
182  }
183  $identifiers = rtrim($identifiers, ',');
184  $sql = $ilDB->query(
185  'SELECT value, identifier FROM lng_data WHERE identifier IN ('
186  . $identifiers . ')'
187  );
188  $titles = array();
189  while ($rec = $ilDB->fetchAssoc($sql)) {
190  $titles[$rec['identifier']][] = $rec['value'];
191  }
192 
193  return $titles;
194  }
global $DIC
Definition: goto.php:24
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 141 of file class.ilDclStandardField.php.

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

Referenced by ilDclContentImporter\getImportFieldsFromTitles().

142  {
143  global $DIC;
144  $ilDB = $DIC['ilDB'];
145  $identifiers = '';
146  foreach (
147  array(
148  'dcl_id',
149  'dcl_creation_date',
150  'dcl_last_update',
151  'dcl_last_edited_by',
152  'dcl_comments',
153  ) as $id
154  ) {
155  $identifiers .= $ilDB->quote($id, 'text') . ',';
156  }
157  $identifiers = rtrim($identifiers, ',');
158  $sql = $ilDB->query(
159  'SELECT value FROM lng_data WHERE identifier IN (' . $identifiers
160  . ')'
161  );
162  $titles = array();
163  while ($rec = $ilDB->fetchAssoc($sql)) {
164  $titles[] = $rec['value'];
165  }
166 
167  return $titles;
168  }
global $DIC
Definition: goto.php:24
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 122 of file class.ilDclStandardField.php.

References ilDclBaseFieldModel\$table_id.

Referenced by ilDclTable\getFirstTableViewId().

123  {
124  $stdFields = array();
125  foreach (self::_getStandardFieldsAsArray() as $array) {
126  $array["table_id"] = $table_id;
127  //$array["datatype_id"] = self::_getDatatypeForId($array["id"]);
128  $field = new ilDclStandardField();
129  $field->buildFromDBRecord($array);
130  $stdFields[] = $field;
131  }
132 
133  return $stdFields;
134  }
Class ilDclBaseFieldModel.
+ Here is the caller graph for this function:

◆ _getStandardFieldsAsArray()

static ilDclStandardField::_getStandardFieldsAsArray ( )
static
Returns
array

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

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

69  {
70 
71  //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.
72  global $DIC;
73  $lng = $DIC['lng'];
74  $stdfields = array(
75  array(
76  "id" => "id",
77  "title" => $lng->txt("dcl_id"),
78  "description" => $lng->txt("dcl_id_description"),
79  "datatype_id" => ilDclDatatype::INPUTFORMAT_NUMBER
80  ),
81  array(
82  "id" => "create_date",
83  "title" => $lng->txt("dcl_creation_date"),
84  "description" => $lng->txt("dcl_creation_date_description"),
86  ),
87  array(
88  "id" => "last_update",
89  "title" => $lng->txt("dcl_last_update"),
90  "description" => $lng->txt("dcl_last_update_description"),
92  ),
93  array(
94  "id" => "owner",
95  "title" => $lng->txt("dcl_owner"),
96  "description" => $lng->txt("dcl_owner_description"),
97  "datatype_id" => ilDclDatatype::INPUTFORMAT_TEXT
98  ),
99  array(
100  "id" => "last_edit_by",
101  "title" => $lng->txt("dcl_last_edited_by"),
102  "description" => $lng->txt("dcl_last_edited_by_description"),
103  "datatype_id" => ilDclDatatype::INPUTFORMAT_TEXT
104  ),
105  array(
106  'id' => 'comments',
107  'title' => $lng->txt('dcl_comments'),
108  'description' => $lng->txt('dcl_comments_desc'),
109  'datatype_id' => ilDclDatatype::INPUTFORMAT_NONE
110  ),
111  );
112 
113  return $stdfields;
114  }
$lng
global $DIC
Definition: goto.php:24

◆ _isStandardField()

static ilDclStandardField::_isStandardField (   $field_id)
static

◆ afterClone()

ilDclStandardField::afterClone (   $records)
Parameters
$records

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

421  {
422  }

◆ allowFilterInListView()

ilDclStandardField::allowFilterInListView ( )
Returns
bool

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

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

374  {
375  //comments are filterable if they are enabled in the tables settings
376  return $this->id != 'comments'
377  || ilDclCache::getTableCache($this->getTableId())->getPublicCommentsEnabled();
378  }
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\setOrder(), and ilDclBaseFieldModel\setUnique().

47  {
48  $this->setOrder($original_record->getOrder());
49  $this->setUnique($original_record->isUnique());
50  $this->setExportable($original_record->getExportable());
51 
52  $this->doUpdate();
53  }
+ Here is the call graph for this function:

◆ doCreate()

ilDclStandardField::doCreate ( )

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

References $DIC, $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: goto.php:24
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$message
Definition: xapiexit.php:14
+ Here is the call graph for this function:

◆ doRead()

ilDclStandardField::doRead ( )

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

References $DIC, $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: goto.php:24
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$message
Definition: xapiexit.php:14
+ 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 386 of file class.ilDclStandardField.php.

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

387  {
388  parent::fillHeaderExcel($worksheet, $row, $col);
389  if ($this->getId() == 'owner') {
390  global $DIC;
391  $lng = $DIC['lng'];
392  $worksheet->setCell($row, $col, $lng->txt("dcl_owner_name"));
393  $col++;
394  }
395  }
$lng
global $DIC
Definition: goto.php:24
setCell($a_row, $a_col, $a_value, $a_datatype=null)
Set cell value.
+ Here is the call graph for this function:

◆ getLocked()

ilDclStandardField::getLocked ( )
Returns
bool

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

60  {
61  return true;
62  }

◆ 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 293 of file class.ilDclStandardField.php.

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

294  {
295  global $DIC;
296  $ilDB = $DIC['ilDB'];
297 
298  $where_additions = "";
299  $join_str = "";
301  $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 "
302  . $ilDB->quote("%$filter_value%", 'text') . ") ";
303  } else {
305  $from = (isset($filter_value['from'])) ? $filter_value['from'] : null;
306  $to = (isset($filter_value['to'])) ? $filter_value['to'] : null;
307  if (is_numeric($from)) {
308  $where_additions .= " AND record.{$this->getId()} >= "
309  . $ilDB->quote($from, 'integer');
310  }
311  if (is_numeric($to)) {
312  $where_additions .= " AND record.{$this->getId()} <= "
313  . $ilDB->quote($to, 'integer');
314  }
315  } else {
317  $date_from = (isset($filter_value['from'])
318  && is_object($filter_value['from'])) ? $filter_value['from'] : null;
319  $date_to = (isset($filter_value['to'])
320  && is_object($filter_value['to'])) ? $filter_value['to'] : null;
321 
322  // db->quote(.. date) at some point invokes ilDate->_toString, which adds a <br /> to the string,
323  // that's why strip_tags is used
324  if ($date_from) {
325  $where_additions .= " AND (record.{$this->getId()} >= "
326  . strip_tags($ilDB->quote($date_from, 'date')) . ")";
327  }
328  if ($date_to) {
329  $where_additions .= " AND (record.{$this->getId()} <= "
330  . strip_tags($ilDB->quote($date_to, 'date')) . ")";
331  }
332  }
333  }
334  }
335 
336  $sql_obj = new ilDclRecordQueryObject();
337  $sql_obj->setJoinStatement($join_str);
338  $sql_obj->setWhereStatement($where_additions);
339 
340  return $sql_obj;
341  }
Class ilDclRecordQueryObject.
global $DIC
Definition: goto.php:24
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 262 of file class.ilDclStandardField.php.

References ilDclBaseFieldModel\getId().

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

◆ getSortField()

ilDclStandardField::getSortField ( )
Returns
string

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

References ilDclBaseFieldModel\getId(), and ilDclBaseFieldModel\getTitle().

348  {
349  if ($this->getId() == 'comments') {
350  return 'n_comments';
351  } else {
352  return $this->getTitle();
353  }
354  }
+ Here is the call graph for this function:

◆ getValueFromExcel()

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

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

References ilObjUser\_lookupId().

406  {
407  $value = $excel->getCell($row, $col);
408  switch ($this->id) {
409  case 'owner':
410  return ilObjUser::_lookupId($value);
411  default:
412  return $value;
413  }
414  }
static _lookupId($a_user_str)
Lookup id by login.
+ Here is the call graph for this function:

◆ hasNumericSorting()

ilDclStandardField::hasNumericSorting ( )
Returns
bool

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

References ilDclBaseFieldModel\getId().

361  {
362  if ($this->getId() == 'comments') {
363  return true;
364  }
365 
366  return parent::hasNumericSorting();
367  }
+ Here is the call graph for this function:

◆ isStandardField()

ilDclStandardField::isStandardField ( )
Returns
bool

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

240  {
241  return true;
242  }

◆ isUnique()

ilDclStandardField::isUnique ( )
Returns
bool

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

249  {
250  return false;
251  }

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