Documentation

MediaDirectoryInputfield extends MediaDirectoryLibrary

AbstractYes

Media Directory Library

Tags
copyright

Cloudrexx AG

author

Cloudrexx Development Team info@cloudrexx.com

author

Thomas Wirz thomas.wirz@cloudrexx.com

subpackage

module_mediadir

Table of Contents

Properties

$_objTpl  : mixed
$arrCommunityGroups  : mixed
$arrFrontendLanguages  : mixed
$arrPlaceholders  : array<string|int, mixed>
$arrSettings  : mixed
$moduleConstVar  : mixed
$moduleLangVar  : mixed
$moduleName  : mixed
$moduleNameLC  : mixed
$moduleTablePrefix  : mixed
$pageContent  : mixed
$strJavascript  : mixed
$category  : mixed
$currentFetchedEntryDataObject  : MediaDirectoryEntry
Holds the MediaDirectoryEntry object with the most recently loaded entries (using MediaDirectoryEntry::getEntries())
$cx  : mixed
$defaultFieldTemplatetKey  : string
Key to reference the default component or context templates in {@see static::$fieldTemplates}.
$fieldTemplates  : array<string|int, mixed>
List of templates to be used for parsing title and content data of entries.
$fieldTemplateScopes  : array<string|int, mixed>
Available scopes to be used as field templates.
$form  : mixed
$guiPreSelectsValue  : bool
$inputFieldMetaData  : array<string|int, mixed>
Temporary container for the meta-data of the input fields.
$level  : mixed
$outputLocale  : Locale
The locale in which the output shall be parsed for
$settings  : array<string|int, mixed>
List of the component's configuration
$slugConversions  : mixed
$slugs  : array<string|int, mixed>
Contains a list of all existing slugs
$type  : string
$usedFrontendLocales  : array<string|int, mixed>
Two-dimensional array of activated frontend locales

Methods

__construct()  : mixed
Constructor
buildDropdownmenu()  : mixed
checkAccess()  : mixed
checkDisplayduration()  : mixed
createFormOnSubmitScript()  : mixed
deleteContent()  : bool
fetchMediaDirListConfigFromTemplate()  : array<string|int, mixed>
Fetch config from template
generateEntrySlugs()  : mixed
Provides each entry (and the form it is based on) with a slug field and a slug value, both only if the entry/form doesn't already have it Is called when usePrettyUrls is activated or a form has been modified, to make sure the resolving of the entries works correctly.
getApplicationPageByCategory()  : mixed
getApplicationPageByEntry()  : mixed
getApplicationPageByLevel()  : mixed
getApplicationPageByLevelAndCategory()  : mixed
getAutoSlugPath()  : Url
Get the human readable url for a mediadir location
getCategoryData()  : mixed
getCategorySlugPath()  : mixed
getCommunityGroups()  : mixed
getContent()  : array<string|int, mixed>
getFieldData()  : array<string|int, mixed>
Get definitions of inputfields.
getFormData()  : mixed
getFormOnSubmit()  : string
getFrontendLanguages()  : mixed
getInputfield()  : string
getJavascript()  : mixed
getJavascriptCheck()  : string
getLevelData()  : mixed
getLevelSlugPath()  : mixed
getMediaBrowserButton()  : string
Get mediabrowser button
getNameFromSlug()  : mixed
getOutputLocale()  : Locale
Get locale in which output shall be parsed for
getQueryToFindPrimaryInputFieldId()  : string
Get SQL statement to fetch the ID of the primary field of a form.
getRawData()  : string
getSelectorJavascript()  : mixed
getSelectorOrder()  : mixed
getSelectorSearch()  : array<string|int, mixed>
Get setting if levels or categories shall be included in extended search functionality of a specific form.
getSettings()  : mixed
getSlugFromName()  : mixed
getThumbImage()  : string
Get the Thumbnail image path from given file Thumbnail will be created it is not exists
getUploadedFilePath()  : bool|string
Get uploaded file path by using uploader id and file name
saveInputfield()  : string
setJavascript()  : mixed
addSlugFieldToForm()  : int
Add a new inputfield to a form and set its context type to 'slug'.
enforceUniqueSlug()  : mixed
Enforce uniqueness of a slug
flushInputFieldMetaDataByFormId()  : mixed
Flush cache of input-field meta-data of a specific form
flushSettings()  : mixed
flushUsedFrontendLocales()  : mixed
Flush cached list of used frontend locales
getApplicationPageByForm()  : mixed
getCurrentFetchedEntryDataObject()  : mixed
getCustomFormatDefinition()  : string
Get the FieldTemplate (HTML-Code) (from {@see static::getCustomFormatTemplates()}) for $scope that best matches $component, $context and $formId.
getCustomFormatTemplates()  : array<string|int, mixed>
Load and return the custom format templates
getMainApplicationPage()  : mixed
getQueryToFindInputFieldIdByContextType()  : string
Get SQL statement to fetch the ID of the field of a form identified by its context.
getSourceLocaleIdForTargetLocale()  : int
Get the source locale of a target locale
initI18nEntryData()  : void
Initialize the multilingual data of all existing entries associated to form identified by `$formId`. This will insert empty datasets into the database for each inputfield of `$formId` that is a multilingual field (`type_multi_lang = 1`).
initOutputLocale()  : Locale
Determine the locale in which the output shall be parsed for.
loadAllSlugsFromDb()  : mixed
Fetch all slugs from the database
parseGoogleMapPlaceholder()  : mixed
setCurrentFetchedEntryDataObject()  : mixed
slugify()  : mixed
Slugifies the given string and ensures its uniqueness

