コード例 #1
0
ファイル: CreatorHelpPage.cs プロジェクト: subratb/GEDKeeper
        // The main method that causes the help page to be created.
        public void Create()
        {
            FileStream   helpStream = null;
            StreamReader helpReader = null;

            try {
                helpStream = new FileStream(CConfig.Instance.ApplicationPath + "\\helpsource.html", FileMode.Open);
                helpReader = new StreamReader(helpStream, System.Text.Encoding.UTF8);
            } catch (IOException e) {
                fLogger.WriteError("Caught io exception while loading help file source: {0}", e);
                helpStream = null;
                helpReader = null;
            }

            if (helpStream != null && helpReader != null)
            {
                string keywords = "family tree history " + CConfig.Instance.OwnersName;
                string title    = CConfig.Instance.SiteTitle;

                HTMLFile f = null;
                try {
                    // Create a new file and put standard header html into it.
                    f = new HTMLFile(CConfig.Instance.HelpPageURL, title, PageDescription, keywords);

                    OutputPageHeader(f, "", "", true, false);

                    f.WriteLine("  <div id=\"page\"> <!-- page -->");

                    // Copy in the help html source
                    string helpLine;
                    while ((helpLine = helpReader.ReadLine()) != null)
                    {
                        f.WriteLine(helpLine);
                    }

                    f.WriteLine("  </div> <!-- page -->");
                } catch (IOException e) {
                    fLogger.WriteError("Caught IO Exception : ", e);
                } catch (ArgumentException e) {
                    fLogger.WriteError("Caught Argument Exception : ", e);
                } finally {
                    if (f != null)
                    {
                        // Add standard footer to the file
                        f.Close();
                    }
                }
            }
            if (helpReader != null)
            {
                helpReader.Close();
            }
            if (helpStream != null)
            {
                helpStream.Close();
            }
        }
コード例 #2
0
ファイル: Creator.cs プロジェクト: m-kosina/GEDKeeper
        // Generates navbar at top of page, in header div
        protected static void OutputPageHeader(HTMLFile f, string previousChildLink, string nextChildLink, bool includeIndexLink)
        {
            if (GMConfig.Instance.IncludeNavbar)
            {
                string frontPageLink = "";
                if (GMConfig.Instance.FrontPageFilename != "")
                {
                    frontPageLink += string.Concat("<a href=\"", GMConfig.Instance.FrontPageFilename, ".", GMConfig.Instance.HtmlExtension, "\">front page</a>");
                }
                string mainSiteLink = "";
                if (GMConfig.Instance.MainWebsiteLink != "")
                {
                    mainSiteLink += string.Concat("<a href=\"", GMConfig.Instance.MainWebsiteLink, "\">main site</a>");
                }

                bool includeNavbar = previousChildLink != "" ||
                                     nextChildLink != "" ||
                                     includeIndexLink ||
                                     frontPageLink != "" ||
                                     mainSiteLink != "";

                if (includeNavbar)
                {
                    f.WriteLine("    <div id=\"header\">");
                    f.WriteLine("      <ul>");

                    if (previousChildLink != "")
                    {
                        f.WriteLine("<li>{0}</li>", previousChildLink);
                    }

                    if (nextChildLink != "")
                    {
                        f.WriteLine("<li>{0}</li>", nextChildLink);
                    }

                    if (includeIndexLink)
                    {
                        f.WriteLine(string.Concat("<li><a href=\"individuals1.", GMConfig.Instance.HtmlExtension, "\">index</a></li>"));
                    }

                    if (frontPageLink != "")
                    {
                        f.WriteLine("<li>{0}</li>", frontPageLink);
                    }

                    if (mainSiteLink != "")
                    {
                        f.WriteLine("<li>{0}</li>", mainSiteLink);
                    }

                    f.WriteLine("      </ul>");
                    f.WriteLine("    </div> <!-- header -->");
                    f.WriteLine("");
                }
            }
        }
