ILIAS  release_7 Revision v7.30-3-g800a261c036
ilBiblEntryFactory Class Reference

Class ilBiblEntryFactory. 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 ($entry_id)
 @inheritDoc More...
 
 findByIdAndTypeString ($id, $type_string)
 @inheritDoc More...
 
 findOrCreateEntry ($id, $bibliographic_obj_id, $entry_type)
 @inheritDoc More...
 
 createEntry ($bibliographic_obj_id, $entry_type)
 @inheritDoc More...
 
 getEmptyInstance ()
 @inheritDoc More...
 
 filterEntriesForTable ($object_id, ilBiblTableQueryInfo $info=null)
 @inheritDoc More...
 
 filterEntryIdsForTableAsArray ($object_id, ilBiblTableQueryInfo $info=null)
 @inheritDoc More...
 
 deleteEntryById ($id)
 
 getAllEntries ($object_id)
 Read all entries from the database. More...
 
 getEntryById ($id)
 Get entry from the database. More...
 
 getAllAttributesByEntryId ($id)
 
 getFileType ()
 
 setFileType ($file_type)
 
 setAttributes ($attributes)
 
 getAttributes ()
 
 findByIdAndTypeString ($id, $type_string)
 
 findOrCreateEntry ($id, $bibliographic_obj_id, $entry_type)
 
 createEntry ($bibliographic_obj_id, $entry_type)
 
 getEmptyInstance ()
 
 filterEntriesForTable ($object_id, ilBiblTableQueryInfo $info=null)
 
 filterEntryIdsForTableAsArray ($object_id, ilBiblTableQueryInfo $info=null)
 
 deleteEntryById ($id)
 
 getAllEntries ($object_id)
 Read all entries from the database. More...
 
 getEntryById ($id)
 Get entry from the database. More...
 
 loadParsedAttributesByEntryId ($entry_id)
 Reads all the entrys attributes from database. More...
 

Protected Attributes

 $bibliographic_obj_id
 
 $entry_id
 
 $type
 
 $attributes
 
 $file_type
 
 $field_factory
 
 $overview_factory
 

Private Member Functions

 getARInstance ($id)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

ilBiblEntryFactory constructor.

Parameters
ilBiblFieldFactoryInterface$field_factory
ilBiblTypeInterface$file_type

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

75 {
76 $this->file_type = $file_type;
77 $this->field_factory = $field_factory;
78 $this->overview_factory = $overview_factory;
79 }

References $field_factory, $file_type, and $overview_factory.

Member Function Documentation

◆ createEntry()

ilBiblEntryFactory::createEntry (   $bibliographic_obj_id,
  $entry_type 
)

@inheritDoc

Implements ilBiblEntryFactoryInterface.

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

146 {
147 $inst = new ilBiblEntry();
148 $inst->setDataId($bibliographic_obj_id);
149 $inst->setEntryType($entry_type);
150 $inst->create();
151
152 return $inst;
153 }
Class ilBiblEntry.

References $bibliographic_obj_id.

Referenced by findOrCreateEntry().

+ Here is the caller graph for this function:

◆ deleteEntryById()

ilBiblEntryFactory::deleteEntryById (   $id)
Parameters
int$id

Implements ilBiblEntryFactoryInterface.

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

243 {
244 $entry = ilBiblEntry::where(array('id' => $id))->first();
245 if ($entry instanceof ilBiblEntry) {
246 $entry->delete();
247 }
248 }
static where($where, $operator=null)

References ActiveRecord\where().

+ Here is the call graph for this function:

◆ filterEntriesForTable()

ilBiblEntryFactory::filterEntriesForTable (   $object_id,
ilBiblTableQueryInfo  $info = null 
)

@inheritDoc

Implements ilBiblEntryFactoryInterface.

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

