//---------------------------------------------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        ///     Bind the search results object after all the sorting etc has taken place ...
        /// </summary>
        protected void Page_PreRender(object sender, EventArgs e)
        {
            StringBuilder jsStr = new StringBuilder();

            //_____ 22-Mar-2016 - Append the list of static resources
            jsStr.Append(HTMLUtilities.BuildStaticResourcesHTML(this.Page, new string[] { "Scripts/DataManipulation.js" }));

            JS.Controls.Add(new LiteralControl(jsStr.ToString()));
        }
        //----------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        ///  Note for this to work we need to add a key to the web.config as described here:
        ///  http://stackoverflow.com/questions/25132057/error-when-i-try-to-launch-website-in-iis-value-cannot-be-null-parameter-name
        ///  add key="PageInspector:ServerCodeMappingSupport" value="Disabled"
        ///  Bit shit as this might also kill some useful validation, but after fiddling for a bit I can't otherwise make it work!!!
        /// </summary>
        /// <param name="tn"></param>
        /// <param name="isFirstLevel"></param>
        /// <returns></returns>
        public static string CreateTreeView(TreeNode tn)
        {
            HtmlGenericControl ul = new HtmlGenericControl("ul");

            //ul.Attributes.Add("class", "DBXHidden");
            // DBXHidden
            ul.Controls.Add(CustomTreeView(tn));

            //            return ul;
            string html = HTMLUtilities.RenderControlToHtml(ul);

            return(html);
        }
        //----------------------------------------------------------------------------------------------------------------------------

        /*        List<TreeNode> BuildTreeAndGetRoots(List<Metadata> actualObjects) {
         *          var lookup = new Dictionary<string, TreeNode>();
         *          var rootNodes = new List<TreeNode>();
         *
         *          foreach (Metadata item in actualObjects) {
         *              // add us to lookup
         *              TreeNode ourNode;
         *              if (lookup.TryGetValue(item.PathLower, out ourNode)) {   // was already found as a parent - register the actual object
         *                  ourNode..Source = item;
         *              } else {
         *                  ourNode = new TreeNode() { Source = item };
         *                  lookup.Add(item.ID, ourNode);
         *              }
         *
         *              // hook into parent
         *              if (item.ParentID == item.ID) {   // is a root node
         *                  rootNodes.Add(ourNode);
         *              } else {   // is a child row - so we have a parent
         *                  TreeNode parentNode;
         *                  if (!lookup.TryGetValue(item.ParentID, out parentNode)) {   // unknown parent, construct preliminary parent
         *                      parentNode = new Node();
         *                      lookup.Add(item.ParentID, parentNode);
         *                  }
         *                  parentNode.Children.Add(ourNode);
         *              }
         *          }
         *
         *          return rootNodes;
         *      }
         */


        //----------------------------------------------------------------------------------------------------------------------------
        public static async Task <string> ListFigures(string path)
        {
            List <Metadata> mdList = await DropboxWrapper.ListFolderRecursive(path);

            HtmlGenericControl ul = new HtmlGenericControl("ul");

            // This is a little nastily coded here ...
            Regex rFigureFile = new Regex("[.]svg[z]?$");

            int figuresFound = 0;

            if (mdList != null && mdList.Count > 0)
            {
                foreach (Metadata item in mdList)
                {
                    if (item.IsFile && rFigureFile.IsMatch(item.PathLower) == true)
                    {
                        HtmlGenericControl li = new HtmlGenericControl("li");
                        li.InnerHtml = item.Name;
                        li.Attributes.Add("class", "DBXWebFigure");

                        ul.Controls.Add(li);

                        figuresFound++;
                    }
                }
            }

            string html = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;No figures available in this document's Dropbox folder.";

            if (figuresFound > 0)
            {
                html = HTMLUtilities.RenderControlToHtml(ul);
            }

            return(html);
        }