コード例 #3
0
        // Adds an HTML page footer (Record date, W3C sticker, GEDmill credit etc.)
        protected void OutputFooter(HTMLFile f, GDMRecord r)
        {
            f.WriteLine("      <div id=\"footer\">");
            if ((r.UserReferences.Count > 0) ||
                (!string.IsNullOrEmpty(r.AutomatedRecordID)) ||
                (r.ChangeDate != null) ||
                (CConfig.Instance.CustomFooter != ""))
            {
                foreach (GDMUserReference urn in r.UserReferences)
                {
                    string idType = EscapeHTML(urn.ReferenceType, false);
                    if (idType == "")
                    {
                        idType = "User reference number";
                    }
                    f.WriteLine("<p>{0}: {1}</p>", idType, EscapeHTML(urn.StringValue, false));
                }

                if (!string.IsNullOrEmpty(r.AutomatedRecordID))
                {
                    f.WriteLine("<p>Record {0}</p>", r.AutomatedRecordID);
                }

                if (r.ChangeDate != null)
                {
                    GDMChangeDate changeDate = r.ChangeDate;
                    string        dtx        = r.ChangeDate.ToString();
                    if (changeDate != null && dtx != null)
                    {
                        if (dtx != "")
                        {
                            dtx = " " + dtx;
                        }
                        f.WriteLine("<p id=\"changedate\">Record last changed {0}</p>", dtx);
                    }
                }

                if (CConfig.Instance.CustomFooter != "")
                {
                    if (CConfig.Instance.FooterIsHtml)
                    {
                        f.WriteLine("<p>{0}</p>", CConfig.Instance.CustomFooter);
                    }
                    else
                    {
                        f.WriteLine("<p>{0}</p>", EscapeHTML(CConfig.Instance.CustomFooter, false));
                    }
                }
            }
            f.WriteLine("      </div> <!-- footer -->");

            f.WriteLine("<p class=\"plain\">Page created using GEDmill {0}</p>", CConfig.SoftwareVersion);

            if (CConfig.Instance.IncludeValiditySticker)
            {
                OutputValiditySticker(f);
            }
        }
コード例 #4
0
 public void WriteNotes(HTMLFile f, GDMNotes ns)
 {
     if (ns != null)
     {
         string noteText = GetNoteText(ns);
         f.WriteLine("<p>{0}</p>", EscapeHTML(noteText, false));
     }
 }
コード例 #5
0
        // Generates the HTML file for the given page of the index.
        private void OutputIndividualsIndexPage(string headingsLinks, IndexPage indexPage)
        {
            fLogger.WriteInfo("OutputIndividualsIndexPage()");

            string ownerName = CConfig.Instance.OwnersName;

            if (ownerName != "")
            {
                ownerName = " of " + ownerName;
            }

            string fullFilename = CConfig.Instance.OutputFolder;

            if (fullFilename != "")
            {
                fullFilename += "\\";
            }
            fullFilename += indexPage.FileName;

            HTMLFile f = null;

            try {
                f = new HTMLFile(fullFilename, CConfig.Instance.IndexTitle, "Index of all individuals in the family tree" + ownerName, "individuals index family tree people history dates"); // Creates a new file, and puts standard header html into it.

                OutputPageHeader(f, "", "", false, true);

                f.WriteLine("    <div class=\"hr\" />");
                f.WriteLine("");

                f.WriteLine("  <div id=\"page\">");
                f.WriteLine("    <h1 class=\"centred\">{0}</h1>", CConfig.Instance.IndexTitle);

                if (headingsLinks != "")
                {
                    f.WriteLine("    <div id=\"headingsLinks\">");
                    f.WriteLine("      <p>{0}</p>", headingsLinks);
                    f.WriteLine("    </div>");
                }

                OutputIndexPage(indexPage, f);

                f.WriteLine("  </div> <!-- page -->");
            } catch (IOException e) {
                fLogger.WriteError("Caught IO Exception(3) : ", e);
            } catch (ArgumentException e) {
                fLogger.WriteError("Caught Argument Exception(3) : ", e);
            } finally {
                if (f != null)
                {
                    f.Close();
                }
            }
        }
