示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var objectType = Helper.GetObjectType(Request.QueryString["OT"]);

            dataObject = DataObject.LoadByReflection(Request.QueryString["OID"].ToGuid(), objectType.NumericId);

            _4screen.CSB.Extensions.Business.TrackingManager.TrackEventPage(dataObject.CommunityID, dataObject.objectType, IsPostBack, LogSitePageType.Detail);
            dataObject.AddViewed(UserDataContext.GetUserDataContext());

            if (UserProfile.Current.UserId != dataObject.UserID.Value)
            {
                _4screen.CSB.Extensions.Business.IncentivePointsManager.AddIncentivePointEvent("OBJECT_VIEWED_MOBILE_DEVICE", UserDataContext.GetUserDataContext(), dataObject.ObjectID.Value.ToString());
            }

            Control control = !string.IsNullOrEmpty(objectType.MobileDetailsCtrl) ? LoadControl(objectType.MobileDetailsCtrl) : LoadControl("/M/UserControls/Templates/DetailsObject.ascx");

            ((IDataObjectWorker)control).DataObject = dataObject;
            PhCnt.Controls.Add(control);

            if (dataObject.Title != null)
            {
                Master.Page.Title = SiteConfig.SiteName + " - " + _4screen.Utils.Extensions.EscapeForXHTML(dataObject.Title);
            }
        }
