/** * @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']); }
/** * @param ilImportMapping $a_mapping */ public function importLibraryFile($a_mapping) { $import_path = $this->getImportDirectory() . "/Modules/Bibliographic/set_1/expDir_1/" . $this->import_bib_object->getFilename(); $new_id = $this->import_bib_object->getId(); $new_path = ilUtil::getDataDir() . "/bibl/" . $new_id; mkdir($new_path); copy($import_path, $new_path . "/" . $this->import_bib_object->getFilename()); $this->import_bib_object->writeSourcefileEntriesToDb(); }
/** * updateSettings */ public function updateCustom(ilPropertyFormGUI $a_form) { global $ilAccess; if ($ilAccess->checkAccess('write', "", $this->object->getRefId())) { if ($this->object->getOnline() != $a_form->getInput("is_online")) { $this->object->setOnline($a_form->getInput("is_online")); } if (!empty($_FILES['bibliographic_file']['name'])) { $this->addNews($this->bibl_obj->getId(), 'updated'); } } else { ilUtil::sendFailure($this->lng->txt("no_permission"), true); ilObjectGUI::_gotoRepositoryRoot(); } }
/** * provide file as a download */ public function sendFile() { global $ilAccess, $tpl, $lng; if ($ilAccess->checkAccess('read', "", $this->object->getRefId())) { $file_path = $this->bibl_obj->getFileAbsolutePath(); if ($file_path) { if (is_file($file_path)) { $path_array = explode(DIRECTORY_SEPARATOR, $file_path); $filename = $path_array[sizeof($path_array) - 1]; ilUtil::deliverFile($file_path, $filename); } else { ilUtil::sendFailure($lng->txt("file_not_found")); $this->showContent($this->bibl_obj); } } } else { ilUtil::sendFailure($this->lng->txt("no_permission"), true); ilObjectGUI::_gotoRepositoryRoot(); } }
/** * @param ilObjBibliographic $bibl_obj * @param ilBibliographicEntry $entry * * @return string */ public function getButton(ilObjBibliographic $bibl_obj, ilBibliographicEntry $entry) { if ($this->getImg()) { require_once './Services/UIComponent/Button/classes/class.ilImageLinkButton.php'; $button = ilImageLinkButton::getInstance(); $button->setUrl($this->generateLibraryLink($entry, $bibl_obj->getFiletype())); $button->setImage($this->getImg(), false); $button->setTarget('_blank'); return $button->render(); } else { require_once './Services/UIComponent/Button/classes/class.ilLinkButton.php'; $button = ilLinkButton::getInstance(); $button->setUrl($this->generateLibraryLink($entry, $bibl_obj->getFiletype())); $button->setTarget('_blank'); $button->setCaption('bibl_link_online'); return $button->render(); } }
/** * Attention only use this for objects who have not yet been created (use like: $x = new ilObjDataCollection; $x->cloneStructure($id)) * @param $original_id The original ID of the dataselection you want to clone it's structure * @return void */ public function cloneStructure($original_id) { $original = new ilObjBibliographic($original_id); $this->moveFile($original->getFileAbsolutePath()); $this->setOnline($original->getOnline()); $this->setDescription($original->getDescription()); $this->setTitle($original->getTitle()); $this->setType($original->getType()); $this->doUpdate(); $this->writeSourcefileEntriesToDb(); }
public function setOverwiew() { $attributes = $this->getAttributes(); //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>" $overviewModels = ilObjBibliographic::__getAllOverviewModels(); //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; }