コード例 #1
0
 //+
 //- #OnInit -//
 protected override void OnInit(System.EventArgs e)
 {
     lock (_lock)
     {
         if (_sectionTitleMap == null)
         {
             _sectionTitleMap = new Themelia.Map();
             _sectionTitleMap.Add("producta", "Product A");
             _sectionTitleMap.Add("productb", "Product B");
             _sectionTitleMap.Add("faq", "Frequently Asked Questions");
             _sectionTitleMap.Add("investor", "Investors");
         }
     }
     Load += new System.EventHandler(Page_Load);
     //+
     base.OnInit(e);
 }
コード例 #2
0
        public String PostNewComment(String blogEntryGuid, String text, String author, String email, String website, DateTime dateTime, String emailBodyTemplate, String emailSubject)
        {
            String commentGuid    = String.Empty;
            String blogEntryTitle = String.Empty;

            using (DataContext db = new DataContext(ServiceConfiguration.ConnectionString))
            {
                //+ validate
                BlogEntryLINQ blogEntryLinq;
                Validator.EnsureBlogEntryExists(blogEntryGuid, out blogEntryLinq, db);
                //+
                CommentLINQ commentLinq = new CommentLINQ();
                commentLinq.CommentEmail  = email;
                commentLinq.CommentAuthor = author;
                commentLinq.CommentText   = text;
                if (website.ToLower().StartsWith("http://") || website.ToLower().StartsWith("https://"))
                {
                    commentLinq.CommentWebsite = website;
                }
                commentLinq.CommentPostDate  = dateTime;
                commentLinq.CommentModerated = true;
                commentLinq.BlogEntryId      = blogEntryLinq.BlogEntryId;
                commentLinq.CommentGuid      = Themelia.GuidCreator.GetNewGuid();
                //+
                db.Comments.InsertOnSubmit(commentLinq);
                db.SubmitChanges();
                //+
                commentGuid = commentLinq.CommentGuid;
                //+
                blogEntryTitle = blogEntryLinq.BlogEntryTitle;
            }
            //+ email
            Themelia.Map map = new Themelia.Map();
            map.Add("BlogEntryTitle", blogEntryTitle);
            map.Add("CommentGuid", commentGuid);
            String body = new Themelia.Template(emailBodyTemplate).Interpolate(map);

            //+ this could be sent from the person, but those e-mails will more than likely be caught by a spam filter.
            Emailer.Send(MailConfiguration.GeneralFromEmailAddress, MailConfiguration.GeneralToEmailAddress, emailSubject, body, MailOptions.IsHtml);
            //+
            return(commentGuid);
        }
コード例 #3
0
        //- @PostNewComment -//
        public Int32 PostNewComment(Int32 captchaValue, String blogEntryGuid, String author, String email, String website, String text)
        {
            Int32 returnStatus;

            //+
            if (captchaValue == HttpData.GetScopedSessionItem <Int32>("Captcha", "ExpectedValue"))
            {
                CommentReportCreator creator = new CommentReportCreator();
                creator.Formatter = new Themelia.Reporting.HtmlFormatter();
                Themelia.Map map = new Themelia.Map();
                map.Add("BlogEntryTitle", "{BlogEntryTitle}");
                map.Add("Guid", blogEntryGuid);
                map.Add("Author", author);
                map.Add("Email", email);
                map.Add("WebSite", website);
                map.Add("DateTime", DateTime.Now.ToString());
                map.Add("Text", text);
                map.Add("Link", UrlCleaner.FixWebPathTail(Minima.Configuration.BlogSection.GetConfigSection().Domain) + @"/services/comment/{CommentGuid}");
                String emailBodyTemplate = creator.Create(map);
                Themelia.Configuration.SystemSection systemSection = Themelia.Configuration.SystemSection.GetConfigSection();
                String emailSubject = String.Format("{0} ({1})", BlogSection.GetConfigSection().Comment.Subject, systemSection.AppInfo.Name);
                //+
                String commentGuid = String.Empty;
                returnStatus = 0;
                try
                {
                    commentGuid = CommentAgent.PostNewComment(blogEntryGuid, text, author, email, website, DateTime.Now, emailBodyTemplate, emailSubject);
                }
                catch (Exception ex)
                {
                    if (ex.Message != "Failure sending mail.")
                    {
                        returnStatus = 1;
                    }
                }
            }
            else
            {
                returnStatus = 2;
            }
            //+
            return(returnStatus);
        }