Exemple #4
0
        //-------------------------------------------------------------------------------------------------------------------------------------------------------
        protected string BuildStyleList()
        {
            HtmlGenericControl divContainer = new HtmlGenericControl("div");

            // The header row ...
            divContainer.Controls.Add(BuildStyleRow(true, "BCHeader", "Style name", "Importance", "Creates new section?", "Description"));

            // Then all the sub rows ...
            int counter = 0;

            foreach (WebDocStyle wds in KeyInfo.WebDocStyles)
            {
                string altClass = (counter++ % 2 == 0) ? "BCA" : "BCB";

                divContainer.Controls.Add(
                    BuildStyleRow(false, altClass,
                                  wds.Name,
                                  wds.Weight.ToString(),
                                  (wds.CreatesNewSection == true)?"Yes":"No",
                                  wds.Description));
            }

            return(HTMLUtilities.RenderControlToHtml(divContainer));
        }
        //-------------------------------------------------------------------------------------------------------------------------------------------------------------
        protected void BuildChapterTagWidget(WebDoc wd)
        {
            /*  This is the kind of thing we are trying to recreate
             * <div class="row BB">
             *  <div class="col-md-3">
             *      <div class="Marg">
             *          <b>a.2</b> - Choose languages:
             *      </div>
             *  </div>
             *  <div class="col-md-5">
             *      <div class="TBRowPadding">
             *          <asp:listbox id="TBLanguage" data-placeholder="Choose languages" CssClass="chosen-select TBDDL" SelectionMode="Multiple" runat="server"></asp:listbox>
             *          <select size="4" name="E$MC$DocumentEditor$TBLanguage" multiple="multiple" id="TBLanguage" class="chosen-select TBDDL" data-placeholder="Choose languages">
             *      </div>
             *  </div>
             * </div>
             */

            List <int> chapterIDs = new List <int>();

            HtmlGenericControl container = new HtmlGenericControl("div");

            if (wd.DocumentChapters == null || wd.DocumentChapters.Count == 0)
            {
                // Show a generic warning message ...
                container.InnerHtml =
                    "<span class='InfoFailure'>There are currently no chapters saved for this document.</span>  "
                    + "To create the list of chapters, go back to the edit document page and choose <i>add content</i> for one of the document language versions(preferably the English version).  "
                    + "Once this has been successfully achieved, return to this page and the full list of chapters will be displayed.  You can then add the relevant tags to each chapter.";

                ctlInfoSplash.SetupInfoSplash(false, "There are currently no chapters saved for this document!", false);
            }
            else
            {
                foreach (WebDocChapter wdc in wd.DocumentChapters)
                {
                    string altCSS = (wdc.ChapterNumber % 2 == 0) ? "BA" : "BB";

                    chapterIDs.Add(wdc.ID);

                    HtmlGenericControl row = new HtmlGenericControl("div");
                    row.Attributes.Add("class", "row " + altCSS);

                    HtmlGenericControl cell1 = new HtmlGenericControl("div");
                    cell1.Attributes.Add("class", "col-md-6");
                    cell1.InnerHtml = "<b>" + wdc.ChapterNumber + ".</b> " + wdc.ChapterTitle;
                    row.Controls.Add(cell1);

                    HtmlGenericControl cell2 = new HtmlGenericControl("div");
                    cell2.Attributes.Add("class", "col-md-5 TBRowPadding");

                    HtmlSelect select = new HtmlSelect();
                    //ListBox lb = new ListBox();
                    // Ok 7-Nov-16 - change of heart here - we are going to use the ChapterNumber (1,2,3 etc) instead of the ID (4,000,000) etc as this makes it easier to build the BlogEditor page
                    // dynamically, which is the only other place where the tags are referenced (currently)
                    // client side stuff then just needs to use the incremental numbers instead...
                    select.ID   = "TB_ChapTags_" + wdc.ChapterNumber;
                    select.Size = 4;
                    select.Attributes.Add("class", "chosen-select TBDDL");
                    select.Attributes.Add("data-placeholder", "Choose languages");
                    select.Attributes.Add("multiple", "multiple");

                    List <ListItem> list = new List <ListItem>();
                    //lis.Add(new ListItem("Please choose", ""));

                    foreach (WebDocTag wdtGlobal in KeyInfo.Tags)
                    {
                        ListItem li = new ListItem(wdtGlobal.Name, wdtGlobal.ID.ToString());
                        list.Add(li);
                    }

                    select.DataSource     = list;
                    select.DataTextField  = "Text";
                    select.DataValueField = "Value";
                    select.DataBind();

                    // Now see if they are selected or not ...
                    foreach (WebDocTag wdtInDoc in wd.DocumentTags)
                    {
                        if (wdtInDoc.ChapterID == wdc.ID)
                        {
                            ListItem selectedLi = select.Items.FindByValue(wdtInDoc.ID.ToString());
                            selectedLi.Selected = true;
                        }
                    }


                    cell2.Controls.Add(select);
                    row.Controls.Add(cell2);

                    container.Controls.Add(row);
                }
            }

            // And lastly, lets add the list of chapter IDs as the JS array - we will need this when saving the content
            //container.Controls.Add(new LiteralControl("<script type='text/javascript'>var webDocID="+wd.ID+"; var webDocType="
            //+((int)wd.DocumentType)+"; var chapterIDList=["+DataUtilities.GetCSVList(chapterIDs)+ "];</script>"));

            container.Controls.Add(new LiteralControl("<script type='text/javascript'>var chapterIDList=[" + DataUtilities.GetCSVList(chapterIDs) + "];</script>"));

            WDChapterTagWidget.InnerHtml = HTMLUtilities.RenderControlToHtml(container);
        }
