ILIAS  release_8 Revision v8.24
ilBiblLibraryPresentationGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilBiblLibraryPresentationGUI:

Public Member Functions

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

Protected Attributes

ilBiblLibraryInterface $library
 
ilBiblFactoryFacade $facade
 

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 ilBiblLibraryPresentationGUI

Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch

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

Constructor & Destructor Documentation

◆ __construct()

ilBiblLibraryPresentationGUI::__construct ( \ilBiblLibraryInterface  $library,
\ilBiblFactoryFacade  $facade 
)

ilBiblLibraryPresentationGUI constructor.

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

32 {
33 $this->library = $library;
34 $this->facade = $facade;
35 }

References $facade, and $library.

Member Function Documentation

◆ formatAttribute()

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

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

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

References Vendor\Package\$a, $attributes, and $type.

Referenced by generateLibraryLink().

+ 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 40 of file class.ilBiblLibraryPresentationGUI.php.

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

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

Referenced by getButton().

+ 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 103 of file class.ilBiblLibraryPresentationGUI.php.

104 {
105 if ($this->library->getImg()) {
107 $button->setImage($this->library->getImg(), false);
108 $button->addCSSClass("btn");
109 $button->addCSSClass("btn-default");
110 } else {
111 $button = ilLinkButton::getInstance();
112 }
113 $button->setUrl($this->generateLibraryLink($entry, $bibl_factory_facade->type()->getStringRepresentation()));
114 $button->setTarget('_blank');
115 $button->setCaption('bibl_link_online');
116
117 return $button->render();
118 }
generateLibraryLink(ilBiblEntry $entry, string $type)

References generateLibraryLink(), ilImageLinkButton\getInstance(), ilLinkButton\getInstance(), and ilBiblFactoryFacadeInterface\type().

+ Here is the call graph for this function:

Field Documentation

◆ $facade

ilBiblFactoryFacade ilBiblLibraryPresentationGUI::$facade
protected

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

Referenced by __construct().

◆ $library

ilBiblLibraryInterface ilBiblLibraryPresentationGUI::$library
protected

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

Referenced by __construct().


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