Beispiel #1
0
    protected void Grid1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            var item = (PigeonCms.Item)e.Row.DataItem;

            if (item.IsThreadRoot)
                lastRowDataboundRoot = e.Row;
            else
            {
                if (lastRowDataboundRoot != null)
                    e.Row.RowState = lastRowDataboundRoot.RowState; //keeps same style of thread root
            }

            var LnkTitle = (LinkButton)e.Row.FindControl("LnkTitle");
            LnkTitle.Text = "<i class='fa fa-pgn_edit fa-fw'></i>";
            if (!item.IsThreadRoot)
                LnkTitle.Text += "--";
            LnkTitle.Text += Utility.Html.GetTextPreview(item.Title, 50, "");
            if (string.IsNullOrEmpty(item.Title))
                LnkTitle.Text += Utility.GetLabel("NO_VALUE", "<no value>");

            if (base.ShowSecurity && Roles.IsUserInRole("debug"))
                LnkTitle.Text += " ["+ item.Id.ToString() +"]";

            var LitItemInfo = (Literal)e.Row.FindControl("LitItemInfo");
            if (!string.IsNullOrEmpty(item.ExtId))
                LitItemInfo.Text += "extId: " + item.ExtId + "<br>";
            if (this.ShowType)
                LitItemInfo.Text += item.ItemTypeName + "<br>";
            if (!string.IsNullOrEmpty(item.CssClass))
                LitItemInfo.Text += "class: " + item.CssClass;

            if (item.CategoryId > 0)
            {
                var mgr = new CategoriesManager();
                var cat = mgr.GetByKey(item.CategoryId);
                var LitCategoryTitle = (Literal)e.Row.FindControl("LitCategoryTitle");
                LitCategoryTitle.Text = cat.Title;
            }

            if (item.Enabled)
            {
                var img1 = e.Row.FindControl("ImgEnabledOk");
                img1.Visible = true;
            }
            else
            {
                var img1 = e.Row.FindControl("ImgEnabledKo");
                img1.Visible = true;
            }

            //permissions
            var LitAccessTypeDesc = (Literal)e.Row.FindControl("LitAccessTypeDesc");
            LitAccessTypeDesc.Text = RenderAccessTypeSummary(item);

            //files upload
            var LnkUploadFiles = (HyperLink)e.Row.FindControl("LnkUploadFiles");
            LnkUploadFiles.NavigateUrl = this.FilesUploadUrl
                + "?type=items&id=" + item.Id.ToString();
            LnkUploadFiles.Visible = this.TargetFilesUpload > 0;
            if (this.IsMobileDevice == false)
                LnkUploadFiles.CssClass = "fancyRefresh";
            var LitFilesCount = (Literal)e.Row.FindControl("LitFilesCount");
            int filesCount = item.Files.Count;
            if (filesCount > 0)
            {
                LitFilesCount.Text = filesCount.ToString();
                LitFilesCount.Text += filesCount == 1 ? " file" : " files";
                LitFilesCount.Text += "<br />(" + Utility.GetFileHumanLength(item.FilesSize) + ")";
            }

            //images upload
            var LnkUploadImg = (HyperLink)e.Row.FindControl("LnkUploadImg");
            LnkUploadImg.NavigateUrl = this.ImagesUploadUrl
                + "?type=items&id=" + item.Id.ToString();
            LnkUploadImg.Visible = this.TargetImagesUpload > 0;
            if (this.IsMobileDevice == false)
                LnkUploadImg.CssClass = "fancyRefresh";
            var LitImgCount = (Literal)e.Row.FindControl("LitImgCount");
            int imgCount = item.Images.Count;
            if (imgCount > 0)
            {
                LitImgCount.Text = imgCount.ToString();
                LitImgCount.Text += imgCount == 1 ? " file" : " files";
                LitImgCount.Text += "<br />(" + Utility.GetFileHumanLength(item.ImagesSize) + ")";
            }
        }
    }
Beispiel #2
0
 /// <summary>
 /// parent category
 /// </summary>
 public Category Parent(CategoriesManager man)
 {
     if (parent == null)
     {
         parent = new Category();
         if (this.ParentId > 0)
             parent = man.GetByKey(this.ParentId);
     }
     return parent;
 }
Beispiel #3
0
    private bool checkFolderNameGrants(string type, string sId)
    {
        bool res = true;

        if (this.TypeParamRequired)
        {
            int id = 0;
            int.TryParse(sId, out id);

            if (string.IsNullOrEmpty(type))
                return false;

            if (id == 0 && type != "temp")
                return false;

            switch (type)
            {
                case "items":
                    {
                        var man = new ItemsManager<Item, ItemsFilter>(true, true);
                        var item = man.GetByKey(id);
                        if (item.Id == 0) res = false;
                    }
                    break;

                case "categories":
                    {
                        var man = new CategoriesManager(true, true);
                        var item = man.GetByKey(id);
                        if (item.Id == 0) res = false;
                    }
                    break;

                case "sections":
                    {
                        var man = new SectionsManager(true, true);
                        var item = man.GetByKey(id);
                        if (item.Id == 0) res = false;
                    }
                    break;

                case "temp":
                    res = this.AllowTemporaryFiles && sId == Utility._SessionID();
                    break;

                default:
                    res = false;
                    break;
            }
        }

        return res;
    }
Beispiel #4
0
    private void setFlag(int recordId, bool value, string flagName)
    {
        if (!this.AllowEdit)
            return;

        try
        {
            var man = new CategoriesManager(true, true);
            var o1 = man.GetByKey(recordId);
            if (o1.Id > 0)
            {
                switch (flagName.ToLower())
                {
                    case "enabled":
                        o1.Enabled = value;
                        break;
                    default:
                        break;
                }
                man.Update(o1);
            }
        }
        catch (Exception e1)
        {
            LblErr.Text = RenderError(Utility.GetLabel("RECORD_ERR_MSG") + "<br />" + e1.ToString());
        }
        finally { }
    }