Example #1
0
 private List<FileCategory> getRootList() {
     List<FileCategory> list = FileCategory.GetRootList();
     FileCategory f = new FileCategory {
         Id = 0, Name = lang( "plsSelect" )
     };
     list.Insert( 0, f );
     return list;
 }
        private void bindSubCats( IBlock block, FileCategory cat ) {
            IBlock subBlock = block.GetBlock( "subcat" );
            List<FileCategory> subcats = FileCategory.GetByParentId( cat.Id );
            foreach (FileCategory subcat in subcats) {

                subBlock.Set( "subcat.Name", subcat.Name );
                subBlock.Set( "subcat.Link", to( new CategoryController().Show, subcat.Id ) );
                subBlock.Next();

            }
        }
        private void bindSubCats( IBlock block, FileCategory cat ) {
            IBlock subBlock = block.GetBlock( "subcat" );
            List<FileCategory> subcats = FileCategory.GetByParentId( cat.Id );
            foreach (FileCategory subcat in subcats) {

                subBlock.Set( "subcat.ThumbIcon", subcat.ThumbIcon );
                subBlock.Set( "subcat.Name", subcat.Name );
                subBlock.Set( "subcat.Link", to( Edit, subcat.Id ) );
                subBlock.Next();
            }
        }
        public virtual void Create() {
            string name = ctx.Post( "Name" );
            if (strUtil.IsNullOrEmpty( name )) {
                echoError( "请填写名称" );
                return;
            }

            FileCategory cat = new FileCategory();
            cat.Name = name;
            cat.IsThumbView = ctx.PostIsCheck( "IsThumbView" );
            cat.insert();

            echoToParentPart( lang( "opok" ) );
        }
Example #5
0
        public static String GetSubCategories( MvcContext ctx, FileCategory c )
        {
            int rootId = c.Id;
            if (c.ParentId > 0) rootId = c.ParentId;

            StringBuilder sb = new StringBuilder();

            List<FileCategory> subs = FileCategory.GetByParentId( rootId );
            foreach (FileCategory sub in subs) {

                sb.AppendFormat( "<a href=\"{0}\">{1}</a> ", ctx.link.To( new CategoryController().Show, sub.Id ), sub.Name );

            }

            return sb.ToString();
        }
        public void Create()
        {
            string name = ctx.Post( "Name" );
            if (strUtil.IsNullOrEmpty( name )) {
                errors.Add( "�������" );
                run( Add );
                return;
            }

            FileCategory cat = new FileCategory();
            cat.Name = name;
            cat.IsThumbView = ctx.PostIsCheck( "IsThumbView" );
            cat.insert();

            echoRedirect( lang( "opok" ), List );
        }
Example #7
0
        public int CompareTo(object obj)
        {
            FileCategory t = obj as FileCategory;

            if (this.OrderId > t.OrderId)
            {
                return(-1);
            }
            if (this.OrderId < t.OrderId)
            {
                return(1);
            }
            if (this.Id > t.Id)
            {
                return(1);
            }
            if (this.Id < t.Id)
            {
                return(-1);
            }
            return(0);
        }
Example #8
0
        public static DataPage <FileItem> GetPage(int appId, int categoryId)
        {
            FileCategory c = FileCategory.GetById(categoryId);

            if (c.ParentId == 0)
            {
                List <FileCategory> list = FileCategory.GetByParentId(c.Id);
                String ids = "";
                for (int i = 0; i < list.Count; i++)
                {
                    ids += list[i].Id;
                    if (i < list.Count - 1)
                    {
                        ids += ",";
                    }
                }

                return(FileItem.findPage("AppId=" + appId + " and CategoryId in (" + ids + ")"));
            }
            else
            {
                return(FileItem.findPage("AppId=" + appId + " and CategoryId=" + categoryId));
            }
        }
Example #9
0
        private void bindSubCatsFiles( IBlock block, FileCategory cat )
        {
            IBlock subBlock = block.GetBlock( "subcat" );
            List<FileCategory> subcats = FileCategory.GetByParentId( cat.Id );
            foreach (FileCategory subcat in subcats) {

                subBlock.Set( "subcat.ThumbIcon", subcat.ThumbIcon );
                subBlock.Set( "subcat.Name", subcat.Name );
                subBlock.Set( "subcat.DataCount", subcat.DataCount );
                subBlock.Set( "subcat.Link", to( new FileController().Category, subcat.Id ) );
                subBlock.Next();
            }
        }
Example #10
0
        public static long GetParentId(long id)
        {
            FileCategory c = cdb.findById <FileCategory>(id);

            return(c.ParentId);
        }
Example #11
0
        public static string GetParentName(long id)
        {
            FileCategory c = cdb.findById <FileCategory>(id);

            return(cdb.findById <FileCategory>(c.ParentId).Name);
        }
Example #12
0
 private static String getCatLink( MvcContext ctx, FileCategory cat )
 {
     String catLink = string.Format( "<a href=\"{0}\">{1}</a>", ctx.link.To( new CategoryController().Show, cat.Id ), cat.Name );
     return catLink;
 }
Example #13
0
        public static int GetParentId(int id)
        {
            FileCategory c = cdb.findById <FileCategory>(id);

            return(c.ParentId);
        }