public virtual void Show(long id)
        {
            FileCategory c = FileCategory.GetById(id);

            if (c == null)
            {
                echo(lang("exDataNotFound"));
                return;
            }

            ctx.Page.Title = c.Name;


            load("sidebar", new DownloadController().sidebar);

            set("location", Location.GetCategory(ctx, c.Id));

            set("categories", Location.GetSubCategories(ctx, c));

            DataPage <FileItem> list = FileItem.GetPage(ctx.app.Id, c.Id);

            ctx.SetItem("list", list);
            ctx.SetItem("category", c);
            load("list", List);
        }
Exemple #2
0
        public void Show(int id)
        {
            FileItem f = FileItem.findById(id);

            if (f == null)
            {
                echo(lang("exDataNotFound"));
                return;
            }

            ctx.Page.Title = f.Title;


            bind("f", f);
            bindTopList(f.CategoryId);

            set("location", Location.GetFile(ctx, f));
            set("categories", Location.GetSubCategories(ctx, FileCategory.GetById(f.CategoryId)));

            String url = to(Download, id) + "?url=";

            String link1 = "";
            String link2 = "";
            String link3 = "";

            if (strUtil.HasText(f.Url))
            {
                link1 = string.Format("<a href=\"{0}\">下载网址1</a>", url + 1);
            }
            if (strUtil.HasText(f.Url2))
            {
                link2 = string.Format("<a href=\"{0}\">下载网址2</a>", url + 2);
            }
            if (strUtil.HasText(f.Url3))
            {
                link3 = string.Format("<a href=\"{0}\">下载网址3</a>", url + 3);
            }


            set("downloadLink1", link1);
            set("downloadLink2", link2);
            set("downloadLink3", link3);

            String previewPic = "";

            if (f.HasPreviewPic())
            {
                previewPic = string.Format("<br /><img src=\"{0}\" />", f.PreviewPicMedium);
            }
            set("previewPic", previewPic);


            bindComment(f);

            FileItem.AddHits(f);
        }
        public void Delete(int id)
        {
            FileCategory f = FileCategory.GetById(id);

            if (f != null)
            {
                f.delete();
                redirect(List);
            }
        }
        public virtual void Delete(long id)
        {
            FileCategory cat = FileCategory.GetById(id);

            if (cat != null)
            {
                cat.delete();
                redirect(List);
            }
        }
Exemple #5
0
        public static String GetCategory(MvcContext ctx, long categoryId)
        {
            FileCategory cat = FileCategory.GetById(categoryId);

            if (cat.ParentId == 0)
            {
                return(getCatLink(ctx, cat));
            }
            else
            {
                FileCategory parent = FileCategory.GetById(cat.ParentId);
                return(getCatLink(ctx, parent) + " " + separator + " " + getCatLink(ctx, cat));
            }
        }
        public virtual void Edit(long id)
        {
            target(Update, id);

            FileCategory cat = FileCategory.GetById(id);

            set("Name", cat.Name);

            String chkstr = "";

            if (cat.IsThumbView == 1)
            {
                chkstr = "checked=\"checked\"";
            }
            set("checked", chkstr);
        }
        public void Update(int id)
        {
            FileCategory c = FileCategory.GetById(id);

            FileCategory cat = ctx.PostValue(c) as FileCategory;

            if (ctx.HasErrors)
            {
                run(Edit, id);
                return;
            }
            cat.IsThumbView = ctx.PostIsCheck("fileCategory.IsThumbView");


            cat.update();
            echoRedirect(lang("opok"), List);
        }
        public void Update(int id)
        {
            FileCategory c = FileCategory.GetById(id);

            FileCategory cat = ctx.PostValue(c) as FileCategory;

            if (strUtil.IsNullOrEmpty(cat.Name))
            {
                echoError("请填写名称");
                return;
            }

            cat.IsThumbView = ctx.PostIsCheck("fileCategory.IsThumbView");

            cat.update();
            echoToParentPart(lang("opok"));
        }
        public virtual void Update(long id)
        {
            string name = ctx.Post("Name");

            if (strUtil.IsNullOrEmpty(name))
            {
                echoError("请填写名称");
                return;
            }

            FileCategory cat = FileCategory.GetById(id);

            cat.Name        = name;
            cat.IsThumbView = ctx.PostIsCheck("IsThumbView");
            cat.update();

            echoToParentPart(lang("opok"));
        }
        public void Edit(int id)
        {
            FileCategory cat = FileCategory.GetById(id);

            bind(cat);

            List <FileCategory> cats = FileCategory.GetRootList();

            dropList("fileCategory.ParentId", cats, "Name=Id", cat.ParentId);
            target(Update, id);

            String chkstr = "";

            if (cat.IsThumbView == 1)
            {
                chkstr = "checked=\"checked\"";
            }
            set("checked", chkstr);
        }
        public void Category(int id)
        {
            FileCategory cat = FileCategory.GetById(id);

            if (cat.IsThumbView == 1)
            {
                view("ThumbList");
            }
            else
            {
                view("List");
            }
            set("addLink", to(Add));

            DataPage <FileItem> pages = FileItem.GetPage(ctx.app.Id, id);

            bindList("list", "data", pages.Results, bindLink);
            set("page", pages.PageBar);
        }
Exemple #12
0
        public void Update(int id)
        {
            string name = ctx.Post("Name");

            if (strUtil.IsNullOrEmpty(name))
            {
                errors.Add("ÇëÌîдÃû³Æ");
                run(Edit, id);
                return;
            }

            FileCategory cat = FileCategory.GetById(id);

            cat.Name        = name;
            cat.IsThumbView = ctx.PostIsCheck("IsThumbView");
            cat.update();

            echoRedirect(lang("opok"), List);
        }
Exemple #13
0
        public virtual void Category(long id)
        {
            FileCategory cat = FileCategory.GetById(id);

            if (cat.IsThumbView == 1)
            {
                view("ThumbList");
            }
            else
            {
                view("List");
            }
            set("addLink", to(Add));
            set("lnkCateShow", to(new Admin.SubCategoryController().Files));

            DataPage <FileItem> pages = FileItem.GetPage(ctx.app.Id, id);

            bindList("list", "data", pages.Results, bindLink);
            set("page", pages.PageBar);
        }
        public void ListSub(int id)
        {
            FileCategory cat = FileCategory.GetById(id);

            set("cat.Name", cat.Name);
            set("addLink", to(Add, id));
            set("sortAction", to(SaveSort, id));

            IBlock block = getBlock("list");
            List <FileCategory> subcats = FileCategory.GetByParentId(cat.Id);

            foreach (FileCategory subcat in subcats)
            {
                block.Set("data.ThumbIcon", subcat.ThumbIcon);
                block.Set("data.Id", subcat.Id);
                block.Set("data.Name", subcat.Name);
                block.Set("data.LinkEdit", to(Edit, subcat.Id));
                block.Set("data.LinkDelete", to(Delete, subcat.Id));
                block.Next();
            }
        }
        public virtual void SaveSort(int parentId)
        {
            int    id  = ctx.PostInt("id");
            String cmd = ctx.Post("cmd");

            FileCategory acategory = FileCategory.GetById(id);

            List <FileCategory> list = FileCategory.GetByParentId(parentId);

            if (cmd == "up")
            {
                new SortUtil <FileCategory>(acategory, list).MoveUp();
                echoRedirect("ok");
            }
            else if (cmd == "down")
            {
                new SortUtil <FileCategory>(acategory, list).MoveDown();
                echoRedirect("ok");
            }
            else
            {
                echoError(lang("exUnknowCmd"));
            }
        }