Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 327 lines (305 sloc) 13.89 kb
e7f3c31 GWoo going lithium
gwoo authored
1 <?php
2 /**
3 * Lithium: the most rad php framework
4 *
14de7bf GWoo Happy 2012!
gwoo authored
5 * @copyright Copyright 2012, Union of RAD (http://union-of-rad.org)
e7f3c31 GWoo going lithium
gwoo authored
6 * @license http://opensource.org/licenses/bsd-license.php The BSD License
7 */
8
ad490d8 GWoo singularizing some namespaces, merging 0.3-console and some other change...
gwoo authored
9 namespace lithium\template\helper;
e7f3c31 GWoo going lithium
gwoo authored
10
a33c51f Nate Abele Adding docblocks and fixing code formatting.
nateabele authored
11 /**
12 * A template helper that assists in generating HTML content. Accessible in templates via
13 * `$this->html`, which will auto-load this helper into the rendering context. For examples of how
14 * to use this helper, see the documentation for a specific method. For a list of the
15 * template strings this helper uses, see the `$_strings` property.
16 */
e7f3c31 GWoo going lithium
gwoo authored
17 class Html extends \lithium\template\Helper {
18
19 /**
20 * String templates used by this helper.
21 *
22 * @var array
23 */
24 protected $_strings = array(
25 'block' => '<div{:options}>{:content}</div>',
26 'block-end' => '</div>',
27 'block-start' => '<div{:options}>',
a2ca302 David Persson Renaming `$charset` parameter to `$encoding`.
davidpersson authored
28 'charset' => '<meta charset="{:encoding}" />',
e7f3c31 GWoo going lithium
gwoo authored
29 'image' => '<img src="{:path}"{:options} />',
30 'js-block' => '<script type="text/javascript"{:options}>{:content}</script>',
31 'js-end' => '</script>',
32 'js-start' => '<script type="text/javascript"{:options}>',
33 'link' => '<a href="{:url}"{:options}>{:title}</a>',
34 'list' => '<ul{:options}>{:content}</ul>',
35 'list-item' => '<li{:options}>{:content}</li>',
36 'meta' => '<meta{:options}/>',
37 'meta-link' => '<link href="{:url}"{:options} />',
38 'para' => '<p{:options}>{:content}</p>',
39 'para-start' => '<p{:options}>',
c8b7b6d Nate Abele Adding plugin lookup support for assets in `http\Media::asset()`, refact...
nateabele authored
40 'script' => '<script type="text/javascript" src="{:path}"{:options}></script>',
e7f3c31 GWoo going lithium
gwoo authored
41 'style' => '<style type="text/css"{:options}>{:content}</style>',
42 'style-import' => '<style type="text/css"{:options}>@import url({:url});</style>',
43 'style-link' => '<link rel="{:type}" type="text/css" href="{:path}"{:options} />',
44 'table-header' => '<th{:options}>{:content}</th>',
45 'table-header-row' => '<tr{:options}>{:content}</tr>',
46 'table-cell' => '<td{:options}>{:content}</td>',
47 'table-row' => '<tr{:options}>{:content}</tr>',
48 'tag' => '<{:name}{:options}>{:content}</{:name}>',
49 'tag-end' => '</{:name}>',
50 'tag-start' => '<{:name}{:options}>'
51 );
52
53 /**
54 * Data used for custom <meta /> links.
55 *
56 * @var array
57 */
58 protected $_metaLinks = array(
59 'atom' => array('type' => 'application/atom+xml', 'rel' => 'alternate'),
f8d75ca GWoo adding more tests and refactoring `\template`. Most of the changes are i...
gwoo authored
60 'rss' => array('type' => 'application/rss+xml', 'rel' => 'alternate'),
e7f3c31 GWoo going lithium
gwoo authored
61 'icon' => array('type' => 'image/x-icon', 'rel' => 'icon')
62 );
63
64 /**
e6a7d28 Flavius Aspra Added "meta" functionality to the Html helper and to the Renderer
flavius authored
65 * List of meta tags to cache and to output.
66 *
67 * @var array
68 * @see lithium\template\helper\Html::meta()
69 */
70 protected $_metaList = array();
71
72 /**
e7f3c31 GWoo going lithium
gwoo authored
73 * Used by output handlers to calculate asset paths in conjunction with the `Media` class.
74 *
75 * @var array
9e2105b GWoo Moving \http to \net\http and \util\socket to \net\socket.
gwoo authored
76 * @see lithium\net\http\Media
e7f3c31 GWoo going lithium
gwoo authored
77 */
78 public $contentMap = array(
79 'script' => 'js',
80 'style' => 'css',
81 'image' => 'image',
82 '_metaLink' => 'generic'
83 );
84
85 /**
70c0f17 David Persson Adding documentation to `charset()` in `Html` helper.
davidpersson authored
86 * Returns a charset meta-tag for declaring the encoding of the document.
e7f3c31 GWoo going lithium
gwoo authored
87 *
70c0f17 David Persson Adding documentation to `charset()` in `Html` helper.
davidpersson authored
88 * The terms character set (here: charset) and character encoding (here:
89 * encoding) were historically synonymous. The terms now have related but
90 * distinct meanings. Whenever possible Lithium tries to use precise
91 * terminology. Since HTML uses the term `charset` we expose this method
891280f David Persson Correcting a few typos.
davidpersson authored
92 * under the exact same name. This caters to the expectation towards a HTML
93 * helper. However the rest of the framework will use the term `encoding`
94 * when talking about character encoding.
70c0f17 David Persson Adding documentation to `charset()` in `Html` helper.
davidpersson authored
95 *
96 * It is suggested that uppercase letters should be used when specifying
97 * the encoding. HTML specs don't require it to be uppercase and sites in
98 * the wild most often use the lowercase variant. On the other hand must
99 * XML parsers (those may not be relevant in this context anyway) not
891280f David Persson Correcting a few typos.
davidpersson authored
100 * support lowercase encodings. This and the fact that IANA lists only
101 * encodings with uppercase characters led to the above suggestion.
70c0f17 David Persson Adding documentation to `charset()` in `Html` helper.
davidpersson authored
102 *
103 * @see lithium\net\http\Response::$encoding
104 * @link http://www.iana.org/assignments/character-sets
105 * @param string $encoding The character encoding to be used in the meta tag.
106 * Defaults to the encoding of the `Response` object attached to the
107 * current context. The default encoding of that object is `UTF-8`.
108 * The string given here is not manipulated in any way, so that
109 * values are rendered literally. Also see above note about casing.
110 * @return string A meta tag containing the specified encoding (literally).
e7f3c31 GWoo going lithium
gwoo authored
111 */
a2ca302 David Persson Renaming `$charset` parameter to `$encoding`.
davidpersson authored
112 public function charset($encoding = null) {
7e42ea7 Nate Abele Making dependency checks more test-friendly in `Html` helper.
nateabele authored
113 if ($response = $this->_context->response()) {
114 $encoding = $encoding ?: $response->encoding;
115 }
a2ca302 David Persson Renaming `$charset` parameter to `$encoding`.
davidpersson authored
116 return $this->_render(__METHOD__, 'charset', compact('encoding'));
e7f3c31 GWoo going lithium
gwoo authored
117 }
118
119 /**
a33c51f Nate Abele Adding docblocks and fixing code formatting.
nateabele authored
120 * Creates an HTML link (`<a />`) or a document meta-link (`<link />`).
e7f3c31 GWoo going lithium
gwoo authored
121 *
5f16dca Mehdi Lahmam Revamp Html helper API docs
mehlah authored
122 * If `$url` starts with `'http://'` or `'https://'`, this is treated as an external link.
a33c51f Nate Abele Adding docblocks and fixing code formatting.
nateabele authored
123 * Otherwise, it is treated as a path to controller/action and parsed using
124 * the `Router::match()` method (where `Router` is the routing class dependency specified by
125 * the rendering context, i.e. `lithium\template\view\Renderer::$_classes`).
e7f3c31 GWoo going lithium
gwoo authored
126 *
a33c51f Nate Abele Adding docblocks and fixing code formatting.
nateabele authored
127 * If `$url` is empty, `$title` is used in its place.
e7f3c31 GWoo going lithium
gwoo authored
128 *
5f16dca Mehdi Lahmam Revamp Html helper API docs
mehlah authored
129 * @param string $title The content to be wrapped by an `<a />` tag,
c4e6436 Mehdi Lahmam Minor fixes
mehlah authored
130 * or the `title` attribute of a meta-link `<link />`.
a33c51f Nate Abele Adding docblocks and fixing code formatting.
nateabele authored
131 * @param mixed $url Can be a string representing a URL relative to the base of your Lithium
b746e26 Christopher Garvis cleaned up syntax
cgarvis authored
132 * application, an external URL (starts with `'http://'` or `'https://'`), an
133 * anchor name starting with `'#'` (i.e. `'#top'`), or an array defining a set
134 * of request parameters that should be matched against a route in `Router`.
5f16dca Mehdi Lahmam Revamp Html helper API docs
mehlah authored
135 * @param array $options The available options are:
5450f20 Michael Nitschinger QA: various max line length fixes.
daschl authored
136 * - `'escape'` _boolean_: Whether or not the title content should be escaped.
e5d7338 Nate Abele Merge branch 'dev'
nateabele authored
137 * Defaults to `true`.
5f16dca Mehdi Lahmam Revamp Html helper API docs
mehlah authored
138 * - `'type'` _string_: The meta-link type, which is looked up in `Html::$_metaLinks`.
41ab56f Nate Abele Cleaning up coding standards issues.
nateabele authored
139 * By default it accepts `atom`, `rss` and `icon`.
140 * If a `type` is specified, this method will render a document meta-link (`<link />`),
141 * instead of an HTML link (`<a />`).
5f16dca Mehdi Lahmam Revamp Html helper API docs
mehlah authored
142 * - any other options specified are rendered as HTML attributes of the element.
a33c51f Nate Abele Adding docblocks and fixing code formatting.
nateabele authored
143 * @return string Returns an `<a />` or `<link />` element.
e7f3c31 GWoo going lithium
gwoo authored
144 */
f80098d Nate Abele Adding type hinting to constructor `$config` arrays and all applicable `...
nateabele authored
145 public function link($title, $url = null, array $options = array()) {
f8d75ca GWoo adding more tests and refactoring `\template`. Most of the changes are i...
gwoo authored
146 $defaults = array('escape' => true, 'type' => null);
147 list($scope, $options) = $this->_options($defaults, $options);
e7f3c31 GWoo going lithium
gwoo authored
148
f8d75ca GWoo adding more tests and refactoring `\template`. Most of the changes are i...
gwoo authored
149 if (isset($scope['type']) && $type = $scope['type']) {
150 $options += compact('title');
e7f3c31 GWoo going lithium
gwoo authored
151 return $this->_metaLink($type, $url, $options);
152 }
153
154 $url = is_null($url) ? $title : $url;
f8d75ca GWoo adding more tests and refactoring `\template`. Most of the changes are i...
gwoo authored
155 return $this->_render(__METHOD__, 'link', compact('title', 'url', 'options'), $scope);
e7f3c31 GWoo going lithium
gwoo authored
156 }
157
158 /**
a33c51f Nate Abele Adding docblocks and fixing code formatting.
nateabele authored
159 * Returns a JavaScript include tag (`<script />` element). If the filename is prefixed with
5f16dca Mehdi Lahmam Revamp Html helper API docs
mehlah authored
160 * `'/'`, the path will be relative to the base path of your application. Otherwise, the path
a33c51f Nate Abele Adding docblocks and fixing code formatting.
nateabele authored
161 * will be relative to your JavaScript path, usually `webroot/js`.
e7f3c31 GWoo going lithium
gwoo authored
162 *
5f16dca Mehdi Lahmam Revamp Html helper API docs
mehlah authored
163 * @link http://lithify.me/docs/manual/handling-http-requests/views.wiki
164 * @param mixed $path String The name of a JavaScript file, or an array of names.
165 * @param array $options Available options are:
166 * - `'inline'` _boolean_: Whether or not the `<script />` element should be output inline.
41ab56f Nate Abele Cleaning up coding standards issues.
nateabele authored
167 * When set to false, the `scripts()` handler prints out the script, and other specified
168 * scripts to be included in the layout. Defaults to `true`. This is useful when
169 * page-specific scripts are created inline in the page, and you'd like to place them
170 * in the `<head />` along with your other scripts.
5f16dca Mehdi Lahmam Revamp Html helper API docs
mehlah authored
171 * - any other options specified are rendered as HTML attributes of the element.
e7f3c31 GWoo going lithium
gwoo authored
172 * @return string
f8d75ca GWoo adding more tests and refactoring `\template`. Most of the changes are i...
gwoo authored
173 * @filter This method can be filtered.
e7f3c31 GWoo going lithium
gwoo authored
174 */
f80098d Nate Abele Adding type hinting to constructor `$config` arrays and all applicable `...
nateabele authored
175 public function script($path, array $options = array()) {
e7f3c31 GWoo going lithium
gwoo authored
176 $defaults = array('inline' => true);
f8d75ca GWoo adding more tests and refactoring `\template`. Most of the changes are i...
gwoo authored
177 list($scope, $options) = $this->_options($defaults, $options);
e7f3c31 GWoo going lithium
gwoo authored
178
179 if (is_array($path)) {
53fcf4d Nate Abele Fixing issue in `Html` helper where multi-resource calls to `script()` a...
nateabele authored
180 foreach ($path as $i => $item) {
f8d75ca GWoo adding more tests and refactoring `\template`. Most of the changes are i...
gwoo authored
181 $path[$i] = $this->script($item, $scope);
53fcf4d Nate Abele Fixing issue in `Html` helper where multi-resource calls to `script()` a...
nateabele authored
182 }
f8d75ca GWoo adding more tests and refactoring `\template`. Most of the changes are i...
gwoo authored
183 return ($scope['inline']) ? join("\n\t", $path) . "\n" : null;
e7f3c31 GWoo going lithium
gwoo authored
184 }
f8d75ca GWoo adding more tests and refactoring `\template`. Most of the changes are i...
gwoo authored
185 $m = __METHOD__;
186 $params = compact('path', 'options');
e7f3c31 GWoo going lithium
gwoo authored
187
43e8b8c Nate Abele Updating helpers for `_filter()` refactor. Adding test coverage for form...
nateabele authored
188 $script = $this->_filter(__METHOD__, $params, function($self, $params, $chain) use ($m) {
c8b7b6d Nate Abele Adding plugin lookup support for assets in `http\Media::asset()`, refact...
nateabele authored
189 return $self->invokeMethod('_render', array($m, 'script', $params));
e7f3c31 GWoo going lithium
gwoo authored
190 });
f8d75ca GWoo adding more tests and refactoring `\template`. Most of the changes are i...
gwoo authored
191 if ($scope['inline']) {
e7f3c31 GWoo going lithium
gwoo authored
192 return $script;
193 }
12632ed Nate Abele Adding `view\Renderer::set()` to allow variables to be passed between te...
nateabele authored
194 if ($this->_context) {
195 $this->_context->scripts($script);
196 }
e7f3c31 GWoo going lithium
gwoo authored
197 }
198
199 /**
41ab56f Nate Abele Cleaning up coding standards issues.
nateabele authored
200 * Creates a `<link />` element for CSS stylesheets or a `<style />` tag. If the filename is
201 * prefixed with `'/'`, the path will be relative to the base path of your application.
202 * Otherwise, the path will be relative to your stylesheets path, usually `webroot/css`.
e7f3c31 GWoo going lithium
gwoo authored
203 *
5f16dca Mehdi Lahmam Revamp Html helper API docs
mehlah authored
204 * @param mixed $path The name of a CSS stylesheet in `/app/webroot/css`, or an array
e7f3c31 GWoo going lithium
gwoo authored
205 * containing names of CSS stylesheets in that directory.
5f16dca Mehdi Lahmam Revamp Html helper API docs
mehlah authored
206 * @param array $options Available options are:
207 * - `'inline'` _boolean_: Whether or not the `<style />` element should be output inline.
41ab56f Nate Abele Cleaning up coding standards issues.
nateabele authored
208 * When set to `false`, the `styles()` handler prints out the styles, and other specified
209 * styles to be included in the layout. Defaults to `true`. This is useful when
210 * page-specific styles are created inline in the page, and you'd like to place them in
211 * the `<head />` along with your other styles.
5f16dca Mehdi Lahmam Revamp Html helper API docs
mehlah authored
212 * - `'type'` _string_: By default, accepts `stylesheet` or `import`,
41ab56f Nate Abele Cleaning up coding standards issues.
nateabele authored
213 * which respectively correspond to `style-link` and `style-import` strings templates
214 * defined in `Html::$_strings`.
5f16dca Mehdi Lahmam Revamp Html helper API docs
mehlah authored
215 * - any other options specified are rendered as HTML attributes of the element.
e7f3c31 GWoo going lithium
gwoo authored
216 * @return string CSS <link /> or <style /> tag, depending on the type of link.
a33c51f Nate Abele Adding docblocks and fixing code formatting.
nateabele authored
217 * @filter This method can be filtered.
e7f3c31 GWoo going lithium
gwoo authored
218 */
f80098d Nate Abele Adding type hinting to constructor `$config` arrays and all applicable `...
nateabele authored
219 public function style($path, array $options = array()) {
e7f3c31 GWoo going lithium
gwoo authored
220 $defaults = array('type' => 'stylesheet', 'inline' => true);
f8d75ca GWoo adding more tests and refactoring `\template`. Most of the changes are i...
gwoo authored
221 list($scope, $options) = $this->_options($defaults, $options);
e7f3c31 GWoo going lithium
gwoo authored
222
223 if (is_array($path)) {
53fcf4d Nate Abele Fixing issue in `Html` helper where multi-resource calls to `script()` a...
nateabele authored
224 foreach ($path as $i => $item) {
f8d75ca GWoo adding more tests and refactoring `\template`. Most of the changes are i...
gwoo authored
225 $path[$i] = $this->style($item, $scope);
53fcf4d Nate Abele Fixing issue in `Html` helper where multi-resource calls to `script()` a...
nateabele authored
226 }
f8d75ca GWoo adding more tests and refactoring `\template`. Most of the changes are i...
gwoo authored
227 return ($scope['inline']) ? join("\n\t", $path) . "\n" : null;
e7f3c31 GWoo going lithium
gwoo authored
228 }
c8b7b6d Nate Abele Adding plugin lookup support for assets in `http\Media::asset()`, refact...
nateabele authored
229 $method = __METHOD__;
f8d75ca GWoo adding more tests and refactoring `\template`. Most of the changes are i...
gwoo authored
230 $type = $scope['type'];
231 $params = compact('type', 'path', 'options');
c8b7b6d Nate Abele Adding plugin lookup support for assets in `http\Media::asset()`, refact...
nateabele authored
232 $filter = function($self, $params, $chain) use ($defaults, $method) {
f8d75ca GWoo adding more tests and refactoring `\template`. Most of the changes are i...
gwoo authored
233 $template = ($params['type'] == 'import') ? 'style-import' : 'style-link';
c8b7b6d Nate Abele Adding plugin lookup support for assets in `http\Media::asset()`, refact...
nateabele authored
234 return $self->invokeMethod('_render', array($method, $template, $params));
e7f3c31 GWoo going lithium
gwoo authored
235 };
f8d75ca GWoo adding more tests and refactoring `\template`. Most of the changes are i...
gwoo authored
236 $style = $this->_filter($method, $params, $filter);
12632ed Nate Abele Adding `view\Renderer::set()` to allow variables to be passed between te...
nateabele authored
237
f8d75ca GWoo adding more tests and refactoring `\template`. Most of the changes are i...
gwoo authored
238 if ($scope['inline']) {
12632ed Nate Abele Adding `view\Renderer::set()` to allow variables to be passed between te...
nateabele authored
239 return $style;
240 }
241 if ($this->_context) {
242 $this->_context->styles($style);
243 }
e7f3c31 GWoo going lithium
gwoo authored
244 }
209102b David Persson Adding blank line between docblock and closing curly brace.
davidpersson authored
245
e6a7d28 Flavius Aspra Added "meta" functionality to the Html helper and to the Renderer
flavius authored
246 /**
5f16dca Mehdi Lahmam Revamp Html helper API docs
mehlah authored
247 * Creates a tag for the `<head>` section of your document.
e6a7d28 Flavius Aspra Added "meta" functionality to the Html helper and to the Renderer
flavius authored
248 *
aa80c53 Flavius Aspra Added head() feature to the html helper and to the Renderer
flavius authored
249 * If there is a rendering context, then it also pushes the resulting tag to it.
250 *
5f16dca Mehdi Lahmam Revamp Html helper API docs
mehlah authored
251 * The `$options` must match the named parameters from `$_strings` for the
252 * given `$tag`.
c219785 Nate Abele Implementing nested object support in `Form` helper.
nateabele authored
253 *
5f16dca Mehdi Lahmam Revamp Html helper API docs
mehlah authored
254 * @param string $tag the name of a key in `$_strings`
255 * @param array $options the options required by `$_strings[$tag]`
256 * @return mixed a string if successful, otherwise `null`
e6a7d28 Flavius Aspra Added "meta" functionality to the Html helper and to the Renderer
flavius authored
257 * @filter This method can be filtered.
258 */
aa80c53 Flavius Aspra Added head() feature to the html helper and to the Renderer
flavius authored
259 public function head($tag, array $options) {
6e0ab9c David Persson QA: Updating control structures for correct spacing.
davidpersson authored
260 if (!isset($this->_strings[$tag])) {
261 return null;
aa80c53 Flavius Aspra Added head() feature to the html helper and to the Renderer
flavius authored
262 }
e6a7d28 Flavius Aspra Added "meta" functionality to the Html helper and to the Renderer
flavius authored
263 $method = __METHOD__;
aa80c53 Flavius Aspra Added head() feature to the html helper and to the Renderer
flavius authored
264 $filter = function($self, $options, $chain) use ($method, $tag) {
265 return $self->invokeMethod('_render', array($method, $tag, $options));
e6a7d28 Flavius Aspra Added "meta" functionality to the Html helper and to the Renderer
flavius authored
266 };
aa80c53 Flavius Aspra Added head() feature to the html helper and to the Renderer
flavius authored
267 $head = $this->_filter($method, $options, $filter);
6e0ab9c David Persson QA: Updating control structures for correct spacing.
davidpersson authored
268 if ($this->_context) {
aa80c53 Flavius Aspra Added head() feature to the html helper and to the Renderer
flavius authored
269 $this->_context->head($head);
e6a7d28 Flavius Aspra Added "meta" functionality to the Html helper and to the Renderer
flavius authored
270 }
aa80c53 Flavius Aspra Added head() feature to the html helper and to the Renderer
flavius authored
271 return $head;
e6a7d28 Flavius Aspra Added "meta" functionality to the Html helper and to the Renderer
flavius authored
272 }
e7f3c31 GWoo going lithium
gwoo authored
273
274 /**
5f16dca Mehdi Lahmam Revamp Html helper API docs
mehlah authored
275 * Creates a formatted `<img />` element.
e7f3c31 GWoo going lithium
gwoo authored
276 *
5f16dca Mehdi Lahmam Revamp Html helper API docs
mehlah authored
277 * @param string $path Path to the image file. If the filename is prefixed with
5450f20 Michael Nitschinger QA: various max line length fixes.
daschl authored
278 * `'/'`, the path will be relative to the base path of your application.
279 * Otherwise the path will be relative to the images directory, usually `app/webroot/img/`.
280 * If the name starts with `'http://'`, this is treated as an external url used as the `src`
281 * attribute.
53a9fd9 Alexander Morland hooks fixes for lithium/template
alkemann authored
282 * @param array $options Array of HTML attributes.
41ab56f Nate Abele Cleaning up coding standards issues.
nateabele authored
283 * @return string Returns a formatted `<img />` tag.
f8d75ca GWoo adding more tests and refactoring `\template`. Most of the changes are i...
gwoo authored
284 * @filter This method can be filtered.
e7f3c31 GWoo going lithium
gwoo authored
285 */
285b34d Michael Nitschinger QA: replacing spaces with tabs where appropriate.
daschl authored
286 public function image($path, array $options = array()) {
e7f3c31 GWoo going lithium
gwoo authored
287 $defaults = array('alt' => '');
288 $options += $defaults;
c8b7b6d Nate Abele Adding plugin lookup support for assets in `http\Media::asset()`, refact...
nateabele authored
289 $path = is_array($path) ? $this->_context->url($path) : $path;
290 $params = compact('path', 'options');
291 $method = __METHOD__;
e7f3c31 GWoo going lithium
gwoo authored
292
c8b7b6d Nate Abele Adding plugin lookup support for assets in `http\Media::asset()`, refact...
nateabele authored
293 return $this->_filter($method, $params, function($self, $params, $chain) use ($method) {
294 return $self->invokeMethod('_render', array($method, 'image', $params));
295 });
e7f3c31 GWoo going lithium
gwoo authored
296 }
297
298 /**
299 * Creates a link to an external resource.
300 *
301 * @param string $type The title of the external resource
302 * @param mixed $url The address of the external resource or string for content attribute
8e160ac Alexander Morland formatting and documentation cleanup
alkemann authored
303 * @param array $options Other attributes for the generated tag. If the type attribute
5450f20 Michael Nitschinger QA: various max line length fixes.
daschl authored
304 * 4 is 'html', 'rss', 'atom', or 'icon', the mime-type is returned.
e7f3c31 GWoo going lithium
gwoo authored
305 * @return string
306 */
f80098d Nate Abele Adding type hinting to constructor `$config` arrays and all applicable `...
nateabele authored
307 protected function _metaLink($type, $url = null, array $options = array()) {
e7f3c31 GWoo going lithium
gwoo authored
308 $options += isset($this->_metaLinks[$type]) ? $this->_metaLinks[$type] : array();
309
310 if ($type == 'icon') {
311 $url = $url ?: 'favicon.ico';
312 $standard = $this->_render(__METHOD__, 'meta-link', compact('url', 'options'), array(
313 'handlers' => array('url' => 'path')
314 ));
315 $options['rel'] = 'shortcut icon';
316 $ieFix = $this->_render(__METHOD__, 'meta-link', compact('url', 'options'), array(
317 'handlers' => array('url' => 'path')
318 ));
319 return "{$standard}\n\t{$ieFix}";
320 }
321 return $this->_render(__METHOD__, 'meta-link', compact('url', 'options'), array(
322 'handlers' => array()
323 ));
324 }
325 }
326
327 ?>
Something went wrong with that request. Please try again.