ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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 (protected \ilBiblLibraryInterface $library, protected \ilBiblFactoryFacade $facade, protected \ilCtrlInterface $ctrl, protected \ilLanguage $lng, protected \ILIAS\DI\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

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 ( protected \ilBiblLibraryInterface  $library,
protected \ilBiblFactoryFacade  $facade,
protected \ilCtrlInterface  $ctrl,
protected \ilLanguage  $lng,
protected \ILIAS\DI\UIServices  $ui 
)

ilBiblLibraryPresentationGUI constructor.

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

34  {
35  }

Member Function Documentation

◆ formatAttribute()

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

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

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

Referenced by generateLibraryLink().

126  : string
127  {
128  if ($type->getStringRepresentation() === 'ris') {
129  switch ($a) {
130  case 't1':
131  case 'ti':
132  $a = "title";
133  break;
134  case 'au':
135  $a = "author";
136  break;
137  case 'sn':
138  if (strlen($attributes[$prefix . "sn"]) <= 9) {
139  $a = "issn";
140  } else {
141  $a = "isbn";
142  }
143  break;
144  case 'py':
145  $a = "date";
146  break;
147  case 'is':
148  $a = "issue";
149  break;
150  case 'vl':
151  $a = "volume";
152  break;
153  }
154  } elseif ($type->getStringRepresentation() === 'bib') {
155  switch ($a) {
156  case 'number':
157  $a = "issue";
158  break;
159  case 'year':
160  $a = "date";
161  break;
162  }
163  }
164 
165  return $a;
166  }
$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 40 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().

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

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

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

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