예제 #1
0
        /// <summary>
        /// Render this control to the output parameter specified.
        /// </summary>
        /// <param name="output"> The HTML writer to write out to </param>
        protected override void RenderContent(HtmlTextWriter output)
        {
            DbContentHitManager    m = new DbContentHitManager();
            DbContentHitCollection dbContentHitCollection = m.GetCollection(string.Empty, string.Empty, DbContentHitFlags.RequestContent);
            bool   rowflag = false;
            string rowCssClass;

            //
            // Render Records
            //
            foreach (DbContentHit dbContentHit in dbContentHitCollection)
            {
                if (rowflag)
                {
                    rowCssClass = defaultRowCssClass;
                }
                else
                {
                    rowCssClass = alternateRowCssClass;
                }
                rowflag = !rowflag;
                output.WriteFullBeginTag("tr");
                output.WriteAttribute("i", dbContentHit.ID.ToString());
                output.WriteLine(HtmlTextWriter.TagRightChar);
                output.Indent++;

                // UserHostAddress
                output.WriteBeginTag("td");
                output.WriteAttribute("valign", "top");
                output.WriteAttribute("class", rowCssClass);
                output.Write(HtmlTextWriter.TagRightChar);
                output.Write(dbContentHit.UserHostAddress);
                output.WriteEndTag("td");
                output.WriteLine();

                // Page ID
                output.WriteBeginTag("td");
                output.WriteAttribute("valign", "top");
                output.WriteAttribute("class", rowCssClass);
                output.Write(HtmlTextWriter.TagRightChar);
                output.Write(dbContentHit.RequestContent.ID);
                output.WriteEndTag("td");
                output.WriteLine();

                // Page Title
                output.WriteBeginTag("td");
                output.WriteAttribute("valign", "top");
                output.WriteAttribute("class", rowCssClass);
                output.Write(HtmlTextWriter.TagRightChar);
                output.Write(dbContentHit.RequestContent.Title);
                output.WriteEndTag("td");
                output.WriteLine();

                output.Indent--;
                output.WriteEndTag("tr");
                output.WriteLine();
            }
        }
예제 #2
0
        /// <summary>
        /// Render this control to the output parameter specified.
        /// </summary>
        /// <param name="output"> The HTML writer to write out to </param>
        protected override void RenderContent(HtmlTextWriter output)
        {
            DbContentHitManager    m = new DbContentHitManager();
            DbContentHitCollection dbContentHitCollection = m.GetCollection(string.Empty, string.Empty, null);

            // Render Header Row
            this.headerLockEnabled = true;
            RenderRow(this.HeaderRowCssClass, );

            bool   rowflag = false;
            string rowCssClass;

            //
            // Render Records
            //
            foreach (DbContentHit dbContentHit in dbContentHitCollection)
            {
                if (rowflag)
                {
                    rowCssClass = defaultRowCssClass;
                }
                else
                {
                    rowCssClass = alternateRowCssClass;
                }
                rowflag = !rowflag;
                output.WriteBeginTag("tr");
                output.WriteAttribute("i", dbContentHit.ID.ToString());
                output.WriteLine(HtmlTextWriter.TagRightChar);
                output.Indent++;

                output.Indent--;
                output.WriteEndTag("tr");
                output.WriteLine();
            }
        }
