/** * @return array */ public function getStyles() { if (!static::$styles) { $paths = glob($this->app->locator()->get('theme:styles') . '/*/style.less', GLOB_NOSORT) ?: []; static::$styles = ['default']; foreach ($paths as $p) { static::$styles[] = basename(dirname($p)); } } return static::$styles; }
/** * @return array */ public function getTypes() { //todo cache this if (!$this->types) { $this->types = []; $paths = glob(App::locator()->get('formmaker:app/fields') . '/*.php', GLOB_NOSORT) ?: []; foreach ($paths as $p) { $package = array_merge(['id' => '', 'hasOptions' => 0, 'required' => 0, 'multiple' => 0, 'dependancies' => [], 'style' => [], 'prepareValue' => function (Field $field, $value) { return $value; }, 'formatValue' => function (Field $field, $value) { if (count($field->options)) { $options = $field->getOptionsRef(); if (is_array($value) && count($value)) { return array_map(function ($val) use($options) { return isset($options[$val]) ? $options[$val] : $val; }, $value); } else { return $value ? isset($options[$value]) ? [$options[$value]] : [$value] : ['-']; } } else { return is_array($value) ? count($value) ? $value : ['-'] : [$value ?: '-']; } }], include $p); $this->registerType($package); } } return $this->types; }
/** * Returns several config settings needed for the settings view. */ public function configAction() { $styles = array_map(function ($fn) { return basename($fn, '.css'); }, glob(App::locator()->get('highlight:assets/styles') . '/*.css')); return compact('styles'); }
/** * @return array */ public function getTypes() { //todo cache this if (!$this->types) { $this->types = []; $paths = glob(App::locator()->get('userprofile:app/fields') . '/*.json', GLOB_NOSORT) ?: []; foreach ($paths as $p) { $package = json_decode(file_get_contents($p), true); $this->registerType($package); } } return $this->types; }
/** * @return bool|string */ public function getImageCachepath() { if ($folder = App::locator()->get(App::module('bixie/framework')->config('image_cache_path')) and is_writable($folder)) { //all fine, quick return return $folder; } //try to create user-folder App::file()->makeDir($folder, 0755); if (!file_exists($folder)) { //create default folder $folder = $this->app['path.storage'] . '/bixframework'; if (!file_exists($folder)) { App::file()->makeDir($folder, 0755); } } if (!file_exists($folder) || !is_writable($folder)) { //give up return false; } return $folder; }
/** * @param string $source * @param array $options * @return bool|mixed */ protected function resizeImage($source, $options) { try { $image_path = App::locator()->get($source); $cachepath = $this->getCachePath($image_path, $options); if (!file_exists($cachepath)) { $image = new SimpleImage($image_path); if (!empty($options['width']) && empty($options['height'])) { $image->fit_to_width($options['width']); } if (!empty($options['height']) && empty($options['width'])) { $image->fit_to_height($options['height']); } if (!empty($options['height']) && !empty($options['width'])) { $image->thumbnail($options['width'], $options['height']); } $image->save($cachepath); } return $this->basePath($cachepath); } catch (\Exception $e) { return false; } }
/** * @param string $file * @return array|null */ protected function parse($file) { static $data = []; if (!isset($data[$file])) { $data[$file] = ($file = App::locator()->get($file)) ? json_decode(file_get_contents($file), true) : null; } return $data[$file]; }
/** * {@inheritdoc} */ public function getPath() { return App::locator()->get($this->source) ?: false; }