Ejemplo n.º 1
0
//修改文章栏目页面
func (c *CategoryController) Edit() {
	CheckAdminLogin(&c.Controller, 0)
	myid := c.Ctx.Input.Param(":id")
	id, err := strconv.ParseInt(myid, 10, 64)
	if err != nil {
		EchoErrorPage(&c.Controller, "错误参数传递!", "/admin/category")
	}
	entity := models.GetCategory(id)
	if entity == nil {
		EchoErrorPage(&c.Controller, "系统找不到本记录!", "/admin/category")
	}
	//获取所有上级栏目
	PCategories := models.GetCategoryTree(0, -1, true, entity.Id)
	//获取模板目录
	skin := "default"
	templatesList, err := common.GetFolderFiles("views/"+skin, "")
	if err != nil {
		templatesList = nil
	}
	c.Data["Title"] = "修改栏目"
	c.Data["Entity"] = entity
	c.Data["Action"] = "edit"
	c.Data["TemplatesList"] = templatesList
	c.Data["PCategories"] = PCategories
	c.TplNames = "admin/category_add.tpl"
}
Ejemplo n.º 2
0
//显示列表
func (c *CategoryController) List() {
	//显示栏目列表
	CheckAdminLogin(&c.Controller, 0)
	categories := models.GetCategoryTree(0, -1, false, 0)
	c.Data["List"] = categories
	c.Data["Title"] = "栏目列表"
	c.TplNames = "admin/category.tpl"
}
Ejemplo n.º 3
0
//添加文章页面
func (c *ArticleController) Add() {
	CheckAdminLogin(&c.Controller, 0)
	//添加的时候,先初始化一个实体
	entity := &models.Article{}
	entity.Id = 0
	entity.Created = time.Now()
	entity.Rank = 999
	//获取所有栏目
	Categories := models.GetCategoryTree(0, -1, true, 0)
	c.Data["Title"] = "添加文章"
	c.Data["Action"] = "add"
	c.Data["Entity"] = entity
	c.Data["Categories"] = Categories
	c.TplNames = "admin/article_add.tpl"
}
Ejemplo n.º 4
0
//编辑文章页面
func (c *ArticleController) Edit() {
	CheckAdminLogin(&c.Controller, 0)

	myid := c.Ctx.Input.Param(":id")
	id, err := strconv.ParseInt(myid, 10, 64)
	if err != nil {
		EchoErrorPage(&c.Controller, "错误参数传递!", "/admin/category")
	}
	entity := models.GetArticle(id)
	if entity == nil {
		EchoErrorPage(&c.Controller, "系统找不到本记录!", "/admin/category")
	}
	//获取所有栏目
	Categories := models.GetCategoryTree(0, -1, true, 0)
	c.Data["Title"] = "修改文章"
	c.Data["Action"] = "edit"
	c.Data["Entity"] = entity
	c.Data["Categories"] = Categories
	c.TplNames = "admin/article_add.tpl"
}
Ejemplo n.º 5
0
//显示添加文章栏目
func (c *CategoryController) Add() {
	CheckAdminLogin(&c.Controller, 0)
	//添加的时候,先初始化一个实体
	entity := &models.Category{}
	entity.Id = 0
	entity.PageSize = 15
	entity.Rank = 0
	entity.DetailTemplateFile = "article.tpl"
	entity.TemplateFile = "list_article.tpl"
	//获取所有上级栏目
	PCategories := models.GetCategoryTree(0, -1, true, 0)
	//获取模板目录
	skin := "default"
	templatesList, err := common.GetFolderFiles("views/"+skin, "")
	if err != nil {
		templatesList = nil
	}
	c.Data["Title"] = "添加栏目"
	c.Data["Action"] = "add"
	c.Data["Entity"] = entity
	c.Data["TemplatesList"] = templatesList
	c.Data["PCategories"] = PCategories
	c.TplNames = "admin/category_add.tpl"
}