mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	Rename ctx.Form() to ctx.FormString() and move code into own file (#16571)
Followup from #16562 prepare for #16567 * Rename ctx.Form() to ctx.FormString() * Reimplement FormX func to need less code and cpu cycles * Move code into own file
This commit is contained in:
		| @@ -157,7 +157,7 @@ func Dashboard(ctx *context.Context) { | ||||
| 		IncludePrivate:  true, | ||||
| 		OnlyPerformedBy: false, | ||||
| 		IncludeDeleted:  false, | ||||
| 		Date:            ctx.Form("date"), | ||||
| 		Date:            ctx.FormString("date"), | ||||
| 	}) | ||||
|  | ||||
| 	if ctx.Written() { | ||||
| @@ -200,11 +200,11 @@ func Milestones(ctx *context.Context) { | ||||
| 		repoCond     = userRepoCond | ||||
| 		repoIDs      []int64 | ||||
|  | ||||
| 		reposQuery   = ctx.Form("repos") | ||||
| 		isShowClosed = ctx.Form("state") == "closed" | ||||
| 		sortType     = ctx.Form("sort") | ||||
| 		reposQuery   = ctx.FormString("repos") | ||||
| 		isShowClosed = ctx.FormString("state") == "closed" | ||||
| 		sortType     = ctx.FormString("sort") | ||||
| 		page         = ctx.FormInt("page") | ||||
| 		keyword      = strings.Trim(ctx.Form("q"), " ") | ||||
| 		keyword      = strings.Trim(ctx.FormString("q"), " ") | ||||
| 	) | ||||
|  | ||||
| 	if page <= 1 { | ||||
| @@ -380,7 +380,7 @@ func buildIssueOverview(ctx *context.Context, unitType models.UnitType) { | ||||
|  | ||||
| 	var ( | ||||
| 		viewType   string | ||||
| 		sortType   = ctx.Form("sort") | ||||
| 		sortType   = ctx.FormString("sort") | ||||
| 		filterMode = models.FilterModeAll | ||||
| 	) | ||||
|  | ||||
| @@ -390,14 +390,14 @@ func buildIssueOverview(ctx *context.Context, unitType models.UnitType) { | ||||
| 	// - Remember pre-determined viewType string for later. Will be posted to ctx.Data. | ||||
| 	//   Organization does not have view type and filter mode. | ||||
| 	// User: | ||||
| 	// - Use ctx.Form("type") to determine filterMode. | ||||
| 	// - Use ctx.FormString("type") to determine filterMode. | ||||
| 	//  The type is set when clicking for example "assigned to me" on the overview page. | ||||
| 	// - Remember either this or a fallback. Will be posted to ctx.Data. | ||||
| 	// -------------------------------------------------------------------------------- | ||||
|  | ||||
| 	// TODO: distinguish during routing | ||||
|  | ||||
| 	viewType = ctx.Form("type") | ||||
| 	viewType = ctx.FormString("type") | ||||
| 	switch viewType { | ||||
| 	case "assigned": | ||||
| 		filterMode = models.FilterModeAssign | ||||
| @@ -456,7 +456,7 @@ func buildIssueOverview(ctx *context.Context, unitType models.UnitType) { | ||||
| 	} | ||||
|  | ||||
| 	// keyword holds the search term entered into the search field. | ||||
| 	keyword := strings.Trim(ctx.Form("q"), " ") | ||||
| 	keyword := strings.Trim(ctx.FormString("q"), " ") | ||||
| 	ctx.Data["Keyword"] = keyword | ||||
|  | ||||
| 	// Execute keyword search for issues. | ||||
| @@ -477,7 +477,7 @@ func buildIssueOverview(ctx *context.Context, unitType models.UnitType) { | ||||
| 	} | ||||
|  | ||||
| 	// Educated guess: Do or don't show closed issues. | ||||
| 	isShowClosed := ctx.Form("state") == "closed" | ||||
| 	isShowClosed := ctx.FormString("state") == "closed" | ||||
| 	opts.IsClosed = util.OptionalBoolOf(isShowClosed) | ||||
|  | ||||
| 	// Filter repos and count issues in them. Count will be used later. | ||||
| @@ -502,7 +502,7 @@ func buildIssueOverview(ctx *context.Context, unitType models.UnitType) { | ||||
| 	// Get IDs for labels (a filter option for issues/pulls). | ||||
| 	// Required for IssuesOptions. | ||||
| 	var labelIDs []int64 | ||||
| 	selectedLabels := ctx.Form("labels") | ||||
| 	selectedLabels := ctx.FormString("labels") | ||||
| 	if len(selectedLabels) > 0 && selectedLabels != "0" { | ||||
| 		labelIDs, err = base.StringsToInt64s(strings.Split(selectedLabels, ",")) | ||||
| 		if err != nil { | ||||
| @@ -512,9 +512,9 @@ func buildIssueOverview(ctx *context.Context, unitType models.UnitType) { | ||||
| 	} | ||||
| 	opts.LabelIDs = labelIDs | ||||
|  | ||||
| 	// Parse ctx.Form("repos") and remember matched repo IDs for later. | ||||
| 	// Parse ctx.FormString("repos") and remember matched repo IDs for later. | ||||
| 	// Gets set when clicking filters on the issues overview page. | ||||
| 	repoIDs := getRepoIDs(ctx.Form("repos")) | ||||
| 	repoIDs := getRepoIDs(ctx.FormString("repos")) | ||||
| 	if len(repoIDs) > 0 { | ||||
| 		opts.RepoIDs = repoIDs | ||||
| 	} | ||||
| @@ -658,7 +658,7 @@ func buildIssueOverview(ctx *context.Context, unitType models.UnitType) { | ||||
| 	ctx.Data["IsShowClosed"] = isShowClosed | ||||
|  | ||||
| 	ctx.Data["IssueRefEndNames"], ctx.Data["IssueRefURLs"] = | ||||
| 		issue_service.GetRefEndNamesAndURLs(issues, ctx.Form("RepoLink")) | ||||
| 		issue_service.GetRefEndNamesAndURLs(issues, ctx.FormString("RepoLink")) | ||||
|  | ||||
| 	ctx.Data["Issues"] = issues | ||||
|  | ||||
| @@ -900,7 +900,7 @@ func ShowGPGKeys(ctx *context.Context, uid int64) { | ||||
|  | ||||
| // Email2User show user page via email | ||||
| func Email2User(ctx *context.Context) { | ||||
| 	u, err := models.GetUserByEmail(ctx.Form("email")) | ||||
| 	u, err := models.GetUserByEmail(ctx.FormString("email")) | ||||
| 	if err != nil { | ||||
| 		if models.IsErrUserNotExist(err) { | ||||
| 			ctx.NotFound("GetUserByEmail", err) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user