ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilBibliographicDetailsGUI.php
Go to the documentation of this file.
1<?php
2
3require_once "./Modules/Bibliographic/classes/class.ilBibliographicEntry.php";
4require_once "./Modules/Bibliographic/classes/Admin/class.ilBibliographicSetting.php";
5require_once('./Modules/Bibliographic/classes/Types/BibTex/class.ilBibTex.php');
6require_once("Services/Form/classes/class.ilPropertyFormGUI.php");
7require_once('./Modules/Bibliographic/classes/Types/Ris/class.ilRis.php');
8
16
20 public $bibl_obj;
24 public $entry;
25
26
33 public static function getInstance(ilObjBibliographic $bibl_obj, $entry_id) {
34 $obj = new self();
35 $obj->bibl_obj = $bibl_obj;
36 $obj->entry = ilBibliographicEntry::getInstance($obj->bibl_obj->getFiletype(), $entry_id);
37
38 return $obj;
39 }
40
41
45 public function getHTML() {
46 global $DIC;
47 $tpl = $DIC['tpl'];
48 $ilTabs = $DIC['ilTabs'];
49 $ilCtrl = $DIC['ilCtrl'];
50 $lng = $DIC['lng'];
51 $ilHelp = $DIC['ilHelp'];
55 $ilHelp->setScreenIdComponent('bibl');
56
57 $form = new ilPropertyFormGUI();
58 $ilTabs->clearTargets();
59 $ilTabs->setBackTarget($lng->txt("back"), $ilCtrl->getLinkTarget($this, 'showContent'));
60 $form->setTitle($lng->txt('detail_view'));
61 // add link button if a link is defined in the settings
62 $set = new ilSetting("bibl");
63 $link = $set->get(strtolower($this->bibl_obj->getFiletype()));
64 if (!empty($link)) {
65 $form->addCommandButton('autoLink', 'Link');
66 }
67
68 $attributes = $this->entry->getAttributes();
69 //translate array key in order to sort by those keys
70 foreach ($attributes as $key => $attribute) {
71 //Check if there is a specific language entry
72 if ($lng->exists($key)) {
73 $strDescTranslated = $lng->txt($key);
74 } //If not: get the default language entry
75 else {
76 $arrKey = explode("_", $key);
77 $is_standard_field = false;
78 switch ($arrKey[0]) {
79 case 'bib':
80 $is_standard_field = ilBibTex::isStandardField($arrKey[2]);
81 break;
82 case 'ris':
83 $is_standard_field = ilRis::isStandardField($arrKey[2]);
84 break;
85 }
86 if ($is_standard_field) {
87 $strDescTranslated = $lng->txt($arrKey[0] . "_default_" . $arrKey[2]);
88 } else {
89 $strDescTranslated = $arrKey[2];
90 }
91 }
92 unset($attributes[$key]);
93 $attributes[$strDescTranslated] = $attribute;
94 }
95 // sort attributes alphabetically by their array-key
96 ksort($attributes, SORT_STRING);
97 // render attributes to html
98 foreach ($attributes as $key => $attribute) {
99 $ci = new ilCustomInputGUI($key);
100 $ci->setHTML(self::prepareLatex($attribute));
101 $form->addItem($ci);
102 }
103 // generate/render links to libraries
104 $settings = ilBibliographicSetting::getAll();
105 foreach ($settings as $set) {
106 $ci = new ilCustomInputGUI($set->getName());
107 $ci->setHtml($set->getButton($this->bibl_obj, $this->entry));
108 $form->addItem($ci);
109 }
110 $tpl->setPermanentLink("bibl", $this->bibl_obj->getRefId(), "_" . $_GET[ilObjBibliographicGUI::P_ENTRY_ID]);
111
112 // set content and title
113 return $form->getHTML();
114 //Permanent Link
115 }
116
117
124 public static function prepareLatex($string) {
125 return $string;
126 static $init;
127 require_once('./Services/MathJax/classes/class.ilMathJax.php');
128 $ilMathJax = ilMathJax::getInstance();
129 if (!$init) {
130 require_once('./Services/MathJax/classes/class.ilMathJax.php');
131 $ilMathJax->init();
132 $init = true;
133 }
134
135 // $string = preg_replace('/\\$\\\\‍(.*)\\$/u', '[tex]$1[/tex]', $string);
136 $string = preg_replace('/\\$(.*)\\$/u', '[tex]$1[/tex]', $string);
137
138 return $ilMathJax->insertLatexImages($string);
139 }
140}
global $tpl
Definition: ilias.php:8
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
static isStandardField($field_name)
Class ilBibliographicDetailsGUI The detailled view on each entry.
static getInstance(ilObjBibliographic $bibl_obj, $entry_id)
static prepareLatex($string)
This feature has to be discussed by JF first.
static getInstance($file_type, $entry_id=null)
This class represents a custom property in a property form.
static getInstance()
Singleton: get instance.
Class ilObjBibliographic.
This class represents a property form user interface.
static isStandardField($field_name)
ILIAS Setting Class.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
global $DIC