Documentation
¶
Index ¶
- Constants
- func DateValueOf(ctx context.Context, field entity.FieldInstanceDef, in DateInput, ...) (entity.DateValue, bool, string)
- func ParseIDList(raw string) []int
- func ParseLinkRows(r *http.Request, fieldID int) []entity.Link
- func TagSpecifications(tags []TagInput) []entity.TagSpecification
- type BlockInput
- type DateInput
- type DynamicForm
- func (f *DynamicForm) ParseDynamicForm(r *http.Request, fieldIDs []int) (*DynamicForm, error)
- func (f *DynamicForm) Validate(ctx context.Context, fields entity.FieldInstanceDefs) map[string]string
- func (f *DynamicForm) ValidateFields(ctx context.Context, fields entity.FieldInstanceDefs) map[string]string
- type NodeMetaFields
- type TagInput
Constants ¶
const ( MetaTitleMaxLen = 200 MetaDescriptionMaxLen = entity.MaxMetaDesc )
The longest meta title and meta description, in characters, that a node form keeps (ParseNodeMeta cuts the rest).
Variables ¶
This section is empty.
Functions ¶
func DateValueOf ¶
func DateValueOf(ctx context.Context, field entity.FieldInstanceDef, in DateInput, zone *time.Location) (entity.DateValue, bool, string)
DateValueOf - the value of a date field's inputs in (times in zone): false - none (no start); a message - what's wrong ("" - nothing). A part the field doesn't have is ignored; an end time without an end date ends on the start's day. A plain field's (no time, no end) - its date.
func ParseIDList ¶
ParseIDList - the positive IDs of a comma-separated list (a picker's hidden input), in order, each once.
func ParseLinkRows ¶
ParseLinkRows - the links of a link field's rows as submitted: field_<id>_url and field_<id>_title, one pair per row in the form's order (the order saved). A row without an address and a title is left out; an address without a scheme gets https://.
func TagSpecifications ¶
func TagSpecifications(tags []TagInput) []entity.TagSpecification
TagSpecifications converts parsed Tagify TagInput values into entity.TagSpecification, ready for TaxonomyService.ProcessTagInputs. Shared by every content type's own tag-saving path (saveContentTaxonomy) and by DynamicContentController's multi-value taxonomy fields.
Types ¶
type BlockInput ¶
type BlockInput struct {
Key string
Item entity.BlockItem
Form *DynamicForm
}
BlockInput - a block of a blocks field as submitted: its key in the form (its inputs' names' part), its item (its values resolved) and its own form (shown again: its links and dates as sent).
type DateInput ¶
type DateInput struct {
Date, Time, EndDate, EndTime string
}
DateInput - the inputs of a date field with a time or an end (entity.FieldInstanceDef.DateRich) in the content form: the start's date and time, the end's ("" - empty).
func DateInputOf ¶
DateInputOf - the inputs of value d, its times in zone.
func ParseDateInput ¶
ParseDateInput - a date field's inputs as submitted: field_<id> (the start's date), field_<id>_time, field_<id>_end, field_<id>_end_time.
func ParseDateInputs ¶
func ParseDateInputs(r *http.Request, field entity.FieldInstanceDef) []DateInput
ParseDateInputs - the rows of a date field with several dates as submitted: the same inputs as ParseDateInput, one of each per row in the form's order (the parts the field has); an empty row left out.
type DynamicForm ¶
type DynamicForm struct {
NodeMetaFields
NodeID int
Title string
Slug string
// PathAuto - "generate the URL alias automatically" (path_auto);
// PathAutoShown - the form had that checkbox (path_auto_shown: the
// URL settings are shown only to who may change them), else the node
// keeps its own setting.
PathAuto bool
PathAutoShown bool
// Promote/Sticky - "on the front page", "at the top of lists";
// NodeFlagsShown - the form had them (node_flags_shown) and its user
// may set them (DynamicContentController checks), else the node keeps
// its own (a new one: its type's defaults).
Promote bool
Sticky bool
NodeFlagsShown bool
// Status/OnModeration - published, on moderation; taken from the form
// only when SettingsAllowed.
Status int
OnModeration int
// SettingsAllowed - the editor may administer content, so the
// publishing (Status, OnModeration), the author and the date come
// from the form; set by DynamicContentController, never by the
// request. Without it a new node gets its type's DefaultPublishing,
// an edited one keeps its own.
SettingsAllowed bool
// WorkflowManaged - a module's workflow publishes the type's items
// (interfaces.NodeWorkflow): the publishing and the schedule aren't
// the form's; set by DynamicContentController, never by the request.
WorkflowManaged bool
FieldValues map[int]string
// FieldLinks - the link fields' links (FieldTypeLink, ParseLinkRows;
// a hidden field's carried forward), keyed by FieldInstanceDef.ID.
FieldLinks map[int][]entity.Link
// FieldDates - the values of the date fields with a time, an end or
// several dates (DateRich, DateList; DateValueOf, a hidden field's
// carried forward; one value - one item) and FieldDateErrors what's
// wrong with their inputs, keyed by FieldInstanceDef.ID; DateInputs -
// those inputs as sent (the form shown again).
FieldDates map[int][]entity.DateValue
FieldDateErrors map[int]string
DateInputs map[int][]DateInput
// TextFormatValues - validated per-field text format choice, keyed by
// FieldInstanceDef.ID; set by resolveTextFormat
// only for fields with AllowedTextFormatIDs().
TextFormatValues map[int]entity.TextFormatDef
// CreatedByID/CreatedAt - author and date overrides (the edit form,
// SettingsAllowed only). Zero value means "not submitted"; the
// existing node's values are kept.
CreatedByID int
CreatedAt time.Time
// ScheduleShown - the form had the schedule (SettingsAllowed, a
// content type's node): PublishOn / UnpublishOn are the node's new
// ones, zero - none. Without it the node keeps its own.
ScheduleShown bool
PublishOn time.Time
UnpublishOn time.Time
// ViewRoles - who may view the node, of those its type is for
// (entity.Node.ViewRoles); ViewRolesShown - the form had them
// (SettingsAllowed, a content type's node), else the node keeps its own.
ViewRoles []string
ViewRolesShown bool
// CommentMode - the node's comment visibility (see entity.CommentMode).
// Empty means "not submitted"; on create the content type's
// DefaultCommentMode applies.
CommentMode string
// Submitted - the whole submitted form (nil - not submitted): the
// modules' sections of a redisplayed form show what was sent
// (interfaces.NodeSettings).
Submitted url.Values
// FieldUploadErrors - image upload validation failures (extensions, size,
// resolution; see entity.FieldUploadPolicy) set by
// resolveFileUploads, reported by Validate
// so they render inline on the form.
FieldUploadErrors map[int]string
// FileAlts - the alt texts sent for the images, by file ID: written
// with the content (not while the form is read: it may come back with
// errors), shown again on a redisplayed form.
FileAlts map[int]string
// SentFiles, FileDeletes - a form sent back with errors (the node
// controller's sentBack): an image or file field's file sent and not
// saved yet, which the next submit keeps (<field>_sent, checked as a
// pick from the media library), by field ID; the fields whose saved
// file was ticked for deleting (the tick shown again).
SentFiles map[int]int
FileDeletes map[int]bool
// FieldBlocks - the blocks fields' items as submitted (a hidden
// field's - the node's), keyed by FieldInstanceDef.ID; BlockErrors -
// what's wrong with their values, by input name (Validate reports
// them). Set by resolveBlocks (keepBlocks - a hidden field's).
FieldBlocks map[int][]BlockInput
BlockErrors map[string]string
}
DynamicForm is the form for admin-defined content types. FieldValues holds one raw submitted string per field, keyed by FieldInstanceDef.ID; typed conversion happens in DynamicContentController, which has the resolved field list. Validate lives here to reuse the shared validation primitives.
func (*DynamicForm) ParseDynamicForm ¶
func (f *DynamicForm) ParseDynamicForm(r *http.Request, fieldIDs []int) (*DynamicForm, error)
ParseDynamicForm reads the generic node-level fields (title/slug/status/ tags/meta) plus one "field_<id>" value per id in fieldIDs.
func (*DynamicForm) Validate ¶
func (f *DynamicForm) Validate(ctx context.Context, fields entity.FieldInstanceDefs) map[string]string
Validate checks the generic node fields (title required, slug rules) plus each field per its FieldType/Required/MaxLen. number/taxonomy/reference/image values get a structural parse check since they go into typed value columns.
func (*DynamicForm) ValidateFields ¶
func (f *DynamicForm) ValidateFields(ctx context.Context, fields entity.FieldInstanceDefs) map[string]string
ValidateFields checks the values of fields (Validate without the node's own ones: a block's).
type NodeMetaFields ¶
NodeMetaFields are shared by node edit forms (edit_node_settings.html).
func NodeMetaFromPageSEO ¶
func NodeMetaFromPageSEO(ps entity.PageSEO) NodeMetaFields
NodeMetaFromPageSEO fills meta fields from persisted node SEO (may be empty).
func (*NodeMetaFields) ParseNodeMeta ¶
func (n *NodeMetaFields) ParseNodeMeta(r *http.Request)
ParseNodeMeta reads meta_title and meta_description from the request.
type TagInput ¶
TagInput is one parsed tag value from a Tagify hidden input's "5,7,new:Name" format: Type is "existing" (Value is the term ID as a string) or "new" (Value is the name of a term to create).
func ParseTagsInput ¶
ParseTagsInput exports parseTagsInput for callers outside package form that resolve a Tagify input's "new:<name>"/plain-ID encoding (e.g. multi-value taxonomy fields in DynamicContentController).