示例#2
0
        public override bool ShowObject(string settingsXml)
        {
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(settingsXml);
            bool showEdit = true;

            bool   byUrl      = XmlHelper.GetElementValue(xmlDocument.DocumentElement, "ByUrl", false);
            string objectType = XmlHelper.GetElementValue(xmlDocument.DocumentElement, "ObjectType", "0");
            Guid?  objectId   = XmlHelper.GetElementValue(xmlDocument.DocumentElement, "ObjectID", string.Empty).ToNullableGuid();
            int    source     = XmlHelper.GetElementValue(xmlDocument.DocumentElement, "Source", 8);
            bool   showPager  = XmlHelper.GetElementValue(xmlDocument.DocumentElement, "ShowPager", false);

            if (objectType == "0")
            {
                byUrl = true;
                if (string.IsNullOrEmpty(Request.QueryString["OT"]) || string.IsNullOrEmpty(Request.QueryString["OID"]))
                {
                    return(false);
                }
                else
                {
                    objectType = Request.QueryString["OT"];
                    objectId   = Request.QueryString["OID"].ToGuid();
                }
            }

            DataObject dataObject = null;

            if (byUrl)
            {
                if (!objectId.HasValue && string.IsNullOrEmpty(Request.QueryString["OID"]))
                {
                    return(false);
                }

                if (!string.IsNullOrEmpty(Request.QueryString["OT"]) && Helper.GetObjectTypeNumericID(Request.QueryString["OT"]) != Helper.GetObjectTypeNumericID(objectType))
                {
                    return(false);
                }

                objectId   = Request.QueryString["OID"].ToGuid();
                dataObject = DataObject.LoadByReflection(objectId.Value, Helper.GetObjectTypeNumericID(objectType));
            }
            else if (source > -1)
            {
                dataObject = LoadBySource(Helper.GetObjectTypeNumericID(objectType), source);
                showEdit   = false;
            }
            else if (objectId.HasValue)
            {
                dataObject = DataObject.LoadByReflection(objectId.Value, Helper.GetObjectTypeNumericID(objectType), null);
            }
            else
            {
                return(false);
            }

            if (dataObject == null)
            {
                return(false);
            }

            if (dataObject.State == ObjectState.Added)
            {
                return(false);
            }
            else if (dataObject.State == ObjectState.Deleted)
            {
                this.PhDet.Controls.Add(new LiteralControl(GuiLanguage.GetGuiLanguage("WidgetObjectDetail").GetString("MessageDeleted")));
                return(true);
            }

            if (showEdit)
            {
                Control   controlEP = LoadControl("~/UserControls/CntEdit.ascx");
                ISettings ISettEP   = controlEP as ISettings;
                ISettEP.Settings = new System.Collections.Generic.Dictionary <string, object>();
                ISettEP.Settings.Add("ObjectID", dataObject.ObjectID);
                PhEP.Controls.Add(controlEP);
            }

            string template = "ObjectDetail.ascx";

            if (WidgetHost.OutputTemplate != null)
            {
                if (!string.IsNullOrEmpty(WidgetHost.OutputTemplate.OutputTemplateControl))
                {
                    template = WidgetHost.OutputTemplate.OutputTemplateControl;
                }
            }

            try
            {
                Control control = LoadControl("~/UserControls/Templates/" + template);

                IDataObjectWorker dataObjectWorker = control as IDataObjectWorker;
                dataObjectWorker.DataObject = dataObject;

                ISettings setting = control as ISettings;
                if (setting != null)
                {
                    setting.Settings = new System.Collections.Generic.Dictionary <string, object>();
                    setting.Settings.Add("ObjectType", Helper.GetObjectTypeNumericID(objectType));
                    setting.Settings.Add("ObjectId", dataObject.ObjectID);
                    setting.Settings.Add("Width", WidgetHost.ColumnWidth - WidgetHost.ContentPadding);
                    setting.Settings.Add("ParentPageType", WidgetHost.ParentPageType);
                    setting.Settings.Add("ParentObjectType", WidgetHost.ParentObjectType);
                    setting.Settings.Add("ParentCommunityID", WidgetHost.ParentCommunityID);
                }

                PhDet.Controls.Add(control);

                if (showPager)
                {
                    Control pager = LoadControl("/UserControls/DetailPager.ascx");
                    ((IDataObjectWorker)pager).DataObject = dataObject;
                    PhPager.Controls.Add(pager);
                }

                // Set widget title
                Control widgetControl = WidgetHelper.GetWidgetHost(this, 0, 5);
                ((Literal)widgetControl.FindControl("LitTitle")).Text = ((Literal)widgetControl.FindControl("LitTitle")).Text.Replace("##OBJ_TITLE##", dataObject.Title).Replace("##OBJ_INSERT_DATE##", dataObject.Inserted.ToShortDateString() + " " + dataObject.Inserted.ToShortTimeString()).Replace("##OBJ_NICKNAME##", dataObject.Nickname);

                if (WidgetHost.ParentPageType == PageType.Detail)
                {
                    StringBuilder taglist = new StringBuilder();
                    foreach (string tag in dataObject.TagList.Split(Constants.TAG_DELIMITER))
                    {
                        if (tag.StartsWith("*"))
                        {
                            continue;
                        }

                        if (taglist.Length > 0)
                        {
                            taglist.Append(", ");
                        }

                        taglist.Append(tag);
                    }

                    if (WidgetHost.WidgetInstance.INS_HeadingTag.HasValue && WidgetHost.WidgetInstance.INS_HeadingTag.Value == 1)
                    {
                        ((IWidgetPageMaster)this.Page.Master).BreadCrumb.RenderDetailPageBreadCrumbs(dataObject);

                        ((IWidgetPageMaster)this.Page.Master).MetaKeywords.Content     = Server.HtmlEncode(taglist.ToString().Trim());
                        ((IWidgetPageMaster)this.Page.Master).MetaDescription.Content  = Server.HtmlEncode(dataObject.Description.StripHTMLTags());
                        ((IWidgetPageMaster)this.Page.Master).MetaModifiedDate.Content = System.Xml.XmlConvert.ToString(dataObject.Updated);
                        ((IWidgetPageMaster)this.Page.Master).MetaModifiedDate.Visible = true;

                        ((IWidgetPageMaster)this.Page.Master).MetaOgTitle.Content = Server.HtmlEncode(dataObject.Title.StripHTMLTags());
                        ((IWidgetPageMaster)this.Page.Master).MetaOgTitle.Visible = true;
                        ((IWidgetPageMaster)this.Page.Master).MetaOgUrl.Content   = _4screen.CSB.Common.SiteConfig.SiteURL + Helper.GetDetailLink(dataObject.ObjectType, dataObject.ObjectID.ToString());
                        ((IWidgetPageMaster)this.Page.Master).MetaOgUrl.Visible   = true;
                        if (!string.IsNullOrEmpty(dataObject.GetImage(PictureVersion.S, false)))
                        {
                            ((IWidgetPageMaster)this.Page.Master).MetaOgImage.Content = _4screen.CSB.Common.SiteConfig.MediaDomainName + dataObject.GetImage(PictureVersion.S, false);
                            ((IWidgetPageMaster)this.Page.Master).MetaOgImage.Visible = true;
                        }

                        if (dataObject.Geo_Lat != Double.MinValue && dataObject.Geo_Long != Double.MinValue)
                        {
                            ((IWidgetPageMaster)this.Page.Master).MetaOgLatitude.Content  = dataObject.Geo_Lat.ToString();
                            ((IWidgetPageMaster)this.Page.Master).MetaOgLatitude.Visible  = true;
                            ((IWidgetPageMaster)this.Page.Master).MetaOgLongitude.Content = dataObject.Geo_Long.ToString();
                            ((IWidgetPageMaster)this.Page.Master).MetaOgLongitude.Visible = true;
                        }

                        if (!string.IsNullOrEmpty(dataObject.Street) && !string.IsNullOrEmpty(dataObject.City) && !string.IsNullOrEmpty(dataObject.CountryCode))
                        {
                            ((IWidgetPageMaster)this.Page.Master).MetaOgStreet.Content      = dataObject.Street;
                            ((IWidgetPageMaster)this.Page.Master).MetaOgStreet.Visible      = true;
                            ((IWidgetPageMaster)this.Page.Master).MetaOgCity.Content        = dataObject.City;
                            ((IWidgetPageMaster)this.Page.Master).MetaOgCity.Visible        = true;
                            ((IWidgetPageMaster)this.Page.Master).MetaOgCountryCode.Content = dataObject.CountryCode;
                            ((IWidgetPageMaster)this.Page.Master).MetaOgCountryCode.Visible = true;
                            if (!string.IsNullOrEmpty(dataObject.Zip))
                            {
                                ((IWidgetPageMaster)this.Page.Master).MetaOgZipCode.Content = dataObject.Zip;
                                ((IWidgetPageMaster)this.Page.Master).MetaOgZipCode.Visible = true;
                            }
                        }
                    }
                }

                bool hasContent = true;
                if (setting.Settings.ContainsKey("HasContent"))
                {
                    hasContent = (bool)setting.Settings["HasContent"];
                }

                if (hasContent)
                {
                    dataObject.AddViewed(UserDataContext.GetUserDataContext());
                    if (UserProfile.Current.UserId != dataObject.UserID.Value)
                    {
                        _4screen.CSB.Extensions.Business.IncentivePointsManager.AddIncentivePointEvent(dataObject.ObjectType.ToString().ToUpper() + "_VIEWED", UserDataContext.GetUserDataContext(), dataObject.ObjectID.Value.ToString());
                    }
                }
                return(hasContent);
            }
            catch (Exception ex)
            {
                PhDet.Controls.Add(new LiteralControl(string.Format(GuiLanguage.GetGuiLanguage("Shared").GetString("MessageNotLoad"), Helper.GetObjectName(objectType, true))));
            }

            return(true);
        }