180 {
181 $entries = $this->filterEntryIdsForTableAsArray($object_id, $info);
182 $entry_objects = [];
183 foreach ($entries as $entry_id => $entry) {
184 $entry_objects[$entry_id] = $this->findByIdAndTypeString($entry['type'], $entry['id']);
185 }
186
187 return $entry_objects;
188 }
filterEntryIdsForTableAsArray($object_id, ilBiblTableQueryInfo $info=null)
@inheritDoc
findByIdAndTypeString($id, $type_string)
@inheritDoc

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

+ Here is the call graph for this function:

◆ filterEntryIdsForTableAsArray()

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

@inheritDoc

Implements ilBiblEntryFactoryInterface.

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

195 {
196 global $DIC;
197
198 $types = ["integer"];
199 $values = [$object_id];
200
201 if ($info instanceof ilBiblTableQueryInfo) {
202 $filters = $info->getFilters();
203 if (!empty($filters)) {
204 $q = "SELECT (e.id), e.type FROM il_bibl_entry AS e WHERE data_id = %s";
205 foreach ($filters as $filter) {
206 $value = $filter->getFieldValue();
207 if (!$value) {
208 continue;
209 }
210 if ($filter->getOperator() === "IN" && is_array($filter->getFieldValue())) {
211 $types[] = "text";
212 $values[] = $filter->getFieldName();
213 $q .= " AND e.id IN (SELECT a.entry_id FROM il_bibl_attribute AS a WHERE a.name = %s AND " . $DIC->database()->in("a.value", $value, false, "text") . ")";
214 } else {
215 $types[] = "text";
216 $values[] = $filter->getFieldName();
217 $types[] = "text";
218 $values[] = "{$value}";
219 $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 )";
220 }
221 }
222 } else {
223 $q = "SELECT DISTINCT (e.id), e.type FROM il_bibl_entry AS e
224 JOIN il_bibl_attribute AS a ON a.entry_id = e.id
225 WHERE data_id = %s";
226 }
227 }
228 $entries = array();
229 $set = $DIC->database()->queryF($q, $types, $values);
230
231 $i = 0;
232 while ($rec = $DIC->database()->fetchAssoc($set)) {
233 $entries[$i]['entry_id'] = $rec['id'];
234 $entries[$i]['entry_type'] = $rec['type'];
235 $i++;
236 }
237
238 return $entries;
239 }
Class ilBiblTableQueryInfo.
global $DIC
Definition: goto.php:24
$i
Definition: metadata.php:24

References $DIC, and $i.

Referenced by filterEntriesForTable().

+ Here is the caller graph for this function:

◆ findByIdAndTypeString()

ilBiblEntryFactory::findByIdAndTypeString (   $id,
  $type_string 
)

@inheritDoc

Implements ilBiblEntryFactoryInterface.

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

120 {
121 return ilBiblEntry::where(array('id' => $id))->first();
122 }
Interface ilBiblEntryInterface.

References ActiveRecord\where().

Referenced by filterEntriesForTable().

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

◆ findOrCreateEntry()

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

@inheritDoc

Implements ilBiblEntryFactoryInterface.

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

129 {
130 $inst = $this->getARInstance($id);
131 if (!$inst) {
132 $inst = $this->createEntry($bibliographic_obj_id, $entry_type);
133 }
134 $inst->setDataId($bibliographic_obj_id);
135 $inst->setEntryType($entry_type);
136 $inst->update();
137
138 return $inst;
139 }
createEntry($bibliographic_obj_id, $entry_type)
@inheritDoc

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

+ Here is the call graph for this function:

◆ getAllAttributesByEntryId()

ilBiblEntryFactory::getAllAttributesByEntryId (   $id)

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

264 {
265 return ilBiblAttribute::where(array('entry_id' => $id))->get();
266 }

References ActiveRecord\where().

Referenced by loadParsedAttributesByEntryId().

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

◆ getAllEntries()

ilBiblEntryFactory::getAllEntries (   $object_id)

Read all entries from the database.

Parameters
int$object_id
Returns
\ilBiblEntryInterface[]

