/** * Create iframe. * * @param string $src * @param string $class * @param string $id * @param array $attrs * @return string */ public function render($src, $class = '', $id = '', array $attrs = array()) { $attrs = array_merge(array('frameborder' => 0, 'content' => null, 'tag' => 'iframe', 'src' => Str::trim($src)), $attrs); $attrs = $this->_cleanAttrs($attrs); $content = $attrs['content']; unset($attrs['content']); return Html::_('tag')->render($content, Str::trim($class), Str::trim($id), $attrs); }
/** * {@inheritdoc} */ public function load(array $filters = []) { $source = Str::trim($this->_source, true); if (stripos($source, '<style') === 0) { if (preg_match('#<style.*?>(.*?)</style>#ius', $source, $matches)) { $source = $matches[1]; } } return [$this->_type, $source]; }
/** * Find theme path. * * @param string $name * @return null|string */ protected static function _find($name) { $paths = App::path('Plugin'); foreach ($paths as $path) { $path = FS::clean($path . '/', DS); $details = explode(DS, rtrim($path, DS)); $folder = Str::trim(array_pop($details)); $themeFolder = $path . $name; if (Arr::in($folder, self::$_skipFolder) || !FS::isDir($themeFolder)) { $themeFolder .= self::POSTFIX; } if (FS::isDir($themeFolder)) { return $themeFolder; } } return null; }
/** * Get class with union prefix. * * @param string $class * @return string */ protected function _class($class = 'union') { return $this->_classPrefix . '-' . Str::trim(Str::slug($class)); }
/** * Get plugin name by alias. * * @param $plugin * @return string */ public static function getNameByAlias($plugin) { $plugin = Str::trim((string) Inflector::camelize($plugin)); if (strpos($plugin, '-')) { $_details = []; $details = explode('-', $plugin); foreach ($details as $detail) { $_details[] = (string) Inflector::camelize($detail); } $plugin = implode('/', $_details); } if (strpos($plugin, '_')) { return Inflector::camelize($plugin); } return $plugin; }
/** * @return string */ protected function _getItemsAppCategory() { $app = Str::trim($this->_config->find('params.application', 1)); $cat = Str::trim($this->_config->find('params.category', '-1')); return $app . ':' . $cat; }
/** * String to upper and trim * * @param $string * @return string * * @SuppressWarnings(PHPMD.ShortMethodName) */ public static function up($string) { $cleaned = Str::up($string); $cleaned = Str::trim($cleaned); return $cleaned; }
/** * CSS compressing. * * @param string $code * @param string $cacheId * @return string */ protected function _minify($code, $cacheId) { $code = (string) $code; // remove comments $code = preg_replace('#/\\*[^*]*\\*+([^/][^*]*\\*+)*/#ius', '', $code); $code = str_replace(["\r\n", "\r", "\n", "\t", ' ', ' ', ' {', '{ ', ' }', '; ', ';;', ';;;', ';;;;', ';}'], ['', '', '', '', '', '', '{', '{', '}', ';', ';', ';', ';', '}'], $code); // remove tabs, spaces, newlines, etc. // remove spaces after and before colons $code = preg_replace('#([a-z\\-])(:\\s*|\\s*:\\s*|\\s*:)#ius', '$1:', $code); // spaces before "!important" $code = preg_replace('#(\\s*\\!important)#ius', '!important', $code); $code = Str::trim($code); return implode('', [$cacheId, $code]); }