ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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 (protected \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)
 

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 ( protected \ilBiblTypeInterface  $type)

ilBiblFieldFactory constructor.

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

30  {
31  }

Member Function Documentation

◆ filterAllFieldsForType()

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

Implements ilBiblFieldFactoryInterface.

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

References getCollectionForFilter().

124  : array
125  {
126  return $this->getCollectionForFilter($type, $queryInfo)->get();
127  }
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 133 of file class.ilBiblFieldFactory.php.

References getCollectionForFilter().

133  : array
134  {
135  return $this->getCollectionForFilter($type, $queryInfo)->getArray();
136  }
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 79 of file class.ilBiblFieldFactory.php.

References getARInstance(), getType(), and null.

Referenced by getAvailableFieldsForObjId().

80  {
81  $inst = $this->getARInstance($type, $identifier);
82  if ($inst === null) {
83  $inst = new ilBiblField();
84  $inst->setIdentifier($identifier);
85  $inst->setDataType($type);
86  $inst->setIsStandardField($this->getType()->isStandardField($identifier));
87  $inst->create();
88  }
89  $inst->setDataType($type);
90  $inst->setIdentifier($identifier);
91  $inst->setIsStandardField($this->getType()->isStandardField($identifier));
92  $inst->update();
93 
94  return $inst;
95  }
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...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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 142 of file class.ilBiblFieldFactory.php.

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

143  {
144  $field = ilBiblField::where(['identifier' => $attribute->getName()])->first();
145  if ($field === null) {
146  $field = new ilBiblField();
147  $field->setIdentifier($attribute->getName());
148  $field->setDataType($this->type->getId());
149  $field->setIsStandardField($this->type->isStandardField($attribute->getName()));
150  $field->create();
151  } else {
152  $field->setDataType($this->type->getId());
153  $field->update();
154  }
155 
156  return $field;
157  }
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)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ forcePosition()

ilBiblFieldFactory::forcePosition ( ilBiblFieldInterface  $field)

Implements ilBiblFieldFactoryInterface.

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

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

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

◆ getARInstance()

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

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

References ActiveRecord\where().

Referenced by findOrCreateFieldByTypeAndIdentifier(), and getFieldByTypeAndIdentifier().

209  : ?\ilBiblField
210  {
211  return ilBiblField::where(["identifier" => $identifier, "data_type" => $type])->first();
212  }
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:
+ Here is the caller graph for this function:

◆ getAvailableFieldsForObjId()

ilBiblFieldFactory::getAvailableFieldsForObjId ( int  $obj_id)

Implements ilBiblFieldFactoryInterface.

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

References Vendor\Package\$d, $data, $DIC, and findOrCreateFieldByTypeAndIdentifier().

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

◆ getCollectionForFilter()

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

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

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

Referenced by filterAllFieldsForType(), and filterAllFieldsForTypeAsArray().

216  {
217  $collection = ilBiblField::getCollection();
218 
219  $collection->where(['data_type' => $type->getId()]);
220 
221  if ($queryInfo !== null) {
222  $sorting_column = $queryInfo->getSortingColumn() !== '' && $queryInfo->getSortingColumn() !== '0' ? $queryInfo->getSortingColumn() : null;
223  $offset = $queryInfo->getOffset();
224  $sorting_direction = $queryInfo->getSortingDirection();
225  $limit = $queryInfo->getLimit();
226  if ($sorting_column) {
227  $collection->orderBy($sorting_column, $sorting_direction);
228  }
229  $collection->limit($offset, $limit);
230 
231  foreach ($queryInfo->getFilters() as $queryFilter) {
232  $collection->where([$queryFilter->getFieldName() => $queryFilter->getFieldValue()], $queryFilter->getOperator());
233  }
234  }
235 
236  return $collection;
237  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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 64 of file class.ilBiblFieldFactory.php.

References getARInstance(), and null.

65  {
66  $inst = $this->getARInstance($type, $identifier);
67  if ($inst === null) {
68  throw new ilException("bibliografic identifier {$identifier} not found");
69  }
70 
72  return $inst;
73  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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 197 of file class.ilBiblFieldFactory.php.

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

197  : int
198  {
199  global $DIC;
200  $tablename = ilBiblField::TABLE_NAME;
201  $q = "SELECT MAX(position) + 1 as next_position FROM {$tablename} WHERE data_type = %s;";
202  $res = $DIC->database()->queryF($q, ['integer'], [$field->getDataType()]);
203  $data = $DIC->database()->fetchObject($res);
204 
205  return (int) $data->next_position;
206  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
$q
Definition: shib_logout.php:21
+ Here is the call graph for this function:

◆ getType()

ilBiblFieldFactory::getType ( )

Implements ilBiblFieldFactoryInterface.

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

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

Referenced by findOrCreateFieldByTypeAndIdentifier().

38  {
39  return $this->type;
40  }
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:

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