ILIAS  release_4-4 Revision
ilBibliographicEntry Class Reference

Class ilObjBibliographic. More...

+ Collaboration diagram for ilBibliographicEntry:

Public Member Functions

 __construct ($file_type, $entry_id=null)
 
 doCreate ()
 Create object. More...
 
 doRead ()
 Read data from database tables il_bibl_entry and il_bibl_attribute. More...
 
 doUpdate ()
 Update database tables il_bibl_entry and il_bibl_attribute. More...
 
 doDelete ()
 Delete data from db. More...
 
 setAttributes ($attributes)
 
 getAttributes ()
 
 setOverwiew ()
 
 getOverwiew ()
 
 setBibliographicObjId ($bibliographic_obj_id)
 
 getBibliographicObjId ()
 
 setEntryId ($entry_id)
 
 getEntryId ()
 
 setType ($type)
 
 getType ()
 

Static Public Member Functions

static __getAllEntries ($object_id)
 Read all entries from the database. More...
 

Protected Member Functions

 loadAttributes ()
 Reads all the entrys attributes from database. More...
 

Protected Attributes

 $bibliographic_obj_id
 
 $entry_id
 
 $type
 
 $attributes
 
 $file_type
 

Detailed Description

Class ilObjBibliographic.

Author
Gabriel Comte
Version
Id
class.ilBibliographicEntry.php 2012-11-15 16:11:42Z gcomte

Definition at line 12 of file class.ilBibliographicEntry.php.

Constructor & Destructor Documentation

◆ __construct()

ilBibliographicEntry::__construct (   $file_type,
  $entry_id = null 
)

Definition at line 46 of file class.ilBibliographicEntry.php.

References $entry_id, $file_type, doRead(), and setEntryId().

47  {
48  $this->file_type = $file_type;
49  if($entry_id)
50  {
51  $this->setEntryId($entry_id);
52  $this->doRead();
53  }
54  }
doRead()
Read data from database tables il_bibl_entry and il_bibl_attribute.
+ Here is the call graph for this function:

Member Function Documentation

◆ __getAllEntries()

static ilBibliographicEntry::__getAllEntries (   $object_id)
static

Read all entries from the database.

Parameters
$object_id
Returns
array

Definition at line 332 of file class.ilBibliographicEntry.php.

Referenced by ilDataBibliographicRecordListTableGUI\__construct().

333  {
334  global $ilDB;
335 
336  $entries = array();
337 
338  $set = $ilDB->query("SELECT id FROM il_bibl_entry ".
339  " WHERE data_id = ".$ilDB->quote($object_id, "integer")
340  );
341 
342  while ($rec = $ilDB->fetchAssoc($set))
343  {
344  $entries[]['entry_id'] = $rec['id'];
345  }
346 
347  return $entries;
348 
349  }
+ Here is the caller graph for this function:

◆ doCreate()

ilBibliographicEntry::doCreate ( )

Create object.

Definition at line 62 of file class.ilBibliographicEntry.php.

References getAttributes(), and setEntryId().

63  {
64  global $ilDB;
65 
66  //auto-increment il_bibl_entry
67  $this->setEntryId($ilDB->nextID('il_bibl_entry'));
68 
69  //table il_bibl_entry
70  $ilDB->manipulate("INSERT INTO il_bibl_entry " . "(data_id, id, type) VALUES (" .
71  $ilDB->quote($this->getBibliographicObjId(), "integer") . "," . // data_id
72  $ilDB->quote($this->getEntryId(), "integer") . "," . // id
73  $ilDB->quote($this->getType(), "text") . // type
74  ")");
75  //table il_bibl_attribute
76  foreach($this->getAttributes() as $attribute)
77  {
78  //auto-increment il_bibl_attribute
79  $id = $ilDB->nextID('il_bibl_attribute');
80 
81  $ilDB->manipulate("INSERT INTO il_bibl_attribute " . "(entry_id, name, value, id) VALUES (" .
82  $ilDB->quote($this->getEntryId(), "integer") . "," . // entry_id
83  $ilDB->quote($attribute['name'], "text") . "," . // name
84  $ilDB->quote($attribute['value'], "text") . "," . // value
85  $ilDB->quote($id, "integer") . // id
86  ")");
87  }
88  }
+ Here is the call graph for this function:

