ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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 74 of file class.ilBiblEntryFactory.php.

References $field_factory, $file_type, and $overview_factory.

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

Member Function Documentation

◆ createEntry()

ilBiblEntryFactory::createEntry (   $bibliographic_obj_id,
  $entry_type 
)

Implements ilBiblEntryFactoryInterface.

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

References $bibliographic_obj_id.

Referenced by findOrCreateEntry().

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

References ActiveRecord\where().

243  {
244  $entry = ilBiblEntry::where(array('id' => $id))->first();
245  if ($entry instanceof ilBiblEntry) {
246  $entry->delete();
247  }
248  }
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 179 of file class.ilBiblEntryFactory.php.

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

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

References $DIC, and $i.

Referenced by filterEntriesForTable().

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
+ Here is the caller graph for this function:

◆ findByIdAndTypeString()

ilBiblEntryFactory::findByIdAndTypeString (   $id,
  $type_string 
)

Implements ilBiblEntryFactoryInterface.

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

References ActiveRecord\where().

Referenced by filterEntriesForTable().

120  {
121  return ilBiblEntry::where(array('id' => $id))->first();
122  }
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 128 of file class.ilBiblEntryFactory.php.

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

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)
+ Here is the call graph for this function:

◆ getAllAttributesByEntryId()

ilBiblEntryFactory::getAllAttributesByEntryId (   $id)

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

References ActiveRecord\where().

Referenced by loadParsedAttributesByEntryId().

264  {
265  return ilBiblAttribute::where(array('entry_id' => $id))->get();
266  }
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 251 of file class.ilBiblEntryFactory.php.

References ActiveRecord\where().

252  {
253  return ilBiblEntry::where(array('data_id' => $object_id))->first();
254  }
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 170 of file class.ilBiblEntryFactory.php.

References ActiveRecord\where().

Referenced by findOrCreateEntry().

171  {
172  return ilBiblEntry::where(["ïd" => $id])->first();
173  }
static where($where, $operator=null)
+ 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.

301  {
302  return $this->attributes;
303  }

◆ getEmptyInstance()

ilBiblEntryFactory::getEmptyInstance ( )

Implements ilBiblEntryFactoryInterface.

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

160  {
161  return new ilBiblEntry();
162  }
Class ilBiblEntry.

◆ getEntryById()

ilBiblEntryFactory::getEntryById (   $id)

Get entry from the database.

Parameters
int$object_id
Returns

Implements ilBiblEntryFactoryInterface.

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

References ActiveRecord\where().

258  {
259  return ilBiblEntry::where(array('id' => $id))->first();
260  }
static where($where, $operator=null)
+ Here is the call graph for this function:

◆ getFileType()

ilBiblEntryFactory::getFileType ( )
Returns
string

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

References $file_type.

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

◆ loadParsedAttributesByEntryId()

ilBiblEntryFactory::loadParsedAttributesByEntryId (   $entry_id)

Implements ilBiblEntryFactoryInterface.

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

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

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

◆ setAttributes()

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

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

References $attributes.

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

◆ setFileType()

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

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

References $file_type.

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

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: