Bloom.Book.Book.AddChildBookContentsToFolio C# (CSharp) Method

AddChildBookContentsToFolio() private method

used when this book is a "master"/"folio" book that is used to bring together a number of other books in the collection
private AddChildBookContentsToFolio ( HtmlDom printingDom, BookCollection currentBookCollection, BookServer bookServer ) : void
printingDom HtmlDom
currentBookCollection Bloom.Collection.BookCollection
bookServer BookServer
return void
        private void AddChildBookContentsToFolio(HtmlDom printingDom, BookCollection currentBookCollection, BookServer bookServer)
        {
            XmlNode currentLastContentPage = GetLastPageForInsertingNewContent(printingDom);

            //currently we have no way of filtering them, we just take them all
            foreach (var bookInfo in currentBookCollection.GetBookInfos())
            {
                if (bookInfo.IsFolio)
                    continue;
                var childBook =bookServer.GetBookFromBookInfo(bookInfo);

                //this will set the class bloom-content1 on the correct language
                //this happens anyhow if the page was ever looked at in the Edti Tab
                //But if we are testing a collection's folio pdf'ing ability on a newly-generated
                //SHRP collection, and we don't do this, we see lots of sample text because every
                //bloom-editable has "bloom-content1", even the "Z" language ones.
                childBook.UpdateEditableAreasOfElement(childBook.OurHtmlDom);

                //add links to the template css needed by the children.

                HtmlDom.AddStylesheetFromAnotherBook(childBook.OurHtmlDom, printingDom);
                printingDom.SortStyleSheetLinks();

                foreach (XmlElement pageDiv in childBook.OurHtmlDom.RawDom.SafeSelectNodes("/html/body//div[contains(@class, 'bloom-page') and not(contains(@class,'bloom-frontMatter')) and not(contains(@class,'bloom-backMatter'))]"))
                {
                    XmlElement importedPage = (XmlElement) printingDom.RawDom.ImportNode(pageDiv, true);
                    currentLastContentPage.ParentNode.InsertAfter(importedPage, currentLastContentPage);
                    currentLastContentPage = importedPage;

                    foreach(XmlElement img in HtmlDom.SelectChildImgAndBackgroundImageElements(importedPage))
                    {
                        var bookFolderName = Path.GetFileName(bookInfo.FolderPath);
                        var path = HtmlDom.GetImageElementUrl(img);
                        var pathRelativeToFolioFolder = ".../" + bookFolderName + "/" + path.NotEncoded;
                        //NB: URLEncode would replace spaces with '+', which is ok in the parameter section, but not the URL
                        //So we are using UrlPathEncode

                        HtmlDom.SetImageElementUrl(new ElementProxy(img), UrlPathString.CreateFromUnencodedString(pathRelativeToFolioFolder));

                    }
                }
            }
        }
Book