summaryrefslogtreecommitdiffstats
path: root/user_guide/helpers
diff options
context:
space:
mode:
authorPascal Kriete <pascal.kriete@ellislab.com>2010-11-04 22:59:52 +0100
committerPascal Kriete <pascal.kriete@ellislab.com>2010-11-04 22:59:52 +0100
commite917f9be8b05c81357c1c2c9730d5060685d644d (patch)
treeb6a7d5ce8ba57b69ba61454f77829b04f2ce5974 /user_guide/helpers
parent5b2d2da5ae2e97043c6bef53e565d30e50196e2b (diff)
parente1f6e9ddff788f6a154f5f35dc117d14aeb0c484 (diff)
Automated merge with http://hg.ellislab.com/CodeIgniter2
Diffstat (limited to 'user_guide/helpers')
-rw-r--r--user_guide/helpers/array_helper.html51
-rw-r--r--user_guide/helpers/captcha_helper.html22
-rw-r--r--user_guide/helpers/compatibility_helper.html2
-rw-r--r--user_guide/helpers/date_helper.html4
-rw-r--r--user_guide/helpers/directory_helper.html2
-rw-r--r--user_guide/helpers/form_helper.html6
-rw-r--r--user_guide/helpers/html_helper.html4
-rw-r--r--user_guide/helpers/smiley_helper.html14
-rw-r--r--user_guide/helpers/string_helper.html2
-rw-r--r--user_guide/helpers/text_helper.html2
10 files changed, 80 insertions, 29 deletions
diff --git a/user_guide/helpers/array_helper.html b/user_guide/helpers/array_helper.html
index c0bdd78e3..6d95c4a5f 100644
--- a/user_guide/helpers/array_helper.html
+++ b/user_guide/helpers/array_helper.html
@@ -100,7 +100,58 @@ echo element('size', $array, NULL);
echo random_element($quotes);</code>
+<h2>elements()</h2>
+<p>Lets you fetch a number of items from an array. The function tests whether each of the array indices is set. If an index does not exist
+it is set to FALSE, or whatever you've specified as the default value via the third parameter. Example:</p>
+
+<code>
+$array = array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'color' => 'red',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'shape' => 'round',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'radius' => '10',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'diameter' => '20'<br />
+);<br />
+<br />
+$my_shape = elements(array('color', 'shape', 'height'), $array);<br />
+</code>
+
+<p>The above will return the following array:</p>
+
+<code>
+array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'color' => 'red',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'shape' => 'round',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'height' => FALSE<br />
+);
+</code>
+
+<p>You can set the third parameter to any default value you like:</p>
+
+<code>
+$my_shape = elements(array('color', 'shape', 'height'), $array, NULL);<br />
+</code>
+
+<p>The above will return the following array:</p>
+
+<code>
+array(<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'color' => 'red',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'shape' => 'round',<br />
+&nbsp;&nbsp;&nbsp;&nbsp;'height' => NULL<br />
+);
+</code>
+
+<p>This is useful when sending the <kbd>$_POST</kbd> array to one of your Models. This prevents users from
+sending additional POST data to be entered into your tables:</p>
+
+<code>
+$this->load->model('post_model');<br />
+<br />
+$this->post_model->update(elements(array('id', 'title', 'content'), $_POST));
+</code>
+
+<p>This ensures that only the id, title and content fields are sent to be updated.</p>
</div>
<!-- END CONTENT -->
diff --git a/user_guide/helpers/captcha_helper.html b/user_guide/helpers/captcha_helper.html
index c4aa65fad..d6eb0652c 100644
--- a/user_guide/helpers/captcha_helper.html
+++ b/user_guide/helpers/captcha_helper.html
@@ -87,9 +87,9 @@ CAPTCHA Helper
<p>The "word" is the word that appears in the captcha image, which if not
supplied to the function, will be a random string.</p>
-
+
<h3>Using the CAPTCHA helper</h3>
-
+
<p>Once loaded you can generate a captcha like this:</p>
<code>$vals = array(<br />
@@ -120,14 +120,14 @@ echo $cap['image'];</code>
</ul>
<h3>Adding a Database</h3>
-
+
<p>In order for the captcha function to prevent someone from submitting, you will need
to add the information returned from <kbd>create_captcha()</kbd> function to your database.
Then, when the data from the form is submitted by the user you will need to verify
that the data exists in the database and has not expired.</p>
-
+
<p>Here is a table prototype:</p>
-
+
<code>CREATE TABLE captcha (<br />
&nbsp;captcha_id bigint(13) unsigned NOT NULL auto_increment,<br />
&nbsp;captcha_time int(10) unsigned NOT NULL,<br />
@@ -135,10 +135,10 @@ echo $cap['image'];</code>
&nbsp;word varchar(20) NOT NULL,<br />
&nbsp;PRIMARY KEY `captcha_id` (`captcha_id`),<br />
&nbsp;KEY `word` (`word`)<br />
-)</code>
+);</code>
<p>Here is an example of usage with a database. On the page where the CAPTCHA will be shown you'll have something like this:</p>
-
+
<code>$this-&gt;load-&gt;helper(&#x27;captcha&#x27;);<br />
$vals = array(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&#x27;img_path&#x27; =&gt; &#x27;./captcha/&#x27;,<br />
@@ -161,10 +161,10 @@ echo $cap[&#x27;image&#x27;];<br />
echo &#x27;&lt;input type=&quot;text&quot; name=&quot;captcha&quot; value=&quot;&quot; /&gt;&#x27;;</code>
<p>Then, on the page that accepts the submission you'll have something like this:</p>
-
+
<code>// First, delete old captchas<br />
$expiration = time()-7200; // Two hour limit<br />
-$this-&gt;db-&gt;query(&quot;DELETE FROM captcha WHERE captcha_time &lt; &quot;.$expiration); <br />
+$this-&gt;db-&gt;query(&quot;DELETE FROM captcha WHERE captcha_time &lt; &quot;.$expiration); <br />
<br />
// Then see if a captcha exists:<br />
$sql = &quot;SELECT COUNT(*) AS count FROM captcha WHERE word = ? AND ip_address = ? AND date &gt; ?&quot;;<br />
@@ -176,7 +176,7 @@ if ($row-&gt;count == 0)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;You must submit the word that appears in the image&quot;;<br />
}</code>
-
+
</div>
<!-- END CONTENT -->
@@ -192,4 +192,4 @@ Previous Topic:&nbsp;&nbsp;<a href="url_helper.html">URL Helper</a>
</div>
</body>
-</html> \ No newline at end of file
+</html>
diff --git a/user_guide/helpers/compatibility_helper.html b/user_guide/helpers/compatibility_helper.html
index de8c49d0a..9afec6541 100644
--- a/user_guide/helpers/compatibility_helper.html
+++ b/user_guide/helpers/compatibility_helper.html
@@ -68,7 +68,7 @@ Compatibility Helper
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>
diff --git a/user_guide/helpers/date_helper.html b/user_guide/helpers/date_helper.html
index 2d908705e..f8775b146 100644
--- a/user_guide/helpers/date_helper.html
+++ b/user_guide/helpers/date_helper.html
@@ -116,7 +116,7 @@ echo standard_date($format, $time);
<th>Description</th>
<th>Example</th>
</tr>
- <tr>
+ <tr>
<td>DATE_ATOM</td>
<td>Atom</td>
<td>2005-08-15T16:13:03+0000</td>
@@ -149,7 +149,7 @@ echo standard_date($format, $time);
<tr>
<td>DATE_RFC1123</td>
<td>RFC 1123</td>
- <td>Sun, 14 Aug 2005 16:13:03 UTC</td>
+ <td>Sun, 14 Aug 2005 16:13:03 UTC</td>
</tr>
<tr>
<td>DATE_RFC2822</td>
diff --git a/user_guide/helpers/directory_helper.html b/user_guide/helpers/directory_helper.html
index 2324252dd..6e4faef02 100644
--- a/user_guide/helpers/directory_helper.html
+++ b/user_guide/helpers/directory_helper.html
@@ -83,7 +83,7 @@ you can do so using the second parameter (integer). A depth of 1 will only map t
<code>$map = directory_map('./mydirectory/', 1);</code>
-<p>By default, hidden files will not be included in the returned array. To override this behavior,
+<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>
diff --git a/user_guide/helpers/form_helper.html b/user_guide/helpers/form_helper.html
index 03a60685b..0aaa8f60f 100644
--- a/user_guide/helpers/form_helper.html
+++ b/user_guide/helpers/form_helper.html
@@ -258,11 +258,11 @@ echo form_fieldset_close();
<br />
<br />
// Produces<br />
-&lt;fieldset&gt;
+&lt;fieldset&gt;
<br />
-&lt;legend&gt;Address Information&lt;/legend&gt;
+&lt;legend&gt;Address Information&lt;/legend&gt;
<br />
-&lt;p&gt;form content here&lt;/p&gt;
+&lt;p&gt;form content here&lt;/p&gt;
<br />
&lt;/fieldset&gt;</code>
<p>Similar to other functions, you can submit an associative array in the second parameter if you prefer to set additional attributes. </p>
diff --git a/user_guide/helpers/html_helper.html b/user_guide/helpers/html_helper.html
index 50a1c48a4..845ecf109 100644
--- a/user_guide/helpers/html_helper.html
+++ b/user_guide/helpers/html_helper.html
@@ -118,7 +118,7 @@ echo link_tag('css/mystyles.css');<br />
<code>
echo link_tag('favicon.ico', 'shortcut icon', 'image/ico');<br />
- // &lt;link href=&quot;http://site.com/favicon.ico&quot; rel=&quot;shortcut icon&quot; type=&quot;image/ico&quot; /&gt;
+ // &lt;link href=&quot;http://site.com/favicon.ico&quot; rel=&quot;shortcut icon&quot; type=&quot;image/ico&quot; /&gt;
<br />
<br />
echo link_tag('feed', 'alternate', 'application/rss+xml', 'My RSS Feed');<br />
@@ -134,7 +134,7 @@ echo link_tag('css/mystyles.css');<br />
<br />
echo link_tag($link);<br />
// &lt;link href=&quot;http://site.com/css/printer.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;print&quot; /&gt;</code></p>
-
+
<h2><a name="nbs"></a>nbs()</h2>
<p>Generates non-breaking spaces (&amp;nbsp;) based on the number you submit. Example:</p>
<code>echo nbs(3);</code>
diff --git a/user_guide/helpers/smiley_helper.html b/user_guide/helpers/smiley_helper.html
index 661330aab..d95562d94 100644
--- a/user_guide/helpers/smiley_helper.html
+++ b/user_guide/helpers/smiley_helper.html
@@ -91,7 +91,7 @@ a publicly accessible place on your server. This helper also assumes you have t
<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
+<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>
@@ -105,21 +105,21 @@ class Smileys extends Controller {
{
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);
}
-
+
}
?&gt;
</textarea>
diff --git a/user_guide/helpers/string_helper.html b/user_guide/helpers/string_helper.html
index 2b12c2a2a..d3f97fb52 100644
--- a/user_guide/helpers/string_helper.html
+++ b/user_guide/helpers/string_helper.html
@@ -145,7 +145,7 @@ The third parameter is FALSE by default; if set to TRUE it will remove occurence
$string=",Fred, Bill,, Joe, Jimmy,";<br />
$string=reduce_multiples($string, ", ", TRUE); //results in "Fred, Bill, Joe, Jimmy"
</code>
-</p>
+</p>
<h2>quotes_to_entities()</h2>
<p>Converts single and double quotes in a string to the corresponding HTML entities. Example:</p>
diff --git a/user_guide/helpers/text_helper.html b/user_guide/helpers/text_helper.html
index 438eaec45..6a68180b6 100644
--- a/user_guide/helpers/text_helper.html
+++ b/user_guide/helpers/text_helper.html
@@ -120,7 +120,7 @@ part it should correctly identify characters outside the normal range (like acce
<p>Transliterates high ASCII characters to low ASCII equivalents, useful when non-English characters need to be used where only standard ASCII characters are safely used, for instance, in URLs.</p>
<code>$string = convert_accented_characters($string);</code>
-
+
<p>This function uses a companion config file <dfn>application/config/foreign_chars.php</dfn> to define the to and from array for transliteration.</p>
<h2>word_censor()</h2>