◆ doDelete()

ilBibliographicEntry::doDelete ( )

Delete data from db.

Definition at line 137 of file class.ilBibliographicEntry.php.

138  {
139  global $ilDB;
140 
141  $this->emptyCache();
142  $this->deleteOptions();
143 
144  $ilDB->manipulate("DELETE FROM il_bibl_entry WHERE id = " . $ilDB->quote($this->getEntryId(), "integer"));
145  $ilDB->manipulate("DELETE FROM il_bibl_attribute WHERE entry_id = " . $ilDB->quote($this->getEntryId(), "integer"));
146  }

◆ doRead()

ilBibliographicEntry::doRead ( )

Read data from database tables il_bibl_entry and il_bibl_attribute.

Definition at line 93 of file class.ilBibliographicEntry.php.

References loadAttributes(), setAttributes(), setOverwiew(), and setType().

Referenced by __construct().

94  {
95  global $ilDB;
96 
97  //table il_bibl_entry
98  $set = $ilDB->query("SELECT * FROM il_bibl_entry " .
99  " WHERE id = ".$ilDB->quote($this->getEntryId(), "integer")
100  );
101  while ($rec = $ilDB->fetchAssoc($set))
102  {
103  $this->setType($rec['type']);
104  }
105 
106  $this->setAttributes($this->loadAttributes());
107 
108  $this->setOverwiew();
109  }
loadAttributes()
Reads all the entrys attributes from database.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doUpdate()

ilBibliographicEntry::doUpdate ( )

Update database tables il_bibl_entry and il_bibl_attribute.

Definition at line 114 of file class.ilBibliographicEntry.php.

References getAttributes().

115  {
116  global $ilDB;
117 
118  //table il_bibl_entry
119  $ilDB->manipulate($up = "UPDATE il_bibl_entry SET " . " type = " .
120  $ilDB->quote($this->getType(), "integer") . // type
121  " WHERE id = " . $ilDB->quote($this->getEntryId(), "integer"));
122 
123 
124  //table il_bibl_attribute
125  foreach($this->getAttributes() as $attribute)
126  {
127  $ilDB->manipulate($up = "UPDATE il_bibl_attribute SET " .
128  " name = " . $ilDB->quote($attribute['name'], "integer") . "," . // name
129  " value = " . $ilDB->quote($attribute['value'], "integer") . "," . // value
130  " WHERE id = " . $ilDB->quote($attribute['id'], "integer"));
131  }
132  }
+ Here is the call graph for this function:

◆ getAttributes()

ilBibliographicEntry::getAttributes ( )

Definition at line 192 of file class.ilBibliographicEntry.php.

References $attributes.

Referenced by doCreate(), doUpdate(), setOverwiew(), and ilBibliographicDetailsGUI\showDetails().

193  {
194  return $this->attributes;
195  }
+ Here is the caller graph for this function:

◆ getBibliographicObjId()

ilBibliographicEntry::getBibliographicObjId ( )
Returns
int

Definition at line 289 of file class.ilBibliographicEntry.php.

References $bibliographic_obj_id.

290  {
292 
293  }

◆ getEntryId()

ilBibliographicEntry::getEntryId ( )
Returns
int

Definition at line 306 of file class.ilBibliographicEntry.php.

References $entry_id.

307  {
308  return $this->entry_id;
309  }

◆ getOverwiew()

ilBibliographicEntry::getOverwiew ( )
Returns
string

Definition at line 272 of file class.ilBibliographicEntry.php.

