summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorDerek Allard <derek.allard@ellislab.com>2008-01-30 17:13:57 +0100
committerDerek Allard <derek.allard@ellislab.com>2008-01-30 17:13:57 +0100
commit432e97322ad518468235649ad25974eef3f3d39f (patch)
treef0f94220884c10ee75966e5eb86284a38d879f72 /system
parent63df95edbaaa6f94ee8e37128a4577909a9574a1 (diff)
Added link() to the HTML helper.
Diffstat (limited to 'system')
-rw-r--r--system/helpers/html_helper.php130
1 files changed, 126 insertions, 4 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("&nbsp;", $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("&nbsp;", $num);
+ }
+}
+
?> \ No newline at end of file