Properties

$arrPlaceholders

public array<string|int, mixed> $arrPlaceholders = ['TXT_MEDIADIR_INPUTFIELD_NAME', 'MEDIADIR_INPUTFIELD_VALUE']

List of placeholders this inputfield type provides.

$currentFetchedEntryDataObject

Holds the MediaDirectoryEntry object with the most recently loaded entries (using MediaDirectoryEntry::getEntries())

protected static MediaDirectoryEntry $currentFetchedEntryDataObject = null

$defaultFieldTemplatetKey

Key to reference the default component or context templates in {@see static::$fieldTemplates}.

protected static string $defaultFieldTemplatetKey = 'default'

$fieldTemplates

List of templates to be used for parsing title and content data of entries.

protected static array<string|int, mixed> $fieldTemplates = []

$fieldTemplateScopes

Available scopes to be used as field templates.

protected static array<string|int, mixed> $fieldTemplateScopes = ['title', 'content']

Those are currently only title (Title.html) and content (Content.html).

$inputFieldMetaData

Temporary container for the meta-data of the input fields.

protected static array<string|int, mixed> $inputFieldMetaData = array()

This is used to reduce the amount of queries made to the database system.

$slugs

Contains a list of all existing slugs

protected static array<string|int, mixed> $slugs = array()

Is being used to ensure uniqueness within slugs.

$usedFrontendLocales

Two-dimensional array of activated frontend locales

protected static array<string|int, mixed> $usedFrontendLocales = array()

Contains array-data of the frontend locales that have been activated in the settings section.

Methods

buildDropdownmenu()

public buildDropdownmenu(mixed $arrOptions[, mixed $intSelected = null ]) : mixed
Parameters
$arrOptions : mixed
$intSelected : mixed = null

createFormOnSubmitScript()

public createFormOnSubmitScript(mixed $arrScripts) : mixed
Parameters
$arrScripts : mixed

deleteContent()

public deleteContent(int $entryId, int $fieldId) : bool
Parameters
$entryId : int
$fieldId : int
Tags
todo

Implement DocBlock

Return values
bool

fetchMediaDirListConfigFromTemplate()

Fetch config from template

public static fetchMediaDirListConfigFromTemplate(string $block, Sigma $template[, int $formId = null ][, int $categoryId = null ][, int $levelId = null ]) : array<string|int, mixed>

