ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilBiblOverviewGUI.php
Go to the documentation of this file.
1 <?php
2 
10 {
11 
15  protected $entry;
19  protected $html = '';
20 
21 
28  {
29  $this->entry = $entry;
30  $this->render();
31  }
32 
33 
37  protected function render()
38  {
39  $attributes = $this->getEntry()->getAttributes();
40  //Get the model which declares which attributes to show in the overview table and how to show them
41  //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>"
42  $overviewModels = ilObjBibliographic::getAllOverviewModels();
43  //get design for specific entry type or get filetypes default design if type is not specified
44  $entryType = $this->getEntry()->getType();
45  //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, ...)
46  if (!$overviewModels[$this->getEntry()->getFileType()][$entryType]) {
47  $entryType = 'default';
48  }
49  $single_entry = $overviewModels[$this->getEntry()->getFileType()][$entryType];
50  //split the model into single attributes (which begin and end with a bracket, eg [|bib_default_title|. ] )
51  //such values are saved in $placeholders[0] while the same values but whithout brackets are saved in $placeholders[1] (eg |bib_default_title|. )
52  preg_match_all('/\[(.*?)\]/', $single_entry, $placeholders);
53  foreach ($placeholders[1] as $key => $placeholder) {
54  //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.
55  $cuts = explode('|', $placeholder);
56  //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)
57  if (!$attributes[$cuts[1]]) {
58  $attribute_elements = explode('_', $cuts[1]);
59  $attribute_elements[1] = strtolower($this->getEntry()->getType());
60  $cuts[1] = implode('_', $attribute_elements);
61  }
62  if ($attributes[$cuts[1]]) {
63  //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
64  $single_entry = str_replace(
65  $placeholders[0][$key],
66  $cuts[0] . $attributes[$cuts[1]]
67  . $cuts[2],
68  $single_entry
69  );
70  // replace the <emph> tags with a span, in order to make text italic by css
71  do {
72  $first_sign_after_begin_emph_tag = strpos(strtolower($single_entry), '<emph>')
73  + 6;
74  $last_sign_after_end_emph_tag = strpos(strtolower($single_entry), '</emph>');
75  $italic_text_length = $last_sign_after_end_emph_tag
76  - $first_sign_after_begin_emph_tag;
77  //would not be true if there is no <emph> tag left
78  if ($last_sign_after_end_emph_tag) {
79  $italic_text = substr($single_entry, $first_sign_after_begin_emph_tag, $italic_text_length);
80  //parse
81  $it_tpl = new ilTemplate("tpl.bibliographic_italicizer.html", true, true, "Modules/Bibliographic");
82  $it_tpl->setCurrentBlock("italic_section");
83  $it_tpl->setVariable('ITALIC_STRING', $italic_text);
84  $it_tpl->parseCurrentBlock();
85  //replace the emph tags and the text between with the parsed text from il_tpl
86  $text_before_emph_tag = substr(
87  $single_entry,
88  0,
89  $first_sign_after_begin_emph_tag
90  - 6
91  );
92  $text_after_emph_tag = substr(
93  $single_entry,
94  $last_sign_after_end_emph_tag
95  + 7
96  );
97  $single_entry = $text_before_emph_tag . $it_tpl->get()
98  . $text_after_emph_tag;
99  }
100  } while ($last_sign_after_end_emph_tag);
101  } else {
102  //if the attribute for the attribute key does not exist, just remove this attribute-key from the overview text line of a single entry
103  $single_entry = str_replace($placeholders[0][$key], '', $single_entry);
104  }
105  }
106 
107  $this->setHtml($single_entry);
108  }
109 
110 
114  public function getHtml()
115  {
116  return $this->html;
117  }
118 
119 
123  public function setHtml($html)
124  {
125  $this->html = $html;
126  }
127 
128 
132  public function getEntry()
133  {
134  return $this->entry;
135  }
136 
137 
141  public function setEntry($entry)
142  {
143  $this->entry = $entry;
144  }
145 }
$attributes
special template class to simplify handling of ITX/PEAR
Class ilBiblOverviewGUI.
html()
Class ilBibliographicEntry.
$key
Definition: croninfo.php:18
__construct(ilBibliographicEntry $entry)
ilBiblOverviewGUI constructor.