Initial commit
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Array Helper : CodeIgniter User Guide</title>
|
||||
|
||||
<style type='text/css' media='all'>@import url('../userguide.css');</style>
|
||||
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
|
||||
|
||||
<script type="text/javascript" src="../nav/nav.js"></script>
|
||||
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
|
||||
<script type="text/javascript" src="../nav/moo.fx.js"></script>
|
||||
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
|
||||
|
||||
<meta http-equiv='expires' content='-1' />
|
||||
<meta http-equiv= 'pragma' content='no-cache' />
|
||||
<meta name='robots' content='all' />
|
||||
<meta name='author' content='ExpressionEngine Dev Team' />
|
||||
<meta name='description' content='CodeIgniter User Guide' />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- START NAVIGATION -->
|
||||
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
|
||||
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
|
||||
<div id="masthead">
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td><h1>CodeIgniter User Guide Version 1.7.3</h1></td>
|
||||
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END NAVIGATION -->
|
||||
|
||||
|
||||
<!-- START BREADCRUMB -->
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td id="breadcrumb">
|
||||
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
|
||||
<a href="../index.html">User Guide Home</a> ›
|
||||
Array Helper
|
||||
</td>
|
||||
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- END BREADCRUMB -->
|
||||
|
||||
<br clear="all" />
|
||||
|
||||
|
||||
<!-- START CONTENT -->
|
||||
<div id="content">
|
||||
|
||||
|
||||
<h1>Array Helper</h1>
|
||||
|
||||
<p>The Array Helper file contains functions that assist in working with arrays.</p>
|
||||
|
||||
|
||||
<h2>Loading this Helper</h2>
|
||||
|
||||
<p>This helper is loaded using the following code:</p>
|
||||
<code>$this->load->helper('array');</code>
|
||||
|
||||
<p>The following functions are available:</p>
|
||||
|
||||
<h2>element()</h2>
|
||||
|
||||
<p>Lets you fetch an item from an array. The function tests whether the array index is set and whether it has a value. If
|
||||
a value exists it is returned. If a value does not exist it returns FALSE, or whatever you've specified as the default value via the third parameter. Example:</p>
|
||||
|
||||
<code>
|
||||
$array = array('color' => 'red', 'shape' => 'round', 'size' => '');<br />
|
||||
<br />
|
||||
// returns "red"<br />
|
||||
echo element('color', $array);<br />
|
||||
<br />
|
||||
// returns NULL<br />
|
||||
echo element('size', $array, NULL);
|
||||
</code>
|
||||
|
||||
|
||||
<h2>random_element()</h2>
|
||||
|
||||
<p>Takes an array as input and returns a random element from it. Usage example:</p>
|
||||
|
||||
<code>$quotes = array(<br />
|
||||
"I find that the harder I work, the more luck I seem to have. - Thomas Jefferson",<br />
|
||||
"Don't stay in bed, unless you can make money in bed. - George Burns",<br />
|
||||
"We didn't lose the game; we just ran out of time. - Vince Lombardi",<br />
|
||||
"If everything seems under control, you're not going fast enough. - Mario Andretti",<br />
|
||||
"Reality is merely an illusion, albeit a very persistent one. - Albert Einstein",<br />
|
||||
"Chance favors the prepared mind - Louis Pasteur"<br />
|
||||
);<br />
|
||||
<br />
|
||||
echo random_element($quotes);</code>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
|
||||
|
||||
<div id="footer">
|
||||
<p>
|
||||
Previous Topic: <a href="../libraries/zip.html">Zip Encoding Class</a> ·
|
||||
<a href="#top">Top of Page</a> ·
|
||||
<a href="../index.html">User Guide Home</a> ·
|
||||
Next Topic: <a href="compatibility_helper.html">Compatibility Helper</a></p>
|
||||
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006-2010 · <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,118 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Compatibility Helper : CodeIgniter User Guide</title>
|
||||
|
||||
<style type='text/css' media='all'>@import url('../userguide.css');</style>
|
||||
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
|
||||
|
||||
<script type="text/javascript" src="../nav/nav.js"></script>
|
||||
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
|
||||
<script type="text/javascript" src="../nav/moo.fx.js"></script>
|
||||
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
|
||||
|
||||
<meta http-equiv='expires' content='-1' />
|
||||
<meta http-equiv= 'pragma' content='no-cache' />
|
||||
<meta name='robots' content='all' />
|
||||
<meta name='author' content='ExpressionEngine Dev Team' />
|
||||
<meta name='description' content='CodeIgniter User Guide' />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- START NAVIGATION -->
|
||||
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
|
||||
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
|
||||
<div id="masthead">
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td><h1>CodeIgniter User Guide Version 1.7.3</h1></td>
|
||||
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END NAVIGATION -->
|
||||
|
||||
|
||||
<!-- START BREADCRUMB -->
|
||||
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td id="breadcrumb">
|
||||
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
|
||||
<a href="../index.html">User Guide Home</a> ›
|
||||
Compatibility Helper
|
||||
</td>
|
||||
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- END BREADCRUMB -->
|
||||
|
||||
<br clear="all" />
|
||||
|
||||
|
||||
<!-- START CONTENT -->
|
||||
<div id="content">
|
||||
|
||||
|
||||
<h1>Compatibility Helper</h1>
|
||||
|
||||
<p>The Compatibility Helper file contains PHP 4 implementations of some PHP 5 only native PHP functions and constants. This can be useful
|
||||
if you'd like to take advantage of some of these native function but your application may end up running on a PHP 4 server.
|
||||
In these cases, it may be advantageous to <a href="../general/autoloader.html">Auto-load</a> the Compatibility Helper so you
|
||||
do not have to load it in each controller.</p>
|
||||
|
||||
<p class="important"><strong>Note:</strong> There are a few compatibility functions that are in CodeIgniter's native Compat.php file.
|
||||
You may use those functions without loading this helper. The functions are split between that file and this Helper so that only
|
||||
functions required by the framework are included by default. This way, whether or not you load the additional functions in this Helper
|
||||
remains your choice.</p>
|
||||
|
||||
<h2>Loading this Helper</h2>
|
||||
|
||||
<p>This helper is loaded using the following code:</p>
|
||||
<code>$this->load->helper('compatibility');</code>
|
||||
|
||||
<h2>Available Constants</h2>
|
||||
<p>The following constants are available:</p>
|
||||
|
||||
<h3>PHP_EOL</h3>
|
||||
<p>The newline character for the server's current OS, e.g. on Windows systems "\r\n", on *nix "\n".
|
||||
|
||||
<h2>Available Functions</h2>
|
||||
<p>The following functions are available (see linked PHP documentation for documentation):</p>
|
||||
|
||||
<h3><a href="http://us.php.net/manual/en/function.file-put-contents.php">file_put_contents()</a> - The fourth parameter, <var>$context</var>, is not supported.</h3>
|
||||
|
||||
<h3><a href="http://us.php.net/manual/en/function.fputcsv.php">fputcsv()</a></h3>
|
||||
|
||||
<h3><a href="http://us.php.net/manual/en/function.http-build-query.php">http_build_query()</a></h3>
|
||||
|
||||
<h3><a href="http://us.php.net/manual/en/function.str-ireplace.php">str_ireplace()</a> - The fourth parameter, <var>$count</var>, is not supported, as PHP 4 would make it become required.</h3>
|
||||
|
||||
<h3><a href="http://us.php.net/manual/en/function.stripos.php">stripos()</a></h3>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
|
||||
|
||||
<div id="footer">
|
||||
<p>
|
||||
Previous Topic: <a href="array_helper.html">Array Helper</a>
|
||||
·
|
||||
<a href="#top">Top of Page</a> ·
|
||||
<a href="../index.html">User Guide Home</a> ·
|
||||
Next Topic: <a href="cookie_helper.html">Cookie Helper</a>
|
||||
</p>
|
||||
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006-2010 · <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,147 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Cookie Helper : CodeIgniter User Guide</title>
|
||||
|
||||
<style type='text/css' media='all'>@import url('../userguide.css');</style>
|
||||
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
|
||||
|
||||
<script type="text/javascript" src="../nav/nav.js"></script>
|
||||
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
|
||||
<script type="text/javascript" src="../nav/moo.fx.js"></script>
|
||||
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
|
||||
|
||||
<meta http-equiv='expires' content='-1' />
|
||||
<meta http-equiv= 'pragma' content='no-cache' />
|
||||
<meta name='robots' content='all' />
|
||||
<meta name='author' content='ExpressionEngine Dev Team' />
|
||||
<meta name='description' content='CodeIgniter User Guide' />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- START NAVIGATION -->
|
||||
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
|
||||
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
|
||||
<div id="masthead">
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td><h1>CodeIgniter User Guide Version 1.7.3</h1></td>
|
||||
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END NAVIGATION -->
|
||||
|
||||
|
||||
<!-- START BREADCRUMB -->
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td id="breadcrumb">
|
||||
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
|
||||
<a href="../index.html">User Guide Home</a> ›
|
||||
Cookie Helper
|
||||
</td>
|
||||
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- END BREADCRUMB -->
|
||||
|
||||
<br clear="all" />
|
||||
|
||||
|
||||
<!-- START CONTENT -->
|
||||
<div id="content">
|
||||
|
||||
|
||||
<h1>Cookie Helper</h1>
|
||||
|
||||
<p>The Cookie Helper file contains functions that assist in working with cookies.</p>
|
||||
|
||||
|
||||
<h2>Loading this Helper</h2>
|
||||
|
||||
<p>This helper is loaded using the following code:</p>
|
||||
<code>$this->load->helper('cookie');</code>
|
||||
|
||||
<p>The following functions are available:</p>
|
||||
|
||||
<h2>set_cookie()</h2>
|
||||
|
||||
<p>Sets a cookie containing the values you specify. There are two ways to pass information to this function so that a cookie can be set:
|
||||
Array Method, and Discrete Parameters:</p>
|
||||
|
||||
<h4>Array Method</h4>
|
||||
|
||||
<p>Using this method, an associative array is passed to the first parameter:</p>
|
||||
|
||||
<code>$cookie = array(<br />
|
||||
'name' => 'The Cookie Name',<br />
|
||||
'value' => 'The Value',<br />
|
||||
'expire' => '86500',<br />
|
||||
'domain' => '.some-domain.com',<br />
|
||||
'path' => '/',<br />
|
||||
'prefix' => 'myprefix_',<br />
|
||||
);<br />
|
||||
<br />
|
||||
set_cookie($cookie);
|
||||
</code>
|
||||
|
||||
<p><strong>Notes:</strong></p>
|
||||
|
||||
<p>Only the name and value are required. To delete a cookie set it with the expiration blank.</p>
|
||||
|
||||
<p>The expiration is set in <strong>seconds</strong>, which will be added to the current time. Do not include the time, but rather only the
|
||||
number of seconds from <em>now</em> that you wish the cookie to be valid. If the expiration is set to
|
||||
zero the cookie will only last as long as the browser is open.</p>
|
||||
<p>For site-wide cookies regardless of how your site is requested, add your URL to the <strong>domain</strong> starting with a period, like this: .your-domain.com</p>
|
||||
<p>The path is usually not needed since the function sets a root path.</p>
|
||||
<p>The prefix is only needed if you need to avoid name collisions with other identically named cookies for your server.</p>
|
||||
|
||||
<h4>Discrete Parameters</h4>
|
||||
|
||||
<p>If you prefer, you can set the cookie by passing data using individual parameters:</p>
|
||||
|
||||
<code>set_cookie($name, $value, $expire, $domain, $path, $prefix);</code>
|
||||
|
||||
<h2>get_cookie()</h2>
|
||||
|
||||
<p>Lets you fetch a cookie. The first parameter will contain the name of the cookie you are looking for (including any prefixes):</p>
|
||||
|
||||
<code>get_cookie('some_cookie');</code>
|
||||
|
||||
<p>The function returns FALSE (boolean) if the item you are attempting to retrieve does not exist.</p>
|
||||
|
||||
<p>The second optional parameter lets you run the data through the XSS filter. It's enabled by setting the second parameter to boolean TRUE;</p>
|
||||
|
||||
<p><code>get_cookie('some_cookie', TRUE);</code></p>
|
||||
<h2>delete_cookie()</h2>
|
||||
|
||||
<p>Lets you delete a cookie. Unless you've set a custom path or other values, only the name of the cookie is needed:</p>
|
||||
|
||||
<code>delete_cookie("name");</code>
|
||||
|
||||
<p>This function is otherwise identical to <dfn>set_cookie()</dfn>, except that it does not have the value and expiration parameters. You can submit an array
|
||||
of values in the first parameter or you can set discrete parameters.</p>
|
||||
|
||||
<code>delete_cookie($name, $domain, $path, $prefix)</code>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
|
||||
|
||||
<div id="footer">
|
||||
<p>
|
||||
Previous Topic: <a href="compatibility_helper.html">Compatibility Helper</a>
|
||||
·
|
||||
<a href="#top">Top of Page</a> ·
|
||||
<a href="../index.html">User Guide Home</a> ·
|
||||
Next Topic: <a href="date_helper.html">Date Helper</a></p>
|
||||
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006-2010 · <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,408 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Date Helper : CodeIgniter User Guide</title>
|
||||
|
||||
<style type='text/css' media='all'>@import url('../userguide.css');</style>
|
||||
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
|
||||
|
||||
<script type="text/javascript" src="../nav/nav.js"></script>
|
||||
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
|
||||
<script type="text/javascript" src="../nav/moo.fx.js"></script>
|
||||
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
|
||||
|
||||
<meta http-equiv='expires' content='-1' />
|
||||
<meta http-equiv= 'pragma' content='no-cache' />
|
||||
<meta name='robots' content='all' />
|
||||
<meta name='author' content='ExpressionEngine Dev Team' />
|
||||
<meta name='description' content='CodeIgniter User Guide' />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- START NAVIGATION -->
|
||||
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
|
||||
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
|
||||
<div id="masthead">
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td><h1>CodeIgniter User Guide Version 1.7.3</h1></td>
|
||||
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END NAVIGATION -->
|
||||
|
||||
|
||||
<!-- START BREADCRUMB -->
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td id="breadcrumb">
|
||||
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
|
||||
<a href="../index.html">User Guide Home</a> ›
|
||||
Date Helper
|
||||
</td>
|
||||
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- END BREADCRUMB -->
|
||||
|
||||
<br clear="all" />
|
||||
|
||||
|
||||
<!-- START CONTENT -->
|
||||
<div id="content">
|
||||
|
||||
|
||||
<h1>Date Helper</h1>
|
||||
|
||||
<p>The Date Helper file contains functions that help you work with dates.</p>
|
||||
|
||||
|
||||
<h2>Loading this Helper</h2>
|
||||
|
||||
<p>This helper is loaded using the following code:</p>
|
||||
<code>$this->load->helper('date');</code>
|
||||
|
||||
|
||||
<p>The following functions are available:</p>
|
||||
|
||||
<h2>now()</h2>
|
||||
|
||||
<p>Returns the current time as a Unix timestamp, referenced either to your server's local time or GMT, based on the "time reference"
|
||||
setting in your config file. If you do not intend to set your master time reference to GMT (which you'll typically do if you
|
||||
run a site that lets each user set their own timezone settings) there is no benefit to using this function over PHP's time() function.
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
<h2>mdate()</h2>
|
||||
|
||||
<p>This function is identical to PHPs <a href="http://www.php.net/date">date()</a> function, except that it lets you
|
||||
use MySQL style date codes, where each code letter is preceded with a percent sign: %Y %m %d etc.</p>
|
||||
|
||||
<p>The benefit of doing dates this way is that you don't have to worry about escaping any characters that
|
||||
are not date codes, as you would normally have to do with the date() function. Example:</p>
|
||||
|
||||
<code>$datestring = "Year: %Y Month: %m Day: %d - %h:%i %a";<br />
|
||||
$time = time();<br />
|
||||
<br />
|
||||
echo mdate($datestring, $time);</code>
|
||||
|
||||
<p>If a timestamp is not included in the second parameter the current time will be used.</p>
|
||||
|
||||
|
||||
<h2>standard_date()</h2>
|
||||
|
||||
<p>Lets you generate a date string in one of several standardized formats. Example:</p>
|
||||
|
||||
<code>
|
||||
$format = 'DATE_RFC822';<br />
|
||||
$time = time();<br />
|
||||
<br />
|
||||
echo standard_date($format, $time);
|
||||
</code>
|
||||
|
||||
<p>The first parameter must contain the format, the second parameter must contain the date as a Unix timestamp.</p>
|
||||
|
||||
<p>Supported formats:</p>
|
||||
|
||||
<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
|
||||
<tr>
|
||||
<th>Constant</th>
|
||||
<th>Description</th>
|
||||
<th>Example</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>DATE_ATOM</td>
|
||||
<td>Atom</td>
|
||||
<td>2005-08-15T16:13:03+0000</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>DATE_COOKIE</td>
|
||||
<td>HTTP Cookies</td>
|
||||
<td>Sun, 14 Aug 2005 16:13:03 UTC</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>DATE_ISO8601</td>
|
||||
<td>ISO-8601</td>
|
||||
<td>2005-08-14T16:13:03+0000</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>DATE_RFC822</td>
|
||||
<td>RFC 822</td>
|
||||
<td>Sun, 14 Aug 2005 16:13:03 UTC</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>DATE_RFC850</td>
|
||||
<td>RFC 850</td>
|
||||
<td>Sunday, 14-Aug-05 16:13:03 UTC</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>DATE_RFC1036</td>
|
||||
<td>RFC 1036</td>
|
||||
<td>Sunday, 14-Aug-05 16:13:03 UTC</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>DATE_RFC1123</td>
|
||||
<td>RFC 1123</td>
|
||||
<td>Sun, 14 Aug 2005 16:13:03 UTC</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>DATE_RFC2822</td>
|
||||
<td>RFC 2822</td>
|
||||
<td>Sun, 14 Aug 2005 16:13:03 +0000</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>DATE_RSS</td>
|
||||
<td>RSS</td>
|
||||
<td>Sun, 14 Aug 2005 16:13:03 UTC</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>DATE_W3C</td>
|
||||
<td>World Wide Web Consortium</td>
|
||||
<td>2005-08-14T16:13:03+0000</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2>local_to_gmt()</h2>
|
||||
|
||||
<p>Takes a Unix timestamp as input and returns it as GMT. Example:</p>
|
||||
|
||||
<code>$now = time();<br />
|
||||
<br />
|
||||
$gmt = local_to_gmt($now);</code>
|
||||
|
||||
|
||||
<h2>gmt_to_local()</h2>
|
||||
|
||||
<p>Takes a Unix timestamp (referenced to GMT) as input, and converts it to a localized timestamp based on the
|
||||
timezone and Daylight Saving time submitted. Example:</p>
|
||||
|
||||
<code>
|
||||
$timestamp = '1140153693';<br />
|
||||
$timezone = 'UM8';<br />
|
||||
$daylight_saving = TRUE;<br />
|
||||
<br />
|
||||
echo gmt_to_local($timestamp, $timezone, $daylight_saving);</code>
|
||||
|
||||
<p><strong>Note:</strong> For a list of timezones see the reference at the bottom of this page.</p>
|
||||
|
||||
<h2>mysql_to_unix()</h2>
|
||||
|
||||
<p>Takes a MySQL Timestamp as input and returns it as Unix. Example:</p>
|
||||
|
||||
<code>$mysql = '20061124092345';<br />
|
||||
<br />
|
||||
$unix = mysql_to_unix($mysql);</code>
|
||||
|
||||
|
||||
<h2>unix_to_human()</h2>
|
||||
|
||||
<p>Takes a Unix timestamp as input and returns it in a human readable format with this prototype:</p>
|
||||
|
||||
<code>YYYY-MM-DD HH:MM:SS AM/PM</code>
|
||||
|
||||
<p>This can be useful if you need to display a date in a form field for submission.</p>
|
||||
|
||||
<p>The time can be formatted with or without seconds, and it can be set to European or US format. If only
|
||||
the timestamp is submitted it will return the time without seconds formatted for the U.S. Examples:</p>
|
||||
|
||||
<code>$now = time();<br />
|
||||
<br />
|
||||
echo unix_to_human($now); // U.S. time, no seconds<br />
|
||||
<br />
|
||||
echo unix_to_human($now, TRUE, 'us'); // U.S. time with seconds<br />
|
||||
<br />
|
||||
echo unix_to_human($now, TRUE, 'eu'); // Euro time with seconds</code>
|
||||
|
||||
|
||||
<h2>human_to_unix()</h2>
|
||||
|
||||
<p>The opposite of the above function. Takes a "human" time as input and returns it as Unix. This function is
|
||||
useful if you accept "human" formatted dates submitted via a form. Returns FALSE (boolean) if
|
||||
the date string passed to it is not formatted as indicated above. Example:</p>
|
||||
|
||||
<code>$now = time();<br />
|
||||
<br />
|
||||
$human = unix_to_human($now);<br />
|
||||
<br />
|
||||
$unix = human_to_unix($human);</code>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h2>timespan()</h2>
|
||||
|
||||
<p>Formats a unix timestamp so that is appears similar to this:</p>
|
||||
|
||||
<code>1 Year, 10 Months, 2 Weeks, 5 Days, 10 Hours, 16 Minutes</code>
|
||||
|
||||
<p>The first parameter must contain a Unix timestamp. The second parameter must contain a
|
||||
timestamp that is greater that the first timestamp. If the second parameter empty, the current time will be used. The most common purpose
|
||||
for this function is to show how much time has elapsed from some point in time in the past to now. Example:</p>
|
||||
|
||||
<code>$post_date = '1079621429';<br />
|
||||
$now = time();<br />
|
||||
<br />
|
||||
echo timespan($post_date, $now);</code>
|
||||
|
||||
<p class="important"><strong>Note:</strong> The text generated by this function is found in the following language file: language/<your_lang>/date_lang.php</p>
|
||||
|
||||
|
||||
<h2>days_in_month()</h2>
|
||||
|
||||
<p>Returns the number of days in a given month/year. Takes leap years into account. Example:</p>
|
||||
<code>echo days_in_month(06, 2005);</code>
|
||||
|
||||
<p>If the second parameter is empty, the current year will be used.</p>
|
||||
<h2>timezones()</h2>
|
||||
<p> Takes a timezone reference (for a list of valid timezones, see the "Timezone Reference" below) and returns the number of hours offset from UTC.</p>
|
||||
<p><code>echo timezones('UM5');</code></p>
|
||||
<p>This function is useful when used with timezone_menu(). </p>
|
||||
<h2>timezone_menu()</h2>
|
||||
<p>Generates a pull-down menu of timezones, like this one:</p>
|
||||
|
||||
<form action="#">
|
||||
<select name="timezones">
|
||||
<option value='UM12'>(UTC - 12:00) Enitwetok, Kwajalien</option>
|
||||
<option value='UM11'>(UTC - 11:00) Nome, Midway Island, Samoa</option>
|
||||
<option value='UM10'>(UTC - 10:00) Hawaii</option>
|
||||
<option value='UM9'>(UTC - 9:00) Alaska</option>
|
||||
<option value='UM8'>(UTC - 8:00) Pacific Time</option>
|
||||
<option value='UM7'>(UTC - 7:00) Mountain Time</option>
|
||||
<option value='UM6'>(UTC - 6:00) Central Time, Mexico City</option>
|
||||
<option value='UM5'>(UTC - 5:00) Eastern Time, Bogota, Lima, Quito</option>
|
||||
<option value='UM4'>(UTC - 4:00) Atlantic Time, Caracas, La Paz</option>
|
||||
<option value='UM25'>(UTC - 3:30) Newfoundland</option>
|
||||
<option value='UM3'>(UTC - 3:00) Brazil, Buenos Aires, Georgetown, Falkland Is.</option>
|
||||
<option value='UM2'>(UTC - 2:00) Mid-Atlantic, Ascention Is., St Helena</option>
|
||||
<option value='UM1'>(UTC - 1:00) Azores, Cape Verde Islands</option>
|
||||
<option value='UTC' selected='selected'>(UTC) Casablanca, Dublin, Edinburgh, London, Lisbon, Monrovia</option>
|
||||
<option value='UP1'>(UTC + 1:00) Berlin, Brussels, Copenhagen, Madrid, Paris, Rome</option>
|
||||
<option value='UP2'>(UTC + 2:00) Kaliningrad, South Africa, Warsaw</option>
|
||||
<option value='UP3'>(UTC + 3:00) Baghdad, Riyadh, Moscow, Nairobi</option>
|
||||
<option value='UP25'>(UTC + 3:30) Tehran</option>
|
||||
<option value='UP4'>(UTC + 4:00) Adu Dhabi, Baku, Muscat, Tbilisi</option>
|
||||
<option value='UP35'>(UTC + 4:30) Kabul</option>
|
||||
<option value='UP5'>(UTC + 5:00) Islamabad, Karachi, Tashkent</option>
|
||||
<option value='UP45'>(UTC + 5:30) Bombay, Calcutta, Madras, New Delhi</option>
|
||||
<option value='UP6'>(UTC + 6:00) Almaty, Colomba, Dhaka</option>
|
||||
<option value='UP7'>(UTC + 7:00) Bangkok, Hanoi, Jakarta</option>
|
||||
<option value='UP8'>(UTC + 8:00) Beijing, Hong Kong, Perth, Singapore, Taipei</option>
|
||||
<option value='UP9'>(UTC + 9:00) Osaka, Sapporo, Seoul, Tokyo, Yakutsk</option>
|
||||
<option value='UP85'>(UTC + 9:30) Adelaide, Darwin</option>
|
||||
<option value='UP10'>(UTC + 10:00) Melbourne, Papua New Guinea, Sydney, Vladivostok</option>
|
||||
<option value='UP11'>(UTC + 11:00) Magadan, New Caledonia, Solomon Islands</option>
|
||||
<option value='UP12'>(UTC + 12:00) Auckland, Wellington, Fiji, Marshall Island</option>
|
||||
</select>
|
||||
</form>
|
||||
|
||||
<p>This menu is useful if you run a membership site in which your users are allowed to set their local timezone value.</p>
|
||||
|
||||
<p>The first parameter lets you set the "selected" state of the menu. For example, to set Pacific time as the default you will do this:</p>
|
||||
|
||||
<code>echo timezone_menu('UM8');</code>
|
||||
|
||||
<p>Please see the timezone reference below to see the values of this menu.</p>
|
||||
|
||||
<p>The second parameter lets you set a CSS class name for the menu.</p>
|
||||
|
||||
<p class="important"><strong>Note:</strong> The text contained in the menu is found in the following language file: language/<your_lang>/date_lang.php</p>
|
||||
|
||||
|
||||
|
||||
<h2>Timezone Reference</h2>
|
||||
|
||||
<p>The following table indicates each timezone and its location.</p>
|
||||
|
||||
<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
|
||||
<tr>
|
||||
<th>Time Zone</th>
|
||||
<th>Location</th>
|
||||
</tr><tr>
|
||||
|
||||
<td class="td">UM12</td><td class="td">(UTC - 12:00) Enitwetok, Kwajalien</td>
|
||||
</tr><tr>
|
||||
<td class="td">UM11</td><td class="td">(UTC - 11:00) Nome, Midway Island, Samoa</td>
|
||||
</tr><tr>
|
||||
<td class="td">UM10</td><td class="td">(UTC - 10:00) Hawaii</td>
|
||||
</tr><tr>
|
||||
<td class="td">UM9</td><td class="td">(UTC - 9:00) Alaska</td>
|
||||
</tr><tr>
|
||||
<td class="td">UM8</td><td class="td">(UTC - 8:00) Pacific Time</td>
|
||||
</tr><tr>
|
||||
<td class="td">UM7</td><td class="td">(UTC - 7:00) Mountain Time</td>
|
||||
</tr><tr>
|
||||
<td class="td">UM6</td><td class="td">(UTC - 6:00) Central Time, Mexico City</td>
|
||||
</tr><tr>
|
||||
<td class="td">UM5</td><td class="td">(UTC - 5:00) Eastern Time, Bogota, Lima, Quito</td>
|
||||
</tr><tr>
|
||||
<td class="td">UM4</td><td class="td">(UTC - 4:00) Atlantic Time, Caracas, La Paz</td>
|
||||
</tr><tr>
|
||||
<td class="td">UM25</td><td class="td">(UTC - 3:30) Newfoundland</td>
|
||||
</tr><tr>
|
||||
<td class="td">UM3</td><td class="td">(UTC - 3:00) Brazil, Buenos Aires, Georgetown, Falkland Is.</td>
|
||||
</tr><tr>
|
||||
<td class="td">UM2</td><td class="td">(UTC - 2:00) Mid-Atlantic, Ascention Is., St Helena</td>
|
||||
</tr><tr>
|
||||
<td class="td">UM1</td><td class="td">(UTC - 1:00) Azores, Cape Verde Islands</td>
|
||||
</tr><tr>
|
||||
<td class="td">UTC</td><td class="td">(UTC) Casablanca, Dublin, Edinburgh, London, Lisbon, Monrovia</td>
|
||||
</tr><tr>
|
||||
<td class="td">UP1</td><td class="td">(UTC + 1:00) Berlin, Brussels, Copenhagen, Madrid, Paris, Rome</td>
|
||||
</tr><tr>
|
||||
<td class="td">UP2</td><td class="td">(UTC + 2:00) Kaliningrad, South Africa, Warsaw</td>
|
||||
</tr><tr>
|
||||
<td class="td">UP3</td><td class="td">(UTC + 3:00) Baghdad, Riyadh, Moscow, Nairobi</td>
|
||||
</tr><tr>
|
||||
<td class="td">UP25</td><td class="td">(UTC + 3:30) Tehran</td>
|
||||
</tr><tr>
|
||||
<td class="td">UP4</td><td class="td">(UTC + 4:00) Adu Dhabi, Baku, Muscat, Tbilisi</td>
|
||||
</tr><tr>
|
||||
<td class="td">UP35</td><td class="td">(UTC + 4:30) Kabul</td>
|
||||
</tr><tr>
|
||||
<td class="td">UP5</td><td class="td">(UTC + 5:00) Islamabad, Karachi, Tashkent</td>
|
||||
</tr><tr>
|
||||
<td class="td">UP45</td><td class="td">(UTC + 5:30) Bombay, Calcutta, Madras, New Delhi</td>
|
||||
</tr><tr>
|
||||
<td class="td">UP6</td><td class="td">(UTC + 6:00) Almaty, Colomba, Dhaka</td>
|
||||
</tr><tr>
|
||||
<td class="td">UP7</td><td class="td">(UTC + 7:00) Bangkok, Hanoi, Jakarta</td>
|
||||
</tr><tr>
|
||||
<td class="td">UP8</td><td class="td">(UTC + 8:00) Beijing, Hong Kong, Perth, Singapore, Taipei</td>
|
||||
</tr><tr>
|
||||
<td class="td">UP9</td><td class="td">(UTC + 9:00) Osaka, Sapporo, Seoul, Tokyo, Yakutsk</td>
|
||||
</tr><tr>
|
||||
<td class="td">UP85</td><td class="td">(UTC + 9:30) Adelaide, Darwin</td>
|
||||
</tr><tr>
|
||||
<td class="td">UP10</td><td class="td">(UTC + 10:00) Melbourne, Papua New Guinea, Sydney, Vladivostok</td>
|
||||
</tr><tr>
|
||||
<td class="td">UP11</td><td class="td">(UTC + 11:00) Magadan, New Caledonia, Solomon Islands</td>
|
||||
</tr><tr>
|
||||
<td class="td">UP12</td><td class="td">(UTC + 12:00) Auckland, Wellington, Fiji, Marshall Island</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
|
||||
|
||||
<div id="footer">
|
||||
<p>
|
||||
Previous Topic: <a href="cookie_helper.html">Cookie Helper</a>
|
||||
·
|
||||
<a href="#top">Top of Page</a> ·
|
||||
<a href="../index.html">User Guide Home</a> ·
|
||||
Next Topic: <a href="directory_helper.html">Directory Helper</a>
|
||||
</p>
|
||||
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006-2010 · <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,143 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Directory Helper : CodeIgniter User Guide</title>
|
||||
|
||||
<style type='text/css' media='all'>@import url('../userguide.css');</style>
|
||||
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
|
||||
|
||||
<script type="text/javascript" src="../nav/nav.js"></script>
|
||||
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
|
||||
<script type="text/javascript" src="../nav/moo.fx.js"></script>
|
||||
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
|
||||
|
||||
<meta http-equiv='expires' content='-1' />
|
||||
<meta http-equiv= 'pragma' content='no-cache' />
|
||||
<meta name='robots' content='all' />
|
||||
<meta name='author' content='ExpressionEngine Dev Team' />
|
||||
<meta name='description' content='CodeIgniter User Guide' />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- START NAVIGATION -->
|
||||
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
|
||||
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
|
||||
<div id="masthead">
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td><h1>CodeIgniter User Guide Version 1.7.3</h1></td>
|
||||
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END NAVIGATION -->
|
||||
|
||||
|
||||
<!-- START BREADCRUMB -->
|
||||
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td id="breadcrumb">
|
||||
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
|
||||
<a href="../index.html">User Guide Home</a> ›
|
||||
Directory Helper
|
||||
</td>
|
||||
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- END BREADCRUMB -->
|
||||
|
||||
<br clear="all" />
|
||||
|
||||
|
||||
<!-- START CONTENT -->
|
||||
<div id="content">
|
||||
|
||||
|
||||
<h1>Directory Helper</h1>
|
||||
|
||||
<p>The Directory Helper file contains functions that assist in working with directories.</p>
|
||||
|
||||
|
||||
<h2>Loading this Helper</h2>
|
||||
|
||||
<p>This helper is loaded using the following code:</p>
|
||||
<code>$this->load->helper('directory');</code>
|
||||
|
||||
<p>The following functions are available:</p>
|
||||
|
||||
<h2>directory_map('<var>source directory</var>')</h2>
|
||||
|
||||
<p>This function reads the directory path specified in the first parameter
|
||||
and builds an array representation of it and all its contained files. Example:</p>
|
||||
|
||||
<code>$map = directory_map('./mydirectory/');</code>
|
||||
|
||||
<p class="important"><strong>Note:</strong> Paths are almost always relative to your main index.php file.</p>
|
||||
|
||||
<p>Sub-folders contained within the directory will be mapped as well. If you wish to map
|
||||
only the top level directory set the second parameter to <var>true</var> (boolean):</p>
|
||||
|
||||
<code>$map = directory_map('./mydirectory/', TRUE);</code>
|
||||
|
||||
<p>By default, hidden files will not be included in the returned array. To override this behavior,
|
||||
you may set a third parameter to <var>true</var> (boolean):</p>
|
||||
|
||||
<code>$map = directory_map('./mydirectory/', FALSE, TRUE);</code>
|
||||
|
||||
<p>Each folder name will be an array index, while its contained files will be numerically indexed.
|
||||
Here is an example of a typical array:</p>
|
||||
|
||||
<code>Array<br />
|
||||
(<br />
|
||||
[libraries] => Array<br />
|
||||
(<br />
|
||||
[0] => benchmark.html<br />
|
||||
[1] => config.html<br />
|
||||
[database] => Array<br />
|
||||
(<br />
|
||||
[0] => active_record.html<br />
|
||||
[1] => binds.html<br />
|
||||
[2] => configuration.html<br />
|
||||
[3] => connecting.html<br />
|
||||
[4] => examples.html<br />
|
||||
[5] => fields.html<br />
|
||||
[6] => index.html<br />
|
||||
[7] => queries.html<br />
|
||||
)<br />
|
||||
[2] => email.html<br />
|
||||
[3] => file_uploading.html<br />
|
||||
[4] => image_lib.html<br />
|
||||
[5] => input.html<br />
|
||||
[6] => language.html<br />
|
||||
[7] => loader.html<br />
|
||||
[8] => pagination.html<br />
|
||||
[9] => uri.html<br />
|
||||
)</code>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
|
||||
|
||||
<div id="footer">
|
||||
<p>
|
||||
Previous Topic: <a href="date_helper.html">Date Helper</a>
|
||||
·
|
||||
<a href="#top">Top of Page</a> ·
|
||||
<a href="../index.html">User Guide Home</a> ·
|
||||
Next Topic: <a href="download_helper.html">Download Helper</a>
|
||||
</p>
|
||||
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006-2010 · <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,112 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Download Helper : CodeIgniter User Guide</title>
|
||||
|
||||
<style type='text/css' media='all'>@import url('../userguide.css');</style>
|
||||
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
|
||||
|
||||
<script type="text/javascript" src="../nav/nav.js"></script>
|
||||
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
|
||||
<script type="text/javascript" src="../nav/moo.fx.js"></script>
|
||||
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
|
||||
|
||||
<meta http-equiv='expires' content='-1' />
|
||||
<meta http-equiv= 'pragma' content='no-cache' />
|
||||
<meta name='robots' content='all' />
|
||||
<meta name='author' content='ExpressionEngine Dev Team' />
|
||||
<meta name='description' content='CodeIgniter User Guide' />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- START NAVIGATION -->
|
||||
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
|
||||
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
|
||||
<div id="masthead">
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td><h1>CodeIgniter User Guide Version 1.7.3</h1></td>
|
||||
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END NAVIGATION -->
|
||||
|
||||
|
||||
<!-- START BREADCRUMB -->
|
||||
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td id="breadcrumb">
|
||||
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
|
||||
<a href="../index.html">User Guide Home</a> ›
|
||||
Download Helper
|
||||
</td>
|
||||
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- END BREADCRUMB -->
|
||||
|
||||
<br clear="all" />
|
||||
|
||||
|
||||
<!-- START CONTENT -->
|
||||
<div id="content">
|
||||
|
||||
|
||||
<h1>Download Helper</h1>
|
||||
|
||||
<p>The Download Helper lets you download data to your desktop.</p>
|
||||
|
||||
|
||||
<h2>Loading this Helper</h2>
|
||||
|
||||
<p>This helper is loaded using the following code:</p>
|
||||
<code>$this->load->helper('download');</code>
|
||||
|
||||
<p>The following functions are available:</p>
|
||||
|
||||
<h2>force_download('<var>filename</var>', '<var>data</var>')</h2>
|
||||
|
||||
<p>Generates server headers which force data to be downloaded to your desktop. Useful with file downloads.
|
||||
The first parameter is the <strong>name you want the downloaded file to be named</strong>, the second parameter is the file data.
|
||||
Example:</p>
|
||||
|
||||
<code>
|
||||
$data = 'Here is some text!';<br />
|
||||
$name = 'mytext.txt';<br />
|
||||
<br />
|
||||
force_download($name, $data);
|
||||
</code>
|
||||
|
||||
<p>If you want to download an existing file from your server you'll need to read the file into a string:</p>
|
||||
|
||||
<code>
|
||||
$data = file_get_contents("/path/to/photo.jpg"); // Read the file's contents<br />
|
||||
$name = 'myphoto.jpg';<br />
|
||||
<br />
|
||||
force_download($name, $data);
|
||||
</code>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
|
||||
|
||||
<div id="footer">
|
||||
<p>
|
||||
Previous Topic: <a href="directory_helper.html">Directory Helper</a>
|
||||
·
|
||||
<a href="#top">Top of Page</a> ·
|
||||
<a href="../index.html">User Guide Home</a> ·
|
||||
Next Topic: <a href="email_helper.html">Email Helper</a></p>
|
||||
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006-2010 · <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,102 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Email Helper : CodeIgniter User Guide</title>
|
||||
|
||||
<style type='text/css' media='all'>@import url('../userguide.css');</style>
|
||||
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
|
||||
|
||||
<script type="text/javascript" src="../nav/nav.js"></script>
|
||||
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
|
||||
<script type="text/javascript" src="../nav/moo.fx.js"></script>
|
||||
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
|
||||
|
||||
<meta http-equiv='expires' content='-1' />
|
||||
<meta http-equiv= 'pragma' content='no-cache' />
|
||||
<meta name='robots' content='all' />
|
||||
<meta name='author' content='ExpressionEngine Dev Team' />
|
||||
<meta name='description' content='CodeIgniter User Guide' />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- START NAVIGATION -->
|
||||
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
|
||||
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
|
||||
<div id="masthead">
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td><h1>CodeIgniter User Guide Version 1.7.3</h1></td>
|
||||
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END NAVIGATION -->
|
||||
|
||||
|
||||
<!-- START BREADCRUMB -->
|
||||
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td id="breadcrumb">
|
||||
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
|
||||
<a href="../index.html">User Guide Home</a> ›
|
||||
Email Helper
|
||||
</td>
|
||||
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- END BREADCRUMB -->
|
||||
|
||||
<br clear="all" />
|
||||
|
||||
|
||||
<!-- START CONTENT -->
|
||||
<div id="content">
|
||||
|
||||
|
||||
<h1>Email Helper</h1>
|
||||
|
||||
<p>The Email Helper provides some assistive functions for working with Email. For a more robust email solution, see CodeIgniter's <a href="../libraries/email.html">Email Class</a>.</p>
|
||||
|
||||
<h2>Loading this Helper</h2>
|
||||
|
||||
<p>This helper is loaded using the following code:</p>
|
||||
<p><code>$this->load->helper('email');</code></p>
|
||||
|
||||
<p>The following functions are available:</p>
|
||||
|
||||
<h2>valid_email('<var>email</var>')</h2>
|
||||
|
||||
<p>Checks if an email is a correctly formatted email. Note that is doesn't actually prove the email will recieve mail, simply that it is a validly formed address.</p>
|
||||
<p>It returns TRUE/FALSE</p>
|
||||
<code> $this->load->helper('email');<br />
|
||||
<br />
|
||||
if (valid_email('email@somesite.com'))<br />
|
||||
{<br />
|
||||
echo 'email is valid';<br />
|
||||
}<br />
|
||||
else<br />
|
||||
{<br />
|
||||
echo 'email is not valid';<br />
|
||||
}</code>
|
||||
<h2>send_email('<var>recipient</var>', '<var>subject</var>', '<var>message</var>')</h2>
|
||||
<p>Sends an email using PHP's native <a href="http://www.php.net/function.mail">mail()</a> function. For a more robust email solution, see CodeIgniter's <a href="../libraries/email.html">Email Class</a>.</p>
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
|
||||
|
||||
<div id="footer">
|
||||
<p>
|
||||
Previous Topic: <a href="download_helper.html">Download Helper</a>
|
||||
·
|
||||
<a href="#top">Top of Page</a> ·
|
||||
<a href="../index.html">User Guide Home</a> ·
|
||||
Next Topic: <a href="file_helper.html">File Helper</a></p>
|
||||
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006-2010 · <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,178 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>File Helper : CodeIgniter User Guide</title>
|
||||
|
||||
<style type='text/css' media='all'>@import url('../userguide.css');</style>
|
||||
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
|
||||
|
||||
<script type="text/javascript" src="../nav/nav.js"></script>
|
||||
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
|
||||
<script type="text/javascript" src="../nav/moo.fx.js"></script>
|
||||
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
|
||||
|
||||
<meta http-equiv='expires' content='-1' />
|
||||
<meta http-equiv= 'pragma' content='no-cache' />
|
||||
<meta name='robots' content='all' />
|
||||
<meta name='author' content='ExpressionEngine Dev Team' />
|
||||
<meta name='description' content='CodeIgniter User Guide' />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- START NAVIGATION -->
|
||||
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
|
||||
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
|
||||
<div id="masthead">
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td><h1>CodeIgniter User Guide Version 1.7.3</h1></td>
|
||||
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END NAVIGATION -->
|
||||
|
||||
|
||||
<!-- START BREADCRUMB -->
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td id="breadcrumb">
|
||||
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
|
||||
<a href="../index.html">User Guide Home</a> ›
|
||||
File Helper
|
||||
</td>
|
||||
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- END BREADCRUMB -->
|
||||
|
||||
<br clear="all" />
|
||||
|
||||
|
||||
<!-- START CONTENT -->
|
||||
<div id="content">
|
||||
|
||||
|
||||
<h1>File Helper</h1>
|
||||
|
||||
<p>The File Helper file contains functions that assist in working with files.</p>
|
||||
|
||||
|
||||
<h2>Loading this Helper</h2>
|
||||
|
||||
<p>This helper is loaded using the following code:</p>
|
||||
<code>$this->load->helper('file');</code>
|
||||
|
||||
<p>The following functions are available:</p>
|
||||
|
||||
<h2>read_file('<var>path</var>')</h2>
|
||||
|
||||
<p>Returns the data contained in the file specified in the path. Example:</p>
|
||||
|
||||
<code>$string = read_file('./path/to/file.php');</code>
|
||||
|
||||
<p>The path can be a relative or full server path. Returns FALSE (boolean) on failure.</p>
|
||||
|
||||
<p class="important"><strong>Note:</strong> The path is relative to your main site index.php file, NOT your controller or view files.
|
||||
CodeIgniter uses a front controller so paths are always relative to the main site index.</p>
|
||||
|
||||
<p>If your server is running an open_basedir restriction this function
|
||||
might not work if you are trying to access a file above the calling script.</p>
|
||||
|
||||
<h2>write_file('<var>path</var>', <kbd>$data</kbd>)</h2>
|
||||
|
||||
<p>Writes data to the file specified in the path. If the file does not exist the function will create it. Example:</p>
|
||||
|
||||
<code>
|
||||
$data = 'Some file data';<br />
|
||||
<br />
|
||||
if ( ! write_file('./path/to/file.php', $data))<br />
|
||||
{<br />
|
||||
echo 'Unable to write the file';<br />
|
||||
}<br />
|
||||
else<br />
|
||||
{<br />
|
||||
echo 'File written!';<br />
|
||||
}</code>
|
||||
|
||||
<p>You can optionally set the write mode via the third parameter:</p>
|
||||
|
||||
<code>write_file('./path/to/file.php', $data, <var>'r+'</var>);</code>
|
||||
|
||||
<p>The default mode is <kbd>wb</kbd>. Please see the <a href="http://php.net/fopen">PHP user guide</a> for mode options.</p>
|
||||
|
||||
<p>Note: In order for this function to write data to a file its file permissions must be set such that it is writable (666, 777, etc.).
|
||||
If the file does not already exist, the directory containing it must be writable.</p>
|
||||
|
||||
<p class="important"><strong>Note:</strong> The path is relative to your main site index.php file, NOT your controller or view files.
|
||||
CodeIgniter uses a front controller so paths are always relative to the main site index.</p>
|
||||
|
||||
<h2>delete_files('<var>path</var>')</h2>
|
||||
|
||||
<p>Deletes ALL files contained in the supplied path. Example:</p>
|
||||
<code>delete_files('./path/to/directory/');</code>
|
||||
|
||||
<p>If the second parameter is set to <kbd>true</kbd>, any directories contained within the supplied root path will be deleted as well. Example:</p>
|
||||
|
||||
<code>delete_files('./path/to/directory/', TRUE);</code>
|
||||
|
||||
<p class="important"><strong>Note:</strong> The files must be writable or owned by the system in order to be deleted.</p>
|
||||
|
||||
<h2>get_filenames('<var>path/to/directory/</var>')</h2>
|
||||
|
||||
<p>Takes a server path as input and returns an array containing the names of all files contained within it. The file path
|
||||
can optionally be added to the file names by setting the second parameter to TRUE.</p>
|
||||
|
||||
<h2>get_dir_file_info('<var>path/to/directory/</var>')</h2>
|
||||
|
||||
<p>Reads the specified directory and builds an array containing the filenames, filesize, dates, and permissions. Any sub-folders contained within the specified path are read as well.</p>
|
||||
|
||||
<h2>get_file_info('<var>path/to/file</var>', <kbd>$file_information</kbd>)</h2>
|
||||
|
||||
<p>Given a file and path, returns the name, path, size, date modified. Second parameter allows you to explicitly declare what information you want returned; options are: name, server_path, size, date, readable, writable, executable, fileperms. Returns FALSE if the file cannot be found.</p>
|
||||
|
||||
<p class="important"><strong>Note:</strong> The "writable" uses the PHP function is_writable() which is known to have issues on the IIS webserver. Consider using fileperms instead, which returns information from PHP's fileperms() function.</p>
|
||||
<h2>get_mime_by_extension('<var>file</var>')</h2>
|
||||
|
||||
<p>Translates a file extension into a mime type based on config/mimes.php. Returns FALSE if it can't determine the type, or open the mime config file.</p>
|
||||
<p>
|
||||
<code>$file = "somefile.png";<br />
|
||||
echo $file . ' is has a mime type of ' . get_mime_by_extension($file);</code>
|
||||
</p>
|
||||
<p class="critical"><strong>Note:</strong> This is not an accurate way of determining file mime types, and is here strictly as a convenience. It should not be used for security.</p>
|
||||
|
||||
<h2>symbolic_permissions(<kbd>$perms</kbd>)</h2>
|
||||
|
||||
<p>Takes numeric permissions (such as is returned by <kbd>fileperms()</kbd> and returns standard symbolic notation of file permissions.</p>
|
||||
|
||||
<code>echo symbolic_permissions(fileperms('./index.php'));<br />
|
||||
<br />
|
||||
// -rw-r--r--</code>
|
||||
|
||||
<h2>octal_permissions(<kbd>$perms</kbd>)</h2>
|
||||
|
||||
<p>Takes numeric permissions (such as is returned by <kbd>fileperms()</kbd> and returns a three character octal notation of file permissions.</p>
|
||||
|
||||
<code>echo octal_permissions(fileperms('./index.php'));<br />
|
||||
<br />
|
||||
// 644</code>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- END CONTENT -->
|
||||
|
||||
|
||||
<div id="footer">
|
||||
<p>
|
||||
Previous Topic: <a href="email_helper.html">Email Helper</a>
|
||||
·
|
||||
<a href="#top">Top of Page</a> ·
|
||||
<a href="../index.html">User Guide Home</a> ·
|
||||
Next Topic: <a href="form_helper.html">Form Helper</a></p>
|
||||
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006-2010 · <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,484 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Form Helper : CodeIgniter User Guide</title>
|
||||
|
||||
<style type='text/css' media='all'>@import url('../userguide.css');</style>
|
||||
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
|
||||
|
||||
<script type="text/javascript" src="../nav/nav.js"></script>
|
||||
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
|
||||
<script type="text/javascript" src="../nav/moo.fx.js"></script>
|
||||
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
|
||||
|
||||
<meta http-equiv='expires' content='-1' />
|
||||
<meta http-equiv= 'pragma' content='no-cache' />
|
||||
<meta name='robots' content='all' />
|
||||
<meta name='author' content='ExpressionEngine Dev Team' />
|
||||
<meta name='description' content='CodeIgniter User Guide' />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- START NAVIGATION -->
|
||||
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
|
||||
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
|
||||
<div id="masthead">
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td><h1>CodeIgniter User Guide Version 1.7.3</h1></td>
|
||||
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END NAVIGATION -->
|
||||
|
||||
|
||||
<!-- START BREADCRUMB -->
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td id="breadcrumb">
|
||||
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
|
||||
<a href="../index.html">User Guide Home</a> ›
|
||||
Form Helper
|
||||
</td>
|
||||
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- END BREADCRUMB -->
|
||||
|
||||
<br clear="all" />
|
||||
|
||||
|
||||
<!-- START CONTENT -->
|
||||
<div id="content">
|
||||
|
||||
|
||||
<h1>Form Helper</h1>
|
||||
|
||||
<p>The Form Helper file contains functions that assist in working with forms.</p>
|
||||
|
||||
|
||||
<h2>Loading this Helper</h2>
|
||||
|
||||
<p>This helper is loaded using the following code:</p>
|
||||
<code>$this->load->helper('form');</code>
|
||||
|
||||
<p>The following functions are available:</p>
|
||||
|
||||
|
||||
|
||||
<h2>form_open()</h2>
|
||||
|
||||
<p>Creates an opening form tag with a base URL <strong>built from your config preferences</strong>. It will optionally let you
|
||||
add form attributes and hidden input fields.</p>
|
||||
|
||||
<p>The main benefit of using this tag rather than hard coding your own HTML is that it permits your site to be more portable
|
||||
in the event your URLs ever change.</p>
|
||||
|
||||
<p>Here's a simple example:</p>
|
||||
|
||||
<code>echo form_open('email/send');</code>
|
||||
|
||||
<p>The above example would create a form that points to your base URL plus the "email/send" URI segments, like this:</p>
|
||||
|
||||
<code><form method="post" action="http:/example.com/index.php/email/send" /></code>
|
||||
|
||||
<h4>Adding Attributes</h4>
|
||||
|
||||
<p>Attributes can be added by passing an associative array to the second parameter, like this:</p>
|
||||
|
||||
<code>
|
||||
$attributes = array('class' => 'email', 'id' => 'myform');<br />
|
||||
<br />
|
||||
echo form_open('email/send', $attributes);</code>
|
||||
|
||||
<p>The above example would create a form similar to this:</p>
|
||||
|
||||
<code><form method="post" action="http:/example.com/index.php/email/send" class="email" id="myform" /></code>
|
||||
|
||||
<h4>Adding Hidden Input Fields</h4>
|
||||
|
||||
<p>Hidden fields can be added by passing an associative array to the third parameter, like this:</p>
|
||||
|
||||
<code>
|
||||
$hidden = array('username' => 'Joe', 'member_id' => '234');<br />
|
||||
<br />
|
||||
echo form_open('email/send', '', $hidden);</code>
|
||||
|
||||
<p>The above example would create a form similar to this:</p>
|
||||
|
||||
<code><form method="post" action="http:/example.com/index.php/email/send"><br />
|
||||
<input type="hidden" name="username" value="Joe" /><br />
|
||||
<input type="hidden" name="member_id" value="234" /></code>
|
||||
|
||||
|
||||
<h2>form_open_multipart()</h2>
|
||||
|
||||
<p>This function is absolutely identical to the <dfn>form_open()</dfn> tag above except that it adds a multipart attribute,
|
||||
which is necessary if you would like to use the form to upload files with.</p>
|
||||
|
||||
<h2>form_hidden()</h2>
|
||||
|
||||
<p>Lets you generate hidden input fields. You can either submit a name/value string to create one field:</p>
|
||||
|
||||
<code>form_hidden('username', 'johndoe');<br />
|
||||
<br />
|
||||
// Would produce:<br /><br />
|
||||
<input type="hidden" name="username" value="johndoe" /></code>
|
||||
|
||||
<p>Or you can submit an associative array to create multiple fields:</p>
|
||||
|
||||
<code>$data = array(<br />
|
||||
'name' => 'John Doe',<br />
|
||||
'email' => 'john@example.com',<br />
|
||||
'url' => 'http://example.com'<br />
|
||||
);<br />
|
||||
<br />
|
||||
echo form_hidden($data);<br />
|
||||
<br />
|
||||
// Would produce:<br /><br />
|
||||
<input type="hidden" name="name" value="John Doe" /><br />
|
||||
<input type="hidden" name="email" value="john@example.com" /><br />
|
||||
<input type="hidden" name="url" value="http://example.com" /></code>
|
||||
|
||||
|
||||
|
||||
|
||||
<h2>form_input()</h2>
|
||||
|
||||
<p>Lets you generate a standard text input field. You can minimally pass the field name and value in the first
|
||||
and second parameter:</p>
|
||||
|
||||
<code>echo form_input('username', 'johndoe');</code>
|
||||
|
||||
<p>Or you can pass an associative array containing any data you wish your form to contain:</p>
|
||||
|
||||
<code>$data = array(<br />
|
||||
'name' => 'username',<br />
|
||||
'id' => 'username',<br />
|
||||
'value' => 'johndoe',<br />
|
||||
'maxlength' => '100',<br />
|
||||
'size' => '50',<br />
|
||||
'style' => 'width:50%',<br />
|
||||
);<br />
|
||||
<br />
|
||||
echo form_input($data);<br />
|
||||
<br />
|
||||
// Would produce:<br /><br />
|
||||
<input type="text" name="username" id="username" value="johndoe" maxlength="100" size="50" style="width:50%" /></code>
|
||||
|
||||
<p>If you would like your form to contain some additional data, like Javascript, you can pass it as a string in the
|
||||
third parameter:</p>
|
||||
|
||||
<code>$js = 'onClick="some_function()"';<br />
|
||||
<br />
|
||||
echo form_input('username', 'johndoe', $js);</code>
|
||||
|
||||
<h2>form_password()</h2>
|
||||
|
||||
<p>This function is identical in all respects to the <dfn>form_input()</dfn> function above
|
||||
except that is sets it as a "password" type.</p>
|
||||
|
||||
<h2>form_upload()</h2>
|
||||
|
||||
<p>This function is identical in all respects to the <dfn>form_input()</dfn> function above
|
||||
except that is sets it as a "file" type, allowing it to be used to upload files.</p>
|
||||
|
||||
<h2>form_textarea()</h2>
|
||||
|
||||
<p>This function is identical in all respects to the <dfn>form_input()</dfn> function above
|
||||
except that it generates a "textarea" type. Note: Instead of the "maxlength" and "size" attributes in the above
|
||||
example, you will instead specify "rows" and "cols".</p>
|
||||
|
||||
|
||||
<h2>form_dropdown()</h2>
|
||||
|
||||
<p>Lets you create a standard drop-down field. The first parameter will contain the name of the field,
|
||||
the second parameter will contain an associative array of options, and the third parameter will contain the
|
||||
value you wish to be selected. You can also pass an array of multiple items through the third parameter, and CodeIgniter will create a multiple select for you. Example:</p>
|
||||
|
||||
<code>$options = array(<br />
|
||||
'small' => 'Small Shirt',<br />
|
||||
'med' => 'Medium Shirt',<br />
|
||||
'large' => 'Large Shirt',<br />
|
||||
'xlarge' => 'Extra Large Shirt',<br />
|
||||
);<br />
|
||||
<br />
|
||||
$shirts_on_sale = array('small', 'large');<br />
|
||||
<br />
|
||||
echo form_dropdown('shirts', $options, 'large');<br />
|
||||
<br />
|
||||
// Would produce:<br />
|
||||
<br />
|
||||
<select name="shirts"><br />
|
||||
<option value="small">Small Shirt</option><br />
|
||||
<option value="med">Medium Shirt</option><br />
|
||||
<option value="large" selected="selected">Large Shirt</option><br />
|
||||
<option value="xlarge">Extra Large Shirt</option><br />
|
||||
</select><br />
|
||||
<br />
|
||||
echo form_dropdown('shirts', $options, $shirts_on_sale);<br />
|
||||
<br />
|
||||
// Would produce:<br />
|
||||
<br />
|
||||
<select name="shirts" multiple="multiple"><br />
|
||||
<option value="small" selected="selected">Small Shirt</option><br />
|
||||
<option value="med">Medium Shirt</option><br />
|
||||
<option value="large" selected="selected">Large Shirt</option><br />
|
||||
<option value="xlarge">Extra Large Shirt</option><br />
|
||||
</select></code>
|
||||
|
||||
|
||||
<p>If you would like the opening <select> to contain additional data, like an <kbd>id</kbd> attribute or JavaScript, you can pass it as a string in the
|
||||
fourth parameter:</p>
|
||||
|
||||
<code>$js = 'id="shirts" onChange="some_function();"';<br />
|
||||
<br />
|
||||
echo form_dropdown('shirts', $options, 'large', $js);</code>
|
||||
|
||||
<p>If the array passed as $options is a multidimensional array, form_dropdown() will produce an <optgroup> with the array key as the label.</p>
|
||||
|
||||
<h2>form_multiselect()</h2>
|
||||
|
||||
<p>Lets you create a standard multiselect field. The first parameter will contain the name of the field,
|
||||
the second parameter will contain an associative array of options, and the third parameter will contain the
|
||||
value or values you wish to be selected. The parameter usage is identical to using <kbd>form_dropdown()</kbd> above,
|
||||
except of course that the name of the field will need to use POST array syntax, e.g. <samp>foo[]</samp>.</p>
|
||||
|
||||
|
||||
<h2>form_fieldset()</h2>
|
||||
|
||||
<p>Lets you generate fieldset/legend fields.</p>
|
||||
<code>echo form_fieldset('Address Information');<br />
|
||||
echo "<p>fieldset content here</p>\n";<br />
|
||||
echo form_fieldset_close();
|
||||
<br />
|
||||
<br />
|
||||
// Produces<br />
|
||||
<fieldset>
|
||||
<br />
|
||||
<legend>Address Information</legend>
|
||||
<br />
|
||||
<p>form content here</p>
|
||||
<br />
|
||||
</fieldset></code>
|
||||
<p>Similar to other functions, you can submit an associative array in the second parameter if you prefer to set additional attributes. </p>
|
||||
<p><code>$attributes = array('id' => 'address_info', 'class' => 'address_info');<br />
|
||||
echo form_fieldset('Address Information', $attributes);<br />
|
||||
echo "<p>fieldset content here</p>\n";<br />
|
||||
echo form_fieldset_close(); <br />
|
||||
<br />
|
||||
// Produces<br />
|
||||
<fieldset id="address_info" class="address_info"> <br />
|
||||
<legend>Address Information</legend> <br />
|
||||
<p>form content here</p> <br />
|
||||
</fieldset></code></p>
|
||||
<h2>form_fieldset_close()</h2>
|
||||
<p>Produces a closing </fieldset> tag. The only advantage to using this function is it permits you to pass data to it
|
||||
which will be added below the tag. For example:</p>
|
||||
<code>$string = "</div></div>";<br />
|
||||
<br />
|
||||
echo fieldset_close($string);<br />
|
||||
<br />
|
||||
// Would produce:<br />
|
||||
</fieldset><br />
|
||||
</div></div></code>
|
||||
<h2>form_checkbox()</h2>
|
||||
<p>Lets you generate a checkbox field. Simple example:</p>
|
||||
<code>echo form_checkbox('newsletter', 'accept', TRUE);<br />
|
||||
<br />
|
||||
// Would produce:<br />
|
||||
<br />
|
||||
<input type="checkbox" name="newsletter" value="accept" checked="checked" /></code>
|
||||
<p>The third parameter contains a boolean TRUE/FALSE to determine whether the box should be checked or not.</p>
|
||||
<p>Similar to the other form functions in this helper, you can also pass an array of attributes to the function:</p>
|
||||
|
||||
<code>$data = array(<br />
|
||||
'name' => 'newsletter',<br />
|
||||
'id' => 'newsletter',<br />
|
||||
'value' => 'accept',<br />
|
||||
'checked' => TRUE,<br />
|
||||
'style' => 'margin:10px',<br />
|
||||
);<br />
|
||||
<br />
|
||||
echo form_checkbox($data);<br />
|
||||
<br />
|
||||
// Would produce:<br /><br />
|
||||
<input type="checkbox" name="newsletter" id="newsletter" value="accept" checked="checked" style="margin:10px" /></code>
|
||||
|
||||
<p>As with other functions, if you would like the tag to contain additional data, like JavaScript, you can pass it as a string in the
|
||||
fourth parameter:</p>
|
||||
|
||||
<code>$js = 'onClick="some_function()"';<br />
|
||||
<br />
|
||||
echo form_checkbox('newsletter', 'accept', TRUE, $js)</code>
|
||||
|
||||
|
||||
<h2>form_radio()</h2>
|
||||
<p>This function is identical in all respects to the <dfn>form_checkbox()</dfn> function above except that is sets it as a "radio" type.</p>
|
||||
|
||||
|
||||
<h2>form_submit()</h2>
|
||||
|
||||
<p>Lets you generate a standard submit button. Simple example:</p>
|
||||
<code>echo form_submit('mysubmit', 'Submit Post!');<br />
|
||||
<br />
|
||||
// Would produce:<br />
|
||||
<br />
|
||||
<input type="submit" name="mysubmit" value="Submit Post!" /></code>
|
||||
<p>Similar to other functions, you can submit an associative array in the first parameter if you prefer to set your own attributes.
|
||||
The third parameter lets you add extra data to your form, like JavaScript.</p>
|
||||
<h2>form_label()</h2>
|
||||
<p>Lets you generate a <label>. Simple example:</p>
|
||||
<code>echo form_label('What is your Name', 'username');<br />
|
||||
<br />
|
||||
// Would produce:
|
||||
<br />
|
||||
<label for="username">What is your Name</label></code>
|
||||
<p>Similar to other functions, you can submit an associative array in the third parameter if you prefer to set additional attributes. </p>
|
||||
<p><code>$attributes = array(<br />
|
||||
'class' => 'mycustomclass',<br />
|
||||
'style' => 'color: #000;',<br />
|
||||
);<br />
|
||||
echo form_label('What is your Name', 'username', $attributes);<br />
|
||||
<br />
|
||||
// Would produce: <br />
|
||||
<label for="username" class="mycustomclass" style="color: #000;">What is your Name</label></code></p>
|
||||
<h2>form_reset()</h2>
|
||||
|
||||
<p>Lets you generate a standard reset button. Use is identical to <dfn>form_submit()</dfn>.</p>
|
||||
|
||||
<h2>form_button()</h2>
|
||||
|
||||
<p>Lets you generate a standard button element. You can minimally pass the button name and content in the first and second parameter:</p>
|
||||
<code>
|
||||
echo form_button('name','content');<br />
|
||||
<br />
|
||||
// Would produce<br />
|
||||
<button name="name" type="button">Content</button>
|
||||
</code>
|
||||
|
||||
Or you can pass an associative array containing any data you wish your form to contain:
|
||||
<code>
|
||||
$data = array(<br />
|
||||
'name' => 'button',<br />
|
||||
'id' => 'button',<br />
|
||||
'value' => 'true',<br />
|
||||
'type' => 'reset',<br />
|
||||
'content' => 'Reset'<br />
|
||||
);<br />
|
||||
<br />
|
||||
echo form_button($data);<br />
|
||||
<br />
|
||||
// Would produce:<br />
|
||||
<button name="button" id="button" value="true" type="reset">Reset</button>
|
||||
</code>
|
||||
|
||||
If you would like your form to contain some additional data, like JavaScript, you can pass it as a string in the third parameter:
|
||||
<code>
|
||||
$js = 'onClick="some_function()"';<br /><br />
|
||||
echo form_button('mybutton', 'Click Me', $js);
|
||||
</code>
|
||||
|
||||
|
||||
<h2>form_close()</h2>
|
||||
|
||||
<p>Produces a closing </form> tag. The only advantage to using this function is it permits you to pass data to it
|
||||
which will be added below the tag. For example:</p>
|
||||
|
||||
<code>$string = "</div></div>";<br />
|
||||
<br />
|
||||
echo form_close($string);<br />
|
||||
<br />
|
||||
// Would produce:<br />
|
||||
<br />
|
||||
</form><br />
|
||||
</div></div></code>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h2>form_prep()</h2>
|
||||
|
||||
<p>Allows you to safely use HTML and characters such as quotes within form elements without breaking out of the form. Consider this example:</p>
|
||||
|
||||
<code>$string = 'Here is a string containing <strong>"quoted"</strong> text.';<br />
|
||||
<br />
|
||||
<input type="text" name="myform" value="<var>$string</var>" /></code>
|
||||
|
||||
<p>Since the above string contains a set of quotes it will cause the form to break.
|
||||
The form_prep function converts HTML so that it can be used safely:</p>
|
||||
|
||||
<code><input type="text" name="myform" value="<var><?php echo form_prep($string); ?></var>" /></code>
|
||||
|
||||
<p class="important"><strong>Note:</strong> If you use any of the form helper functions listed in this page the form
|
||||
values will be prepped automatically, so there is no need to call this function. Use it only if you are
|
||||
creating your own form elements.</p>
|
||||
|
||||
|
||||
<h2>set_value()</h2>
|
||||
|
||||
<p>Permits you to set the value of an input form or textarea. You must supply the field name via the first parameter of the function.
|
||||
The second (optional) parameter allows you to set a default value for the form. Example:</p>
|
||||
|
||||
<code><input type="text" name="quantity" value="<dfn><?php echo set_value('quantity', '0'); ?></dfn>" size="50" /></code>
|
||||
|
||||
<p>The above form will show "0" when loaded for the first time.</p>
|
||||
|
||||
<h2>set_select()</h2>
|
||||
|
||||
<p>If you use a <dfn><select></dfn> menu, this function permits you to display the menu item that was selected. The first parameter
|
||||
must contain the name of the select menu, the second parameter must contain the value of
|
||||
each item, and the third (optional) parameter lets you set an item as the default (use boolean TRUE/FALSE).</p>
|
||||
|
||||
<p>Example:</p>
|
||||
|
||||
<code>
|
||||
<select name="myselect"><br />
|
||||
<option value="one" <dfn><?php echo set_select('myselect', 'one', TRUE); ?></dfn> >One</option><br />
|
||||
<option value="two" <dfn><?php echo set_select('myselect', 'two'); ?></dfn> >Two</option><br />
|
||||
<option value="three" <dfn><?php echo set_select('myselect', 'three'); ?></dfn> >Three</option><br />
|
||||
</select>
|
||||
</code>
|
||||
|
||||
|
||||
<h2>set_checkbox()</h2>
|
||||
|
||||
<p>Permits you to display a checkbox in the state it was submitted. The first parameter
|
||||
must contain the name of the checkbox, the second parameter must contain its value, and the third (optional) parameter lets you set an item as the default (use boolean TRUE/FALSE). Example:</p>
|
||||
|
||||
<code><input type="checkbox" name="mycheck" value="1" <dfn><?php echo set_checkbox('mycheck', '1'); ?></dfn> /><br />
|
||||
<input type="checkbox" name="mycheck" value="2" <dfn><?php echo set_checkbox('mycheck', '2'); ?></dfn> /></code>
|
||||
|
||||
|
||||
<h2>set_radio()</h2>
|
||||
|
||||
<p>Permits you to display radio buttons in the state they were submitted. This function is identical to the <strong>set_checkbox()</strong> function above.</p>
|
||||
|
||||
<code><input type="radio" name="myradio" value="1" <dfn><?php echo set_radio('myradio', '1', TRUE); ?></dfn> /><br />
|
||||
<input type="radio" name="myradio" value="2" <dfn><?php echo set_radio('myradio', '2'); ?></dfn> /></code>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
|
||||
|
||||
<div id="footer">
|
||||
<p>
|
||||
Previous Topic: <a href="file_helper.html">File Helper</a>
|
||||
·
|
||||
<a href="#top">Top of Page</a> ·
|
||||
<a href="../index.html">User Guide Home</a> ·
|
||||
Next Topic: <a href="html_helper.html">HTML Helper</a>
|
||||
</p>
|
||||
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006-2010 · <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,385 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>HTML Helper : CodeIgniter User Guide</title>
|
||||
|
||||
<style type='text/css' media='all'>@import url('../userguide.css');</style>
|
||||
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
|
||||
|
||||
<script type="text/javascript" src="../nav/nav.js"></script>
|
||||
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
|
||||
<script type="text/javascript" src="../nav/moo.fx.js"></script>
|
||||
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
|
||||
|
||||
<meta http-equiv='expires' content='-1' />
|
||||
<meta http-equiv= 'pragma' content='no-cache' />
|
||||
<meta name='robots' content='all' />
|
||||
<meta name='author' content='ExpressionEngine Dev Team' />
|
||||
<meta name='description' content='CodeIgniter User Guide' />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- START NAVIGATION -->
|
||||
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
|
||||
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
|
||||
<div id="masthead">
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td><h1>CodeIgniter User Guide Version 1.7.3</h1></td>
|
||||
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END NAVIGATION -->
|
||||
|
||||
|
||||
<!-- START BREADCRUMB -->
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td id="breadcrumb">
|
||||
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
|
||||
<a href="../index.html">User Guide Home</a> ›
|
||||
HTML Helper
|
||||
</td>
|
||||
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- END BREADCRUMB -->
|
||||
|
||||
<br clear="all" />
|
||||
|
||||
|
||||
<!-- START CONTENT -->
|
||||
<div id="content">
|
||||
|
||||
|
||||
<h1>HTML Helper</h1>
|
||||
|
||||
<p>The HTML Helper file contains functions that assist in working with HTML.</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="#br">br()</a></li>
|
||||
<li><a href="#heading">heading()</a></li>
|
||||
<li><a href="#img">img()</a></li>
|
||||
<li><a href="#link_tag">link_tag()</a></li>
|
||||
<li><a href="#nbs">nbs()</a></li>
|
||||
<li><a href="#ol_and_ul">ol() and ul()</a></li>
|
||||
<li><a href="#meta">meta()</a></li>
|
||||
<li><a href="#doctype">doctype()</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Loading this Helper</h2>
|
||||
|
||||
<p>This helper is loaded using the following code:</p>
|
||||
<code>$this->load->helper('html');</code>
|
||||
|
||||
<p>The following functions are available:</p>
|
||||
|
||||
<h2><a name="br"></a>br()</h2>
|
||||
<p>Generates line break tags (<br />) based on the number you submit. Example:</p>
|
||||
<code>echo br(3);</code>
|
||||
<p>The above would produce: <br /><br /><br /></p>
|
||||
|
||||
<h2><a name="heading"></a>heading()</h2>
|
||||
<p>Lets you create HTML <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: <h3>Welcome!</h3></p>
|
||||
|
||||
<h2><a name="img"></a>img()</h2>
|
||||
<p>Lets you create HTML <img /> tags. The first parameter contains the image source. Example:</p>
|
||||
<code>echo img('images/picture.jpg');<br />
|
||||
// gives <img src="http://site.com/images/picture.jpg" /></code>
|
||||
<p>There is an optional second parameter that is a TRUE/FALSE value that specifics if the src should have the page specified by $config['index_page'] added to the address it creates. Presumably, this would be if you were using a media controller.</p>
|
||||
<p><code>echo img('images/picture.jpg', TRUE);<br />
|
||||
// gives <img src="http://site.com/index.php/images/picture.jpg" /></code></p>
|
||||
<p>Additionally, an associative array can be passed to the img() function for complete control over all attributes and values.</p>
|
||||
<p><code> $image_properties = array(<br />
|
||||
'src' => 'images/picture.jpg',<br />
|
||||
'alt' => 'Me, demonstrating how to eat 4 slices of pizza at one time',<br />
|
||||
'class' => 'post_images',<br />
|
||||
'width' => '200',<br />
|
||||
'height' => '200',<br />
|
||||
'title' => 'That was quite a night',<br />
|
||||
'rel' => 'lightbox',<br />
|
||||
);<br />
|
||||
<br />
|
||||
img($image_properties);<br />
|
||||
// <img src="http://site.com/index.php/images/picture.jpg" alt="Me, demonstrating how to eat 4 slices of pizza at one time" class="post_images" width="200" height="200" title="That was quite a night" rel="lightbox" /></code></p>
|
||||
|
||||
<h2><a name="link_tag"></a>link_tag()</h2>
|
||||
<p>Lets you create HTML <link /> tags. This is useful for stylesheet links, as well as other links. 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.<code>
|
||||
echo link_tag('css/mystyles.css');<br />
|
||||
// gives <link href="http://site.com/css/mystyles.css" rel="stylesheet" type="text/css" /></code></p>
|
||||
<p>Further examples:</p>
|
||||
|
||||
<code>
|
||||
echo link_tag('favicon.ico', 'shortcut icon', 'image/ico');<br />
|
||||
// <link href="http://site.com/favicon.ico" rel="shortcut icon" type="image/ico" />
|
||||
<br />
|
||||
<br />
|
||||
echo link_tag('feed', 'alternate', 'application/rss+xml', 'My RSS Feed');<br />
|
||||
// <link href="http://site.com/feed" rel="alternate" type="application/rss+xml" title="My RSS Feed" /> </code>
|
||||
<p>Additionally, an associative array can be passed to the link() function for complete control over all attributes and values.</p>
|
||||
<p><code>
|
||||
$link = array(<br />
|
||||
'href' => 'css/printer.css',<br />
|
||||
'rel' => 'stylesheet',<br />
|
||||
'type' => 'text/css',<br />
|
||||
'media' => 'print'<br />
|
||||
);<br />
|
||||
<br />
|
||||
echo link_tag($link);<br />
|
||||
// <link href="http://site.com/css/printer.css" rel="stylesheet" type="text/css" media="print" /></code></p>
|
||||
|
||||
<h2><a name="nbs"></a>nbs()</h2>
|
||||
<p>Generates non-breaking spaces (&nbsp;) based on the number you submit. Example:</p>
|
||||
<code>echo nbs(3);</code>
|
||||
<p>The above would produce: &nbsp;&nbsp;&nbsp;</p>
|
||||
|
||||
<h2><a name="ol_and_ul"></a>ol() and ul()</h2>
|
||||
|
||||
<p>Permits you to generate ordered or unordered HTML lists from simple or multi-dimensional arrays. Example:</p>
|
||||
|
||||
<code>
|
||||
$this->load->helper('html');<br />
|
||||
<br />
|
||||
$list = array(<br />
|
||||
'red', <br />
|
||||
'blue', <br />
|
||||
'green',<br />
|
||||
'yellow'<br />
|
||||
);<br />
|
||||
<br />
|
||||
$attributes = array(<br />
|
||||
'class' => 'boldlist',<br />
|
||||
'id' => 'mylist'<br />
|
||||
);<br />
|
||||
<br />
|
||||
echo ul($list, $attributes);<br />
|
||||
</code>
|
||||
|
||||
<p>The above code will produce this:</p>
|
||||
|
||||
<code>
|
||||
<ul class="boldlist" id="mylist"><br />
|
||||
<li>red</li><br />
|
||||
<li>blue</li><br />
|
||||
<li>green</li><br />
|
||||
<li>yellow</li><br />
|
||||
</ul>
|
||||
</code>
|
||||
|
||||
<p>Here is a more complex example, using a multi-dimensional array:</p>
|
||||
|
||||
<code>
|
||||
$this->load->helper('html');<br />
|
||||
<br />
|
||||
$attributes = array(<br />
|
||||
'class' => 'boldlist',<br />
|
||||
'id' => 'mylist'<br />
|
||||
);<br />
|
||||
<br />
|
||||
$list = array(<br />
|
||||
'colors' => array(<br />
|
||||
'red',<br />
|
||||
'blue',<br />
|
||||
'green'<br />
|
||||
),<br />
|
||||
'shapes' => array(<br />
|
||||
'round', <br />
|
||||
'square',<br />
|
||||
'circles' => array(<br />
|
||||
'ellipse', <br />
|
||||
'oval', <br />
|
||||
'sphere'<br />
|
||||
)<br />
|
||||
),<br />
|
||||
'moods' => array(<br />
|
||||
'happy', <br />
|
||||
'upset' => array(<br />
|
||||
'defeated' => array(<br />
|
||||
'dejected',<br />
|
||||
'disheartened',<br />
|
||||
'depressed'<br />
|
||||
),<br />
|
||||
'annoyed',<br />
|
||||
'cross',<br />
|
||||
'angry'<br />
|
||||
)<br />
|
||||
)<br />
|
||||
);<br />
|
||||
<br />
|
||||
<br />
|
||||
echo ul($list, $attributes);</code>
|
||||
|
||||
<p>The above code will produce this:</p>
|
||||
|
||||
<code>
|
||||
<ul class="boldlist" id="mylist"><br />
|
||||
<li>colors<br />
|
||||
<ul><br />
|
||||
<li>red</li><br />
|
||||
<li>blue</li><br />
|
||||
<li>green</li><br />
|
||||
</ul><br />
|
||||
</li><br />
|
||||
<li>shapes<br />
|
||||
<ul><br />
|
||||
<li>round</li><br />
|
||||
<li>suare</li><br />
|
||||
<li>circles<br />
|
||||
<ul><br />
|
||||
<li>elipse</li><br />
|
||||
<li>oval</li><br />
|
||||
<li>sphere</li><br />
|
||||
</ul><br />
|
||||
</li><br />
|
||||
</ul><br />
|
||||
</li><br />
|
||||
<li>moods<br />
|
||||
<ul><br />
|
||||
<li>happy</li><br />
|
||||
<li>upset<br />
|
||||
<ul><br />
|
||||
<li>defeated<br />
|
||||
<ul><br />
|
||||
<li>dejected</li><br />
|
||||
<li>disheartened</li><br />
|
||||
<li>depressed</li><br />
|
||||
</ul><br />
|
||||
</li><br />
|
||||
<li>annoyed</li><br />
|
||||
<li>cross</li><br />
|
||||
<li>angry</li><br />
|
||||
</ul><br />
|
||||
</li><br />
|
||||
</ul><br />
|
||||
</li><br />
|
||||
</ul>
|
||||
</code>
|
||||
|
||||
|
||||
|
||||
<h2><a name="meta"></a>meta()</h2>
|
||||
|
||||
<p>Helps you generate meta tags. You can pass strings to the function, or simple arrays, or multidimensional ones. Examples:</p>
|
||||
|
||||
<code>
|
||||
echo meta('description', 'My Great site');<br />
|
||||
// Generates: <meta name="description" content="My Great Site" /><br />
|
||||
<br /><br />
|
||||
|
||||
echo meta('Content-type', 'text/html; charset=utf-8', 'equiv'); // Note the third parameter. Can be "equiv" or "name"<br />
|
||||
// Generates: <meta http-equiv="Content-type" content="text/html; charset=utf-8" /><br />
|
||||
|
||||
<br /><br />
|
||||
|
||||
echo meta(array('name' => 'robots', 'content' => 'no-cache'));<br />
|
||||
// Generates: <meta name="robots" content="no-cache" /><br />
|
||||
|
||||
<br /><br />
|
||||
|
||||
$meta = array(<br />
|
||||
array('name' => 'robots', 'content' => 'no-cache'),<br />
|
||||
array('name' => 'description', 'content' => 'My Great Site'),<br />
|
||||
array('name' => 'keywords', 'content' => 'love, passion, intrigue, deception'),<br />
|
||||
array('name' => 'robots', 'content' => 'no-cache'),<br />
|
||||
array('name' => 'Content-type', 'content' => 'text/html; charset=utf-8', 'type' => 'equiv')<br />
|
||||
);<br />
|
||||
<br />
|
||||
echo meta($meta);
|
||||
<br />
|
||||
// Generates: <br />
|
||||
// <meta name="robots" content="no-cache" /><br />
|
||||
// <meta name="description" content="My Great Site" /><br />
|
||||
// <meta name="keywords" content="love, passion, intrigue, deception" /><br />
|
||||
// <meta name="robots" content="no-cache" /><br />
|
||||
// <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
||||
</code>
|
||||
|
||||
|
||||
<h2><a name="doctype"></a>doctype()</h2>
|
||||
|
||||
<p>Helps you generate document type declarations, or DTD's. XHTML 1.0 Strict is used by default, but many doctypes are available.</p>
|
||||
|
||||
<code>
|
||||
echo doctype();<br />
|
||||
// <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><br />
|
||||
<br />
|
||||
echo doctype('html4-trans');<br />
|
||||
// <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
</code>
|
||||
|
||||
<p>The following is a list of doctype choices. These are configurable, and pulled from <samp>application/config/doctypes.php</samp></p>
|
||||
|
||||
<table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder">
|
||||
<tr>
|
||||
<th>Doctype</th>
|
||||
<th>Option</th>
|
||||
<th>Result</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td">XHTML 1.1</td>
|
||||
<td class="td">doctype('xhtml11')</td>
|
||||
<td class="td"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td">XHTML 1.0 Strict</td>
|
||||
<td class="td">doctype('xhtml1-strict')</td>
|
||||
<td class="td"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td">XHTML 1.0 Transitional</td>
|
||||
<td class="td">doctype('xhtml1-trans')</td>
|
||||
<td class="td"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td">XHTML 1.0 Frameset</td>
|
||||
<td class="td">doctype('xhtml1-frame')</td>
|
||||
<td class="td"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td">HTML 5</td>
|
||||
<td class="td">doctype('html5')</td>
|
||||
<td class="td"><!DOCTYPE html></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td">HTML 4 Strict</td>
|
||||
<td class="td">doctype('html4-strict')</td>
|
||||
<td class="td"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td">HTML 4 Transitional</td>
|
||||
<td class="td">doctype('html4-trans')</td>
|
||||
<td class="td"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td">HTML 4 Frameset</td>
|
||||
<td class="td">doctype('html4-frame')</td>
|
||||
<td class="td"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
|
||||
|
||||
<div id="footer">
|
||||
<p>
|
||||
Previous Topic: <a href="form_helper.html">Form Helper</a>
|
||||
·
|
||||
<a href="#top">Top of Page</a> ·
|
||||
<a href="../index.html">User Guide Home</a> ·
|
||||
Next Topic: <a href="path_helper.html"> Path Helper</a></p>
|
||||
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006-2010 · <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,151 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Inflector Helper : CodeIgniter User Guide</title>
|
||||
|
||||
<style type='text/css' media='all'>@import url('../userguide.css');</style>
|
||||
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
|
||||
|
||||
<script type="text/javascript" src="../nav/nav.js"></script>
|
||||
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
|
||||
<script type="text/javascript" src="../nav/moo.fx.js"></script>
|
||||
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
|
||||
|
||||
<meta http-equiv='expires' content='-1' />
|
||||
<meta http-equiv= 'pragma' content='no-cache' />
|
||||
<meta name='robots' content='all' />
|
||||
<meta name='author' content='ExpressionEngine Dev Team' />
|
||||
<meta name='description' content='CodeIgniter User Guide' />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- START NAVIGATION -->
|
||||
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
|
||||
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
|
||||
<div id="masthead">
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td><h1>CodeIgniter User Guide Version 1.7.3</h1></td>
|
||||
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END NAVIGATION -->
|
||||
|
||||
|
||||
<!-- START BREADCRUMB -->
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td id="breadcrumb">
|
||||
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
|
||||
<a href="../index.html">User Guide Home</a> ›
|
||||
Inflector Helper
|
||||
</td>
|
||||
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- END BREADCRUMB -->
|
||||
|
||||
<br clear="all" />
|
||||
|
||||
|
||||
<!-- START CONTENT -->
|
||||
<div id="content">
|
||||
|
||||
|
||||
<h1>Inflector Helper</h1>
|
||||
|
||||
<p>The Inflector Helper file contains functions that permits you to change words to plural, singular, camel case, etc.</p>
|
||||
|
||||
|
||||
<h2>Loading this Helper</h2>
|
||||
|
||||
<p>This helper is loaded using the following code:</p>
|
||||
<code>$this->load->helper('inflector');</code>
|
||||
|
||||
<p>The following functions are available:</p>
|
||||
|
||||
|
||||
<h2>singular()</h2>
|
||||
|
||||
<p>Changes a plural word to singular. Example:</p>
|
||||
|
||||
<code>
|
||||
$word = "dogs";<br />
|
||||
echo singular($word); // Returns "dog"
|
||||
</code>
|
||||
|
||||
|
||||
<h2>plural()</h2>
|
||||
|
||||
<p>Changes a singular word to plural. Example:</p>
|
||||
|
||||
<code>
|
||||
$word = "dog";<br />
|
||||
echo plural($word); // Returns "dogs"
|
||||
</code>
|
||||
|
||||
|
||||
<p>To force a word to end with "es" use a second "true" argument. </p>
|
||||
<code> $word = "pass";<br />
|
||||
echo plural($word, TRUE); // Returns "passes" </code>
|
||||
|
||||
<h2>camelize()</h2>
|
||||
<p>Changes a string of words separated by spaces or underscores to camel case. Example:</p>
|
||||
|
||||
<code>
|
||||
$word = "my_dog_spot";<br />
|
||||
echo camelize($word); // Returns "myDogSpot"
|
||||
</code>
|
||||
|
||||
|
||||
<h2>underscore()</h2>
|
||||
|
||||
<p>Takes multiple words separated by spaces and underscores them. Example:</p>
|
||||
|
||||
<code>
|
||||
$word = "my dog spot";<br />
|
||||
echo underscore($word); // Returns "my_dog_spot"
|
||||
</code>
|
||||
|
||||
|
||||
<h2>humanize()</h2>
|
||||
|
||||
<p>Takes multiple words separated by underscores and adds spaces between them. Each word is capitalized. Example:</p>
|
||||
|
||||
<code>
|
||||
$word = "my_dog_spot";<br />
|
||||
echo humanize($word); // Returns "My Dog Spot"
|
||||
</code>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
|
||||
|
||||
<div id="footer">
|
||||
<p>
|
||||
Previous Topic: <a href="html_helper.html"> HTML Helper</a>
|
||||
·
|
||||
<a href="#top">Top of Page</a> ·
|
||||
<a href="../index.html">User Guide Home</a> ·
|
||||
Next Topic: <a href="number_helper.html">Number Helper</a>
|
||||
</p>
|
||||
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006-2010 · <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,98 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Language Helper : CodeIgniter User Guide</title>
|
||||
|
||||
<style type='text/css' media='all'>@import url('../userguide.css');</style>
|
||||
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
|
||||
|
||||
<script type="text/javascript" src="../nav/nav.js"></script>
|
||||
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
|
||||
<script type="text/javascript" src="../nav/moo.fx.js"></script>
|
||||
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
|
||||
|
||||
<meta http-equiv='expires' content='-1' />
|
||||
<meta http-equiv= 'pragma' content='no-cache' />
|
||||
<meta name='robots' content='all' />
|
||||
<meta name='author' content='ExpressionEngine Dev Team' />
|
||||
<meta name='description' content='CodeIgniter User Guide' />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- START NAVIGATION -->
|
||||
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
|
||||
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
|
||||
<div id="masthead">
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td><h1>CodeIgniter User Guide Version 1.7.3</h1></td>
|
||||
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END NAVIGATION -->
|
||||
|
||||
|
||||
<!-- START BREADCRUMB -->
|
||||
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td id="breadcrumb">
|
||||
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
|
||||
<a href="../index.html">User Guide Home</a> ›
|
||||
Language Helper
|
||||
</td>
|
||||
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- END BREADCRUMB -->
|
||||
|
||||
<br clear="all" />
|
||||
|
||||
|
||||
<!-- START CONTENT -->
|
||||
<div id="content">
|
||||
|
||||
|
||||
<h1>Language Helper</h1>
|
||||
|
||||
<p>The Language Helper file contains functions that assist in working with language files.</p>
|
||||
|
||||
|
||||
<h2>Loading this Helper</h2>
|
||||
|
||||
<p>This helper is loaded using the following code:</p>
|
||||
<code>$this->load->helper('language');</code>
|
||||
|
||||
<p>The following functions are available:</p>
|
||||
|
||||
<h2>lang('<var>language line</var>', '<var>element id</var>')</h2>
|
||||
|
||||
<p>This function returns a line of text from a loaded language file with simplified syntax
|
||||
that may be more desirable for view files than calling <kbd>$this->lang->line()</kbd>.
|
||||
The optional second parameter will also output a form label for you. Example:</p>
|
||||
|
||||
<code>echo lang('<samp>language_key</samp>', '<samp>form_item_id</samp>');<br />
|
||||
// becomes <label for="form_item_id">language_key</label></code>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
|
||||
|
||||
<div id="footer">
|
||||
<p>
|
||||
Previous Topic: <a href="date_helper.html">Date Helper</a>
|
||||
·
|
||||
<a href="#top">Top of Page</a> ·
|
||||
<a href="../index.html">User Guide Home</a> ·
|
||||
Next Topic: <a href="download_helper.html">Download Helper</a>
|
||||
</p>
|
||||
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006-2010 · <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,107 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Number Helper : CodeIgniter User Guide</title>
|
||||
|
||||
<style type='text/css' media='all'>@import url('../userguide.css');</style>
|
||||
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
|
||||
|
||||
<script type="text/javascript" src="../nav/nav.js"></script>
|
||||
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
|
||||
<script type="text/javascript" src="../nav/moo.fx.js"></script>
|
||||
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
|
||||
|
||||
<meta http-equiv='expires' content='-1' />
|
||||
<meta http-equiv= 'pragma' content='no-cache' />
|
||||
<meta name='robots' content='all' />
|
||||
<meta name='author' content='ExpressionEngine Dev Team' />
|
||||
<meta name='description' content='CodeIgniter User Guide' />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- START NAVIGATION -->
|
||||
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
|
||||
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
|
||||
<div id="masthead">
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td><h1>CodeIgniter User Guide Version 1.7.3</h1></td>
|
||||
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END NAVIGATION -->
|
||||
|
||||
|
||||
<!-- START BREADCRUMB -->
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td id="breadcrumb">
|
||||
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
|
||||
<a href="../index.html">User Guide Home</a> ›
|
||||
Number Helper
|
||||
</td>
|
||||
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- END BREADCRUMB -->
|
||||
|
||||
<br clear="all" />
|
||||
|
||||
|
||||
<!-- START CONTENT -->
|
||||
<div id="content">
|
||||
|
||||
|
||||
<h1>Number Helper</h1>
|
||||
|
||||
<p>The Number Helper file contains functions that help you work with numeric data.</p>
|
||||
|
||||
|
||||
<h2>Loading this Helper</h2>
|
||||
|
||||
<p>This helper is loaded using the following code:</p>
|
||||
<code>$this->load->helper('number');</code>
|
||||
|
||||
<p>The following functions are available:</p>
|
||||
|
||||
|
||||
<h2>byte_format()</h2>
|
||||
|
||||
<p>Formats a numbers as bytes, based on size, and adds the appropriate suffix. Examples:</p>
|
||||
|
||||
<code>
|
||||
echo byte_format(456); // Returns 456 Bytes<br />
|
||||
echo byte_format(4567); // Returns 4.5 KB<br />
|
||||
echo byte_format(45678); // Returns 44.8 KB<br />
|
||||
echo byte_format(456789); // Returns 447.8 KB<br />
|
||||
echo byte_format(3456789); // Returns 3.3 MB<br />
|
||||
echo byte_format(12345678912345); // Returns 1.8 GB<br />
|
||||
echo byte_format(123456789123456789); // Returns 11,228.3 TB
|
||||
</code>
|
||||
|
||||
<p class="important">
|
||||
<strong>Note:</strong>
|
||||
The text generated by this function is found in the following language file: language/<your_lang>/number_lang.php
|
||||
</p>
|
||||
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
|
||||
|
||||
<div id="footer">
|
||||
<p>
|
||||
Previous Topic: <a href="inflector_helper.html">Inflector Helper</a>
|
||||
·
|
||||
<a href="#top">Top of Page</a> ·
|
||||
<a href="../index.html">User Guide Home</a> ·
|
||||
Next Topic: <a href="path_helper.html">Path Helper</a>
|
||||
</p>
|
||||
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006-2010 · <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,106 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Path Helper : CodeIgniter User Guide</title>
|
||||
|
||||
<style type='text/css' media='all'>@import url('../userguide.css');</style>
|
||||
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
|
||||
|
||||
<script type="text/javascript" src="../nav/nav.js"></script>
|
||||
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
|
||||
<script type="text/javascript" src="../nav/moo.fx.js"></script>
|
||||
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
|
||||
|
||||
<meta http-equiv='expires' content='-1' />
|
||||
<meta http-equiv= 'pragma' content='no-cache' />
|
||||
<meta name='robots' content='all' />
|
||||
<meta name='author' content='ExpressionEngine Dev Team' />
|
||||
<meta name='description' content='CodeIgniter User Guide' />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- START NAVIGATION -->
|
||||
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
|
||||
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
|
||||
<div id="masthead">
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td><h1>CodeIgniter User Guide Version 1.7.3</h1></td>
|
||||
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END NAVIGATION -->
|
||||
|
||||
|
||||
<!-- START BREADCRUMB -->
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td id="breadcrumb">
|
||||
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
|
||||
<a href="../index.html">User Guide Home</a> ›
|
||||
Path Helper
|
||||
</td>
|
||||
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- END BREADCRUMB -->
|
||||
|
||||
<br clear="all" />
|
||||
|
||||
|
||||
<!-- START CONTENT -->
|
||||
<div id="content">
|
||||
|
||||
|
||||
<h1>Path Helper</h1>
|
||||
|
||||
<p>The Path Helper file contains functions that permits you to work with file paths on the server.</p>
|
||||
|
||||
|
||||
<h2>Loading this Helper</h2>
|
||||
|
||||
<p>This helper is loaded using the following code:</p>
|
||||
<code>$this->load->helper('path');</code>
|
||||
|
||||
<p>The following functions are available:</p>
|
||||
|
||||
|
||||
<h2>set_realpath()</h2>
|
||||
|
||||
<p>Checks to see if the path exists. This function will return a server path without symbolic links or relative directory structures. An optional second argument will cause an error to be triggered if the path cannot be resolved.</p>
|
||||
|
||||
<code>$directory = '/etc/passwd';<br />
|
||||
echo set_realpath($directory);<br />
|
||||
// returns "/etc/passwd"<br />
|
||||
<br />
|
||||
$non_existent_directory = '/path/to/nowhere';<br />
|
||||
echo set_realpath($non_existent_directory, TRUE);<br />
|
||||
// returns an <strong>error</strong>, as the path could not be resolved
|
||||
<br /><br />
|
||||
echo set_realpath($non_existent_directory, FALSE);<br />
|
||||
// returns "/path/to/nowhere"
|
||||
|
||||
|
||||
|
||||
</code>
|
||||
<h2> </h2>
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
|
||||
|
||||
<div id="footer">
|
||||
<p>
|
||||
Previous Topic: <a href="number_helper.html">Number Helper</a>
|
||||
·
|
||||
<a href="#top">Top of Page</a> ·
|
||||
<a href="../index.html">User Guide Home</a> ·
|
||||
Next Topic: <a href="security_helper.html">Security Helper</a>
|
||||
</p>
|
||||
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006-2010 · <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,125 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Security Helper : CodeIgniter User Guide</title>
|
||||
|
||||
<style type='text/css' media='all'>@import url('../userguide.css');</style>
|
||||
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
|
||||
|
||||
<script type="text/javascript" src="../nav/nav.js"></script>
|
||||
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
|
||||
<script type="text/javascript" src="../nav/moo.fx.js"></script>
|
||||
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
|
||||
|
||||
<meta http-equiv='expires' content='-1' />
|
||||
<meta http-equiv= 'pragma' content='no-cache' />
|
||||
<meta name='robots' content='all' />
|
||||
<meta name='author' content='ExpressionEngine Dev Team' />
|
||||
<meta name='description' content='CodeIgniter User Guide' />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- START NAVIGATION -->
|
||||
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
|
||||
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
|
||||
<div id="masthead">
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td><h1>CodeIgniter User Guide Version 1.7.3</h1></td>
|
||||
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END NAVIGATION -->
|
||||
|
||||
|
||||
<!-- START BREADCRUMB -->
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td id="breadcrumb">
|
||||
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
|
||||
<a href="../index.html">User Guide Home</a> ›
|
||||
Security Helper
|
||||
</td>
|
||||
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- END BREADCRUMB -->
|
||||
|
||||
<br clear="all" />
|
||||
|
||||
|
||||
<!-- START CONTENT -->
|
||||
<div id="content">
|
||||
|
||||
|
||||
<h1>Security Helper</h1>
|
||||
|
||||
<p>The Security Helper file contains security related functions.</p>
|
||||
|
||||
|
||||
<h2>Loading this Helper</h2>
|
||||
|
||||
<p>This helper is loaded using the following code:</p>
|
||||
<code>$this->load->helper('security');</code>
|
||||
|
||||
<p>The following functions are available:</p>
|
||||
|
||||
|
||||
<h2>xss_clean()</h2>
|
||||
|
||||
<p>Provides Cross Site Script Hack filtering. This function is an alias to the one in the
|
||||
<a href="../libraries/input.html">Input class</a>. More info can be found there.</p>
|
||||
|
||||
|
||||
<h2>dohash()</h2>
|
||||
|
||||
<p>Permits you to create SHA1 or MD5 one way hashes suitable for encrypting passwords. Will create SHA1 by default. Examples:</p>
|
||||
|
||||
<code>
|
||||
$str = dohash($str); // SHA1<br />
|
||||
<br />
|
||||
$str = dohash($str, 'md5'); // MD5
|
||||
</code>
|
||||
|
||||
|
||||
|
||||
|
||||
<h2>strip_image_tags()</h2>
|
||||
|
||||
<p>This is a security function that will strip image tags from a string. It leaves the image URL as plain text.</p>
|
||||
|
||||
<code>$string = strip_image_tags($string);</code>
|
||||
|
||||
|
||||
<h2>encode_php_tags()</h2>
|
||||
|
||||
<p>This is a security function that converts PHP tags to entities. Note: If you use the XSS filtering function it does this automatically.</p>
|
||||
|
||||
<code>$string = encode_php_tags($string);</code>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
|
||||
|
||||
<div id="footer">
|
||||
<p>
|
||||
Previous Topic: <a href="path_helper.html"> Path Helper</a>
|
||||
·
|
||||
<a href="#top">Top of Page</a> ·
|
||||
<a href="../index.html">User Guide Home</a> ·
|
||||
Next Topic: <a href="smiley_helper.html">Smiley Helper</a></p>
|
||||
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006-2010 · <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,215 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Smiley Helper : CodeIgniter User Guide</title>
|
||||
|
||||
<style type='text/css' media='all'>@import url('../userguide.css');</style>
|
||||
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
|
||||
|
||||
<script type="text/javascript" src="../nav/nav.js"></script>
|
||||
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
|
||||
<script type="text/javascript" src="../nav/moo.fx.js"></script>
|
||||
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
|
||||
|
||||
<meta http-equiv='expires' content='-1' />
|
||||
<meta http-equiv= 'pragma' content='no-cache' />
|
||||
<meta name='robots' content='all' />
|
||||
<meta name='author' content='ExpressionEngine Dev Team' />
|
||||
<meta name='description' content='CodeIgniter User Guide' />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- START NAVIGATION -->
|
||||
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
|
||||
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
|
||||
<div id="masthead">
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td><h1>CodeIgniter User Guide Version 1.7.3</h1></td>
|
||||
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END NAVIGATION -->
|
||||
|
||||
|
||||
<!-- START BREADCRUMB -->
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td id="breadcrumb">
|
||||
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
|
||||
<a href="../index.html">User Guide Home</a> ›
|
||||
Smiley Helper
|
||||
</td>
|
||||
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- END BREADCRUMB -->
|
||||
|
||||
<br clear="all" />
|
||||
|
||||
|
||||
<!-- START CONTENT -->
|
||||
<div id="content">
|
||||
|
||||
|
||||
<h1>Smiley Helper</h1>
|
||||
|
||||
<p>The Smiley Helper file contains functions that let you manage smileys (emoticons).</p>
|
||||
|
||||
|
||||
<h2>Loading this Helper</h2>
|
||||
|
||||
<p>This helper is loaded using the following code:</p>
|
||||
<code>$this->load->helper('smiley');</code>
|
||||
|
||||
<h2>Overview</h2>
|
||||
|
||||
<p>The Smiley helper has a renderer that takes plain text simileys, like <dfn>:-)</dfn> and turns
|
||||
them into a image representation, like <img src="../images/smile.gif" width="19" height="19" border="0" alt="smile!" /></p>
|
||||
|
||||
<p>It also lets you display a set of smiley images that when clicked will be inserted into a form field.
|
||||
For example, if you have a blog that allows user commenting you can show the smileys next to the comment form.
|
||||
Your users can click a desired smiley and with the help of some JavaScript it will be placed into the form field.</p>
|
||||
|
||||
|
||||
|
||||
<h2>Clickable Smileys Tutorial</h2>
|
||||
|
||||
<p>Here is an example demonstrating how you might create a set of clickable smileys next to a form field. This example
|
||||
requires that you first download and install the smiley images, then create a controller and the View as described.</p>
|
||||
|
||||
<p class="important"><strong>Important:</strong> Before you begin, please <a href="http://codeigniter.com/download_files/smileys.zip">download the smiley images</a> and put them in
|
||||
a publicly accessible place on your server. This helper also assumes you have the smiley replacement array located at
|
||||
<dfn>application/config/smileys.php</dfn></p>
|
||||
|
||||
|
||||
<h3>The Controller</h3>
|
||||
|
||||
<p>In your <dfn>application/controllers/</dfn> folder, create a file called <kbd>smileys.php</kbd> and place the code below in it.</p>
|
||||
|
||||
<p><strong>Important:</strong> Change the URL in the <dfn>get_clickable_smileys()</dfn> function below so that it points to
|
||||
your <dfn>smiley</dfn> folder.</p>
|
||||
|
||||
<p>You'll notice that in addition to the smiley helper we are using the <a href="../libraries/table.html">Table Class</a>.</p>
|
||||
|
||||
<textarea class="textarea" style="width:100%" cols="50" rows="25">
|
||||
<?php
|
||||
|
||||
class Smileys extends Controller {
|
||||
|
||||
function Smileys()
|
||||
{
|
||||
parent::Controller();
|
||||
}
|
||||
|
||||
function index()
|
||||
{
|
||||
$this->load->helper('smiley');
|
||||
$this->load->library('table');
|
||||
|
||||
$image_array = get_clickable_smileys('http://example.com/images/smileys/', 'comments');
|
||||
|
||||
$col_array = $this->table->make_columns($image_array, 8);
|
||||
|
||||
$data['smiley_table'] = $this->table->generate($col_array);
|
||||
|
||||
$this->load->view('smiley_view', $data);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
</textarea>
|
||||
|
||||
<p>In your <dfn>application/views/</dfn> folder, create a file called <kbd>smiley_view.php</kbd> and place this code in it:</p>
|
||||
|
||||
<textarea class="textarea" style="width:100%" cols="50" rows="20">
|
||||
<html>
|
||||
<head>
|
||||
<title>Smileys</title>
|
||||
|
||||
<?php echo smiley_js(); ?>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<form name="blog">
|
||||
<textarea name="comments" id="comments" cols="40" rows="4"></textarea>
|
||||
</form>
|
||||
|
||||
<p>Click to insert a smiley!</p>
|
||||
|
||||
<?php echo $smiley_table; ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</textarea>
|
||||
|
||||
|
||||
<p>When you have created the above controller and view, load it by visiting <dfn>http://www.example.com/index.php/smileys/</dfn></p>
|
||||
|
||||
|
||||
<h3>Field Aliases</h3>
|
||||
|
||||
<p>When making changes to a view it can be inconvenient to have the field id in the controller. To work around this,
|
||||
you can give your smiley links a generic name that will be tied to a specific id in your view.</p>
|
||||
<code>$image_array = get_smiley_links("http://example.com/images/smileys/", "comment_textarea_alias");</code>
|
||||
|
||||
<p>To map the alias to the field id, pass them both into the smiley_js function:</p>
|
||||
<code>$image_array = smiley_js("comment_textarea_alias", "comments");</code>
|
||||
|
||||
|
||||
<h1>Function Reference</h1>
|
||||
|
||||
<h2>get_clickable_smileys()</h2>
|
||||
|
||||
<p>Returns an array containing your smiley images wrapped in a clickable link. You must supply the URL to your smiley folder
|
||||
and a field id or field alias.</p>
|
||||
|
||||
<code>$image_array = get_smiley_links("http://example.com/images/smileys/", "comment");</code>
|
||||
<p class="important">Note: Usage of this function without the second parameter, in combination with js_insert_smiley has been deprecated.</p>
|
||||
|
||||
|
||||
<h2>smiley_js()</h2>
|
||||
|
||||
<p>Generates the JavaScript that allows the images to be clicked and inserted into a form field.
|
||||
If you supplied an alias instead of an id when generating your smiley links, you need to pass the
|
||||
alias and corresponding form id into the function.
|
||||
This function is designed to be placed into the <head> area of your web page.</p>
|
||||
|
||||
<code><?php echo smiley_js(); ?></code>
|
||||
<p class="important">Note: This function replaces js_insert_smiley, which has been deprecated.</p>
|
||||
|
||||
|
||||
<h2>parse_smileys()</h2>
|
||||
|
||||
<p>Takes a string of text as input and replaces any contained plain text smileys into the image
|
||||
equivalent. The first parameter must contain your string, the second must contain the URL to your smiley folder:</p>
|
||||
|
||||
<code>
|
||||
$str = 'Here are some simileys: :-) ;-)';
|
||||
|
||||
$str = parse_smileys($str, "http://example.com/images/smileys/");
|
||||
|
||||
echo $str;
|
||||
</code>
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
|
||||
|
||||
<div id="footer">
|
||||
<p>
|
||||
Previous Topic: <a href="security_helper.html">Security Helper</a>
|
||||
·
|
||||
<a href="#top">Top of Page</a> ·
|
||||
<a href="../index.html">User Guide Home</a> ·
|
||||
Next Topic: <a href="string_helper.html">String Helper</a>
|
||||
</p>
|
||||
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006-2010 · <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,176 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>String Helper : CodeIgniter User Guide</title>
|
||||
|
||||
<style type='text/css' media='all'>@import url('../userguide.css');</style>
|
||||
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
|
||||
|
||||
<script type="text/javascript" src="../nav/nav.js"></script>
|
||||
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
|
||||
<script type="text/javascript" src="../nav/moo.fx.js"></script>
|
||||
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
|
||||
|
||||
<meta http-equiv='expires' content='-1' />
|
||||
<meta http-equiv= 'pragma' content='no-cache' />
|
||||
<meta name='robots' content='all' />
|
||||
<meta name='author' content='ExpressionEngine Dev Team' />
|
||||
<meta name='description' content='CodeIgniter User Guide' />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- START NAVIGATION -->
|
||||
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
|
||||
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
|
||||
<div id="masthead">
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td><h1>CodeIgniter User Guide Version 1.7.3</h1></td>
|
||||
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END NAVIGATION -->
|
||||
|
||||
|
||||
<!-- START BREADCRUMB -->
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td id="breadcrumb">
|
||||
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
|
||||
<a href="../index.html">User Guide Home</a> ›
|
||||
String Helper
|
||||
</td>
|
||||
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- END BREADCRUMB -->
|
||||
|
||||
<br clear="all" />
|
||||
|
||||
|
||||
<!-- START CONTENT -->
|
||||
<div id="content">
|
||||
|
||||
|
||||
<h1>String Helper</h1>
|
||||
|
||||
<p>The String Helper file contains functions that assist in working with strings.</p>
|
||||
|
||||
|
||||
<h2>Loading this Helper</h2>
|
||||
|
||||
<p>This helper is loaded using the following code:</p>
|
||||
<code>$this->load->helper('string');</code>
|
||||
|
||||
<p>The following functions are available:</p>
|
||||
|
||||
<h2>random_string()</h2>
|
||||
|
||||
<p>Generates a random string based on the type and length you specify. Useful for creating passwords or generating random hashes.</p>
|
||||
|
||||
<p>The first parameter specifies the type of string, the second parameter specifies the length. The following choices are available:</p>
|
||||
|
||||
|
||||
<ul>
|
||||
<li><strong>alnum</strong>: Alpha-numeric string with lower and uppercase characters.</li>
|
||||
<li><strong>numeric</strong>: Numeric string.</li>
|
||||
<li><strong>nozero</strong>: Numeric string with no zeros.</li>
|
||||
<li><strong>unique</strong>: Encrypted with MD5 and uniqid(). Note: The length parameter is not available for this type.
|
||||
Returns a fixed length 32 character string.</li>
|
||||
</ul>
|
||||
|
||||
<p>Usage example:</p>
|
||||
|
||||
<code>echo random_string('alnum', 16);</code>
|
||||
|
||||
|
||||
<h2>alternator()</h2>
|
||||
|
||||
<p>Allows two or more items to be alternated between, when cycling through a loop. Example:</p>
|
||||
|
||||
<code>for ($i = 0; $i < 10; $i++)<br />
|
||||
{<br />
|
||||
echo alternator('string one', 'string two');<br />
|
||||
}<br />
|
||||
</code>
|
||||
|
||||
<p>You can add as many parameters as you want, and with each iteration of your loop the next item will be returned.</p>
|
||||
|
||||
<code>for ($i = 0; $i < 10; $i++)<br />
|
||||
{<br />
|
||||
echo alternator('one', 'two', 'three', 'four', 'five');<br />
|
||||
}<br />
|
||||
</code>
|
||||
|
||||
<p><strong>Note:</strong> To use multiple separate calls to this function simply call the function with no arguments to re-initialize.</p>
|
||||
|
||||
|
||||
|
||||
<h2>repeater()</h2>
|
||||
<p>Generates repeating copies of the data you submit. Example:</p>
|
||||
<code>$string = "\n";<br />
|
||||
echo repeater($string, 30);</code>
|
||||
|
||||
<p>The above would generate 30 newlines.</p>
|
||||
<h2>reduce_double_slashes()</h2>
|
||||
<p>Converts double slashes in a string to a single slash, except those found in http://. Example: </p>
|
||||
<code>$string = "http://example.com//index.php";<br />
|
||||
echo reduce_double_slashes($string); // results in "http://example.com/index.php"</code>
|
||||
<h2>trim_slashes()</h2>
|
||||
<p>Removes any leading/trailing slashes from a string. Example:<br />
|
||||
<br />
|
||||
<code>$string = "/this/that/theother/";<br />
|
||||
echo trim_slashes($string); // results in this/that/theother</code></p>
|
||||
|
||||
|
||||
<h2>reduce_multiples()</h2>
|
||||
<p>Reduces multiple instances of a particular character occuring directly after each other. Example:</p>
|
||||
<code>
|
||||
$string="Fred, Bill,, Joe, Jimmy";<br />
|
||||
$string=reduce_multiples($string,","); //results in "Fred, Bill, Joe, Jimmy"
|
||||
</code>
|
||||
<p>The function accepts the following parameters:
|
||||
<code>reduce_multiples(string: text to search in, string: character to reduce, boolean: whether to remove the character from the front and end of the string)</code>
|
||||
|
||||
The first parameter contains the string in which you want to reduce the multiplies. The second parameter contains the character you want to have reduced.
|
||||
The third parameter is FALSE by default; if set to TRUE it will remove occurences of the character at the beginning and the end of the string. Example:
|
||||
|
||||
<code>
|
||||
$string=",Fred, Bill,, Joe, Jimmy,";<br />
|
||||
$string=reduce_multiples($string, ", ", TRUE); //results in "Fred, Bill, Joe, Jimmy"
|
||||
</code>
|
||||
</p>
|
||||
|
||||
<h2>quotes_to_entities()</h2>
|
||||
<p>Converts single and double quotes in a string to the corresponding HTML entities. Example:</p>
|
||||
<code>$string="Joe's \"dinner\"";<br />
|
||||
$string=quotes_to_entities($string); //results in "Joe&#39;s &quot;dinner&quot;"
|
||||
</code>
|
||||
|
||||
<h2>strip_quotes()</h2>
|
||||
<p>Removes single and double quotes from a string. Example:</p>
|
||||
<code>$string="Joe's \"dinner\"";<br />
|
||||
$string=strip_quotes($string); //results in "Joes dinner"
|
||||
</code>
|
||||
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
|
||||
|
||||
<div id="footer">
|
||||
<p>
|
||||
Previous Topic: <a href="smiley_helper.html">Smiley Helper</a>
|
||||
·
|
||||
<a href="#top">Top of Page</a> ·
|
||||
<a href="../index.html">User Guide Home</a> ·
|
||||
Next Topic: <a href="text_helper.html">Text Helper</a>
|
||||
</p>
|
||||
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006-2010 · <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,192 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Text Helper : CodeIgniter User Guide</title>
|
||||
|
||||
<style type='text/css' media='all'>@import url('../userguide.css');</style>
|
||||
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
|
||||
|
||||
<script type="text/javascript" src="../nav/nav.js"></script>
|
||||
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
|
||||
<script type="text/javascript" src="../nav/moo.fx.js"></script>
|
||||
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
|
||||
|
||||
<meta http-equiv='expires' content='-1' />
|
||||
<meta http-equiv= 'pragma' content='no-cache' />
|
||||
<meta name='robots' content='all' />
|
||||
<meta name='author' content='ExpressionEngine Dev Team' />
|
||||
<meta name='description' content='CodeIgniter User Guide' />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- START NAVIGATION -->
|
||||
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
|
||||
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
|
||||
<div id="masthead">
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td><h1>CodeIgniter User Guide Version 1.7.3</h1></td>
|
||||
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END NAVIGATION -->
|
||||
|
||||
|
||||
<!-- START BREADCRUMB -->
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td id="breadcrumb">
|
||||
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
|
||||
<a href="../index.html">User Guide Home</a> ›
|
||||
Text Helper
|
||||
</td>
|
||||
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- END BREADCRUMB -->
|
||||
|
||||
<br clear="all" />
|
||||
|
||||
|
||||
<!-- START CONTENT -->
|
||||
<div id="content">
|
||||
|
||||
|
||||
<h1>Text Helper</h1>
|
||||
|
||||
<p>The Text Helper file contains functions that assist in working with text.</p>
|
||||
|
||||
|
||||
<h2>Loading this Helper</h2>
|
||||
|
||||
<p>This helper is loaded using the following code:</p>
|
||||
<code>$this->load->helper('text');</code>
|
||||
|
||||
<p>The following functions are available:</p>
|
||||
|
||||
|
||||
<h2>word_limiter()</h2>
|
||||
|
||||
<p>Truncates a string to the number of <strong>words</strong> specified. Example:</p>
|
||||
|
||||
<code>
|
||||
$string = "Here is a nice text string consisting of eleven words.";<br />
|
||||
<br />
|
||||
$string = word_limiter($string, 4);<br /><br />
|
||||
|
||||
// Returns: Here is a nice…
|
||||
</code>
|
||||
|
||||
<p>The third parameter is an optional suffix added to the string. By default it adds an ellipsis.</p>
|
||||
|
||||
|
||||
<h2>character_limiter()</h2>
|
||||
|
||||
<p>Truncates a string to the number of <strong>characters</strong> specified. It maintains the integrity
|
||||
of words so the character count may be slightly more or less then what you specify. Example:</p>
|
||||
|
||||
<code>
|
||||
$string = "Here is a nice text string consisting of eleven words.";<br />
|
||||
<br />
|
||||
$string = character_limiter($string, 20);<br /><br />
|
||||
|
||||
// Returns: Here is a nice text string…
|
||||
</code>
|
||||
|
||||
<p>The third parameter is an optional suffix added to the string, if undeclared this helper uses an ellipsis.</p>
|
||||
|
||||
|
||||
|
||||
<h2>ascii_to_entities()</h2>
|
||||
|
||||
<p>Converts ASCII values to character entities, including high ASCII and MS Word characters that can cause problems when used in a web page,
|
||||
so that they can be shown consistently regardless of browser settings or stored reliably in a database.
|
||||
There is some dependence on your server's supported character sets, so it may not be 100% reliable in all cases, but for the most
|
||||
part it should correctly identify characters outside the normal range (like accented characters). Example:</p>
|
||||
|
||||
<code>$string = ascii_to_entities($string);</code>
|
||||
|
||||
|
||||
<h2>entities_to_ascii()</h2>
|
||||
|
||||
<p>This function does the opposite of the previous one; it turns character entities back into ASCII.</p>
|
||||
|
||||
|
||||
<h2>word_censor()</h2>
|
||||
|
||||
<p>Enables you to censor words within a text string. The first parameter will contain the original string. The
|
||||
second will contain an array of words which you disallow. The third (optional) parameter can contain a replacement value
|
||||
for the words. If not specified they are replaced with pound signs: ####. Example:</p>
|
||||
|
||||
<code>
|
||||
$disallowed = array('darn', 'shucks', 'golly', 'phooey');<br />
|
||||
<br />
|
||||
$string = word_censor($string, $disallowed, 'Beep!');</code>
|
||||
|
||||
|
||||
<h2>highlight_code()</h2>
|
||||
|
||||
<p>Colorizes a string of code (PHP, HTML, etc.). Example:</p>
|
||||
|
||||
<code>$string = highlight_code($string);</code>
|
||||
|
||||
<p>The function uses PHP's highlight_string() function, so the colors used are the ones specified in your php.ini file.</p>
|
||||
|
||||
|
||||
<h2>highlight_phrase()</h2>
|
||||
|
||||
<p>Will highlight a phrase within a text string. The first parameter will contain the original string, the second will
|
||||
contain the phrase you wish to highlight. The third and fourth parameters will contain the opening/closing HTML tags
|
||||
you would like the phrase wrapped in. Example:</p>
|
||||
|
||||
<code>
|
||||
$string = "Here is a nice text string about nothing in particular.";<br />
|
||||
<br />
|
||||
$string = highlight_phrase($string, "nice text", '<span style="color:#990000">', '</span>');
|
||||
</code>
|
||||
|
||||
<p>The above text returns:</p>
|
||||
|
||||
<p>Here is a <span style="color:#990000">nice text</span> string about nothing in particular.</p>
|
||||
|
||||
|
||||
|
||||
<h2>word_wrap()</h2>
|
||||
|
||||
<p>Wraps text at the specified <strong>character</strong> count while maintaining complete words. Example:</p>
|
||||
|
||||
<code>$string = "Here is a simple string of text that will help us demonstrate this function.";<br />
|
||||
<br />
|
||||
echo word_wrap($string, 25);<br />
|
||||
<br />
|
||||
// Would produce:<br />
|
||||
<br />
|
||||
Here is a simple string<br />
|
||||
of text that will help<br />
|
||||
us demonstrate this<br />
|
||||
function</code>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
|
||||
|
||||
<div id="footer">
|
||||
<p>
|
||||
Previous Topic: <a href="string_helper.html">String Helper</a>
|
||||
·
|
||||
<a href="#top">Top of Page</a> ·
|
||||
<a href="../index.html">User Guide Home</a> ·
|
||||
Next Topic: <a href="typography_helper.html">Typography Helper</a>
|
||||
</p>
|
||||
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006-2010 · <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,112 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Typography Helper : CodeIgniter User Guide</title>
|
||||
|
||||
<style type='text/css' media='all'>@import url('../userguide.css');</style>
|
||||
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
|
||||
|
||||
<script type="text/javascript" src="../nav/nav.js"></script>
|
||||
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
|
||||
<script type="text/javascript" src="../nav/moo.fx.js"></script>
|
||||
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
|
||||
|
||||
<meta http-equiv='expires' content='-1' />
|
||||
<meta http-equiv= 'pragma' content='no-cache' />
|
||||
<meta name='robots' content='all' />
|
||||
<meta name='author' content='ExpressionEngine Dev Team' />
|
||||
<meta name='description' content='CodeIgniter User Guide' />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- START NAVIGATION -->
|
||||
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
|
||||
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
|
||||
<div id="masthead">
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td><h1>CodeIgniter User Guide Version 1.7.3</h1></td>
|
||||
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END NAVIGATION -->
|
||||
|
||||
|
||||
<!-- START BREADCRUMB -->
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td id="breadcrumb">
|
||||
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
|
||||
<a href="../index.html">User Guide Home</a> ›
|
||||
Typography Helper
|
||||
</td>
|
||||
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- END BREADCRUMB -->
|
||||
|
||||
<br clear="all" />
|
||||
|
||||
|
||||
<!-- START CONTENT -->
|
||||
<div id="content">
|
||||
|
||||
|
||||
<h1>Typography Helper</h1>
|
||||
|
||||
<p>The Typography Helper file contains functions that help your format text in semantically relevant ways.</p>
|
||||
|
||||
|
||||
<h2>Loading this Helper</h2>
|
||||
|
||||
<p>This helper is loaded using the following code:</p>
|
||||
<code>$this->load->helper('typography');</code>
|
||||
|
||||
<p>The following functions are available:</p>
|
||||
|
||||
|
||||
<h2>auto_typography()</h2>
|
||||
|
||||
<p>Formats text so that it is semantically and typographically correct HTML. Please see the <a href="../libraries/typography.html">Typography Class</a> for more info.</p>
|
||||
|
||||
<p>Usage example:</p>
|
||||
|
||||
<code>$string = auto_typography($string);</code>
|
||||
|
||||
<p><strong>Note:</strong> Typographic formatting can be processor intensive, particularly if you have a lot of content being formatted.
|
||||
If you choose to use this function you may want to consider
|
||||
<a href="../general/caching.html">caching</a> your pages.</p>
|
||||
|
||||
|
||||
<h2>nl2br_except_pre()</h2>
|
||||
|
||||
<p>Converts newlines to <br /> tags unless they appear within <pre> tags.
|
||||
This function is identical to the native PHP <dfn>nl2br()</dfn> function, except that it ignores <pre> tags.</p>
|
||||
|
||||
<p>Usage example:</p>
|
||||
|
||||
<code>$string = nl2br_except_pre($string);</code>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
|
||||
|
||||
<div id="footer">
|
||||
<p>
|
||||
Previous Topic: <a href="text_helper.html">Text Helper</a>
|
||||
·
|
||||
<a href="#top">Top of Page</a> ·
|
||||
<a href="../index.html">User Guide Home</a> ·
|
||||
Next Topic: <a href="url_helper.html">URL Helper</a>
|
||||
</p>
|
||||
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006-2010 · <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,289 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>URL Helper : CodeIgniter User Guide</title>
|
||||
|
||||
<style type='text/css' media='all'>@import url('../userguide.css');</style>
|
||||
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
|
||||
|
||||
<script type="text/javascript" src="../nav/nav.js"></script>
|
||||
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
|
||||
<script type="text/javascript" src="../nav/moo.fx.js"></script>
|
||||
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
|
||||
|
||||
<meta http-equiv='expires' content='-1' />
|
||||
<meta http-equiv= 'pragma' content='no-cache' />
|
||||
<meta name='robots' content='all' />
|
||||
<meta name='author' content='ExpressionEngine Dev Team' />
|
||||
<meta name='description' content='CodeIgniter User Guide' />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- START NAVIGATION -->
|
||||
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
|
||||
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
|
||||
<div id="masthead">
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td><h1>CodeIgniter User Guide Version 1.7.3</h1></td>
|
||||
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END NAVIGATION -->
|
||||
|
||||
|
||||
<!-- START BREADCRUMB -->
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td id="breadcrumb">
|
||||
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
|
||||
<a href="../index.html">User Guide Home</a> ›
|
||||
URL Helper
|
||||
</td>
|
||||
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- END BREADCRUMB -->
|
||||
|
||||
<br clear="all" />
|
||||
|
||||
|
||||
<!-- START CONTENT -->
|
||||
<div id="content">
|
||||
|
||||
|
||||
<h1>URL Helper</h1>
|
||||
|
||||
<p>The URL Helper file contains functions that assist in working with URLs.</p>
|
||||
|
||||
|
||||
<h2>Loading this Helper</h2>
|
||||
|
||||
<p>This helper is loaded using the following code:</p>
|
||||
<code>$this->load->helper('url');</code>
|
||||
|
||||
<p>The following functions are available:</p>
|
||||
|
||||
<h2>site_url()</h2>
|
||||
|
||||
<p>Returns your site URL, as specified in your config file. The index.php file (or whatever you have set as your
|
||||
site <dfn>index_page</dfn> in your config file) will be added to the URL, as will any URI segments you pass to the function.</p>
|
||||
|
||||
<p>You are encouraged to use this function any time you need to generate a local URL so that your pages become more portable
|
||||
in the event your URL changes.</p>
|
||||
|
||||
<p>Segments can be optionally passed to the function as a string or an array. Here is a string example:</p>
|
||||
|
||||
<code>echo site_url("news/local/123");</code>
|
||||
|
||||
<p>The above example would return something like: http://example.com/index.php/news/local/123</p>
|
||||
|
||||
<p>Here is an example of segments passed as an array:</p>
|
||||
|
||||
<code>
|
||||
$segments = array('news', 'local', '123');<br />
|
||||
<br />
|
||||
echo site_url($segments);</code>
|
||||
|
||||
|
||||
<h2>base_url()</h2>
|
||||
<p>Returns your site base URL, as specified in your config file. Example:</p>
|
||||
<code>echo base_url();</code>
|
||||
|
||||
|
||||
<h2>current_url()</h2>
|
||||
<p>Returns the full URL (including segments) of the page being currently viewed.</p>
|
||||
|
||||
|
||||
<h2>uri_string()</h2>
|
||||
<p>Returns the URI segments of any page that contains this function. For example, if your URL was this:</p>
|
||||
<code>http://some-site.com/blog/comments/123</code>
|
||||
|
||||
<p>The function would return:</p>
|
||||
<code>/blog/comments/123</code>
|
||||
|
||||
|
||||
<h2>index_page()</h2>
|
||||
<p>Returns your site "index" page, as specified in your config file. Example:</p>
|
||||
<code>echo index_page();</code>
|
||||
|
||||
|
||||
|
||||
<h2>anchor()</h2>
|
||||
|
||||
<p>Creates a standard HTML anchor link based on your local site URL:</p>
|
||||
|
||||
<code><a href="http://example.com">Click Here</a></code>
|
||||
|
||||
<p>The tag has three optional parameters:</p>
|
||||
|
||||
<code>anchor(<var>uri segments</var>, <var>text</var>, <var>attributes</var>)</code>
|
||||
|
||||
<p>The first parameter can contain any segments you wish appended to the URL. As with the <dfn>site_url()</dfn> function above,
|
||||
segments can be a string or an array.</p>
|
||||
|
||||
<p><strong>Note:</strong> If you are building links that are internal to your application do not include the base URL (http://...). This
|
||||
will be added automatically from the information specified in your config file. Include only the URI segments you wish appended to the URL.</p>
|
||||
|
||||
<p>The second segment is the text you would like the link to say. If you leave it blank, the URL will be used.</p>
|
||||
|
||||
<p>The third parameter can contain a list of attributes you would like added to the link. The attributes can be a simple string or an associative array.</p>
|
||||
|
||||
<p>Here are some examples:</p>
|
||||
|
||||
<code>echo anchor('news/local/123', 'title="My News"');</code>
|
||||
|
||||
<p>Would produce: <a href="http://example.com/index.php/news/local/123" title="My News">My News</a></p>
|
||||
|
||||
<code>echo anchor('news/local/123', 'My News', array('title' => 'The best news!'));</code>
|
||||
|
||||
<p>Would produce: <a href="http://example.com/index.php/news/local/123" title="The best news!">My News</a></p>
|
||||
|
||||
|
||||
<h2>anchor_popup()</h2>
|
||||
|
||||
<p>Nearly identical to the <dfn>anchor()</dfn> function except that it opens the URL in a new window.
|
||||
|
||||
You can specify JavaScript window attributes in the third parameter to control how the window is opened. If
|
||||
the third parameter is not set it will simply open a new window with your own browser settings. Here is an example
|
||||
with attributes:</p>
|
||||
|
||||
<code>
|
||||
|
||||
$atts = array(<br />
|
||||
'width' => '800',<br />
|
||||
'height' => '600',<br />
|
||||
'scrollbars' => 'yes',<br />
|
||||
'status' => 'yes',<br />
|
||||
'resizable' => 'yes',<br />
|
||||
'screenx' => '0',<br />
|
||||
'screeny' => '0'<br />
|
||||
);<br />
|
||||
<br />
|
||||
echo anchor_popup('news/local/123', 'Click Me!', $atts);</code>
|
||||
|
||||
<p>Note: The above attributes are the function defaults so you only need to set the ones that are different from what you need.
|
||||
If you want the function to use all of its defaults simply pass an empty array in the third parameter:</p>
|
||||
|
||||
<code>echo anchor_popup('news/local/123', 'Click Me!', array());</code>
|
||||
|
||||
|
||||
<h2>mailto()</h2>
|
||||
|
||||
<p>Creates a standard HTML email link. Usage example:</p>
|
||||
|
||||
<code>echo mailto('me@my-site.com', 'Click Here to Contact Me');</code>
|
||||
|
||||
<p>As with the <dfn>anchor()</dfn> tab above, you can set attributes using the third parameter.</p>
|
||||
|
||||
|
||||
<h2>safe_mailto()</h2>
|
||||
|
||||
<p>Identical to the above function except it writes an obfuscated version of the mailto tag using ordinal numbers
|
||||
written with JavaScript to help prevent the email address from being harvested by spam bots.</p>
|
||||
|
||||
|
||||
<h2>auto_link()</h2>
|
||||
|
||||
<p>Automatically turns URLs and email addresses contained in a string into links. Example:</p>
|
||||
|
||||
<code>$string = auto_link($string);</code>
|
||||
|
||||
<p>The second parameter determines whether URLs and emails are converted or just one or the other. Default behavior is both
|
||||
if the parameter is not specified. Email links are encoded as safe_mailto() as shown above.</p>
|
||||
|
||||
<p>Converts only URLs:</p>
|
||||
<code>$string = auto_link($string, 'url');</code>
|
||||
|
||||
<p>Converts only Email addresses:</p>
|
||||
<code>$string = auto_link($string, 'email');</code>
|
||||
|
||||
<p>The third parameter determines whether links are shown in a new window. The value can be TRUE or FALSE (boolean):</p>
|
||||
<code>$string = auto_link($string, 'both', TRUE);</code>
|
||||
|
||||
|
||||
<h2>url_title()</h2>
|
||||
<p>Takes a string as input and creates a human-friendly URL string. This is useful if, for example, you have a blog
|
||||
in which you'd like to use the title of your entries in the URL. Example:</p>
|
||||
|
||||
<code>$title = "What's wrong with CSS?";<br />
|
||||
<br />
|
||||
$url_title = url_title($title);<br />
|
||||
<br />
|
||||
// Produces: Whats-wrong-with-CSS
|
||||
</code>
|
||||
|
||||
|
||||
<p>The second parameter determines the word delimiter. By default dashes are used. Options are: <dfn>dash</dfn>, or <dfn>underscore</dfn>:</p>
|
||||
|
||||
<code>$title = "What's wrong with CSS?";<br />
|
||||
<br />
|
||||
$url_title = url_title($title, 'underscore');<br />
|
||||
<br />
|
||||
// Produces: Whats_wrong_with_CSS
|
||||
</code>
|
||||
|
||||
<p>The third parameter determines whether or not lowercase characters are forced. By default they are not. Options are boolean <dfn>TRUE</dfn>/<dfn>FALSE</dfn>:</p>
|
||||
|
||||
<code>$title = "What's wrong with CSS?";<br />
|
||||
<br />
|
||||
$url_title = url_title($title, 'underscore', TRUE);<br />
|
||||
<br />
|
||||
// Produces: whats_wrong_with_css
|
||||
</code>
|
||||
|
||||
<h3>prep_url()</h3>
|
||||
<p>This function will add <kbd>http://</kbd> in the event it is missing from a URL. Pass the URL string to the function like this:</p>
|
||||
<code>
|
||||
$url = "example.com";<br /><br />
|
||||
$url = prep_url($url);</code>
|
||||
|
||||
|
||||
|
||||
|
||||
<h2>redirect()</h2>
|
||||
|
||||
<p>Does a "header redirect" to the local URI specified. Just like other functions in this helper, this one is designed
|
||||
to redirect to a local URL within your site. You will <strong>not</strong> specify the full site URL, but rather simply the URI segments
|
||||
to the controller you want to direct to. The function will build the URL based on your config file values.</p>
|
||||
|
||||
<p>The optional second parameter allows you to choose between the "location"
|
||||
method (default) or the "refresh" method. Location is faster, but on Windows servers it can sometimes be a problem. The optional third parameter allows you to send a specific HTTP Response Code - this could be used for example to create 301 redirects for search engine purposes. The default Response Code is 302. The third parameter is <em>only</em> available with 'location' redirects, and not 'refresh'. Examples:</p>
|
||||
|
||||
<code>if ($logged_in == FALSE)<br />
|
||||
{<br />
|
||||
redirect('/login/form/', 'refresh');<br />
|
||||
}<br />
|
||||
<br />
|
||||
// with 301 redirect<br />
|
||||
redirect('/article/13', 'location', 301);</code>
|
||||
|
||||
<p class="important"><strong>Note:</strong> In order for this function to work it must be used before anything is outputted
|
||||
to the browser since it utilizes server headers.<br />
|
||||
<strong>Note:</strong> For very fine grained control over headers, you should use the <a href="../libraries/output.html">Output Library</a>'s set_header() function.</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
|
||||
|
||||
<div id="footer">
|
||||
<p>
|
||||
Previous Topic: <a href="typography_helper.html">Typography Helper</a>
|
||||
·
|
||||
<a href="#top">Top of Page</a> ·
|
||||
<a href="../index.html">User Guide Home</a> ·
|
||||
Next Topic: <a href="xml_helper.html">XML Helper</a>
|
||||
</p>
|
||||
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006-2010 · <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,105 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>XML Helper : CodeIgniter User Guide</title>
|
||||
|
||||
<style type='text/css' media='all'>@import url('../userguide.css');</style>
|
||||
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
|
||||
|
||||
<script type="text/javascript" src="../nav/nav.js"></script>
|
||||
<script type="text/javascript" src="../nav/prototype.lite.js"></script>
|
||||
<script type="text/javascript" src="../nav/moo.fx.js"></script>
|
||||
<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
|
||||
|
||||
<meta http-equiv='expires' content='-1' />
|
||||
<meta http-equiv= 'pragma' content='no-cache' />
|
||||
<meta name='robots' content='all' />
|
||||
<meta name='author' content='ExpressionEngine Dev Team' />
|
||||
<meta name='description' content='CodeIgniter User Guide' />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- START NAVIGATION -->
|
||||
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
|
||||
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
|
||||
<div id="masthead">
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td><h1>CodeIgniter User Guide Version 1.7.3</h1></td>
|
||||
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END NAVIGATION -->
|
||||
|
||||
|
||||
<!-- START BREADCRUMB -->
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
|
||||
<tr>
|
||||
<td id="breadcrumb">
|
||||
<a href="http://codeigniter.com/">CodeIgniter Home</a> ›
|
||||
<a href="../index.html">User Guide Home</a> ›
|
||||
XML Helper
|
||||
</td>
|
||||
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- END BREADCRUMB -->
|
||||
|
||||
<br clear="all" />
|
||||
|
||||
|
||||
<!-- START CONTENT -->
|
||||
<div id="content">
|
||||
|
||||
|
||||
<h1>XML Helper</h1>
|
||||
|
||||
<p>The XML Helper file contains functions that assist in working with XML data.</p>
|
||||
|
||||
|
||||
<h2>Loading this Helper</h2>
|
||||
|
||||
<p>This helper is loaded using the following code:</p>
|
||||
<code>$this->load->helper('xml');</code>
|
||||
|
||||
<p>The following functions are available:</p>
|
||||
|
||||
<h2>xml_convert('<var>string</var>')</h2>
|
||||
|
||||
<p>Takes a string as input and converts the following reserved XML characters to entities:</p>
|
||||
|
||||
<p>
|
||||
Ampersands: &<br />
|
||||
Less then and greater than characters: < ><br />
|
||||
Single and double quotes: ' "<br />
|
||||
Dashes: -</p>
|
||||
|
||||
<p>This function ignores ampersands if they are part of existing character entities. Example:</p>
|
||||
|
||||
<code>$string = xml_convert($string);</code>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
|
||||
|
||||
<div id="footer">
|
||||
<p>
|
||||
Previous Topic: <a href="url_helper.html">URL Helper</a>
|
||||
·
|
||||
<a href="#top">Top of Page</a> ·
|
||||
<a href="../index.html">User Guide Home</a>
|
||||
</p>
|
||||
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006-2010 · <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user