ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 ()
 
 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)
 

Static Public Member Functions

static _getStandardFieldsAsArray ()
 
static _getStandardFields ($table_id)
 
static _getAllStandardFieldTitles ()
 
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 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

◆ _getAllStandardFieldTitles()

static ilDclStandardField::_getAllStandardFieldTitles ( )
static
Returns
array all possible standardfield titles, in all languages (used for excel-import);

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

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

Referenced by ilDclContentImporter\getImportFieldsFromTitles().

114  {
115  global $ilDB;
116  $identifiers = '';
117  foreach (array('dcl_id', 'dcl_creation_date', 'dcl_last_update', 'dcl_owner', 'dcl_last_edited_by', 'dcl_comments') as $id) {
118  $identifiers .= $ilDB->quote($id, 'text') . ',';
119  }
120  $identifiers = rtrim($identifiers, ',');
121  $sql = $ilDB->query('SELECT value FROM lng_data WHERE identifier IN (' . $identifiers . ')');
122  $titles = array();
123  while ($rec = $ilDB->fetchAssoc($sql)) {
124  $titles[] = $rec['value'];
125  }
126  return $titles;
127  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ _getDatatypeForId()

static ilDclStandardField::_getDatatypeForId (   $id)
static

gives you the datatype id of a specified standard field.

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

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

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

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

152  {
153  $datatype = null;
154  foreach (self::_getStandardFieldsAsArray() as $fields_data) {
155  if ($id == $fields_data['id']) {
156  $datatype = $fields_data['datatype_id'];
157  break;
158  }
159  }
160  return $datatype;
161  }
+ Here is the caller graph for this function:

◆ _getStandardFields()

static ilDclStandardField::_getStandardFields (   $table_id)
static

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

References ilDclBaseFieldModel\$table_id, and array.

Referenced by ilDclTable\getFirstTableViewId().

98  {
99  $stdFields = array();
100  foreach(self::_getStandardFieldsAsArray() as $array)
101  {
102  $array["table_id"] = $table_id;
103  //$array["datatype_id"] = self::_getDatatypeForId($array["id"]);
104  $field = new ilDclStandardField();
105  $field->buildFromDBRecord($array);
106  $stdFields[] = $field;
107  }
108  return $stdFields;
109  }
Class ilDclBaseFieldModel.
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ _getStandardFieldsAsArray()

static ilDclStandardField::_getStandardFieldsAsArray ( )
static

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

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

78  {
79 
80  //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.
81  global $DIC;
82  $lng = $DIC['lng'];
83  $stdfields = array(
84  array("id"=>"id", "title" => $lng->txt("dcl_id"), "description" => $lng->txt("dcl_id_description"), "datatype_id" => ilDclDatatype::INPUTFORMAT_NUMBER, "required" => true),
85  array("id"=>"create_date", "title" => $lng->txt("dcl_creation_date"), "description" => $lng->txt("dcl_creation_date_description"), "datatype_id" => ilDclDatatype::INPUTFORMAT_DATETIME, "required" => true),
86  array("id"=>"last_update", "title" => $lng->txt("dcl_last_update"), "description" => $lng->txt("dcl_last_update_description"), "datatype_id" => ilDclDatatype::INPUTFORMAT_DATETIME, "required" => true),
87  array("id"=>"owner", "title" => $lng->txt("dcl_owner"), "description" => $lng->txt("dcl_owner_description"), "datatype_id" => ilDclDatatype::INPUTFORMAT_TEXT, "required" => true),
88  array("id"=>"last_edit_by", "title" => $lng->txt("dcl_last_edited_by"), "description" => $lng->txt("dcl_last_edited_by_description"), "datatype_id" => ilDclDatatype::INPUTFORMAT_TEXT, "required" => true),
89  array('id' => 'comments', 'title' => $lng->txt('dcl_comments'), 'description' => $lng->txt('dcl_comments_desc'), 'datatype_id' => ilDclDatatype::INPUTFORMAT_NONE, 'required' => false),
90  );
91  return $stdfields;
92  }
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
global $DIC

◆ _isStandardField()

static ilDclStandardField::_isStandardField (   $field_id)
static

◆ afterClone()

ilDclStandardField::afterClone (   $records)
Parameters
$records

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

288  {
289  return; //0020762; afterClone of 'comments' leads to an error since comments has no datatype
290  }

◆ allowFilterInListView()

ilDclStandardField::allowFilterInListView ( )
Returns
bool

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

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

279  {
280  //comments are filterable if they are enabled in the tables settings
281  return $this->id != 'comments' || ilDclCache::getTableCache($this->getTableId())->getPublicCommentsEnabled();
282  }
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 56 of file class.ilDclStandardField.php.

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

56  {
57  $this->setLocked($original_record->getLocked());
58  $this->setOrder($original_record->getOrder());
59  $this->setRequired($original_record->getRequired());
60  $this->setUnique($original_record->isUnique());
61  $this->setExportable($original_record->getExportable());
62 
63  $this->doUpdate();
64  }
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:

◆ doCreate()

ilDclStandardField::doCreate ( )

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

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

36  {
37  global $DIC;
38  $ilLog = $DIC['ilLog'];
39  $message = "Standard fields cannot be written to DB";
40  ilUtil::sendFailure($message);
41  $ilLog->write("[ilDclStandardField] ".$message);
42  }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $DIC
+ Here is the call graph for this function:

◆ doRead()

ilDclStandardField::doRead ( )

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

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

24  {
25  global $DIC;
26  $ilLog = $DIC['ilLog'];
27  $message = "Standard fields cannot be read from DB";
28  ilUtil::sendFailure($message);
29  $ilLog->write("[ilDclStandardField] ".$message);
30  }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $DIC
+ Here is the call graph for this function:

◆ doUpdate()

ilDclStandardField::doUpdate ( )

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

References ilDclBaseFieldModel\updateTableFieldSetting().

Referenced by cloneStructure().

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

◆ getLocked()

ilDclStandardField::getLocked ( )

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

70  {
71  return true;
72  }

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

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

218  {
219  global $DIC;
220  $ilDB = $DIC['ilDB'];
221 
222  $where_additions = "";
223  $join_str = "";
225  $join_str =
226  "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 "
227  . $ilDB->quote("%$filter_value%", 'text') . ") ";
228 
229  } else if($this->getDatatypeId() == ilDclDatatype::INPUTFORMAT_NUMBER) {
230  $from = (isset($filter_value['from'])) ? $filter_value['from'] : NULL;
231  $to = (isset($filter_value['to'])) ? $filter_value['to'] : NULL;
232  if (is_numeric($from)) {
233  $where_additions .= " AND record.{$this->getId()} >= " . $ilDB->quote($from, 'integer');
234  }
235  if (is_numeric($to)) {
236  $where_additions .= " AND record.{$this->getId()} <= " . $ilDB->quote($to, 'integer');
237  }
238 
239  } else if ($this->getDatatypeId() == ilDclDatatype::INPUTFORMAT_DATETIME) {
240  $date_from = (isset($filter_value['from']) && is_object($filter_value['from'])) ? $filter_value['from'] : NULL;
241  $date_to = (isset($filter_value['to']) && is_object($filter_value['to'])) ? $filter_value['to'] : NULL;
242 
243  // db->quote(.. date) at some point invokes ilDate->_toString, which adds a <br /> to the string,
244  // that's why strip_tags is used
245  if ($date_from) {
246  $where_additions .= " AND (record.{$this->getId()} >= " . strip_tags($ilDB->quote($date_from, 'date')) . ")";
247  }
248  if ($date_to) {
249  $where_additions .= " AND (record.{$this->getId()} <= " . strip_tags($ilDB->quote($date_to, 'date')) . ")";
250  }
251 
252  }
253 
254  $sql_obj = new ilDclRecordQueryObject();
255  $sql_obj->setJoinStatement($join_str);
256  $sql_obj->setWhereStatement($where_additions);
257  return $sql_obj;
258  }
Class ilDclRecordQueryObject.
global $ilDB
global $DIC
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 188 of file class.ilDclStandardField.php.

