ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilBibliographicSetting.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3if (class_exists('ActiveRecord') != true) {
4 require_once('./Services/ActiveRecord/class.ActiveRecord.php');
5}
6
15
16 const TABLE_NAME = 'il_bibl_settings';
17
18
23 static function returnDbTableName() {
24 return self::TABLE_NAME;
25 }
26
27
31 public function getConnectorContainerName() {
32 return self::TABLE_NAME;
33 }
34
35
47 protected $id;
56 protected $name;
65 protected $url;
73 protected $img;
81 protected $show_in_list;
82
83
87 public static function getAll() {
88 return self::get();
89 }
90
91
98 public function generateLibraryLink(ilBibliographicEntry $entry, $type) {
99 $attributes = $entry->getAttributes();
100 switch ($type) {
101 case 'bib':
102 $prefix = "bib_default_";
103 if (!empty($attributes[$prefix . "isbn"])) {
104 $attr = Array( "isbn" );
105 } elseif (!empty($attributes[$prefix . "issn"])) {
106 $attr = Array( "issn" );
107 } else {
108 $attr = Array( "title", "author", "year", "number", "volume" );
109 }
110 break;
111 case 'ris':
112 $prefix = "ris_" . strtolower($entry->getType()) . "_";
113 if (!empty($attributes[$prefix . "sn"])) {
114 $attr = Array( "sn" );
115 } else {
116 $attr = Array( "ti", "t1", "au", "py", "is", "vl" );
117 }
118 break;
119 }
120
121 $url_params = "?";
122 if (sizeof($attr) == 1) {
123 $url_params .= $this->formatAttribute($attr[0], $type, $attributes, $prefix) . "=" . urlencode($attributes[$prefix . $attr[0]]);
124 } else {
125 foreach ($attr as $a) {
126 if (array_key_exists($prefix . $a, $attributes)) {
127 if (strlen($url_params) > 1) {
128 $url_params .= "&";
129 }
130 $url_params .= $this->formatAttribute($a, $type, $attributes, $prefix) . "=" . urlencode($attributes[$prefix . $a]);
131 }
132 }
133 }
134
135 // return full link
136 $full_link = $this->getUrl() . $url_params;
137
138 return $full_link;
139 }
140
141
148 public function getButton(ilObjBibliographic $bibl_obj, ilBibliographicEntry $entry) {
149 if ($this->getImg()) {
150 require_once('./Services/UIComponent/Button/classes/class.ilImageLinkButton.php');
152 $button->setUrl($this->generateLibraryLink($entry, $bibl_obj->getFiletype()));
153 $button->setImage($this->getImg(), false);
154 } else {
155 require_once('./Services/UIComponent/Button/classes/class.ilLinkButton.php');
156 $button = ilLinkButton::getInstance();
157 $button->setUrl($this->generateLibraryLink($entry, $bibl_obj->getFiletype()));
158 $button->setCaption('bibl_link_online');
159 }
160
161 $button->setTarget('_blank');
162
163 return $button->render();
164 }
165
166
175 private function formatAttribute($a, $type, $attributes, $prefix) {
176 if ($type = 'ris') {
177 switch ($a) {
178 case 'ti':
179 $a = "title";
180 break;
181 case 't1':
182 $a = "title";
183 break;
184 case 'au':
185 $a = "author";
186 break;
187 case 'sn':
188 if (strlen($attributes[$prefix . "sn"]) <= 9) {
189 $a = "issn";
190 } else {
191 $a = "isbn";
192 }
193 break;
194 case 'py':
195 $a = "date";
196 break;
197 case 'is':
198 $a = "issue";
199 break;
200 case 'vl':
201 $a = "volume";
202 break;
203 }
204 } elseif ($type = 'bib') {
205 switch ($a) {
206 case "number":
207 $a = "issue";
208 break;
209 case "year":
210 $a = "date";
211 break;
212 }
213 }
214
215 return $a;
216 }
217
218
222 public function getId() {
223 return $this->id;
224 }
225
226
230 public function setId($id) {
231 $this->id = $id;
232 }
233
234
238 public function getImg() {
239 return $this->img;
240 }
241
242
246 public function setImg($img) {
247 $this->img = $img;
248 }
249
250
254 public function getName() {
255 return $this->name;
256 }
257
258
262 public function setName($name) {
263 $this->name = $name;
264 }
265
266
270 public function getShowInList() {
271 return $this->show_in_list;
272 }
273
274
278 public function setShowInList($show_in_list) {
279 $this->show_in_list = $show_in_list;
280 }
281
282
286 public function getUrl() {
287 return $this->url;
288 }
289
290
294 public function setUrl($url) {
295 $this->url = $url;
296 }
297}
298
299?>
Class ActiveRecord.
Class ilBibliographicEntry.
Class ilBibliographicSetting.
getButton(ilObjBibliographic $bibl_obj, ilBibliographicEntry $entry)
generateLibraryLink(ilBibliographicEntry $entry, $type)
formatAttribute($a, $type, $attributes, $prefix)
static getInstance()
Factory.
static getInstance()
Factory.
Class ilObjBibliographic.