273  {
274  return $this->Overwiew;
275  }

◆ getType()

ilBibliographicEntry::getType ( )
Returns
string

Definition at line 322 of file class.ilBibliographicEntry.php.

References $type.

Referenced by loadAttributes(), and setOverwiew().

323  {
324  return $this->type;
325  }
+ Here is the caller graph for this function:

◆ loadAttributes()

ilBibliographicEntry::loadAttributes ( )
protected

Reads all the entrys attributes from database.

Returns
array Attributes of an entry

Definition at line 152 of file class.ilBibliographicEntry.php.

References $type, and getType().

Referenced by doRead().

153  {
154  global $ilDB;
155 
156  $all_attributes = array();
157 
158  //table il_bibl_attribute
159  $set = $ilDB->query("SELECT * FROM il_bibl_attribute " .
160  " WHERE entry_id = ".$ilDB->quote($this->getEntryId(), "integer")
161  );
162  while ($rec = $ilDB->fetchAssoc($set))
163  {
164  $all_attributes[$rec['name']] = $rec['value'];
165  }
166 
167  if($this->file_type == "ris"){
168  //for RIS-Files also add the type;
169  $type = $this->getType();
170  }else{
171  $type = 'default';
172  }
173 
174  $parsed_attributes = array();
175  foreach($all_attributes as $key => $value){
176 
177  // surround links with <a href="">
178  // Allowed signs in URL: a-z A-Z 0-9 . ? & _ / - ~ ! ' * ( ) + , : ; @ = $ # [ ] %
179  $value = preg_replace('!(http)(s)?:\/\/[a-zA-Z0-9.?&_/\-~\!\'\*()+,:;@=$#\[\]%]+!', "<a href=\"\\0\" target=\"_blank\">\\0</a>",$value);
180 
181  $parsed_attributes[strtolower($this->file_type . '_' . $type . '_' . $key)] = $value;
182  }
183  return $parsed_attributes;
184  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAttributes()

ilBibliographicEntry::setAttributes (   $attributes)

Definition at line 187 of file class.ilBibliographicEntry.php.

References $attributes.

Referenced by doRead().

188  {
189  $this->attributes = $attributes;
190  }
+ Here is the caller graph for this function:

◆ setBibliographicObjId()

ilBibliographicEntry::setBibliographicObjId (   $bibliographic_obj_id)
Parameters
int$bibliographic_obj_id

Definition at line 281 of file class.ilBibliographicEntry.php.

References $bibliographic_obj_id.

282  {
283  $this->bibliographic_obj_id = $bibliographic_obj_id;
284  }

◆ setEntryId()

ilBibliographicEntry::setEntryId (   $entry_id)
Parameters
int$entry_id

Definition at line 298 of file class.ilBibliographicEntry.php.

References $entry_id.

Referenced by __construct(), and doCreate().

299  {
300  $this->entry_id = $entry_id;
301  }
+ Here is the caller graph for this function:

◆ setOverwiew()

ilBibliographicEntry::setOverwiew ( )

Definition at line 198 of file class.ilBibliographicEntry.php.

References $attributes, $file_type, ilObjBibliographic\__getAllOverviewModels(), getAttributes(), and getType().

Referenced by doRead().

199  {
200 
201  $attributes = $this->getAttributes();
202 
203  //Get the model which declares which attributes to show in the overview table and how to show them
204  //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>"
205  $overviewModels = ilObjBibliographic::__getAllOverviewModels();
206 
207  //get design for specific entry type or get filetypes default design if type is not specified
208  $entryType = $this->getType();
209 
210  //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, ...)
211  if(!$overviewModels[$this->file_type][$entryType]){
212  $entryType = 'default';
213  }
214 
215  $single_entry = $overviewModels[$this->file_type][$entryType];
216 
217  //split the model into single attributes (which begin and end with a bracket, eg [|bib_default_title|. ] )
218  //such values are saved in $placeholders[0] while the same values but whithout brackets are saved in $placeholders[1] (eg |bib_default_title|. )
219  preg_match_all('/\[(.*?)\]/', $single_entry, $placeholders);
220 
221 
222  foreach($placeholders[1] as $key => $placeholder){
223  //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.
224  $cuts = explode('|', $placeholder);
225 
226 
227  //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)
228  if(!$attributes[$cuts[1]]){
229  $attribute_elements = explode('_', $cuts[1]);
230  $attribute_elements[1] = strtolower($this->getType());
231  $cuts[1] = implode('_', $attribute_elements);
232  }
233 
234  if($attributes[$cuts[1]]){
235  //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
236  $single_entry = str_replace($placeholders[0][$key], $cuts[0] . $attributes[$cuts[1]] . $cuts[2], $single_entry);
237  // replace the <emph> tags with a span, in order to make text italic by css
238  do{
239  $first_sign_after_begin_emph_tag = strpos(strtolower($single_entry), '<emph>') + 6;
240  $last_sign_after_end_emph_tag = strpos(strtolower($single_entry), '</emph>');
241  $italic_text_length = $last_sign_after_end_emph_tag - $first_sign_after_begin_emph_tag;
242 
243  //would not be true if there is no <emph> tag left
244  if($last_sign_after_end_emph_tag){
245  $italic_text = substr($single_entry, $first_sign_after_begin_emph_tag, $italic_text_length);
246 
247  //parse
248  $it_tpl = new ilTemplate("tpl.bibliographic_italicizer.html", true, true, "Modules/Bibliographic");
249  $it_tpl->setCurrentBlock("italic_section");
250 
251  $it_tpl->setVariable('ITALIC_STRING', $italic_text);
252  $it_tpl->parseCurrentBlock();
253 
254  //replace the emph tags and the text between with the parsed text from il_tpl
255  $text_before_emph_tag = substr($single_entry, 0, $first_sign_after_begin_emph_tag - 6);
256  $text_after_emph_tag = substr($single_entry, $last_sign_after_end_emph_tag + 7);
257  $single_entry = $text_before_emph_tag . $it_tpl->get() . $text_after_emph_tag;
258  }
259  } while($last_sign_after_end_emph_tag);
260  }else{
261  //if the attribute for the attribute key does not exist, just remove this attribute-key from the overview text line of a single entry
262  $single_entry = str_replace($placeholders[0][$key], '', $single_entry);
263  }
264  }
265 
266  $this->Overwiew = $single_entry;
267  }
special template class to simplify handling of ITX/PEAR
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setType()

ilBibliographicEntry::setType (   $type)
Parameters
string$type

Definition at line 314 of file class.ilBibliographicEntry.php.

References $type.

Referenced by doRead().

315  {
316  $this->type = $type;
317  }
+ Here is the caller graph for this function:

Field Documentation

◆ $attributes

ilBibliographicEntry::$attributes
protected

Definition at line 37 of file class.ilBibliographicEntry.php.

Referenced by getAttributes(), setAttributes(), and setOverwiew().

◆ $bibliographic_obj_id

ilBibliographicEntry::$bibliographic_obj_id
protected

Definition at line 19 of file class.ilBibliographicEntry.php.

Referenced by getBibliographicObjId(), and setBibliographicObjId().

◆ $entry_id

ilBibliographicEntry::$entry_id
protected

Definition at line 25 of file class.ilBibliographicEntry.php.

Referenced by __construct(), getEntryId(), and setEntryId().

◆ $file_type

ilBibliographicEntry::$file_type
protected

Definition at line 43 of file class.ilBibliographicEntry.php.

Referenced by __construct(), and setOverwiew().

◆ $type

ilBibliographicEntry::$type
protected

Definition at line 31 of file class.ilBibliographicEntry.php.

Referenced by getType(), loadAttributes(), and setType().


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