From 53b8ef524529e6ca9f32ad49d36c5140df84feb0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 8 Nov 2012 21:38:53 +0200 Subject: 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 --- user_guide_src/source/helpers/html_helper.rst | 296 +++++++++++++++----------- 1 file changed, 168 insertions(+), 128 deletions(-) (limited to 'user_guide_src/source/helpers/html_helper.rst') 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 (
) based on the number you submit. Example:: @@ -29,7 +34,14 @@ The above would produce:


heading() ========= -Lets you create HTML

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:

Welcome!

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:

Welcome!<

img() ===== -Lets you create HTML 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 tags. The first parameter contains the +image source. Example:: echo img('images/picture.jpg'); // gives 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 -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); // Me, demonstrating how to eat 4 slices of pizza at one time + img($image_properties); + // Me, demonstrating how to eat 4 slices of pizza at one time link_tag() -=========== +========== -Lets you create HTML 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 +Lets you create HTML 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 -:: - echo link_tag('favicon.ico', 'shortcut icon', 'image/ico'); // +Further examples:: - echo link_tag('feed', 'alternate', 'application/rss+xml', 'My RSS Feed'); // + echo link_tag('favicon.ico', 'shortcut icon', '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'); + // -:: +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); // - + echo link_tag($link); + // nbs() ===== -Generates non-breaking spaces ( ) 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 ( ) based on the number you submit. +Example:: -The above would produce + echo nbs(3); -:: +The above would produce::     -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:: -    -
  • red
  •    -
  • blue
  •    -
  • green
  •    + +
  • red
  • +
  • blue
  • +
  • green
  • yellow
  • -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 - -:: - -    -
  • colors      -
             -
    • red
    •        -
    • blue
    •        -
    • green
    •      -
       -
  •    -
  • shapes      -
             -
    • round
    •        -
    • suare
    •        -
    • circles          -
                   -
      • elipse
      •            -
      • oval
      •            -
      • sphere
      •          -
             -
    •      -
       -
  •    -
  • moods      -
             -
    • happy
    •        -
    • upset          -
                   -
      • defeated              -
                         +The above code will produce this:: + + +
        • colors +
            +
          • red
          • +
          • blue
          • +
          • green
          • +
          +
        • +
        • shapes +
            +
          • round
          • +
          • suare
          • +
          • circles +
              +
            • elipse
            • +
            • oval
            • +
            • sphere
            • +
            +
          • +
          +
        • +
        • moods +
            +
          • happy
          • +
          • upset +
              +
            • defeated +
              • dejected
              • disheartened
              • depressed
            • annoyed
            • -
            • cross
            •            -
            • angry
            •          -
                   -
          •      -
             +
        • cross
        • +
        • angry
        • +
        +
      • +
    +.. 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
      tag for +ordered lists instead of
        . + 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: @@ -279,7 +315,7 @@ simple arrays, or multidimensional ones. Examples echo meta(array('name' => 'robots', 'content' => 'no-cache')); // Generates: - $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(); // -- cgit v1.2.3-24-g4f1b