Пример #1
0
        public override void DataBind()
        {
            if (this._bound)
            {
                return;
            }
            _bound = true;

            if (this.Controls.Count == 0)
            {
                this.InnerHtml = StringUtils.AddSup(StringUtils.ReplaceNbSup(Title));
            }

            this.Title = Title;
            this.HRef  = FullURL;

            if (!String.IsNullOrWhiteSpace(Path))
            {
                this.HRef = Path + "/" + this.HRef;
            }
            this.HRef = WebContext.Root + "/" + this.HRef + Anchor;

            if (this.URL.Contains("://"))
            {
                this.HRef   = this.URL;
                this.Target = "_blank";
            }
            else if (this.URL.Contains("mailto:"))
            {
                this.HRef = this.URL;
            }

            string pageFile = ControlUtils.GetBoundedDataField(this.NamingContainer, "PageFile").ToString();

            if (!ForceURL && !String.IsNullOrWhiteSpace(pageFile))
            {
                this.HRef = String.Format("{0}/{3}/Page_{1}/{2}", WebContext.Root, PageId, pageFile, lw.CTE.Folders.PagesFolder);
            }

            if (ShowOnlyInCMSMode)
            {
                this.Visible = false;
            }

            base.DataBind();

            if (MyPage.Editable && ImEditable)
            {
                this.Attributes.Add("data-editable", "true");
                this.Attributes.Add("data-id", PageId.ToString());
                this.Attributes.Add("data-type", EditDataType);
                if (ShowOnlyInCMSMode)
                {
                    this.Visible = true;
                }
            }
            this.Attributes["class"] = this.Attributes["class"] + " " + ControlUtils.GetBoundedDataField(this.NamingContainer, "URL");
            this.Attributes.Add("title", string.Format(Format, Title));
        }
Пример #2
0
        /// <summary>
        /// //Messages (like warning or approval messages)
        /// </summary>
        /// <param name="msg">message</param>
        /// <param name="language">Language for the message</param>
        /// <returns>Content of the message</returns>
        public static string Message(string msg, Languages language)
        {
            string path = Path.Combine(WebContext.Server.MapPath(WebContext.StartDir), ConfigCte.MessagesFolder);

            /*
             * if (language != Languages.Default)
             * {
             *      path = Path.Combine(path, EnumHelper.GetDescription(language));
             * }
             * */

            path = Path.Combine(path, msg + ".htm");

            if (WebContext.Cache[msg + "-" + language.ToString()] != null)
            {
                return(WebContext.Cache[msg].ToString());
            }

            string ret = "";

            if (System.IO.File.Exists(path))
            {
                StreamReader str = new StreamReader(path, Encoding.UTF8);
                ret = str.ReadToEnd();
                ret = ret.Replace("{Root}", WebContext.Root);
                str.Close();
            }

            ret = StringUtils.AddSup(ret);

            CacheDependency dep = new CacheDependency(path);

            int cacheTime = 1;

            string obj = Config.GetFromWebConfig("ContentCachTime");

            if (obj != null)
            {
                cacheTime = Int32.Parse(obj);
            }

            WebContext.Cache.Add(msg, ret, dep, Cache.NoAbsoluteExpiration,
                                 TimeSpan.FromDays(cacheTime), CacheItemPriority.Default, null);

            return(ret);
        }
Пример #3
0
        internal void bind()
        {
            if (_bound)
            {
                return;
            }

            _dataObj = ControlUtils.GetBoundedDataField(NamingContainer, _property, LoadFromDraft);

            _bound = _dataObj != null;

            if (!_bound)
            {
                return;
            }

            if (!String.IsNullOrWhiteSpace(Class))
            {
                var obj = this as IAttributeAccessor;

                if (obj != null)
                {
                    obj.SetAttribute("class", Class);
                }
            }



            string str = "";

            if (_dataObj != DBNull.Value && _dataObj != null && _dataObj.ToString() != "")
            {
                str = string.Format(Format, _dataObj);
            }

            if (MaxCharacters > 0)
            {
                str = StringUtils.Trankate(StringUtils.StripOutHtmlTags(str), _maxCharacters, _closingSentence);
            }

            if (RenderAsHTML)
            {
                str = StringUtils.AddSup(str);
                str = StringUtils.ReplaceNbSup(str);
                str = StringUtils.ReplaceItalicSabis(str);
            }
            if (!String.IsNullOrWhiteSpace(str) || Editable)
            {
                Visible = true;
            }
            else
            {
                Visible = false;
            }
            _iVisible = Visible;
            //str = WebContext.Server.HtmlEncode(str);
            if (_iVisible)
            {
                if (PutBR)
                {
                    if (str != null)
                    {
                        Text = StringUtils.PutBR(str);
                    }
                }
                else
                {
                    Text = str;
                }
            }
        }
