Exemple #1
0
        public override void DataBind()
        {
            if (bound)
            {
                return;
            }
            bound = true;

            object link = DataBinder.Eval(NamingContainer, "DataItem.UniqueName");

            CustomPage page = this.Page as CustomPage;

            if (page != null)
            {
                if (page.GetQueryValue(lw.Downloads.cte.TypeQueryStringName) == link.ToString())
                {
                    this.Attributes["class"] = SelectedClass;
                }
            }


            this.HRef = string.Format("{3}/{0}{1}{2}",
                                      !String.IsNullOrWhiteSpace(path)? path + "/": "",
                                      link,
                                      Extension,
                                      WebContext.Root
                                      );

            string text = DataBinder.Eval(NamingContainer, "DataItem.Type").ToString();

            this.Title = text;

            if (this.Controls.Count == 0)
            {
                this.InnerHtml = text;
            }

            base.DataBind();
        }
Exemple #2
0
        public override void DataBind()
        {
            if (this._bound)
            {
                return;
            }
            _bound = true;

            _page = this.Page as CustomPage;

            int    _itemId = -1;
            object obj     = DataBinder.Eval(this.NamingContainer, "DataItem");

            DataRowView _PhotoAlbumDetails = obj as DataRowView;
            DataRow     _PhotoAlbum        = null;

            if (_PhotoAlbumDetails != null)
            {
                _PhotoAlbum = _PhotoAlbumDetails.Row;
            }
            else
            {
                _PhotoAlbum = obj as DataRow;
            }

            string text = "";

            if (_PhotoAlbum == null)
            {
                obj = DataBinder.Eval(this.NamingContainer, "DataItem.Id");
                if (!String.IsNullOrEmpty(obj.ToString()))
                {
                    _itemId = (int)obj;
                }
                else
                {
                    return;
                }

                DataView dv;

                if (CategoryId > 0)
                {
                    dv = pMgr.GetAllPhotoAlbums(string.Format("id={0} and UniqueName='{1}'", _itemId, Category));
                }
                else
                {
                    dv = pMgr.GetPhotoAlbums(string.Format("id={0}", _itemId));
                }

                if (dv != null && dv.Count > 0)
                {
                    _PhotoAlbum = dv[0].Row;
                }
            }

            if (_PhotoAlbum == null)
            {
                return;
            }

            text = _PhotoAlbum["DisplayName"].ToString();


            switch (Type)
            {
            case PhotoAlbumsLinkType.ArchiveByType:
                text      = (string)_PhotoAlbum["CategoryName"];
                this.HRef = string.Format("{2}/{0}/{1}{3}",
                                          Path == "" ? "photo-gallery" : Path,
                                          _PhotoAlbum["UniqueName"],
                                          WebContext.Root,
                                          Extension
                                          );
                break;

            case PhotoAlbumsLinkType.AlbumId:
                if (IncludePhotoAlbumsPath)
                {
                    this.HRef = string.Format("{3}/{0}{1}/{2}{4}",
                                              Path == null ? "" : Path + "/",
                                              _PhotoAlbum["Name"],
                                              _PhotoAlbum["Id"],
                                              WebContext.Root, Extension
                                              );
                }
                else
                {
                    this.HRef = string.Format("{2}/{0}{1}{3}",
                                              Path == null ? "" : Path + "/",
                                              _PhotoAlbum["Id"],
                                              WebContext.Root, Extension
                                              );
                }
                break;

            case PhotoAlbumsLinkType.Photos:
                string _network = _page.GetQueryValue(RoutingParameters.Network);
                if (!String.IsNullOrWhiteSpace(_network))
                {
                    if (IncludePhotoAlbumsPath)
                    {
                        this.HRef = string.Format("{3}/{0}/{1}/{2}{4}",
                                                  Path == "" ? _network + "/photo-gallery" : Path,
                                                  _PhotoAlbum["UniqueName"],
                                                  _PhotoAlbum["Name"],
                                                  WebContext.Root, Extension
                                                  );
                    }
                    else
                    {
                        this.HRef = string.Format("{2}/{0}/{1}{3}",
                                                  Path == "" ? _network + "/photo-gallery" : Path,
                                                  _PhotoAlbum["Name"],
                                                  WebContext.Root, Extension
                                                  );
                    }
                }
                else
                {
                    if (IncludePhotoAlbumsPath)
                    {
                        this.HRef = string.Format("{3}/{0}/{1}/{2}{4}",
                                                  Path == "" ? "photo-gallery" : Path,
                                                  _PhotoAlbum["UniqueName"],
                                                  _PhotoAlbum["Name"],
                                                  WebContext.Root, Extension
                                                  );
                    }
                    else
                    {
                        this.HRef = string.Format("{2}/{0}/{1}{3}",
                                                  Path == "" ? "photo-gallery" : Path,
                                                  _PhotoAlbum["Name"],
                                                  WebContext.Root, Extension
                                                  );
                    }
                }
                break;

            default:
                if (IncludePhotoAlbumsPath)
                {
                    this.HRef = string.Format("{3}/{0}/{1}/{2}{4}",
                                              Path == "" ? "photo-gallery" : Path,
                                              _PhotoAlbum["UniqueName"],
                                              _PhotoAlbum["Name"],
                                              WebContext.Root, Extension
                                              );
                }
                else
                {
                    this.HRef = string.Format("{2}/{0}/{1}{3}",
                                              Path == "" ? "photo-gallery" : Path,
                                              _PhotoAlbum["Name"],
                                              WebContext.Root, Extension
                                              );
                }
                break;
            }
            if (this.Controls.Count == 0)
            {
                this.InnerHtml = lw.Utils.StringUtils.AddSup(string.Format(Format, text));
            }

            base.DataBind();
            this.Attributes.Add("title", string.Format(Format, text));

            if (MyPage.Editable && ImEditable)
            {
                this.Attributes.Add("data-editable", "true");
                this.Attributes.Add("data-id", _PhotoAlbum["Id"].ToString());
                this.Attributes.Add("data-type", "photoalbums");
            }
        }
        public override void DataBind()
        {
            if (bound)
            {
                return;
            }
            bound = true;

            _page = this.Page as CustomPage;

            StringBuilder cond = new StringBuilder();
            NewsManager   nMgr = new NewsManager();


            if (Type == "")
            {
                Type = _page.GetQueryValue("NewsType");
            }

            if (!StringUtils.IsNullOrWhiteSpace(Type))
            {
                DataView types = nMgr.GetNewsTypes(string.Format("UniqueName='{0}'", StringUtils.SQLEncode(Type)));
                if (types.Count > 0)
                {
                    cond.Append(string.Format(" And NewsType={0}", types[0]["TypeId"]));
                }
            }

            CustomPage cPage = this.Page as CustomPage;

            if (_Language == null)
            {
                if (cPage != null)
                {
                    Language = cPage.Language;
                }
            }

            switch (Language)
            {
            case Languages.French:
                setLanguage = "SET LANGUAGE French;";
                break;

            default:
                break;
            }

            if (Language != Languages.Default)
            {
                cond.Append(string.Format(" And NewsLanguage={0}", (int)Language));
            }

            string sql = "";

            if (cond.Length > 0)
            {
                sql = cond.ToString().Substring(5);
            }

            this.SelectCommand = string.Format("{0} SELECT * FROM NewsDateView WHERE {1}", setLanguage, sql);


            if (!EnablePaging)
            {
                this.SelectCommand += " Order By " + this.OrderBy;
            }

            base.DataBind();
        }