コード例 #6
0
        // Generates the core of the HTML file for the given page of the index.
        private static void OutputIndexPage(IndexPage indexPage, HTMLFile f)
        {
            int nTotal = indexPage.TotalIndis + indexPage.Letters.Count;

            if (indexPage.Letters.Count > 0)
            {
                List <StringTuple> firstHalf   = new List <StringTuple>();
                List <StringTuple> secondHalf  = new List <StringTuple>();
                List <StringTuple> currentHalf = firstHalf;

                int nHalfWay;
                if (nTotal < 20)
                {
                    // If less than 20 individuals, list them in one nColumn.
                    // Set half-way pointer beyond end so that it is never reached.
                    nHalfWay = nTotal + 1;
                }
                else
                {
                    nHalfWay = (nTotal + 1) / 2;
                }
                int nAdded = 0;

                foreach (IndexLetter letter in indexPage.Letters)
                {
                    if (nAdded == nHalfWay)
                    {
                        // Don't add heading letter to bottom of first half.
                        currentHalf = secondHalf;
                    }

                    // Add heading letter.
                    currentHalf.Add(new StringTuple(letter.Title, ""));
                    ++nAdded;

                    // Add indis.
                    foreach (StringTuple tuple in letter.Items)
                    {
                        if (nAdded == nHalfWay)
                        {
                            currentHalf = secondHalf;
                        }
                        currentHalf.Add(tuple);
                        ++nAdded;
                    }
                }

                // Output HTML.
                OutputIndexPageColumns(f, firstHalf, secondHalf);
            }
            else
            {
                f.WriteLine("    <p>There are no individuals to list.</p>");
            }
        }
コード例 #7
0
        // Outputs the HTML for the Notes section of the page
        protected static void OutputNotes(HTMLFile f, GDMList <GDMNotes> notes)
        {
            if (notes.Count > 0)
            {
                // Generate notes list into a local array before adding header title. This is to cope with the case where all notes are nothing but blanks.
                var note_strings = new List <string>(notes.Count);

                foreach (GDMNotes ns in notes)
                {
                    string noteText = CConfig.Instance.ObfuscateEmails ? ObfuscateEmail(ns.Lines.Text) : ns.Lines.Text;
                    note_strings.Add(string.Concat("<li>", EscapeHTML(noteText, false), "</li>"));
                }

                if (note_strings.Count > 0)
                {
                    f.WriteLine("<div id=\"notes\">");
                    f.WriteLine("<h1>Notes</h1>");
                    f.WriteLine("<ul>");

                    foreach (string note_string in note_strings)
                    {
                        f.WriteLine(note_string);
                    }

                    f.WriteLine("</ul>");
                    f.WriteLine("</div> <!-- notes -->");
                }
            }
        }
コード例 #8
0
ファイル: Creator.cs プロジェクト: subratb/GEDKeeper
 // Outputs the HTML to display the W3C Valid XHTML image on the page.
 protected void OutputValiditySticker(HTMLFile f)
 {
     f.WriteLine("<p class=\"plain\">");
     f.WriteLine("<a href=\"http://validator.w3.org/check?uri=referer\"><img");
     f.WriteLine("src=\"" + fW3CFile + "\"");
     f.WriteLine("style=\"margin-top:4px\"");
     f.WriteLine("alt=\"Valid XHTML 1.0 Strict\" height=\"31\" width=\"88\" /></a>");
     f.WriteLine("</p>");
 }
