示例#1
0
func (controller *Module) loadModule() {
	ID := controller.Ctx.Input.Param(":module")
	module, err := repository.NewModule(ID)
	if err == nil {
		controller.Data["module"] = module
		controller.module = module
	}
}
示例#2
0
// DisplayResource shows the page for the resource
func (controller *Repository) DisplayResource() {
	resourceID := controller.Ctx.Input.Param(":resource")
	repo := controller.GetRepository()
	resource, errResource := wisply.GetRecordByID(resourceID)

	if errResource != nil {
		controller.Abort("show-database-error")
	} else {
		moduleID := wisply.DetectModule(resource.Identifier)
		module, err := repository.NewModule(strconv.Itoa(moduleID))
		if err == nil {
			controller.Data["module"] = module
			controller.Data["resourcesSuggested"] = wisply.SuggestResourcesForModule(module.GetID())
		}
		controller.Data["repository"] = repo
		controller.Data["institution"] = repo.GetInstitution()
		controller.Data["resource"] = resource
		controller.LoadTemplate("resource")
	}
}
示例#3
0
// gets the modules
func (search ModuleSearch) getFromDB() []repository.Module {
	var list []repository.Module

	limitClause := search.options.GetLimit()
	fieldsList := "`id`"
	whereClause := "WHERE `title` LIKE ? OR `code` LIKE ?"
	sql := "SELECT DISTINCT " + fieldsList + " FROM `institution_module` " + whereClause + space + limitClause

	rows, err := database.Connection.Query(sql, search.likeQuery(), search.likeQuery())

	if err != nil {
		fmt.Println(err)
	}
	for rows.Next() {
		moduleID := ""
		rows.Scan(&moduleID)
		item, _ := repository.NewModule(moduleID)
		list = append(list, item)
	}
	return list
}