CoolCMS API

AdvertFormTrait

Add/edit form of an advert (banner).

Scalar fields (name, validity from/to, click/view counters, flags), per-language content in language tabs (HTML code = TinyMCE in raw mode, active translation switch in adminLangNav), a multiplier of advert places (M2M through Picker), a multiplier of targeting parameters and a multiplier of page targeting (pages M2M through Picker).

Page targeting applies only when "show everywhere" (showEverywhere) is not checked; when checked, an empty collection is saved, so the page links are cleared and the advert shows on all pages.

Presenter dependencies:

Table of Contents

Constants

DT_FORMAT  : mixed = 'Y-m-d\TH:i'

Methods

createComponentEditForm()  : Form
addAdvertBehaviorFields()  : void
addAdvertContentFields()  : void
addAdvertCounterFields()  : void
addAdvertPageMultiplier()  : void
Multiplier of page targeting (M2M through Picker; row = hidden `pageId` + label).
addAdvertParameterMultiplier()  : void
Multiplier of targeting parameters. Row = hidden `id` (saved, so the row is updated in place without auto-increment churn), `name` and the `from`/`to` range. No picker, plain inputs.
addAdvertPlaceMultiplier()  : void
Multiplier of advert places (M2M through Picker; row = hidden `advertPlaceId` + label).
addAdvertScheduleFields()  : void
buildAdvertEntity()  : Advert
buildAdvertPages()  : ArrayCollection<int, Page>
Page targeting from the multiplier to a collection of Page (id references only; the M2M is serialized as ids on save and the Api hydrator rewrites the join table). When "show everywhere" is checked, it returns an empty collection, so the page links are cleared.
buildAdvertParameters()  : ArrayCollection<int, AdvertParameterRel>
Targeting parameters from the multiplier. An existing row carries `id`, so the hydrator pairs and updates it in place; a new one (empty `id`) is inserted. Rows without `name` are skipped.
buildAdvertPlaces()  : ArrayCollection<int, AdvertPlaceRel>
buildAdvertTranslations()  : void
Language versions of the content. An existing translation (derived identity advert + language) is updated in place, a missing one is created — even an inactive one, so that half-written text is not lost. The front end ignores an inactive translation.
findAdvertTranslation()  : AdvertText|null
getAdvertFormLanguages()  : array<int, Language>
nInt()  : int|null
nStr()  : string
saveAdvertForm()  : bool
setAdvertFormDefaults()  : void

Constants

Methods

addAdvertPageMultiplier()

Multiplier of page targeting (M2M through Picker; row = hidden `pageId` + label).

private addAdvertPageMultiplier(Form $form) : void

Used only when "show everywhere" is not checked.

Parameters
$form : Form

addAdvertParameterMultiplier()

Multiplier of targeting parameters. Row = hidden `id` (saved, so the row is updated in place without auto-increment churn), `name` and the `from`/`to` range. No picker, plain inputs.

private addAdvertParameterMultiplier(Form $form) : void

Create/remove buttons have the ajax class.

Parameters
$form : Form

addAdvertPlaceMultiplier()

Multiplier of advert places (M2M through Picker; row = hidden `advertPlaceId` + label).

private addAdvertPlaceMultiplier(Form $form) : void
Parameters
$form : Form

buildAdvertEntity()

private buildAdvertEntity(ArrayHash<string|int, mixed> $values) : Advert
Parameters
$values : ArrayHash<string|int, mixed>
Return values
Advert

buildAdvertPages()

Page targeting from the multiplier to a collection of Page (id references only; the M2M is serialized as ids on save and the Api hydrator rewrites the join table). When "show everywhere" is checked, it returns an empty collection, so the page links are cleared.

private buildAdvertPages(ArrayHash<string|int, mixed> $values, bool $showEverywhere) : ArrayCollection<int, Page>
Parameters
$values : ArrayHash<string|int, mixed>
$showEverywhere : bool
Return values
ArrayCollection<int, Page>

buildAdvertParameters()

Targeting parameters from the multiplier. An existing row carries `id`, so the hydrator pairs and updates it in place; a new one (empty `id`) is inserted. Rows without `name` are skipped.

private buildAdvertParameters(ArrayHash<string|int, mixed> $values) : ArrayCollection<int, AdvertParameterRel>
Parameters
$values : ArrayHash<string|int, mixed>
Return values
ArrayCollection<int, AdvertParameterRel>

buildAdvertPlaces()

private buildAdvertPlaces(ArrayHash<string|int, mixed> $values) : ArrayCollection<int, AdvertPlaceRel>
Parameters
$values : ArrayHash<string|int, mixed>
Return values
ArrayCollection<int, AdvertPlaceRel>

buildAdvertTranslations()

Language versions of the content. An existing translation (derived identity advert + language) is updated in place, a missing one is created — even an inactive one, so that half-written text is not lost. The front end ignores an inactive translation.

private buildAdvertTranslations(Advert $advert, ArrayHash<string|int, mixed> $values) : void
Parameters
$advert : Advert
$values : ArrayHash<string|int, mixed>

nInt()

private nInt(mixed $value) : int|null
Parameters
$value : mixed
Return values
int|null

nStr()

private nStr(mixed $value) : string
Parameters
$value : mixed
Return values
string

saveAdvertForm()

private saveAdvertForm(ArrayHash<string|int, mixed> $values) : bool
Parameters
$values : ArrayHash<string|int, mixed>
Return values
bool
On this page

Search results