ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 (protected \ilBiblFieldFactoryInterface $field_factory, protected \ilBiblTypeInterface $file_type, protected \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
 
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 23 of file class.ilBiblEntryFactory.php.

Constructor & Destructor Documentation

◆ __construct()

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

ilBiblEntryFactory constructor.

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

38 {
39 global $DIC;
40 $this->db = $DIC->database();
41 }
global $DIC
Definition: shib_login.php:26

References $DIC.

Member Function Documentation

◆ createEntry()

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

@inheritDoc

Implements ilBiblEntryFactoryInterface.

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

99 {
100 $inst = new ilBiblEntry();
101 $inst->setDataId($bibliographic_obj_id);
102 $inst->setEntryType($entry_type);
103 $inst->create();
104
105 return $inst;
106 }
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 187 of file class.ilBiblEntryFactory.php.

187 : void
188 {
189 $this->db->manipulateF("DELETE FROM il_bibl_entry WHERE data_id = %s", ['integer'], [$object_id]);
190 }

◆ deleteEntryById()

ilBiblEntryFactory::deleteEntryById ( int  $id)

Implements ilBiblEntryFactoryInterface.

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

179 : void
180 {
181 $entry = ilBiblEntry::where(['id' => $id])->first();
182 if ($entry instanceof ilBiblEntry) {
183 $entry->delete();
184 }
185 }
$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 122 of file class.ilBiblEntryFactory.php.

122 : array
123 {
124 $entries = $this->filterEntryIdsForTableAsArray($object_id, $info);
125 $entry_objects = [];
126 foreach ($entries as $entry_id => $entry) {
127 $entry_objects[$entry_id] = $this->findByIdAndTypeString($entry['type'], $entry['id']);
128 }
129
130 return $entry_objects;
131 }
filterEntryIdsForTableAsArray(int $object_id, ?ilBiblTableQueryInfo $info=null)
@inheritDoc
findByIdAndTypeString(int $id, string $type_string)
@inheritDoc
$info
Definition: entry_point.php:21

References $entry_id, $info, 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 136 of file class.ilBiblEntryFactory.php.

136 : array
137 {
138 $types = ["integer"];
139 $values = [$object_id];
140
141 $filters = $info->getFilters();
142 if (!empty($filters)) {
143 $q = "SELECT (e.id), e.type FROM il_bibl_entry AS e WHERE data_id = %s";
144 foreach ($filters as $filter) {
145 $value = $filter->getFieldValue();
146 if (!$value) {
147 continue;
148 }
149 if ($filter->getOperator() === "IN" && is_array($filter->getFieldValue())) {
150 $types[] = "text";
151 $values[] = $filter->getFieldName();
152 $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") . ")";
153 } else {
154 $types[] = "text";
155 $values[] = $filter->getFieldName();
156 $types[] = "text";
157 $values[] = "{$value}";
158 $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 )";
159 }
160 }
161 } else {
162 $q = "SELECT DISTINCT (e.id), e.type FROM il_bibl_entry AS e
163 JOIN il_bibl_attribute AS a ON a.entry_id = e.id
164 WHERE data_id = %s";
165 }
166 $entries = [];
167 $set = $this->db->queryF($q, $types, $values);
168
169 $i = 0;
170 while ($rec = $this->db->fetchAssoc($set)) {
171 $entries[$i]['entry_id'] = $rec['id'];
172 $entries[$i]['entry_type'] = $rec['type'];
173 $i++;
174 }
175
176 return $entries;
177 }
$q
Definition: shib_logout.php:23

References $info, and $q.

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 73 of file class.ilBiblEntryFactory.php.

74 {
76 return ilBiblEntry::where(['id' => $id])->first();
77 }

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 82 of file class.ilBiblEntryFactory.php.

83 {
84 $inst = $this->getARInstance($id);
85 if ($inst === null) {
86 $inst = $this->createEntry($bibliographic_obj_id, $entry_type);
87 }
88 $inst->setDataId($bibliographic_obj_id);
89 $inst->setEntryType($entry_type);
90 $inst->update();
91
92 return $inst;
93 }
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 195 of file class.ilBiblEntryFactory.php.

195 : array
196 {
197 return ilBiblAttribute::where(['entry_id' => $id])->get();
198 }

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 113 of file class.ilBiblEntryFactory.php.

113 : ?\ilBiblEntry
114 {
116 return ilBiblEntry::where(["ïd" => $id])->first();
117 }

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 222 of file class.ilBiblEntryFactory.php.

222 : array
223 {
224 return $this->attributes;
225 }

References $attributes.

◆ getEmptyInstance()

ilBiblEntryFactory::getEmptyInstance ( )

Implements ilBiblEntryFactoryInterface.

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

109 {
110 return new ilBiblEntry();
111 }

◆ getFileType()

ilBiblEntryFactory::getFileType ( )

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

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

◆ loadParsedAttributesByEntryId()

ilBiblEntryFactory::loadParsedAttributesByEntryId ( int  $entry_id)

@inheritDoc

Implements ilBiblEntryFactoryInterface.

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

46 : array
47 {
48 $ilBiblEntry = ilBiblEntry::where(['id' => $entry_id])->first();
50
51 $type = $this->file_type->getId() == ilBiblTypeFactoryInterface::DATA_TYPE_RIS ? $ilBiblEntry->getType() : 'default';
52 $parsed_attributes = [];
53 foreach ($attributes as $attribute) {
54 $value = $this->secure($attribute->getValue());
55 // surround links with <a href="">
56 // Allowed signs in URL: a-z A-Z 0-9 . ? & _ / - ~ ! ' * ( ) + , : ; @ = $ # [ ] %
57 $value = preg_replace('!(http)(s)?:\/\/[a-zA-Z0-9.?&_/\-~\!\'\*()+,:;@=$#\[\]%]+!', "<a href=\"\\0\" target=\"_blank\">\\0</a>", $value);
58
59
60
61 $attribute->setValue($value);
62 $parsed_attributes[strtolower($this->file_type->getStringRepresentation() . '_' . $type . '_' . $attribute->getName())] = $value;
63
64 $this->field_factory->findOrCreateFieldOfAttribute($attribute);
65 }
66
67 return $parsed_attributes;
68 }

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 213 of file class.ilBiblEntryFactory.php.

213 : void
214 {
215 $this->attributes = $attributes;
216 }

References $attributes.

◆ setFileType()

ilBiblEntryFactory::setFileType ( string  $file_type)

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

205 : void
206 {
207 $this->file_type = $file_type;
208 }

Field Documentation

◆ $attributes

array ilBiblEntryFactory::$attributes
protected

◆ $bibliographic_obj_id

int ilBiblEntryFactory::$bibliographic_obj_id
protected

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

Referenced by createEntry(), and findOrCreateEntry().

◆ $db

ilDBInterface ilBiblEntryFactory::$db
protected

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

◆ $entry_id

int ilBiblEntryFactory::$entry_id
protected

◆ $type

string ilBiblEntryFactory::$type
protected

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

Referenced by loadParsedAttributesByEntryId().


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