Identity functional placeholders in the block $block of template $templatet that will act as config options to be applied on the listing of entries. Placeholders can have the following form:

  • MEDIADIR_CONFIG_LIST_LATEST => Order by latest addition
  • MEDIADIR_CONFIG_LIST_LIMIT_<limit> => Limit the listing
  • MEDIADIR_CONFIG_LIST_OFFSET_<offset> => Start listing at offset
  • MEDIADIR_CONFIG_FILTER_FIELD_<field>_(EQ|GE|GT|LE|LT|NE)_<value> => filter by field having ID <field> and <value> using equal (EQ), greater equal (GE), greater than (GT), lower equal (LE), lower than (LT) or not equal (NE) operation
  • MEDIADIR_CONFIG_FILTER_FORM_<id> => filter by form
  • MEDIADIR_CONFIG_FILTER_CATEGORY_<id> => filter by category
  • MEDIADIR_CONFIG_FILTER_LEVEL_<id> => filter by level
  • MEDIADIR_CONFIG_FILTER_ASSOCIATED => filter associated entries
  • MEDIADIR_CONFIG_FILTER_AUTO => filter by supplied arguments as default
  • MEDIADIR_CONFIG_SORT_POPULAR => order entries by popularity
  • MEDIADIR_CONFIG_SORT_ALPHABETICAL => order entries alphabetically
  • MEDIADIR_CONFIG_SORT_BY_<field>_(ASC|DESC) => order entries by field having ID <field>
  • MEDIADIR_CONFIG_FUNC_<func> => function specific config. Known usages are:
    • MEDIADIR_CONFIG_FUNC_FIELD_<field>_FILTER_BY_OR => apply OR-filter (instead of AND-filter) on field having ID <field>
    • MEDIADIR_CONFIG_FUNC_FALLBACK_LINK_MYSELF_AS_CATEGORY => Use current page as fallback-link in case no matching category application page is present
    • MEDIADIR_CONFIG_FUNC_FALLBACK_LINK_MYSELF_AS_LEVEL => Use current page as fallback-link in case no matching level application page is present
  • MEDIADIR_CONFIG_FUNC_<func>[_<int>] => function specific config with value set to <int>
Parameters
$block : string

Name of the template block to look up for functional placeholders

$template : Sigma

Template object where the block $block is located in

$formId : int = null

If supplied and filter MEDIADIR_CONFIG_FILTER_AUTO is present, then do set filter form to $formId

$categoryId : int = null

If supplied and filter MEDIADIR_CONFIG_FILTER_AUTO is present, then do set filter category to $categoryId

$levelId : int = null

If supplied and filter MEDIADIR_CONFIG_FILTER_AUTO is present, then do set filter level to $levelId

Return values
array<string|int, mixed>

Multi-dimensional array containing the fetched config having the following structure:

[
    'list' => [
         'latest' => true,
         'limit' => <int:limit>,
         'offset' => <int:offset>,
    ],
    'filter' => [
         'field' => [
             <int:fieldId>' => [
                 (EQ|GE|GT|LE|LT|NE) => <string:filter_value>,
             ],
         ],
         'form' => <int:formId>,
         'category' => <int:categoryId>,
         'level' => <int:levelId>,
         'associated' => true,
    ],
    'sort' => [
        'alphabetical' => true,
        'popular' => true,
        'by' => [
            <int:fieldId> => (ASC|DESC),
        ],
    ],
    'func' => [
        '<string:func>' => (true|<int>),
    ],
]

Note: the sub entries of list, filter, sort and func are only set in case any of the associated placeholders are present in the specified template block.

generateEntrySlugs()

Provides each entry (and the form it is based on) with a slug field and a slug value, both only if the entry/form doesn't already have it Is called when usePrettyUrls is activated or a form has been modified, to make sure the resolving of the entries works correctly.

public generateEntrySlugs([int $formId = 0 ]) : mixed
Parameters
$formId : int = 0

Limit slug generation to form identified by ID $formId.

getApplicationPageByCategory()

public getApplicationPageByCategory(mixed &$categoryId, mixed $langId[, mixed $traverseUp = false ]) : mixed
Parameters
$categoryId : mixed
$langId : mixed
$traverseUp : mixed = false

getApplicationPageByEntry()

public getApplicationPageByEntry(mixed $formId, mixed $langId) : mixed
Parameters
$formId : mixed
$langId : mixed

getApplicationPageByLevel()

public getApplicationPageByLevel(mixed &$levelId, mixed $langId[, mixed $traverseUp = false ]) : mixed
Parameters
$levelId : mixed
$langId : mixed
$traverseUp : mixed = false

