ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilBiblAttributeFactory 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 ilBiblAttributeFactory:
+ Collaboration diagram for ilBiblAttributeFactory:

Public Member Functions

 __construct (ilBiblFieldFactoryInterface $field_factory)
 
 getPossibleValuesForFieldAndObject (ilBiblFieldInterface $field, int $object_id)
 
 getAttributesForEntry (ilBiblEntryInterface $entry)
 
 sortAttributes (array $attributes)
 
 createAttribute (string $name, string $value, int $entry_id)
 

Protected Attributes

ilBiblFieldFactoryInterface $field_factory
 
ilDBInterface $db
 

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 ilBiblAttributeFactory

Author
: Benjamin Seglias bs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch

Definition at line 22 of file class.ilBiblAttributeFactory.php.

Constructor & Destructor Documentation

◆ __construct()

ilBiblAttributeFactory::__construct ( ilBiblFieldFactoryInterface  $field_factory)

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

References $DIC, and $field_factory.

28  {
29  global $DIC;
30  $this->field_factory = $field_factory;
31  $this->db = $DIC->database();
32  }
global $DIC
Definition: feed.php:28
ilBiblFieldFactoryInterface $field_factory

Member Function Documentation

◆ createAttribute()

ilBiblAttributeFactory::createAttribute ( string  $name,
string  $value,
int  $entry_id 
)

Implements ilBiblAttributeFactoryInterface.

Definition at line 92 of file class.ilBiblAttributeFactory.php.

92  : bool
93  {
94  $ilBiblAttribute = new ilBiblAttribute();
95  $ilBiblAttribute->setName($name);
96  $ilBiblAttribute->setValue($value);
97  $ilBiblAttribute->setEntryId($entry_id);
98  $ilBiblAttribute->store();
99 
100  $this->field_factory->findOrCreateFieldOfAttribute($ilBiblAttribute);
101 
102  return true;
103  }
if($format !==null) $name
Definition: metadata.php:247
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getAttributesForEntry()

ilBiblAttributeFactory::getAttributesForEntry ( ilBiblEntryInterface  $entry)

Implements ilBiblAttributeFactoryInterface.

Definition at line 59 of file class.ilBiblAttributeFactory.php.

References ilBiblEntryInterface\getId(), and ActiveRecord\where().

59  : array
60  {
61  return ilBiblAttribute::where(['entry_id' => $entry->getId()])->get();
62  }
static where($where, $operator=null)
+ Here is the call graph for this function:

◆ getPossibleValuesForFieldAndObject()

ilBiblAttributeFactory::getPossibleValuesForFieldAndObject ( ilBiblFieldInterface  $field,
int  $object_id 
)

Implements ilBiblAttributeFactoryInterface.

Definition at line 37 of file class.ilBiblAttributeFactory.php.

References $data, $res, and ilBiblFieldInterface\getIdentifier().

37  : array
38  {
39  $q = "SELECT DISTINCT(a.value) FROM il_bibl_data AS d
40 JOIN il_bibl_entry AS e ON e.data_id = d.id
41 JOIN il_bibl_attribute AS a on a.entry_id = e.id
42 WHERE a.name = %s AND d.id = %s";
43 
44  $res = $this->db->queryF($q, ['text', 'integer'], [
45  $field->getIdentifier(),
46  $object_id,
47  ]);
48  $result = [];
49  while ($data = $this->db->fetchObject($res)) {
50  $result[$data->value] = $data->value;
51  }
52 
53  return $result;
54  }
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:

◆ sortAttributes()

ilBiblAttributeFactory::sortAttributes ( array  $attributes)

Implements ilBiblAttributeFactoryInterface.

Definition at line 67 of file class.ilBiblAttributeFactory.php.

67  : array
68  {
69  $sorted = [];
70  $type_id = $this->field_factory->getType()->getId();
71  $max = 0;
72  foreach ($attributes as $attribute) {
73  if (!$attribute->getName()) {
74  continue;
75  }
76  $field = $this->field_factory->findOrCreateFieldByTypeAndIdentifier($type_id, $attribute->getName());
77  $position = $field->getPosition();
78  $position = $position ?: $max + 1;
79 
80  $max = (max($position, $max));
81  $sorted[$position] = $attribute;
82  }
83 
84  ksort($sorted);
85 
86  return $sorted;
87  }
$attributes
Definition: metadata.php:248

Field Documentation

◆ $db

ilDBInterface ilBiblAttributeFactory::$db
protected

Definition at line 25 of file class.ilBiblAttributeFactory.php.

◆ $field_factory

ilBiblFieldFactoryInterface ilBiblAttributeFactory::$field_factory
protected

Definition at line 24 of file class.ilBiblAttributeFactory.php.

Referenced by __construct().


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