ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilBiblFieldFactory Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilBiblFieldFactory:
+ Collaboration diagram for ilBiblFieldFactory:

Public Member Functions

 __construct (\ilBiblTypeInterface $type)
 ilBiblFieldFactory constructor. More...
 
 getType ()
 
 getFieldByTypeAndIdentifier (int $type, string $identifier)
 
Parameters
int$typeMUST be ilBiblTypeFactoryInterface::DATA_TYPE_RIS or ilBiblTypeFactoryInterface::DATA_TYPE_BIBTEX
Exceptions
More...
 
 findOrCreateFieldByTypeAndIdentifier (int $type, string $identifier)
 
Parameters
int$typeMUST be ilBiblTypeFactoryInterface::DATA_TYPE_RIS or ilBiblTypeFactoryInterface::DATA_TYPE_BIBTEX
Exceptions
More...
 
 getAvailableFieldsForObjId (int $obj_id)
 
 filterAllFieldsForType (ilBiblTypeInterface $type, ilBiblTableQueryInfoInterface $queryInfo=null)
 
 filterAllFieldsForTypeAsArray (ilBiblTypeInterface $type, ilBiblTableQueryInfoInterface $queryInfo=null)
 
 findOrCreateFieldOfAttribute (ilBiblAttributeInterface $attribute)
 
 forcePosition (ilBiblFieldInterface $field)
 
- Public Member Functions inherited from ilBiblFieldFactoryInterface
 findById (int $id)
 

Protected Attributes

ilBiblTypeInterface $type
 

Private Member Functions

 getNextFreePosition (ilBiblFieldInterface $field)
 
 getARInstance (int $type, string $identifier)
 
 getCollectionForFilter (ilBiblTypeInterface $type, ilBiblTableQueryInfoInterface $queryInfo=null)
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilBiblFieldFactory

Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch

Definition at line 24 of file class.ilBiblFieldFactory.php.

Constructor & Destructor Documentation

◆ __construct()

ilBiblFieldFactory::__construct ( \ilBiblTypeInterface  $type)

ilBiblFieldFactory constructor.

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

References $type.

33  {
34  $this->type = $type;
35  }
ilBiblTypeInterface $type

Member Function Documentation

◆ filterAllFieldsForType()

ilBiblFieldFactory::filterAllFieldsForType ( ilBiblTypeInterface  $type,
ilBiblTableQueryInfoInterface  $queryInfo = null 
)

Implements ilBiblFieldFactoryInterface.

Definition at line 128 of file class.ilBiblFieldFactory.php.

References getCollectionForFilter().

128  : array
129  {
130  return $this->getCollectionForFilter($type, $queryInfo)->get();
131  }
getCollectionForFilter(ilBiblTypeInterface $type, ilBiblTableQueryInfoInterface $queryInfo=null)
+ Here is the call graph for this function:

◆ filterAllFieldsForTypeAsArray()

ilBiblFieldFactory::filterAllFieldsForTypeAsArray ( ilBiblTypeInterface  $type,
ilBiblTableQueryInfoInterface  $queryInfo = null 
)

Implements ilBiblFieldFactoryInterface.

Definition at line 137 of file class.ilBiblFieldFactory.php.

References getCollectionForFilter().

137  : array
138  {
139  return $this->getCollectionForFilter($type, $queryInfo)->getArray();
140  }
getCollectionForFilter(ilBiblTypeInterface $type, ilBiblTableQueryInfoInterface $queryInfo=null)
+ Here is the call graph for this function:

◆ findOrCreateFieldByTypeAndIdentifier()

ilBiblFieldFactory::findOrCreateFieldByTypeAndIdentifier ( int  $type,
string  $identifier 
)

Parameters
int$typeMUST be ilBiblTypeFactoryInterface::DATA_TYPE_RIS or ilBiblTypeFactoryInterface::DATA_TYPE_BIBTEX
Exceptions

Implements ilBiblFieldFactoryInterface.

Definition at line 83 of file class.ilBiblFieldFactory.php.

References getARInstance(), and getType().

Referenced by getAvailableFieldsForObjId().