コード例 #9
0
        // Outputs the HTML table that lists the names in two columns.
        private static void OutputIndexPageColumns(HTMLFile f, List <StringTuple> firstHalf, List <StringTuple> secondHalf)
        {
            f.WriteLine("    <table id=\"index\">");
            int i = 0, j = 0;

            while (i < firstHalf.Count || j < secondHalf.Count)
            {
                string sLink1   = "&nbsp;";
                string sLink2   = "&nbsp;";
                string sExtras1 = "&nbsp;";
                string sExtras2 = "&nbsp;";
                if (i < firstHalf.Count)
                {
                    StringTuple tuple = (StringTuple)firstHalf[i];
                    string      sName = EscapeHTML(tuple.First, true);
                    if (sName.Length >= 7 && sName.Substring(0, 7) == ",&nbsp;") // Hack for no surname.
                    {
                        if (sName.Length == 7)
                        {
                            sName = CConfig.Instance.UnknownName;
                        }
                        else
                        {
                            sName = sName.Substring(7);
                        }
                    }
                    else if (sName.Length >= 6 && sName.Substring(0, 6) == ",_&lt;")  // Hack for unknown name.
                    {
                        sName = sName.Substring(2);
                    }
                    string sLink = tuple.Second;
                    if (sLink != "")
                    {
                        sLink1 = string.Concat("<a href=\"", sLink, "\">", sName, "</a>");
                    }
                    else if (sName == CConfig.Instance.NoSurname)   // Hack for no surname.
                    {
                        sLink1 = string.Concat("<h2 id=\"-\">", sName, "</h2>");
                    }
                    else
                    {
                        sLink1 = string.Concat("<h2 id=\"", sName[0], "\">", sName, "</h2>");
                    }

                    sExtras1 = tuple.Third;
                    ++i;
                }
                if (j < secondHalf.Count)
                {
                    StringTuple tuple = (StringTuple)secondHalf[j];
                    string      sName = EscapeHTML(tuple.First, true);
                    if (sName.Length >= 7 && sName.Substring(0, 7) == ",&nbsp;") // Hack for no surname.
                    {
                        if (sName.Length == 7)
                        {
                            sName = CConfig.Instance.UnknownName;
                        }
                        else
                        {
                            sName = sName.Substring(7);
                        }
                    }
                    else if (sName.Length >= 6 && sName.Substring(0, 6) == ",_&lt;")  // Hack for unknown name.
                    {
                        sName = sName.Substring(2);
                    }

                    string sLink = tuple.Second;
                    if (sLink != "")
                    {
                        sLink2 = string.Concat("<a href=\"", sLink, "\">", sName, "</a>");
                    }
                    else if (sName == CConfig.Instance.NoSurname)   // Hack for no surname.
                    {
                        sLink2 = string.Concat("<h2 id=\"-\">", sName, "</h2>");
                    }
                    else
                    {
                        sLink2 = string.Concat("<h2 id=\"", sName[0], "\">", sName, "</h2>");
                    }

                    sExtras2 = tuple.Third;
                    ++j;
                }
                if (CConfig.Instance.IncludeUserRefInIndex)
                {
                    f.WriteLine(string.Concat("        <tr><td>", sExtras1, "</td><td>", sLink1, "</td><td>", sExtras2, "</td><td>", sLink2, "</td></tr>"));
                }
                else
                {
                    f.WriteLine(string.Concat("        <tr><td>", sLink1, "</td><td>", sLink2, "</td></tr>"));
                }
            }
            f.WriteLine("    </table>");
        }
