idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
42,700
private function prepareLabelArguments ( $ propertyNames , PropertiesDefinitionInterface $ properties , EnvironmentInterface $ environment , ModelInterface $ model ) { $ args = [ ] ; foreach ( $ propertyNames as $ propertyName ) { if ( ! $ properties -> hasProperty ( $ propertyName ) ) { $ args [ $ propertyName ] = '-'...
Prepare the arguments for the label formatter .
42,701
private function renderWithColumns ( $ propertyNames , $ args , $ firstSorting ) { $ label = [ ] ; if ( ! \ is_array ( $ args ) ) { @ \ trigger_error ( 'Warning, column layout without arguments will not be supported.' , E_USER_DEPRECATED ) ; $ label [ ] = [ 'colspan' => \ count ( $ propertyNames ) , 'class' => 'tl_file...
Render for column layout .
42,702
private function renderSingleValue ( $ label , $ args , $ maxLength = null ) { $ string = ! \ is_array ( $ args ) ? $ args : \ vsprintf ( $ label , $ args ) ; if ( ( null !== $ maxLength ) && \ strlen ( $ string ) > $ maxLength ) { $ string = \ substr ( $ string , 0 , $ maxLength ) ; } return $ string ; }
Render as single value .
42,703
protected function populatePanel ( EnvironmentInterface $ environment ) { $ view = $ environment -> getView ( ) ; if ( ! ( ( $ view instanceof BaseView ) ) ) { return ; } if ( ! $ environment -> getDataDefinition ( ) -> hasDefinition ( Contao2BackendViewDefinitionInterface :: NAME ) ) { return ; } if ( $ view -> getPan...
Create a panel instance in the view if none has been defined yet .
42,704
public function handleAction ( ActionEvent $ event ) { if ( ! $ this -> scopeDeterminator -> currentScopeIsBackend ( ) ) { return ; } if ( 'clear-clipboard' === ( $ actionName = $ event -> getAction ( ) -> getName ( ) ) ) { $ this -> clearClipboard ( $ event ) ; } if ( false === $ this -> checkPermission ( $ event ) ) ...
Handle action .
42,705
private function checkPermission ( ActionEvent $ event ) { $ actionName = $ event -> getAction ( ) -> getName ( ) ; $ environment = $ event -> getEnvironment ( ) ; $ basicDefinition = $ environment -> getDataDefinition ( ) -> getBasicDefinition ( ) ; if ( ( ( 'create' === $ actionName ) && ( true === $ basicDefinition ...
Check if permission for action .
42,706
private function clearClipboard ( ActionEvent $ event , $ redirect = true ) { $ environment = $ event -> getEnvironment ( ) ; $ eventDispatcher = $ environment -> getEventDispatcher ( ) ; $ clipboard = $ environment -> getClipboard ( ) ; $ input = $ environment -> getInputProvider ( ) ; if ( $ clipboardId = $ input -> ...
Handle clear clipboard action .
42,707
private function translateActionName ( $ actionName ) { switch ( $ actionName ) { case 'create' : return Item :: CREATE ; case 'cut' : return Item :: CUT ; case 'copy' : return Item :: COPY ; case 'deepcopy' : return Item :: DEEP_COPY ; default : } return null ; }
Translate an action name to a clipboard action name .
42,708
private function addToClipboard ( ActionEvent $ event ) { $ actionName = $ event -> getAction ( ) -> getName ( ) ; $ environment = $ event -> getEnvironment ( ) ; $ input = $ environment -> getInputProvider ( ) ; $ clipboard = $ environment -> getClipboard ( ) ; $ parentIdRaw = $ input -> getParameter ( 'pid' ) ; if ( ...
Handle old add to clipboard actions .
42,709
protected function isAddingAllowed ( EnvironmentInterface $ environment ) { $ inputProvider = $ environment -> getInputProvider ( ) ; return ( ! ViewHelpers :: getManualSortingProperty ( $ environment ) || $ inputProvider -> hasParameter ( 'after' ) || $ inputProvider -> hasParameter ( 'into' ) ) ; }
Is adding to the clipboard allowed .
42,710
public function handleView ( ViewEvent $ event ) { if ( ! $ this -> scopeDeterminator -> currentScopeIsBackend ( ) ) { return ; } if ( DcGeneralViews :: CLIPBOARD !== $ event -> getViewName ( ) ) { return ; } $ environment = $ event -> getEnvironment ( ) ; $ input = $ environment -> getInputProvider ( ) ; $ eventDispat...
Handle view .
42,711
protected static function evaluateCallback ( $ callback ) { if ( \ is_array ( $ callback ) && ( 2 === \ count ( $ callback ) ) && \ is_string ( $ callback [ 0 ] ) && \ is_string ( $ callback [ 1 ] ) ) { $ serviceCallback = static :: evaluateServiceCallback ( $ callback ) ; if ( $ serviceCallback [ 0 ] !== $ callback [ ...
Evaluate the callback and create an object instance if required and possible .
42,712
private static function evaluateServiceCallback ( $ callback ) { $ container = System :: getContainer ( ) ; if ( $ container -> has ( $ callback [ 0 ] ) && ( ( false !== \ strpos ( $ callback [ 0 ] , '\\' ) ) || ! \ class_exists ( $ callback [ 0 ] ) ) ) { $ callback [ 0 ] = $ container -> get ( $ callback [ 0 ] ) ; ret...
Evaluate the callback from the service container .
42,713
public function parse ( array $ palettes , array $ subPalettes = [ ] , PaletteCollectionInterface $ collection = null ) { if ( isset ( $ palettes [ '__selector__' ] ) ) { $ selectorFieldNames = $ palettes [ '__selector__' ] ; unset ( $ palettes [ '__selector__' ] ) ; } else { $ selectorFieldNames = [ ] ; } return $ thi...
Parse the palette and sub palette array and create a complete palette collection .
42,714
public function parsePalettes ( array $ palettes , array $ subPaletteProperties = [ ] , array $ selectorFieldNames = [ ] , PaletteCollectionInterface $ collection = null ) { if ( ! $ collection ) { $ collection = new PaletteCollection ( ) ; } if ( isset ( $ palettes [ '__selector__' ] ) ) { $ selectorFieldNames = \ arr...
Parse the given palettes .
42,715
public function parsePalette ( $ paletteSelector , $ fields , array $ subPaletteProperties = [ ] , array $ selectorFieldNames = [ ] , PaletteInterface $ palette = null ) { if ( ! $ palette ) { $ palette = new Palette ( ) ; $ palette -> setName ( $ paletteSelector ) ; } $ palette -> setCondition ( $ this -> createPalett...
Parse a single palette .
42,716
public function createPaletteCondition ( $ paletteSelector , array $ selectorFieldNames ) { if ( 'default' === $ paletteSelector ) { return new DefaultPaletteCondition ( ) ; } if ( false === \ strpos ( $ paletteSelector , '|' ) ) { foreach ( $ selectorFieldNames as $ selectorFieldName ) { $ paletteSelector = \ str_repl...
Parse the palette selector and create the corresponding condition .
42,717
public function parseSubpalettes ( array $ subpalettes , array $ selectorFieldNames = [ ] ) { $ properties = [ ] ; foreach ( $ subpalettes as $ subPaletteSelector => $ childFields ) { if ( ! \ is_string ( $ childFields ) ) { continue ; } $ selectorFieldName = $ this -> createSubpaletteSelectorFieldName ( $ subPaletteSe...
Parse the sub palettes and return the properties for each selector property .
42,718
public function parseSubpalette ( $ subPaletteSelector , $ childFields , array $ selectorFieldNames = [ ] , array $ properties = [ ] ) { $ childFields = \ explode ( ',' , $ childFields ) ; $ childFields = \ array_map ( 'trim' , $ childFields ) ; $ condition = $ this -> createSubpaletteCondition ( $ subPaletteSelector ,...
Parse the list of sub palette fields into an array of properties .
42,719
public function createSubpaletteSelectorFieldName ( $ subPaletteSelector , array $ selectorFieldNames = [ ] ) { $ selectorValues = \ explode ( '_' , $ subPaletteSelector ) ; $ selectorFieldName = \ array_shift ( $ selectorValues ) ; $ selectorValueCount = \ count ( $ selectorValues ) ; while ( $ selectorValueCount ) { ...
Translate a sub palette selector into the real name of a property .
42,720
public function createSubpaletteCondition ( $ subPaletteSelector , array $ selectorFieldNames = [ ] ) { $ condition = null ; $ selectorValues = \ explode ( '_' , $ subPaletteSelector ) ; $ selectorFieldName = \ array_shift ( $ selectorValues ) ; $ selectorValueCount = \ count ( $ selectorValues ) ; while ( $ selectorVa...
Parse the sub palette selector and create the corresponding condition .
42,721
public static function updateModelFromPropertyBag ( PropertiesDefinitionInterface $ properties , ModelInterface $ model , PropertyValueBagInterface $ values ) { foreach ( $ values as $ propertyName => $ value ) { try { if ( ! $ properties -> hasProperty ( $ propertyName ) ) { continue ; } $ property = $ properties -> g...
Update the model with the values from the value bag .
42,722
private function prepareTreeSelector ( PickerInterface $ picker ) { $ modelId = ModelId :: fromSerialized ( $ picker -> getConfig ( ) -> getExtra ( 'modelId' ) ) ; if ( Validator :: isInsecurePath ( $ table = $ modelId -> getDataProviderName ( ) ) ) { throw new \ InvalidArgumentException ( 'The table name contains inva...
Prepare the tree selector .
42,723
public function getFlatModelErrors ( ModelInterface $ model ) { $ modelErrors = $ this -> getModelError ( $ model ) ; if ( ! $ modelErrors ) { return $ modelErrors ; } $ errors = [ [ ] ] ; foreach ( $ this -> getModelError ( $ model ) as $ modelError ) { $ errors [ ] = $ modelError ; } return \ array_merge ( ... $ erro...
Get flat model errors . This returns all errors without property names hierarchy .
42,724
public static function getWizard ( $ propInfo , EnvironmentInterface $ environment ) { $ wizard = '' ; $ propExtra = $ propInfo -> getExtra ( ) ; if ( \ is_array ( $ propExtra ) && \ array_key_exists ( 'colorpicker' , $ propExtra ) && $ propExtra [ 'colorpicker' ] ) { $ pickerText = $ environment -> getTranslator ( ) -...
Append wizard icons .
42,725
public function handle ( GetGroupHeaderEvent $ event ) { if ( ( null !== $ event -> getValue ( ) ) || ! $ this -> scopeDeterminator -> currentScopeIsBackend ( ) ) { return ; } $ environment = $ event -> getEnvironment ( ) ; $ property = $ environment -> getDataDefinition ( ) -> getPropertiesDefinition ( ) -> getPropert...
Handle the subscribed event .
42,726
protected function formatGroupHeader ( EnvironmentInterface $ environment , ModelInterface $ model , PropertyInterface $ property , $ groupingMode , $ groupingLength ) { $ evaluation = $ property -> getExtra ( ) ; if ( ! $ evaluation [ 'multiple' ] && ( 'checkbox' === $ property -> getWidgetType ( ) ) ) { return $ this...
Get the group header .
42,727
private function formatCheckboxOptionLabel ( $ value ) { return ( '' !== $ value ) ? \ ucfirst ( $ this -> translator -> translate ( 'MSC.yes' ) ) : \ ucfirst ( $ this -> translator -> translate ( 'MSC.no' ) ) ; }
Format the grouping header for a checkbox option .
42,728
private function formatByGroupingMode ( $ groupingMode , $ groupingLength , EnvironmentInterface $ environment , PropertyInterface $ property , ModelInterface $ model ) { switch ( $ groupingMode ) { case GroupAndSortingInformationInterface :: GROUP_CHAR : return $ this -> formatByCharGrouping ( ViewHelpers :: getReadab...
Format the group header by the grouping mode .
42,729
private function formatByCharGrouping ( $ value , $ groupingLength ) { if ( '' === $ value ) { return '-' ; } return \ ucfirst ( Utf8 :: substr ( $ value , 0 , $ groupingLength ? : null ) ) ; }
Format a value for char grouping .
42,730
private function formatByDayGrouping ( $ value ) { $ value = $ this -> getTimestamp ( $ value ) ; if ( '' === $ value ) { return '-' ; } $ event = new ParseDateEvent ( $ value , Config :: get ( 'dateFormat' ) ) ; $ this -> dispatcher -> dispatch ( ContaoEvents :: DATE_PARSE , $ event ) ; return $ event -> getResult ( )...
Render a grouping header for day .
42,731
private function formatByMonthGrouping ( $ value ) { $ value = $ this -> getTimestamp ( $ value ) ; if ( '' === $ value ) { return '-' ; } $ event = new ParseDateEvent ( $ value , 'F Y' ) ; $ this -> dispatcher -> dispatch ( ContaoEvents :: DATE_PARSE , $ event ) ; return $ event -> getResult ( ) ; }
Render a grouping header for month .
42,732
private function load ( ) { if ( \ count ( $ this -> attributes ) ) { return ; } $ sessionBag = $ this -> session -> getBag ( $ this -> getSessionBagKey ( ) ) ; $ databaseSessionBag = $ this -> session -> getBag ( $ this -> getDatabaseSessionBagKey ( ) ) ; $ this -> attributes = \ array_merge ( ( array ) $ sessionBag -...
Load the data from the session if it has not been loaded yet .
42,733
private function persist ( ) { $ sessionBag = $ this -> session -> getBag ( $ this -> getSessionBagKey ( ) ) ; $ sessionBag -> set ( $ this -> getScope ( ) , $ this -> filterAttributes ( ) ) ; $ databaseSessionBag = $ this -> session -> getBag ( $ this -> getDatabaseSessionBagKey ( ) ) ; $ databaseSessionBag -> set ( $...
Save the data to the session .
42,734
private function filterAttributes ( $ determineDatabase = false ) { $ databaseAttributes = \ array_merge ( ( array ) $ this -> databaseKeys [ 'common' ] , ( array ) $ this -> databaseKeys [ $ this -> getScope ( ) ] ) ; if ( $ determineDatabase ) { return \ array_intersect_key ( $ this -> attributes , \ array_flip ( $ d...
Filter the attributes .
42,735
protected static function touchKeys ( $ cache , $ keys ) : array { $ items = [ ] ; $ time = microtime ( ) ; foreach ( $ keys as $ key ) { $ items [ $ key ] = $ time ; } $ cache -> setMultiple ( $ items ) ; return $ items ; }
Generates the timestamp for the specified cache keys .
42,736
public function setBaseConfig ( array $ config ) { parent :: setBaseConfig ( $ config ) ; if ( ! $ config [ 'group_column' ] ) { throw new DcGeneralException ( __CLASS__ . ' needs a grouping column.' , 1 ) ; } $ this -> strGroupCol = $ config [ 'group_column' ] ; if ( $ config [ 'sort_column' ] ) { $ this -> strSortCol...
Set base config with source and other necessary parameter .
42,737
public function fetch ( ConfigInterface $ config ) { if ( ! $ config -> getId ( ) ) { throw new DcGeneralException ( 'Error, no id passed, TableRowsAsRecordsDriver is only intended for edit mode.' , 1 ) ; } $ queryBuilder = $ this -> connection -> createQueryBuilder ( ) ; DefaultDataProviderDBalUtils :: addField ( $ co...
Fetch a single record by id .
42,738
public function save ( ModelInterface $ item , $ timestamp = 0 , $ recursive = false ) { if ( ! \ is_int ( $ timestamp ) ) { throw new DcGeneralException ( 'The parameter for this method has been change!' ) ; } $ data = $ item -> getProperty ( 'rows' ) ; if ( ! ( $ data && $ item -> getId ( ) ) ) { throw new DcGeneralE...
Save a model to the database .
42,739
protected static function checkAndFilter ( $ model , $ filter ) { foreach ( $ filter as $ child ) { if ( ! self :: checkCondition ( $ model , $ child ) ) { return false ; } } return true ; }
Check if an AND condition filter matches .
42,740
public static function checkCondition ( ModelInterface $ objParentModel , $ arrFilter ) { switch ( $ arrFilter [ 'operation' ] ) { case 'AND' : return self :: checkAndFilter ( $ objParentModel , $ arrFilter [ 'children' ] ) ; case 'OR' : return self :: checkOrFilter ( $ objParentModel , $ arrFilter [ 'children' ] ) ; c...
Check if the passed filter rules apply to the given model .
42,741
public function checkPermissionForProperties ( BuildDataDefinitionEvent $ event ) { if ( ! $ this -> scopeDeterminator -> currentScopeIsBackend ( ) ) { return ; } $ container = $ event -> getContainer ( ) ; $ properties = $ container -> getPropertiesDefinition ( ) ; $ palettesDefinition = $ container -> getPalettesDefi...
Check permission for properties by user alexf .
42,742
public function checkPermissionIsEditable ( BuildDataDefinitionEvent $ event ) { if ( ! $ this -> scopeDeterminator -> currentScopeIsBackend ( ) ) { return ; } $ container = $ event -> getContainer ( ) ; if ( $ container -> getBasicDefinition ( ) -> isEditable ( ) ) { return ; } $ view = $ container -> getDefinition ( ...
Check permission is editable .
42,743
public function checkPermissionIsDeletable ( BuildDataDefinitionEvent $ event ) { if ( ! $ this -> scopeDeterminator -> currentScopeIsBackend ( ) ) { return ; } $ container = $ event -> getContainer ( ) ; if ( $ container -> getBasicDefinition ( ) -> isDeletable ( ) ) { return ; } $ view = $ container -> getDefinition ...
Check permission is deletable .
42,744
public function checkPermissionIsCreatable ( BuildDataDefinitionEvent $ event ) { if ( ! $ this -> scopeDeterminator -> currentScopeIsBackend ( ) ) { return ; } $ container = $ event -> getContainer ( ) ; if ( $ container -> getBasicDefinition ( ) -> isCreatable ( ) ) { return ; } $ view = $ container -> getDefinition ...
Check permission is creatable .
42,745
private function getVisibilityConditionChain ( $ property ) { if ( ( $ chain = $ property -> getVisibleCondition ( ) ) && ( $ chain instanceof PropertyConditionChain ) && $ chain -> getConjunction ( ) === PropertyConditionChain :: AND_CONJUNCTION ) { return $ chain ; } $ newChain = new PropertyConditionChain ( $ chain ...
Retrieve the visibility condition chain or create an empty one if none exists .
42,746
private function disableCommandByActionName ( CommandCollectionInterface $ commands , $ actionName ) { foreach ( $ commands -> getCommands ( ) as $ command ) { $ parameters = $ command -> getParameters ( ) -> getArrayCopy ( ) ; $ disableCommand = false ; if ( \ array_key_exists ( 'act' , $ parameters ) && ( $ parameter...
Disable command by action name .
42,747
private function disableToggleCommand ( CommandCollectionInterface $ commands ) { foreach ( $ commands -> getCommands ( ) as $ command ) { if ( ! ( $ command instanceof ToggleCommandInterface ) ) { continue ; } $ this -> disableCommandByActionName ( $ commands , $ command -> getName ( ) ) ; } }
Disable the toggle command .
42,748
public function getModel ( $ modelId , $ providerName = null ) { if ( \ is_string ( $ modelId ) ) { try { $ modelId = ModelId :: fromValues ( $ providerName , $ modelId ) ; } catch ( \ Exception $ swallow ) { $ modelId = ModelId :: fromSerialized ( $ modelId ) ; } } if ( ! ( $ modelId instanceof ModelIdInterface ) ) { ...
Fetch a certain model from its provider .
42,749
public function searchParentOfIn ( ModelInterface $ model , CollectionInterface $ models ) { foreach ( $ models as $ candidate ) { foreach ( $ this -> relationships -> getChildConditions ( $ candidate -> getProviderName ( ) ) as $ condition ) { if ( $ condition -> matches ( $ candidate , $ model ) ) { return $ candidat...
Search the parent of the passed model in the passed collection .
42,750
public function searchParentOf ( ModelInterface $ model ) { switch ( $ this -> definitionMode ) { case BasicDefinitionInterface :: MODE_HIERARCHICAL : return $ this -> searchParentOfInHierarchical ( $ model ) ; case BasicDefinitionInterface :: MODE_PARENTEDLIST : return $ this -> searchParentOfInParentedMode ( $ model ...
Search the parent model for the given model .
42,751
private function internalCollectChildrenOf ( ModelInterface $ model , $ providerName = '' , $ recursive = false ) { if ( '' === $ providerName ) { $ providerName = $ model -> getProviderName ( ) ; } $ ids = ( $ model -> getProviderName ( ) === $ providerName ) ? [ $ model -> getId ( ) ] : [ ] ; $ childIds = [ ] ; forea...
Scan for children of a given model .
42,752
private function searchParentOfInParentedMode ( ModelInterface $ model ) { if ( $ this -> defaultProviderName !== $ model -> getProviderName ( ) ) { throw new DcGeneralInvalidArgumentException ( 'Model originates from ' . $ model -> getProviderName ( ) . ' but is expected to be from ' . $ this -> defaultProviderName . ...
Search the parent of a model in parented mode .
42,753
private function searchParentOfInHierarchical ( ModelInterface $ model ) { if ( $ this -> isRootModel ( $ model ) ) { throw new DcGeneralInvalidArgumentException ( 'Invalid condition, root models can not have parents!' ) ; } $ config = $ this -> rootProvider -> getEmptyConfig ( ) -> setFilter ( $ this -> rootCondition ...
Search the parent of a model in hierarchical mode .
42,754
private function addParentFilter ( ModelInterface $ model , $ config ) { if ( BasicDefinitionInterface :: MODE_HIERARCHICAL !== $ this -> definitionMode ) { return ; } if ( $ this -> isRootModel ( $ model ) ) { $ config -> setFilter ( $ this -> rootCondition -> getFilterArray ( ) ) ; return ; } $ parent = $ this -> sea...
Add the parent filter matching the parent of a model .
42,755
private function isRootModel ( ModelInterface $ model ) { return ( null !== $ this -> rootCondition ) && $ this -> rootCondition -> matches ( $ model ) ; }
Check if the passed model is a root model .
42,756
protected function getModelIds ( ) { $ ids = [ ] ; foreach ( $ this -> models as $ model ) { $ ids [ ] = $ model -> getId ( ) ; } return $ ids ; }
Retrieve the ids of the models .
42,757
protected function scanToDesiredPosition ( ) { $ this -> marker = null ; $ this -> position = 0 ; $ ids = $ this -> getModelIds ( ) ; if ( null === $ this -> previousModel ) { if ( $ this -> siblingsCopy -> length ( ) ) { $ this -> marker = $ this -> siblingsCopy -> shift ( ) ; } return ; } if ( $ this -> siblingsCopy ...
Scan through the sibling list to the position we want to insert at .
42,758
private function determineDelta ( ) { $ delta = ( ( $ this -> marker -> getProperty ( $ this -> getSortingProperty ( ) ) - $ this -> position ) / $ this -> results -> length ( ) ) ; if ( ( $ delta < 2 ) || ( $ delta > 128 ) ) { return ( \ ceil ( $ this -> results -> length ( ) / 128 ) * 128 ) ; } return $ delta ; }
Determine delta value .
42,759
private function updateSorting ( ) { $ ids = $ this -> getModelIds ( ) ; if ( ! $ this -> marker ) { foreach ( $ this -> results as $ model ) { $ this -> position += 128 ; $ model -> setProperty ( $ this -> getSortingProperty ( ) , $ this -> position ) ; } return ; } $ delta = $ this -> determineDelta ( ) ; foreach ( $...
Update the sorting property values of all models .
42,760
protected function calculate ( ) { if ( isset ( $ this -> results ) || ( 0 === $ this -> models -> length ( ) ) ) { return ; } if ( ! $ this -> getSortingProperty ( ) ) { throw new \ RuntimeException ( 'No sorting property defined for ' . $ this -> models -> get ( 0 ) -> getProviderName ( ) ) ; } $ this -> results = cl...
Calculate the resulting list .
42,761
private function checkPermission ( ActionEvent $ event ) { $ environment = $ event -> getEnvironment ( ) ; if ( true === $ environment -> getDataDefinition ( ) -> getBasicDefinition ( ) -> isEditable ( ) ) { return true ; } $ inputProvider = $ environment -> getInputProvider ( ) ; $ event -> setResponse ( \ sprintf ( '...
Check permission for edit a model .
42,762
private function checkRestoreVersion ( EnvironmentInterface $ environment , ModelId $ modelId ) { $ inputProvider = $ environment -> getInputProvider ( ) ; $ dataProviderDefinition = $ environment -> getDataDefinition ( ) -> getDataProviderDefinition ( ) ; $ dataProvider = $ environment -> getDataProvider ( $ modelId -...
Check the submitted data if we want to restore a previous version of a model .
42,763
private function getSubmitAction ( EnvironmentInterface $ environment , $ regardSelectMode = false ) { if ( ! $ regardSelectMode && $ environment -> getInputProvider ( ) -> hasParameter ( 'select' ) && ! $ environment -> getInputProvider ( ) -> hasValue ( 'properties' ) ) { return 'select' . \ ucfirst ( $ environment -...
Get the submit action name .
42,764
private function determineAction ( EnvironmentInterface $ environment ) { foreach ( [ 'delete' , 'cut' , 'copy' , 'override' , 'edit' ] as $ action ) { if ( $ environment -> getInputProvider ( ) -> hasValue ( $ action ) || $ environment -> getInputProvider ( ) -> hasValue ( $ action . '_save' ) || $ environment -> getI...
Determine the action .
42,765
private function regardSelectMode ( EnvironmentInterface $ environment ) { $ inputProvider = $ environment -> getInputProvider ( ) ; $ regardSelectMode = false ; \ array_map ( function ( $ value ) use ( $ inputProvider , & $ regardSelectMode ) { if ( ! $ inputProvider -> hasValue ( $ value ) ) { return false ; } $ rega...
Determine regard select mode .
42,766
private function getModelIds ( EnvironmentInterface $ environment , Action $ action , $ submitAction ) { $ valueKey = \ in_array ( $ submitAction , [ 'edit' , 'override' ] ) ? 'properties' : 'models' ; $ modelIds = ( array ) $ environment -> getInputProvider ( ) -> getValue ( $ valueKey ) ; if ( ! empty ( $ modelIds ) ...
Get The model ids from the environment .
42,767
private function handleSelectModelsAllAction ( EnvironmentInterface $ environment , Action $ action ) { $ this -> clearClipboard ( $ environment ) ; $ this -> handleGlobalCommands ( $ environment ) ; if ( $ response = $ this -> callAction ( $ environment , 'selectModelAll' ) ) { return $ response ; } return null ; }
Handel select model all action .
42,768
private function handleSelectPropertiesAllAction ( EnvironmentInterface $ environment , Action $ action ) { $ this -> clearClipboard ( $ environment ) ; $ this -> handleGlobalCommands ( $ environment ) ; $ this -> handleSessionOverrideEditAll ( $ this -> getModelIds ( $ environment , $ action , $ this -> getSubmitActio...
Handle the select property all action .
42,769
private function handleCutAllAction ( EnvironmentInterface $ environment , Action $ action ) { $ inputProvider = $ environment -> getInputProvider ( ) ; foreach ( $ this -> getModelIds ( $ environment , $ action , $ this -> getSubmitAction ( $ environment ) ) as $ modelId ) { $ inputProvider -> setParameter ( 'source' ...
Handle the cut all action .
42,770
private function handleEditAllAction ( EnvironmentInterface $ environment , Action $ action ) { $ this -> clearClipboard ( $ environment ) ; $ this -> handleGlobalCommands ( $ environment ) ; $ this -> handleSessionOverrideEditAll ( $ this -> getModelIds ( $ environment , $ action , $ this -> getSubmitAction ( $ enviro...
Handle the edit all action .
42,771
private function handleGlobalCommands ( EnvironmentInterface $ environment ) { $ dataDefinition = $ environment -> getDataDefinition ( ) ; $ backendView = $ dataDefinition -> getDefinition ( Contao2BackendViewDefinitionInterface :: NAME ) ; $ backButton = null ; if ( $ backendView -> getGlobalCommands ( ) -> hasCommand...
Handle the global commands .
42,772
private function clearClipboard ( EnvironmentInterface $ environment ) { $ basicDefinition = $ environment -> getDataDefinition ( ) -> getBasicDefinition ( ) ; $ filter = new Filter ( ) ; $ filter -> andModelIsFromProvider ( $ basicDefinition -> getDataProvider ( ) ) ; if ( $ basicDefinition -> getParentDataProvider ( ...
Clear the clipboard if has items .
42,773
private function getSelectCollection ( EnvironmentInterface $ environment ) { $ sessionStorage = $ environment -> getSessionStorage ( ) ; $ dataDefinition = $ environment -> getDataDefinition ( ) ; $ dataProvider = $ environment -> getDataProvider ( ) ; $ session = $ sessionStorage -> get ( $ dataDefinition -> getName ...
Get all select models in a collection .
42,774
private function collectIntersectModelProperties ( CollectionInterface $ collection , EnvironmentInterface $ environment ) { $ palettesDefinition = $ environment -> getDataDefinition ( ) -> getPalettesDefinition ( ) ; $ properties = [ ] ; foreach ( $ collection -> getIterator ( ) as $ model ) { $ palette = $ palettesDe...
Collecting intersect properties from the collection of models .
42,775
private function collectIntersectValues ( CollectionInterface $ collection , EnvironmentInterface $ environment ) { $ sessionStorage = $ environment -> getSessionStorage ( ) ; $ dataDefinition = $ environment -> getDataDefinition ( ) ; $ session = $ sessionStorage -> get ( $ dataDefinition -> getName ( ) . '.' . $ this...
Collect the intersect values from the model collection .
42,776
private function getVisibleAndEditAbleProperties ( PaletteInterface $ palette , ModelInterface $ model ) { return \ array_intersect ( \ array_map ( function ( PropertyInterface $ property ) { return $ property -> getName ( ) ; } , $ palette -> getVisibleProperties ( $ model ) ) , \ array_map ( function ( PropertyInterf...
Get the palette properties their are visible and editable .
42,777
private function getUniqueValueFromArray ( array $ values ) { $ serializedValues = false ; foreach ( $ values as $ key => $ value ) { if ( ! \ is_array ( $ value ) ) { continue ; } $ values [ $ key ] = \ serialize ( $ value ) ; $ serializedValues = true ; } if ( ! $ serializedValues ) { return 1 === \ count ( \ array_u...
Get the unique value from a array . The value will return if the all values in the array the same .
42,778
protected function getGroupAndSortingDefinition ( ) { $ view = $ this -> getEnvironment ( ) -> getDataDefinition ( ) -> getDefinition ( Contao2BackendViewDefinitionInterface :: NAME ) ; return $ view -> getListingConfig ( ) -> getGroupAndSortingDefinition ( ) ; }
Retrieve the group and sorting definition .
42,779
protected function searchDefinitionByName ( $ name ) { foreach ( $ this -> getGroupAndSortingDefinition ( ) as $ definition ) { if ( $ name === $ definition -> getName ( ) ) { return $ definition ; } } return null ; }
Search a definition by it s name .
42,780
protected function setUp ( General $ dataContainer = null ) { $ this -> dataContainer = $ dataContainer ? : $ this -> objDca ; if ( ! $ this -> dataContainer ) { return ; } $ environment = $ this -> dataContainer -> getEnvironment ( ) ; if ( ! $ this -> sourceName ) { $ property = $ environment -> getDataDefinition ( )...
Setup all local values and create the dc instance for the referenced data source .
42,781
private function convertValue ( $ value ) { if ( empty ( $ value ) ) { return null ; } if ( \ is_array ( $ value ) ) { return $ value ; } switch ( $ this -> fieldType ) { case 'radio' : return $ value ; case 'checkbox' : $ delimiter = ( false !== \ stripos ( $ value , "\t" ) ) ? "\t" : ',' ; return StringUtil :: trimsp...
Convert the value according to the configured fieldtype .
42,782
protected function validator ( $ value ) { $ convertValue = $ this -> widgetToValue ( $ value ) ; if ( ( null === $ convertValue ) && $ this -> mandatory ) { $ translator = $ this -> getEnvironment ( ) -> getTranslator ( ) ; $ message = empty ( $ this -> label ) ? $ translator -> translate ( 'ERR.mdtryNoLabel' ) : \ sp...
Skip the field if change selection is not checked .
42,783
public function renderItemsPlain ( ) { $ values = [ ] ; $ value = $ this -> varValue ; $ idProperty = $ this -> idProperty ? : 'id' ; if ( 'radio' === $ this -> fieldType && ! empty ( $ value ) ) { $ value = ( array ) $ value ; } if ( \ is_array ( $ value ) && ! empty ( $ value ) ) { $ environment = $ this -> getEnviro...
Render the current values for listing .
42,784
protected function generatePickerUrl ( ) { $ parameter = [ 'fieldType' => $ this -> fieldType , 'sourceName' => $ this -> sourceName , 'modelId' => ModelId :: fromModel ( $ this -> dataContainer -> getModel ( ) ) -> getSerialized ( ) , 'orderField' => $ this -> orderField , 'propertyName' => $ this -> name ] ; if ( $ t...
Generate the picker url .
42,785
public function valueToWidget ( $ value ) { if ( ! \ in_array ( $ this -> fieldType , [ 'radio' , 'checkbox' ] ) ) { throw new \ RuntimeException ( 'Unknown field type encountered: ' . $ this -> fieldType ) ; } if ( null === $ value ) { return '' ; } return ( 'radio' === $ this -> fieldType ) ? $ value : \ implode ( ',...
Convert the value for the widget .
42,786
protected function generateUpdateUrl ( ) { $ request = System :: getContainer ( ) -> get ( 'request_stack' ) -> getCurrentRequest ( ) ; $ configPicker = new PickerConfig ( 'cca_tree' , [ 'fieldType' => $ this -> fieldType , 'sourceName' => $ this -> sourceName , 'modelId' => ModelId :: fromModel ( $ this -> dataContain...
Generate the update url .
42,787
private function generateToggleUrl ( ModelInterface $ model ) { $ toggleUrlEvent = new AddToUrlEvent ( 'ptg=' . $ model -> getId ( ) . '&amp;provider=' . $ model -> getProviderName ( ) ) ; $ this -> getEnvironment ( ) -> getEventDispatcher ( ) -> dispatch ( ContaoEvents :: BACKEND_ADD_TO_URL , $ toggleUrlEvent ) ; retu...
Generate the toggle url .
42,788
private function getQueryParameterFromUrl ( $ url ) { $ parameters = array ( ) ; foreach ( \ preg_split ( '/&(amp;)?/i' , \ preg_split ( '/[?]/ui' , $ url ) [ 1 ] ) as $ value ) { $ chunks = \ explode ( '=' , $ value ) ; $ parameters [ $ chunks [ 0 ] ] = $ chunks [ 1 ] ; } return $ parameters ; }
Get the query parameters from url .
42,789
private function addOrderFieldToTemplate ( ContaoBackendViewTemplate $ template ) { if ( ! $ this -> orderField ) { return ; } $ translator = $ this -> getEnvironment ( ) -> getTranslator ( ) ; $ template -> set ( 'hasOrder' , true ) -> set ( 'orderId' , $ this -> orderField ) -> set ( 'orderName' , $ this -> orderName...
Add the order field to the template if the picker has order .
42,790
public function generatePopup ( ) { $ GLOBALS [ 'TL_JAVASCRIPT' ] [ 'cca.dc-general.vanillaGeneral' ] = 'bundles/ccadcgeneral/js/vanillaGeneral.js' ; $ environment = $ this -> getEnvironment ( ) ; $ translator = $ environment -> getTranslator ( ) ; $ template = new ContaoBackendViewTemplate ( 'widget_treepicker_popup' ...
Generate when being called from within a popup .
42,791
private function getRootIds ( ) { $ root = $ this -> root ; $ root = \ is_array ( $ root ) ? $ root : ( ( \ is_numeric ( $ root ) && $ root > 0 ) ? [ $ root ] : [ ] ) ; $ root = \ array_merge ( $ root , [ 0 ] ) ; return $ root ; }
Determine the root ids .
42,792
public function generateAjax ( ) { $ input = $ this -> getEnvironment ( ) -> getInputProvider ( ) ; if ( $ input -> hasValue ( 'action' ) && ( 'DcGeneralLoadSubTree' === $ input -> getValue ( 'action' ) ) ) { $ provider = $ input -> getValue ( 'providerName' ) ; $ rootId = $ input -> getValue ( 'id' ) ; $ this -> getEn...
Generate a particular sub part of the page tree and return it as HTML string .
42,793
protected function determineModelState ( ModelInterface $ model , $ level ) { $ model -> setMeta ( DCGE :: TREE_VIEW_LEVEL , $ level ) ; $ model -> setMeta ( $ model :: SHOW_CHILDREN , $ this -> getTreeNodeStates ( ) -> isModelOpen ( $ model -> getProviderName ( ) , $ model -> getId ( ) ) ) ; }
Check the state of a model and set the metadata accordingly .
42,794
private function treeWalkChildCollection ( CollectionInterface $ childCollection , ModelInterface $ model , $ level ) { $ relationships = $ this -> getEnvironment ( ) -> getDataDefinition ( ) -> getModelRelationshipDefinition ( ) ; foreach ( $ childCollection as $ childModel ) { $ model -> setMeta ( $ model :: PARENT_I...
Walk in the child collection for the tree .
42,795
private function prepareFilterForRootCondition ( ) { $ environment = $ this -> getEnvironment ( ) ; $ rootCondition = $ environment -> getDataDefinition ( ) -> getModelRelationshipDefinition ( ) -> getRootCondition ( ) ; $ baseConfig = $ environment -> getBaseConfigRegistry ( ) -> getBaseConfig ( ) ; if ( ! $ rootCondi...
Prepare filter if has root condition .
42,796
private function pushRootModelToTreeCollection ( DataProviderInterface $ dataProvider , CollectionInterface $ treeCollection , $ level ) { $ environment = $ this -> getEnvironment ( ) ; $ inputProvider = $ environment -> getInputProvider ( ) ; $ baseConfig = $ this -> prepareFilterForRootCondition ( ) ; $ relationships...
Push root model to the tree collection .
42,797
protected function getFormatter ( ModelInterface $ model , $ treeMode ) { $ definition = $ this -> getEnvironment ( ) -> getDataDefinition ( ) ; $ listing = $ definition -> getDefinition ( Contao2BackendViewDefinitionInterface :: NAME ) -> getListingConfig ( ) ; if ( $ listing -> hasLabelFormatter ( $ model -> getProvi...
Retrieve the formatter for the given model .
42,798
public function formatModel ( ModelInterface $ model , $ treeMode = true ) { $ environment = $ this -> getEnvironment ( ) ; $ definition = $ environment -> getDataDefinition ( ) ; $ listing = $ definition -> getDefinition ( Contao2BackendViewDefinitionInterface :: NAME ) -> getListingConfig ( ) ; $ properties = $ defin...
Format a model accordingly to the current configuration .
42,799
private function prepareLabelWithDisplayedProperties ( ModelFormatterConfigInterface $ formatter , array $ arguments , $ firstSorting , array & $ labelList ) { $ definition = $ this -> getEnvironment ( ) -> getDataDefinition ( ) ; $ listing = $ definition -> getDefinition ( Contao2BackendViewDefinitionInterface :: NAME...
Prepare labels for display with properties .