Contao\DC_File::getPalette PHP Метод

getPalette() публичный Метод

Return the name of the current palette
public getPalette ( ) : string
Результат string
    public function getPalette()
    {
        $palette = 'default';
        $strPalette = $GLOBALS['TL_DCA'][$this->strTable]['palettes'][$palette];
        // Check whether there are selector fields
        if (!empty($GLOBALS['TL_DCA'][$this->strTable]['palettes']['__selector__'])) {
            $sValues = array();
            $subpalettes = array();
            foreach ($GLOBALS['TL_DCA'][$this->strTable]['palettes']['__selector__'] as $name) {
                $trigger = \Config::get($name);
                // Overwrite the trigger if the page is not reloaded
                if (\Input::post('FORM_SUBMIT') == $this->strTable) {
                    $key = \Input::get('act') == 'editAll' ? $name . '_' . $this->intId : $name;
                    if (!$GLOBALS['TL_DCA'][$this->strTable]['fields'][$name]['eval']['submitOnChange']) {
                        $trigger = \Input::post($key);
                    }
                }
                if ($trigger != '') {
                    if ($GLOBALS['TL_DCA'][$this->strTable]['fields'][$name]['inputType'] == 'checkbox' && !$GLOBALS['TL_DCA'][$this->strTable]['fields'][$name]['eval']['multiple']) {
                        $sValues[] = $name;
                        // Look for a subpalette
                        if (strlen($GLOBALS['TL_DCA'][$this->strTable]['subpalettes'][$name])) {
                            $subpalettes[$name] = $GLOBALS['TL_DCA'][$this->strTable]['subpalettes'][$name];
                        }
                    } else {
                        $sValues[] = $trigger;
                        $key = $name . '_' . $trigger;
                        // Look for a subpalette
                        if (strlen($GLOBALS['TL_DCA'][$this->strTable]['subpalettes'][$key])) {
                            $subpalettes[$name] = $GLOBALS['TL_DCA'][$this->strTable]['subpalettes'][$key];
                        }
                    }
                }
            }
            // Build possible palette names from the selector values
            if (!count($sValues)) {
                $names = array('default');
            } elseif (count($sValues) > 1) {
                $names = $this->combiner($sValues);
            } else {
                $names = array($sValues[0]);
            }
            // Get an existing palette
            foreach ($names as $paletteName) {
                if (strlen($GLOBALS['TL_DCA'][$this->strTable]['palettes'][$paletteName])) {
                    $strPalette = $GLOBALS['TL_DCA'][$this->strTable]['palettes'][$paletteName];
                    break;
                }
            }
            // Include subpalettes
            foreach ($subpalettes as $k => $v) {
                $strPalette = preg_replace('/\\b' . preg_quote($k, '/') . '\\b/i', $k . ',[' . $k . '],' . $v . ',[EOF]', $strPalette);
            }
        }
        return $strPalette;
    }