Exemplo n.º 1
0
void notes_display_internal(const ustring& language, bool show_reference_text, bool show_summary, ustring& note_buffer, unsigned int id, const gchar * text, unsigned int cursor_id, unsigned int &cursor_offset)
{
    // Optionally display the extra text.
    if (text) {
        note_buffer.append(text);
        note_buffer.append("<BR>\n");
    }

    // Get data from the note file.
    ustring note;
    ustring project;
    ustring reference;
    ustring category;
    int date_created;
    ustring user_created;
    int date_modified;
    ustring logbook;
    notes_read_one_from_file (id, note, project, reference, category, date_created, user_created, date_modified, logbook);

    // Parse the reference(s) string into its possible several references.
    Parse parse(reference, false);
    reference.clear();

    // Keep list of references.
    vector <Reference> references;

    // Go through each reference.
    for (unsigned int i2 = 0; i2 < parse.words.size(); i2++) {
        // Make it human readable.
        Reference oldRef;
        Reference newRef;
        reference_discover(oldRef, parse.words[i2], newRef);
        if (!reference.empty()) {
            reference.append(", ");
        }
        reference.append(newRef.human_readable(language));
        references.push_back(newRef);
    }

    // Start creating the heading with links.
    ustring linkheading;
    // If this note is to be focused, then insert a special anchor for that:
    // <a name="cursoranchor" id="cursoranchor"></a>
    if (id == cursor_id) {
        linkheading.append ("<a name=\"");
        linkheading.append (notes_cursor_anchor());
        linkheading.append ("\" id=\"");
        linkheading.append (notes_cursor_anchor());
        linkheading.append ("\"></a>");
    }
    extern Settings * settings;
    if (settings->session.project_notes_show_title) {
        // Insert a link with this heading, e.g.: <a href="10">Genesis 1.1</a>
        linkheading.append("<a href=\"" + convert_to_string(id) + "\">");
        linkheading.append(reference);
        if (settings->genconfig.notes_display_project_get())
            linkheading.append(" " + project);
        if (settings->genconfig.notes_display_category_get())
            linkheading.append(" " + category);
        if (settings->genconfig.notes_display_date_created_get())
            linkheading.append(" " + date_time_julian_human_readable(date_created, true));
        if (settings->genconfig.notes_display_created_by_get())
            linkheading.append(" " + user_created);
        linkheading.append("</a>");
        // Append a [delete] link too, e.g.: <a href="d10">[delete]</a>
        linkheading.append(" <a href=\"d" + convert_to_string(id) + "\">");
        linkheading.append("[delete]");
        linkheading.append("</a>");
        // Append a [references] link too, e.g.: <a href="r10">[references]</a>
        linkheading.append(" <a href=\"r" + convert_to_string(id) + "\">");
        linkheading.append("[references]");
        linkheading.append("</a>");
    }
    // Add the heading to the note data.
    note_buffer.append(linkheading);

    // Handle summary. Show only the first few words.
    if (show_summary) {
        ustring summary = note;
        replace_text(summary, "\n", " ");
        replace_text(summary, "<BR>", " ");
        Parse parse(summary, false);
        unsigned int maximum = 5;
        maximum = CLAMP(maximum, 0, parse.words.size());
        summary.clear();
        for (unsigned int w = 0; w < maximum; w++) {
            summary.append(" ");
            summary.append(parse.words[w]);
        }
        if (!summary.empty())
            summary.append(" ...");
        note_buffer.append(summary);
    }
    // Append a new line.
    note_buffer.append("<BR>\n");

    // Insert text of the references, if requested.
    if (show_reference_text) {
        for (unsigned int r = 0; r < references.size(); r++) {
            vector <unsigned int> simple_verses = verse_range_sequence(references[r].verse_get());
            for (unsigned int sv = 0; sv < simple_verses.size(); sv++) {
                Reference ref(references[r]);
                ref.verse_set(convert_to_string(simple_verses[sv]));
                note_buffer.append(ref.human_readable(language));
                note_buffer.append(" ");
                ustring text = project_retrieve_verse(project, ref);
                if (!text.empty()) {
                    text = usfm_get_verse_text_only (text);
                }
                note_buffer.append(text);
                note_buffer.append("<BR>\n");
            }
        }
    }
    // Get the text of the note.
    if (!show_summary) {
        note_buffer.append(note);
        note_buffer.append("<BR>\n");
    }
}
Exemplo n.º 2
0
CheckParallelPassages::CheckParallelPassages(bool nt, const ustring & project, const vector < unsigned int >&books, bool includetext, bool gui,const ustring & project2)
{
  // Language.
  extern Settings *settings;
  ustring language = settings->projectconfig(project, false)->language_get();

  // Mapping.
  ustring versification = settings->projectconfig(project, false)->versification_get();
  Mapping mapping(versification, 0);

  // Get a list of the books to check. If no books were given, take them all.
  vector < unsigned int >mybooks(books.begin(), books.end());
  if (mybooks.empty())
    mybooks = project_get_books(project);
  set < unsigned int >bookset(mybooks.begin(), mybooks.end());

  // Get the parallel passages.
  OtNtParallels otntparallels(0);
  if (nt)
    otntparallels.readnt();
  else
    otntparallels.readot();

  // GUI.
  progresswindow = NULL;
  if (gui) {
    progresswindow = new ProgressWindow(_("Producing passages"), true);
    progresswindow->set_iterate(0, 1, otntparallels.sections.size());
  }
  // Go through each section.
  for (unsigned int i = 0; i < otntparallels.sections.size(); i++) {
    if (gui) {
      progresswindow->iterate();
      if (progresswindow->cancel)
        return;
    }
    OtNtParallelDataSection datasection(0);
    // Section's heading.
    datasection.title = otntparallels.sections[i].title;
    // Go through each set of references.
    for (unsigned int i2 = 0; i2 < otntparallels.sections[i].sets.size(); i2++) {
      // Go through the references in the set.
      OtNtParallelDataSet dataset(0);
      for (unsigned int i3 = 0; i3 < otntparallels.sections[i].sets[i2].references.size(); i3++) {
        // Skip if NT book is not to be included.
        if (bookset.find(otntparallels.sections[i].sets[i2].references[i3].book) == bookset.end())
          continue;
        vector < int >remapped_chapter;
        vector < int >remapped_verse;
        mapping.book_change(otntparallels.sections[i].sets[i2].references[i3].book);
        mapping.original_to_me(otntparallels.sections[i].sets[i2].references[i3].chapter, otntparallels.sections[i].sets[i2].references[i3].verse, remapped_chapter, remapped_verse);
        Reference mapped_reference(otntparallels.sections[i].sets[i2].references[i3].book, remapped_chapter[0], convert_to_string(remapped_verse[0]));
        ustring verse = mapped_reference.human_readable(language);
        if (includetext) {
          verse.append(" ");
          verse.append(usfm_get_verse_text_only(project_retrieve_verse(project, mapped_reference.book, mapped_reference.chapter, mapped_reference.verse)));
        }
        dataset.data.push_back(verse);
        references.push_back(books_id_to_english(mapped_reference.book) + " " + convert_to_string(mapped_reference.chapter) + ":" + mapped_reference.verse);
        comments.push_back(_("Parallel"));
      }

      datasection.sets.push_back(dataset);
      //output verses of second project
      OtNtParallelDataSet dataset2(0);
      //TODO refactor this loop into a separate function
      if (project2!="")
      {
    	  ustring language2 = settings->projectconfig(project2, false)->language_get();

    	  // Mapping.
    	  ustring versification2 = settings->projectconfig(project2, false)->versification_get();
    	  Mapping mapping2(versification2, 0);

    	  for (unsigned int i3 = 0; i3 < otntparallels.sections[i].sets[i2].references.size(); i3++) {
    		  // Skip if NT book is not to be included.
    		  if (bookset.find(otntparallels.sections[i].sets[i2].references[i3].book) == bookset.end())
    			  continue;
    		  vector < int >remapped_chapter;
    		  vector < int >remapped_verse;
    		  mapping2.book_change(otntparallels.sections[i].sets[i2].references[i3].book);
    		  mapping2.original_to_me(otntparallels.sections[i].sets[i2].references[i3].chapter, otntparallels.sections[i].sets[i2].references[i3].verse, remapped_chapter, remapped_verse);
    		  Reference mapped_reference(otntparallels.sections[i].sets[i2].references[i3].book, remapped_chapter[0], convert_to_string(remapped_verse[0]));
    		  ustring verse = mapped_reference.human_readable(language);
    		  if (includetext) {
    			  verse.append(" ");
    			  verse.append(usfm_get_verse_text_only(project_retrieve_verse(project2, mapped_reference.book, mapped_reference.chapter, mapped_reference.verse)));
    		  }
    		  dataset2.data.push_back(verse);
    		  references.push_back(books_id_to_english(mapped_reference.book) + " " + convert_to_string(mapped_reference.chapter) + ":" + mapped_reference.verse);
    		  comments.push_back(_("Parallel"));
    	  }
      	  datasection.sets.push_back(dataset2);
      }

    }
    data.push_back(datasection);
  }
}
Exemplo n.º 3
0
CheckOTQuotationsInNT::CheckOTQuotationsInNT(const ustring& project, const vector <unsigned int>& books, bool includetext)
{
  // Language and versification system.
  extern Settings *settings;
  ustring language = settings->projectconfig(project, false)->language_get();
  ustring versification = settings->projectconfig(project, false)->versification_get();
  Mapping mapping(versification, 0);

  // Get a list of the books to check. If no books were given, take them all.
  vector < unsigned int >mybooks(books.begin(), books.end());
  if (mybooks.empty())
    mybooks = project_get_books(project);
  set < unsigned int >bookset(mybooks.begin(), mybooks.end());

  // Get all quotations in New Testament order, optionally also in OT order.
  OTQuotations otquotations(0);
  otquotations.read();
  bool use_ot_order = settings->session.check_output_in_ot_order;
  if (use_ot_order) {
    otquotations.produce_in_ot_order();
  }
  
  // GUI.
  progresswindow = new ProgressWindow(_("Producing passages"), true);
  progresswindow->set_iterate(0, 1, use_ot_order ? otquotations.quotations_ot_order.size() : otquotations.quotations_nt_order.size());
  
  // Go through the quotations.
  for (unsigned int i = 0; i < (use_ot_order ? otquotations.quotations_ot_order.size() : otquotations.quotations_nt_order.size()); i++) {
    progresswindow->iterate();
    if (progresswindow->cancel)
      return;

    // Skip if the reference book is not to be included.
    unsigned int reference_book = use_ot_order ? otquotations.quotations_ot_order[i].reference.book : otquotations.quotations_nt_order[i].reference.book;
    if (bookset.find(reference_book) == bookset.end())
      continue;

    // Optionally remapping of verses.
    mapping.book_change(reference_book);
    if (use_ot_order)
      mapping.original_to_me(otquotations.quotations_ot_order[i].reference);
    else
      mapping.original_to_me(otquotations.quotations_nt_order[i].reference);

    // Reference chapter and verse.
    unsigned int reference_chapter = use_ot_order ? otquotations.quotations_ot_order[i].reference.chapter : otquotations.quotations_nt_order[i].reference.chapter;
    ustring reference_verse = use_ot_order ? otquotations.quotations_ot_order[i].reference.verse : otquotations.quotations_nt_order[i].reference.verse;
    
    // Store reference, optionally verse text, and comment.
    ustring reference = use_ot_order ? otquotations.quotations_ot_order[i].reference.human_readable (language) : otquotations.quotations_nt_order[i].reference.human_readable(language);
    nt_refs.push_back(reference);
    ustring reference_verse_text;
    if (includetext) {
      reference_verse_text = project_retrieve_verse(project, reference_book, reference_chapter, reference_verse);
      reference_verse_text = usfm_get_verse_text_only (reference_verse_text);
    }
    nt_texts.push_back (reference_verse_text);
    references.push_back(reference);
    comments.push_back(_("Quoted in New Testament"));

    // Go through the OT quotations processing them.
    vector <ustring> refs_store;
    vector <ustring> text_store;
    unsigned int i2_limit = use_ot_order ? otquotations.quotations_ot_order[i].referents.size() : otquotations.quotations_nt_order[i].referents.size();
    for (unsigned i2 = 0; i2 < i2_limit; i2++) {
      if (use_ot_order) {
        mapping.book_change(otquotations.quotations_ot_order[i].referents[i2].book);
        mapping.original_to_me(otquotations.quotations_ot_order[i].referents[i2]);
      } else {
        mapping.book_change(otquotations.quotations_nt_order[i].referents[i2].book);
        mapping.original_to_me(otquotations.quotations_nt_order[i].referents[i2]);
      }
      ustring reference = use_ot_order ? otquotations.quotations_ot_order[i].referents[i2].human_readable(language) : otquotations.quotations_nt_order[i].referents[i2].human_readable(language);
      ustring verse_text;
      if (includetext) {
        verse_text = project_retrieve_verse(project,
                                            use_ot_order ? otquotations.quotations_ot_order[i].referents[i2].book : otquotations.quotations_nt_order[i].referents[i2].book, 
                                            use_ot_order ? otquotations.quotations_ot_order[i].referents[i2].chapter : otquotations.quotations_nt_order[i].referents[i2].chapter, 
                                            use_ot_order ? otquotations.quotations_ot_order[i].referents[i2].verse : otquotations.quotations_nt_order[i].referents[i2].verse);
        verse_text = usfm_get_verse_text_only(verse_text);
      }
      refs_store.push_back(reference);
      text_store.push_back(verse_text);
      Reference ref ((use_ot_order ? otquotations.quotations_ot_order[i].referents[i2].book : otquotations.quotations_nt_order[i].referents[i2].book),
                     (use_ot_order ? otquotations.quotations_ot_order[i].referents[i2].chapter : otquotations.quotations_nt_order[i].referents[i2].chapter),
                     (use_ot_order ? otquotations.quotations_ot_order[i].referents[i2].verse : otquotations.quotations_nt_order[i].referents[i2].verse));
      references.push_back(ref.human_readable (""));
      comments.push_back(_("Old Testament verse quoted from"));
    }
    // Save data.
    ot_refs.push_back(refs_store);
    ot_texts.push_back(text_store);
  }
}
CheckParallelPassages::CheckParallelPassages(bool nt, const ustring & project, const vector < unsigned int >&books, bool includetext, bool gui,const ustring & project2)
{
  // Language.
  extern Settings *settings;
  ustring language = settings->projectconfig(project, false)->language_get();

  // Mapping.
  ustring versification = settings->projectconfig(project, false)->versification_get();
  Mapping mapping(versification, 0);

  // Get a list of the books to check. If no books were given, take them all.
  vector < unsigned int >mybooks(books.begin(), books.end());
  if (mybooks.empty()) {
    mybooks = project_get_books(project);
  }
  set < unsigned int >bookset(mybooks.begin(), mybooks.end());

  // Get the parallel passages.
  OtNtParallels otntparallels(0);
  if (nt) {
    otntparallels.readnt();
  }
  else {
    otntparallels.readot();
  }

  // GUI.
  progresswindow = NULL;
  if (gui) {
    progresswindow = new ProgressWindow(_("Producing passages"), true);
    progresswindow->set_iterate(0, 1, otntparallels.sections.size());
  }
  // Go through each section.
  for (unsigned int i = 0; i < otntparallels.sections.size(); i++) {
    if (gui) {
      progresswindow->iterate();
      if (progresswindow->cancel)
        return;
    }
    OtNtParallelDataSection datasection(0);
    // Section's heading.
    datasection.title = otntparallels.sections[i].title;
    // Go through each set of references.
    for (unsigned int i2 = 0; i2 < otntparallels.sections[i].sets.size(); i2++) {
      // Go through the references in the set.
      OtNtParallelDataSet dataset(0);
      for (unsigned int i3 = 0; i3 < otntparallels.sections[i].sets[i2].references.size(); i3++) {
        // Skip if NT book is not to be included.
        if (bookset.find(otntparallels.sections[i].sets[i2].references[i3].book_get()) == bookset.end()) {
          continue;
	}
        vector < int >remapped_chapter;
        vector < int >remapped_verse;
        mapping.book_change(otntparallels.sections[i].sets[i2].references[i3].book_get());
        mapping.original_to_me(otntparallels.sections[i].sets[i2].references[i3].chapter_get(), otntparallels.sections[i].sets[i2].references[i3].verse_get(), remapped_chapter, remapped_verse);
	ustring verse;

	// The verse can have a range, like Matthew 3:1-2, and we have to handle all verses in that range.
	// Prior to 5/23/2016, all that was used was remapped_verse[0], which destroyed any other verses in the range.
	for (unsigned int i4 = 0; i4 < remapped_verse.size(); i4++) {
	  Reference mapped_reference(otntparallels.sections[i].sets[i2].references[i3].book_get(), remapped_chapter[0], convert_to_string(remapped_verse[i4]));
	  if (i4 > 0) {
	    // For the second verse and beyond, we need to put an extra space and handle the verse number specially.
	    verse.append(" [" + mapped_reference.verse_get() + "]");
	  }
	  else {
	    verse.append(mapped_reference.human_readable(language));
	  }
	  if (includetext) {
	    verse.append(" ");
	    verse.append(usfm_get_verse_text_only(project_retrieve_verse(project, mapped_reference.book_get(), mapped_reference.chapter_get(), mapped_reference.verse_get())));
	  }
	}

        dataset.data.push_back(verse);
	//        references.push_back(books_id_to_localname(mapped_reference.book_get()) + " " + convert_to_string(mapped_reference.chapter_get()) + ":" + mapped_reference.verse_get());
        references.push_back(books_id_to_localname(otntparallels.sections[i].sets[i2].references[i3].book_get()) + " "
			     + convert_to_string(otntparallels.sections[i].sets[i2].references[i3].chapter_get()) + ":"
			     + otntparallels.sections[i].sets[i2].references[i3].verse_get());
        comments.push_back(_("Parallel"));
      }

      datasection.sets.push_back(dataset);
      //output verses of second project
      OtNtParallelDataSet dataset2(0);
      //TODO refactor this loop into a separate function
      if (project2!="")
      {
    	  ustring language2 = settings->projectconfig(project2, false)->language_get();

    	  // Mapping.
    	  ustring versification2 = settings->projectconfig(project2, false)->versification_get();
    	  Mapping mapping2(versification2, 0);

    	  for (unsigned int i3 = 0; i3 < otntparallels.sections[i].sets[i2].references.size(); i3++) {
    		  // Skip if NT book is not to be included.
	    if (bookset.find(otntparallels.sections[i].sets[i2].references[i3].book_get()) == bookset.end())
    			  continue;
    		  vector < int >remapped_chapter;
    		  vector < int >remapped_verse;
    		  mapping2.book_change(otntparallels.sections[i].sets[i2].references[i3].book_get());
    		  mapping2.original_to_me(otntparallels.sections[i].sets[i2].references[i3].chapter_get(), otntparallels.sections[i].sets[i2].references[i3].verse_get(), remapped_chapter, remapped_verse);
    		  Reference mapped_reference(otntparallels.sections[i].sets[i2].references[i3].book_get(), remapped_chapter[0], convert_to_string(remapped_verse[0]));
    		  ustring verse = mapped_reference.human_readable(language);
    		  if (includetext) {
    			  verse.append(" ");
    			  verse.append(usfm_get_verse_text_only(project_retrieve_verse(project2, mapped_reference.book_get(), mapped_reference.chapter_get(), mapped_reference.verse_get())));
    		  }
    		  dataset2.data.push_back(verse);
    		  references.push_back(books_id_to_localname(mapped_reference.book_get()) + " " + convert_to_string(mapped_reference.chapter_get()) + ":" + mapped_reference.verse_get());
    		  comments.push_back(_("Parallel"));
    	  }
      	  datasection.sets.push_back(dataset2);
      }

    }
    data.push_back(datasection);
  }
}