コード例 #10
0
        // The main method that causes the front page to be created.
        public void Create()
        {
            string keywords = "family tree history " + GMConfig.Instance.OwnersName;
            string title    = GMConfig.Instance.SiteTitle;

            HTMLFile f = null;

            try {
                f = new HTMLFile(GMConfig.Instance.FrontPageURL, title, PageDescription, keywords); // Creates a new file, and puts standard header html into it.
                f.WriteLine("  <div id=\"page\"> <!-- page -->");
                f.WriteLine("    <div id=\"cover\"> <!-- cover -->");

                f.WriteLine("<h1>{0}</h1>", EscapeHTML(title, false));

                if (!string.IsNullOrEmpty(GMConfig.Instance.FrontPageImageFilename))
                {
                    Rectangle newArea     = new Rectangle(0, 0, 0, 0);
                    string    pictureFile = CopyMultimedia(GMConfig.Instance.FrontPageImageFilename, "", 0, 0, ref newArea, null);
                    if (!string.IsNullOrEmpty(pictureFile))
                    {
                        f.WriteLine("<p><img src=\"{0}\" alt=\"Front page image\" /></p>", pictureFile);
                    }
                }

                if (!string.IsNullOrEmpty(GMConfig.Instance.CommentaryText))
                {
                    if (GMConfig.Instance.CommentaryIsHtml)
                    {
                        f.WriteLine("<p>{0}</p>", GMConfig.Instance.CommentaryText);
                    }
                    else
                    {
                        f.WriteLine("<p>{0}</p>", EscapeHTML(GMConfig.Instance.CommentaryText, false));
                    }
                }

                if (GMConfig.Instance.ShowFrontPageStats)
                {
                    string individuals = fStats.Individuals == 0 ? "no" : fStats.Individuals.ToString();
                    individuals += " individual";
                    if (fStats.Individuals != 1)
                    {
                        individuals += "s";
                    }

                    string sources = fStats.Sources == 0 ? "" : string.Concat(", cross-referenced to ", fStats.Sources.ToString(), " source");
                    if (fStats.Sources > 1)
                    {
                        sources += "s";
                    }

                    string fileType   = fStats.NonPicturesIncluded ? "multimedia file" : "image";
                    string multimedia = fStats.MultimediaFiles == 0 ? "" : string.Concat(". There are links to ", fStats.MultimediaFiles.ToString(), " ", fileType);

                    if (fStats.MultimediaFiles > 1)
                    {
                        multimedia += "s";
                    }

                    f.WriteLine(string.Concat("       <p>This website contains records on ", individuals, sources, multimedia, ".</p>"));
                }

                f.WriteLine("       <div id=\"links\"> <!-- links -->");
                f.WriteLine(string.Concat("         <p><a href=\"individuals1.", GMConfig.Instance.HtmlExtension, "\">", GMConfig.Instance.IndexTitle, "</a></p>"));
                f.WriteLine("       </div> <!-- links -->");
                if (GMConfig.Instance.KeyIndividuals != null && GMConfig.Instance.KeyIndividuals.Count > 0)
                {
                    // Although in theory you might want a restricted individual as a key individual, (they still form part of the tree), in practice this isn't allowed:
                    var censoredKeyIndividuals = new List <string>(GMConfig.Instance.KeyIndividuals.Count);

                    foreach (string keyXref in GMConfig.Instance.KeyIndividuals)
                    {
                        GDMIndividualRecord air = fTree.XRefIndex_Find(keyXref) as GDMIndividualRecord;
                        if (air != null)
                        {
                            censoredKeyIndividuals.Add(MakeLink(air));
                        }
                    }

                    if (censoredKeyIndividuals.Count > 0)
                    {
                        string plural = "";
                        if (censoredKeyIndividuals.Count > 1)
                        {
                            plural = "s";
                        }
                        f.WriteLine("<div id=\"keyindividuals\">");
                        f.WriteLine("<p>Key Individual{0}:</p>", plural);
                        f.WriteLine("<ul>");
                        foreach (string air_link in censoredKeyIndividuals)
                        {
                            f.WriteLine("<li>{0}</li>", air_link);
                        }
                        f.WriteLine("</ul>");
                        f.WriteLine("</div> <!-- keyindividuals -->");
                    }
                }

                string byEmail = "";
                // Email contact address
                if (!string.IsNullOrEmpty(GMConfig.Instance.UserEmailAddress))
                {
                    byEmail = string.Concat(" by <a href=\"mailto:", GMConfig.Instance.UserEmailAddress, "\">", EscapeHTML(GMConfig.Instance.UserEmailAddress, false), "</a>");
                }

                // Add brand and contact label
                f.WriteLine("<p>Website created{0} using GEDmill.</p>", byEmail);
                // Add last update string
                if (GMConfig.Instance.AddHomePageCreateTime)
                {
                    f.WriteLine("<p>Created on {0}.</p>", GMHelper.GetNowDateStr());
                }

                // Add link to users main website
                if (!string.IsNullOrEmpty(GMConfig.Instance.MainWebsiteLink))
                {
                    f.WriteLine("<p><a href=\"{0}\">Return to main site</a></p>", GMConfig.Instance.MainWebsiteLink);
                }

                f.WriteLine("    </div> <!-- cover -->");
                f.WriteLine("  </div> <!-- page -->");
            } catch (IOException e) {
                fLogger.WriteError("Caught IO Exception(7) : ", e);
            } catch (ArgumentException e) {
                fLogger.WriteError("Caught Argument Exception(7) : ", e);
            } finally {
                if (f != null)
                {
                    // Add standard footer to the file
                    f.Close();
                }
            }
        }
