ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilBibliographicEntry Class Reference

Class ilObjBibliographic. More...

+ Collaboration diagram for ilBibliographicEntry:

Public Member Functions

 __construct ($file_type, $entry_id=null)
 doCreate ()
 Create object.
 doRead ()
 Read data from database tables il_bibl_entry and il_bibl_attribute.
 doUpdate ()
 Update database tables il_bibl_entry and il_bibl_attribute.
 doDelete ()
 Delete data from db.
 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.

Protected Member Functions

 loadAttributes ()
 Reads all the entrys attributes from database.

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

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

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

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

{
$this->file_type = $file_type;
{
$this->doRead();
}
}

+ Here is the call graph for this function:

Member Function Documentation

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().

{
global $ilDB;
$entries = array();
$set = $ilDB->query("SELECT id FROM il_bibl_entry ".
" WHERE data_id = ".$ilDB->quote($object_id, "integer")
);
while ($rec = $ilDB->fetchAssoc($set))
{
$entries[]['entry_id'] = $rec['id'];
}
return $entries;
}

+ Here is the caller graph for this function:

ilBibliographicEntry::doCreate ( )

Create object.

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

References getAttributes(), and setEntryId().

{
global $ilDB;
//auto-increment il_bibl_entry
$this->setEntryId($ilDB->nextID('il_bibl_entry'));
//table il_bibl_entry
$ilDB->manipulate("INSERT INTO il_bibl_entry " . "(data_id, id, type) VALUES (" .
$ilDB->quote($this->getBibliographicObjId(), "integer") . "," . // data_id
$ilDB->quote($this->getEntryId(), "integer") . "," . // id
$ilDB->quote($this->getType(), "text") . // type
")");
//table il_bibl_attribute
foreach($this->getAttributes() as $attribute)
{
//auto-increment il_bibl_attribute
$id = $ilDB->nextID('il_bibl_attribute');
$ilDB->manipulate("INSERT INTO il_bibl_attribute " . "(entry_id, name, value, id) VALUES (" .
$ilDB->quote($this->getEntryId(), "integer") . "," . // entry_id
$ilDB->quote($attribute['name'], "text") . "," . // name
$ilDB->quote($attribute['value'], "text") . "," . // value
$ilDB->quote($id, "integer") . // id
")");
}
}

+ Here is the call graph for this function:

ilBibliographicEntry::doDelete ( )

Delete data from db.

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

{
global $ilDB;
$this->emptyCache();
$this->deleteOptions();
$ilDB->manipulate("DELETE FROM il_bibl_entry WHERE id = " . $ilDB->quote($this->getEntryId(), "integer"));
$ilDB->manipulate("DELETE FROM il_bibl_attribute WHERE entry_id = " . $ilDB->quote($this->getEntryId(), "integer"));
}
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().

