Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
3 lars 1
<?php
2
    /*
3
    * Smarty plugin
4
    * -------------------------------------------------------------
5
    * File:     function.lorem.php
6
    * Type:     function
7
    * Name:     lorem
8
    * Author:   Monte Ohrt
9
    * Date:     Jan 16th, 2010
10
    * Purpose:  outputs lorem ipsum text
11
    * -------------------------------------------------------------
12
    */
13
    function smarty_function_lorem( $params, &$smarty )
14
    {
15
        $length = isset( $params['length'] ) ? ( int )$params['length'] :
16
            446;
17
        $p_tags = isset( $params['p_tags'] ) ? ( bool )$params['p_tags'] : true;
18
 
19
        $repeat = $length <= 446 ? 1 : ceil( ($length / 446) );
20
 
21
        $lorem_text =
22
            "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n";
23
 
24
        $lorem_text = substr( str_repeat($lorem_text, $repeat), 0, $length );
25
 
26
        if ( $p_tags )
27
        {
28
            $lorem_text = preg_replace( array('!^!', '!\n!', '!$!'), array('<p>',
29
                "</p>\n<p>", "</p>\n"), $lorem_text );
30
        }
31
 
32
        return $lorem_text;
33
 
34
    }
35
?>