コード例 #11
0
        // The main method that causes the page to be created.
        public bool Create(Stats stats)
        {
            // Sanity check
            if (fSourceRecord == null)
            {
                return(false);
            }

            // Create the strings to use for the HTML file.
            string pageDescription = "GEDmill GEDCOM to HTML page for " + fSourceRecord.ShortTitle;
            string keywords        = "family tree history " + fSourceRecord.ShortTitle;
            string filename        = string.Concat(CConfig.Instance.OutputFolder, "\\sour", fSourceRecord.XRef);
            string fullFilename    = string.Concat(filename, ".", CConfig.Instance.HtmlExtension);

            HTMLFile f = null;

            try {
                // Create a new file with an HTML header.
                f = new HTMLFile(fullFilename, fSourceRecord.ShortTitle, pageDescription, keywords);

                // Create a navbar to main site, front page etc.
                OutputPageHeader(f, "", "", true, true);

                f.WriteLine("    <div class=\"hr\" />");
                f.WriteLine("");
                f.WriteLine("    <div id=\"page\"> <!-- page -->");

                // Write the page's title text.
                f.WriteLine("      <div id=\"main\">");
                f.WriteLine("        <div id=\"summary\">");
                f.WriteLine("          <div id=\"names\">");
                string sourName = fSourceRecord.ShortTitle;
                if (sourName == "")
                {
                    sourName = "Source ";
                    bool gotSourceName = false;
                    // Try user reference number
                    foreach (var userRef in fSourceRecord.UserReferences)
                    {
                        if (userRef.StringValue != "")
                        {
                            sourName     += userRef.StringValue;
                            gotSourceName = true;
                            break;
                        }
                    }
                    if (!gotSourceName && fSourceRecord.AutomatedRecordID != null && fSourceRecord.AutomatedRecordID != "")
                    {
                        sourName += fSourceRecord.AutomatedRecordID;
                    }
                    else if (!gotSourceName)
                    {
                        sourName += fSourceRecord.XRef;
                    }
                }
                f.WriteLine("<h1>{0}</h1>", EscapeHTML(sourName, false));

                // Add repository information
                foreach (var sourCit in fSourceRecord.RepositoryCitations)
                {
                    GDMRepositoryRecord repoRec = fTree.GetPtrValue <GDMRepositoryRecord>(sourCit);
                    if (repoRec != null)
                    {
                        if (!string.IsNullOrEmpty(repoRec.RepositoryName))
                        {
                            f.WriteLine("<h2>{0}</h2>", EscapeHTML(repoRec.RepositoryName, false));
                        }

                        foreach (GDMNotes ns in repoRec.Notes)
                        {
                            WriteNotes(f, ns);
                        }
                    }

                    foreach (GDMNotes ns in sourCit.Notes)
                    {
                        WriteNotes(f, ns);
                    }
                }

                // Add Publication Information
                string pubFacts;
                if (CConfig.Instance.ObfuscateEmails)
                {
                    pubFacts = ObfuscateEmail(fSourceRecord.Publication.Lines.Text);
                }
                else
                {
                    pubFacts = fSourceRecord.Publication.Lines.Text;
                }
                if (!string.IsNullOrEmpty(pubFacts))
                {
                    if (pubFacts.Length > 7 && pubFacts.ToUpper().Substring(0, 7) == "HTTP://")
                    {
                        f.WriteLine("<h2><a href=\"{0}\">{1}</a></h2>", pubFacts, EscapeHTML(pubFacts, false));
                    }
                    else
                    {
                        f.WriteLine("<h2>{0}</h2>", EscapeHTML(pubFacts, false));
                    }
                }

                f.WriteLine("          </div> <!-- names -->");
                f.WriteLine("        </div> <!-- summary -->");

                // Collect together multimedia links.
                if (CConfig.Instance.AllowMultimedia)
                {
                    // Fill m_alMultimediaList:
                    AddMultimedia(fSourceRecord.MultimediaLinks, string.Concat(fSourceRecord.XRef, "mms"), string.Concat(fSourceRecord.XRef, "mos"), CConfig.Instance.MaxSourceImageWidth, CConfig.Instance.MaxSourceImageHeight, stats);
                }

                // Add pics
                OutputMultimedia(f);

                // Add textFromSource
                string cleanText = fSourceRecord.Text.Lines.Text;
                if (CConfig.Instance.ObfuscateEmails)
                {
                    cleanText = ObfuscateEmail(cleanText);
                }
                if (!string.IsNullOrEmpty(cleanText))
                {
                    f.WriteLine("        <div id=\"text\">");
                    f.WriteLine("          <h1>Text</h1>");
                    f.WriteLine("          <p class=\"pretext\">");
                    f.WriteLine(EscapeHTML(cleanText, false));
                    f.WriteLine("            </p>");
                    f.WriteLine("        </div> <!-- text -->");
                }

                // Add notes
                OutputNotes(f, fSourceRecord.Notes);

                if (!CConfig.Instance.SupressBackreferences)
                {
                    f.WriteLine("        <div id=\"citations\">");
                    f.WriteLine("          <h1>Citations</h1>");
                    f.WriteLine("          <ul>");

                    var htBackrefs = GMHelper.MakeBackReferences(fSourceRecord);
                    IDictionaryEnumerator enumerator = htBackrefs.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        GDMIndividualRecord ir = (GDMIndividualRecord)(enumerator.Value);
                        if (ir != null && GMHelper.GetVisibility(ir))
                        {
                            string link = MakeLink(ir);
                            if (link != "")
                            {
                                f.WriteLine("<li>{0}</li>", link);
                            }
                        }
                    }

                    f.WriteLine("          </ul>");
                    f.WriteLine("        </div> <!-- citations -->");
                }

                f.WriteLine("      </div> <!-- main -->");

                // Add footer (Record date, W3C sticker, GEDmill credit etc.)
                OutputFooter(f, fSourceRecord);

                f.WriteLine("    </div> <!-- page -->");
            } catch (IOException e) {
                fLogger.WriteError("Caught IO Exception(6) : ", e);
            } catch (ArgumentException e) {
                fLogger.WriteError("Caught Argument Exception(6) : ", e);
            } finally {
                if (f != null)
                {
                    f.Close(); // Adds standard footer to the file
                }
            }
            return(true);
        }
