ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilDclStandardField Class Reference
+ Inheritance diagram for ilDclStandardField:
+ Collaboration diagram for ilDclStandardField:

Public Member Functions

 __construct ($a_id=0)
 
 doRead ()
 
 doCreate ()
 
 doUpdate ()
 
 clone (ilDclStandardField $original_record)
 
 getLocked ()
 
 isStandardField ()
 
 getRecordQuerySortObject (string $direction="asc", bool $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, int &$row, int &$col)
 
 getValueFromExcel (ilExcel $excel, int $row, int $col)
 
 afterClone ($records)
 
- Public Member Functions inherited from ilDclBaseFieldModel
 __construct (int $a_id=0)
 
 setId ($a_id)
 Set field id. More...
 
 getId ()
 Get field id. More...
 
 setTableId (int $a_id)
 Set table id. More...
 
 getTableId ()
 Get table id. More...
 
 setTitle (string $a_title)
 Set title. More...
 
 getTitle ()
 Get title. More...
 
 setDescription (string $a_desc)
 Set description. More...
 
 getDescription ()
 Get description. More...
 
 setDatatypeId (int $a_id)
 Set datatype id. More...
 
 getDatatypeId ()
 Get datatype_id. More...
 
 getDatatype ()
 
 getDatatypeTitle ()
 
 getPresentationTitle ()
 
 getPresentationDescription ()
 
 getStorageLocation ()
 Get storage location for the model. More...
 
 getExportable ()
 
 toArray ()
 
 isStandardField ()
 
 doRead ()
 
 buildFromDBRecord (array $rec)
 Builds model from db record. More...
 
 doCreate ()
 
 doUpdate ()
 
 updateProperties ()
 Update properties of this field in Database. More...
 
 doDelete ()
 Remove field and properties. More...
 
 getViewSettings ()
 
 getViewSetting (int $tableview_id)
 
 getOrder ()
 
 setOrder (int $order)
 
 hasProperty (string $key)
 Checks if a certain property for a field is set. More...
 
 getProperty (string $key)
 
 getPropertyInstance (string $key)
 
 setProperty (string $key, $value)
 
 getValidFieldProperties ()
 Returns all valid properties for a field-type. More...
 
 checkValidityFromForm (ilPropertyFormGUI &$form, ?int $record_id)
 
 checkValidity ($value, ?int $record_id)
 Check if input is valid. More...
 
 cloneStructure (int $original_id)
 
 afterClone (array $records)
 
 cloneProperties (ilDclBaseFieldModel $originalField)
 
 setExportable (bool $exportable)
 
 allowFilterInListView ()
 
 getRecordQuerySortObject (string $direction="asc", bool $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...
 
 checkUniqueProp (ilPropertyFormGUI $form)
 
 checkUnique ($value, ?int $record_id)
 
 getStorageLocationOverride ()
 
 setStorageLocationOverride (?int $storage_location_override)
 
 fillHeaderExcel (ilExcel $worksheet, int &$row, int &$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 (int $table_id)
 
static _getNonImportableStandardFieldTitles ()
 
static _getImportableStandardFieldTitle ()
 
static _isStandardField ($field_id)
 
static _getDatatypeForId (string $id)
 gives you the datatype id of a specified standard field. More...
 
- Static Public Member Functions inherited from ilDclBaseFieldModel
static _getTitleInvalidChars (bool $a_as_regex=true)
 All valid chars for filed titles. More...
 
static _getFieldIdByTitle (string $title, int $table_id)
 

Private Attributes

ilGlobalTemplateInterface $main_tpl
 

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_REFERENCE_LINK = "reference_link"
 
const PROP_UNIQUE = "unique"
 
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_text"
 
const PROP_LINK_DETAIL_PAGE_MOB = "link_detail_page_mob"
 
const PROP_SUPPORTED_FILE_TYPES = "supported_file_types"
 
const PROP_PLUGIN_HOOK_NAME = "plugin_hook_name"
 
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...
 
 areEqual ($value_1, $value_2)
 
 normalizeValue (mixed $value)
 
- Protected Attributes inherited from ilDclBaseFieldModel
string $id = ""
 
int $table_id = 0
 
string $title = ""
 
string $description = ""
 
int $datatype_id = 0
 
int $order = null
 
array $property = []
 
bool $exportable = false
 
ilDclDatatype $datatype = null
 
int $storage_location_override = null
 With this property the datatype-storage-location can be overwritten. More...
 
ilDBInterface $db
 
ilLanguage $lng
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilDclStandardField::__construct (   $a_id = 0)

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

References $DIC, and ILIAS\GlobalScreen\Provider\__construct().

26  {
27  parent::__construct($a_id);
28  global $DIC;
29  $this->main_tpl = $DIC->ui()->mainTemplate();
30  }
global $DIC
Definition: shib_login.php:26
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ _getDatatypeForId()

static ilDclStandardField::_getDatatypeForId ( string  $id)
static

gives you the datatype id of a specified standard field.

Parameters
string$idthe id of the standardfield eg. "create_date"

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

References ilDclBaseFieldModel\$id.

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

204  : ?int
205  {
206  return self::_getStandardFieldsAsArray()[$id]['datatype_id'];
207  }
+ 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 164 of file class.ilDclStandardField.php.

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

Referenced by ilDclContentImporter\getImportFieldsFromTitles().

164  : array
165  {
166  global $DIC;
167  $ilDB = $DIC['ilDB'];
168  $identifiers = '';
169  $id = 'dcl_owner';
170  $identifiers .= $ilDB->quote($id, 'text') . ',';
171  $identifiers = rtrim($identifiers, ',');
172  $sql = $ilDB->query(
173  'SELECT value, identifier FROM lng_data WHERE identifier IN ('
174  . $identifiers . ')'
175  );
176  $titles = [];
177  while ($rec = $ilDB->fetchAssoc($sql)) {
178  $titles[$rec['identifier']][] = $rec['value'];
179  }
180 
181  return $titles;
182  }
global $DIC
Definition: shib_login.php:26
+ 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 131 of file class.ilDclStandardField.php.

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

Referenced by ilDclContentImporter\getImportFieldsFromTitles().

131  : array
132  {
133  global $DIC;
134  $ilDB = $DIC['ilDB'];
135  $identifiers = '';
136  foreach (
137  [
138  'dcl_id',
139  'dcl_creation_date',
140  'dcl_last_update',
141  'dcl_last_edited_by',
142  'dcl_comments',
143  ] as $id
144  ) {
145  $identifiers .= $ilDB->quote($id, 'text') . ',';
146  }
147  $identifiers = rtrim($identifiers, ',');
148  $sql = $ilDB->query(
149  'SELECT value FROM lng_data WHERE identifier IN (' . $identifiers
150  . ')'
151  );
152  $titles = [];
153  while ($rec = $ilDB->fetchAssoc($sql)) {
154  $titles[] = $rec['value'];
155  }
156 
157  return $titles;
158  }
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ _getStandardFields()

static ilDclStandardField::_getStandardFields ( int  $table_id)
static

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

References ilDclBaseFieldModel\$table_id.

Referenced by ilDclTable\getFieldsForFormula().

114  : array
115  {
116  $stdFields = [];
117  foreach (self::_getStandardFieldsAsArray() as $array) {
118  $array["table_id"] = $table_id;
119  $field = new ilDclStandardField();
120  $field->buildFromDBRecord($array);
121  $stdFields[] = $field;
122  }
123 
124  return $stdFields;
125  }
+ Here is the caller graph for this function:

◆ _getStandardFieldsAsArray()

static ilDclStandardField::_getStandardFieldsAsArray ( )
static

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

References $DIC, ilDclBaseFieldModel\$lng, ilDclDatatype\INPUTFORMAT_DATETIME, ilDclDatatype\INPUTFORMAT_NUMBER, ilDclDatatype\INPUTFORMAT_TEXT, and ilLanguage\txt().

68  : array
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->language();
74  return [
75  "id" => [
76  "id" => "id",
77  "title" => $lng->txt("dcl_id"),
78  "description" => $lng->txt("dcl_id_description"),
79  "datatype_id" => ilDclDatatype::INPUTFORMAT_NUMBER
80  ],
81  "create_date" => [
82  "id" => "create_date",
83  "title" => $lng->txt("dcl_creation_date"),
84  "description" => $lng->txt("dcl_creation_date_description"),
86  ],
87  "last_update" => [
88  "id" => "last_update",
89  "title" => $lng->txt("dcl_last_update"),
90  "description" => $lng->txt("dcl_last_update_description"),
92  ],
93  "owner" => [
94  "id" => "owner",
95  "title" => $lng->txt("dcl_owner"),
96  "description" => $lng->txt("dcl_owner_description"),
97  "datatype_id" => ilDclDatatype::INPUTFORMAT_TEXT
98  ],
99  "last_edit_by" => [
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  'comments' => [
106  'id' => 'comments',
107  'title' => $lng->txt('dcl_comments'),
108  'description' => $lng->txt('dcl_comments_desc'),
109  'datatype_id' => ilDclDatatype::INPUTFORMAT_TEXT
110  ],
111  ];
112  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
global $DIC
Definition: shib_login.php:26
+ Here is the call graph for this function:

◆ _isStandardField()

static ilDclStandardField::_isStandardField (   $field_id)
static
Parameters
int | string$field_id
Returns
bool

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

Referenced by ilDclTableView\createFieldSetting(), ilDclBaseRecordModel\fillRecordFieldExcelExport(), ilDclBaseRecordModel\fillRecordFieldFormInput(), ilDclBaseRecordModel\getRecordFieldFormulaValue(), ilDclBaseRecordModel\getRecordFieldHTML(), ilDclBaseRecordModel\getRecordFieldValue(), ilDclBaseRecordModel\setRecordFieldValue(), and ilDclBaseRecordModel\setRecordFieldValueFromForm().

188  : bool
189  {
190  $return = false;
191  foreach (self::_getStandardFieldsAsArray() as $field) {
192  if ($field["id"] == $field_id) {
193  $return = true;
194  }
195  }
196 
197  return $return;
198  }
+ Here is the caller graph for this function:

◆ afterClone()

ilDclStandardField::afterClone (   $records)
Parameters
$records

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

350  {
351  }

◆ allowFilterInListView()

ilDclStandardField::allowFilterInListView ( )

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

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

314  : bool
315  {
316  //comments are filterable if they are enabled in the tables settings
317  return $this->id != 'comments'
318  || ilDclCache::getTableCache($this->getTableId())->getPublicCommentsEnabled();
319  }
static getTableCache(?int $table_id=null)
+ Here is the call graph for this function:

◆ clone()

ilDclStandardField::clone ( ilDclStandardField  $original_record)

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

References doUpdate(), ilDclBaseFieldModel\getExportable(), ilDclBaseFieldModel\getOrder(), ilDclBaseFieldModel\setExportable(), and ilDclBaseFieldModel\setOrder().

55  : void
56  {
57  $this->setOrder($original_record->getOrder());
58  $this->setExportable($original_record->getExportable());
59 
60  $this->doUpdate();
61  }
+ Here is the call graph for this function:

◆ doCreate()

ilDclStandardField::doCreate ( )

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

References $DIC, and $message.

41  : void
42  {
43  global $DIC;
44  $ilLog = $DIC['ilLog'];
45  $message = "Standard fields cannot be written to DB";
46  $this->main_tpl->setOnScreenMessage('failure', $message);
47  $ilLog->write("[ilDclStandardField] " . $message);
48  }
global $DIC
Definition: shib_login.php:26
$message
Definition: xapiexit.php:31

◆ doRead()

ilDclStandardField::doRead ( )

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

References $DIC, and $message.

32  : void
33  {
34  global $DIC;
35  $ilLog = $DIC['ilLog'];
36  $message = "Standard fields cannot be read from DB";
37  $this->main_tpl->setOnScreenMessage('failure', $message);
38  $ilLog->write("[ilDclStandardField] " . $message);
39  }
global $DIC
Definition: shib_login.php:26
$message
Definition: xapiexit.php:31

◆ doUpdate()

ilDclStandardField::doUpdate ( )

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

References ilDclBaseFieldModel\updateTableFieldSetting().

Referenced by clone().

50  : void
51  {
52  $this->updateTableFieldSetting();
53  }
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,
int &  $row,
int &  $col 
)

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

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

321  : void
322  {
323  parent::fillHeaderExcel($worksheet, $row, $col);
324  if ($this->getId() == 'owner') {
325  global $DIC;
326  $lng = $DIC['lng'];
327  $worksheet->setCell($row, $col, $lng->txt("dcl_owner_name"));
328  $col++;
329  }
330  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
setCell(int $a_row, int $col, $value, ?string $datatype=null, bool $disable_strip_tags_for_strings=false)
Set cell value.
global $DIC
Definition: shib_login.php:26
+ Here is the call graph for this function:

◆ getLocked()

ilDclStandardField::getLocked ( )

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

63  : bool
64  {
65  return true;
66  }

◆ getRecordQueryFilterObject()

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

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

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

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

248  global $DIC;
249  $ilDB = $DIC['ilDB'];
250 
251  $where_additions = "";
252  $join_str = "";
254  $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 "
255  . $ilDB->quote("%$filter_value%", 'text') . ") ";
256  } else {
258  $from = (isset($filter_value['from'])) ? $filter_value['from'] : null;
259  $to = (isset($filter_value['to'])) ? $filter_value['to'] : null;
260  if (is_numeric($from)) {
261  $where_additions .= " AND record.{$this->getId()} >= "
262  . $ilDB->quote($from, 'integer');
263  }
264  if (is_numeric($to)) {
265  $where_additions .= " AND record.{$this->getId()} <= "
266  . $ilDB->quote($to, 'integer');
267  }
268  } else {
270  $date_from = (isset($filter_value['from'])
271  && is_object($filter_value['from'])) ? $filter_value['from'] : null;
272  $date_to = (isset($filter_value['to'])
273  && is_object($filter_value['to'])) ? $filter_value['to'] : null;
274 
275  // db->quote(.. date) at some point invokes ilDate->_toString, which adds a <br /> to the string,
276  // that's why strip_tags is used
277  if ($date_from) {
278  $where_additions .= " AND (record.{$this->getId()} >= "
279  . strip_tags($ilDB->quote($date_from, 'date')) . ")";
280  }
281  if ($date_to) {
282  $where_additions .= " AND (record.{$this->getId()} <= "
283  . strip_tags($ilDB->quote($date_to, 'date')) . ")";
284  }
285  }
286  }
287  }
288 
289  $sql_obj = new ilDclRecordQueryObject();
290  $sql_obj->setJoinStatement($join_str);
291  $sql_obj->setWhereStatement($where_additions);
292 
293  return $sql_obj;
294  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:26
getDatatypeId()
Get datatype_id.
+ Here is the call graph for this function:

