ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilBiblLibraryPresentationGUI Class Reference

Class ilBiblLibraryPresentationGUI. More...

+ Collaboration diagram for ilBiblLibraryPresentationGUI:

Public Member Functions

 __construct (protected \ilBiblLibraryInterface $library, protected \ilBiblFactoryFacade $facade, protected \ilCtrlInterface $ctrl, protected \ilLanguage $lng, protected UIServices $ui)
 ilBiblLibraryPresentationGUI constructor. More...
 
 generateLibraryLink (ilBiblEntry $entry, string $type)
 
 getButton (ilBiblFactoryFacadeInterface $bibl_factory_facade, ilBiblEntry $entry)
 
 formatAttribute (string $a, ilBiblTypeInterface $type, array $attributes, string $prefix)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilBiblLibraryPresentationGUI::__construct ( protected \ilBiblLibraryInterface  $library,
protected \ilBiblFactoryFacade  $facade,
protected \ilCtrlInterface  $ctrl,
protected \ilLanguage  $lng,
protected UIServices  $ui 
)

ilBiblLibraryPresentationGUI constructor.

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

36  {
37  }

Member Function Documentation

◆ formatAttribute()

ilBiblLibraryPresentationGUI::formatAttribute ( string  $a,
ilBiblTypeInterface  $type,
array  $attributes,
string  $prefix 
)
Deprecated:
REFACTOR type via type factory verwenden

Definition at line 128 of file class.ilBiblLibraryPresentationGUI.php.

References Vendor\Package\$a, and ilBiblTypeInterface\getStringRepresentation().

Referenced by generateLibraryLink().

128  : string
129  {
130  if ($type->getStringRepresentation() === 'ris') {
131  switch ($a) {
132  case 't1':
133  case 'ti':
134  $a = "title";
135  break;
136  case 'au':
137  $a = "author";
138  break;
139  case 'sn':
140  $a = strlen((string) $attributes[$prefix . "sn"]) <= 9 ? "issn" : "isbn";
141  break;
142  case 'py':
143  $a = "date";
144  break;
145  case 'is':
146  $a = "issue";
147  break;
148  case 'vl':
149  $a = "volume";
150  break;
151  }
152  } elseif ($type->getStringRepresentation() === 'bib') {
153  switch ($a) {
154  case 'number':
155  $a = "issue";
156  break;
157  case 'year':
158  $a = "date";
159  break;
160  }
161  }
162 
163  return $a;
164  }
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateLibraryLink()

ilBiblLibraryPresentationGUI::generateLibraryLink ( ilBiblEntry  $entry,
string  $type 
)
Deprecated:
REFACTOR Mit Attribute Objekten arbeiten statt mit Array.

Evtl. URL Erstellung vereinfachen

Definition at line 42 of file class.ilBiblLibraryPresentationGUI.php.

References Vendor\Package\$a, ilBiblTypeFactoryInterface\DATA_TYPE_BIBTEX, ilBiblTypeFactoryInterface\DATA_TYPE_RIS, formatAttribute(), ilBiblEntry\getId(), and ilBiblEntry\getType().

Referenced by getButton().

42  : string
43  {
44  $attributes = $this->facade->entryFactory()->loadParsedAttributesByEntryId($entry->getId());
45  $type = $this->facade->typeFactory()->getInstanceForString($type);
46  $attr = [];
47  $prefix = '';
48  switch ($type->getId()) {
50  $prefix = "bib_default_";
51  if (!empty($attributes[$prefix . "isbn"])) {
52  $attr = ["isbn"];
53  } elseif (!empty($attributes[$prefix . "pmid"])) {
54  $attr = ["pmid"];
55  } elseif (!empty($attributes[$prefix . "doi"])) {
56  $attr = ["doi"];
57  } elseif (!empty($attributes[$prefix . "issn"])) {
58  $attr = ["issn"];
59  } else {
60  $attr = ["title", "author", "year", "number", "volume"];
61  }
62  break;
64  $prefix = "ris_" . strtolower($entry->getType()) . "_";
65  if (!empty($attributes[$prefix . "sn"])) {
66  $attr = ["sn"];
67  } elseif (!empty($attributes[$prefix . "do"])) {
68  $attr = ["do"];
69  } else {
70  $attr = ["ti", "t1", "au", "py", "is", "vl"];
71  }
72  break;
73  }
74 
75  $url_params = "?";
76  if (count($attr) === 1) {
77  if (($attr[0] === "doi") || ($attr[0] === "pmid")) {
78  $url_params .= "id=" . $this->formatAttribute($attr[0], $type, $attributes, $prefix)
79  . "%3A" . $attributes[$prefix . $attr[0]];
80  } elseif ($attr[0] === "do") {
81  $url_params .= "id=" . $this->formatAttribute($attr[0], $type, $attributes, $prefix)
82  . "i%3A" . $attributes[$prefix . $attr[0]];
83  } else {
84  $url_params .= $this->formatAttribute($attr[0], $type, $attributes, $prefix) . "="
85  . urlencode((string) $attributes[$prefix . $attr[0]]);
86  }
87  } else {
88  foreach ($attr as $a) {
89  if (array_key_exists($prefix . $a, $attributes)) {
90  if (strlen($url_params) > 1) {
91  $url_params .= "&";
92  }
93  $url_params .= $this->formatAttribute($a, $type, $attributes, $prefix) . "="
94  . urlencode((string) $attributes[$prefix . $a]);
95  }
96  }
97  }
98 
99  return $this->library->getUrl() . $url_params;
100  }
formatAttribute(string $a, ilBiblTypeInterface $type, array $attributes, string $prefix)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getButton()

ilBiblLibraryPresentationGUI::getButton ( ilBiblFactoryFacadeInterface  $bibl_factory_facade,
ilBiblEntry  $entry 
)
Returns
string|void

Definition at line 105 of file class.ilBiblLibraryPresentationGUI.php.

References generateLibraryLink(), ILIAS\Repository\lng(), null, ilBiblFactoryFacadeInterface\type(), and ILIAS\Repository\ui().

106  {
107  $action = $this->generateLibraryLink($entry, $bibl_factory_facade->type()->getStringRepresentation());
108  if (null !== ($img_path = $this->library->getImg())) {
109  $icon = $this->ui->factory()->symbol()->icon()->custom($img_path, "");
110  $btn_online_link = $this->ui->factory()->button()->bulky(
111  $icon,
112  $this->lng->txt('bibl_link_online'),
113  $action
114  );
115  } else {
116  $btn_online_link = $this->ui->factory()->button()->standard(
117  $this->lng->txt('bibl_link_online'),
118  $action
119  );
120  }
121 
122  return $this->ui->renderer()->render($btn_online_link);
123  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
generateLibraryLink(ilBiblEntry $entry, string $type)
+ Here is the call graph for this function:

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