コード例 #12
0
        // Writes the HTML for the multimedia files associated with this record.
        private void OutputMultimedia(HTMLFile f)
        {
            string nonPicMainFilename = "";

            if (fMultimediaList.Count > 0)
            {
                f.WriteLine("        <div id=\"sourcePics\">");
                foreach (Multimedia iMultimedia in fMultimediaList)
                {
                    nonPicMainFilename = "multimedia/" + GMHelper.NonPicFilename(iMultimedia.Format, false, CConfig.Instance.LinkOriginalPicture);

                    string imageTitle = "";
                    string altName    = "";

                    if (iMultimedia.Title != null)
                    {
                        imageTitle = iMultimedia.Title;
                        altName    = iMultimedia.Title;
                    }

                    f.WriteLine(string.Concat("          <p>"));

                    if (iMultimedia.Width != 0 && iMultimedia.Height != 0)
                    {
                        // Must be a picture.
                        if (altName == "")
                        {
                            altName = "Image for this source";
                        }
                        if (iMultimedia.LargeFileName.Length > 0)
                        {
                            f.WriteLine(string.Concat("            <a href=\"", iMultimedia.LargeFileName, "\"><img src=\"", iMultimedia.FileName, "\" alt=\"", altName, "\" /></a>")); // TODO: clip and scale properly. Use MainForm.s_config to set a max scale
                        }
                        else
                        {
                            f.WriteLine(string.Concat("            <img src=\"", iMultimedia.FileName, "\" alt=\"", altName, "\" />")); // TODO: clip and scale properly. Use MainForm.s_config to set a max scale
                        }
                    }
                    else
                    {
                        // Other multimedia
                        if (altName == "")
                        {
                            altName = "Media for this source";
                        }

                        if (CConfig.Instance.LinkOriginalPicture)
                        {
                            f.WriteLine(string.Concat("            <a href=\"", iMultimedia.FileName, "\"><img src=\"", nonPicMainFilename, "\" alt=\"", altName, "\" /></a>")); // TODO: clip and scale properly. Use MainForm.s_config to set a max scale
                        }
                        else
                        {
                            f.WriteLine(string.Concat("            <img src=\"", nonPicMainFilename, "\" alt=\"", altName, "\" />")); // TODO: clip and scale properly. Use MainForm.s_config to set a max scale
                        }
                    }
                    f.WriteLine(string.Concat("          </p>"));
                    if (imageTitle != "")
                    {
                        f.WriteLine("<p id=\"sourcepic_title\">{0}</p>", imageTitle);
                    }
                }
                f.WriteLine("        </div> <!-- sourcePics -->");
            }
        }