Пример #4
0
        public override void DataBind()
        {
            if (_bound)
            {
                return;
            }
            _bound = true;
            DataRow memberRow = DataBinder.Eval(this.NamingContainer, "DataItem") as DataRow;

            if (memberRow == null)
            {
                DataRowView memberRowView = DataBinder.Eval(this.NamingContainer, "DataItem") as DataRowView;
                if (memberRowView != null)
                {
                    memberRow = memberRowView.Row;
                }
            }
            if (memberRow == null)
            {
                return;
            }

            int privacy = (int)memberRow["Privacy"];

            if (memberRow == null)
            {
                DataRowView drv = DataBinder.Eval(this.NamingContainer, "DataItem") as DataRowView;
                if (drv == null)
                {
                    ErrorContext.Add("invalid-dataitem", "Invalid Container for: " + Property);
                    this.Visible = false;
                    return;
                }
                memberRow = drv.Row;
            }
            object obj = null;

            if (memberRow.Table.Columns.Contains(Property))
            {
                obj = memberRow[Property];
            }

            PrivacySettingsManager psMgr = new PrivacySettingsManager();

            this.Visible = psMgr.CanAccess(memberRow, Property, this);

            if (!this.Visible)
            {
                return;
            }

            int MemberId = (int)memberRow["MemberId"];

            switch (Property)
            {
            /*case "Network":
             *      MemberNetworksManager nMgr = new MemberNetworksManager();
             *      IQueryable<MemberNetworksView> networks = nMgr.GetMemberNetworksView((int)memberRow["MemberId"]);
             *      if (networks.Count() > 0)
             *      {
             *              obj = networks.First().Name;
             *      }
             *      break;
             */
            case "Gender":
                if (memberRow["Gender"] != DBNull.Value && memberRow["Gender"] != null)
                {
                    Gender gender = (Gender)Enum.Parse(typeof(Gender), memberRow["Gender"].ToString());
                    obj = gender.ToString();
                }
                break;

            case "Email":
                break;

            case "StudentID":
                if (MemberId != WebContext.Profile.UserId)
                {
                    this.Visible = false;
                }
                break;

            default:
                break;
            }

            if (obj != null && obj.ToString().Trim() != "")
            {
                obj = string.Format(Format, obj);

                this.Text = StringUtils.AddSup(obj.ToString());
            }
            base.DataBind();

            _iVisible = this.Visible && !String.IsNullOrWhiteSpace(this.Text);
        }
Пример #5
0
        internal void bind()
        {
            if (_bound)
            {
                return;
            }

            PagesDataItem pagesDataItem = null;

            if (String.IsNullOrWhiteSpace(SourceId))
            {
                Control parent = this.Parent;
                while (parent != null)
                {
                    pagesDataItem = parent as PagesDataItem;
                    if (pagesDataItem != null)
                    {
                        break;
                    }
                    parent = parent.Parent;
                }
            }
            var       page       = Page as CustomPage;
            DataTable properties = null;

            if (pagesDataItem == null)
            {
                properties = page.PageContext[cte.PageProperties + "-" + SourceId] as DataTable;
            }
            else
            {
                properties = pagesDataItem.PageProperties;
            }

            if (properties != null)
            {
                try
                {
                    int pageId = (int)ControlUtils.GetBoundedDataField(NamingContainer, "PageId", false);

                    var dv = new DataView(properties, "PageId=" + pageId.ToString() + " and DataPropertyName='" + StringUtils.SQLEncode(Property) + "'", "", DataViewRowState.CurrentRows);
                    if (dv.Count > 0)
                    {
                        _dataObj = dv[0]["DataPropertyValue"];
                    }
                }
                catch
                {
                }
            }
            _bound = _dataObj != null;
            if (!_bound)
            {
                return;
            }
            if (!String.IsNullOrWhiteSpace(Class))
            {
                var obj = this as IAttributeAccessor;

                if (obj != null)
                {
                    obj.SetAttribute("class", Class);
                }
            }

            string str = "";

            if (_dataObj != DBNull.Value && _dataObj != null && _dataObj.ToString() != "")
            {
                str = string.Format(Format, _dataObj);
            }

            if (MaxCharacters > 0)
            {
                str = StringUtils.Trankate(StringUtils.StripOutHtmlTags(str), _maxCharacters, _closingSentence);
            }

            str = StringUtils.AddSup(str);
            str = StringUtils.ReplaceNbSup(str);
            str = StringUtils.ReplaceItalicSabis(str);

            if (!String.IsNullOrWhiteSpace(str) || Editable)
            {
                Visible = true;
            }
            else
            {
                Visible = false;
            }
            _iVisible = Visible;
            //str = WebContext.Server.HtmlEncode(str);
            if (_iVisible)
            {
                if (_putBr)
                {
                    if (str != null)
                    {
                        Text = StringUtils.PutBR(str);
                    }
                }
                else
                {
                    Text = str;
                }
            }
        }