ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 58 of file class.ilBiblEntryFactory.php.

59 {
60 $this->file_type = $file_type;
61 $this->field_factory = $field_factory;
62 $this->overview_factory = $overview_factory;
63 }

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

125 {
126 $inst = new ilBiblEntry();
127 $inst->setDataId($bibliographic_obj_id);
128 $inst->setEntryType($entry_type);
129 $inst->create();
130
131 return $inst;
132 }
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 221 of file class.ilBiblEntryFactory.php.

222 {
223 $entry = ilBiblEntry::where(array('id' => $id))->first();
224 if ($entry instanceof ilBiblEntry) {
225 $entry->delete();
226 }
227 }
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 158 of file class.ilBiblEntryFactory.php.

159 {
160 $entries = $this->filterEntryIdsForTableAsArray($object_id, $info);
161 $entry_objects = [];
162 foreach ($entries as $entry_id => $entry) {
163 $entry_objects[$entry_id] = $this->findByIdAndTypeString($entry['type'], $entry['id']);
164 }
165
166 return $entry_objects;
167 }
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 173 of file class.ilBiblEntryFactory.php.

174 {
175 global $DIC;
176
177 $types = ["integer"];
178 $values = [$object_id];
179
180 if ($info instanceof ilBiblTableQueryInfo) {
181 $filters = $info->getFilters();
182 if (!empty($filters)) {
183 $q = "SELECT (e.id), e.type FROM il_bibl_entry AS e WHERE data_id = %s";
184 foreach ($filters as $filter) {
185 $value = $filter->getFieldValue();
186 if (!$value) {
187 continue;
188 }
189 if ($filter->getOperator() === "IN" && is_array($filter->getFieldValue())) {
190 $types[] = "text";
191 $values[] = $filter->getFieldName();
192 $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") . ")";
193 } else {
194 $types[] = "text";
195 $values[] = $filter->getFieldName();
196 $types[] = "text";
197 $values[] = "{$value}";
198 $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 )";
199 }
200 }
201 } else {
202 $q = "SELECT DISTINCT (e.id), e.type FROM il_bibl_entry AS e
203 JOIN il_bibl_attribute AS a ON a.entry_id = e.id
204 WHERE data_id = %s";
205 }
206 }
207 $entries = array();
208 $set = $DIC->database()->queryF($q, $types, $values);
209
210 $i = 0;
211 while ($rec = $DIC->database()->fetchAssoc($set)) {
212 $entries[$i]['entry_id'] = $rec['id'];
213 $entries[$i]['entry_type'] = $rec['type'];
214 $i++;
215 }
216
217 return $entries;
218 }
Class ilBiblTableQueryInfo.
$i
Definition: metadata.php:24
$DIC
Definition: xapitoken.php:46

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

99 {
100 return ilBiblEntry::where(array('id' => $id))->first();
101 }
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 107 of file class.ilBiblEntryFactory.php.

108 {
109 $inst = $this->getARInstance($id);
110 if (!$inst) {
111 $inst = $this->createEntry($bibliographic_obj_id, $entry_type);
112 }
113 $inst->setDataId($bibliographic_obj_id);
114 $inst->setEntryType($entry_type);
115 $inst->update();
116
117 return $inst;
118 }
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 242 of file class.ilBiblEntryFactory.php.

243 {
244 return ilBiblAttribute::where(array('entry_id' => $id))->get();
245 }

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

231 {
232 return ilBiblEntry::where(array('data_id' => $object_id))->first();
233 }

References ActiveRecord\where().

+ Here is the call graph for this function:

◆ getARInstance()

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

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

150 {
151 return ilBiblEntry::where(["ïd" => $id])->first();
152 }

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

References $attributes.

◆ getEmptyInstance()

ilBiblEntryFactory::getEmptyInstance ( )

@inheritDoc

Implements ilBiblEntryFactoryInterface.

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

139 {
140 return new ilBiblEntry();
141 }

◆ getEntryById()

ilBiblEntryFactory::getEntryById (   $id)

Get entry from the database.

Parameters
int$object_id
Returns
\ilBiblEntryInterface

Implements ilBiblEntryFactoryInterface.

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

237 {
238 return ilBiblEntry::where(array('id' => $id))->first();
239 }

References ActiveRecord\where().

+ Here is the call graph for this function:

◆ getFileType()

ilBiblEntryFactory::getFileType ( )
Returns
string

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

252 {
253 return $this->file_type;
254 }

References $file_type.

◆ loadParsedAttributesByEntryId()

ilBiblEntryFactory::loadParsedAttributesByEntryId (   $entry_id)

@inheritDoc

Implements ilBiblEntryFactoryInterface.

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

70 {
71 $ilBiblEntry = ilBiblEntry::where(array('id' => $entry_id))->first();
73
74 if ($this->file_type->getId() == ilBiblTypeFactoryInterface::DATA_TYPE_RIS) {
75 //for RIS-Files also add the type;
76 $type = $ilBiblEntry->getType();
77 } else {
78 $type = 'default';
79 }
80 $parsed_attributes = array();
81 foreach ($attributes as $attribute) {
82 // surround links with <a href="">
83 // Allowed signs in URL: a-z A-Z 0-9 . ? & _ / - ~ ! ' * ( ) + , : ; @ = $ # [ ] %
84 $value = preg_replace('!(http)(s)?:\/\/[a-zA-Z0-9.?&_/\-~\!\'\*()+,:;@=$#\[\]%]+!', "<a href=\"\\0\" target=\"_blank\">\\0</a>", $attribute->getValue());
85 $attribute->setValue($value);
86 $parsed_attributes[strtolower($this->file_type->getStringRepresentation() . '_' . $type . '_' . $attribute->getName())] = $value;
87
88 $this->field_factory->findOrCreateFieldOfAttribute($attribute);
89 }
90
91 return $parsed_attributes;
92 }

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

270 {
271 $this->attributes = $attributes;
272 }

References $attributes.

◆ setFileType()

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

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

261 {
262 $this->file_type = $file_type;
263 }

References $file_type.

Field Documentation

◆ $attributes

ilBiblEntryFactory::$attributes
protected

◆ $bibliographic_obj_id

ilBiblEntryFactory::$bibliographic_obj_id
protected

Definition at line 17 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 45 of file class.ilBiblEntryFactory.php.

Referenced by __construct().

◆ $file_type

ilBiblEntryFactory::$file_type
protected

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

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

◆ $overview_factory

ilBiblEntryFactory::$overview_factory
protected

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

Referenced by __construct().

◆ $type

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: