summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/helpers/html_helper.php130
-rw-r--r--user_guide/changelog.html1
-rw-r--r--user_guide/helpers/html_helper.html54
3 files changed, 163 insertions, 22 deletions
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index 56e25316c..d887be6ce 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -182,17 +182,122 @@ if (! function_exists('br'))
// ------------------------------------------------------------------------
/**
- * Generates non-breaking space entities based on number supplied
+ * Image
+ *
+ * Generates an image tag
*
* @access public
* @param integer
* @return string
*/
-if (! function_exists('nbs'))
+if (! function_exists('image'))
{
- function nbs($num = 1)
+ function image($src = '', $alt = '', $index_page = FALSE)
{
- return str_repeat(" ", $num);
+ $CI =& get_instance();
+
+ $css = '';
+
+ foreach ($stylesheets as $stylesheet)
+ {
+ if (strpos($stylesheet, '://') !== FALSE)
+ {
+ $href = ' href="'.$stylesheet.'"';
+ }
+ elseif ($index_page === TRUE)
+ {
+ $href = ' href="'.$CI->config->site_url($stylesheet).'"';
+ }
+ else
+ {
+ $href = ' href="'.$CI->config->slash_item('base_url').$stylesheet.'"';
+ }
+
+ $media = ($media !== '') ? ' media="'.$media.'"' : '';
+
+ $css .= 'link type="text/css" rel="stylesheet"'.$href.$media.' />'."\n";
+ }
+
+ return $css;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * Link
+ *
+ * Generates link to a CSS file
+ *
+ * @access public
+ * @param mixed stylesheet name(s)
+ * @param string media type
+ * @param boolean should index_page be added to the css path
+ * @return string
+ */
+if (! function_exists('link'))
+{
+ function link($href = '', $rel = 'stylesheet', $type = 'text/css', $title = '', $media = '', $index_page = FALSE)
+ {
+ $CI =& get_instance();
+
+ $link = 'link ';
+
+ if (is_array($href))
+ {
+ foreach ($href as $k=>$v)
+ {
+ if ($k == 'href' AND strpos($k, '://') === FALSE)
+ {
+ if ($index_page === TRUE)
+ {
+ $link .= ' href="'.$CI->config->site_url($v).'" ';
+ }
+ else
+ {
+ $link .= ' href="'.$CI->config->slash_item('base_url').$v.'" ';
+ }
+ }
+ else
+ {
+ $link .= "$k=\"$v\" ";
+ }
+ }
+
+ $link .= "/>\n";
+ }
+ else
+ {
+ if ( strpos($href, '://') !== FALSE)
+ {
+ $link .= ' href="'.$href.'" ';
+ }
+ elseif ($index_page === TRUE)
+ {
+ $link .= ' href="'.$CI->config->site_url($href).'" ';
+ }
+ else
+ {
+ $link .= ' href="'.$CI->config->slash_item('base_url').$href.'" ';
+ }
+
+ $link .= 'rel="'.$rel.'" type="'.$type.'" ';
+
+ if ($media != '')
+ {
+ $link .= 'media="'.$media.'" ';
+ }
+
+ if ($title != '')
+ {
+ $link .= 'title="'.$title.'" ';
+ }
+
+ $link .= '/>'."\n";
+ }
+
+
+ return $link;
}
}
@@ -219,4 +324,21 @@ if (! function_exists('meta'))
}
}
+// ------------------------------------------------------------------------
+
+/**
+ * Generates non-breaking space entities based on number supplied
+ *
+ * @access public
+ * @param integer
+ * @return string
+ */
+if (! function_exists('nbs'))
+{
+ function nbs($num = 1)
+ {
+ return str_repeat(" ", $num);
+ }
+}
+
?> \ No newline at end of file
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index c37b0951c..2ccfbd88c 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -131,6 +131,7 @@ Change Log
<li>Helpers &amp; Plugins
<ul>
+ <li>Added link() to the <a href="./helpers/html_helper.html">HTML helper.</a></li>
<li>Added ability to <a href="./general/helpers.html">"extend" Helpers</a>.</li>
<li>Added an <a href="./helpers/email_helper.html">email helper</a> into core helpers.</li>
<li>Added <kbd>strip_quotes()</kbd> function to <a href="./helpers/string_helper.html">string helper</a>.</li>
diff --git a/user_guide/helpers/html_helper.html b/user_guide/helpers/html_helper.html
index e07f27778..7abe01af9 100644
--- a/user_guide/helpers/html_helper.html
+++ b/user_guide/helpers/html_helper.html
@@ -68,16 +68,49 @@ Directory Helper
<p>The following functions are available:</p>
+<h2>br()</h2>
+<p>Generates line break tags (&lt;br />) based on the number you submit. Example:</p>
+<code>echo br(3);</code>
+<p>The above would produce: &lt;br />&lt;br />&lt;br /></p>
<h2>heading()</h2>
-
<p>Lets you create HTML &lt;h1> tags. The first parameter will contain the data, the
second the size of the heading. Example:</p>
-
<code>echo heading('Welcome!', 3);</code>
-
<p>The above would produce: &lt;h3>Welcome!&lt;/h3></p>
+<h2>link()</h2>
+<p>Lets you create HTML &lt;link /> tags. The parameters are href, with optional rel, type, title, media and index_page. index_page is a TRUE/FALSE value that specifics if the href should have the page specified by $config['index_page'] added to the address it creates.</p>
+<p>While stylesheets are more conveniently handled through the stylesheet() function, they can also be called here.</p>
+<code>
+link('css/mystyles.css');<br />
+ // gives &lt;link href=&quot;http://site.com/css/mystyles.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;</code>
+<p>Further examples:</p>
+
+<code>
+link('favicon.ico', 'shortcut icon', 'image/ico');<br />
+ // &lt;link href=&quot;http://site.com/favicon.ico&quot; rel=&quot;shortcut icon&quot; type=&quot;image/ico&quot; /&gt; </p>
+<br />
+<br />
+link('feed', 'alternate', 'application/rss+xml', 'My RSS Feed');<br />
+ // &lt;link href=&quot;http://site.com/feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot; title=&quot;My RSS Feed&quot; /&gt; <br />
+<br />
+
+<br />
+$link = array(<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'href' =&gt; 'css/printer.css',<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rel' =&gt; 'stylesheet',<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt; 'text/css',<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'media' =&gt; 'print'<br />
+ );<br />
+ <br />
+ link($link);<br />
+ // &lt;link href=&quot;http://site.com/css/printer.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;print&quot; /&gt;</code>
+
+<h2>nbs()</h2>
+<p>Generates non-breaking spaces (&amp;nbsp;) based on the number you submit. Example:</p>
+<code>echo nbs(3);</code>
+<p>The above would produce: &amp;nbsp;&amp;nbsp;&amp;nbsp;</p>
<h2>ol()&nbsp; and&nbsp; ul()</h2>
@@ -196,21 +229,6 @@ echo ul($list);</code>
&lt;/ul&gt;
</code>
-
-<h2>nbs()</h2>
-<p>Generates non-breaking spaces (&amp;nbsp;) based on the number you submit. Example:</p>
-<code>echo nbs(3);</code>
-<p>The above would produce: &amp;nbsp;&amp;nbsp;&amp;nbsp;</p>
-
-
-<h2>br()</h2>
-<p>Generates line break tags (&lt;br />) based on the number you submit. Example:</p>
-<code>echo br(3);</code>
-<p>The above would produce: &lt;br />&lt;br />&lt;br /></p>
-
-
-
-
</div>
<!-- END CONTENT -->