Resources/contao/dca/tl_c4g_map_profiles.php
public function updateDCA(DataContainer $dc)
    {
        if (!$dc->id) {
            return;
        }
        $objProfile = $this->Database->prepare("SELECT zoom_panel, geosearch_engine, be_optimize_checkboxes_limit FROM tl_c4g_map_profiles WHERE id=?")
        ->limit(1)
        ->execute($dc->id);
        if ($objProfile->numRows > 0) {

            if ($objProfile->geosearch_engine == '2') {
                $GLOBALS['TL_DCA']['tl_c4g_map_profiles']['subpalettes']['geosearch'] =
                    str_replace('geosearch_engine,','geosearch_engine,geosearch_key,',
                        $GLOBALS['TL_DCA']['tl_c4g_map_profiles']['subpalettes']['geosearch']);
                // make key-field mandatory
                $GLOBALS['TL_DCA']['tl_c4g_map_profiles']['fields']['geosearch_key']['eval']['mandatory'] = true;
            } elseif ($objProfile->geosearch_engine == '3') {
                $GLOBALS['TL_DCA']['tl_c4g_map_profiles']['subpalettes']['geosearch'] =
                    str_replace('geosearch_engine,','geosearch_engine,geosearch_customengine_url,geosearch_customengine_attribution,geosearch_key,',
                        $GLOBALS['TL_DCA']['tl_c4g_map_profiles']['subpalettes']['geosearch']);
            } elseif ($objProfile->geosearch_engine == '4') {
                $GLOBALS['TL_DCA']['tl_c4g_map_profiles']['subpalettes']['geosearch'] =
                    str_replace('geosearch_engine,','geosearch_engine,geosearch_key,',
                        $GLOBALS['TL_DCA']['tl_c4g_map_profiles']['subpalettes']['geosearch']);
            }


            // convert checkboxes to chosenfields, if there are to many locationstyles
            if (intval($objProfile->be_optimize_checkboxes_limit) > 0) {
                // basemap-options
                $objLocCount = $this->Database->prepare("SELECT COUNT(id) AS entry_count FROM tl_c4g_map_baselayers")->execute();
                if ($objLocCount->numRows > 0) {
                    if (intval($objLocCount->entry_count) >= intval($objProfile->be_optimize_checkboxes_limit)) {
                        $GLOBALS['TL_DCA']['tl_c4g_map_profiles']['fields']['baselayers']['inputType'] = 'select';
                        $GLOBALS['TL_DCA']['tl_c4g_map_profiles']['fields']['baselayers']['eval']['chosen'] = true;
                    }
                }
                // locationstyle-options
                $objLocCount = $this->Database->prepare("SELECT COUNT(id) AS entry_count FROM tl_c4g_map_locstyles")->execute();
                if ($objLocCount->numRows > 0) {
                    if (intval($objLocCount->entry_count) >= intval($objProfile->be_optimize_checkboxes_limit)) {
                        $GLOBALS['TL_DCA']['tl_c4g_map_profiles']['fields']['locstyles']['inputType'] = 'select';
                        $GLOBALS['TL_DCA']['tl_c4g_map_profiles']['fields']['locstyles']['eval']['chosen'] = true;
                    }
                }
            }
        }

    }
public function updateDCA(DataContainer $dc)
    {
        if (!$dc->id) {
            return;
        }
        $objProfile = $this->Database->prepare("SELECT zoom_panel, geosearch_engine, be_optimize_checkboxes_limit FROM tl_c4g_map_profiles WHERE id=?")
        ->limit(1)
        ->execute($dc->id);
        if ($objProfile->numRows > 0) {

            if ($objProfile->geosearch_engine == '2') {
                $GLOBALS['TL_DCA']['tl_c4g_map_profiles']['subpalettes']['geosearch'] =
                    str_replace('geosearch_engine,','geosearch_engine,geosearch_key,',
                        $GLOBALS['TL_DCA']['tl_c4g_map_profiles']['subpalettes']['geosearch']);
                // make key-field mandatory
                $GLOBALS['TL_DCA']['tl_c4g_map_profiles']['fields']['geosearch_key']['eval']['mandatory'] = true;
            } elseif ($objProfile->geosearch_engine == '3') {
                $GLOBALS['TL_DCA']['tl_c4g_map_profiles']['subpalettes']['geosearch'] =
                    str_replace('geosearch_engine,','geosearch_engine,geosearch_customengine_url,geosearch_customengine_attribution,geosearch_key,',
                        $GLOBALS['TL_DCA']['tl_c4g_map_profiles']['subpalettes']['geosearch']);
            } elseif ($objProfile->geosearch_engine == '4') {
                $GLOBALS['TL_DCA']['tl_c4g_map_profiles']['subpalettes']['geosearch'] =
                    str_replace('geosearch_engine,','geosearch_engine,geosearch_key,',
                        $GLOBALS['TL_DCA']['tl_c4g_map_profiles']['subpalettes']['geosearch']);
            }


            // convert checkboxes to chosenfields, if there are to many locationstyles
            if (intval($objProfile->be_optimize_checkboxes_limit) > 0) {
                // basemap-options
                $objLocCount = $this->Database->prepare("SELECT COUNT(id) AS entry_count FROM tl_c4g_map_baselayers")->execute();
                if ($objLocCount->numRows > 0) {
                    if (intval($objLocCount->entry_count) >= intval($objProfile->be_optimize_checkboxes_limit)) {
                        $GLOBALS['TL_DCA']['tl_c4g_map_profiles']['fields']['baselayers']['inputType'] = 'select';
                        $GLOBALS['TL_DCA']['tl_c4g_map_profiles']['fields']['baselayers']['eval']['chosen'] = true;
                    }
                }
                // locationstyle-options
                $objLocCount = $this->Database->prepare("SELECT COUNT(id) AS entry_count FROM tl_c4g_map_locstyles")->execute();
                if ($objLocCount->numRows > 0) {
                    if (intval($objLocCount->entry_count) >= intval($objProfile->be_optimize_checkboxes_limit)) {
                        $GLOBALS['TL_DCA']['tl_c4g_map_profiles']['fields']['locstyles']['inputType'] = 'select';
                        $GLOBALS['TL_DCA']['tl_c4g_map_profiles']['fields']['locstyles']['eval']['chosen'] = true;
                    }
                }
            }
        }

    }
