Ejemplo n.º 1
0
        protected void OBJOVW_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            DataObject  dataObject = (DataObject)e.Item.DataItem;
            PlaceHolder ph         = (PlaceHolder)e.Item.FindControl("PhItem");

            Control           ctrl             = LoadControl(string.Format("~/UserControls/Templates/{0}", template));
            IDataObjectWorker dataObjectWorker = ctrl as IDataObjectWorker;

            if (dataObjectWorker != null)
            {
                dataObjectWorker.DataObject = dataObject;
            }

            LiteralControl lit = new LiteralControl();

            if (TxtSelected.Value == dataObject.ObjectID.ToString())
            {
                lit.Text = string.Format("<div id=\"{0}\" onclick=\"javascript:SelectElement('{0}', '{1}');\" class=\"itemSelected\">", dataObject.ObjectID, TxtSelected.ClientID);
            }
            else
            {
                lit.Text = string.Format("<div id=\"{0}\" onclick=\"javascript:SelectElement('{0}', '{1}');\" class=\"itemNotSelected\">", dataObject.ObjectID, TxtSelected.ClientID);
            }

            ph.Controls.Add(lit);
            ph.Controls.Add(ctrl);
            ph.Controls.Add(new LiteralControl("</div>"));
        }
Ejemplo n.º 2
0
 private void SetOutput(PlaceHolder ph, IDataObjectWorker outputControl, DataObject DataObject)
 {
     outputControl.DataObject = DataObject;
     if (outputControl is IFolderParameters)
     {
         ((IFolderParameters)outputControl).FolderParameters = folderParams;
     }
     ph.Controls.Add((Control)outputControl);
 }
Ejemplo n.º 3
0
        protected void OnOverviewItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            DataObjectUser dataObjectUser = (DataObjectUser)e.Item.DataItem;
            PlaceHolder    ph             = (PlaceHolder)e.Item.FindControl("PhItem");

            Control ctrl = LoadControl(string.Format("~/UserControls/Templates/{0}", this.OutputTemplate));

            IDataObjectWorker dataObjectWorker = ctrl as IDataObjectWorker;

            if (dataObjectWorker != null)
            {
                dataObjectWorker.DataObject = dataObjectUser;
            }

            ph.Controls.Add(ctrl);
        }
Ejemplo n.º 4
0
        protected void OnOverviewItemDataBound(object sender, DataListItemEventArgs e)
        {
            DataObjectProduct dataObjectUser = (DataObjectProduct)e.Item.DataItem;
            PlaceHolder       ph             = (PlaceHolder)e.Item.FindControl("PhItem");

            string  templateControl = this.OutputTemplate;
            Control outControl      = LoadControl(string.Format("~/UserControls/Templates/{0}", templateControl));

            IDataObjectWorker outputControl = outControl as IDataObjectWorker;

            outputControl.DataObject = dataObjectUser;

            ISettings iCtrSett = outputControl as ISettings;

            iCtrSett.Settings = this.Settings;

            ph.Controls.Add(outControl);
        }
Ejemplo n.º 5
0
        protected void OnSearchItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            DataObject  dataObject  = (DataObject)e.Item.DataItem;
            PlaceHolder placeHolder = (PlaceHolder)e.Item.FindControl("Ph");

            Control control = LoadControl(string.Format("~/UserControls/Templates/{0}", Helper.GetObjectType(dataObject.ObjectType).SearchResultCtrl));

            IDataObjectWorker dataObjectWorker = control as IDataObjectWorker;

            if (dataObjectWorker != null)
            {
                dataObjectWorker.DataObject = dataObject;
            }
            else
            {
                ((ISettings)control).Settings.Add("DataObject", dataObject);
            }
            placeHolder.Controls.Add(control);
        }
