ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
class.ilBiblOverviewGUI.php
Go to the documentation of this file.
1 <?php
2 
10 
14  protected $entry;
18  protected $html = '';
19 
20 
27  $this->entry = $entry;
28  $this->render();
29  }
30 
31 
35  protected function render() {
36  $attributes = $this->getEntry()->getAttributes();
37  //Get the model which declares which attributes to show in the overview table and how to show them
38  //example for overviewModels: $overviewModels['bib']['default'] => "[<strong>|bib_default_author|</strong>: ][|bib_default_title|. ]<Emph>[|bib_default_publisher|][, |bib_default_year|][, |bib_default_address|].</Emph>"
39  $overviewModels = ilObjBibliographic::getAllOverviewModels();
40  //get design for specific entry type or get filetypes default design if type is not specified
41  $entryType = $this->getEntry()->getType();
42  //if there is no model for the specific entrytype (book, article, ....) the entry overview will be structured by the default entrytype from the given filetype (ris, bib, ...)
43  if (! $overviewModels[$this->getEntry()->getFileType()][$entryType]) {
44  $entryType = 'default';
45  }
46  $single_entry = $overviewModels[$this->getEntry()->getFileType()][$entryType];
47  //split the model into single attributes (which begin and end with a bracket, eg [|bib_default_title|. ] )
48  //such values are saved in $placeholders[0] while the same values but whithout brackets are saved in $placeholders[1] (eg |bib_default_title|. )
49  preg_match_all('/\[(.*?)\]/', $single_entry, $placeholders);
50  foreach ($placeholders[1] as $key => $placeholder) {
51  //cut a moedel attribute like |bib_default_title|. in three pieces while $cuts[1] is the attribute key for the actual value and $cuts[0] is what comes before respectively $cuts[2] is what comes after the value if it is not empty.
52  $cuts = explode('|', $placeholder);
53  //if attribute key does not exist, because it comes from the default entry (e.g. ris_default_u2), we replace 'default' with the entrys type (e.g. ris_book_u2)
54  if (! $attributes[$cuts[1]]) {
55  $attribute_elements = explode('_', $cuts[1]);
56  $attribute_elements[1] = strtolower($this->getEntry()->getType());
57  $cuts[1] = implode('_', $attribute_elements);
58  }
59  if ($attributes[$cuts[1]]) {
60  //if the attribute for the attribute key exists, replace one attribute in the overview text line of a single entry with its actual value and the text before and after the value given by the model
61  $single_entry = str_replace($placeholders[0][$key], $cuts[0] . $attributes[$cuts[1]] . $cuts[2], $single_entry);
62  // replace the <emph> tags with a span, in order to make text italic by css
63  do {
64  $first_sign_after_begin_emph_tag = strpos(strtolower($single_entry), '<emph>') + 6;
65  $last_sign_after_end_emph_tag = strpos(strtolower($single_entry), '</emph>');
66  $italic_text_length = $last_sign_after_end_emph_tag - $first_sign_after_begin_emph_tag;
67  //would not be true if there is no <emph> tag left
68  if ($last_sign_after_end_emph_tag) {
69  $italic_text = substr($single_entry, $first_sign_after_begin_emph_tag, $italic_text_length);
70  //parse
71  $it_tpl = new ilTemplate("tpl.bibliographic_italicizer.html", true, true, "Modules/Bibliographic");
72  $it_tpl->setCurrentBlock("italic_section");
73  $it_tpl->setVariable('ITALIC_STRING', $italic_text);
74  $it_tpl->parseCurrentBlock();
75  //replace the emph tags and the text between with the parsed text from il_tpl
76  $text_before_emph_tag = substr($single_entry, 0, $first_sign_after_begin_emph_tag - 6);
77  $text_after_emph_tag = substr($single_entry, $last_sign_after_end_emph_tag + 7);
78  $single_entry = $text_before_emph_tag . $it_tpl->get() . $text_after_emph_tag;
79  }
80  } while ($last_sign_after_end_emph_tag);
81  } else {
82  //if the attribute for the attribute key does not exist, just remove this attribute-key from the overview text line of a single entry
83  $single_entry = str_replace($placeholders[0][$key], '', $single_entry);
84  }
85  }
86 
87  $this->setHtml($single_entry);
88  }
89 
90 
94  public function getHtml() {
95  return $this->html;
96  }
97 
98 
102  public function setHtml($html) {
103  $this->html = $html;
104  }
105 
106 
110  public function getEntry() {
111  return $this->entry;
112  }
113 
114 
118  public function setEntry($entry) {
119  $this->entry = $entry;
120  }
121 }
122 
123 ?>
special template class to simplify handling of ITX/PEAR
Class ilBiblOverviewGUI.
Class ilBibliographicEntry.
__construct(ilBibliographicEntry $entry)
ilBiblOverviewGUI constructor.