z_props (zotonic_core v1.0.0-rc.11)
Link to this section Summary
Functions
Find all different language codes in the maps.
Convert a list for rsc insert and/or update to a map. The list could be a list of (binary) query args, or a property list with atom keys.
Transform a proplist from older resources and/or code to a (nested) map. This knows how to handle nestes lists like the 'blocks' list of lists.
Combine properties from a form. The form consists of a flat list with query string properties. The result is a map which can be used by the rsc and other routines.
Like from_qs/1, except that a specific date is used to fill in any missing date/time parts.
Normalize dates, ensure that all dates are in UTC and parsed to Erlang datetime format.
Check all trans records, remove languages not mentioned.
Link to this section Types
Link to this type
qs_key/0
-type qs_key() :: binary().
Link to this type
qs_prop/0
Link to this type
qs_value/0
-type qs_value() :: binary() | #upload{} | term().
Link to this section Functions
Link to this function
extract_languages(Props)
-spec extract_languages(map()) -> [atom()].
Link to this function
from_list(L)
-spec from_list(list()) -> {ok, #{binary() => term()}}.
Link to this function
from_props(Ps)
-spec from_props(proplists:proplist() | undefined) -> map().
Link to this function
from_qs(Qs)
-spec from_qs([qs_prop()]) -> {ok, #{binary() => term()}}.
Combine properties from a form. The form consists of a flat list with query string properties. The result is a map which can be used by the rsc and other routines.
The keys can have a special format, specifying how they are processed:- 'dt:ymd:0:property' is datetime property, 0 for start-date, 1 for end-date, the pattern 'ymd' describes what is in the value, could also be 'y', 'm', 'd', 'dmy', 'his', 'hi', 'h', 'i', or 's'
- 'prop$en' is the 'en' translation of the property named 'prop'
- 'a.b.c.d' is a nested map
- 'blocks[].name' is a list of maps, use 'blocks[].' to append a new empty entry. Use 'name[]' to append to a list of values.
Link to this function
from_qs(Qs, Now)
-spec from_qs([qs_prop()], calendar:datetime()) -> {ok, #{binary() => term()}}.
Link to this function
normalize_dates(Props, IsAllDay, Tz)
-spec normalize_dates(m_rsc:props(), boolean(), binary() | undefined) -> m_rsc:props().
Link to this function
prune_languages(Props, Langs)
-spec prune_languages(map(), [atom()]) -> map().