{
global $ilDB;
//table il_bibl_entry
$set = $ilDB->query("SELECT * FROM il_bibl_entry " .
" WHERE id = ".$ilDB->quote($this->getEntryId(), "integer")
);
while ($rec = $ilDB->fetchAssoc($set))
{
$this->setType($rec['type']);
}
$this->setAttributes($this->loadAttributes());
$this->setOverwiew();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilBibliographicEntry::doUpdate ( )

Update database tables il_bibl_entry and il_bibl_attribute.

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

References getAttributes().

{
global $ilDB;
//table il_bibl_entry
$ilDB->manipulate($up = "UPDATE il_bibl_entry SET " . " type = " .
$ilDB->quote($this->getType(), "integer") . // type
" WHERE id = " . $ilDB->quote($this->getEntryId(), "integer"));
//table il_bibl_attribute
foreach($this->getAttributes() as $attribute)
{
$ilDB->manipulate($up = "UPDATE il_bibl_attribute SET " .
" name = " . $ilDB->quote($attribute['name'], "integer") . "," . // name
" value = " . $ilDB->quote($attribute['value'], "integer") . "," . // value
" WHERE id = " . $ilDB->quote($attribute['id'], "integer"));
}
}

+ Here is the call graph for this function:

ilBibliographicEntry::getAttributes ( )

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

References $attributes.

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

{
}

+ Here is the caller graph for this function:

ilBibliographicEntry::getBibliographicObjId ( )
Returns
int

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

References $bibliographic_obj_id.

ilBibliographicEntry::getEntryId ( )
Returns
int

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

References $entry_id.

{
}
ilBibliographicEntry::getOverwiew ( )
Returns
string

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

{
return $this->Overwiew;
}
ilBibliographicEntry::getType ( )
Returns
string

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

References $type.

Referenced by loadAttributes(), and setOverwiew().

{
return $this->type;
}

+ Here is the caller graph for this function:

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().

{
global $ilDB;
$all_attributes = array();
//table il_bibl_attribute
$set = $ilDB->query("SELECT * FROM il_bibl_attribute " .
" WHERE entry_id = ".$ilDB->quote($this->getEntryId(), "integer")
);
while ($rec = $ilDB->fetchAssoc($set))
{
$all_attributes[$rec['name']] = $rec['value'];
}
if($this->file_type == "ris"){
//for RIS-Files also add the type;
$type = $this->getType();
}else{
$type = 'default';
}
$parsed_attributes = array();
foreach($all_attributes as $key => $value){
// surround links with <a href="">
// Allowed signs in URL: a-z A-Z 0-9 . ? & _ / - ~ ! ' * ( ) + , : ; @ = $ # [ ] %
$value = preg_replace('!(http)(s)?:\/\/[a-zA-Z0-9.?&_/\-~\!\'\*()+,:;@=$#\[\]%]+!', "<a href=\"\\0\" target=\"_blank\">\\0</a>",$value);
$parsed_attributes[strtolower($this->file_type . '_' . $type . '_' . $key)] = $value;
}
return $parsed_attributes;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilBibliographicEntry::setAttributes (   $attributes)

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

References $attributes.

Referenced by doRead().

{
$this->attributes = $attributes;
}

+ Here is the caller graph for this function:

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

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

References $bibliographic_obj_id.

{
$this->bibliographic_obj_id = $bibliographic_obj_id;
}
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().

{
$this->entry_id = $entry_id;
}

+ Here is the caller graph for this function:

ilBibliographicEntry::setOverwiew ( )

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

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

Referenced by doRead().

{
//Get the model which declares which attributes to show in the overview table and how to show them
//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>"
//get design for specific entry type or get filetypes default design if type is not specified
$entryType = $this->getType();
//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, ...)
if(!$overviewModels[$this->file_type][$entryType]){
$entryType = 'default';
}
$single_entry = $overviewModels[$this->file_type][$entryType];
//split the model into single attributes (which begin and end with a bracket, eg [|bib_default_title|. ] )
//such values are saved in $placeholders[0] while the same values but whithout brackets are saved in $placeholders[1] (eg |bib_default_title|. )
preg_match_all('/\[(.*?)\]/', $single_entry, $placeholders);
foreach($placeholders[1] as $key => $placeholder){
//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.
$cuts = explode('|', $placeholder);
//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)
if(!$attributes[$cuts[1]]){
$attribute_elements = explode('_', $cuts[1]);
$attribute_elements[1] = strtolower($this->getType());
$cuts[1] = implode('_', $attribute_elements);
}
if($attributes[$cuts[1]]){
//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
$single_entry = str_replace($placeholders[0][$key], $cuts[0] . $attributes[$cuts[1]] . $cuts[2], $single_entry);
// replace the <emph> tags with a span, in order to make text italic by css
do{
$first_sign_after_begin_emph_tag = strpos(strtolower($single_entry), '<emph>') + 6;
$last_sign_after_end_emph_tag = strpos(strtolower($single_entry), '</emph>');
$italic_text_length = $last_sign_after_end_emph_tag - $first_sign_after_begin_emph_tag;
//would not be true if there is no <emph> tag left
if($last_sign_after_end_emph_tag){
$italic_text = substr($single_entry, $first_sign_after_begin_emph_tag, $italic_text_length);
//parse
$it_tpl = new ilTemplate("tpl.bibliographic_italicizer.html", true, true, "Modules/Bibliographic");
$it_tpl->setCurrentBlock("italic_section");
$it_tpl->setVariable('ITALIC_STRING', $italic_text);
$it_tpl->parseCurrentBlock();
//replace the emph tags and the text between with the parsed text from il_tpl
$text_before_emph_tag = substr($single_entry, 0, $first_sign_after_begin_emph_tag - 6);
$text_after_emph_tag = substr($single_entry, $last_sign_after_end_emph_tag + 7);
$single_entry = $text_before_emph_tag . $it_tpl->get() . $text_after_emph_tag;
}
} while($last_sign_after_end_emph_tag);
}else{
//if the attribute for the attribute key does not exist, just remove this attribute-key from the overview text line of a single entry
$single_entry = str_replace($placeholders[0][$key], '', $single_entry);
}
}
$this->Overwiew = $single_entry;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

References $type.

Referenced by doRead().

{
$this->type = $type;
}

+ Here is the caller graph for this function:

Field Documentation

ilBibliographicEntry::$attributes
protected

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

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

ilBibliographicEntry::$bibliographic_obj_id
protected

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

Referenced by getBibliographicObjId(), and setBibliographicObjId().

ilBibliographicEntry::$entry_id
protected

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

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

ilBibliographicEntry::$file_type
protected

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

Referenced by __construct(), and setOverwiew().

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: