- // need to do this to keep old info while also not
- // copying over any files that have been deleted.
- EmbeddedFileList oldlist = bibfiles_;
- bibfiles_.clear();
-
- docstring bibfile;
- docstring embfile;
-
- docstring bibfiles = getParam("bibfiles");
- docstring embfiles = getParam("embed");
-
- bibfiles = split(bibfiles, bibfile, ',');
- embfiles = split(embfiles, embfile, ',');
-
- while (!bibfile.empty()) {
- FileName bib = getBibTeXPath(bibfile, buffer());
- EmbeddedFileList::iterator efp = oldlist.findFile(bib.absFilename());
- if (efp != oldlist.end()) {
- // already have this one, but embedding status may have been changed
- bool old_status = efp->embedded();
- bool new_status = !embfile.empty();
- efp->setEmbed(new_status);
- try {
- // copy file if embedding status changed.
- efp->enable(buffer().embedded(), &buffer(), old_status != new_status);
- } catch (ExceptionMessage const & message) {
- Alert::error(message.title_, message.details_);
- // failed to change embeddeing status
- efp->setEmbed(old_status);
- }
- bibfiles_.push_back(*efp);
- } else {
- EmbeddedFile file(bib.absFilename(), buffer().filePath());
- file.setEmbed(!embfile.empty());
- try {
- file.enable(buffer().embedded(), &buffer(), true);
- } catch (ExceptionMessage const & message) {
- Alert::error(message.title_, message.details_);
- // failed to embed
- file.setEmbed(false);
- }
- bibfiles_.push_back(file);
+ BiblioInfo const & bibinfo = buffer().masterBibInfo();
+ vector<docstring> const & cites = bibinfo.citedEntries();
+ CiteEngineType const engine_type = buffer().params().citeEngineType();
+ bool const numbers = (engine_type == ENGINE_TYPE_NUMERICAL);
+
+ docstring reflabel = from_ascii("References");
+ Language const * l = buffer().params().language;
+ if (l)
+ reflabel = translateIfPossible(reflabel, l->code());
+
+ xs << html::StartTag("h2", "class='bibtex'")
+ << reflabel
+ << html::EndTag("h2")
+ << html::StartTag("div", "class='bibtex'");
+
+ // Now we loop over the entries
+ vector<docstring>::const_iterator vit = cites.begin();
+ vector<docstring>::const_iterator const ven = cites.end();
+ for (; vit != ven; ++vit) {
+ BiblioInfo::const_iterator const biit = bibinfo.find(*vit);
+ if (biit == bibinfo.end())
+ continue;
+ BibTeXInfo const & entry = biit->second;
+ xs << html::StartTag("div", "class='bibtexentry'");
+ // FIXME XHTML
+ // The same name/id problem we have elsewhere.
+ string const attr =
+ "id='LyXCite-" + to_utf8(html::cleanAttr(entry.key())) + "'";
+ xs << html::CompTag("a", attr);
+ docstring citekey;
+ if (numbers)
+ citekey = entry.citeNumber();
+ else {
+ docstring const auth = entry.getAbbreviatedAuthor();
+ // we do it this way so as to access the xref, if necessary
+ // note that this also gives us the modifier
+ docstring const year = bibinfo.getYear(*vit, true);
+ if (!auth.empty() && !year.empty())
+ citekey = auth + ' ' + year;