ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 */
3 
12 {
13  const TABLE_NAME = 'il_bibl_settings';
14 
15 
20  public static function returnDbTableName()
21  {
22  return self::TABLE_NAME;
23  }
24 
25 
29  public function getConnectorContainerName()
30  {
31  return self::TABLE_NAME;
32  }
33 
34 
46  protected $id;
55  protected $name;
64  protected $url;
72  protected $img;
80  protected $show_in_list;
81 
82 
86  public static function getAll()
87  {
88  return self::get();
89  }
90 
91 
99  {
100  $attributes = $entry->getAttributes();
101  switch ($type) {
102  case 'bib':
103  $prefix = "bib_default_";
104  if (!empty($attributes[$prefix . "isbn"])) {
105  $attr = array( "isbn" );
106  } elseif (!empty($attributes[$prefix . "pmid"])) {
107  $attr = array( "pmid" );
108  } elseif (!empty($attributes[$prefix . "doi"])) {
109  $attr = array( "doi" );
110  } elseif (!empty($attributes[$prefix . "issn"])) {
111  $attr = array( "issn" );
112  } else {
113  $attr = array( "title", "author", "year", "number", "volume" );
114  }
115  break;
116  case 'ris':
117  $prefix = "ris_" . strtolower($entry->getType()) . "_";
118  if (!empty($attributes[$prefix . "sn"])) {
119  $attr = array( "sn" );
120  } elseif (!empty($attributes[$prefix . "do"])) {
121  $attr = array( "do" );
122  } else {
123  $attr = array( "ti", "t1", "au", "py", "is", "vl" );
124  }
125  break;
126  }
127 
128  $url_params = "?";
129  if (sizeof($attr) == 1) {
130  if (($attr[0] == "doi") || ($attr[0] == "pmid")) {
131  $url_params .= "id=" . $this->formatAttribute($attr[0], $type, $attributes, $prefix) . "%3A" . $attributes[$prefix . $attr[0]];
132  } elseif ($attr[0] == "do") {
133  $url_params .= "id=" . $this->formatAttribute($attr[0], $type, $attributes, $prefix) . "i%3A" . $attributes[$prefix . $attr[0]];
134  } else {
135  $url_params .= $this->formatAttribute($attr[0], $type, $attributes, $prefix) . "=" . urlencode($attributes[$prefix . $attr[0]]);
136  }
137  } else {
138  foreach ($attr as $a) {
139  if (array_key_exists($prefix . $a, $attributes)) {
140  if (strlen($url_params) > 1) {
141  $url_params .= "&";
142  }
143  $url_params .= $this->formatAttribute($a, $type, $attributes, $prefix) . "=" . urlencode($attributes[$prefix . $a]);
144  }
145  }
146  }
147 
148  // return full link
149  $full_link = $this->getUrl() . $url_params;
150 
151  return $full_link;
152  }
153 
154 
161  public function getButton(ilObjBibliographic $bibl_obj, ilBibliographicEntry $entry)
162  {
163  if ($this->getImg()) {
164  $button = ilImageLinkButton::getInstance();
165  $button->setUrl($this->generateLibraryLink($entry, $bibl_obj->getFiletype()));
166  $button->setImage($this->getImg(), false);
167  } else {
168  $button = ilLinkButton::getInstance();
169  $button->setUrl($this->generateLibraryLink($entry, $bibl_obj->getFiletype()));
170  $button->setCaption('bibl_link_online');
171  }
172 
173  $button->setTarget('_blank');
174 
175  return $button->render();
176  }
177 
178 
187  private function formatAttribute($a, $type, $attributes, $prefix)
188  {
189  if ($type = 'ris') {
190  switch ($a) {
191  case 'ti':
192  $a = "title";
193  break;
194  case 't1':
195  $a = "title";
196  break;
197  case 'au':
198  $a = "author";
199  break;
200  case 'sn':
201  if (strlen($attributes[$prefix . "sn"]) <= 9) {
202  $a = "issn";
203  } else {
204  $a = "isbn";
205  }
206  break;
207  case 'py':
208  $a = "date";
209  break;
210  case 'is':
211  $a = "issue";
212  break;
213  case 'vl':
214  $a = "volume";
215  break;
216  }
217  } elseif ($type = 'bib') {
218  switch ($a) {
219  case 'number':
220  $a = "issue";
221  break;
222  case 'year':
223  $a = "date";
224  break;
225  }
226  }
227 
228  return $a;
229  }
230 
231 
235  public function getId()
236  {
237  return $this->id;
238  }
239 
240 
244  public function setId($id)
245  {
246  $this->id = $id;
247  }
248 
249 
253  public function getImg()
254  {
255  return $this->img;
256  }
257 
258 
262  public function setImg($img)
263  {
264  $this->img = $img;
265  }
266 
267 
271  public function getName()
272  {
273  return $this->name;
274  }
275 
276 
280  public function setName($name)
281  {
282  $this->name = $name;
283  }
284 
285 
289  public function getShowInList()
290  {
291  return $this->show_in_list;
292  }
293 
294 
298  public function setShowInList($show_in_list)
299  {
300  $this->show_in_list = $show_in_list;
301  }
302 
303 
307  public function getUrl()
308  {
309  return $this->url;
310  }
311 
312 
316  public function setUrl($url)
317  {
318  $this->url = $url;
319  }
320 }
Class ilBibliographicSetting.
getButton(ilObjBibliographic $bibl_obj, ilBibliographicEntry $entry)
$type
Class ActiveRecord.
formatAttribute($a, $type, $attributes, $prefix)
$attributes
generateLibraryLink(ilBibliographicEntry $entry, $type)
Create styles array
The data for the language used.
Class ilBibliographicEntry.
Class ilObjBibliographic.