Backend\Modules\Extensions\Engine\Model::getThemes PHP Method

getThemes() public static method

Fetch the list of available themes
public static getThemes ( ) : array
return array
    public static function getThemes()
    {
        $records = array();
        $records['Core'] = array('value' => 'Core', 'label' => BL::lbl('NoTheme'), 'thumbnail' => '/src/Frontend/Core/Layout/images/thumbnail.png', 'installed' => self::isThemeInstalled('Core'), 'installable' => false);
        $finder = new Finder();
        foreach ($finder->directories()->in(FRONTEND_PATH . '/Themes')->depth(0) as $directory) {
            $pathInfoXml = PATH_WWW . '/src/Frontend/Themes/' . $directory->getBasename() . '/info.xml';
            if (!is_file($pathInfoXml)) {
                throw new Exception('info.xml is missing for the theme ' . $directory->getBasename());
            }
            try {
                $infoXml = @new \SimpleXMLElement($pathInfoXml, LIBXML_NOCDATA, true);
                $information = self::processThemeXml($infoXml);
                if (!$information) {
                    throw new Exception('Invalid info.xml');
                }
            } catch (Exception $e) {
                $information['thumbnail'] = 'thumbnail.png';
            }
            $item = array();
            $item['value'] = $directory->getBasename();
            $item['label'] = $directory->getBasename();
            $item['thumbnail'] = '/src/Frontend/Themes/' . $item['value'] . '/' . $information['thumbnail'];
            $item['installed'] = self::isThemeInstalled($item['value']);
            $item['installable'] = isset($information['templates']);
            $records[$item['value']] = $item;
        }
        return (array) $records;
    }

Usage Example

Esempio n. 1
0
 /**
  * Load the selected theme, falling back to default if none specified.
  */
 private function loadData()
 {
     // get data
     $this->selectedTheme = $this->getParameter('theme', 'string');
     // build available themes
     foreach (Model::getThemes() as $theme) {
         $this->availableThemes[$theme['value']] = $theme['label'];
     }
     // determine selected theme, based upon submitted form or default theme
     $this->selectedTheme = \SpoonFilter::getValue($this->selectedTheme, array_keys($this->availableThemes), $this->get('fork.settings')->get('Core', 'theme', 'core'));
 }
All Usage Examples Of Backend\Modules\Extensions\Engine\Model::getThemes