ILIAS  release_8 Revision v8.24
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)
 @inheritDoc More...
 
 findByIdAndTypeString (int $id, string $type_string)
 @inheritDoc More...
 
 findOrCreateEntry (int $id, int $bibliographic_obj_id, string $entry_type)
 @inheritDoc More...
 
 createEntry (int $bibliographic_obj_id, string $entry_type)
 @inheritDoc More...
 
 getEmptyInstance ()
 
 filterEntriesForTable (int $object_id, ilBiblTableQueryInfo $info=null)
 
 filterEntryIdsForTableAsArray (int $object_id, ?ilBiblTableQueryInfo $info=null)
 @inheritDoc More...
 
 deleteEntryById (int $id)
 
 deleteEntriesById (int $object_id)
 
 getAllAttributesByEntryId (int $id)
 
 getFileType ()
 
 setFileType (string $file_type)
 
 setAttributes (array $attributes)
 
 getAttributes ()
 
 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)
 
 loadParsedAttributesByEntryId (int $entry_id)
 Reads all the entrys attributes from database. More...
 

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.

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
ilBiblTypeInterface $file_type
ilBiblFieldFactoryInterface $field_factory
global $DIC
Definition: feed.php:28

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

Member Function Documentation

◆ createEntry()

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

@inheritDoc

Implements ilBiblEntryFactoryInterface.

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

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

References $bibliographic_obj_id.

Referenced by findOrCreateEntry().

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

189 : void
190 {
191 $entry = ilBiblEntry::where(array('id' => $id))->first();
192 if ($entry instanceof ilBiblEntry) {
193 $entry->delete();
194 }
195 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static where($where, $operator=null)

References $id, and ActiveRecord\where().

+ Here is the call graph for this function:

◆ filterEntriesForTable()

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

Implements ilBiblEntryFactoryInterface.

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

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)
@inheritDoc
findByIdAndTypeString(int $id, string $type_string)
@inheritDoc

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

+ Here is the call graph for this function:

◆ filterEntryIdsForTableAsArray()

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

@inheritDoc

Implements ilBiblEntryFactoryInterface.

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

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

References $i.

Referenced by filterEntriesForTable().

+ Here is the caller graph for this function:

◆ findByIdAndTypeString()

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

@inheritDoc

@noinspection PhpIncompatibleReturnTypeInspection

Implements ilBiblEntryFactoryInterface.

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

84 {
86 return ilBiblEntry::where(array('id' => $id))->first();
87 }

References $id, and ActiveRecord\where().

Referenced by filterEntriesForTable().

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

@inheritDoc

Implements ilBiblEntryFactoryInterface.

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

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)
@inheritDoc

References $bibliographic_obj_id, createEntry(), and getARInstance().

+ Here is the call graph for this function:

◆ getAllAttributesByEntryId()

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

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

205 : array
206 {
207 return ilBiblAttribute::where(array('entry_id' => $id))->get();
208 }

References $id, and ActiveRecord\where().

Referenced by loadParsedAttributesByEntryId().

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

◆ getARInstance()

ilBiblEntryFactory::getARInstance ( int  $id)
private

@noinspection PhpIncompatibleReturnTypeInspection

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

123 : ?\ilBiblEntry
124 {
126 return ilBiblEntry::where(["ïd" => $id])->first();
127 }

References $id, and ActiveRecord\where().

Referenced by findOrCreateEntry().

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

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

References $attributes.

◆ getEmptyInstance()

ilBiblEntryFactory::getEmptyInstance ( )

Implements ilBiblEntryFactoryInterface.

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

119 {
120 return new ilBiblEntry();
121 }

◆ getFileType()

ilBiblEntryFactory::getFileType ( )

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

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

References $file_type.

◆ loadParsedAttributesByEntryId()

ilBiblEntryFactory::loadParsedAttributesByEntryId ( int  $entry_id)

@inheritDoc

Implements ilBiblEntryFactoryInterface.

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

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 }

References $attributes, $entry_id, $type, ilBiblTypeFactoryInterface\DATA_TYPE_RIS, getAllAttributesByEntryId(), and ActiveRecord\where().

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

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

References $attributes.

◆ setFileType()

ilBiblEntryFactory::setFileType ( string  $file_type)

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

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

References $file_type.

Field Documentation

◆ $attributes

array ilBiblEntryFactory::$attributes
protected

◆ $bibliographic_obj_id

int ilBiblEntryFactory::$bibliographic_obj_id
protected

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

Referenced by createEntry(), and findOrCreateEntry().

◆ $db

ilDBInterface ilBiblEntryFactory::$db
protected

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

◆ $entry_id

int ilBiblEntryFactory::$entry_id
protected

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

Referenced by loadParsedAttributesByEntryId().


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