示例#1
0
 /**
  * {@inheritDoc}
  */
 public function getThemeCustomizableStylePresets()
 {
     $presets = array();
     $env = Environment::get();
     if ($this->isThemeCustomizable()) {
         $directory = $env->getPath(DIRNAME_THEMES . '/' . $this->getThemeHandle() . '/' . DIRNAME_CSS . '/' . DIRNAME_STYLE_CUSTOMIZER_PRESETS, $this->getPackageHandle());
         $urlroot = $env->getURL(DIRNAME_THEMES . '/' . $this->getThemeHandle() . '/' . DIRNAME_CSS, $this->getPackageHandle());
         $dh = Loader::helper('file');
         $files = $dh->getDirectoryContents($directory);
         foreach ($files as $f) {
             if (Core::make('Concrete\\Package\\AssetPipeline\\Src\\Asset\\UtilityInterface')->canFileContainCustomizableStyles($f)) {
                 $preset = Preset::getFromFile($directory . '/' . $f, $urlroot);
                 if (is_object($preset)) {
                     $presets[] = $preset;
                 }
             }
         }
     }
     usort($presets, function ($a, $b) {
         if ($a->isDefaultPreset()) {
             return -1;
         } else {
             return strcasecmp($a->getPresetDisplayName('text'), $b->getPresetDisplayName('text'));
         }
     });
     return $presets;
 }
示例#2
0
 /**
  * Gets all presets available to this theme.
  */
 public function getThemeCustomizableStylePresets()
 {
     $presets = [];
     $env = Environment::get();
     if ($this->isThemeCustomizable()) {
         $directory = $env->getPath(DIRNAME_THEMES . '/' . $this->getThemeHandle() . '/' . DIRNAME_CSS . '/' . DIRNAME_STYLE_CUSTOMIZER_PRESETS, $this->getPackageHandle());
         $urlroot = $env->getURL(DIRNAME_THEMES . '/' . $this->getThemeHandle() . '/' . DIRNAME_CSS, $this->getPackageHandle());
         $dh = Loader::helper('file');
         $files = $dh->getDirectoryContents($directory);
         foreach ($files as $f) {
             if (strrchr($f, '.') == static::THEME_CUSTOMIZABLE_STYLESHEET_EXTENSION) {
                 $preset = Preset::getFromFile($directory . '/' . $f, $urlroot);
                 if (is_object($preset)) {
                     $presets[] = $preset;
                 }
             }
         }
     }
     usort($presets, function ($a, $b) {
         if ($a->isDefaultPreset()) {
             return -1;
         } else {
             return strcasecmp($a->getPresetDisplayName('text'), $b->getPresetDisplayName('text'));
         }
     });
     return $presets;
 }