getApplicationPageByLevelAndCategory()

public getApplicationPageByLevelAndCategory(mixed &$levelId, mixed &$categoryId, mixed $langId[, mixed $traverseUp = false ]) : mixed
Parameters
$levelId : mixed
$categoryId : mixed
$langId : mixed
$traverseUp : mixed = false

getAutoSlugPath()

Get the human readable url for a mediadir location

public getAutoSlugPath([array<string|int, mixed> $arrEntry = null ][, int $categoryId = null ][, int $levelId = null ][, bool $useRequestedPageAsFallback = false ][, bool $includeDetailApplicationPage = true ][, Locale $locale = null ]) : Url

URI-Slug scheme precedence

  1. $levelId & $categoryId are set: Url will point to specific level & category application page (if existing). I.e.: section=MediaDir&cmd=4-2

  2. $levelId is set: Url will point to specific level application page (if existing). I.e.: section=MediaDir&cmd=4

  3. $categoryId is set: Url will point to specific category application page (if existing). I.e.: section=MediaDir&cmd=2

  4. if $arrEntry is set: Url will point to specific form application page (if existing). I.e.: section=MediaDir&cmd=team

  5. $categoryId is set: Url will point to main application page (if existing). I.e.: section=MediaDir

  6. if $arrEntry is set: Url will point to specific form detail application page (if existing). I.e.: section=MediaDir&cmd=detail12

  7. if $arrEntry is set: Url will point to generic detail application page (if existing). I.e.: section=MediaDir&cmd=detail

  8. fallback #1 Url will point to main application page (if existing). I.e.: section=MediaDir

  9. fallback #2 Lookup failed, NULL will be returned

Parameters
$arrEntry : array<string|int, mixed> = null

(Optional) Array definition of the entry to locate

$categoryId : int = null

(Optional) ID of the category to locate

$levelId : int = null

(Optional) ID of the level to locate

$useRequestedPageAsFallback : bool = false

(Optional) Whether or not to use the requested page as fallback in case no matching mediadir application could be found

$includeDetailApplicationPage : bool = true

(Optional) Whether or not to include the detail application page as a feasible url target

$locale : Locale = null

(Optional) Get slug-path from specific locale. the detail application page as a feasible url target

Return values
Url

Returns an Url object of the mediadir location. If location is invalid, method will return NULL.

getCategorySlugPath()

public getCategorySlugPath(int $categoryId[, int $offsetCategoryId = 0 ]) : mixed
Parameters
$categoryId : int

ID of category to get the slug-path from

$offsetCategoryId : int = 0

Set the ID of a parent category to only fetch the slug-path from that category downwards.

getContent()

public abstract getContent(int $intEntryId, array<string|int, mixed> $arrInputfield[, array<string|int, mixed>|null $arrTranslationStatus = null ]) : array<string|int, mixed>
Parameters
$intEntryId : int
$arrInputfield : array<string|int, mixed>
$arrTranslationStatus : array<string|int, mixed>|null = null
Tags
todo

Implement DocBlock

Return values
array<string|int, mixed>

getFieldData()

Get definitions of inputfields.

public getFieldData() : array<string|int, mixed>
Tags
todo

Extend returned data by additional meta data.

Return values
array<string|int, mixed>

Associated array of all inputfields that are accessible by the current request. Inputfields on which the current user is not authorized to access to, are not returned. The returned array has the following structure:

[
    <int:fieldId> => [
        'type' => <int:type>,
    ],
]

getFormOnSubmit()

public getFormOnSubmit(int $intInputfieldId) : string
Parameters
$intInputfieldId : int
Tags
todo

Implement DocBlock

Return values
string

getInputfield()

public abstract getInputfield(int $intView, array<string|int, mixed> $arrInputfield[, int|null $intEntryId = null ]) : string
Parameters
$intView : int
$arrInputfield : array<string|int, mixed>
$intEntryId : int|null = null
Tags
todo

Implement DocBlock

Return values
string

getLevelSlugPath()

public getLevelSlugPath(int $levelId[, int $offsetLevelId = 0 ]) : mixed
Parameters
$levelId : int

ID of level to get the slug-path from

$offsetLevelId : int = 0