public function updateDCA ( DataContainer $ dc ) { if ( ! $ dc -> id ) { return ; } $ objProfile = $ this -> Database -> prepare ( "SELECT zoom_panel, geosearch_engine, be_optimize_checkboxes_limit FROM tl_c4g_map_profiles WHERE id=?" ) -> limit ( 1 ) -> execute ( $ dc -> id ) ; if ( $ objProfile -> numRows > 0 ) { if ( $ objProfile -> geosearch_engine == '2' ) { $ GLOBALS [ 'TL_DCA' ] [ 'tl_c4g_map_profiles' ] [ 'subpalettes' ] [ 'geosearch' ] = str_replace ( 'geosearch_engine,' , 'geosearch_engine,geosearch_key,' , $ GLOBALS [ 'TL_DCA' ] [ 'tl_c4g_map_profiles' ] [ 'subpalettes' ] [ 'geosearch' ] ) ; // make key-field mandatory $ GLOBALS [ 'TL_DCA' ] [ 'tl_c4g_map_profiles' ] [ 'fields' ] [ 'geosearch_key' ] [ 'eval' ] [ 'mandatory' ] = true ; } elseif ( $ objProfile -> geosearch_engine == '3' ) { $ GLOBALS [ 'TL_DCA' ] [ 'tl_c4g_map_profiles' ] [ 'subpalettes' ] [ 'geosearch' ] = str_replace ( 'geosearch_engine,' , 'geosearch_engine,geosearch_customengine_url,geosearch_customengine_attribution,geosearch_key,' , $ GLOBALS [ 'TL_DCA' ] [ 'tl_c4g_map_profiles' ] [ 'subpalettes' ] [ 'geosearch' ] ) ; } elseif ( $ objProfile -> geosearch_engine == '4' ) { $ GLOBALS [ 'TL_DCA' ] [ 'tl_c4g_map_profiles' ] [ 'subpalettes' ] [ 'geosearch' ] = str_replace ( 'geosearch_engine,' , 'geosearch_engine,geosearch_key,' , $ GLOBALS [ 'TL_DCA' ] [ 'tl_c4g_map_profiles' ] [ 'subpalettes' ] [ 'geosearch' ] ) ; } // convert checkboxes to chosenfields, if there are to many locationstyles if ( intval ( $ objProfile -> be_optimize_checkboxes_limit ) > 0 ) { // basemap-options $ objLocCount = $ this -> Database -> prepare ( "SELECT COUNT(id) AS entry_count FROM tl_c4g_map_baselayers" ) -> execute ( ) ; if ( $ objLocCount -> numRows > 0 ) { if ( intval ( $ objLocCount -> entry_count ) >= intval ( $ objProfile -> be_optimize_checkboxes_limit ) ) { $ GLOBALS [ 'TL_DCA' ] [ 'tl_c4g_map_profiles' ] [ 'fields' ] [ 'baselayers' ] [ 'inputType' ] = 'select' ; $ GLOBALS [ 'TL_DCA' ] [ 'tl_c4g_map_profiles' ] [ 'fields' ] [ 'baselayers' ] [ 'eval' ] [ 'chosen' ] = true ; } } // locationstyle-options $ objLocCount = $ this -> Database -> prepare ( "SELECT COUNT(id) AS entry_count FROM tl_c4g_map_locstyles" ) -> execute ( ) ; if ( $ objLocCount -> numRows > 0 ) { if ( intval ( $ objLocCount -> entry_count ) >= intval ( $ objProfile -> be_optimize_checkboxes_limit ) ) { $ GLOBALS [ 'TL_DCA' ] [ 'tl_c4g_map_profiles' ] [ 'fields' ] [ 'locstyles' ] [ 'inputType' ] = 'select' ; $ GLOBALS [ 'TL_DCA' ] [ 'tl_c4g_map_profiles' ] [ 'fields' ] [ 'locstyles' ] [ 'eval' ] [ 'chosen' ] = true ; } } } } }
Update the palette information that depend on other values
Update the palette information that depend on other values