示例#3
0
        private void PreparePage()
        {
            // Check access rights and increase view count
            if ((pageOrCommunity.GetUserAccess(UserDataContext.GetUserDataContext()) & ObjectAccessRight.Update) == ObjectAccessRight.Update)
            {
                isReadOnly = false;
            }
            if (pageOrCommunity.ObjectType == Helper.GetObjectTypeNumericID("ProfileCommunity") && !CustomizationSection.CachedInstance.CustomizationBar.Enabled)
            {
                isReadOnly = true;
            }
            if (UserDataContext.GetUserDataContext().IsAdmin)
            {
                isReadOnly = false;
            }

            if (UserProfile.Current.UserId != Guid.Empty)
            {
                isOwner = Community.GetIsUserOwner(UserProfile.Current.UserId, PageInfo.EffectiveCommunityId.Value, out isMember);
            }

            if (pageOrCommunity.ObjectType == Helper.GetObjectTypeNumericID("Community"))
            {
                if (pageOrCommunity.Status == ObjectStatus.Public || isOwner || isMember)
                {
                    DataObject.AddViewed(UserDataContext.GetUserDataContext(), pageOrCommunity.UserID, Helper.GetObjectTypeNumericID("Community"));
                }
                else
                {
                    Response.Redirect("/pages/static/AccessDenied.aspx", true);
                }
            }
            else if (pageOrCommunity.ObjectType == Helper.GetObjectTypeNumericID("ProfileCommunity"))
            {
                DataObject.AddViewed(UserDataContext.GetUserDataContext(), pageOrCommunity.UserID, Helper.GetObjectTypeNumericID("User"));
                DataObject.AddViewed(UserDataContext.GetUserDataContext(), pageOrCommunity.UserID, Helper.GetObjectTypeNumericID("ProfileCommunity"));
            }
            else if (pageOrCommunity.ObjectType == Helper.GetObjectTypeNumericID("Page"))
            {
                if (pageOrCommunity.RoleRight.ContainsKey(UserDataContext.GetUserDataContext().UserRole) && pageOrCommunity.RoleRight[UserDataContext.GetUserDataContext().UserRole])
                {
                    DataObject.AddViewed(UserDataContext.GetUserDataContext(), pageOrCommunity.UserID, Helper.GetObjectTypeNumericID("Page"));
                }
                else
                {
                    Response.Redirect("/pages/static/AccessDenied.aspx", true);
                }
            }

            // Load pages
            pages = wdc.hitbl_Page_PAGs.Where(x => x.CTY_ID == PageInfo.EffectiveCommunityId).OrderBy(x => x.PAG_OrderNr).ToList();
            if (pageOrCommunity.ObjectType == Helper.GetObjectTypeNumericID("Community") || pageOrCommunity.ObjectType == Helper.GetObjectTypeNumericID("ProfileCommunity"))
            {
                int pageIndex;
                if (isOwner && (page.ToLower() == "dashboard" || string.IsNullOrEmpty(page)))
                {
                    currentPage = pages[0];
                    page        = "dashboard";
                }
                else if (!string.IsNullOrEmpty(page) && int.TryParse(page, out pageIndex))
                {
                    currentPage = pages[pageIndex];
                }
                else
                {
                    currentPage = pages[1];
                }
            }
            else
            {
                currentPage = pages[0];
            }

            hitbl_Community_CTY owningCommunity = null;
            Guid?owningCommunityId = null;
            int  owningObjectType  = 0;

            // Set theme and style
            bool themeAndStyleOverridden = false;

            if (pageOrCommunity.ObjectType == Helper.GetObjectTypeNumericID("Page"))
            {
                DataObjectPage page = DataObject.Load <DataObjectPage>(PageInfo.EffectiveCommunityId);
                parentPageType = page.PageType;
                if (parentPageType == PageType.Detail && !string.IsNullOrEmpty(Request.QueryString["OID"]))
                {
                    DataObject detail = DataObject.Load <DataObject>(Request.QueryString["OID"].ToGuid());
                    if (detail.State != ObjectState.Added)
                    {
                        owningCommunityId       = detail.CommunityID;
                        owningObjectType        = page.ObjectType;
                        owningCommunity         = wdc.hitbl_Community_CTies.Where(x => x.CTY_ID == owningCommunityId).SingleOrDefault();
                        themeAndStyleOverridden = true;
                    }
                    else
                    {
                        Response.Redirect("/Pages/Static/ObjectNotFound.aspx");
                    }
                }
                else if (parentPageType == PageType.Overview && (!string.IsNullOrEmpty(Request.QueryString["XUI"]) || !string.IsNullOrEmpty(Request.QueryString["XCN"])))
                {
                    if (!string.IsNullOrEmpty(Request.QueryString["XUI"]))
                    {
                        MembershipUser membershipUser = Membership.GetUser(new Guid(Request.QueryString["XUI"]), false);
                        owningCommunityId = UserProfile.GetProfile(membershipUser.UserName).ProfileCommunityID;
                        owningObjectType  = Helper.GetObjectType("ProfileCommunity").NumericId;
                    }
                    else if (!string.IsNullOrEmpty(Request.QueryString["XCN"]))
                    {
                        owningCommunityId = new Guid(Request.QueryString["XCN"]);
                        owningObjectType  = Helper.GetObjectType("Community").NumericId;
                    }
                    owningCommunity         = wdc.hitbl_Community_CTies.Where(x => x.CTY_ID == owningCommunityId).SingleOrDefault();
                    themeAndStyleOverridden = true;
                }
            }

            if (!themeAndStyleOverridden)
            {
                owningCommunity = community;
            }

            Theme = owningCommunity.CTY_Theme;
            ((IWidgetPageMaster)Page.Master).HeaderStyle = owningCommunity.CTY_HeaderStyle;
            ((IWidgetPageMaster)Page.Master).BodyStyle   = owningCommunity.CTY_BodyStyle;
            ((IWidgetPageMaster)Page.Master).FooterStyle = owningCommunity.CTY_FooterStyle;

            //Add custom widget styles
            var           widgetStyles = wdc.hisp_WidgetTemplates_GetCommunityTemplates(PageInfo.EffectiveCommunityId).ToList();
            StringBuilder styles       = new StringBuilder("<style>");

            foreach (var widgetStyle in widgetStyles)
            {
                styles.Append(widgetStyle.WTP_Template);
            }
            styles.Append("</style>");
            PhStyle.Controls.Clear();
            PhStyle.Controls.Add(new LiteralControl(styles.ToString()));

            // Set metadata and breadcrumbs
            // TODO: weitere Format-Config's in Customizaition.config machen (die vorhandenen sind unklar benannt und somit weiss man nicht wo verwendet)
            ((IWidgetPageMaster)Page.Master).MetaDescription.Content = Server.HtmlEncode(pageOrCommunity.Description.StripHTMLTags());
            ((IWidgetPageMaster)Page.Master).MetaKeywords.Content    = Server.HtmlEncode(pageOrCommunity.TagList.StripHTMLTags().Replace(Common.Constants.TAG_DELIMITER.ToString(), ","));

            ((IWidgetPageMaster)Page.Master).MetaOgSiteName.Content = SiteConfig.SiteName;
            ((IWidgetPageMaster)Page.Master).MetaOgUrl.Content      = SiteConfig.SiteURL + Request.RawUrl;
            ((IWidgetPageMaster)Page.Master).MetaOgTitle.Content    = Server.HtmlEncode(pageOrCommunity.Title.StripHTMLTags());

            if (parentPageType == PageType.Homepage)
            {
                Master.Page.Title = string.Format(CustomizationSection.CachedInstance.Common.TitleFormat1, SiteConfig.SiteName, pageOrCommunity.Title);
            }
            else if (parentPageType == PageType.Overview)
            {
                ((IWidgetPageMaster)Page.Master).RssLink.Href = "/pages/other/rssfeed.aspx" + Request.Url.Query;
            }
            else if (parentPageType == PageType.Detail)
            {
                if (Helper.GetObjectTypeNumericID(Request.QueryString["OT"]) == Helper.GetObjectTypeNumericID("ForumTopic") && !string.IsNullOrEmpty(Request.QueryString["OID"]))
                {
                    ((IWidgetPageMaster)Page.Master).RssLink.Href = "/pages/other/rssfeed.aspx?OT=ForumTopicItem&RPID=" + Request.QueryString["OID"];
                }
                else if (Helper.GetObjectTypeNumericID(Request.QueryString["OT"]) == Helper.GetObjectTypeNumericID("Forum"))
                {
                    ((IWidgetPageMaster)Page.Master).RssLink.Href = "/pages/other/rssfeed.aspx?OT=ForumTopicItem";
                }
            }
            else if (parentPageType == PageType.None)
            {
                if (pageOrCommunity.ObjectType == Helper.GetObjectTypeNumericID("ProfileCommunity") && page.ToLower() != "dashboard")
                {
                    ((IWidgetPageMaster)Page.Master).BreadCrumb.BreadCrumbs.Add(new LiteralControl(string.Format("{0}", pageOrCommunity.Nickname)));
                    ((IWidgetPageMaster)Page.Master).BreadCrumb.BreadCrumpImage = string.Format("/Library/Images/Layout/{0}", Helper.GetObjectIcon(Helper.GetObjectTypeNumericID("User")));
                    ((IWidgetPageMaster)Page.Master).BreadCrumb.RenderBreadCrumbs();
                    ((IWidgetPageMaster)Page.Master).RssLink.Href = "/pages/other/rssfeed.aspx" + Request.Url.Query;
                    Master.Page.Title = string.Format(CustomizationSection.CachedInstance.Common.TitleFormat1, SiteConfig.SiteName, pageOrCommunity.Nickname);
                }
                else if (pageOrCommunity.ObjectType == Helper.GetObjectTypeNumericID("Community") || pageOrCommunity.ObjectType == Helper.GetObjectTypeNumericID("Page"))
                {
                    ((IWidgetPageMaster)Page.Master).BreadCrumb.BreadCrumpImage = string.Format("/Library/Images/Layout/{0}", Helper.GetObjectIcon(pageOrCommunity.ObjectType));
                    string title = Regex.Replace(pageOrCommunity.Title, @"\[tracking=.*?\]", "", RegexOptions.IgnoreCase);

                    if (!pageOrCommunity.ParentObjectID.HasValue)
                    {
                        ((IWidgetPageMaster)Page.Master).BreadCrumb.BreadCrumbs.Add(new LiteralControl(title));
                        ((IWidgetPageMaster)Page.Master).BreadCrumb.RenderBreadCrumbs();
                        Master.Page.Title = string.Format(CustomizationSection.CachedInstance.Common.TitleFormat1, SiteConfig.SiteName, title);
                    }
                    else
                    {
                        Community parentCommunity = new Community(pageOrCommunity.ParentObjectID.Value);
                        string    parentTitle     = Regex.Replace(parentCommunity.ProfileOrCommunity.Title, @"\[tracking=.*?\]", "", RegexOptions.IgnoreCase);
                        ((IWidgetPageMaster)Page.Master).BreadCrumb.BreadCrumbs.Add(new LiteralControl(string.Format("<a href='{0}'>{1}</a> / {2}", Helper.GetDetailLink(Helper.GetObjectTypeNumericID("Community"), ((DataObjectCommunity)parentCommunity.ProfileOrCommunity).VirtualURL, true), parentTitle, title)));
                        ((IWidgetPageMaster)Page.Master).BreadCrumb.RenderBreadCrumbs();
                        Master.Page.Title = string.Format(CustomizationSection.CachedInstance.Common.TitleFormat1, SiteConfig.SiteName, parentTitle + " / " + title);
                    }
                }
            }

            // Track events
            if (pageOrCommunity.objectType == Helper.GetObjectType("Page").NumericId)
            {
                if (parentPageType == PageType.Overview)
                {
                    _4screen.CSB.Extensions.Business.TrackingManager.TrackEventPage(owningCommunityId, owningObjectType, IsPostBack, LogSitePageType.Overview);
                }
                else if (parentPageType == PageType.Detail)
                {
                    _4screen.CSB.Extensions.Business.TrackingManager.TrackEventPage(owningCommunityId, owningObjectType, IsPostBack, LogSitePageType.Detail);
                }
                else if (parentPageType == PageType.Homepage)
                {
                    _4screen.CSB.Extensions.Business.TrackingManager.TrackEventPage(owningCommunityId, owningObjectType, IsPostBack, LogSitePageType.Homepage);
                }
                else
                {
                    _4screen.CSB.Extensions.Business.TrackingManager.TrackEventPage(PageInfo.EffectiveCommunityId, pageOrCommunity.ObjectType, IsPostBack, LogSitePageType.CmsPage);
                }
            }
            else if (pageOrCommunity.objectType == Helper.GetObjectType("Community").NumericId)
            {
                _4screen.CSB.Extensions.Business.TrackingManager.TrackEventPage(pageOrCommunity.ObjectID, pageOrCommunity.ObjectType, IsPostBack, LogSitePageType.Community);
            }
            else if (pageOrCommunity.objectType == Helper.GetObjectType("ProfileCommunity").NumericId)
            {
                _4screen.CSB.Extensions.Business.TrackingManager.TrackEventPage(pageOrCommunity.ObjectID, pageOrCommunity.ObjectType, IsPostBack, LogSitePageType.UserProfile);
            }
        }