Set the ID of a parent level to only fetch the slug-path from that level downwards.

getMediaBrowserButton()

Get mediabrowser button

public getMediaBrowserButton(string $buttonValue[, string $options = array() ][, string $callback = '' ]) : string
Parameters
$buttonValue : string

Value of the button

$options : string = array()

Input button options

$callback : string = ''

Media browser callback function

Return values
string

html element of browse button

getQueryToFindPrimaryInputFieldId()

Get SQL statement to fetch the ID of the primary field of a form.

public getQueryToFindPrimaryInputFieldId([int $formId = 0 ]) : string

The SQL statement can be used as a sub-query in a query where contrexx_module_mediadir_entry is used and has been aliased as 'entry'

Parameters
$formId : int = 0

Set to the ID of a form to restrict the query to a specific form.

Return values
string

The SQL statement to be used as sub-query

getRawData()

public getRawData(int $intEntryId, array<string|int, mixed> $arrInputfield[, array<string|int, mixed>|null $arrTranslationStatus = null ]) : string
Parameters
$intEntryId : int
$arrInputfield : array<string|int, mixed>
$arrTranslationStatus : array<string|int, mixed>|null = null
Tags
todo

Implement DocBlock

Return values
string

getSelectorSearch()

Get setting if levels or categories shall be included in extended search functionality of a specific form.

public getSelectorSearch(int $intSelectorId) : array<string|int, mixed>
Parameters
$intSelectorId : int

Set to 9 to get the setting for category. set to 10 to get the setting for level.

Return values
array<string|int, mixed>

Array containung the setting if the levels or categories shall be included in the extended seach functionality for each form. Format: array( => )

getThumbImage()

Get the Thumbnail image path from given file Thumbnail will be created it is not exists

public getThumbImage(string $path) : string
Parameters
$path : string

Relative path to the file

Return values
string

Thumbnail path

getUploadedFilePath()

Get uploaded file path by using uploader id and file name

public getUploadedFilePath(string $uploaderId, string $fileName) : bool|string
Parameters
$uploaderId : string

Uploader id

$fileName : string

File name

Return values
bool|string

File path when File exists, false otherwise

saveInputfield()

public abstract saveInputfield(int $intInputfieldId, string $strValue[, int $langId = 0 ]) : string
Parameters
$intInputfieldId : int
$strValue : string
$langId : int = 0
Tags
todo

Implement DocBlock

Return values
string

addSlugFieldToForm()

Add a new inputfield to a form and set its context type to 'slug'.

protected addSlugFieldToForm(int $formId) : int
Parameters
$formId : int

Id of form to add the inputfield to.

Return values
int

Id of the newly added inputfield.

enforceUniqueSlug()

Enforce uniqueness of a slug

protected enforceUniqueSlug(string &$slug, int $entryId, int $slugLangId) : mixed

