ILIAS  release_7 Revision v7.30-3-g800a261c036
ilBiblLibraryPresentationGUI Class Reference

Class ilBiblLibraryPresentationGUI. More...

+ Collaboration diagram for ilBiblLibraryPresentationGUI:

Public Member Functions

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

Protected Attributes

 $library
 
 $facade
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

ilBiblLibraryPresentationGUI constructor.

Parameters
\ilBiblLibraryInterface$library

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

References $facade, and $library.

Member Function Documentation

◆ formatAttribute()

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

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

142 {
143 if ($type->getStringRepresentation() === 'ris') {
144 switch ($a) {
145 case 'ti':
146 $a = "title";
147 break;
148 case 't1':
149 $a = "title";
150 break;
151 case 'au':
152 $a = "author";
153 break;
154 case 'sn':
155 if (strlen($attributes[$prefix . "sn"]) <= 9) {
156 $a = "issn";
157 } else {
158 $a = "isbn";
159 }
160 break;
161 case 'py':
162 $a = "date";
163 break;
164 case 'is':
165 $a = "issue";
166 break;
167 case 'vl':
168 $a = "volume";
169 break;
170 }
171 } elseif ($type->getStringRepresentation() === 'bib') {
172 switch ($a) {
173 case 'number':
174 $a = "issue";
175 break;
176 case 'year':
177 $a = "date";
178 break;
179 }
180 }
181
182 return $a;
183 }
$attributes
Definition: metadata.php:231
$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,
  $type 
)
Parameters
\ilBiblEntry$entry
$type
Returns
string
Deprecated:
REFACTOR Mit Attribute Objekten arbeiten statt mit Array. Evtl. URL Erstellung vereinfachen

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

43 {
44 $attributes = $this->facade->entryFactory()->loadParsedAttributesByEntryId($entry->getId());
45 $type = $this->facade->typeFactory()->getInstanceForString($type);
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 (sizeof($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 full link
98 $full_link = $this->library->getUrl() . $url_params;
99
100 return $full_link;
101 }
formatAttribute($a, $type, $attributes, $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 
)
Parameters
\ilBiblFactoryFacadeInterface$bibl_factory_facade
\ilBiblEntry$entry
Returns
string

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

111 {
112 if ($this->library->getImg()) {
114 $button->setUrl($this->generateLibraryLink($entry, $bibl_factory_facade->type()->getStringRepresentation()));
115 $button->setImage($this->library->getImg(), false);
116 $button->setTarget('_blank');
117
118 return $button->render();
119 } else {
120 $button = ilLinkButton::getInstance();
121 $button->setUrl($this->generateLibraryLink($entry, $bibl_factory_facade->type()->getStringRepresentation()));
122 $button->setTarget('_blank');
123 $button->setCaption('bibl_link_online');
124
125 return $button->render();
126 }
127 }
static getInstance()
Factory.
static getInstance()
Factory.

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

+ Here is the call graph for this function:

Field Documentation

◆ $facade

ilBiblLibraryPresentationGUI::$facade
protected

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

Referenced by __construct().

◆ $library

ilBiblLibraryPresentationGUI::$library
protected

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

Referenced by __construct().


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