Implements ilBiblEntryFactoryInterface.

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

252 {
253 return ilBiblEntry::where(array('data_id' => $object_id))->first();
254 }

References ActiveRecord\where().

+ Here is the call graph for this function:

◆ getARInstance()

ilBiblEntryFactory::getARInstance (   $id)
private
Parameters
int$id
Returns
\ilBiblField

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

171 {
172 return ilBiblEntry::where(["ïd" => $id])->first();
173 }

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

References $attributes.

◆ getEmptyInstance()

ilBiblEntryFactory::getEmptyInstance ( )

@inheritDoc

Implements ilBiblEntryFactoryInterface.

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

160 {
161 return new ilBiblEntry();
162 }

◆ getEntryById()

ilBiblEntryFactory::getEntryById (   $id)

Get entry from the database.

Parameters
int$object_id
Returns
\ilBiblEntryInterface

Implements ilBiblEntryFactoryInterface.

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

258 {
259 return ilBiblEntry::where(array('id' => $id))->first();
260 }

References ActiveRecord\where().

+ Here is the call graph for this function:

◆ getFileType()

ilBiblEntryFactory::getFileType ( )
Returns
string

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

273 {
274 return $this->file_type;
275 }

References $file_type.

◆ loadParsedAttributesByEntryId()

ilBiblEntryFactory::loadParsedAttributesByEntryId (   $entry_id)

@inheritDoc

Implements ilBiblEntryFactoryInterface.

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

87 {
88 $ilBiblEntry = ilBiblEntry::where(array('id' => $entry_id))->first();
90
91 if ($this->file_type->getId() == ilBiblTypeFactoryInterface::DATA_TYPE_RIS) {
92 //for RIS-Files also add the type;
93 $type = $ilBiblEntry->getType();
94 } else {
95 $type = 'default';
96 }
97 $parsed_attributes = array();
98 foreach ($attributes as $attribute) {
99 $value = $this->secure($attribute->getValue());
100 // surround links with <a href="">
101 // Allowed signs in URL: a-z A-Z 0-9 . ? & _ / - ~ ! ' * ( ) + , : ; @ = $ # [ ] %
102 $value = preg_replace('!(http)(s)?:\/\/[a-zA-Z0-9.?&_/\-~\!\'\*()+,:;@=$#\[\]%]+!', "<a href=\"\\0\" target=\"_blank\">\\0</a>", $value);
103
104
105
106 $attribute->setValue($value);
107 $parsed_attributes[strtolower($this->file_type->getStringRepresentation() . '_' . $type . '_' . $attribute->getName())] = $value;
108
109 $this->field_factory->findOrCreateFieldOfAttribute($attribute);
110 }
111
112 return $parsed_attributes;
113 }

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

+ Here is the call graph for this function:

◆ setAttributes()

ilBiblEntryFactory::setAttributes (   $attributes)
Parameters
$attributesilBiblFieldInterface[]

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

291 {
292 $this->attributes = $attributes;
293 }

References $attributes.

◆ setFileType()

ilBiblEntryFactory::setFileType (   $file_type)
Parameters
string$file_type

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

282 {
283 $this->file_type = $file_type;
284 }

References $file_type.

Field Documentation

◆ $attributes

ilBiblEntryFactory::$attributes
protected

◆ $bibliographic_obj_id

ilBiblEntryFactory::$bibliographic_obj_id
protected

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

Referenced by createEntry(), and findOrCreateEntry().

◆ $entry_id

ilBiblEntryFactory::$entry_id
protected

◆ $field_factory

ilBiblEntryFactory::$field_factory
protected

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

Referenced by __construct().

◆ $file_type

ilBiblEntryFactory::$file_type
protected

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

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

◆ $overview_factory

ilBiblEntryFactory::$overview_factory
protected

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

Referenced by __construct().

◆ $type

ilBiblEntryFactory::$type
protected

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

Referenced by loadParsedAttributesByEntryId().


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