Ejemplo n.º 6
0
        protected void OnOverviewItemDataBound(object sender, DataListItemEventArgs e)
        {
            DataObjectHTMLContent dataObjectUser = (DataObjectHTMLContent)e.Item.DataItem;
            PlaceHolder           ph             = (PlaceHolder)e.Item.FindControl("PhItem");

            string  templateControl = this.OutputTemplate;
            Control outControl      = LoadControl(string.Format("~/UserControls/Templates/{0}", templateControl));

            IDataObjectWorker outputControl = outControl as IDataObjectWorker;

            outputControl.DataObject = dataObjectUser;

            ISettings iCtrSett = outputControl as ISettings;

            iCtrSett.Settings = new Dictionary <string, object>();
            iCtrSett.Settings.Add("ParentPageType", (PageType)Settings["ParentPageType"]);

            ph.Controls.Add(outControl);
        }
Ejemplo n.º 7
0
        public override bool ShowObject(string settingsXml)
        {
            if (WidgetHost.ParentPageType == PageType.Detail && !string.IsNullOrEmpty(Request.QueryString["OID"]))
            {
                DataObject        dataObject       = DataObject.Load <DataObject>(Request.QueryString["OID"].ToGuid());
                Control           control          = LoadControl("~/UserControls/Templates/Permalink.ascx");
                IDataObjectWorker dataObjectWorker = control as IDataObjectWorker;
                if (dataObjectWorker != null)
                {
                    dataObjectWorker.DataObject = dataObject;
                    Ph.Controls.Add(control);
                    hasContent = true;
                }

                if (dataObject.ObjectType == Helper.GetObjectTypeNumericID("Picture"))
                {
                    dataObject = DataObject.Load <DataObjectPicture>(Request.QueryString["OID"].ToGuid());
                }
                else if (dataObject.ObjectType == Helper.GetObjectTypeNumericID("Video"))
                {
                    dataObject = DataObject.Load <DataObjectVideo>(Request.QueryString["OID"].ToGuid());
                }
                else
                {
                    return(hasContent);
                }

                control          = LoadControl("~/UserControls/Templates/EmbedCode.ascx");
                dataObjectWorker = control as IDataObjectWorker;
                if (dataObjectWorker != null)
                {
                    dataObjectWorker.DataObject = dataObject;
                    Ph.Controls.Add(control);
                    hasContent = true;
                }
            }
            return(hasContent);
        }
Ejemplo n.º 8
0
        public override bool ShowObject(string settingsXml)
        {
            Guid?communityId = null;

            try
            {
                if (this.WidgetHost.ParentObjectType == Helper.GetObjectTypeNumericID("Community"))
                {
                    communityId = this.WidgetHost.ParentCommunityID;
                }
                else if (this.WidgetHost.ParentObjectType == Helper.GetObjectTypeNumericID("Page"))
                {
                    if (WidgetHost.ParentPageType == PageType.Detail && !string.IsNullOrEmpty(Request.QueryString["OID"]))
                    {
                        DataObject detail = DataObject.Load <DataObject>(Request.QueryString["OID"].ToGuid());
                        communityId = detail.CommunityID;
                    }
                    else if (WidgetHost.ParentPageType == PageType.Overview && !string.IsNullOrEmpty(Request.QueryString["XCN"]))
                    {
                        communityId = Request.QueryString["XCN"].ToGuid();
                    }
                }
            }
            catch
            {
                return(false);
            }

            string template = string.Empty;

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


            if (communityId.HasValue && !string.IsNullOrEmpty(template))
            {
                DataObjectCommunity community = DataObject.Load <DataObjectCommunity>(communityId);
                if (community.State != ObjectState.Added)
                {
                    Control control = LoadControl("~/UserControls/Templates/" + template);
                    control.ID = "USI";

                    IDataObjectWorker dataObjectWorker = control as IDataObjectWorker;
                    if (dataObjectWorker != null)
                    {
                        dataObjectWorker.DataObject = community;
                    }
                    else
                    {
                        return(false);
                    }
                    Ph.Controls.Add(control);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
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);
        }