The supplied $slug will be made unqiue within the sopce of a locale (identified by the locale's ID through argument $slugLangId). This is achieved by adding a trailing (unique) integer to the slug in case its not yet unique. In case the option settingsShowEntriesInAllLang is set, then the slug will be made unique over all locales.

Parameters
$slug : string

The slug to make unique.

$entryId : int

The associated entry of the slug.

$slugLangId : int

The ID of the locale the slug is from.

flushInputFieldMetaDataByFormId()

Flush cache of input-field meta-data of a specific form

protected static flushInputFieldMetaDataByFormId(int $id) : mixed
Parameters
$id : int

ID of form to flush the meta-data of its input fields from the cache.

flushUsedFrontendLocales()

Flush cached list of used frontend locales

protected static flushUsedFrontendLocales() : mixed

getApplicationPageByForm()

protected getApplicationPageByForm(mixed $formCmd, mixed $langId) : mixed
Parameters
$formCmd : mixed
$langId : mixed

getCustomFormatDefinition()

Get the FieldTemplate (HTML-Code) (from {@see static::getCustomFormatTemplates()}) for $scope that best matches $component, $context and $formId.

protected getCustomFormatDefinition(string $scope, string $component, string $context[, int $formId = 0 ]) : string

If there is no matching template for $context, then the default for $component will be returned. However if not even a default for $component exists, then the generic default template will be returned.

Parameters
$scope : string

Either title or content.

$component : string

The name of a component.

$context : string

The specific context to use.

$formId : int = 0

The ID of a form.

Return values
string

The HTML-code of the matching template.

getCustomFormatTemplates()

Load and return the custom format templates

protected getCustomFormatTemplates() : array<string|int, mixed>

The custom format templates are defined in two locations:

  1. modules/MediaDir/View/Template/Generic/.html
  2. images/MediaDir/FieldTemplate/[<formId>/][<componentName>/[/]].html
Tags
todo

Move templates to /data/private/MediaDir (CLX-4442)

Return values
array<string|int, mixed>

List of loaded field templates. The returned array has the following format:

[
    <componentName> => [
        <context> => [
            <scope> => <template>,
            ...
        ],
        ...
    ],
    ...
],

If there are any form specific templates defined, then those are returned in the list of loaded field templates as follows:

[
    <formId> => [
        <componentName> => [
            <context> => [
                <scope> => <template>,
                ...
            ],
            ...
        ],
        ...
    ],
    ...
 ],

getQueryToFindInputFieldIdByContextType()

Get SQL statement to fetch the ID of the field of a form identified by its context.

protected getQueryToFindInputFieldIdByContextType(string $type[, int $formId = 0 ][, bool $allowFallback = false ]) : string

The SQL statement can be used as a sub-query in a query where contrexx_module_mediadir_entry is used and has been aliased as 'entry'

Parameters
$type : string

Context type (MediaDirectoryInputfields::getInputContexts()

$formId : int = 0

Set to the ID of a form to restrict the query to a specific form. In case the form (identified by $formId) has a field set as context $type, then $allowFallback = false is implied.

$allowFallback : bool = false

Set to true to return the first inputfield (according to the set sort order of the inputfields) in case the form of the associated entry does not contain a field by the specified context $type.

Return values
string

The SQL statement to be used as sub-query

getSourceLocaleIdForTargetLocale()

Get the source locale of a target locale

protected static getSourceLocaleIdForTargetLocale(int $localeId[, array<string|int, mixed> $usedFrontendLocales = array() ]) : int

The source locale is the fallback locale of a locale (the target locale) or the system's default locale.

Parameters
$localeId : int

The ID of the target locale

$usedFrontendLocales : array<string|int, mixed> = array()

List of available locales. One-dimensional array of locale IDs.

Return values
int

The ID of the source locale

initI18nEntryData()

Initialize the multilingual data of all existing entries associated to form identified by `$formId`. This will insert empty datasets into the database for each inputfield of `$formId` that is a multilingual field (`type_multi_lang = 1`).

protected initI18nEntryData(int $formId) : void
Parameters
$formId : int

ID of form to init the i18n entry data.

initOutputLocale()

Determine the locale in which the output shall be parsed for.

protected static initOutputLocale() : Locale

Backend:

  1. Matching Locale of Backend language
  2. Selected Frontend Locale (of menu / if used by MediaDir)
  3. Default Frontend Locale (if used by MediaDir)
  4. Any Frontend Locale used by MediaDir

Any other mode: Currently requested frontend Locale

Return values
Locale

loadAllSlugsFromDb()

Fetch all slugs from the database

protected loadAllSlugsFromDb() : mixed

Those will be used to ensure uniqueness within slugs (@see MediaDirectoryLibrary::enforceUniqueSlug()).

parseGoogleMapPlaceholder()

protected parseGoogleMapPlaceholder(mixed $template, mixed $placeholder) : mixed
Parameters
$template : mixed
$placeholder : mixed

setCurrentFetchedEntryDataObject()

protected setCurrentFetchedEntryDataObject(mixed $objEntry) : mixed
Parameters
$objEntry : mixed

slugify()

Slugifies the given string and ensures its uniqueness

protected slugify(int $entryId, string &$string, int $langId[, array<string|int, mixed> $titleData = array() ]) : mixed
Parameters
$entryId : int

The ID of the associated entry

$string : string

The string to slugify

$langId : int

The ID of the locale the string $string comes from.

$titleData : array<string|int, mixed> = array()

Array of strings to be used in case $string is an empty string. The array uses the IDs of available locales as keys for each string.


        
On this page

Search results