summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-11-08 20:38:53 +0100
committerAndrey Andreev <narf@bofh.bg>2012-11-08 20:38:53 +0100
commit53b8ef524529e6ca9f32ad49d36c5140df84feb0 (patch)
tree383e10c617709699ca9e275797e405afad458816
parentf6d9a7cff222f868312a6d4ae4e4050616acb9a7 (diff)
Polish docs for HTML, Inflector, Language, Number, Path, Security and Smiley helpers
Also fixed a DB_cache bug introduced in previous commit and removed an unused parameter in a smiley helper
-rw-r--r--system/database/DB_cache.php2
-rw-r--r--system/helpers/html_helper.php6
-rw-r--r--system/helpers/inflector_helper.php21
-rw-r--r--system/helpers/smiley_helper.php5
-rw-r--r--user_guide_src/source/helpers/html_helper.rst296
-rw-r--r--user_guide_src/source/helpers/inflector_helper.rst82
-rw-r--r--user_guide_src/source/helpers/language_helper.rst25
-rw-r--r--user_guide_src/source/helpers/number_helper.rst32
-rw-r--r--user_guide_src/source/helpers/path_helper.rst31
-rw-r--r--user_guide_src/source/helpers/security_helper.rst70
-rw-r--r--user_guide_src/source/helpers/smiley_helper.rst70
11 files changed, 368 insertions, 272 deletions
diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php
index b8f8995fa..1be80c5c7 100644
--- a/system/database/DB_cache.php
+++ b/system/database/DB_cache.php
@@ -199,7 +199,7 @@ class CI_DB_Cache {
*/
public function delete_all()
{
- delete_files($this->db->cachedir, TRUE, 0, TRUE);
+ delete_files($this->db->cachedir, TRUE, TRUE);
}
}
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index 404392f06..fa49f7d75 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -157,12 +157,12 @@ if ( ! function_exists('br'))
/**
* Generates HTML BR tags based on number supplied
*
- * @param int
+ * @param int $count Number of times to repeat the tag
* @return string
*/
- function br($num = 1)
+ function br($count = 1)
{
- return str_repeat('<br />', $num);
+ return str_repeat('<br />', $count);
}
}
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index 6f1086a00..59cb296b2 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -45,7 +45,7 @@ if ( ! function_exists('singular'))
*
* Takes a plural word and makes it singular
*
- * @param string
+ * @param string $str Input string
* @return string
*/
function singular($str)
@@ -109,11 +109,10 @@ if ( ! function_exists('plural'))
*
* Takes a singular word and makes it plural
*
- * @param string
- * @param bool
+ * @param string $str Input string
* @return string
*/
- function plural($str, $force = FALSE)
+ function plural($str)
{
$result = strval($str);
@@ -166,7 +165,7 @@ if ( ! function_exists('camelize'))
*
* Takes multiple words separated by spaces or underscores and camelizes them
*
- * @param string
+ * @param string $str Input string
* @return string
*/
function camelize($str)
@@ -184,7 +183,7 @@ if ( ! function_exists('underscore'))
*
* Takes multiple words separated by spaces and underscores them
*
- * @param string
+ * @param string $str Input string
* @return string
*/
function underscore($str)
@@ -202,8 +201,8 @@ if ( ! function_exists('humanize'))
*
* Takes multiple words separated by the separator and changes them to spaces
*
- * @param string $str
- * @param string $separator
+ * @param string $str Input string
+ * @param string $separator Input separator
* @return string
*/
function humanize($str, $separator = '_')
@@ -219,12 +218,12 @@ if ( ! function_exists('is_countable'))
/**
* Checks if the given word has a plural version.
*
- * @param string the word to check
- * @return bool if the word is countable
+ * @param string $word Word to check
+ * @return bool
*/
function is_countable($word)
{
- return ! in_array(strtolower(strval($word)),
+ return ! in_array(strtolower($word),
array(
'equipment', 'information', 'rice', 'money',
'species', 'series', 'fish', 'meta'
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index 6ae8937ee..4b491758e 100644
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -131,10 +131,9 @@ if ( ! function_exists('get_clickable_smileys'))
*
* @param string the URL to the folder containing the smiley images
* @param array
- * @param array
* @return array
*/
- function get_clickable_smileys($image_url, $alias = '', $smileys = NULL)
+ function get_clickable_smileys($image_url, $alias = '')
{
// For backward compatibility with js_insert_smiley
if (is_array($alias))
@@ -143,7 +142,7 @@ if ( ! function_exists('get_clickable_smileys'))
}
elseif (FALSE === ($smileys = _get_smiley_array()))
{
- return $smileys;
+ return FALSE;
}
// Add a trailing slash to the file path if needed
diff --git a/user_guide_src/source/helpers/html_helper.rst b/user_guide_src/source/helpers/html_helper.rst
index 17c28cd2a..df53ebd2f 100644
--- a/user_guide_src/source/helpers/html_helper.rst
+++ b/user_guide_src/source/helpers/html_helper.rst
@@ -19,6 +19,11 @@ The following functions are available:
br()
====
+.. php:function:: br($count = 1)
+
+ :param int $count: Number of times to repeat the tag
+ :returns: string
+
Generates line break tags (<br />) based on the number you submit.
Example::
@@ -29,7 +34,14 @@ The above would produce: <br /><br /><br />
heading()
=========
-Lets you create HTML <h1> tags. The first parameter will contain the
+.. php:function:: heading($data = '', $h = '1', $attributes = '')
+
+ :param string $data: Content
+ :param string $h: Heading level
+ :param array $attributes: HTML attributes
+ :returns: string
+
+Lets you create HTML heading tags. The first parameter will contain the
data, the second the size of the heading. Example::
echo heading('Welcome!', 3);
@@ -37,9 +49,7 @@ data, the second the size of the heading. Example::
The above would produce: <h3>Welcome!</h3>
Additionally, in order to add attributes to the heading tag such as HTML
-classes, ids or inline styles, a third parameter is available.
-
-::
+classes, ids or inline styles, a third parameter is available::
echo heading('Welcome!', 3, 'class="pink"')
@@ -48,28 +58,31 @@ The above code produces: <h3 class="pink">Welcome!<<h3>
img()
=====
-Lets you create HTML <img /> tags. The first parameter contains the
-image source. Example
+.. php:function:: img($src = '', $index_page = FALSE, $attributes = '')
-::
+ :param string $src: Image source data
+ :param bool $index_page: Whether to treat $src as a routed URI string
+ :param array $attributes: HTML attributes
+ :returns: string
+
+Lets you create HTML <img /> tags. The first parameter contains the
+image source. Example::
echo img('images/picture.jpg'); // gives <img src="http://site.com/images/picture.jpg" />
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.
-
-::
+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::
echo img('images/picture.jpg', TRUE); // gives <img src="http://site.com/index.php/images/picture.jpg" alt="" />
-Additionally, an associative array can be passed to the img() function
-for complete control over all attributes and values. If an alt attribute
+Additionally, an associative array can be passed to the ``img()`` function
+for complete control over all attributes and values. If an *alt* attribute
is not provided, CodeIgniter will generate an empty string.
-::
+Example::
$image_properties = array(           
'src' => 'images/picture.jpg',           
@@ -81,128 +94,136 @@ is not provided, CodeIgniter will generate an empty string.
'rel' => 'lightbox'
);
- img($image_properties); // <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" />
+ img($image_properties);
+ // <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" />
link_tag()
-===========
+==========
-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.
+.. php:function:: ling_tag($href = '', $rel = 'stylesheet', $type = 'text/css', $title = '', $media = '', $index_page = FALSE)
-::
+ :param string $href: What are we linking to
+ :param string $rel: Relation type
+ :param string $type: Type of the related document
+ :param string $title: Link title
+ :param string $media: Media type
+ :param bool $index_page: Whether to treat $src as a routed URI string
+ :returns: string
- echo link_tag('css/mystyles.css'); // gives <link href="http://site.com/css/mystyles.css" rel="stylesheet" type="text/css" />
+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 boolean value that specifies if the *href* should have
+the page specified by ``$config['index_page']`` added to the address it creates.
+Example::
-Further examples
+ echo link_tag('css/mystyles.css');
+ // gives <link href="http://site.com/css/mystyles.css" rel="stylesheet" type="text/css" />
-::
- echo link_tag('favicon.ico', 'shortcut icon', 'image/ico'); // <link href="http://site.com/favicon.ico" rel="shortcut icon" type="image/ico" />
+Further examples::
- echo link_tag('feed', 'alternate', 'application/rss+xml', 'My RSS Feed'); // <link href="http://site.com/feed" rel="alternate" type="application/rss+xml" title="My RSS Feed" />
+ echo link_tag('favicon.ico', 'shortcut icon', 'image/ico');
+ // <link href="http://site.com/favicon.ico" rel="shortcut icon" type="image/ico" />
-Additionally, an associative array can be passed to the link() function
-for complete control over all attributes and values.
+ echo link_tag('feed', 'alternate', 'application/rss+xml', 'My RSS Feed');
+ // <link href="http://site.com/feed" rel="alternate" type="application/rss+xml" title="My RSS Feed" />
-::
+Additionally, an associative array can be passed to the ``link()`` function
+for complete control over all attributes and values::
$link = array(           
- 'href' => 'css/printer.css',           
- 'rel' => 'stylesheet',           
- 'type' => 'text/css',           
- 'media' => 'print'
+ 'href' => 'css/printer.css',
+ 'rel' => 'stylesheet',
+ 'type' => 'text/css',
+ 'media' => 'print'
);
- echo link_tag($link); // <link href="http://site.com/css/printer.css" rel="stylesheet" type="text/css" media="print" />
-
+ echo link_tag($link);
+ // <link href="http://site.com/css/printer.css" rel="stylesheet" type="text/css" media="print" />
nbs()
=====
-Generates non-breaking spaces (&nbsp;) based on the number you submit.
-Example
+.. php:function:: nbs($num = 1)
-::
+ :param int $num: Number of space entities to produce
+ :returns: string
- echo nbs(3);
+Generates non-breaking spaces (&nbsp;) based on the number you submit.
+Example::
-The above would produce
+ echo nbs(3);
-::
+The above would produce::
&nbsp;&nbsp;&nbsp;
-ol() and ul()
+ul() and ol()
=============
-Permits you to generate ordered or unordered HTML lists from simple or
-multi-dimensional arrays. Example
+.. php:function:: ul($list, $attributes = '')
-::
+ :param array $list: List entries
+ :param array $attributes: HTML attributes
+ :returns: string
- $this->load->helper('html');
+Permits you to generate ordered or unordered HTML lists from simple or
+multi-dimensional arrays. Example::
- $list = array(             
- 'red',             
- 'blue',             
- 'green',             
- 'yellow'             
+ $list = array(
+ 'red',
+ 'blue',
+ 'green',
+ 'yellow'
);
- $attributes = array(                     
- 'class' => 'boldlist',                     
- 'id'    => 'mylist'                    
+ $attributes = array(
+ 'class' => 'boldlist',
+ 'id' => 'mylist'
);
echo ul($list, $attributes);
-The above code will produce this
-
-::
+The above code will produce this::
- <ul class="boldlist" id="mylist">   
- <li>red</li>   
- <li>blue</li>   
- <li>green</li>   
+ <ul class="boldlist" id="mylist">
+ <li>red</li>
+ <li>blue</li>
+ <li>green</li>
<li>yellow</li>
</ul>
-Here is a more complex example, using a multi-dimensional array
-
-::
-
- $this->load->helper('html');
+Here is a more complex example, using a multi-dimensional array::
- $attributes = array(                     
- 'class' => 'boldlist',                     
- 'id'    => 'mylist'                     
+ $attributes = array(
+ 'class' => 'boldlist',
+ 'id' => 'mylist'
);
- $list = array(             
- 'colors' => array(                                 
- 'red',                                 
- 'blue',                                 
- 'green'                             
+ $list = array(
+ 'colors' => array(
+ 'red',
+ 'blue',
+ 'green'
),
- 'shapes' => array(                                 
- 'round',                                 
- 'square',                                 
- 'circles' => array(                                             
+ 'shapes' => array(
+ 'round',
+ 'square',
+ 'circles' => array(
'ellipse',
'oval',
'sphere'
- )                             
- ),             
- 'moods' => array(                                 
- 'happy',                                 
- 'upset' => array(                                         
+ )
+ ),
+ 'moods' => array(
+ 'happy',
+ 'upset' => array(
'defeated' => array(
- 'dejected',                
+ 'dejected',
'disheartened',
'depressed'
),
@@ -215,59 +236,74 @@ Here is a more complex example, using a multi-dimensional array
echo ul($list, $attributes);
-The above code will produce this
-
-::
-
- <ul class="boldlist" id="mylist">   
- <li>colors     
- <ul>       
- <li>red</li>       
- <li>blue</li>       
- <li>green</li>     
- </ul>   
- </li>   
- <li>shapes     
- <ul>       
- <li>round</li>       
- <li>suare</li>       
- <li>circles         
- <ul>           
- <li>elipse</li>           
- <li>oval</li>           
- <li>sphere</li>         
- </ul>       
- </li>     
- </ul>   
- </li>   
- <li>moods     
- <ul>       
- <li>happy</li>       
- <li>upset         
- <ul>           
- <li>defeated             
- <ul>               
+The above code will produce this::
+
+ <ul class="boldlist" id="mylist">
+ <li>colors
+ <ul>
+ <li>red</li>
+ <li>blue</li>
+ <li>green</li>
+ </ul>
+ </li>
+ <li>shapes
+ <ul>
+ <li>round</li>
+ <li>suare</li>
+ <li>circles
+ <ul>
+ <li>elipse</li>
+ <li>oval</li>
+ <li>sphere</li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li>moods
+ <ul>
+ <li>happy</li>
+ <li>upset
+ <ul>
+ <li>defeated
+ <ul>
<li>dejected</li>
<li>disheartened</li>
<li>depressed</li>
</ul>
</li>
<li>annoyed</li>
- <li>cross</li>           
- <li>angry</li>         
- </ul>       
- </li>     
- </ul>   
+ <li>cross</li>
+ <li>angry</li>
+ </ul>
+ </li>
+ </ul>
</li>
</ul>
+.. php:function:: ol($list, $attributes = '')
+
+ :param array $list: List entries
+ :param array $attributes: HTML attributes
+ :returns: string
+
+Identical to :php:func:`ul()`, only it produces the <ol> tag for
+ordered lists instead of <ul>.
+
meta()
======
+.. php:function:: meta($name = '', $content = '', $type = 'name', $newline = "\n")
+
+ :param string $name: Meta name
+ :param string $content: Meta content
+ :param string $type: Meta type
+ :param string $newline: Newline character
+ :returns: string
+
Helps you generate meta tags. You can pass strings to the function, or
-simple arrays, or multidimensional ones. Examples
+simple arrays, or multidimensional ones.
-::
+Examples::
echo meta('description', 'My Great site');
// Generates: <meta name="description" content="My Great Site" />
@@ -279,7 +315,7 @@ simple arrays, or multidimensional ones. Examples
echo meta(array('name' => 'robots', 'content' => 'no-cache'));
// Generates: <meta name="robots" content="no-cache" />
- $meta = array(         
+ $meta = array(
array(
'name' => 'robots',
'content' => 'no-cache'
@@ -291,7 +327,7 @@ simple arrays, or multidimensional ones. Examples
array(
'name' => 'keywords',
'content' => 'love, passion, intrigue, deception'
- ),         
+ ),
array(
'name' => 'robots',
'content' => 'no-cache'
@@ -313,10 +349,14 @@ simple arrays, or multidimensional ones. Examples
doctype()
=========
+.. php:function:: doctype($type = 'xhtml1-strict')
+
+ :param string $type: Doctype name
+
Helps you generate document type declarations, or DTD's. XHTML 1.0
Strict is used by default, but many doctypes are available.
-::
+Example::
echo doctype(); // <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
diff --git a/user_guide_src/source/helpers/inflector_helper.rst b/user_guide_src/source/helpers/inflector_helper.rst
index cc46a1851..1f54b76c0 100644
--- a/user_guide_src/source/helpers/inflector_helper.rst
+++ b/user_guide_src/source/helpers/inflector_helper.rst
@@ -10,9 +10,7 @@ words to plural, singular, camel case, etc.
Loading this Helper
===================
-This helper is loaded using the following code
-
-::
+This helper is loaded using the following code::
$this->load->helper('inflector');
@@ -21,65 +19,81 @@ The following functions are available:
singular()
==========
-Changes a plural word to singular. Example
+.. php:function:: singular($str)
+
+ :param string $str: Input string
+ :returns: string
-::
+Changes a plural word to singular. Example::
- $word = "dogs";
- echo singular($word); // Returns "dog"
+ echo singular('dogs'); // Prints 'dog'
plural()
========
-Changes a singular word to plural. Example
-
-::
-
- $word = "dog";
- echo plural($word); // Returns "dogs"
+.. php:function:: plural($str)
-To force a word to end with "es" use a second "true" argument.
+ :param string $str: Input string
+ :returns: string
-::
+Changes a singular word to plural. Example::
- $word = "pass";
- echo plural($word, TRUE); // Returns "passes"
+ echo plural('dog'); // Prints 'dogs'
camelize()
==========
-Changes a string of words separated by spaces or underscores to camel
-case. Example
+.. php:function:: camelize($str)
+
+ :param string $str: Input string
+ :returns: string
-::
+Changes a string of words separated by spaces or underscores to camel
+case. Example::
- $word = "my_dog_spot";
- echo camelize($word); // Returns "myDogSpot"
+ echo camelize('my_dog_spot'); // Prints 'myDogSpot'
underscore()
============
-Takes multiple words separated by spaces and underscores them. Example
+.. php:function:: camelize($str)
-::
+ :param string $str: Input string
+ :returns: string
- $word = "my dog spot";
- echo underscore($word); // Returns "my_dog_spot"
+Takes multiple words separated by spaces and underscores them.
+Example::
+
+ echo underscore('my dog spot'); // Prints 'my_dog_spot'
humanize()
==========
+.. php:function:: camelize($str)
+
+ :param string $str: Input string
+ :param string $separator: Input separator
+ :returns: string
+
Takes multiple words separated by underscores and adds spaces between
-them. Each word is capitalized. Example
+them. Each word is capitalized.
+
+Example::
+
+ echo humanize('my_dog_spot'); // Prints 'My Dog Spot'
+
+To use dashes instead of underscores::
+
+ echo humanize('my-dog-spot', '-'); // Prints 'My Dog Spot'
-::
+is_countable()
+==============
- $word = "my_dog_spot";
- echo humanize($word); // Returns "My Dog Spot"
+.. php:function:: is_countable($word)
-To use dashes instead of underscores
+ :param string $word: Input string
+ :returns: bool
-::
+Checks if the given word has a plural version. Example::
- $word = "my-dog-spot";
- echo humanize($word, '-'); // Returns "My Dog Spot" \ No newline at end of file
+ is_countable('equipment'); // Returns FALSE \ No newline at end of file
diff --git a/user_guide_src/source/helpers/language_helper.rst b/user_guide_src/source/helpers/language_helper.rst
index b7b23d149..8b039374d 100644
--- a/user_guide_src/source/helpers/language_helper.rst
+++ b/user_guide_src/source/helpers/language_helper.rst
@@ -10,24 +10,27 @@ language files.
Loading this Helper
===================
-This helper is loaded using the following code
-
-::
+This helper is loaded using the following code::
$this->load->helper('language');
The following functions are available:
-lang('language line', 'element id')
-===================================
+lang()
+======
+
+.. php:function:: lang($line, $id = '')
+
+ :param string $line: Language line key
+ :param string $id: ID of the element we're creating a label for
+ :returns: string
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
-`$this->lang->line()`. The optional second parameter will also output a
-form label for you. Example
+simplified syntax that may be more desirable for view files than
+``CI_Lang::line()``.
+The optional second parameter will also output a form label for you.
-::
+Example::
echo lang('language_key', 'form_item_id');
- // becomes <label for="form_item_id">language_key</label>
-
+ // becomes <label for="form_item_id">language_key</label> \ No newline at end of file
diff --git a/user_guide_src/source/helpers/number_helper.rst b/user_guide_src/source/helpers/number_helper.rst
index af6cdad57..8e0ebda5e 100644
--- a/user_guide_src/source/helpers/number_helper.rst
+++ b/user_guide_src/source/helpers/number_helper.rst
@@ -10,9 +10,7 @@ numeric data.
Loading this Helper
===================
-This helper is loaded using the following code
-
-::
+This helper is loaded using the following code::
$this->load->helper('number');
@@ -21,25 +19,27 @@ The following functions are available:
byte_format()
=============
-Formats a numbers as bytes, based on size, and adds the appropriate
-suffix. Examples
+.. php:function:: byte_format($num, $precision = 1)
+
+ :param mixed $num: Number of bytes
+ :param int $precision: Floating point precision
+ :returns: string
-::
+Formats numbers as bytes, based on size, and adds the appropriate
+suffix. Examples::
- echo byte_format(456); // Returns 456 Bytes
- echo byte_format(4567); // Returns 4.5 KB
- echo byte_format(45678); // Returns 44.6 KB
- echo byte_format(456789); // Returns 447.8 KB
- echo byte_format(3456789); // Returns 3.3 MB
- echo byte_format(12345678912345); // Returns 1.8 GB
+ echo byte_format(456); // Returns 456 Bytes
+ echo byte_format(4567); // Returns 4.5 KB
+ echo byte_format(45678); // Returns 44.6 KB
+ echo byte_format(456789); // Returns 447.8 KB
+ echo byte_format(3456789); // Returns 3.3 MB
+ echo byte_format(12345678912345); // Returns 1.8 GB
echo byte_format(123456789123456789); // Returns 11,228.3 TB
An optional second parameter allows you to set the precision of the
-result.
-
-::
+result::
echo byte_format(45678, 2); // Returns 44.61 KB
.. note:: The text generated by this function is found in the following
- language file: language/<your_lang>/number_lang.php
+ language file: `language/<your_lang>/number_lang.php` \ No newline at end of file
diff --git a/user_guide_src/source/helpers/path_helper.rst b/user_guide_src/source/helpers/path_helper.rst
index 847f5a08b..3a271b28f 100644
--- a/user_guide_src/source/helpers/path_helper.rst
+++ b/user_guide_src/source/helpers/path_helper.rst
@@ -10,9 +10,7 @@ file paths on the server.
Loading this Helper
===================
-This helper is loaded using the following code
-
-::
+This helper is loaded using the following code::
$this->load->helper('path');
@@ -21,23 +19,28 @@ The following functions are available:
set_realpath()
==============
-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.
+.. php:function:: set_realpath($path, $check_existance = FALSE)
+
+ :param string $path: Path
+ :param bool $check_existance: Whether to check if the path actually exists
+ :returns: string
+
+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.
-::
+Examples::
$file = '/etc/php5/apache2/php.ini';
- echo set_realpath($file); // returns "/etc/php5/apache2/php.ini"
+ echo set_realpath($file); // Prints '/etc/php5/apache2/php.ini'
$non_existent_file = '/path/to/non-exist-file.txt';
- echo set_realpath($non_existent_file, TRUE); // shows an error, as the path cannot be resolved
- echo set_realpath($non_existent_file, FALSE); // returns "/path/to/non-exist-file.txt"
+ echo set_realpath($non_existent_file, TRUE); // Shows an error, as the path cannot be resolved
+ echo set_realpath($non_existent_file, FALSE); // Prints '/path/to/non-exist-file.txt'
$directory = '/etc/php5';
- echo set_realpath($directory); // returns "/etc/php5/"
+ echo set_realpath($directory); // Prints '/etc/php5/'
$non_existent_directory = '/path/to/nowhere';
- echo set_realpath($non_existent_directory, TRUE); // shows an error, as the path cannot be resolved
- echo set_realpath($non_existent_directory, FALSE); // returns "/path/to/nowhere"
+ echo set_realpath($non_existent_directory, TRUE); // Shows an error, as the path cannot be resolved
+ echo set_realpath($non_existent_directory, FALSE); // Prints '/path/to/nowhere' \ No newline at end of file
diff --git a/user_guide_src/source/helpers/security_helper.rst b/user_guide_src/source/helpers/security_helper.rst
index ec0be28b3..21bf53490 100644
--- a/user_guide_src/source/helpers/security_helper.rst
+++ b/user_guide_src/source/helpers/security_helper.rst
@@ -9,9 +9,7 @@ The Security Helper file contains security related functions.
Loading this Helper
===================
-This helper is loaded using the following code
-
-::
+This helper is loaded using the following code::
$this->load->helper('security');
@@ -20,25 +18,47 @@ The following functions are available:
xss_clean()
===========
-Provides Cross Site Script Hack filtering. This function is an alias to
-the one in the :doc:`Input class <../libraries/input>`. More info can
-be found there.
+.. php:function:: xss_clean($str, $is_image = FALSE)
+
+ :param string $str: Input data
+ :param bool $is_image: Whether we're dealing with an image
+ :returns: string
+
+Provides Cross Site Script Hack filtering.
+
+This function is an alias for ``CI_Input::xss_clean()``. For more info,
+please see the :doc:`Input Library <../libraries/input>` documentation.
sanitize_filename()
===================
-Provides protection against directory traversal. This function is an
-alias to the one in the :doc:`Security class <../libraries/security>`.
-More info can be found there.
+.. php:function:: sanitize_filename($filename)
+
+ :param string $filename: Filename
+ :returns: string
+
+Provides protection against directory traversal.
+
+This function is an alias for ``CI_Security::sanitize_filename()``.
+For more info, please see the :doc:`Security Library <../libraries/security>`
+documentation.
do_hash()
=========
+.. php:function:: do_hash($str, $type = 'sha1')
+
+ :param string $str: Input
+ :param string $type: Algorithm
+ :returns: string
+
Permits you to create one way hashes suitable for encrypting
-passwords. Will create SHA1 by default. See `hash_algos() <http://php.net/function.hash_algos>`_
+passwords. Will use SHA1 by default.
+
+See `hash_algos() <http://php.net/function.hash_algos>`_
for a full list of supported algorithms.
-::
+Examples::
$str = do_hash($str); // SHA1
$str = do_hash($str, 'md5'); // MD5
@@ -51,20 +71,34 @@ for a full list of supported algorithms.
strip_image_tags()
==================
-This is a security function that will strip image tags from a string. It
-leaves the image URL as plain text.
+.. php:function:: strip_image_tags($str)
+
+ :param string $str: Input
+ :returns: string
+
+This is a security function that will strip image tags from a string.
+It leaves the image URL as plain text.
-::
+Example::
$string = strip_image_tags($string);
+This function is an alias for ``CI_Security::strip_image_tags()``. For
+more info, please see the :doc:`Security Library <../libraries/security>`
+documentation.
+
encode_php_tags()
=================
-This is a security function that converts PHP tags to entities. Note: If
-you use the XSS filtering function it does this automatically.
+.. php:function:: encode_php_tags($str)
+
+ :param string $str: Input
+ :returns: string
+
+This is a security function that converts PHP tags to entities.
-::
+.. note: :php:func:`xss_clean()` does this automatically, if you use it.
- $string = encode_php_tags($string);
+Example::
+ $string = encode_php_tags($string); \ No newline at end of file
diff --git a/user_guide_src/source/helpers/smiley_helper.rst b/user_guide_src/source/helpers/smiley_helper.rst
index 941ba11e3..13841e8bd 100644
--- a/user_guide_src/source/helpers/smiley_helper.rst
+++ b/user_guide_src/source/helpers/smiley_helper.rst
@@ -10,9 +10,7 @@ The Smiley Helper file contains functions that let you manage smileys
Loading this Helper
===================
-This helper is loaded using the following code
-
-::
+This helper is loaded using the following code::
$this->load->helper('smiley');
@@ -36,10 +34,11 @@ 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.
-.. important:: Before you begin, please `download the smiley images <http://codeigniter.com/download_files/smileys.zip>`_
- and put them in a publicly accessible place on your server. This helper
- also assumes you have the smiley replacement array located at
- `application/config/smileys.php`
+.. important:: Before you begin, please `download the smiley images
+ <http://codeigniter.com/download_files/smileys.zip>`_
+ and put them in a publicly accessible place on your server.
+ This helper also assumes you have the smiley replacement array
+ located at `application/config/smileys.php`
The Controller
--------------
@@ -47,18 +46,17 @@ The Controller
In your `application/controllers/` folder, create a file called
smileys.php and place the code below in it.
-.. important:: Change the URL in the `get_clickable_smileys()`
+.. important:: Change the URL in the :php:func:`get_clickable_smileys()`
function below so that it points to your smiley folder.
-You'll notice that in addition to the smiley helper we are using the :doc:`Table Class <../libraries/table>`.
-
-::
+You'll notice that in addition to the smiley helper, we are also using
+the :doc:`Table Class <../libraries/table>`::
<?php
class Smileys extends CI_Controller {
- function index()
+ public function index()
{
$this->load->helper('smiley');
$this->load->library('table');
@@ -69,12 +67,11 @@ You'll notice that in addition to the smiley helper we are using the :doc:`Table
$data['smiley_table'] = $this->table->generate($col_array);
$this->load->view('smiley_view', $data);
}
+
}
In your `application/views/` folder, create a file called `smiley_view.php`
-and place this code in it:
-
-::
+and place this code in it::
<html>
<head>
@@ -102,59 +99,66 @@ links a generic name that will be tied to a specific id in your view.
$image_array = get_smiley_links("http://example.com/images/smileys/", "comment_textarea_alias");
-To map the alias to the field id, pass them both into the `smiley_js`
-function
-
-::
+To map the alias to the field id, pass them both into the
+:php:func:`smiley_js()` function::
$image_array = smiley_js("comment_textarea_alias", "comments");
-******************
-Function Reference
-******************
-
get_clickable_smileys()
=======================
+.. php:function:: get_clickable_smileys($image_url, $alias = '', $smileys = NULL)
+
+ :param string $image_url: URL path to the smileys directory
+ :param string $alias: Field alias
+ :returns: array
+
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.
-::
+Example::
$image_array = get_smiley_links("http://example.com/images/smileys/", "comment");
-Note: Usage of this function without the second parameter, in
-combination with `js_insert_smiley` has been deprecated.
-
smiley_js()
===========
+.. php:function:: smiley_js($alias = '', $field_id = '', $inline = TRUE)
+
+ :param string $alias: Field alias
+ :param string $field_id: Field ID
+ :param bool $inline: Whether we're inserting an inline smiley
+
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.
-::
+Example::
<?php echo smiley_js(); ?>
-Note: This function replaces `js_insert_smiley`, which has been
-deprecated.
-
parse_smileys()
===============
+.. php:function:: parse_smileys($str = '', $image_url = '', $smileys = NULL)
+
+ :param string $str: Text containing smiley codes
+ :param string $image_url: URL path to the smileys directory
+ :param array $smileys: An array of smileys
+ :returns: string
+
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
-::
+Example::
$str = 'Here are some simileys: :-) ;-)';
$str = parse_smileys($str, "http://example.com/images/smileys/");
echo $str;
-.. |smile!| image:: ../images/smile.gif
+.. |smile!| image:: ../images/smile.gif \ No newline at end of file