public function style() { $nret = ''; foreach ($this->style as $style) { $nret .= HTML::style($style); } return $nret; }
public static function styles() { $buffer = "\n"; //css links foreach (self::$css as $item) { $buffer .= HTML::style($item); } //inline styles if (count(self::$styles)) { $buffer .= sprintf("<style type=\"text/css\">\n%s\n</style>", implode("\n", self::$styles)); } return $buffer; }
public static function head() { $buffer = "\n"; //css links foreach (self::$css as $item) { $buffer .= HTML::style($item); } //js links foreach (self::$js as $item) { $buffer .= HTML::script($item); } return $buffer; }
public function styles(array $media = array()) { $styles = array(); if (empty($media)) { $styles = $this->config['styles']; } else { foreach ($media as $query) { $styles[$query] = array_get($this->config['styles'], $query); } } $markup = ''; foreach (array_dot($styles) as $key => $href) { list($media) = explode('.', $key); $markup .= HTML::style($href, array('media' => $media)); } return $markup; }
/** * PUblish a single asset * * @param array $asset The asset data * @param string $type The asset type * @return string The link to the asset resource */ protected function publishAsset($asset, $type) { $output = ''; // prepare target directory if (!file_exists(dirname($asset['full']))) { File::makeDirectory(dirname($asset['full']), 0777, true); } // create the asset file File::put($asset['full'], $asset['contents']); // add the element $link = $asset['link'] . '?' . str_random(10); if ($type === 'styles') { $output .= HTML::style($link); } elseif ($type === 'scripts') { $output .= HTML::script($link); } return $output; }
/** * Process given CSS path. * * @return string */ public function css($path, $attrs = [], $timestamp = null, $secure = null) { return HTML::style($this->process($path, '.css', $timestamp), $attrs, $secure); }
/** * Prepare the given assets to be rendered to call the Casset controller * and return the HTML link to that resource. * * @param array $assets * @param string $type * * @return string */ public function prepareForController($assets, $type) { $controller_url = $this->cdn ? $this->cdn . '/' : '/'; $controller_url .= $this->route . '/' . $type; $controller_url .= '?c=' . urlencode($this->name); $links = array(); foreach ($assets as &$asset) { $attributes = $asset['attributes']; unset($asset['attributes']); unset($asset['ext']); if (empty($asset['dependencies'])) { unset($asset['dependencies']); } if (!$this->combine) { $url = $controller_url . '&files=' . base64_encode(json_encode(array($asset))); $url .= $this->version ? '&v=' . $this->version : ''; if ('style' == $type) { $links[] = HTML::style($url, $attributes); } else { $links[] = HTML::script($url, $attributes); } } } if ($this->combine) { $url = $controller_url . '&files=' . base64_encode(json_encode($assets)); $url .= $this->version ? '&v=' . $this->version : ''; if ('style' == $type) { $links[] = HTML::style($url); } else { $links[] = HTML::script($url); } } return implode('', $links); }
/** * render the html code for the given position * @param string $position to render * @return html the rendered html code */ protected function render($position = 'head') { $html = null; if ($position == 'head') { $html[] = '<meta charset="' . $this->charset . '">'; $html[] = '<title>' . e($this->getTitle()) . '</title>'; if ($this->html5Ie) { $html[] = '<!--[if lt IE 9]>' . PHP_EOL . HTML::script('//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js') . '<![endif]-->'; } if (!is_null($this->cssFiles)) { ksort($this->cssFiles, SORT_NUMERIC); foreach ($this->cssFiles as $index => $items) { foreach ($items as $item) { $html[] = HTML::style($item[0]); } } } if (!is_null($this->css)) { $html[] = '<style type="text/css">' . implode($this->css) . '</style>'; } if (!is_null($this->favicon)) { $html[] = $this->getLinkTag('shortcut icon', $this->favicon, 'image/x-icon'); } if (!is_null($this->appleTouchIcon)) { $html[] = $this->getLinkTag('apple-touch-icon', $this->appleTouchIcon); } if (!is_null($this->canonical)) { $html[] = $this->getLinkTag('canonical', $this->canonical); } $meta = $this->getMetaProperties(); if (!is_null($meta)) { $html[] = $meta; } $og_tags = $this->renderOgTags(); if (!is_null($og_tags)) { $html[] = $og_tags; } } if ($position == 'footer') { if (!is_null($this->facebook_sdk)) { $html[] = '<div id="fb-root"></div>'; $this->js($this->getFacebookSdkCode(), 'footer', array('jquery' => false)); } if (!is_null($this->twitter_sdk)) { $this->js($this->getTwitterSdkCode(), 'footer', array('jquery' => false)); } if (!is_null($this->youtube_sdk) or !is_null($this->google_plus_sdk)) { $this->js($this->getGoogleSdkCode(), 'footer', array('jquery' => false)); } } if (!is_null($this->jsFiles[$position])) { ksort($this->jsFiles[$position], SORT_NUMERIC); foreach ($this->jsFiles[$position] as $index => $items) { foreach ($items as $item) { if (!in_array($item[0], $this->jsFilesLoaded)) { $html[] = HTML::script($item[0]); $this->jsFilesLoaded[] = $item[0]; } } } } if (!is_null($this->js[$position])) { ksort($this->js[$position]); foreach ($this->js[$position] as $index => $items) { foreach ($items as $item) { if (isset($item[1]['jquery']) and $item[1]['jquery'] === true) { $jquery_code[] = $item[0]; } else { $js_code[] = $item[0]; } } } if (isset($jquery_code)) { $js_code[] = 'jQuery(document).ready(function($){ ' . implode($jquery_code) . ' });'; } $html[] = '<script>' . implode($js_code) . '</script>'; } return !is_null($html) ? implode($html) : null; }
/** * Get the links to all of the registered CSS assets. * * @param array $attributes * @return string */ public function styles($attributes = array()) { $this->assetCapture = Config::get('theme::assetCapture'); if ($style = $this->group('style')) { // This line fixing config path. $style = $this->configAssetUrl($style); return HTML::style($style, $attributes); } }