84  {
85  $inst = $this->getARInstance($type, $identifier);
86  if ($inst === null) {
87  $inst = new ilBiblField();
88  $inst->setIdentifier($identifier);
89  $inst->setDataType($type);
90  $inst->setIsStandardField($this->getType()->isStandardField($identifier));
91  $inst->create();
92  }
93  $inst->setDataType($type);
94  $inst->setIdentifier($identifier);
95  $inst->setIsStandardField($this->getType()->isStandardField($identifier));
96  $inst->update();
97 
98  return $inst;
99  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilBiblTypeInterface $type
getARInstance(int $type, string $identifier)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findOrCreateFieldOfAttribute()

ilBiblFieldFactory::findOrCreateFieldOfAttribute ( ilBiblAttributeInterface  $attribute)

Implements ilBiblFieldFactoryInterface.

Definition at line 146 of file class.ilBiblFieldFactory.php.

References ilBiblAttributeInterface\getName(), and ActiveRecord\where().

147  {
148  $field = ilBiblField::where(['identifier' => $attribute->getName()])->first();
149  if ($field === null) {
150  $field = new ilBiblField();
151  $field->setIdentifier($attribute->getName());
152  $field->setDataType($this->type->getId());
153  $field->setIsStandardField($this->type->isStandardField($attribute->getName()));
154  $field->create();
155  } else {
156  $field->setDataType($this->type->getId());
157  $field->update();
158  }
159 
160  return $field;
161  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static where($where, $operator=null)
+ Here is the call graph for this function:

◆ forcePosition()

ilBiblFieldFactory::forcePosition ( ilBiblFieldInterface  $field)

Implements ilBiblFieldFactoryInterface.

Definition at line 167 of file class.ilBiblFieldFactory.php.

References $DIC, ilBiblFieldInterface\getDataType(), ilBiblFieldInterface\getPosition(), ilBiblFieldInterface\store(), and ilBiblField\TABLE_NAME.

167  : int
168  {
169  global $DIC;
170  $tablename = ilBiblField::TABLE_NAME;
171  $q = "UPDATE {$tablename} SET position = position + 1 WHERE data_type = %s AND position >= %s;";
172  $DIC->database()->manipulateF(
173  $q,
174  ['integer', 'integer'],
175  [
176  $field->getDataType(),
177  $field->getPosition(),
178  ]
179  );
180  $field->store();
181  $DIC->database()->query("SET @i=0");
182  $DIC->database()->manipulateF(
183  "UPDATE {$tablename} SET position = (@i := @i + 1) WHERE data_type = %s ORDER BY position",
184  ['integer'],
185  [
186  $field->getDataType(),
187  ]
188  );
189 
190  return (int) $field->getPosition();
191  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

◆ getARInstance()

ilBiblFieldFactory::getARInstance ( int  $type,
string  $identifier 
)
private

Definition at line 213 of file class.ilBiblFieldFactory.php.

References ActiveRecord\where().

Referenced by findOrCreateFieldByTypeAndIdentifier(), and getFieldByTypeAndIdentifier().

213  : ?\ilBiblField
214  {
215  return ilBiblField::where(["identifier" => $identifier, "data_type" => $type])->first();
216  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilBiblTypeInterface $type
static where($where, $operator=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAvailableFieldsForObjId()

ilBiblFieldFactory::getAvailableFieldsForObjId ( int  $obj_id)

Implements ilBiblFieldFactoryInterface.

Definition at line 105 of file class.ilBiblFieldFactory.php.

References $d, $data, $DIC, and findOrCreateFieldByTypeAndIdentifier().

105  : array
106  {
107  global $DIC;
108  $sql
109  = "SELECT DISTINCT(il_bibl_attribute.name), il_bibl_data.file_type FROM il_bibl_data
110  JOIN il_bibl_entry ON il_bibl_entry.data_id = il_bibl_data.id
111  JOIN il_bibl_attribute ON il_bibl_attribute.entry_id = il_bibl_entry.id
112  WHERE il_bibl_data.id = %s;";
113 
114  $result = $DIC->database()->queryF($sql, ['integer'], [$obj_id]);
115 
116  $data = [];
117  while ($d = $DIC->database()->fetchObject($result)) {
118  $data[] = $this->findOrCreateFieldByTypeAndIdentifier($d->file_type, $d->name);
119  }
120 
121  return $data;
122  }
global $DIC
Definition: feed.php:28
findOrCreateFieldByTypeAndIdentifier(int $type, string $identifier)
MUST be ilBiblTypeFactoryInterface::DATA_TYPE_RIS or ilBiblTypeFactoryInterface::DATA_TYPE_BIBTEX ...
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
+ Here is the call graph for this function:

◆ getCollectionForFilter()

ilBiblFieldFactory::getCollectionForFilter ( ilBiblTypeInterface  $type,
ilBiblTableQueryInfoInterface  $queryInfo = null 
)
private

Definition at line 219 of file class.ilBiblFieldFactory.php.

References ActiveRecord\getCollection(), and ilBiblTypeInterface\getId().

Referenced by filterAllFieldsForType(), and filterAllFieldsForTypeAsArray().

220  {
221  $collection = ilBiblField::getCollection();
222 
223  $collection->where(array('data_type' => $type->getId()));
224 
225  if ($queryInfo) {
226  $sorting_column = $queryInfo->getSortingColumn() ? $queryInfo->getSortingColumn() : null;
227  $offset = $queryInfo->getOffset() ? $queryInfo->getOffset() : 0;
228  $sorting_direction = $queryInfo->getSortingDirection();
229  $limit = $queryInfo->getLimit();
230  if ($sorting_column) {
231  $collection->orderBy($sorting_column, $sorting_direction);
232  }
233  $collection->limit($offset, $limit);
234 
235  foreach ($queryInfo->getFilters() as $queryFilter) {
236  switch ($queryFilter->getFieldName()) {
237  default:
238  $collection->where(array($queryFilter->getFieldName() => $queryFilter->getFieldValue()), $queryFilter->getOperator());
239  break;
240  }
241  }
242  }
243 
244  return $collection;
245  }
NullPointerExceptionInspection
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFieldByTypeAndIdentifier()

ilBiblFieldFactory::getFieldByTypeAndIdentifier ( int  $type,
string  $identifier 
)

Parameters
int$typeMUST be ilBiblTypeFactoryInterface::DATA_TYPE_RIS or ilBiblTypeFactoryInterface::DATA_TYPE_BIBTEX
Exceptions

PhpIncompatibleReturnTypeInspection

Implements ilBiblFieldFactoryInterface.

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

References getARInstance().

69  {
70  $inst = $this->getARInstance($type, $identifier);
71  if (!$inst) {
72  throw new ilException("bibliografic identifier {$identifier} not found");
73  }
74 
76  return $inst;
77  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilBiblTypeInterface $type
getARInstance(int $type, string $identifier)
+ Here is the call graph for this function:

◆ getNextFreePosition()

ilBiblFieldFactory::getNextFreePosition ( ilBiblFieldInterface  $field)
private
Parameters
ilBiblFieldInterface$field
Returns
int

Definition at line 201 of file class.ilBiblFieldFactory.php.

References $data, $DIC, $res, ilBiblFieldInterface\getDataType(), and ilBiblField\TABLE_NAME.

201  : int
202  {
203  global $DIC;
204  $tablename = ilBiblField::TABLE_NAME;
205  $q = "SELECT MAX(position) + 1 as next_position FROM {$tablename} WHERE data_type = %s;";
206  $res = $DIC->database()->queryF($q, ['integer'], [$field->getDataType()]);
207  $data = $DIC->database()->fetchObject($res);
208 
209  return (int) $data->next_position;
210  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

◆ getType()

ilBiblFieldFactory::getType ( )

Implements ilBiblFieldFactoryInterface.

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

References $id, $type, ilBiblFieldFactoryInterface\findById(), and ActiveRecord\findOrFail().

Referenced by findOrCreateFieldByTypeAndIdentifier().

42  {
43  return $this->type;
44  }
ilBiblTypeInterface $type
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $type

ilBiblTypeInterface ilBiblFieldFactory::$type
protected

Definition at line 26 of file class.ilBiblFieldFactory.php.

Referenced by __construct(), and getType().


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