예제 #1
0
    private void LoadQuotesByFounder(int founderId)
    {
        bool addedMeta = false;

        CoreDataObjects.QuotesViewDataTable quotesDt = quotesAdpt.GetByFounderID(founderId);

        int numOfRecords = quotesDt.Rows.Count;
        int numOfPages   = (int)Math.Ceiling((decimal)numOfRecords / (decimal)RECORDS_PER_PAGE);

        //loop for generating the page links for these results
        for (int p = 1; p <= numOfPages; p++)
        {
            string    linkUrl  = string.Format("~/search.aspx?searchType=Founders&founderId={0}&p={1}", _founderId, p);
            HyperLink pageLink = new HyperLink();
            pageLink.NavigateUrl = linkUrl;
            pageLink.Text        = p.ToString();

            //set visual difference for active page
            if (p == _page)
            {
                pageLink.CssClass = "ActivePage";
            }

            PanelPagingBottom.Controls.Add(pageLink);
        }

        //loop that displays the quotes
        int startRecord   = ((_page * RECORDS_PER_PAGE) - RECORDS_PER_PAGE) + 1;
        int lastRecOnPage = _page * RECORDS_PER_PAGE;
        int recRatio      = lastRecOnPage / numOfRecords;
        int totalRecsLeft = numOfRecords - ((_page - 1) * RECORDS_PER_PAGE);
        int endRecord     = lastRecOnPage + (recRatio * totalRecsLeft) - (recRatio * RECORDS_PER_PAGE);

        if (numOfRecords < RECORDS_PER_PAGE)
        {
            startRecord = 1;
            endRecord   = numOfRecords;
            PanelPagingBottom.Visible = false;
        }

        for (int i = startRecord; i <= endRecord; i++)
        {
            //add the quote to the page
            CoreDataObjects.QuotesViewRow r = (CoreDataObjects.QuotesViewRow)quotesDt.Rows[i - 1];
            QuoteHelper.LoadQuote(PanelQuotes, "", r.QuoteText, r.QuoteID, r.ReferenceInfo, r.Keywords, false);

            //add the page meta data only once
            if (!addedMeta)
            {
                SummaryText.Text = string.Format("Showing {3} Quotes <b>{0}</b> - <b>{1}</b> of <b>{2}</b>", startRecord, endRecord, quotesDt.Rows.Count, r.FullName);
                LoadFounderData(_founderId);
                Page.Title = string.Format("Quotes By {0}", r.FullName);
                Page.AddMetaInfo(MetaTags.Title, string.Format("What Would The Founders Do : {0}", r.FullName));
                Page.AddMetaInfo(MetaTags.Description, string.Format("WWFD found {0} quotes by {1}: \"{2}\" More quotes available at http://whatwouldthefoundersdo.org.", quotesDt.Rows.Count, r.FullName, r.QuoteText));
                addedMeta = true;
            }
        }
    }
예제 #2
0
    private void ShowResults(DataTable results, string[] searchWords)
    {
        lnkSort.NavigateUrl = string.Format("~/Search.aspx?searchType=Quotes&searchText={0}&sort={1}", Server.UrlEncode(searchBox.Text), "true");

        bool addedMeta = false;

        foreach (CoreDataObjects.QuotesViewRow r in results.Rows)
        {
            QuoteHelper.LoadQuote(PanelQuotes, r.FullName, r.QuoteText, r.QuoteID, r.ReferenceInfo, r.Keywords, searchWords, true);

            if (!addedMeta)
            {
                int founderCount = results.SelectDistinct("FounderID").Rows.Count;

                Page.Title = string.Format("{0} - WWFD Search", searchBox.Text);
                Page.AddMetaInfo(MetaTags.Title, string.Format("WWFD Search for '{0}' Returned {1} Quote(s) From {2} Founder(s).", searchBox.Text, results.Rows.Count, founderCount));
                Page.AddMetaInfo(MetaTags.Description, string.Format("{0}", r.QuoteText, r.FullName));
                addedMeta = true;
            }
        }
    }
예제 #3
0
    private void LoadSingleQuote(int quoteId)
    {
        CoreDataObjects.QuotesViewRow r;

        if (quoteId == 0)
        {
            //load the quote of the day
            r = (CoreDataObjects.QuotesViewRow)quotesAdpt.GetQuoteOfTheDay().Rows[0];
        }
        else
        {
            //get quote that is requested
            r = (CoreDataObjects.QuotesViewRow)quotesAdpt.GetByQuoteID(quoteId).Rows[0];
        }

        //setup page meta data title
        Page.Title = string.Format("{0} Quote #{1}", r.FullName, r.QuoteID);

        //change meta title on the quote of the day request
        if (_qotd)
        {
            Page.AddMetaInfo(OpenGraphMetaTags.Title, string.Format("Quote of the Day: {0} Quote #{1}", r.FullName, r.QuoteID));
        }
        else
        {
            Page.AddMetaInfo(OpenGraphMetaTags.Title, string.Format("{0} Quote #{1}", r.FullName, r.QuoteID));
        }

        Page.AddMetaInfo(OpenGraphMetaTags.Type, "article");
        Page.AddMetaInfo(OpenGraphMetaTags.Site_Name, "WhatWouldTheFoundersDo.org");
        Page.AddMetaInfo(OpenGraphMetaTags.URL, string.Format("http://www.whatwouldthefoundersdo.org/showquote.aspx?q={0}", r.QuoteID));
        Page.AddMetaInfo(OpenGraphMetaTags.Description, string.Format("{0}", r.QuoteText));

        LoadFounderData(r.FounderID);

        try
        {
            if (Request.QueryString["Edit"] != null)
            {
                if (Authenticator.GetUser().Role == ContributorRoles.Admin)
                {
                    if (!IsPostBack)
                    {
                        FoundersTableAdapter foundersAdpt = new FoundersTableAdapter();
                        this.ddFounders.DataSource     = foundersAdpt.GetData().OrderBy(n => n.FirstName);
                        this.ddFounders.DataTextField  = "FullName";
                        this.ddFounders.DataValueField = "FounderID";
                        this.ddFounders.DataBind();
                    }


                    //show the quote in a text box
                    QuoteText.Text     = r.QuoteText;
                    QuoteText.Width    = 580;
                    QuoteText.Rows     = (r.QuoteText.Length / 118) + 1;
                    QuoteText.CssClass = "transparent";
                    QuoteText.ToolTip  = "Click to modify.";
                    QuoteText.Attributes.Add("onclick", "this.className = 'selected';");
                    QuoteText.Attributes.Add("onblur", "this.className = 'transparent';");

                    ddFounders.ClearSelection();
                    //ddFounders.SelectedValue = r.FounderID.ToString();
                    ddFounders.Items.FindByValue(r.FounderID.ToString()).Attributes.Add("selected", "true");

                    PanelAdmin.Visible = true;
                    QuoteId.Value      = r.QuoteID.ToString();
                }
            }
            else
            {
                QuoteHelper.LoadQuote(PanelQuote, "", r.QuoteText, 0, r.ReferenceInfo, r.Keywords, false);
            }
        }
        catch
        {
            QuoteHelper.LoadQuote(PanelQuote, "", r.QuoteText, 0, r.ReferenceInfo, r.Keywords, false);
        }
    }