ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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)
 
 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...
 
 getAllAttributesByEntryId ($id)
 
 getFileType ()
 
 setFileType ($file_type)
 
 setAttributes ($attributes)
 
 getAttributes ()
 

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.

References $field_factory, $file_type, and $overview_factory.

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

Member Function Documentation

◆ createEntry()

ilBiblEntryFactory::createEntry (   $bibliographic_obj_id,
  $entry_type 
)

Implements ilBiblEntryFactoryInterface.

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

References $bibliographic_obj_id.

Referenced by findOrCreateEntry().

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

References $id, and ActiveRecord\where().

222  {
223  $entry = ilBiblEntry::where(array('id' => $id))->first();
224  if ($entry instanceof ilBiblEntry) {
225  $entry->delete();
226  }
227  }
if(!array_key_exists('StateId', $_REQUEST)) $id
static where($where, $operator=null)
Class ilBiblEntry.
+ Here is the call graph for this function:

◆ filterEntriesForTable()

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

Implements ilBiblEntryFactoryInterface.

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

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

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  }
findByIdAndTypeString($id, $type_string)
filterEntryIdsForTableAsArray($object_id, ilBiblTableQueryInfo $info=null)
+ Here is the call graph for this function:

◆ filterEntryIdsForTableAsArray()

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

Implements ilBiblEntryFactoryInterface.

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

References $DIC, $i, $info, and $values.

Referenced by filterEntriesForTable().

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  }
global $DIC
Definition: saml.php:7
$values
Class ilBiblTableQueryInfo.
$i
Definition: disco.tpl.php:19
+ Here is the caller graph for this function:

◆ findByIdAndTypeString()

ilBiblEntryFactory::findByIdAndTypeString (   $id,
  $type_string 
)

Implements ilBiblEntryFactoryInterface.

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

References $id, and ActiveRecord\where().

Referenced by filterEntriesForTable().

99  {
100  return ilBiblEntry::where(array( 'id' => $id))->first();
101  }
if(!array_key_exists('StateId', $_REQUEST)) $id
static where($where, $operator=null)
Interface ilBiblEntryInterface.
+ 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 
)

Implements ilBiblEntryFactoryInterface.

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

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

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  }
if(!array_key_exists('StateId', $_REQUEST)) $id
createEntry($bibliographic_obj_id, $entry_type)
+ Here is the call graph for this function:

◆ getAllAttributesByEntryId()

ilBiblEntryFactory::getAllAttributesByEntryId (   $id)

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

References $id, and ActiveRecord\where().

Referenced by loadParsedAttributesByEntryId().

243  {
244  return ilBiblAttribute::where(array( 'entry_id' => $id ))->get();
245  }
if(!array_key_exists('StateId', $_REQUEST)) $id
static where($where, $operator=null)
+ 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
[]

Implements ilBiblEntryFactoryInterface.

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

References ActiveRecord\where().

231  {
232  return ilBiblEntry::where(array( 'data_id' => $object_id ))->first();
233  }
static where($where, $operator=null)
+ Here is the call graph for this function:

◆ getARInstance()

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

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

References $id, and ActiveRecord\where().

Referenced by findOrCreateEntry().

150  {
151  return ilBiblEntry::where([ "ïd" => $id ])->first();
152  }
if(!array_key_exists('StateId', $_REQUEST)) $id
static where($where, $operator=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAttributes()

ilBiblEntryFactory::getAttributes ( )
Deprecated:
REFACTOR nach refactoring von loadAttributes Methoden die getAttributes verwenden entsprechend anpassen.

(Statt Array Objekte verwenden)

Returns
string[]

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

References $attributes.

279  {
280  return $this->attributes;
281  }

◆ getEmptyInstance()

ilBiblEntryFactory::getEmptyInstance ( )

Implements ilBiblEntryFactoryInterface.

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

139  {
140  return new ilBiblEntry();
141  }
Class ilBiblEntry.

◆ getEntryById()

ilBiblEntryFactory::getEntryById (   $id)

Get entry from the database.

Parameters
int$object_id
Returns

Implements ilBiblEntryFactoryInterface.

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

References $id, and ActiveRecord\where().

237  {
238  return ilBiblEntry::where(array( 'id' => $id ))->first();
239  }
if(!array_key_exists('StateId', $_REQUEST)) $id
static where($where, $operator=null)
+ Here is the call graph for this function:

◆ getFileType()

ilBiblEntryFactory::getFileType ( )
Returns
string

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

References $file_type.

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

◆ loadParsedAttributesByEntryId()

ilBiblEntryFactory::loadParsedAttributesByEntryId (   $entry_id)

Implements ilBiblEntryFactoryInterface.

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

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

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  }
static where($where, $operator=null)
+ Here is the call graph for this function:

◆ setAttributes()

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

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

References $attributes.

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

◆ setFileType()

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

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

References $file_type.

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

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: