ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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)
 
 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)
 
 getAllAttributesByEntryId (int $id)
 
 getFileType ()
 
 setFileType (string $file_type)
 
 setAttributes (array $attributes)
 
 getAttributes ()
 

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

References $DIC.

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

Member Function Documentation

◆ createEntry()

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

Implements ilBiblEntryFactoryInterface.

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

Referenced by findOrCreateEntry().

98  {
99  $inst = new ilBiblEntry();
100  $inst->setDataId($bibliographic_obj_id);
101  $inst->setEntryType($entry_type);
102  $inst->create();
103 
104  return $inst;
105  }
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...
+ Here is the caller graph for this function:

◆ deleteEntriesById()

ilBiblEntryFactory::deleteEntriesById ( int  $object_id)

Implements ilBiblEntryFactoryInterface.

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

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

◆ deleteEntryById()

ilBiblEntryFactory::deleteEntryById ( int  $id)

Implements ilBiblEntryFactoryInterface.

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

References ActiveRecord\where().

178  : void
179  {
180  $entry = ilBiblEntry::where(['id' => $id])->first();
181  if ($entry instanceof ilBiblEntry) {
182  $entry->delete();
183  }
184  }
static where($where, $operator=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ filterEntriesForTable()

ilBiblEntryFactory::filterEntriesForTable ( int  $object_id,
?ilBiblTableQueryInfo  $info = null 
)
Returns
[]

Implements ilBiblEntryFactoryInterface.

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

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

121  : array
122  {
123  $entries = $this->filterEntryIdsForTableAsArray($object_id, $info);
124  $entry_objects = [];
125  foreach ($entries as $entry_id => $entry) {
126  $entry_objects[$entry_id] = $this->findByIdAndTypeString($entry['type'], $entry['id']);
127  }
128 
129  return $entry_objects;
130  }
filterEntryIdsForTableAsArray(int $object_id, ?ilBiblTableQueryInfo $info=null)
findByIdAndTypeString(int $id, string $type_string)
+ Here is the call graph for this function:

◆ filterEntryIdsForTableAsArray()

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

Implements ilBiblEntryFactoryInterface.

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

References $q.

Referenced by filterEntriesForTable().

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

◆ findByIdAndTypeString()

ilBiblEntryFactory::findByIdAndTypeString ( int  $id,
string  $type_string 
)

PhpIncompatibleReturnTypeInspection

Implements ilBiblEntryFactoryInterface.

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

References ActiveRecord\where().

Referenced by filterEntriesForTable().

73  {
75  return ilBiblEntry::where(['id' => $id])->first();
76  }
static where($where, $operator=null)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ 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 
)

Implements ilBiblEntryFactoryInterface.

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

References createEntry(), getARInstance(), and null.

82  {
83  $inst = $this->getARInstance($id);
84  if ($inst === null) {
85  $inst = $this->createEntry($bibliographic_obj_id, $entry_type);
86  }
87  $inst->setDataId($bibliographic_obj_id);
88  $inst->setEntryType($entry_type);
89  $inst->update();
90 
91  return $inst;
92  }
createEntry(int $bibliographic_obj_id, string $entry_type)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ getAllAttributesByEntryId()

ilBiblEntryFactory::getAllAttributesByEntryId ( int  $id)
Returns
[]

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

References ActiveRecord\where().

Referenced by loadParsedAttributesByEntryId().

194  : array
195  {
196  return ilBiblAttribute::where(['entry_id' => $id])->get();
197  }
static where($where, $operator=null)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getARInstance()

ilBiblEntryFactory::getARInstance ( int  $id)
private

PhpIncompatibleReturnTypeInspection

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

References ActiveRecord\where().

Referenced by findOrCreateEntry().

112  : ?\ilBiblEntry
113  {
115  return ilBiblEntry::where(["ïd" => $id])->first();
116  }
static where($where, $operator=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ 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 221 of file class.ilBiblEntryFactory.php.

References $attributes.

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

◆ getEmptyInstance()

ilBiblEntryFactory::getEmptyInstance ( )

Implements ilBiblEntryFactoryInterface.

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

107  : \ilBiblEntry
108  {
109  return new ilBiblEntry();
110  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getFileType()

ilBiblEntryFactory::getFileType ( )

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

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

◆ loadParsedAttributesByEntryId()

ilBiblEntryFactory::loadParsedAttributesByEntryId ( int  $entry_id)

Implements ilBiblEntryFactoryInterface.

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

References ilBiblTypeFactoryInterface\DATA_TYPE_RIS, getAllAttributesByEntryId(), and ActiveRecord\where().

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

◆ setAttributes()

ilBiblEntryFactory::setAttributes ( array  $attributes)
Parameters
ilBiblFieldInterface[]$attributes

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

References $attributes.

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

◆ setFileType()

ilBiblEntryFactory::setFileType ( string  $file_type)

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

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

Field Documentation

◆ $attributes

array ilBiblEntryFactory::$attributes
protected

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

Referenced by getAttributes(), and setAttributes().

◆ $bibliographic_obj_id

int ilBiblEntryFactory::$bibliographic_obj_id
protected

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

◆ $db

ilDBInterface ilBiblEntryFactory::$db
protected

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

◆ $entry_id

int ilBiblEntryFactory::$entry_id
protected

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

Referenced by filterEntriesForTable().

◆ $type

string ilBiblEntryFactory::$type
protected

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


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