CoolCMS API

PagePresenter extends BasePresenter
in package
uses PageFormTrait, CustomAssetTabTrait, CustomAssetTabSaveTrait, CustomAssetPickerTrait, PagePickerTrait, PickerHostTrait, TreePositionHostTrait, AdminEditFormComponentsTrait

FinalYes

Abstract base for all Admin presenters.

Shares the auth layer with the Front module (JWT + Nette session), but access is controlled only by RBAC (PrivilegeCheckTrait::checkAdminAccess(), key :Admin), not by page.isOnlyForLoggedInUsers. The theme is admin/default, the session namespace admin.

LoginPresenter overrides authorize() to skip checkAdminAccess(); otherwise the login page would be unreachable.

Table of Contents

Constants

LOGIN_BACKLINK  : string = 'backlink'
Login page parameter with the key of the stored request to return to ({@see loginReturnArgs()}).
DEFAULT_ITEMS_PER_PAGE  : mixed = 20
Items per page of admin lists when the DB setting is missing.
FORM_BACK_SUBSECTION  : mixed = 'formBack'
Session subsection mapping a key to the previous page URL of edit forms.
SESSION_NAMESPACE  : mixed = 'admin'
BLOCKED_EXTENSIONS  : mixed = ['php', 'php3', 'php4', 'php5', 'php7', 'php8',...
Extensions that must not be uploaded into the web-served folder; otherwise an editor upload would mean running foreign code on the server. It is no content whitelist (the editor uploads what is needed), only a safeguard against executable files.
CHANGEFREQ_VALUES  : mixed = ['always', 'hourly', 'daily', 'weekly', 'monthl...
Allowed `changefreq` (sitemap) values; translated in the template through options.
EDITOR_PAGE_LIMIT  : mixed = 500
Listing cap; the dialog is a suggester, not a paged list.
EDITOR_PAGE_TARGETS  : mixed = ['front:system:page:show']
Routes the editor may link to: text pages only.
EDITOR_UPLOAD_FOLDER  : mixed = 'editorUploads'
Editor root (relative to the `uploads/` root). Changing it to `''` would open the whole `uploads/` tree to the manager; the editor user could then reach (and delete) files of other modules such as products and avatars.
IMAGE_EXTENSIONS  : mixed = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'avif', '...
Extensions the file manager shows as a preview instead of a document icon.
LOCALE_MAP  : mixed = ['cs' => 'cs_CZ', 'en' => 'en_US', 'sk' => 'sk_...
Maps the short language code to the full locale of the registered NEON sources.

Properties

$accessTokenValidator  : AccessTokenValidator
Signature and expiry alone are not enough: a revoked token (`jti` on the deny-list) that has not expired yet would keep the session logged in although the Api guard rejects the same token. Same contract as {@see \App\Core\Traits\Api\Presenters\JwtAuthTrait::checkJwtAuth()}, one implementation.
$adminFormActionsFactory  : FormActionsFactory
$adminLangNavFactory  : LangNavFactory
$adminPageManager  : AdminPageManager
$authManager  : AuthManager
$authStorageManager  : AuthStorageManager
$authUserManager  : UserManager
Admin `UserManager` for {@see UserManager::login()}. A module must not read through another module, so admin has its own `login()` that calls the same Api endpoint (`api/system/auth/login`).
$columnSchema  : ColumnSchema
Limits of the real database columns for {@see guardColumns()}.
$container  : Container
$deviceDetector  : DeviceDetector
$editorAutosaveScope  : EditorAutosaveScope
Scope of the editor autosave drafts, see {@see \App\Core\Security\EditorAutosaveScope}.
$editorLinkPageManager  : PageManager
NOTE: own property name. `$pageManager` already exists on presenters (`PagePickerTrait`), and two `#[Inject]` properties of the same name would collide in the trait composition.
$editorUploadManager  : FileSystemManager
NOTE: own property name, not `$fileSystemManager`.
$eventDispatcher  : EventDispatcher
$formSubmissionGuard  : FormSubmissionGuard
One-time submission tokens of "add" forms, see {@see guardFormSubmitOnce()}.
$jwtManager  : JwtManager
$languageContext  : LanguageContext
$languageManager  : LanguageManager
$localizationContext  : LocalizationContext
$localizationManager  : LocalizationManager
$loginDeviceCookie  : LoginDeviceCookie
Cookie of a known device for the password login throttle ({@see self::rememberLoginDevice()}).
$modalWindowFactory  : ModalWindowFactory
Injected through Nette presenter inject (after construction), not the constructor.
$pageManager  : PageManager
$picker  : string
Picker mode of a list; when not empty, the presenter renders its `show` grid as a selection modal (no add/edit/delete/checkboxes, each row has a select button) in the minimal `@picker.latte` layout.
$pickerExclude  : int
Id of the record that cannot be selected in picker mode (its select button is hidden).
$pickerExcludeSubtreeLft  : int
`lft`/`rgt` bounds of a whole subtree whose nodes cannot be selected in picker mode.
$pickerExcludeSubtreeRgt  : int
$presenterContext  : PresenterContext
$privilegeManager  : PrivilegeManager
$queryCacheContext  : QueryCacheContext
Query cache policy for the whole admin request; `startup()` disables it.
$routerDispatcher  : RouterDispatcher
$settingContext  : SettingContext
$settingManager  : SettingManager
$themeContext  : ThemeContext
$themeManager  : ThemeManager
$themeResolver  : DefaultThemeResolver
$translator  : ITranslator
$translatorSessionResolver  : Session
$treePositionFactory  : TreePositionFactory
$userManager  : UserManager
$adminPageEntity  : AdminPage|null
$debugMode  : bool
$productionMode  : bool
$savedEntityId  : int|null
Id of the record just saved; set by the `$processData` callback in `createForm()` after a successful save.
$translatorDomain  : string
$adminLanguageManager  : LanguageManager
$customAssetManager  : CustomAssetManager
$customAssetRowsCache  : array<int, CustomAsset>|null
Assets loaded for the current page and mode, cached per request (one presenter instance per request), so defaults and the lookup map share one DB query.
$dataGridFactory  : DataGridFactory
$editedPage  : Page|null
Edited page (null when adding).
$isLoggingIn  : bool
$menuItemManager  : MenuItemManager
$pickerFactory  : PickerFactory
$routeManager  : RouteManager
$theme  : Theme|null
$userPrivileges  : array<int, string>

Methods

__construct()  : mixed
actionAdd()  : void
actionEdit()  : void
beforeRender()  : void
createComponent()  : IComponent|null
extractCustomAssetRowIds()  : array<int, mixed>
Returns the ids from the tab rows (hidden `assetId`).
flashFormOwnErrors()  : void
Flashes form-level errors (`$form->getOwnErrors()`) as `danger` messages.
flashRejectedUploads()  : void
Flashes one `warning` listing the files the Api rejected (type, dimensions, unreadable) after a successful save of a form with a dropzone ({@see UploadRejection}).
formatLayoutTemplateFiles()  : array<string|int, mixed>
Admin version of {@see \App\Core\Traits\Front\Presenters\ThemeInitTrait::formatLayoutTemplateFiles()}.
getAdminPageEntity()  : AdminPage|null
getContainer()  : Container
getFormBackUrl()  : string
Returns the stored previous page URL for the key, used by the `cancel` link in the template.
getModalWindow()  : ModalWindow
getRouterDispatcher()  : RouterDispatcher
getTranslator()  : ITranslator
guardFormSubmitOnce()  : void
Protects a form against a double submit: one rendered form saves at most once.
handleChangeLocale()  : void
handleEditorCreateFolder()  : void
Creates a subfolder in `folder` (path relative to the editor root).
handleEditorDelete()  : void
Deletes a file or (recursively) a folder. An empty path would point to the editor root, which cannot be deleted.
handleEditorFiles()  : void
Sends the folder listing for the editor file manager. The `folder` parameter is a path relative to the editor root (empty means the root).
handleEditorPages()  : void
Sends the page list for the link dialog as JSON `{"pages": [{id, label, url}, ...]}` sorted by label.
handleEditorRename()  : void
Renames a file or folder (`path` relative to the editor root).
handleEditorUpload()  : void
Accepts a file from the editor (field `file`, multipart POST; optional `folder` = subfolder of the editor root) and sends JSON `{"location": "/www/uploads/editorUploads/..."}`, the format TinyMCE expects from `images_upload_handler`.
handleLogout()  : void
handleSignOut()  : void
hasServiceByType()  : bool
Returns whether the container has a service of the given type.
initializeTranslator()  : void
isAddAction()  : bool
Tells whether the current action creates a record: `add` and the `add<Something>` actions (`addMenu`, `addKey`). Derived from the server context only, like {@see formSubmitPrivilege()}.
isAllowed()  : bool
Returns whether the logged-in user has the given privilege.
isSubmitOnceForm()  : bool
Tells whether the form was protected by {@see guardFormSubmitOnce()}.
loginWithCredentials()  : void
Logs in with username and password; called only by the login form (after validation and CSRF).
persistPageCustomAssetsTab()  : CustomAssetTabSaveOutcome
publishFieldErrors()  : void
Publishes element errors of a failed submit to the client.
redirectToFormBack()  : void
Redirects to the stored previous page and discards the key.
renderAdd()  : void
renderDashboard()  : void
renderEdit()  : void
renderShow()  : void
Front end page list (`/admin/system/page/show`): a tree by parentId/lft with drag and drop, column search and inline update of the sitemap flag.
resolveFormBackKey()  : string
Returns the previous-page key: from the URL if present (survives the update redirect), otherwise on a plain GET render of the edit page stores `Referer` in the session under a new random key.
runSubmitOnce()  : bool|null
Runs a saving step of a form under its one-time token (a form without the token just runs it).
setConfigParameters()  : void
setTranslator()  : $this
startup()  : void
typedComponent()  : T
Returns a subcomponent with a verified type.
addCustomAssetPickerControls()  : void
Adds the picker controls (hidden id plus text label) to a multiplier row.
addCustomAssetTab()  : void
Adds the `customAssets` multiplier to the form, only with the `assign` privilege.
addPageControls()  : void
Adds the page picker controls (hidden id plus text label) to a multiplier row.
addTreePositionFields()  : void
Position fields for the form (default: keep the current place).
authorize()  : void
Authorization hook; by default requires the `:Admin` privilege.
authorizeFormSubmit()  : void
Gate for writing presenter forms built by `createForm()`.
authorizeListing()  : void
Gate for reading lists.
buildTreeMoveMeta()  : array<string, mixed>|null
Move meta for `save()` of an existing node; `null` means an invalid choice (the flash is already set, the caller just returns `false`). `[]` means nothing moves.
checkAdminAccess()  : void
Entry gate to the admin: a guest is sent to login; a logged-in user without `:Admin` is sent to login with an error.
checkAuthentication()  : void
checkCurrentPrivilege()  : void
Builds the key from the current request (`:Admin:<Module>:<Presenter>:<action>`) and checks it. `getName()` already contains the `Admin:...` prefix, so only one leading colon is added.
checkPrivilege()  : void
Checks a specific privilege; throws 403 when denied.
createComponentAdminFormActions()  : FormActions
createComponentAdminLangNav()  : LangNav
createComponentEditForm()  : Form
createComponentGrid()  : DataGrid
createComponentModalWindow()  : ModalWindow
createComponentPicker()  : Multiplier<string|int, Picker>
createComponentTreePosition()  : TreePosition
createForm()  : Form
Creates an edit form with the standard actions and a return to the previous page.
customAssetLookupMap()  : array<int, array{type: string, placement: string}>
Returns an id to type and placement map only for assets loaded in this request (the tab defaults). A newly selected row (id outside this set) keeps type and placement empty in the template until the page is reloaded.
customAssetPicker()  : PickerConfig
deletePageNode()  : Result
Seam: compensation for a new page.
domainTranslator()  : PrefixedTranslator|null
Returns a translator prefixed with the presenter domain, or `null` (empty domain or a translator other than Contributte).
flashTreeMoveFailure()  : bool
Failure message for a save with a tree-specific reason (stale snapshot, lock, invalid target); only when the save really carried a move. `false` means the caller sets its own generic message.
formSubmitPrivilege()  : string
Returns the privilege key required to save a form built by `createForm()`.
getAdminItemsPerPage()  : int
Returns the default items per page of admin lists from the DB setting `admin.itemsPerPage` (module System = 1), falling back to {@see DEFAULT_ITEMS_PER_PAGE}.
getAdminLayout()  : string
Returns the layout name; in picker mode ({@see $picker}) the `show` grid uses the minimal `@picker.latte` (no sidebar/header) so the opener fetch returns only the table.
getFormBackFallback()  : string
Returns the return URL when the previous page is unknown; override in a presenter without a `show` action.
getSessionKey()  : string
Returns a session key string, e.g. 'front.auth.step1'.
getSessionSection()  : SessionSection
Returns a Nette\SessionSection instance using a dynamically built session key.
guardColumns()  : void
Gates every text and number field of the form by the real column it writes to ({@see \App\Core\Forms\ColumnGate::guard()}): an oversized value is an error at the field, never a database error that closes the entity manager (admin walkthrough A1, A14).
initializePresenterContext()  : void
isSameSiteRequest()  : bool
Tells whether the request comes from the own site (Nette SameSite cookie); protects GET actions with a side effect.
loadCustomAssetReadOnlyRows()  : array<int, array{id: int, name: string, type: string, placement: string}>
Returns the rows for the read-only display (without `assign`), passed straight to the template because the form field does not exist without the privilege.
loadCustomAssetTabDefaults()  : array<int, array{assetId: string, asset: string}>
Returns the multiplier defaults: the codes assigned to the page when editing, the codes with `addToNewPages = 1` when adding.
loadUserPrivileges()  : void
Loads all privileges of the logged-in user with one database query. Call it right after `checkAdminAccess()` in `startup()` (the user is guaranteed to be logged in by then).
logout()  : void
mayAssignCustomAssets()  : bool
Whether the user may change the set (picker, add, remove).
mayEditCustomAssetInLibrary()  : bool
Whether the user may open a code for editing in the library (the edit link).
mayShowCustomAssets()  : bool
Whether the user may see the tab at all (read-only included).
pageMultiplierPicker()  : PickerConfig
Page picker for a multiplier (several pages in one form, e.g. targeting an advert at specific pages). Unlike {@see pagePicker()}, it addresses the hidden field inside the multiplier container and carries a text `displayField`, so the label survives the AJAX re-render of the row. The row is built by {@see addPageControls()}.
pagePicker()  : PickerConfig
pickers()  : array<string, PickerConfig>
Returns the presenter pickers (multicontrol); pure configuration, also callable during the AJAX signal `suggest!`. `parentId` is the self-reference to `Page` (suggest plus a modal with the `Page` `show` grid); `customAsset` is the custom code tab (pick from the library).
savePageEntity()  : Result
Seam: saves the page entity. Override in a test to avoid touching the DB.
setTranslatorDomain()  : void
setupTemplateTranslator()  : void
Sets a translator prefixed with the presenter domain into the template (as Front components do, see {@see \App\Core\Base\BaseComponent::setup()}).
syncPageCustomAssets()  : Result
Seam: syncs the page code set (`api/system/custom-asset/sync-page`).
treePositionConfig()  : TreePositionConfig
Position of the page among the parent's children (`{control treePosition}`); existing record only.
addBehaviorFields()  : void
Visibility and behavior switches of the page.
addCssField()  : void
CSS files of the page: multiselect of theme CSS files ({@see \App\UI\Admin\System\Models\Managers\PageManager::scanTemplateCssFiles()}), stored as a comma-separated list of names. Degrades to a text input without files.
addLayoutField()  : void
Layout field: select of layout files of the active front-end theme ({@see \App\UI\Admin\System\Models\Managers\PageManager::scanTemplateLayoutFiles()}).
addNavigationFields()  : void
Navigation and structure: parent page (picker) and theme layout files.
addRouteFields()  : void
Routes assigned to the page: multiselect filled through {@see \App\UI\Admin\System\Models\Managers\RouteManager}.
addSeoFields()  : void
SEO: update frequency and sitemap priority.
addTechnicalFields()  : void
Technical settings: CSS files (multiselect), HTML class, internal notes.
addTranslationFields()  : void
Multilingual fields: one set per language (`<field>_<langId>`), active by checkbox.
applyRoutes()  : void
Overwrites the M:N relation of the page to routes by the ids selected in the multiselect.
buildCustomAssetsTabTemplateData()  : array{mayAssign: bool, mayEditInLibrary: bool, lookup: array, readOnlyRows: list}|null
Builds the template data of the custom code tab; `null` means the tab is not rendered at all (no `show` privilege). With the `assign` privilege the template renders an editable multiplier (the form field exists); without it only read-only rows (`readOnlyRows`), and the form does not save the assignments.
buildPageEntity()  : Page
buildRouteMenuProblemMessage()  : string
Builds the finished message text (no translation key); {@see BaseControl::addError()} receives it with `translate: false`.
collectRouteIds()  : array<int, int>
Returns ids of routes assigned to the page (to prefill the multiselect on edit).
collectRouteMenuProblems()  : array<int, array{route: string, params: list, lang: string|null}>
Decides, for every selected route, what exactly would break the menu link.
createIdentity()  : SimpleIdentity|null
createMultiplierComponent()  : Multiplier<string|int, IComponent>
Creates a multiplier for the component.
createNewComponentInstance()  : IComponent|null
Creates a new component instance without adding it to the presenter; used by the multiplier.
createStandardComponent()  : IComponent|null
Creates a standard component (not a multiplier).
cssToString()  : string
Converts the CSS field value to the stored string: the multiselect returns a name array (joined by commas), the text input a plain string.
customAssetPickerLabel()  : string
customAssetPickerLabelFor()  : string
customAssetPlacementLabel()  : string
customAssetTypeLabel()  : string
editorBreadcrumb()  : array<int, array{label: string, path: string}>
Builds the breadcrumb navigation: cumulative segment paths.
editorLinkLangId()  : int
Returns the language used to pick labels and URLs (default 1, Czech).
editorPageLabel()  : string
Returns the page label: title, otherwise name, otherwise `#id`.
editorPageRoute()  : Route|null
Returns the first page route the editor may link to. A page may have several (many-to-many); the whitelisted one is taken, not the first in order, so a page with both `Page:show` and `Page:form` ends up on the right one.
editorPageUrl()  : string|null
Returns the front end address of a page. The router builds it from the page route, so `/o-nas` and any prefix come out on their own.
editorParentFolder()  : string|null
Returns the parent folder (null in the editor root).
editorPath()  : string|null
Converts a client path (relative to the editor root) to an Api path (relative to the `uploads/` root).
editorUploadName()  : string|null
Builds a safe and unique file name. Sanitization copies the Api layer rules (webalize of the base and of the extension), so the name returned in the URL is exactly the name the file is stored under. The random suffix prevents collisions: `writeFile()` overwrites the same name without asking, so two different `obrazek.jpg` files would overwrite each other.
editorUploadUrl()  : string
Returns the public URL of a file. `$path` is relative to the `uploads/` root (so it includes `editorUploads/`), the same shape as other uploads in the system.
ensureEditorRoot()  : void
Creates the editor root folder; when it already exists the Api returns false and nothing happens.
expireIdleLogin()  : bool
Returns whether the login expired from inactivity. If so, revokes the tokens (like a logout), clears the `auth` section, logs out the Nette identity and returns true; otherwise moves the activity stamp forward.
findPageByHref()  : Page|null
Returns a page with the same `href` in the given language (other than the edited one).
getClientIp()  : string
getEditedPageId()  : int|null
Returns the edited page id (>0) for excluding the self-reference in the picker; null when adding.
getFormLanguages()  : array<int, Language>
Returns languages for the multilingual form fields (admin `LanguageManager`).
initializeMetaTags()  : void
Fills the template with the title, meta tags and HTML text of the page from the translation (`PageText`) of the current language, for the layout (like the Front {@see \App\Core\Traits\Front\Presenters\PageInitTrait}).
initializePage()  : void
isDevelopment()  : bool
languageLabel()  : string
Short language code for the message (`cs`, `en`), not the full name: technical context of the route choice.
loadCustomAssetTabEntities()  : array<int, CustomAsset>
Loads the assets relevant to `$page` in one query, shared by defaults, the lookup map and the read-only list (cached on the presenter instance).
loadLocalization()  : Localization|null
localizationCurrencyKey()  : string|null
Admin ignores the localization currency (it takes the language only).
loginReturnArgs()  : array<string, string>
Remembers the request of a logged-out user so the login can return to it ({@see storeRequest()}, `backlink` of the login page, restored by `AuthStorageTrait::redirectAfterLoginAction()`).
logoutNetteUser()  : void
pageIsInMenu()  : bool
Tells whether the page `$pageId` is linked in any menu. Only existence, not the item: `cms_system_menu_items.cms_system_pages_page_id` filtered through the `page.id` association ({@see EqualFilter} auto-joins the dotted path, like `CategoryManager::findAll()` does for `'translations.href'`).
pageLabel()  : string
pageTitleForLang()  : string
Returns the colliding page label for the message: title, else name, else `#id`.
parsePickerName()  : array{0: string, 1: list}
Splits a picker instance name into the config key plus row indexes (multiplier and nested multiplier). `parentId` -> `['parentId', []]`; `address_2` -> `['address', ['2']]`; `parameter_1_0` -> `['parameter', ['1','0']]` (nested).
pickerLangId()  : int
prepareCssOptions()  : array<string, string>
CSS multiselect options: theme files plus names stored on the page (on edit), even when the file has disappeared.
prepareLayoutOptions()  : array<string, string>
Layout select options: theme files plus the values stored on the page (on edit), even when the file has disappeared, so the select can still be prefilled.
prepareRouteOptions()  : array<int, string>
Options of the route multiselect: `id => "module presenter:action"`, alphabetical.
processFailedLogin()  : void
processInvalidToken()  : void
processLogin()  : void
processLoginException()  : void
processMissingToken()  : void
processSuccessfulLogin()  : void
processValidToken()  : void
readLoginDeviceToken()  : string|null
Returns the raw known-device cookie for the Api login (the Api verifies its signature).
redirectAfterLoginAction()  : void
After a login attempt: a successful login returns to the request remembered before the login (`backlink`, {@see PrivilegeCheckTrait::loginReturnArgs()}), otherwise to the dashboard; a failed one stays on the login page and keeps the way back.
redrawCustomAssetTab()  : void
Redraws the tab rows.
refreshNetteIdentity()  : bool
Refreshes the token of the same logged-in user: identity data (token, name, email) are overwritten in the stored object without `login()`, so neither the session id nor the form CSRF tokens change. The identity is stored in the session section as an object; the change is written at the end of the request.
rememberLoginDevice()  : void
After a successful login (password or OAuth) issues or renews the known-device cookie ({@see LoginDeviceCookie}): a signed proof that this browser has already logged in to the account. The next login sends it to the Api ({@see self::processLogin()}), and above the account limit the password from this browser is still verified, so foreign attempts do not lock out the owner. HttpOnly, SameSite=Lax, Secure on HTTPS; lifetime from `ratelimit.loginDevice.cookieLifetime`.
reportCustomAssetTabFailure()  : bool
Adds a danger flash (and an optional log entry) and returns false; shared by all failed tab-save results.
reportCustomAssetTabSuccess()  : bool
Adds a success flash plus `savedEntityId` (for `apply`) and returns true.
resolveCustomAssetLabel()  : string|null
resolveLoginErrorMessage()  : string
Resolves the flash message of a failed login.
resolvePageLabel()  : string|null
Label to prefill on edit (from the hidden value).
revokeTokensOnLogout()  : void
Calls the Api logout (revokes the refresh family and deny-lists the access `jti`) for the tokens of the current session. Fail-open on purpose: any failure is only logged, because the local logout must not stay unfinished.
saveEditForm()  : bool
Saves the form data. The redirect is done by {@see \App\Core\Base\Admin\BasePresenter::createForm()} according to the pressed button.
savePageWithCustomAssets()  : bool
Saves the page and then its own custom code set (the "custom code" tab). The decision logic (what to call, in which order, how to react to failure) lives in {@see CustomAssetTabSaveTrait::persistPageCustomAssetsTab()}; here the result is only mapped to flash messages.
setCustomAssetTabDefaults()  : void
Defaults of the custom code tab: set on the whole form (`setDefaults`), not `setValues` on the multiplier container. Edit = codes assigned to the page; add = codes with `addToNewPages = 1`. Without the `assign` privilege the field does not exist in the form ({@see CustomAssetTabTrait::addCustomAssetTab()}), so `setDefaults()` silently skips the key.
setEditFormDefaults()  : void
setNetteUser()  : void
splitCss()  : array<int, string>
Splits the stored comma-separated CSS string into file names.
storeEditorUpload()  : bool
Stores a file; the target folder may not exist (first upload into the root), so after a failure the root is created once and the write is retried. Deeper subfolders are created by the editor user through `editorCreateFolder`.
str()  : string
Safely converts a mixed form value to string (NEON/ArrayHash).
suggestCustomAssets()  : array<int, array{id: int, label: string}>
Suggestions: `LIKE` on `name`, label "name (type, placement)".
suggestPages()  : array<int, array{id: int, label: string}>
Suggestions: `OR LIKE` over the page name and title, optionally without the excluded node and its whole subtree (a page must not be its own parent or the parent of its descendant).
tr()  : string
Translates a key in the form domain to a finished string (for fields with `setTranslator(null)`).
trCustomAssetPickerOption()  : string
Translates an absolute key; the trait is used in presenters with different domains.
trCustomAssetTabKey()  : string
Translates an absolute key shared with the library (`CustomAssetFormTrait`), not duplicated.
tryRefresh()  : bool
Tries an auto-refresh for an expired access token. If the session holds a refresh token and the Api accepts it, stores the new pair in the session and returns true; otherwise returns false and the caller cancels the session.
validateHrefUniqueness()  : bool
Requires the `href` to be unique within one language.
validateRouteMenuCompatibility()  : bool
Blocks a route whose mask needs a parameter the menu cannot fill.

Constants

Login page parameter with the key of the stored request to return to ({@see loginReturnArgs()}).

public string LOGIN_BACKLINK = 'backlink'

DEFAULT_ITEMS_PER_PAGE

Items per page of admin lists when the DB setting is missing.

protected mixed DEFAULT_ITEMS_PER_PAGE = 20

FORM_BACK_SUBSECTION

Session subsection mapping a key to the previous page URL of edit forms.

protected mixed FORM_BACK_SUBSECTION = 'formBack'

SESSION_NAMESPACE

protected mixed SESSION_NAMESPACE = 'admin'

BLOCKED_EXTENSIONS

Extensions that must not be uploaded into the web-served folder; otherwise an editor upload would mean running foreign code on the server. It is no content whitelist (the editor uploads what is needed), only a safeguard against executable files.

private mixed BLOCKED_EXTENSIONS = ['php', 'php3', 'php4', 'php5', 'php7', 'php8', 'phps', 'phtml', 'phar', 'cgi', 'pl', 'py', 'sh', 'bash', 'htaccess', 'htpasswd']

CHANGEFREQ_VALUES

Allowed `changefreq` (sitemap) values; translated in the template through options.

private mixed CHANGEFREQ_VALUES = ['always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never']

EDITOR_PAGE_LIMIT

Listing cap; the dialog is a suggester, not a paged list.

private mixed EDITOR_PAGE_LIMIT = 500

EDITOR_PAGE_TARGETS

Routes the editor may link to: text pages only.

private mixed EDITOR_PAGE_TARGETS = ['front:system:page:show']

Other page routes need parameters the editor cannot know (Front:System:User:profile wants id and username, Front:System:Registration:registration wants email and activationKey, advert details want id/name). A link to them could not be built or would lead to a broken address, so they stay out of the offer.

Another target (e.g. Front:System:Page:homepage or Front:System:Page:form) is one more line here, provided its route needs only slug.

EDITOR_UPLOAD_FOLDER

Editor root (relative to the `uploads/` root). Changing it to `''` would open the whole `uploads/` tree to the manager; the editor user could then reach (and delete) files of other modules such as products and avatars.

private mixed EDITOR_UPLOAD_FOLDER = 'editorUploads'

IMAGE_EXTENSIONS

Extensions the file manager shows as a preview instead of a document icon.

private mixed IMAGE_EXTENSIONS = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'avif', 'svg', 'bmp']

LOCALE_MAP

Maps the short language code to the full locale of the registered NEON sources.

private mixed LOCALE_MAP = ['cs' => 'cs_CZ', 'en' => 'en_US', 'sk' => 'sk_SK']

The short code (cs, en, sk) comes from LanguageContext, derived from the URL parameter loc/lang; the full locales are cs_CZ, en_US, sk_SK. translator.neon configures one shared fallback chain [cs_CZ, cs, en_US, en, sk_SK, sk] for all languages, so a short code would always map to cs_CZ first, whatever language is active. A direct match on the full locale bypasses that.

The Contributte LocaleResolvers\Router (the only configured resolver) looks for the route parameter locale, but this application routes under loc, so it always returns null and the translator falls back to default: cs. An explicit setLocale() from here bypasses the resolver, which Translator::getLocale() asks only while no locale has been set explicitly.

Properties

$accessTokenValidator

Signature and expiry alone are not enough: a revoked token (`jti` on the deny-list) that has not expired yet would keep the session logged in although the Api guard rejects the same token. Same contract as {@see \App\Core\Traits\Api\Presenters\JwtAuthTrait::checkJwtAuth()}, one implementation.

public AccessTokenValidator $accessTokenValidator
Attributes
#[Inject]

$authUserManager

Admin `UserManager` for {@see UserManager::login()}. A module must not read through another module, so admin has its own `login()` that calls the same Api endpoint (`api/system/auth/login`).

public UserManager $authUserManager

The own property name avoids a collision with the generic $userManager from UserTrait (typed to the admin CRUD manager).

Attributes
#[Inject]

$columnSchema

Limits of the real database columns for {@see guardColumns()}.

public ColumnSchema $columnSchema
Attributes
#[Inject]

$editorAutosaveScope

Scope of the editor autosave drafts, see {@see \App\Core\Security\EditorAutosaveScope}.

public EditorAutosaveScope $editorAutosaveScope
Attributes
#[Inject]

$editorLinkPageManager

NOTE: own property name. `$pageManager` already exists on presenters (`PagePickerTrait`), and two `#[Inject]` properties of the same name would collide in the trait composition.

public PageManager $editorLinkPageManager
Attributes
#[Inject]

$editorUploadManager

NOTE: own property name, not `$fileSystemManager`.

public FileSystemManager $editorUploadManager

FileSystemPresenter takes the same manager as private readonly in its constructor, and PHP cannot redeclare a property of the same name between public and private.

Attributes
#[Inject]

$formSubmissionGuard

One-time submission tokens of "add" forms, see {@see guardFormSubmitOnce()}.

public FormSubmissionGuard $formSubmissionGuard
Attributes
#[Inject]

$loginDeviceCookie

Cookie of a known device for the password login throttle ({@see self::rememberLoginDevice()}).

public LoginDeviceCookie $loginDeviceCookie
Attributes
#[Inject]

$modalWindowFactory

Injected through Nette presenter inject (after construction), not the constructor.

public ModalWindowFactory $modalWindowFactory
Attributes
#[Inject]

$picker

Picker mode of a list; when not empty, the presenter renders its `show` grid as a selection modal (no add/edit/delete/checkboxes, each row has a select button) in the minimal `@picker.latte` layout.

public string $picker = ''

Opened by Picker; the value is the name of the opener's target field that receives the selection. Persistent, so it stays in grid links (filter/sort/paging) inside the modal. The presenter activates it in createComponent…Grid(): if ($this->picker !== '') { $grid->setPickerMode($this->picker); }.

Attributes
#[Persistent]

$pickerExclude

Id of the record that cannot be selected in picker mode (its select button is hidden).

public int $pickerExclude = 0

Serves self-referencing pickers (a parent page cannot be itself). Passed by Picker in the modal link via PickerConfig::targetParams; 0 means no exclusion.

Attributes
#[Persistent]

$pickerExcludeSubtreeLft

`lft`/`rgt` bounds of a whole subtree whose nodes cannot be selected in picker mode.

public int $pickerExcludeSubtreeLft = 0

Excludes the root and all descendants, so a node cannot be moved under its own descendant. 0 means no subtree exclusion.

Attributes
#[Persistent]

$pickerExcludeSubtreeRgt

public int $pickerExcludeSubtreeRgt = 0
Attributes
#[Persistent]

$queryCacheContext

Query cache policy for the whole admin request; `startup()` disables it.

public QueryCacheContext $queryCacheContext

Injected as a public property like the other admin base services; it cannot live in a trait because startup() touches it first.

Attributes
#[Inject]

$savedEntityId

Id of the record just saved; set by the `$processData` callback in `createForm()` after a successful save.

protected int|null $savedEntityId = null

The apply button (update) uses it: on the add action (new record, no id in the URL) it redirects to editing the new record (edit?id=...). Redirecting to this would lead back to an empty add form and the next apply would create a duplicate. When the callback leaves it null (e.g. a settings form without an edit action), the redirect goes to this.

$translatorDomain

protected string $translatorDomain = 'admin.system.presenters.page'

$customAssetRowsCache

Assets loaded for the current page and mode, cached per request (one presenter instance per request), so defaults and the lookup map share one DB query.

private array<int, CustomAsset>|null $customAssetRowsCache = null

$editedPage

Edited page (null when adding).

private Page|null $editedPage = null

$userPrivileges

private array<int, string> $userPrivileges = []

privileges of the current user loaded in startup()

Methods

actionEdit()

public actionEdit(int $id) : void
Parameters
$id : int

createComponent()

public createComponent(string $name) : IComponent|null
Parameters
$name : string
Return values
IComponent|null

extractCustomAssetRowIds()

Returns the ids from the tab rows (hidden `assetId`).

public extractCustomAssetRowIds(iterable<string|int, mixed> $rows) : array<int, mixed>

Empty rows (added by the user with nothing selected) are skipped so they never reach the normalizer.

Parameters
$rows : iterable<string|int, mixed>
Return values
array<int, mixed>

flashFormOwnErrors()

Flashes form-level errors (`$form->getOwnErrors()`) as `danger` messages.

public flashFormOwnErrors(Form $form) : void

Called from onError of createForm(); public for component forms (AdminComponentFormTrait). Element errors are not flashed; {inputError} renders them at the field.

Parameters
$form : Form

flashRejectedUploads()

Flashes one `warning` listing the files the Api rejected (type, dimensions, unreadable) after a successful save of a form with a dropzone ({@see UploadRejection}).

public flashRejectedUploads(Result $result) : void

The save itself passed and accepted files are stored. The message is already translated (a list of names), so translate = false (see flashFormOwnErrors()). Call it before the redirect, because a flash sent through redirectUrl is lost; public for component forms.

Parameters
$result : Result

formatLayoutTemplateFiles()

Admin version of {@see \App\Core\Traits\Front\Presenters\ThemeInitTrait::formatLayoutTemplateFiles()}.

public formatLayoutTemplateFiles() : array<string|int, mixed>

It starts from AdminPage ($adminPageEntity, column layout), not from the Front $pageEntity, which an admin presenter does not have; admin also has no loggedLayout. The database value wins; getAdminLayout() is the fallback that LoginPresenter overrides with @login.latte.

Return values
array<string|int, mixed>

getContainer()

public getContainer() : Container
Return values
Container

getFormBackUrl()

Returns the stored previous page URL for the key, used by the `cancel` link in the template.

public getFormBackUrl(string|null $key) : string
Parameters
$key : string|null
Return values
string

guardFormSubmitOnce()

Protects a form against a double submit: one rendered form saves at most once.

public guardFormSubmitOnce(Form $form) : void

createForm() applies it to every form of an "add" action (isAddAction()), the component skeleton AdminComponentFormTrait likewise, and forms built outside both call it themselves (product import upload, credit notes, stocktake). A repeated submit of an edit form only saves the same values again, so edits are not guarded.

Adds the hidden token (FormSubmissionGuard::FIELD), issued on every GET render (on POST it comes back from the browser), and data-submit-once for submit-once.js, which blocks a second click in the browser. The server side (runSubmitOnce()) is the authority, because a request can come from outside the browser or the client script may not run. Idempotent.

Parameters
$form : Form

handleChangeLocale()

public handleChangeLocale(string $locale) : void
Parameters
$locale : string

handleEditorCreateFolder()

Creates a subfolder in `folder` (path relative to the editor root).

public handleEditorCreateFolder([string $folder = '' ][, string $name = '' ]) : void
Parameters
$folder : string = ''
$name : string = ''
Attributes
#[Requires]
$methods: 'POST'

handleEditorDelete()

Deletes a file or (recursively) a folder. An empty path would point to the editor root, which cannot be deleted.

public handleEditorDelete([string $path = '' ]) : void
Parameters
$path : string = ''
Attributes
#[Requires]
$methods: 'POST'

handleEditorFiles()

Sends the folder listing for the editor file manager. The `folder` parameter is a path relative to the editor root (empty means the root).

public handleEditorFiles([string $folder = '' ]) : void

Sends JSON {folder, parent, breadcrumb[], folders[], files[]}; paths in the response are again relative to the editor root, and a public URL is given for files only. The server path never leaves the server.

A non-existent folder gives an empty listing, not an error (until something is uploaded the root does not exist physically and the manager just shows the empty state).

Parameters
$folder : string = ''

handleEditorPages()

Sends the page list for the link dialog as JSON `{"pages": [{id, label, url}, ...]}` sorted by label.

public handleEditorPages() : void

Only text pages (EDITOR_PAGE_TARGETS); pages without a filled URL (href) are skipped too, because no link can be built for them.

handleEditorRename()

Renames a file or folder (`path` relative to the editor root).

public handleEditorRename([string $path = '' ][, string $name = '' ]) : void
Parameters
$path : string = ''
$name : string = ''
Attributes
#[Requires]
$methods: 'POST'

handleEditorUpload()

Accepts a file from the editor (field `file`, multipart POST; optional `folder` = subfolder of the editor root) and sends JSON `{"location": "/www/uploads/editorUploads/..."}`, the format TinyMCE expects from `images_upload_handler`.

public handleEditorUpload() : void
Attributes
#[Requires]
$methods: 'POST'

handleLogout()

public handleLogout() : void
Attributes
#[Requires]
$methods: 'POST'

handleSignOut()

public handleSignOut() : void
Attributes
#[Requires]
$methods: 'POST'

hasServiceByType()

Returns whether the container has a service of the given type.

public hasServiceByType(string $className) : bool

The name is composed dynamically (module plus component), so class_exists() runs first, and a true result guarantees a valid type.

Parameters
$className : string
Tags
phpstan-assert-if-true

class-string $className

Return values
bool

initializeTranslator()

public initializeTranslator(string|null $alias) : void
Parameters
$alias : string|null

isAddAction()

Tells whether the current action creates a record: `add` and the `add<Something>` actions (`addMenu`, `addKey`). Derived from the server context only, like {@see formSubmitPrivilege()}.

public isAddAction() : bool
Return values
bool

isAllowed()

Returns whether the logged-in user has the given privilege.

public isAllowed(string $key) : bool

Reads the array loaded in startup(), with no database query. Fail-closed: returns false when loadUserPrivileges() was not called or failed.

Public so templates can call it ($presenter->isAllowed(...)) for conditional display of actions outside DataGrid (e.g. static menu management links).

Parameters
$key : string
Return values
bool

isSubmitOnceForm()

Tells whether the form was protected by {@see guardFormSubmitOnce()}.

public isSubmitOnceForm(Form $form) : bool
Parameters
$form : Form
Return values
bool

loginWithCredentials()

Logs in with username and password; called only by the login form (after validation and CSRF).

public loginWithCredentials(string $username, string $password[, bool $remember = false ]) : void

IMPORTANT: this must not be named handleLogin(). A handle* method is a public signal of every presenter (?do=login&username=...&password=...): the password could end up in the URL and the server log, and the form token would be bypassed. Nette finds signals by the handle prefix only.

Parameters
$username : string
$password : string
$remember : bool = false

persistPageCustomAssetsTab()

public persistPageCustomAssetsTab(bool $mayAssign, array<int, mixed> $rawAssetIds, Page $page, array<string, mixed> $meta, bool $isInsert) : CustomAssetTabSaveOutcome
Parameters
$mayAssign : bool
$rawAssetIds : array<int, mixed>

raw id values from the tab rows (non-empty rows only, see extractCustomAssetRowIds()), ignored entirely when $mayAssign is false

$page : Page
$meta : array<string, mixed>

meta for pageManager->save() (e.g. moveSubtreeToParentId)

$isInsert : bool
Return values
CustomAssetTabSaveOutcome

publishFieldErrors()

Publishes element errors of a failed submit to the client.

public publishFieldErrors(Form $form) : void

IMPORTANT: field errors were visible only where the template has {inputError}; server rules on fields without it stopped the form but showed the user no message.

An AJAX submit sends payload.fieldErrors; a full render sets data-server-field-errors on <body> (see @layout.latte), which the script reads on load. The script avoids duplicating {inputError}.

Parameters
$form : Form

redirectToFormBack()

Redirects to the stored previous page and discards the key.

public redirectToFormBack(string|null $key) : void

Public for component forms (AdminComponentFormTrait), whose save submit calls it through $this->getPresenter().

Parameters
$key : string|null

renderShow()

Front end page list (`/admin/system/page/show`): a tree by parentId/lft with drag and drop, column search and inline update of the sitemap flag.

public renderShow() : void

show is the default action of all admin presenters (see the default action of the fallback route in AdminRouteFactory).

resolveFormBackKey()

Returns the previous-page key: from the URL if present (survives the update redirect), otherwise on a plain GET render of the edit page stores `Referer` in the session under a new random key.

public resolveFormBackKey() : string

Public for component forms (AdminComponentFormTrait); a component reaches it through $this->getPresenter().

Return values
string

runSubmitOnce()

Runs a saving step of a form under its one-time token (a form without the token just runs it).

public runSubmitOnce(Form $form, string $backKey, callable(): bool $save) : bool|null
  • the first submit claims the token and saves; a failed save (false or an exception) releases it, so the corrected form can be sent again; a successful one keeps it with $savedEntityId. A redirect thrown from inside the step counts as a successful save, so the step should set $savedEntityId before redirecting;
  • a submit of an already used token does not run the step, flashes a notice, sets $savedEntityId to the record of the first submit and returns null; the caller leads where the first submit led;
  • a submit arriving while the first one still saves waits for it a few seconds, then behaves as above, or ends on the previous page with a warning (redirect);
  • a missing or malformed token does not run the step; the form gets a fresh token and a message and false is returned (the browser case is a form opened before the protection was deployed).

Public for component forms and form traits outside createForm().

Parameters
$form : Form
$backKey : string
$save : callable(): bool
Return values
bool|null —

true = saved now, false = not saved, null = saved by an earlier submit of the same form

setConfigParameters()

public setConfigParameters([bool $debugMode = false ][, bool $productionMode = false ]) : void
Parameters
$debugMode : bool = false
$productionMode : bool = false

setTranslator()

public setTranslator(ITranslator $translator) : $this
Parameters
$translator : ITranslator
Return values
$this

typedComponent()

Returns a subcomponent with a verified type.

public typedComponent(string $name, T> $type) : T

Use it instead of an inline @var above $this['x'] (which does not narrow the type) and instead of the generic IComponent that $this['x'] returns. See Form::typedComponent().

Parameters
$name : string
$type : T>
Tags
template
Return values
T

addCustomAssetPickerControls()

Adds the picker controls (hidden id plus text label) to a multiplier row.

protected addCustomAssetPickerControls(Container $parent[, string $targetField = 'assetId' ][, string $displayField = 'asset' ]) : void
Parameters
$parent : Container
$targetField : string = 'assetId'
$displayField : string = 'asset'

addCustomAssetTab()

Adds the `customAssets` multiplier to the form, only with the `assign` privilege.

protected addCustomAssetTab(Form $form) : void

Without it the form has no such field: the template skips it by isset() and saving the page does not save the set, see CustomAssetTabSaveTrait.

Parameters
$form : Form

addPageControls()

Adds the page picker controls (hidden id plus text label) to a multiplier row.

protected addPageControls(Container $parent[, string $targetField = 'pageId' ][, string $displayField = 'page' ]) : void
Parameters
$parent : Container
$targetField : string = 'pageId'
$displayField : string = 'page'

addTreePositionFields()

Position fields for the form (default: keep the current place).

protected addTreePositionFields(Container $form) : void
Parameters
$form : Container

authorize()

Authorization hook; by default requires the `:Admin` privilege.

protected authorize() : void

LoginPresenter overrides it so the login page stays reachable for a guest.

authorizeFormSubmit()

Gate for writing presenter forms built by `createForm()`.

protected authorizeFormSubmit(Form $form) : void

IMPORTANT: a form submit is a signal (?do=editForm-submit) that Nette handles on any action, after action*(). A gate in actionAdd()/actionEdit() therefore covers only submits sent to add/edit; a submit sent to a list (show) passes authorizeListing() only, and a save callback without its own gate would write with view-only rights.

Called by createForm() before $processData (only for the update/save buttons) and by custom saving submits outside that gate.

Parameters
$form : Form

authorizeListing()

Gate for reading lists.

protected authorizeListing() : void

IMPORTANT: without this gate anyone inside the admin could open any list without the privilege. The gate lives here once, not in every presenter. The key is derived as in PrivilegeCheckTrait::checkCurrentPrivilege(): :Admin:<Module>:<Presenter>:show.

IMPORTANT: guards only the show action. Other actions have their own gates (add/edit/signals), and a blanket key would not fit them: dashboard, login, downloadPdf, statistics and similar have no ...:<action> key, so the fail-closed check would lock out even the administrator.

NOTE: every show screen needs its key in the privilege table and enabled for the admin role.

buildTreeMoveMeta()

Move meta for `save()` of an existing node; `null` means an invalid choice (the flash is already set, the caller just returns `false`). `[]` means nothing moves.

protected buildTreeMoveMeta(ArrayHash<string|int, mixed> $values, int|null $nodeId, int|null $originalParentId, int|null $newParentId) : array<string, mixed>|null
Parameters
$values : ArrayHash<string|int, mixed>
$nodeId : int|null
$originalParentId : int|null
$newParentId : int|null
Return values
array<string, mixed>|null

checkAdminAccess()

Entry gate to the admin: a guest is sent to login; a logged-in user without `:Admin` is sent to login with an error.

protected checkAdminAccess() : void

checkCurrentPrivilege()

Builds the key from the current request (`:Admin:<Module>:<Presenter>:<action>`) and checks it. `getName()` already contains the `Admin:...` prefix, so only one leading colon is added.

protected checkCurrentPrivilege() : void

Use it where the key matches the action; use explicit checkPrivilege() where it differs (another presenter, add versus edit).

checkPrivilege()

Checks a specific privilege; throws 403 when denied.

protected checkPrivilege(string $key) : void

IMPORTANT: a hidden button is no protection. A hand-built ?...&do=<signal> URL runs the action, so every non-standard action and every mutating signal needs the gate as its first statement; otherwise anyone who types the URL can run it.

IMPORTANT: form actions need two gates, one in the signal and one in process*() (the submit), because a submit arrives as its own request. With only the signal gate the submit stays open. See the WorkList traits.

Parameters
$key : string

createComponentPicker()

protected createComponentPicker() : Multiplier<string|int, Picker>
Return values
Multiplier<string|int, Picker>

createForm()

Creates an edit form with the standard actions and a return to the previous page.

protected createForm(callable(ArrayHash<string|int, mixed>, Form): bool $processData) : Form

Buttons (the template renders them on the right as cancel, update, save):

  • save saves and returns to the previous page,
  • update saves and stays on the edit page (redirect to this),
  • cancel is only a link back, rendered by the template via getFormBackUrl().

On the first load of the edit page (plain GET render, not POST/signal) the previous page is taken from Referer, stored in the session under a random key, and the key goes into the hidden backKey field. It is per form so concurrent tabs do not overwrite each other, and it travels through the update redirect as a URL parameter.

The concrete presenter adds fields and defaults; this method provides the skeleton, buttons and redirects.

Parameters
$processData : callable(ArrayHash<string|int, mixed>, Form): bool

Saves the data; returns success (handles its own flash).

Return values
Form

customAssetLookupMap()

Returns an id to type and placement map only for assets loaded in this request (the tab defaults). A newly selected row (id outside this set) keeps type and placement empty in the template until the page is reloaded.

protected customAssetLookupMap(Page|null $page) : array<int, array{type: string, placement: string}>
Parameters
$page : Page|null
Return values
array<int, array{type: string, placement: string}>

customAssetPicker()

protected customAssetPicker([string $formName = 'editForm' ][, string|null $container = 'customAssets' ][, string $targetField = 'assetId' ][, string $displayField = 'asset' ]) : PickerConfig
Parameters
$formName : string = 'editForm'
$container : string|null = 'customAssets'
$targetField : string = 'assetId'
$displayField : string = 'asset'
Return values
PickerConfig

domainTranslator()

Returns a translator prefixed with the presenter domain, or `null` (empty domain or a translator other than Contributte).

protected domainTranslator() : PrefixedTranslator|null

beforeRender() sets it only on $this->template. Templates created separately through createTemplate() (e.g. modal content built in the handle phase) do not have it, and their relative {_'...'} keys would print raw. Such places obtain it here.

Return values
PrefixedTranslator|null

flashTreeMoveFailure()

Failure message for a save with a tree-specific reason (stale snapshot, lock, invalid target); only when the save really carried a move. `false` means the caller sets its own generic message.

protected flashTreeMoveFailure(Result $result, array<string, mixed> $meta) : bool
Parameters
$result : Result
$meta : array<string, mixed>

meta the save was run with

Return values
bool

formSubmitPrivilege()

Returns the privilege key required to save a form built by `createForm()`.

protected formSubmitPrivilege(Form $form) : string

Derived only from server context (presenter and action), never from a form field, so a changed hidden id cannot select a different right:

  • action add gives ...:add, action edit gives ...:edit;
  • any other action of a presenter with records (it has an add/edit action) gives ...:edit; a record form does not belong there, and whoever sends it needs at least the edit right;
  • a presenter without add/edit actions (single-page settings) gives the key of the current action, i.e. ...:show. Those screens have no other key in RBAC; an unknown action ends on a nonexistent key, which is a 403 (fail-closed).

A form bound to a custom action (sendEmail, inventory, addMenu...) overrides the method in its presenter and returns that action's key, always matched by form name so the exception does not let another form of the same presenter through.

Parameters
$form : Form
Return values
string

getAdminItemsPerPage()

Returns the default items per page of admin lists from the DB setting `admin.itemsPerPage` (module System = 1), falling back to {@see DEFAULT_ITEMS_PER_PAGE}.

protected getAdminItemsPerPage() : int
Return values
int

getAdminLayout()

Returns the layout name; in picker mode ({@see $picker}) the `show` grid uses the minimal `@picker.latte` (no sidebar/header) so the opener fetch returns only the table.

protected getAdminLayout() : string

LoginPresenter overrides it with @login.latte.

Return values
string

getFormBackFallback()

Returns the return URL when the previous page is unknown; override in a presenter without a `show` action.

protected getFormBackFallback() : string
Return values
string

getSessionKey()

Returns a session key string, e.g. 'front.auth.step1'.

protected getSessionKey([string|null $namespace = null ][, string|null $subsection = null ], string ...$extra) : string
Parameters
$namespace : string|null = null

Base namespace (module prefix). Uses SESSION_NAMESPACE if null.

$subsection : string|null = null

Subsection under the namespace. Uses SESSION_SUBSECTION constant if null.

$extra : string

Additional parts to append (e.g. 'step1', 'wizard', etc.).

Return values
string

getSessionSection()

Returns a Nette\SessionSection instance using a dynamically built session key.

protected getSessionSection([string|null $namespace = null ][, string|null $subsection = null ], string ...$extra) : SessionSection
Parameters
$namespace : string|null = null
$subsection : string|null = null
$extra : string
Tags
see
getSessionKey()
Return values
SessionSection

guardColumns()

Gates every text and number field of the form by the real column it writes to ({@see \App\Core\Forms\ColumnGate::guard()}): an oversized value is an error at the field, never a database error that closes the entity manager (admin walkthrough A1, A14).

protected guardColumns(Form $form, array<string, array<int, class-string>> $containers[, array<int, string> $except = [] ]) : void
Parameters
$form : Form
$containers : array<string, array<int, class-string>>

container path ('' = the form, a multiplier name = its rows) => entities

$except : array<int, string> = []

control names never gated (a value transformed before storage)

isSameSiteRequest()

Tells whether the request comes from the own site (Nette SameSite cookie); protects GET actions with a side effect.

protected isSameSiteRequest() : bool

getHttpRequest() returns the IRequest interface, while isSameSite() exists only on Nette\Http\Request.

Return values
bool

loadCustomAssetReadOnlyRows()

Returns the rows for the read-only display (without `assign`), passed straight to the template because the form field does not exist without the privilege.

protected loadCustomAssetReadOnlyRows(Page|null $page) : array<int, array{id: int, name: string, type: string, placement: string}>
Parameters
$page : Page|null
Return values
array<int, array{id: int, name: string, type: string, placement: string}>

loadCustomAssetTabDefaults()

Returns the multiplier defaults: the codes assigned to the page when editing, the codes with `addToNewPages = 1` when adding.

protected loadCustomAssetTabDefaults(Page|null $page) : array<int, array{assetId: string, asset: string}>
Parameters
$page : Page|null
Return values
array<int, array{assetId: string, asset: string}>

loadUserPrivileges()

Loads all privileges of the logged-in user with one database query. Call it right after `checkAdminAccess()` in `startup()` (the user is guaranteed to be logged in by then).

protected loadUserPrivileges() : void

mayAssignCustomAssets()

Whether the user may change the set (picker, add, remove).

protected mayAssignCustomAssets() : bool
Return values
bool

mayEditCustomAssetInLibrary()

Whether the user may open a code for editing in the library (the edit link).

protected mayEditCustomAssetInLibrary() : bool
Return values
bool

mayShowCustomAssets()

Whether the user may see the tab at all (read-only included).

protected mayShowCustomAssets() : bool
Return values
bool

pageMultiplierPicker()

Page picker for a multiplier (several pages in one form, e.g. targeting an advert at specific pages). Unlike {@see pagePicker()}, it addresses the hidden field inside the multiplier container and carries a text `displayField`, so the label survives the AJAX re-render of the row. The row is built by {@see addPageControls()}.

protected pageMultiplierPicker([string $formName = 'editForm' ][, string $container = 'pages' ][, string $targetField = 'pageId' ][, string $displayField = 'page' ]) : PickerConfig
Parameters
$formName : string = 'editForm'

form name (editForm)

$container : string = 'pages'

name of the multiplier container (pages)

$targetField : string = 'pageId'

name of the hidden control in the row (pageId)

$displayField : string = 'page'

name of the text label control in the row (page)

Return values
PickerConfig

pagePicker()

protected pagePicker(string $formName, string $targetField[, int|null $excludeId = null ][, int|null $excludeSubtreeLft = null ][, int|null $excludeSubtreeRgt = null ]) : PickerConfig
Parameters
$formName : string

form name with the hidden field (editForm)

$targetField : string

name of the hidden control (parentId)

$excludeId : int|null = null

id that must not be selected (self-reference); excluded from the suggestions and the modal (passed to the show grid via pickerExclude)

$excludeSubtreeLft : int|null = null

lft of the edited node, to exclude the whole subtree

$excludeSubtreeRgt : int|null = null

rgt of the edited node, to exclude the whole subtree

Return values
PickerConfig

pickers()

Returns the presenter pickers (multicontrol); pure configuration, also callable during the AJAX signal `suggest!`. `parentId` is the self-reference to `Page` (suggest plus a modal with the `Page` `show` grid); `customAsset` is the custom code tab (pick from the library).

protected pickers() : array<string, PickerConfig>
Return values
array<string, PickerConfig>

savePageEntity()

Seam: saves the page entity. Override in a test to avoid touching the DB.

protected savePageEntity(Page $page, array<string, mixed> $meta) : Result
Parameters
$page : Page
$meta : array<string, mixed>
Return values
Result

setupTemplateTranslator()

Sets a translator prefixed with the presenter domain into the template (as Front components do, see {@see \App\Core\Base\BaseComponent::setup()}).

protected setupTemplateTranslator() : void

Templates then use short keys {_'key'} resolved as <translatorDomain>.key without {translator}. Shared keys in the layout are written absolutely with the // prefix, which bypasses the domain. The domain comes from the $translatorDomain property of the concrete presenter (admin.system.presenters.<presenter>).

syncPageCustomAssets()

Seam: syncs the page code set (`api/system/custom-asset/sync-page`).

protected syncPageCustomAssets(int $pageId, array<int, int> $assetIds) : Result
Parameters
$pageId : int
$assetIds : array<int, int>
Return values
Result

addBehaviorFields()

Visibility and behavior switches of the page.

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

addCssField()

CSS files of the page: multiselect of theme CSS files ({@see \App\UI\Admin\System\Models\Managers\PageManager::scanTemplateCssFiles()}), stored as a comma-separated list of names. Degrades to a text input without files.

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

addLayoutField()

Layout field: select of layout files of the active front-end theme ({@see \App\UI\Admin\System\Models\Managers\PageManager::scanTemplateLayoutFiles()}).

private addLayoutField(Form $form, string $name, bool $required) : void

Options are file names, so the control translator is off and the label is translated by hand. Degrades to a text input when the theme offers no file, so the form stays usable.

Parameters
$form : Form
$name : string
$required : bool

addNavigationFields()

Navigation and structure: parent page (picker) and theme layout files.

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

addRouteFields()

Routes assigned to the page: multiselect filled through {@see \App\UI\Admin\System\Models\Managers\RouteManager}.

private addRouteFields(Form $form) : void

Options are technical strings (module + presenter:action), so the control translator is off and the label is translated by hand.

Parameters
$form : Form

addSeoFields()

SEO: update frequency and sitemap priority.

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

addTechnicalFields()

Technical settings: CSS files (multiselect), HTML class, internal notes.

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

addTranslationFields()

Multilingual fields: one set per language (`<field>_<langId>`), active by checkbox.

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

applyRoutes()

Overwrites the M:N relation of the page to routes by the ids selected in the multiselect.

private applyRoutes(Page $page, ArrayHash<string|int, mixed> $values) : void

Routes are loaded through RouteManager (InFilter) so that real references are stored (Doctrine synchronizes the join table cms_system_page_route_rel).

Parameters
$page : Page
$values : ArrayHash<string|int, mixed>

buildCustomAssetsTabTemplateData()

Builds the template data of the custom code tab; `null` means the tab is not rendered at all (no `show` privilege). With the `assign` privilege the template renders an editable multiplier (the form field exists); without it only read-only rows (`readOnlyRows`), and the form does not save the assignments.

private buildCustomAssetsTabTemplateData(Page|null $page) : array{mayAssign: bool, mayEditInLibrary: bool, lookup: array, readOnlyRows: list}|null
Parameters
$page : Page|null
Return values
array{mayAssign: bool, mayEditInLibrary: bool, lookup: array, readOnlyRows: list}|null

buildPageEntity()

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

buildRouteMenuProblemMessage()

Builds the finished message text (no translation key); {@see BaseControl::addError()} receives it with `translate: false`.

private buildRouteMenuProblemMessage(array<int, array{route: string, params: list, lang: string|null}> $problems) : string
Parameters
$problems : array<int, array{route: string, params: list, lang: string|null}>
Return values
string

collectRouteIds()

Returns ids of routes assigned to the page (to prefill the multiselect on edit).

private collectRouteIds(Page $page) : array<int, int>
Parameters
$page : Page
Return values
array<int, int>

collectRouteMenuProblems()

Decides, for every selected route, what exactly would break the menu link.

private collectRouteMenuProblems(array<int, Route> $routes, ArrayHash<string|int, mixed> $values) : array<int, array{route: string, params: list, lang: string|null}>

Unsatisfiable non-slug parameters (name, id, order_id, ...) are always a problem because the menu never supplies them. A missing slug is a problem only for languages whose href_<langId> is empty in the submitted form; all form languages are checked, not only those with the active checkbox, because Link.latte reads href regardless of active.

Parameters
$routes : array<int, Route>
$values : ArrayHash<string|int, mixed>
Return values
array<int, array{route: string, params: list, lang: string|null}>

createIdentity()

private createIdentity(array<string, mixed> $payload, string $token) : SimpleIdentity|null
Parameters
$payload : array<string, mixed>
$token : string
Return values
SimpleIdentity|null

createMultiplierComponent()

Creates a multiplier for the component.

private createMultiplierComponent(string $name) : Multiplier<string|int, IComponent>
Parameters
$name : string
Return values
Multiplier<string|int, IComponent>

createNewComponentInstance()

Creates a new component instance without adding it to the presenter; used by the multiplier.

private createNewComponentInstance(string $baseName[, int|string|null $uniqueKey = null ]) : IComponent|null
Parameters
$baseName : string
$uniqueKey : int|string|null = null
Return values
IComponent|null

createStandardComponent()

Creates a standard component (not a multiplier).

private createStandardComponent(string $name) : IComponent|null
Parameters
$name : string
Return values
IComponent|null

cssToString()

Converts the CSS field value to the stored string: the multiselect returns a name array (joined by commas), the text input a plain string.

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

editorBreadcrumb()

Builds the breadcrumb navigation: cumulative segment paths.

private editorBreadcrumb(string $relative) : array<int, array{label: string, path: string}>
Parameters
$relative : string
Return values
array<int, array{label: string, path: string}>

editorLinkLangId()

Returns the language used to pick labels and URLs (default 1, Czech).

private editorLinkLangId() : int
Return values
int

editorPageLabel()

Returns the page label: title, otherwise name, otherwise `#id`.

private editorPageLabel(Page $page, int $langId) : string
Parameters
$page : Page
$langId : int
Return values
string

editorPageRoute()

Returns the first page route the editor may link to. A page may have several (many-to-many); the whitelisted one is taken, not the first in order, so a page with both `Page:show` and `Page:form` ends up on the right one.

private editorPageRoute(Page $page) : Route|null
Parameters
$page : Page
Return values
Route|null

editorPageUrl()

Returns the front end address of a page. The router builds it from the page route, so `/o-nas` and any prefix come out on their own.

private editorPageUrl(Page $page, int $langId) : string|null
Parameters
$page : Page
$langId : int
Return values
string|null —

null when the page is not a text page (see EDITOR_PAGE_TARGETS), has no filled URL, or its route cannot build a link

editorParentFolder()

Returns the parent folder (null in the editor root).

private editorParentFolder(string $relative) : string|null
Parameters
$relative : string
Return values
string|null

editorPath()

Converts a client path (relative to the editor root) to an Api path (relative to the `uploads/` root).

private editorPath(string $relative) : string|null

This is the only place where the prefix is added, so the segment check lives here too. The Api rejects .. as well, but without this check a ../ from the request would not escape uploads/ yet would escape editorUploads/ into neighboring folders of other modules.

Parameters
$relative : string
Return values
string|null —

null when the path contains a forbidden segment

editorUploadName()

Builds a safe and unique file name. Sanitization copies the Api layer rules (webalize of the base and of the extension), so the name returned in the URL is exactly the name the file is stored under. The random suffix prevents collisions: `writeFile()` overwrites the same name without asking, so two different `obrazek.jpg` files would overwrite each other.

private editorUploadName(string $untrustedName) : string|null
Parameters
$untrustedName : string
Return values
string|null —

null for a forbidden extension or an unusable name

editorUploadUrl()

Returns the public URL of a file. `$path` is relative to the `uploads/` root (so it includes `editorUploads/`), the same shape as other uploads in the system.

private editorUploadUrl(string $path) : string
Parameters
$path : string
Return values
string

ensureEditorRoot()

Creates the editor root folder; when it already exists the Api returns false and nothing happens.

private ensureEditorRoot() : void

expireIdleLogin()

Returns whether the login expired from inactivity. If so, revokes the tokens (like a logout), clears the `auth` section, logs out the Nette identity and returns true; otherwise moves the activity stamp forward.

private expireIdleLogin(AuthSessionStorage $authStorage) : bool

Admin keeps 30 min, or 8 h with its own "remember me", regardless of the front end "remember me" (the auth section is shared, its 31 days do not count here). An expiry in admin logs out of the front end too (one session).

Parameters
$authStorage : AuthSessionStorage
Return values
bool

findPageByHref()

Returns a page with the same `href` in the given language (other than the edited one).

private findPageByHref(string $href, int $langId, int|null $excludeId) : Page|null

The translations.href filter matches pages having the address in any language (the dotted path is auto-joined, see pageIsInMenu()), so the language match is confirmed on the loaded translations; two filters over one collection would not guarantee the same row.

Parameters
$href : string
$langId : int
$excludeId : int|null
Return values
Page|null

getEditedPageId()

Returns the edited page id (>0) for excluding the self-reference in the picker; null when adding.

private getEditedPageId() : int|null
Return values
int|null

getFormLanguages()

Returns languages for the multilingual form fields (admin `LanguageManager`).

private getFormLanguages() : array<int, Language>
Return values
array<int, Language>

initializeMetaTags()

Fills the template with the title, meta tags and HTML text of the page from the translation (`PageText`) of the current language, for the layout (like the Front {@see \App\Core\Traits\Front\Presenters\PageInitTrait}).

private initializeMetaTags(AdminPage|null $adminPageEntity) : void

When the page or translation is missing, the values are empty strings and the layout uses its fallbacks.

Parameters
$adminPageEntity : AdminPage|null

languageLabel()

Short language code for the message (`cs`, `en`), not the full name: technical context of the route choice.

private languageLabel(Language $language) : string
Parameters
$language : Language
Return values
string

loadCustomAssetTabEntities()

Loads the assets relevant to `$page` in one query, shared by defaults, the lookup map and the read-only list (cached on the presenter instance).

private loadCustomAssetTabEntities(Page|null $page) : array<int, CustomAsset>
Parameters
$page : Page|null
Return values
array<int, CustomAsset>

localizationCurrencyKey()

Admin ignores the localization currency (it takes the language only).

private localizationCurrencyKey(object $localization) : string|null
Parameters
$localization : object
Return values
string|null

loginReturnArgs()

Remembers the request of a logged-out user so the login can return to it ({@see storeRequest()}, `backlink` of the login page, restored by `AuthStorageTrait::redirectAfterLoginAction()`).

private loginReturnArgs() : array<string, string>

Without it a save sent after a logout in another tab (or after the idle timeout) ended on the login page with no explanation, the login led to the dashboard and the filled-in form was lost. A restored POST renders the form again with the submitted values, but Nette does not process it (Request::RESTORED, no blind replay): the admin checks the values and saves once more. An AJAX request is not stored (naja would replay it as a page). The user id stored with the request is the previous identity, so a different account logging in is not sent there.

Return values
array<string, string>

pageIsInMenu()

Tells whether the page `$pageId` is linked in any menu. Only existence, not the item: `cms_system_menu_items.cms_system_pages_page_id` filtered through the `page.id` association ({@see EqualFilter} auto-joins the dotted path, like `CategoryManager::findAll()` does for `'translations.href'`).

private pageIsInMenu(int $pageId) : bool
Parameters
$pageId : int
Return values
bool

pageLabel()

private pageLabel(Page $page, int $langId) : string
Parameters
$page : Page
$langId : int
Return values
string

pageTitleForLang()

Returns the colliding page label for the message: title, else name, else `#id`.

private pageTitleForLang(Page $page, int $langId) : string
Parameters
$page : Page
$langId : int
Return values
string

parsePickerName()

Splits a picker instance name into the config key plus row indexes (multiplier and nested multiplier). `parentId` -> `['parentId', []]`; `address_2` -> `['address', ['2']]`; `parameter_1_0` -> `['parameter', ['1','0']]` (nested).

private parsePickerName(string $name) : array{0: string, 1: list}

The separator is an underscore, not a dash: - is the component path separator in Nette ({control picker-address_0} = Multiplier picker -> child address_0). A config key must not end with _<number> (keys: parentId, address, parameter).

Parameters
$name : string
Return values
array{0: string, 1: list}

prepareCssOptions()

CSS multiselect options: theme files plus names stored on the page (on edit), even when the file has disappeared.

private prepareCssOptions() : array<string, string>
Return values
array<string, string>

prepareLayoutOptions()

Layout select options: theme files plus the values stored on the page (on edit), even when the file has disappeared, so the select can still be prefilled.

private prepareLayoutOptions() : array<string, string>
Return values
array<string, string>

prepareRouteOptions()

Options of the route multiselect: `id => "module presenter:action"`, alphabetical.

private prepareRouteOptions() : array<int, string>
Return values
array<int, string>

processLogin()

private processLogin(string $username, string $password[, bool $remember = false ]) : void
Parameters
$username : string
$password : string
$remember : bool = false

processLoginException()

private processLoginException(Exception $e) : void
Parameters
$e : Exception

readLoginDeviceToken()

Returns the raw known-device cookie for the Api login (the Api verifies its signature).

private readLoginDeviceToken() : string|null
Return values
string|null

redirectAfterLoginAction()

After a login attempt: a successful login returns to the request remembered before the login (`backlink`, {@see PrivilegeCheckTrait::loginReturnArgs()}), otherwise to the dashboard; a failed one stays on the login page and keeps the way back.

private redirectAfterLoginAction() : void

redrawCustomAssetTab()

Redraws the tab rows.

private redrawCustomAssetTab() : void

The customAssets snippet lives in an included template (Page/parts/custom-assets.latte), so the wrapping {snippetArea customAssetsArea} in Page/edit.latte must be redrawn too; otherwise Latte does not find the snippet in the AJAX response and the added row silently does not appear.

refreshNetteIdentity()

Refreshes the token of the same logged-in user: identity data (token, name, email) are overwritten in the stored object without `login()`, so neither the session id nor the form CSRF tokens change. The identity is stored in the session section as an object; the change is written at the end of the request.

private refreshNetteIdentity(array<string, mixed> $payload, string $token) : bool
Parameters
$payload : array<string, mixed>
$token : string
Return values
bool —

false when impossible (nobody logged in or another user); the caller uses login

rememberLoginDevice()

After a successful login (password or OAuth) issues or renews the known-device cookie ({@see LoginDeviceCookie}): a signed proof that this browser has already logged in to the account. The next login sends it to the Api ({@see self::processLogin()}), and above the account limit the password from this browser is still verified, so foreign attempts do not lock out the owner. HttpOnly, SameSite=Lax, Secure on HTTPS; lifetime from `ratelimit.loginDevice.cookieLifetime`.

private rememberLoginDevice(mixed $payload) : void
Parameters
$payload : mixed

reportCustomAssetTabFailure()

Adds a danger flash (and an optional log entry) and returns false; shared by all failed tab-save results.

private reportCustomAssetTabFailure(string $messageKey[, string|null $logMessage = null ]) : bool
Parameters
$messageKey : string
$logMessage : string|null = null
Return values
bool

reportCustomAssetTabSuccess()

Adds a success flash plus `savedEntityId` (for `apply`) and returns true.

private reportCustomAssetTabSuccess(Page $page) : bool
Parameters
$page : Page
Return values
bool

resolveCustomAssetLabel()

private resolveCustomAssetLabel(int $id) : string|null
Parameters
$id : int
Return values
string|null

resolveLoginErrorMessage()

Resolves the flash message of a failed login.

private resolveLoginErrorMessage(Result $result) : string

IMPORTANT: a brute-force throttle must not be shown as "wrong password"; the limit would then look like an inexplicably failing form.

results.rateLimitExceeded (the generic text of ResultCode) carries no seconds and does not belong to login. The login flow therefore has its own key in the same family as admin.general.login.error.message: login.rateLimit.message, with the seconds passed as %count% (Contributte: numeric 2nd argument).

The Api sends retryAfter in data (AuthPresenter::rateLimitedResult()); the internal bridge call does not see the Retry-After header.

Parameters
$result : Result
Return values
string

resolvePageLabel()

Label to prefill on edit (from the hidden value).

private resolvePageLabel(int $id) : string|null
Parameters
$id : int
Return values
string|null

revokeTokensOnLogout()

Calls the Api logout (revokes the refresh family and deny-lists the access `jti`) for the tokens of the current session. Fail-open on purpose: any failure is only logged, because the local logout must not stay unfinished.

private revokeTokensOnLogout(AuthSessionStorage $authStorage, mixed $userId) : void
Parameters
$authStorage : AuthSessionStorage
$userId : mixed

saveEditForm()

Saves the form data. The redirect is done by {@see \App\Core\Base\Admin\BasePresenter::createForm()} according to the pressed button.

private saveEditForm(ArrayHash<string|int, mixed> $values) : bool

A parentId change of an existing page is reported by the Api through meta['moveSubtreeToParentId'], so the lft/rgt/level recalculation of the whole subtree runs in the same transaction as the parent_id write.

Parameters
$values : ArrayHash<string|int, mixed>
Return values
bool —

true when the page was saved

savePageWithCustomAssets()

Saves the page and then its own custom code set (the "custom code" tab). The decision logic (what to call, in which order, how to react to failure) lives in {@see CustomAssetTabSaveTrait::persistPageCustomAssetsTab()}; here the result is only mapped to flash messages.

private savePageWithCustomAssets(ArrayHash<string|int, mixed> $values, Page $page, array<string, mixed> $meta, bool $isInsert) : bool
Parameters
$values : ArrayHash<string|int, mixed>
$page : Page
$meta : array<string, mixed>
$isInsert : bool

true when the page was created in this request

Return values
bool

setCustomAssetTabDefaults()

Defaults of the custom code tab: set on the whole form (`setDefaults`), not `setValues` on the multiplier container. Edit = codes assigned to the page; add = codes with `addToNewPages = 1`. Without the `assign` privilege the field does not exist in the form ({@see CustomAssetTabTrait::addCustomAssetTab()}), so `setDefaults()` silently skips the key.

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

setNetteUser()

private setNetteUser(array<string, mixed>|null $payload, string $token) : void
Parameters
$payload : array<string, mixed>|null
$token : string

splitCss()

Splits the stored comma-separated CSS string into file names.

private splitCss(string|null $css) : array<int, string>
Parameters
$css : string|null
Return values
array<int, string>

storeEditorUpload()

Stores a file; the target folder may not exist (first upload into the root), so after a failure the root is created once and the write is retried. Deeper subfolders are created by the editor user through `editorCreateFolder`.

private storeEditorUpload(string $folder, string $name, string $base64) : bool
Parameters
$folder : string
$name : string
$base64 : string
Return values
bool

str()

Safely converts a mixed form value to string (NEON/ArrayHash).

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

suggestCustomAssets()

Suggestions: `LIKE` on `name`, label "name (type, placement)".

private suggestCustomAssets(string $query) : array<int, array{id: int, label: string}>
Parameters
$query : string
Return values
array<int, array{id: int, label: string}>

suggestPages()

Suggestions: `OR LIKE` over the page name and title, optionally without the excluded node and its whole subtree (a page must not be its own parent or the parent of its descendant).

private suggestPages(string $query[, int|null $excludeId = null ][, int|null $excludeSubtreeLft = null ][, int|null $excludeSubtreeRgt = null ]) : array<int, array{id: int, label: string}>
Parameters
$query : string
$excludeId : int|null = null
$excludeSubtreeLft : int|null = null
$excludeSubtreeRgt : int|null = null
Return values
array<int, array{id: int, label: string}>

tr()

Translates a key in the form domain to a finished string (for fields with `setTranslator(null)`).

private tr(string $key) : string
Parameters
$key : string
Return values
string

trCustomAssetPickerOption()

Translates an absolute key; the trait is used in presenters with different domains.

private trCustomAssetPickerOption(string $key) : string
Parameters
$key : string
Return values
string

trCustomAssetTabKey()

Translates an absolute key shared with the library (`CustomAssetFormTrait`), not duplicated.

private trCustomAssetTabKey(string $key) : string
Parameters
$key : string
Return values
string

tryRefresh()

Tries an auto-refresh for an expired access token. If the session holds a refresh token and the Api accepts it, stores the new pair in the session and returns true; otherwise returns false and the caller cancels the session.

private tryRefresh(AuthSessionStorage $authStorage) : bool
Parameters
$authStorage : AuthSessionStorage
Return values
bool

validateHrefUniqueness()

Requires the `href` to be unique within one language.

private validateHrefUniqueness(ArrayHash<string|int, mixed> $values) : bool

IMPORTANT: the router derives the page id from the slug through slugToId[language][href] = pageId (PageSlugTranslator). On a collision the last written page overrides the previous one, which becomes unreachable on the website, while idToSlug still generates the same address for both: a redirect after an action leads to the wrong page and no error appears.

The check is global on purpose (across modules and tree branches) because the router map is one per language. An empty href is not checked; such a page is not in the map.

Parameters
$values : ArrayHash<string|int, mixed>
Return values
bool

validateRouteMenuCompatibility()

Blocks a route whose mask needs a parameter the menu cannot fill.

private validateRouteMenuCompatibility(ArrayHash<string|int, mixed> $values) : bool

A page placed in the menu (cms_system_menu_items) gets such a route, and the menu would crash: MenuComponent passes only slug (from the page translation href) to safeLink() (\App\UI\Front\System\Components\MenuComponent\Templates\Default\parts\Link.latte). SafeLinkExtension would degrade the link to '#', but that is a safety net, not a goal.

IMPORTANT: the boundary is "the page is in the menu", not "the route has parameters". Parametric routes (for example article detail with name and id) are legitimate: the list component supplies the parameters and no link is generated from the menu context. A general "route has an unsatisfiable parameter" check would forbid that widely used pattern. A new page ($this->editedPage === null) cannot be in the menu, because the menu links an existing page_id (MenuItemFormTrait), so the check is skipped on add.

Every selected route is checked, not only getRoutes()->first() that the menu really uses: the order of the stored collection is not the order of the multiselect selection.

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

Search results