示例#4
0
        public override bool ShowObject(string settingsXml)
        {
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(settingsXml);
            bool showEdit = true;

            bool   byUrl      = XmlHelper.GetElementValue(xmlDocument.DocumentElement, "ByUrl", false);
            string objectType = XmlHelper.GetElementValue(xmlDocument.DocumentElement, "ObjectType", "0");
            Guid?  objectId   = XmlHelper.GetElementValue(xmlDocument.DocumentElement, "ObjectID", string.Empty).ToNullableGuid();
            int    source     = XmlHelper.GetElementValue(xmlDocument.DocumentElement, "Source", 8);

            if (objectType == "0")
            {
                byUrl = true;
                if (string.IsNullOrEmpty(Request.QueryString["OT"]) || string.IsNullOrEmpty(Request.QueryString["OID"]))
                {
                    return(false);
                }
                else
                {
                    objectType = Request.QueryString["OT"];
                    objectId   = Request.QueryString["OID"].ToGuid();
                }
            }

            DataObject dataObject = null;

            if (byUrl)
            {
                if (!objectId.HasValue && string.IsNullOrEmpty(Request.QueryString["OID"]))
                {
                    return(false);
                }

                if (!string.IsNullOrEmpty(Request.QueryString["OT"]) && Helper.GetObjectTypeNumericID(Request.QueryString["OT"]) != Helper.GetObjectTypeNumericID(objectType))
                {
                    return(false);
                }

                objectId   = Request.QueryString["OID"].ToGuid();
                dataObject = DataObject.LoadByReflection(objectId.Value, Helper.GetObjectTypeNumericID(objectType));
            }
            else if (source > -1)
            {
                dataObject = LoadBySource(Helper.GetObjectTypeNumericID(objectType), source);
                showEdit   = false;
            }
            else if (objectId.HasValue)
            {
                dataObject = DataObject.LoadByReflection(objectId.Value, Helper.GetObjectTypeNumericID(objectType));
            }
            else
            {
                return(false);
            }

            if (dataObject == null)
            {
                return(false);
            }

            if (dataObject.State == ObjectState.Added)
            {
                return(false);
            }
            else if (dataObject.State == ObjectState.Deleted)
            {
                this.PhDet.Controls.Add(new LiteralControl(GuiLanguage.GetGuiLanguage("WidgetObjectDetail").GetString("MessageDeleted")));
                return(true);
            }

            if (showEdit)
            {
                Control   controlEP = LoadControl("~/UserControls/CntEdit.ascx");
                ISettings ISettEP   = controlEP as ISettings;
                ISettEP.Settings = new System.Collections.Generic.Dictionary <string, object>();
                ISettEP.Settings.Add("ObjectID", dataObject.ObjectID);
                PhEP.Controls.Add(controlEP);
            }

            string template = "ObjectDetail.ascx";

            if (_Host.OutputTemplate != null)
            {
                if (!string.IsNullOrEmpty(_Host.OutputTemplate.OutputTemplateControl))
                {
                    template = _Host.OutputTemplate.OutputTemplateControl;
                }
            }

            try
            {
                Control control = LoadControl("~/UserControls/Templates/" + template);

                IDataObjectWorker dataObjectWorker = control as IDataObjectWorker;
                dataObjectWorker.DataObject = dataObject;

                ISettings setting = control as ISettings;
                if (setting != null)
                {
                    setting.Settings = new System.Collections.Generic.Dictionary <string, object>();
                    setting.Settings.Add("ObjectType", Helper.GetObjectTypeNumericID(objectType));
                    setting.Settings.Add("ObjectId", dataObject.ObjectID);
                    setting.Settings.Add("Width", _Host.ColumnWidth);
                    setting.Settings.Add("ParentPageType", _Host.ParentPageType);
                    setting.Settings.Add("ParentObjectType", _Host.ParentObjectType);
                    setting.Settings.Add("ParentCommunityID", _Host.ParentCommunityID);
                }

                PhDet.Controls.Add(control);
                if (dataObject.ObjectType == 3) //Picture
                {
                    ((IWidgetPageMaster)this.Page.Master).BodyTag.Attributes.Add("onload", "initImageAnnotation();");
                }

                //// Set widget title
                Control widgetControl = WidgetHelper.GetWidgetHost(this, 0, 5);
                ((Literal)widgetControl.FindControl("LitTitle")).Text = ((Literal)widgetControl.FindControl("LitTitle")).Text.Replace("##OBJ_TITLE##", dataObject.Title);

                if (_Host.ParentPageType == PageType.Detail)
                {
                    StringBuilder taglist = new StringBuilder();
                    foreach (string tag in dataObject.TagList.Split(Constants.TAG_DELIMITER))
                    {
                        if (tag.StartsWith("*"))
                        {
                            continue;
                        }

                        if (taglist.Length > 0)
                        {
                            taglist.Append(", ");
                        }

                        taglist.Append(tag);
                    }

                    // TODO: HTML content will not be rendered to the breadcrumb, because the breadcrumb would contain a lot of 'static' html content links
                    // same issue occurs of course, if there are multiple other object detail widget on ONE page
                    if (dataObject.objectType != 1020)
                    {
                        ((IWidgetPageMaster)this.Page.Master).BreadCrumb.RenderDetailPageBreadCrumbs(dataObject);
                    }

                    ((IWidgetPageMaster)this.Page.Master).MetaKeywords.Content     = taglist.ToString().Trim();
                    ((IWidgetPageMaster)this.Page.Master).MetaDescription.Content  = dataObject.Description.StripHTMLTags();
                    ((IWidgetPageMaster)this.Page.Master).MetaModifiedDate.Content = System.Xml.XmlConvert.ToString(dataObject.Updated);
                    ((IWidgetPageMaster)this.Page.Master).MetaModifiedDate.Visible = true;
                    ((IWidgetPageMaster)this.Page.Master).MetaModifiedDate.ID      = null;
                }

                dataObject.AddViewed();

                if (UserProfile.Current.UserId != dataObject.UserID.Value)
                {
                    _4screen.CSB.Extensions.Business.IncentivePointsManager.AddIncentivePointEvent(dataObject.ObjectType.ToString().ToUpper() + "_VIEWED", UserDataContext.GetUserDataContext(), dataObject.ObjectID.Value.ToString());
                }

                if (setting.Settings.ContainsKey("HasContent"))
                {
                    return((bool)setting.Settings["HasContent"]);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                PhDet.Controls.Add(new LiteralControl(string.Format(GuiLanguage.GetGuiLanguage("UserControls.WebUI").GetString("MessageNotLoad"), Helper.GetObjectName(objectType, true))));
            }

            return(true);
        }