Exemple #6
0
        //--------------------------------------------------------------------------------------------------------------------------------------------------------------
        protected string BuildTagSummary(int tagID)
        {
            KeyValuePair <int, string> kvp = KeyInfo.FindValue(WebDocTag.ConvertToKeyValuePair(KeyInfo.Tags), tagID);

            tagName.InnerHtml = kvp.Value;


            WebDocProcessing wdp = new WebDocProcessing(MGLSessionInterface.Instance().Config);
            // ok this is gonna be a custom query!!
            List <string[]> data = wdp.ContentLinkedToTag(tagID);

            HtmlGenericControl container = new HtmlGenericControl("div");

            if (data == null || data.Count == 0)
            {
                container.InnerHtml = "No content is currently associated with the '" + kvp.Value + "' tag.";
            }
            else
            {
                int counter = 0;

                // The header row
                {
                    HtmlGenericControl hDivRow = new HtmlGenericControl("div");
                    hDivRow.Attributes.Add("class", "row");

                    HtmlGenericControl hCell1 = new HtmlGenericControl("div");
                    hCell1.Attributes.Add("class", "col-md-2");
                    hCell1.InnerHtml = "<h4>Document type</h4>";
                    hDivRow.Controls.Add(hCell1);

                    // Document ID
                    HtmlGenericControl hCell2 = new HtmlGenericControl("div");
                    hCell2.Attributes.Add("class", "col-md-2");
                    hCell2.InnerHtml = "<h4>Document ID</h4>";
                    hDivRow.Controls.Add(hCell2);

                    // Description
                    HtmlGenericControl hCell3 = new HtmlGenericControl("div");
                    hCell3.Attributes.Add("class", "col-md-4");
                    hCell3.InnerHtml = "<h4>Document description</h4>";
                    hDivRow.Controls.Add(hCell3);

                    // Chapter
                    HtmlGenericControl hCell4 = new HtmlGenericControl("div");
                    hCell4.Attributes.Add("class", "col-md-4");
                    hCell4.InnerHtml = "<h4>Chapter name</h4>";
                    hDivRow.Controls.Add(hCell4);

                    container.Controls.Add(hDivRow);
                }


                // a.ID, a.DocumentType, a.GeneralDescription, b.ChapterNumber, b.ChapterTitle
                foreach (string[] row in data)
                {
                    string altCSS = (counter++ % 2 == 0) ? "BA" : "BB";

                    HtmlGenericControl divRow = new HtmlGenericControl("div");
                    divRow.Attributes.Add("class", "row " + altCSS);

                    // Document type
                    WebDocType         webDocType = (WebDocType)Enum.Parse(typeof(WebDocType), row[1]);
                    HtmlGenericControl cell1      = new HtmlGenericControl("div");
                    cell1.Attributes.Add("class", "col-md-2");
                    cell1.InnerHtml = webDocType.ToString();
                    divRow.Controls.Add(cell1);

                    // Document ID
                    HtmlGenericControl cell2 = new HtmlGenericControl("div");
                    cell2.Attributes.Add("class", "col-md-2");
                    HtmlAnchor link = new HtmlAnchor();
                    link.InnerHtml = row[0];
                    link.HRef      = "/" + webDocType.ToString() + "Editor?DocID=" + row[0];
                    cell2.Controls.Add(link);
                    divRow.Controls.Add(cell2);

                    // Description
                    HtmlGenericControl cell3 = new HtmlGenericControl("div");
                    cell3.Attributes.Add("class", "col-md-4");
                    cell3.InnerHtml = row[2];
                    divRow.Controls.Add(cell3);

                    // Chapter
                    HtmlGenericControl cell4 = new HtmlGenericControl("div");
                    cell4.Attributes.Add("class", "col-md-4");
                    cell4.InnerHtml = "<b>" + row[3] + ".</b> " + row[4];
                    divRow.Controls.Add(cell4);

                    container.Controls.Add(divRow);
                }
            }

            string html = HTMLUtilities.RenderControlToHtml(container);

            return(html);
        }