コード例 #4
0
        public BlogInfo[] GetUsersBlogs(String key, String emailAddress, String password)
        {
            if (this.Reporter.Initialized)
            {
                this.Reporter.SendSingle(new Object[] { key, emailAddress, password }, "XmlRpcApi::GetUsersBlogs", false);
            }
            //+
            List <BlogMetaData> blogList = BlogAgent.GetBlogListForAssociatedAuthor(emailAddress, password);

            //+
            Themelia.Map webDomainPathMap = new Themelia.Map();
            foreach (WebDomainData webDomainData in WebDomainDataList.AllWebDomainData)
            {
                ComponentData data = webDomainData.ComponentDataList[Info.MinimaKey];
                if (data != null)
                {
                    ParameterData parameterData = data.ParameterDataList[Info.BlogGuid];
                    if (parameterData != null)
                    {
                        String blogGuid = parameterData.Value;
                        if (!webDomainPathMap.ContainsKey(blogGuid))
                        {
                            webDomainPathMap.Add(blogGuid, webDomainData.Path);
                        }
                        else
                        {
                            throw new InvalidOperationException("Only one MinimaComponent may use a particular blog guid on a web site.  Minima web controls in other web domains may reference the web domain for a particular blog guid in order to access that blog.  Also, make sure that only the MinimaComponent component is using the \"Minima\" Key.");
                        }
                    }
                }
            }
            List <String> registeredBlogGuidList = webDomainPathMap.GetKeyList();

            //+
            BlogInfo[] netBlogList = (from b in blogList
                                      where registeredBlogGuidList.Contains(b.Guid)
                                      select new BlogInfo
            {
                blogid = b.Guid,
                blogName = b.Title,
                url = Themelia.Web.WebDomain.GetUrl(webDomainPathMap[b.Guid])
            }).ToArray();
            //+
            return(netBlogList);
        }
コード例 #5
0
 //+
 //- @InstantiateIn -//
 public void InstantiateIn(System.Web.UI.Control container)
 {
     System.Web.UI.WebControls.PlaceHolder pane = new System.Web.UI.WebControls.PlaceHolder();
     switch (type)
     {
     case ListItemType.Item:
         pane.DataBinding += new EventHandler(delegate(Object sender, System.EventArgs ea)
         {
             RepeaterItem item = (RepeaterItem)pane.NamingContainer;
             //+
             System.Web.UI.WebControls.Literal dtHeader = new System.Web.UI.WebControls.Literal();
             dtHeader.Text = "<dl class=\"index-section-list\"><dt>";
             pane.Controls.Add(dtHeader);
             //+
             System.Web.UI.WebControls.Literal image = new System.Web.UI.WebControls.Literal();
             Themelia.Template template  = new Themelia.Template(Themelia.Template.Common.Image);
             Themelia.Map map            = new Themelia.Map();
             BlogEntryType blogEntryType = FindBlogEntryType((String)DataBinder.Eval(item.DataItem, "TypeGuid"));
             if (blogEntryType != null && !String.IsNullOrEmpty(blogEntryType.Extra))
             {
                 map.Add("Source", blogEntryType.Extra);
                 map.Add("Text", blogEntryType.Name);
                 image.Text = template.Interpolate(map);
                 pane.Controls.Add(image);
             }
             //+
             System.Web.UI.WebControls.Literal dtddConnection = new System.Web.UI.WebControls.Literal();
             dtddConnection.Text = "</dt><dd>";
             pane.Controls.Add(dtddConnection);
             //+
             System.Web.UI.WebControls.Literal link = new System.Web.UI.WebControls.Literal();
             template = new Themelia.Template(Themelia.Template.Common.Link);
             map      = new Themelia.Map();
             map.Add("Link", (String)DataBinder.Eval(item.DataItem, "Url"));
             map.Add("Text", (String)DataBinder.Eval(item.DataItem, "Title"));
             link.Text = template.Interpolate(map);
             pane.Controls.Add(link);
             //+
             List <Minima.Service.Label> labelList = (List <Minima.Service.Label>)DataBinder.Eval(item.DataItem, "LabelList");
             if (labelList != null && labelList.Count > 0)
             {
                 Repeater rptLabel   = new Repeater();
                 rptLabel.DataSource = labelList.Select(label => new
                 {
                     Title = label.Title,
                     Url   = LabelHelper.GetLabelUrl(label)
                 });
                 rptLabel.HeaderTemplate = new IndexLabelListTemplate(ListItemType.Header);
                 rptLabel.ItemTemplate   = new IndexLabelListTemplate(ListItemType.Item);
                 rptLabel.FooterTemplate = new IndexLabelListTemplate(ListItemType.Footer);
                 pane.Controls.Add(rptLabel);
             }
             //+
             System.Web.UI.WebControls.Literal ddFooter = new System.Web.UI.WebControls.Literal();
             ddFooter.Text = "</dd></dl>";
             pane.Controls.Add(ddFooter);
         });
         break;
     }
     container.Controls.Add(pane);
 }