◆ getRecordQuerySortObject()

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

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

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

References ilDclBaseFieldModel\getId().

221  $sql_obj = new ilDclRecordQueryObject();
222 
223  $join_str = "";
224  if ($this->getId() == 'owner' || $this->getId() == 'last_edit_by') {
225  $join_str = "LEFT JOIN usr_data AS sort_usr_data_{$this->getId()} ON (sort_usr_data_{$this->getId()}.usr_id = record.{$this->getId()})";
226  $select_str = " sort_usr_data_{$this->getId()}.login AS field_{$this->getId()},";
227  } else {
228  $select_str = " record.{$this->getId()} AS field_{$this->getId()},";
229  }
230 
231  $sql_obj->setSelectStatement($select_str);
232  $sql_obj->setJoinStatement($join_str);
233 
234  if ($this->getId() !== "comments") {
235  $sql_obj->setOrderStatement("field_{$this->getId()} " . $direction);
236  }
237 
238  return $sql_obj;
239  }
+ Here is the call graph for this function:

◆ getSortField()

ilDclStandardField::getSortField ( )

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

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

296  : string
297  {
298  if ($this->getId() == 'comments') {
299  return 'n_comments';
300  } else {
301  return $this->getTitle();
302  }
303  }
+ Here is the call graph for this function:

◆ getValueFromExcel()

ilDclStandardField::getValueFromExcel ( ilExcel  $excel,
int  $row,
int  $col 
)
Returns
string|int

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

References ilObjUser\_lookupId(), and ilExcel\getCell().

336  {
337  $value = $excel->getCell($row, $col);
338  switch ($this->id) {
339  case 'owner':
340  return ilObjUser::_lookupId($value);
341  default:
342  return $value;
343  }
344  }
static _lookupId($a_user_str)
getCell(int $a_row, int $a_col)
Returns the value of a cell.
+ Here is the call graph for this function:

◆ hasNumericSorting()

ilDclStandardField::hasNumericSorting ( )

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

References ilDclBaseFieldModel\getId().

305  : bool
306  {
307  if ($this->getId() == 'comments') {
308  return true;
309  }
310 
311  return parent::hasNumericSorting();
312  }
+ Here is the call graph for this function:

◆ isStandardField()

ilDclStandardField::isStandardField ( )

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

209  : bool
210  {
211  return true;
212  }

Field Documentation

◆ $main_tpl

ilGlobalTemplateInterface ilDclStandardField::$main_tpl
private

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


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