References ilDclBaseFieldModel\getId().

188  {
189  $sql_obj = new ilDclRecordQueryObject();
190 
191  $join_str = "";
192  if ($this->getId() == 'owner' || $this->getId() == 'last_edit_by') {
193  $join_str = "LEFT JOIN usr_data AS sort_usr_data_{$this->getId()} ON (sort_usr_data_{$this->getId()}.usr_id = record.{$this->getId()})";
194  $select_str = " sort_usr_data_{$this->getId()}.login AS field_{$this->getId()},";
195  } else {
196  $select_str = " record.{$this->getId()} AS field_{$this->getId()},";
197  }
198 
199  $sql_obj->setSelectStatement($select_str);
200  $sql_obj->setJoinStatement($join_str);
201 
202  if($this->getId() !== "comments") {
203  $sql_obj->setOrderStatement("field_{$this->getId()} ".$direction);
204  }
205 
206  return $sql_obj;
207  }
Class ilDclRecordQueryObject.
+ Here is the call graph for this function:

◆ getSortField()

ilDclStandardField::getSortField ( )

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

References ilDclBaseFieldModel\getId().

261  {
262  if($this->getId() == 'comments') {
263  return 'n_comments';
264  }
265  }
+ Here is the call graph for this function:

◆ hasNumericSorting()

ilDclStandardField::hasNumericSorting ( )

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

References ilDclBaseFieldModel\getId().

268  {
269  if($this->getId() == 'comments') {
270  return true;
271  }
272 
273  return parent::hasNumericSorting();
274  }
+ Here is the call graph for this function:

◆ isStandardField()

ilDclStandardField::isStandardField ( )

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

167  {
168  return true;
169  }

◆ isUnique()

ilDclStandardField::isUnique ( )

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

175  {
176  return false;
177  }

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