ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilBiblEntryFactory 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 ilBiblEntryFactory:
+ Collaboration diagram for ilBiblEntryFactory:

Public Member Functions

 __construct (ilBiblFieldFactoryInterface $field_factory, \ilBiblTypeInterface $file_type, ilBiblOverviewModelFactoryInterface $overview_factory)
 ilBiblEntryFactory constructor. More...
 
 loadParsedAttributesByEntryId (int $entry_id)
 
 findByIdAndTypeString (int $id, string $type_string)
 
 findOrCreateEntry (int $id, int $bibliographic_obj_id, string $entry_type)
 
 createEntry (int $bibliographic_obj_id, string $entry_type)
 
 getEmptyInstance ()
 
 filterEntriesForTable (int $object_id, ilBiblTableQueryInfo $info=null)
 
 filterEntryIdsForTableAsArray (int $object_id, ?ilBiblTableQueryInfo $info=null)
 
 deleteEntryById (int $id)
 
 deleteEntriesById (int $object_id)
 
 getAllAttributesByEntryId (int $id)
 
 getFileType ()
 
 setFileType (string $file_type)
 
 setAttributes (array $attributes)
 
 getAttributes ()
 

Protected Attributes

int $bibliographic_obj_id
 
int $entry_id
 
string $type
 
array $attributes
 
ilBiblTypeInterface $file_type
 
ilBiblFieldFactoryInterface $field_factory
 
ilBiblOverviewModelFactoryInterface $overview_factory
 
ilDBInterface $db
 

Private Member Functions

 getARInstance (int $id)
 

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 ilBiblEntryFactory

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

Definition at line 22 of file class.ilBiblEntryFactory.php.

Constructor & Destructor Documentation

◆ __construct()

ilBiblEntryFactory::__construct ( ilBiblFieldFactoryInterface  $field_factory,
\ilBiblTypeInterface  $file_type,
ilBiblOverviewModelFactoryInterface  $overview_factory 
)

ilBiblEntryFactory constructor.

Definition at line 39 of file class.ilBiblEntryFactory.php.

References $DIC, $field_factory, $file_type, and $overview_factory.

40  {
41  global $DIC;
42  $this->db = $DIC->database();
43  $this->file_type = $file_type;
44  $this->field_factory = $field_factory;
45  $this->overview_factory = $overview_factory;
46  }
ilBiblOverviewModelFactoryInterface $overview_factory
global $DIC
Definition: feed.php:28
ilBiblTypeInterface $file_type
ilBiblFieldFactoryInterface $field_factory

Member Function Documentation

◆ createEntry()

ilBiblEntryFactory::createEntry ( int  $bibliographic_obj_id,
string  $entry_type 
)

Implements ilBiblEntryFactoryInterface.

Definition at line 108 of file class.ilBiblEntryFactory.php.

Referenced by findOrCreateEntry().

109  {
110  $inst = new ilBiblEntry();
111  $inst->setDataId($bibliographic_obj_id);
112  $inst->setEntryType($entry_type);
113  $inst->create();
114 
115  return $inst;
116  }
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...
+ Here is the caller graph for this function:

◆ deleteEntriesById()

ilBiblEntryFactory::deleteEntriesById ( int  $object_id)

Implements ilBiblEntryFactoryInterface.

Definition at line 197 of file class.ilBiblEntryFactory.php.

197  : void
198  {
199  $this->db->manipulateF("DELETE FROM il_bibl_entry WHERE data_id = %s", ['integer'], [$object_id]);
200  }

◆ deleteEntryById()

ilBiblEntryFactory::deleteEntryById ( int  $id)

Implements ilBiblEntryFactoryInterface.

Definition at line 189 of file class.ilBiblEntryFactory.php.

References ActiveRecord\where().

