public function itemsProcFunc(&$params)
    {
        // if this tt_content element is inline element of mask
        if ($params["row"]["colPos"] == $this->colPos) {
            $fieldHelper = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Helper\\FieldHelper');
            $this->storageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Domain\\Repository\\StorageRepository');

            if (isset($_REQUEST["ajax"]["context"])) {
                $ajaxContext = json_decode($_REQUEST["ajax"]["context"]);
                $fieldKey = str_replace("_parent", "", $ajaxContext->config->foreign_field);
            } else {
                $fields = $params["row"];
                foreach ($fields as $key => $field) {
                    // search for the parent field, to get the key of mask field this content element belongs to
                    if ($this->startsWith($key, "tx_mask_") && $this->endsWith($key, "_parent") && $field > 0) {

                        // if a parent field was found, that is filled with a uid, extract the mask field name from it
                        $fieldKey = str_replace("_parent", "", $key);

                        // if one parent field was found, don't continue search, there can only be one parent
                        break;
                    }
                }
            }

            // load the json configuration of this field
            $table = $fieldHelper->getFieldType($fieldKey);
            $fieldConfiguration = $this->storageRepository->loadField($table, $fieldKey);

            // if there is a restriction of cTypes specified
            if (is_array($fieldConfiguration["cTypes"])) {

                // prepare array of allowed cTypes, with cTypes as keys
                $cTypes = array_flip($fieldConfiguration["cTypes"]);

                // and check each item if it is allowed. if not, unset it
                foreach ($params["items"] as $itemKey => $item) {
                    if (!isset($cTypes[$item[1]])) {
                        unset($params["items"][$itemKey]);
                    }
                }
            }
        } else { // if it is not inline tt_content element
            // and if other itemsProcFunc from other extension was available (e.g. gridelements),
            // then call it now and let it render the items
            if (!empty($params["config"]["m_itemsProcFunc"])) {
                \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($params["config"]["m_itemsProcFunc"], $params,
                    $this);
            }
        }
    }
public function itemsProcFunc(&$params)
    {
        // if this tt_content element is inline element of mask
        if ($params["row"]["colPos"] == $this->colPos) {
            $fieldHelper = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Helper\\FieldHelper');
            $this->storageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Domain\\Repository\\StorageRepository');

            if (isset($_REQUEST["ajax"]["context"])) {
                $ajaxContext = json_decode($_REQUEST["ajax"]["context"]);
                $fieldKey = str_replace("_parent", "", $ajaxContext->config->foreign_field);
            } else {
                $fields = $params["row"];
                foreach ($fields as $key => $field) {
                    // search for the parent field, to get the key of mask field this content element belongs to
                    if ($this->startsWith($key, "tx_mask_") && $this->endsWith($key, "_parent") && $field > 0) {

                        // if a parent field was found, that is filled with a uid, extract the mask field name from it
                        $fieldKey = str_replace("_parent", "", $key);

                        // if one parent field was found, don't continue search, there can only be one parent
                        break;
                    }
                }
            }

            // load the json configuration of this field
            $table = $fieldHelper->getFieldType($fieldKey);
            $fieldConfiguration = $this->storageRepository->loadField($table, $fieldKey);

            // if there is a restriction of cTypes specified
            if (is_array($fieldConfiguration["cTypes"])) {

                // prepare array of allowed cTypes, with cTypes as keys
                $cTypes = array_flip($fieldConfiguration["cTypes"]);

                // and check each item if it is allowed. if not, unset it
                foreach ($params["items"] as $itemKey => $item) {
                    if (!isset($cTypes[$item[1]])) {
                        unset($params["items"][$itemKey]);
                    }
                }
            }
        } else { // if it is not inline tt_content element
            // and if other itemsProcFunc from other extension was available (e.g. gridelements),
            // then call it now and let it render the items
            if (!empty($params["config"]["m_itemsProcFunc"])) {
                \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($params["config"]["m_itemsProcFunc"], $params,
                    $this);
            }
        }
    }
public function itemsProcFunc ( & $ params ) { // if this tt_content element is inline element of mask if ( $ params [ "row" ] [ "colPos" ] == $ this -> colPos ) { $ fieldHelper = \ TYPO3 \ CMS \ Core \ Utility \ GeneralUtility :: makeInstance ( 'MASK\\Mask\\Helper\\FieldHelper' ) ; $ this -> storageRepository = \ TYPO3 \ CMS \ Core \ Utility \ GeneralUtility :: makeInstance ( 'MASK\\Mask\\Domain\\Repository\\StorageRepository' ) ; if ( isset ( $ _REQUEST [ "ajax" ] [ "context" ] ) ) { $ ajaxContext = json_decode ( $ _REQUEST [ "ajax" ] [ "context" ] ) ; $ fieldKey = str_replace ( "_parent" , "" , $ ajaxContext -> config -> foreign_field ) ; } else { $ fields = $ params [ "row" ] ; foreach ( $ fields as $ key => $ field ) { // search for the parent field, to get the key of mask field this content element belongs to if ( $ this -> startsWith ( $ key , "tx_mask_" ) && $ this -> endsWith ( $ key , "_parent" ) && $ field > 0 ) { // if a parent field was found, that is filled with a uid, extract the mask field name from it $ fieldKey = str_replace ( "_parent" , "" , $ key ) ; // if one parent field was found, don't continue search, there can only be one parent break ; } } } // load the json configuration of this field $ table = $ fieldHelper -> getFieldType ( $ fieldKey ) ; $ fieldConfiguration = $ this -> storageRepository -> loadField ( $ table , $ fieldKey ) ; // if there is a restriction of cTypes specified if ( is_array ( $ fieldConfiguration [ "cTypes" ] ) ) { // prepare array of allowed cTypes, with cTypes as keys $ cTypes = array_flip ( $ fieldConfiguration [ "cTypes" ] ) ; // and check each item if it is allowed. if not, unset it foreach ( $ params [ "items" ] as $ itemKey => $ item ) { if ( ! isset ( $ cTypes [ $ item [ 1 ] ] ) ) { unset ( $ params [ "items" ] [ $ itemKey ] ) ; } } } } else { // if it is not inline tt_content element // and if other itemsProcFunc from other extension was available (e.g. gridelements), // then call it now and let it render the items if ( ! empty ( $ params [ "config" ] [ "m_itemsProcFunc" ] ) ) { \ TYPO3 \ CMS \ Core \ Utility \ GeneralUtility :: callUserFunction ( $ params [ "config" ] [ "m_itemsProcFunc" ] , $ params , $ this ) ; } } }
Render the allowed CTypes for nested content elements
@param array $params
Render the allowed CTypes for nested content elements