ILIAS  release_8 Revision v8.24
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

ilException if a wrong $type is passed or field is not found More...

 
 findOrCreateFieldByTypeAndIdentifier (int $type, string $identifier)
 
Parameters
int$typeMUST be ilBiblTypeFactoryInterface::DATA_TYPE_RIS or ilBiblTypeFactoryInterface::DATA_TYPE_BIBTEX
Exceptions

ilException if a wrong $type is passed More...

 
 getAvailableFieldsForObjId (int $obj_id)
 @inheritDoc More...
 
 filterAllFieldsForType (ilBiblTypeInterface $type, ilBiblTableQueryInfoInterface $queryInfo=null)
 @inheritDoc More...
 
 filterAllFieldsForTypeAsArray (ilBiblTypeInterface $type, ilBiblTableQueryInfoInterface $queryInfo=null)
 @inheritDoc More...
 
 findOrCreateFieldOfAttribute (ilBiblAttributeInterface $attribute)
 @inheritDoc More...
 
 forcePosition (ilBiblFieldInterface $field)
 @inheritDoc More...
 
- Public Member Functions inherited from ilBiblFieldFactoryInterface
 getFieldByTypeAndIdentifier (int $type, string $identifier)
 
 findOrCreateFieldByTypeAndIdentifier (int $type, string $identifier)
 
 getAvailableFieldsForObjId (int $obj_id)
 
 filterAllFieldsForType (ilBiblTypeInterface $type, ilBiblTableQueryInfoInterface $queryInfo=null)
 
 filterAllFieldsForTypeAsArray (ilBiblTypeInterface $type, ilBiblTableQueryInfoInterface $queryInfo=null)
 
 getType ()
 
 findById (int $id)
 
 findOrCreateFieldOfAttribute (ilBiblAttributeInterface $attribute)
 
 forcePosition (ilBiblFieldInterface $field)
 

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.

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

References $type.

Member Function Documentation

◆ filterAllFieldsForType()

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

@inheritDoc

Implements ilBiblFieldFactoryInterface.

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

128 : array
129 {
130 return $this->getCollectionForFilter($type, $queryInfo)->get();
131 }
getCollectionForFilter(ilBiblTypeInterface $type, ilBiblTableQueryInfoInterface $queryInfo=null)

References getCollectionForFilter().

+ Here is the call graph for this function:

◆ filterAllFieldsForTypeAsArray()

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

@inheritDoc

Implements ilBiblFieldFactoryInterface.

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

137 : array
138 {
139 return $this->getCollectionForFilter($type, $queryInfo)->getArray();
140 }

References getCollectionForFilter().

+ 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

ilException if a wrong $type is passed

Implements ilBiblFieldFactoryInterface.

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

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 }
getARInstance(int $type, string $identifier)
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...

References $type, getARInstance(), and getType().

Referenced by getAvailableFieldsForObjId().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findOrCreateFieldOfAttribute()

ilBiblFieldFactory::findOrCreateFieldOfAttribute ( ilBiblAttributeInterface  $attribute)

@inheritDoc

Implements ilBiblFieldFactoryInterface.

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

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 }
static where($where, $operator=null)

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

+ Here is the call graph for this function:

◆ forcePosition()

ilBiblFieldFactory::forcePosition ( ilBiblFieldInterface  $field)

@inheritDoc

Implements ilBiblFieldFactoryInterface.

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

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

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

+ 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.

213 : ?\ilBiblField
214 {
215 return ilBiblField::where(["identifier" => $identifier, "data_type" => $type])->first();
216 }

References $type, and ActiveRecord\where().

Referenced by findOrCreateFieldByTypeAndIdentifier(), and getFieldByTypeAndIdentifier().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAvailableFieldsForObjId()

ilBiblFieldFactory::getAvailableFieldsForObjId ( int  $obj_id)

@inheritDoc

Implements ilBiblFieldFactoryInterface.

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

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 }
findOrCreateFieldByTypeAndIdentifier(int $type, string $identifier)
ilException if a wrong $type is passed
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296

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

+ 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.

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 }
@noinspection NullPointerExceptionInspection

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

Referenced by filterAllFieldsForType(), and filterAllFieldsForTypeAsArray().

+ 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

ilException if a wrong $type is passed or field is not found

@noinspection PhpIncompatibleReturnTypeInspection

Implements ilBiblFieldFactoryInterface.

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

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...

References getARInstance().

+ 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.

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

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

+ Here is the call graph for this function:

◆ getType()

ilBiblFieldFactory::getType ( )

Implements ilBiblFieldFactoryInterface.

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

42 {
43 return $this->type;
44 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $type.

Referenced by findOrCreateFieldByTypeAndIdentifier().

+ Here is the caller graph for this function:

Field Documentation

◆ $type


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