/** * @return string */ public function getHTML() { global $tpl, $ilTabs, $ilCtrl, $lng; $form = new ilPropertyFormGUI(); $ilTabs->clearTargets(); $ilTabs->setBackTarget($lng->txt("back"), $ilCtrl->getLinkTarget($this, 'showContent')); $form->setTitle($lng->txt('detail_view')); // add link button if a link is defined in the settings $set = new ilSetting("bibl"); $link = $set->get(strtolower($this->bibl_obj->getFiletype())); if (!empty($link)) { $form->addCommandButton('autoLink', 'Link'); } $attributes = $this->entry->getAttributes(); //translate array key in order to sort by those keys foreach ($attributes as $key => $attribute) { //Check if there is a specific language entry if ($lng->exists($key)) { $strDescTranslated = $lng->txt($key); } else { $arrKey = explode("_", $key); $is_standard_field = false; switch ($arrKey[0]) { case 'bib': $is_standard_field = ilBibTex::isStandardField($arrKey[2]); break; case 'ris': $is_standard_field = ilRis::isStandardField($arrKey[2]); break; } // var_dump($is_standard_field); // FSX if ($is_standard_field) { $strDescTranslated = $lng->txt($arrKey[0] . "_default_" . $arrKey[2]); } else { $strDescTranslated = $arrKey[2]; } } unset($attributes[$key]); $attributes[$strDescTranslated] = $attribute; } // sort attributes alphabetically by their array-key ksort($attributes, SORT_STRING); // render attributes to html foreach ($attributes as $key => $attribute) { $ci = new ilCustomInputGUI($key); $ci->setHtml($attribute); $form->addItem($ci); } // generate/render links to libraries $settings = ilBibliographicSetting::getAll(); foreach ($settings as $set) { $ci = new ilCustomInputGUI($set->getName()); $ci->setHtml($set->getButton($this->bibl_obj, $this->entry)); $form->addItem($ci); } $tpl->setPermanentLink("bibl", $this->bibl_obj->getRefId(), "_" . $_GET[ilObjBibliographicGUI::P_ENTRY_ID]); // set content and title return $form->getHTML(); //Permanent Link }
/** * @param ilObjBibliographic $bibl_obj * @return void * */ public function showDetails(ilObjBibliographic $bibl_obj) { global $tpl, $ilTabs, $ilCtrl, $lng; include_once "Services/Form/classes/class.ilPropertyFormGUI.php"; $form = new ilPropertyFormGUI(); $ilTabs->clearTargets(); $ilTabs->setBackTarget("back", $ilCtrl->getLinkTarget($this, 'showContent')); $form->setTitle($lng->txt('detail_view')); $entry = new ilBibliographicEntry($bibl_obj->getFiletype(), $_GET['entryId']); $attributes = $entry->getAttributes(); //translate array key in order to sort by those keys foreach ($attributes as $key => $attribute) { //Check if there is a specific language entry if ($lng->exists($key)) { $strDescTranslated = $lng->txt($key); } else { $arrKey = explode("_", $key); $strDescTranslated = $lng->txt($arrKey[0] . "_default_" . $arrKey[2]); } unset($attributes[$key]); $attributes[$strDescTranslated] = $attribute; } // sort attributes alphabetically by their array-key ksort($attributes, SORT_STRING); // render attributes to html foreach ($attributes as $key => $attribute) { $ci = new ilCustomInputGUI($key); $ci->setHtml($attribute); $form->addItem($ci); } // set content and title $tpl->setContent($form->getHTML()); //Permanent Link $tpl->setPermanentLink("bibl", $bibl_obj->getRefId(), "_" . $_GET['entryId']); }
/** * fill row * * @access public * @param $a_set */ public function fillRow($a_set) { global $ilCtrl; $ilObjEntry = new ilBibliographicEntry($this->parent_obj->object->getFiletype(), $a_set['entry_id']); $this->tpl->setVariable("SINGLE_ENTRY", $ilObjEntry->getOverwiew()); //Detail-Link $ilCtrl->setParameterByClass("ilObjBibliographicGUI", "entryId", $a_set['entry_id']); $this->tpl->setVariable("DETAIL_LINK", $ilCtrl->getLinkTargetByClass("ilObjBibliographicGUI", "showDetails")); $this->tpl->setVariable("VIEW_IMAGE_SRC", ilUtil::img(ilUtil::getImagePath("cmd_view_s.png"))); }
protected function initData() { $entries = array(); foreach (ilBibliographicEntry::getAllEntries($this->parent_obj->object->getId()) as $entry) { $ilBibliographicEntry = ilBibliographicEntry::getInstance($this->parent_obj->object->getFiletype(), $entry['entry_id']); $entry['content'] = strip_tags($ilBibliographicEntry->getOverwiew()); $entries[] = $entry; } $this->setData($entries); }
/** * @param ilBibliographicEntry $entry * @param string $type (bib|ris) * * @return string */ public function generateLibraryLink(ilBibliographicEntry $entry, $type) { $attributes = $entry->getAttributes(); switch ($type) { case 'bib': $prefix = "bib_default_"; if (!empty($attributes[$prefix . "isbn"])) { $attr = array("isbn"); } elseif (!empty($attributes[$prefix . "issn"])) { $attr = array("issn"); } else { $attr = array("title", "author", "year", "number", "volume"); } break; case 'ris': $prefix = "ris_" . strtolower($entry->getType()) . "_"; if (!empty($attributes[$prefix . "sn"])) { $attr = array("sn"); } else { $attr = array("ti", "t1", "au", "py", "is", "vl"); } break; } $url_params = "?"; if (sizeof($attr) == 1) { $url_params .= $this->formatAttribute($attr[0], $type, $attributes, $prefix) . "=" . urlencode($attributes[$prefix . $attr[0]]); } else { foreach ($attr as $a) { if (array_key_exists($prefix . $a, $attributes)) { if (strlen($url_params) > 1) { $url_params .= "&"; } $url_params .= $this->formatAttribute($a, $type, $attributes, $prefix) . "=" . urlencode($attributes[$prefix . $a]); } } } // return full link $full_link = $this->getUrl() . $url_params; return $full_link; }
/** * Reads out the source file and writes all entries to the database * @return void */ public function writeSourcefileEntriesToDb() { //Read File switch ($this->getFiletype()) { case "ris": $entries_from_file = self::__readRisFile($this->getFileAbsolutePath()); break; case "bib": $entries_from_file = self::__readBibFile($this->getFileAbsolutePath()); break; } //fill each entry into a ilBibliographicEntry object and then write it to DB by executing doCreate() foreach ($entries_from_file as $file_entry) { $type = null; $x = 0; $parsed_entry = array(); foreach ($file_entry as $key => $attribute) { // if the attribute is an array, make a comma separated string out of it if (is_array($attribute)) { $attribute = implode(", ", $attribute); } // ty (RIS) or entryType (BIB) is the type and is treated seperately if (strtolower($key) == 'ty' || strtolower($key) == 'entrytype') { $type = $attribute; continue; } //TODO - Refactoring for ILIAS 4.5 - get rid off array restructuring //change array structure (name not as the key, but under the key "name") $parsed_entry[$x]['name'] = $key; $parsed_entry[$x++]['value'] = $attribute; } //create the entry and fill data into database by executing doCreate() $entry_model = new ilBibliographicEntry($this->getFiletype()); $entry_model->setType($type); $entry_model->setAttributes($parsed_entry); $entry_model->setBibliographicObjId($this->getId()); $entry_model->doCreate(); } }
/** * Reads out the source file and writes all entries to the database * * @return void */ public function writeSourcefileEntriesToDb() { //Read File $entries_from_file = array(); switch ($this->getFiletype()) { case "ris": $entries_from_file = self::__readRisFile($this->getFileAbsolutePath()); break; case "bib": $entries_from_file = self::__readBibFile($this->getFileAbsolutePath()); break; } //fill each entry into a ilBibliographicEntry object and then write it to DB by executing doCreate() foreach ($entries_from_file as $file_entry) { $type = NULL; $x = 0; $parsed_entry = array(); foreach ($file_entry as $key => $attribute) { // if the attribute is an array, make a comma separated string out of it if (is_array($attribute)) { $attribute = implode(", ", $attribute); } // reduce the attribute strings to a maximum of 4000 (ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH) characters, in order to fit in the database //if (mb_strlen($attribute, 'UTF-8') > self::ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH) { if (ilStr::strLen($attribute) > self::ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH) { // $attribute = mb_substr($attribute, 0, self::ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH - 3, 'UTF-8') . '...'; $attribute = ilStr::subStr($attribute, 0, self::ATTRIBUTE_VALUE_MAXIMAL_TEXT_LENGTH - 3) . '...'; } // ty (RIS) or entryType (BIB) is the type and is treated seperately if (strtolower($key) == 'ty' || strtolower($key) == 'entrytype') { $type = $attribute; continue; } //TODO - Refactoring for ILIAS 4.5 - get rid off array restructuring //change array structure (name not as the key, but under the key "name") $parsed_entry[$x]['name'] = $key; $parsed_entry[$x++]['value'] = $attribute; } //create the entry and fill data into database by executing doCreate() $entry_model = ilBibliographicEntry::getInstance($this->getFiletype()); $entry_model->setType($type); $entry_model->setAttributes($parsed_entry); $entry_model->setBibliographicObjId($this->getId()); $entry_model->doCreate(); } }