예제 #3
0
        protected override void Render(HtmlTextWriter output)
        {
            #region Test for Errors

            if (clip == null)
            {
                RenderException(output, "The requested content could not be found.");
                return;
            }

            if (!adminView)
            {
                if (!clip.ParentCatalog.Enabled)
                {
                    RenderException(output, "The content's requested catalog is disabled.");
                    return;
                }

                if (clip.ExpirationDate < DateTime.Now)
                {
                    RenderException(output, "The requested content is expired.");
                    return;
                }

                if (clip.PublishDate > DateTime.Now)
                {
                    RenderException(output, "The requested content is awaiting publishing.");
                    return;
                }
            }

            #endregion

            #region Editor Rendering

            if (userEditor != null && userEditor.Visible)
            //if (caEditor != null && caEditor.Visible)
            //if (ftbEditor != null && ftbEditor.Visible)
            {
                output.Write("<div style=\"margin-bottom:5px\">Title:</div><div style=\"margin-bottom:5px\">");
                tbTitle.RenderControl(output);
                output.Write("</div><div style=\"margin-bottom:5px\">Description:</div><div style=\"margin-bottom:5px\">");
                tbDescription.RenderControl(output);
                output.Write("</div><div style=\"margin-bottom:5px\">");
                userEditor.RenderControl(output);
                //ftbEditor.RenderControl(output);
                output.Write("</div><div>");
                btSave.RenderControl(output);
                output.Write("&nbsp;");
                btCancel.RenderControl(output);
                output.Write("</div>");
                return;
            }

            #endregion

            #region Content Rendering

            if (_contentOnly)
            {
                // Resolve home references! Whahoo!
                output.Write(clip.Body.Replace("=\"~", Page.ResolveUrl("~")));

                // Display Edit Link
                if (btEdit != null && btEdit.Visible)
                {
                    output.Write("<br>");
                    btEdit.RenderControl(output);
                }

                return;
            }

            #endregion

            // Compile Clip
            Amns.GreyFox.Content.Support.ContentBuilder b = new Amns.GreyFox.Content.Support.ContentBuilder(clip);
            b.Compile();

            this.renderTextTag(output, _titleCssClass, "h3", clip.Title);

            if (clip.Authors.Count != 0)
            {
                output.WriteBeginTag("h4");
                if (_contributorsCssClass != "")
                {
                    output.WriteAttribute("class", _contributorsCssClass);
                }
                output.Write(HtmlTextWriter.TagRightChar);
                for (int i = 0; i < clip.Authors.Count; i++)
                {
                    output.Write(clip.Authors[i].Contact.ConstructName("P F L S"));
                    if (i + 1 < clip.Authors.Count)
                    {
                        output.Write(", ");
                    }
                }
                output.WriteEndTag("h4");

                // Output Dates
                this.renderTextTag(output, _publishDateCssClass, "h5", clip.PublishDate.ToString("MMMM yyyy"));
            }

            output.WriteBeginTag("div");
            if (_bodyCssClass != string.Empty)
            {
                output.WriteAttribute("class", _bodyCssClass);
            }
            output.Write(HtmlTextWriter.TagRightChar);

            #region Reference, Administrator and Additional Side Panels

            output.WriteBeginTag("div");
            output.WriteAttribute("style", "float:right;");
            output.Write(HtmlTextWriter.TagRightChar);

            #region Reference Panel

            if (clip.References.Count != 0)
            {
                output.WriteBeginTag("table");
                output.WriteAttribute("border", "0");
                output.WriteAttribute("cellPadding", "5");
                output.WriteAttribute("cellSpacing", "0");
                output.WriteAttribute("width", "150px");
                if (_referenceTableCssClass != string.Empty)
                {
                    output.WriteAttribute("class", _referenceTableCssClass);
                }
                output.Write(HtmlTextWriter.TagRightChar);
                output.WriteFullBeginTag("tr");
                output.WriteBeginTag("td");
                if (_referenceTitleCssClass != string.Empty)
                {
                    output.WriteAttribute("class", _referenceTitleCssClass);
                }
                output.Write(HtmlTextWriter.TagRightChar);
                output.Write("References");
                output.WriteEndTag("td");
                output.WriteEndTag("tr");
                foreach (DbContentClip reference in clip.References)
                {
                    output.WriteFullBeginTag("tr");
                    output.WriteFullBeginTag("td");
                    output.WriteBeginTag("a");
                    if (reference.OverrideUrl != string.Empty)
                    {
                        output.WriteAttribute("href", reference.OverrideUrl);
                    }
                    else
                    {
                        output.WriteAttribute("href", Page.ResolveUrl(string.Format(_linkFormat, reference.ID)));
                    }
                    if (reference.MenuTooltip != string.Empty)
                    {
                        output.WriteAttribute("title", reference.MenuTooltip);
                    }
                    output.Write(HtmlTextWriter.TagRightChar);
                    output.Write(reference.Title);
                    output.WriteEndTag("a");
                    output.WriteEndTag("td");
                    output.WriteEndTag("tr");
                }
                output.WriteEndTag("table");
            }

            #endregion

            #region Administration Panel

            if (btEdit != null && btEdit.Visible)
            {
                output.WriteBeginTag("table");
                output.WriteAttribute("border", "0");
                output.WriteAttribute("cellPadding", "5");
                output.WriteAttribute("cellSpacing", "0");
                output.WriteAttribute("width", "150px");
                if (_referenceTableCssClass != string.Empty)
                {
                    output.WriteAttribute("class", _referenceTableCssClass);
                }
                output.Write(HtmlTextWriter.TagRightChar);
                output.WriteFullBeginTag("tr");
                output.WriteBeginTag("td");
                if (_referenceTitleCssClass != string.Empty)
                {
                    output.WriteAttribute("class", _referenceTitleCssClass);
                }
                output.Write(HtmlTextWriter.TagRightChar);
                output.Write("Administration");
                output.WriteEndTag("td");
                output.WriteEndTag("tr");
                output.WriteFullBeginTag("tr");
                output.WriteFullBeginTag("td");
                btEdit.RenderControl(output);
                output.WriteEndTag("td");
                output.WriteEndTag("tr");

                #region Hit Counter Display

                // TODO: Finish Counter
                int totalHits  = 0;
                int uniqueHits = 0;

                DbContentHitManager    hm   = new DbContentHitManager();
                DbContentHitCollection hits = hm.GetCollection("RequestContentID=" + clip.ID.ToString(), "RequestDate", null);

                totalHits = hits.Count;

                // =================================================
                // BAR GRAPH
                // =================================================

                DateTime now = DateTime.Now;

                DateTime weekStart6 = DateManipulator.FirstOfWeek(now);
                DateTime weekStart5 = DateManipulator.FirstOfWeek(now.Subtract(TimeSpan.FromDays(7)));
                DateTime weekStart4 = DateManipulator.FirstOfWeek(now.Subtract(TimeSpan.FromDays(14)));
                DateTime weekStart3 = DateManipulator.FirstOfWeek(now.Subtract(TimeSpan.FromDays(21)));
                DateTime weekStart2 = DateManipulator.FirstOfWeek(now.Subtract(TimeSpan.FromDays(28)));
                DateTime weekStart1 = DateManipulator.FirstOfWeek(now.Subtract(TimeSpan.FromDays(35)));

                int[] weekCounts = new int[6];

                // Count Unique Hits
                foreach (DbContentHit hit in hits)
                {
                    if (hit.IsUnique)
                    {
                        if (hit.RequestDate > weekStart1 & hit.RequestDate < weekStart2)
                        {
                            weekCounts[0]++;
                        }
                        if (hit.RequestDate > weekStart2 & hit.RequestDate < weekStart3)
                        {
                            weekCounts[1]++;
                        }
                        if (hit.RequestDate > weekStart3 & hit.RequestDate < weekStart4)
                        {
                            weekCounts[2]++;
                        }
                        if (hit.RequestDate > weekStart4 & hit.RequestDate < weekStart5)
                        {
                            weekCounts[3]++;
                        }
                        if (hit.RequestDate > weekStart5 & hit.RequestDate < weekStart6)
                        {
                            weekCounts[4]++;
                        }
                        if (hit.RequestDate > weekStart6)
                        {
                            weekCounts[5]++;
                        }

                        uniqueHits++;
                    }
                }

                int graphWidth   = 138;
                int graphHeight  = 100;
                int graphPadding = 1;
                int plotWidth    = graphWidth - (graphPadding * 2);
                int plotHeight   = graphHeight - (graphPadding * 2);
                int maxBarHeight = plotHeight;
                int minBarHeight = 20;
                int barMargin    = 2;
                int barWidth     = 21;

                // Find Highest Count
                int maxCount = 0;
                for (int i = 0; i < weekCounts.Length; i++)
                {
                    if (weekCounts[i] > maxCount)
                    {
                        maxCount = weekCounts[i];
                    }
                }

                // Find Height per Unit
                double pixelUnit = Convert.ToDouble(maxBarHeight) / Convert.ToDouble(maxCount);

                output.WriteFullBeginTag("tr");
                output.WriteFullBeginTag("td");
                output.Write("<strong>Hits:</strong>");
                output.WriteEndTag("td");
                output.WriteEndTag("tr");

                output.WriteFullBeginTag("tr");
                output.WriteFullBeginTag("td");

                output.WriteFullBeginTag("style");
                output.WriteLine("#vertgraph { width : " + graphWidth.ToString() + "px; " +
                                 "height: " + graphHeight.ToString() + "px; " +
                                 "position: relative; " +
                                 "padding: " + graphPadding.ToString() + "px; " +
                                 "background: #aaaaaa; }");
                output.WriteLine("#vertgraph .graph-area { width: " + plotWidth.ToString() + "px; " +
                                 "height: " + plotHeight.ToString() + "px; " +
                                 "padding: 0; " +
                                 "margin: 0; " +
                                 "position: relative; " +
                                 "overflow: hidden; } ");
                output.WriteLine("#vertgraph ul { width: " + plotWidth.ToString() + "px; " +
                                 "height: " + plotHeight.ToString() + "px; " +
                                 "margin: 0; " +
                                 "padding: 0; " +
                                 "position: absolute; " +
                                 "bottom: 0; " +
                                 "list-style-type: none; }");
                output.Write("#vertgraph ul li { position: absolute; " +
                             "width: " + barWidth.ToString() + "px; " +
                             "height: " + maxBarHeight.ToString() + "px; " +
                             "bottom: 0; " +
                             "padding 0; " +
                             "margin 0; " +
                             "background: no-repeat; " +
                             "writing-mode:tb-rl; " +
                             "text-align: center; " +
                             "font-size: xx-small; " +
                             //					"font-weight: bold; " +
                             "vertical-align: middle; " +
                             "color: white; }");
                output.WriteLine("#vertgraph li.week1 { background: #999999; left: 0px; }");
                output.WriteLine("#vertgraph li.week2 { background: #888888; left: " + ((barMargin + barWidth) * 1).ToString() + "px; }");
                output.WriteLine("#vertgraph li.week3 { background: #777777; left: " + ((barMargin + barWidth) * 2).ToString() + "px; }");
                output.WriteLine("#vertgraph li.week4 { background: #666666; left: " + ((barMargin + barWidth) * 3).ToString() + "px; }");
                output.WriteLine("#vertgraph li.week5 { background: #555555; left: " + ((barMargin + barWidth) * 4).ToString() + "px; }");
                output.WriteLine("#vertgraph li.week6 { background: #444444; left: " + ((barMargin + barWidth) * 5).ToString() + "px; }");
                output.WriteEndTag("style");

                output.WriteBeginTag("div");
                output.WriteAttribute("id", "vertgraph");
                output.Write(HtmlTextWriter.TagRightChar);
                output.WriteBeginTag("div");
                output.WriteAttribute("id", "graph-area");
                output.Write(HtmlTextWriter.TagRightChar);
                output.WriteFullBeginTag("ul");

                int    barHeight;
                double barHeightD = 0;

                for (int i = 0; i < 6; i++)
                {
                    barHeightD = Convert.ToDouble(weekCounts[i]) * pixelUnit;
                    if (barHeightD < minBarHeight)
                    {
                        barHeight = minBarHeight;
                    }
                    else if (double.IsNaN(barHeightD))
                    {
                        barHeight = minBarHeight;
                    }
                    else
                    {
                        barHeight = Convert.ToInt32(barHeightD);
                    }

                    output.WriteBeginTag("li");
                    output.WriteAttribute("class", "week" + (i + 1).ToString());
                    output.WriteAttribute("style", "height: " + barHeight + "px;");
                    output.Write(HtmlTextWriter.TagRightChar);
                    output.Write(weekCounts[i]);
                    output.WriteEndTag("li");
                    output.WriteLine();
                }

                output.WriteEndTag("ul");
                output.WriteEndTag("div");
                output.WriteEndTag("div");

                output.WriteEndTag("td");
                output.WriteEndTag("tr");
                // ===============================================
                // END BAR GRAPH
                // ===============================================

                output.WriteFullBeginTag("tr");
                output.WriteFullBeginTag("td");
                output.Write("<strong>Unique Hits:</strong><br />");
                output.Write(uniqueHits);
                output.WriteEndTag("td");
                output.WriteEndTag("tr");

                output.WriteFullBeginTag("tr");
                output.WriteFullBeginTag("td");
                output.Write("<strong>Total Hits:</strong><br />");
                output.Write(totalHits);
                output.WriteEndTag("td");
                output.WriteEndTag("tr");

                if (hits.Count > 0)
                {
                    output.WriteFullBeginTag("tr");
                    output.WriteFullBeginTag("td");
                    output.Write("<strong>Last Hit:</strong><br />");
                    output.Write(hits[hits.Count - 1].RequestDate.ToString());
                    output.WriteEndTag("td");
                    output.WriteEndTag("tr");
                }

                #endregion

                #region Update Display

                output.WriteFullBeginTag("tr");
                output.WriteFullBeginTag("td");
                output.Write("<strong>Last Updated:</strong><br />");
                output.Write(clip.ModifyDate.ToString());
                output.WriteEndTag("td");
                output.WriteEndTag("tr");

                #endregion

                #region Admin Notices

                output.WriteFullBeginTag("tr");
                output.WriteFullBeginTag("td");

                if (!clip.ParentCatalog.Enabled)
                {
                    output.Write(string.Format("<div><font color=\"ff0000\">Admin Notice: The requested clip's parent catalog '{0}' is disabled.</font></div>", clip.ParentCatalog.Title));
                }
                if (clip.ExpirationDate < DateTime.Now)
                {
                    output.Write(string.Format("<div><font color=\"ff0000\">Admin Notice: The requested clip expired on {0}.</font></div>", clip.ExpirationDate));
                }
                if (clip.PublishDate > DateTime.Now)
                {
                    output.Write(string.Format("<div><font color=\"ff0000\">Admin Notice: The requested clip will be published on {0}.</font></div>", clip.PublishDate));
                }

                output.WriteEndTag("td");
                output.WriteEndTag("tr");

                #endregion

                output.WriteEndTag("table");
            }

            #endregion

            #region Gloss Word Panel

            if (b.FaqCompiled)
            {
                output.Write("\r\n" +
                             "<script language=\"javascript\">\r\n" +
                             "function gfx_faqToggle(id) {\r\n" +
                             "	q = new getObj(id); \r\n"+
                             "	if(q.style.display == 'block') \r\n"+
                             "		q.style.display = 'none'; \r\n"+
                             "	else \r\n"+
                             "		q.style.display = 'block'; \r\n"+
                             "}\r\n" +
                             "</script>\r\n");
            }

            if (b.GlossWordsCompiled)
            {
                output.Write("\r\n" +
                             "<script language=\"javascript\">\r\n" +
                             "function gfx_glossCopy(id) {\r\n" +
                             "	document.getElementById('glosscontainer').innerHTML = \r\n"+
                             "		document.getElementById(id).innerHTML;\r\n"+
                             "}\r\n" +
                             "</script>\r\n");

                output.WriteBeginTag("table");
                output.WriteAttribute("border", "0");
                output.WriteAttribute("cellPadding", "5");
                output.WriteAttribute("cellSpacing", "0");
                output.WriteAttribute("width", "150px");
                if (_glossTableCssClass != string.Empty)
                {
                    output.WriteAttribute("class", _glossTableCssClass);
                }
                output.Write(HtmlTextWriter.TagRightChar);
                output.WriteFullBeginTag("tr");
                output.WriteBeginTag("td");
                if (_glossTitleCssClass != string.Empty)
                {
                    output.WriteAttribute("class", _glossTitleCssClass);
                }
                output.Write(HtmlTextWriter.TagRightChar);
                output.Write("Glossary");
                output.WriteEndTag("td");
                output.WriteEndTag("tr");
                output.WriteFullBeginTag("tr");
                output.WriteFullBeginTag("td");
                output.WriteBeginTag("div");
                output.WriteAttribute("id", "glosscontainer");
                output.Write(HtmlTextWriter.TagRightChar);
                output.Write("Please hover over a keyword to view glossary content.");
                output.WriteEndTag("div");
                output.Write(b.GlossBlock);
                output.WriteEndTag("td");
                output.WriteEndTag("tr");
                output.WriteEndTag("table");
            }

            #endregion

            output.WriteEndTag("div");

            #endregion

            output.Write(b.Output);

            output.WriteEndTag("div");

            // DO NOT RECORD HITS ON ADMIN VIEW OR IF USER HAS ALREADY
            // HIT THIS PAGE UNIQUELY.
            if (!adminView & _hitCounterEnabled)
            {
                if (Page.Session["GFX_HIT_" + clip.ID.ToString()] == null)
                {
                    clip.SaveHit(Page.Request, true);
                    Page.Session["GFX_HIT_" + clip.ID.ToString()] = true;
                }
                else
                {
                    clip.SaveHit(Page.Request, false);
                }
            }
        }