189  : void
190  {
191  $entry = ilBiblEntry::where(array('id' => $id))->first();
192  if ($entry instanceof ilBiblEntry) {
193  $entry->delete();
194  }
195  }
static where($where, $operator=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ filterEntriesForTable()

ilBiblEntryFactory::filterEntriesForTable ( int  $object_id,
ilBiblTableQueryInfo  $info = null 
)
Returns
[]

Implements ilBiblEntryFactoryInterface.

Definition at line 132 of file class.ilBiblEntryFactory.php.

References $entry_id, filterEntryIdsForTableAsArray(), and findByIdAndTypeString().

132  : array
133  {
134  $entries = $this->filterEntryIdsForTableAsArray($object_id, $info);
135  $entry_objects = [];
136  foreach ($entries as $entry_id => $entry) {
137  $entry_objects[$entry_id] = $this->findByIdAndTypeString($entry['type'], $entry['id']);
138  }
139 
140  return $entry_objects;
141  }
filterEntryIdsForTableAsArray(int $object_id, ?ilBiblTableQueryInfo $info=null)
findByIdAndTypeString(int $id, string $type_string)
+ Here is the call graph for this function:

◆ filterEntryIdsForTableAsArray()

ilBiblEntryFactory::filterEntryIdsForTableAsArray ( int  $object_id,
?ilBiblTableQueryInfo  $info = null 
)

Implements ilBiblEntryFactoryInterface.

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

References $i.

Referenced by filterEntriesForTable().

146  : array
147  {
148  $types = ["integer"];
149  $values = [$object_id];
150 
151  $filters = $info->getFilters();
152  if (!empty($filters)) {
153  $q = "SELECT (e.id), e.type FROM il_bibl_entry AS e WHERE data_id = %s";
154  foreach ($filters as $filter) {
155  $value = $filter->getFieldValue();
156  if (!$value) {
157  continue;
158  }
159  if ($filter->getOperator() === "IN" && is_array($filter->getFieldValue())) {
160  $types[] = "text";
161  $values[] = $filter->getFieldName();
162  $q .= " AND e.id IN (SELECT a.entry_id FROM il_bibl_attribute AS a WHERE a.name = %s AND " . $this->db->in("a.value", $value, false, "text") . ")";
163  } else {
164  $types[] = "text";
165  $values[] = $filter->getFieldName();
166  $types[] = "text";
167  $values[] = "{$value}";
168  $q .= " AND e.id IN (SELECT a.entry_id FROM il_bibl_attribute AS a WHERE a.name = %s AND a.value {$filter->getOperator()} %s )";
169  }
170  }
171  } else {
172  $q = "SELECT DISTINCT (e.id), e.type FROM il_bibl_entry AS e
173  JOIN il_bibl_attribute AS a ON a.entry_id = e.id
174  WHERE data_id = %s";
175  }
176  $entries = [];
177  $set = $this->db->queryF($q, $types, $values);
178 
179  $i = 0;
180  while ($rec = $this->db->fetchAssoc($set)) {
181  $entries[$i]['entry_id'] = $rec['id'];
182  $entries[$i]['entry_type'] = $rec['type'];
183  $i++;
184  }
185 
186  return $entries;
187  }
$i
Definition: metadata.php:41
+ Here is the caller graph for this function:

◆ findByIdAndTypeString()

ilBiblEntryFactory::findByIdAndTypeString ( int  $id,
string  $type_string 
)

PhpIncompatibleReturnTypeInspection

Implements ilBiblEntryFactoryInterface.

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

References ActiveRecord\where().

Referenced by filterEntriesForTable().

84  {
86  return ilBiblEntry::where(array('id' => $id))->first();
87  }
static where($where, $operator=null)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
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:

◆ findOrCreateEntry()

ilBiblEntryFactory::findOrCreateEntry ( int  $id,
int  $bibliographic_obj_id,
string  $entry_type 
)

Implements ilBiblEntryFactoryInterface.

Definition at line 92 of file class.ilBiblEntryFactory.php.

References createEntry(), and getARInstance().

93  {
94  $inst = $this->getARInstance($id);
95  if (!$inst) {
96  $inst = $this->createEntry($bibliographic_obj_id, $entry_type);
97  }
98  $inst->setDataId($bibliographic_obj_id);
99  $inst->setEntryType($entry_type);
100  $inst->update();
101 
102  return $inst;
103  }
createEntry(int $bibliographic_obj_id, string $entry_type)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
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:

◆ getAllAttributesByEntryId()

ilBiblEntryFactory::getAllAttributesByEntryId ( int  $id)
Returns
[]

Definition at line 205 of file class.ilBiblEntryFactory.php.

References ActiveRecord\where().

Referenced by loadParsedAttributesByEntryId().

205  : array
206  {
207  return ilBiblAttribute::where(array('entry_id' => $id))->get();
208  }
static where($where, $operator=null)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getARInstance()

ilBiblEntryFactory::getARInstance ( int  $id)
private

PhpIncompatibleReturnTypeInspection

Definition at line 123 of file class.ilBiblEntryFactory.php.

References ActiveRecord\where().

Referenced by findOrCreateEntry().

123  : ?\ilBiblEntry
124  {
126  return ilBiblEntry::where(["ïd" => $id])->first();
127  }
static where($where, $operator=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAttributes()

ilBiblEntryFactory::getAttributes ( )
Returns
string[]
Deprecated:
REFACTOR nach refactoring von loadAttributes Methoden die getAttributes verwenden entsprechend anpassen. (Statt Array Objekte verwenden)

Definition at line 232 of file class.ilBiblEntryFactory.php.

References $attributes.

232  : array
233  {
234  return $this->attributes;
235  }

◆ getEmptyInstance()

ilBiblEntryFactory::getEmptyInstance ( )

Implements ilBiblEntryFactoryInterface.

Definition at line 118 of file class.ilBiblEntryFactory.php.

118  : \ilBiblEntry
119  {
120  return new ilBiblEntry();
121  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getFileType()

ilBiblEntryFactory::getFileType ( )

Definition at line 210 of file class.ilBiblEntryFactory.php.

References $file_type.

211  {
212  return $this->file_type;
213  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilBiblTypeInterface $file_type

◆ loadParsedAttributesByEntryId()

ilBiblEntryFactory::loadParsedAttributesByEntryId ( int  $entry_id)

Implements ilBiblEntryFactoryInterface.

Definition at line 51 of file class.ilBiblEntryFactory.php.

References ilBiblTypeFactoryInterface\DATA_TYPE_RIS, getAllAttributesByEntryId(), and ActiveRecord\where().

51  : array
52  {
53  $ilBiblEntry = ilBiblEntry::where(array('id' => $entry_id))->first();
55 
56  if ($this->file_type->getId() == ilBiblTypeFactoryInterface::DATA_TYPE_RIS) {
57  //for RIS-Files also add the type;
58  $type = $ilBiblEntry->getType();
59  } else {
60  $type = 'default';
61  }
62  $parsed_attributes = array();
63  foreach ($attributes as $attribute) {
64  $value = $this->secure($attribute->getValue());
65  // surround links with <a href="">
66  // Allowed signs in URL: a-z A-Z 0-9 . ? & _ / - ~ ! ' * ( ) + , : ; @ = $ # [ ] %
67  $value = preg_replace('!(http)(s)?:\/\/[a-zA-Z0-9.?&_/\-~\!\'\*()+,:;@=$#\[\]%]+!', "<a href=\"\\0\" target=\"_blank\">\\0</a>", $value);
68 
69 
70 
71  $attribute->setValue($value);
72  $parsed_attributes[strtolower($this->file_type->getStringRepresentation() . '_' . $type . '_' . $attribute->getName())] = $value;
73 
74  $this->field_factory->findOrCreateFieldOfAttribute($attribute);
75  }
76 
77  return $parsed_attributes;
78  }
static where($where, $operator=null)
+ Here is the call graph for this function:

◆ setAttributes()

ilBiblEntryFactory::setAttributes ( array  $attributes)
Parameters
ilBiblFieldInterface[]$attributes

Definition at line 223 of file class.ilBiblEntryFactory.php.

References $attributes.

223  : void
224  {
225  $this->attributes = $attributes;
226  }

◆ setFileType()

ilBiblEntryFactory::setFileType ( string  $file_type)

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

References $file_type.

215  : void
216  {
217  $this->file_type = $file_type;
218  }
ilBiblTypeInterface $file_type

Field Documentation

◆ $attributes

array ilBiblEntryFactory::$attributes
protected

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

Referenced by getAttributes(), and setAttributes().

◆ $bibliographic_obj_id

int ilBiblEntryFactory::$bibliographic_obj_id
protected

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

◆ $db

ilDBInterface ilBiblEntryFactory::$db
protected

Definition at line 33 of file class.ilBiblEntryFactory.php.

◆ $entry_id

int ilBiblEntryFactory::$entry_id
protected

Definition at line 27 of file class.ilBiblEntryFactory.php.

Referenced by filterEntriesForTable().

◆ $field_factory

ilBiblFieldFactoryInterface ilBiblEntryFactory::$field_factory
protected

Definition at line 31 of file class.ilBiblEntryFactory.php.

Referenced by __construct().

◆ $file_type

ilBiblTypeInterface ilBiblEntryFactory::$file_type
protected

Definition at line 30 of file class.ilBiblEntryFactory.php.

Referenced by __construct(), getFileType(), and setFileType().

◆ $overview_factory

ilBiblOverviewModelFactoryInterface ilBiblEntryFactory::$overview_factory
protected

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

Referenced by __construct().

◆ $type

string ilBiblEntryFactory::$type
protected

Definition at line 28 of file class.ilBiblEntryFactory.php.


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