Documentación GVHIDRA 3.1.5
Referencia del Archivo outputfilter.trimwhitespace.php

Ir al código fuente de este archivo.

Namespaces

namespace  Smarty

Funciones

 smarty_outputfilter_trimwhitespace ($source, &$smarty)
 smarty_outputfilter_trimwhitespace_replace ($search_str, $replace, &$subject)

Documentación de las funciones

smarty_outputfilter_trimwhitespace ( source,
&$  smarty 
)

Smarty trimwhitespace outputfilter plugin

File: outputfilter.trimwhitespace.php
Type: outputfilter
Name: trimwhitespace
Date: Jan 25, 2003
Purpose: trim leading white space and blank lines from template source after it gets interpreted, cleaning up code and saving bandwidth. Does not affect <

>

and <SCRIPT></SCRIPT> blocks.
Install: Drop into the plugin directory, call $smarty->load_filter('output','trimwhitespace'); from application.

Autor:
Monte Ohrt <monte at="" ohrt="" dot="" com>="">
Contributions from Lars Noschinski <lars@usenet.noschinski.de>
Versión:
1.3
Parámetros:
string
Smarty

Definición en la línea 28 del archivo outputfilter.trimwhitespace.php.

{
    // Pull out the script blocks
    preg_match_all("!<script[^>]+>.*?</script>!is", $source, $match);
    $_script_blocks = $match[0];
    $source = preg_replace("!<script[^>]+>.*?</script>!is",
                           '@@@SMARTY:TRIM:SCRIPT@@@', $source);

    // Pull out the pre blocks
    preg_match_all("!<pre>.*?</pre>!is", $source, $match);
    $_pre_blocks = $match[0];
    $source = preg_replace("!<pre>.*?</pre>!is",
                           '@@@SMARTY:TRIM:PRE@@@', $source);

    // Pull out the textarea blocks
    preg_match_all("!<textarea[^>]+>.*?</textarea>!is", $source, $match);
    $_textarea_blocks = $match[0];
    $source = preg_replace("!<textarea[^>]+>.*?</textarea>!is",
                           '@@@SMARTY:TRIM:TEXTAREA@@@', $source);

    // remove all leading spaces, tabs and carriage returns NOT
    // preceeded by a php close tag.
    $source = trim(preg_replace('/((?<!\?>)\n)[\s]+/m', '\1', $source));

    // replace script blocks
    smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@",$_script_blocks, $source);

    // replace pre blocks
    smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@",$_pre_blocks, $source);

    // replace textarea blocks
    smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@",$_textarea_blocks, $source);

    return $source;
}
smarty_outputfilter_trimwhitespace_replace ( search_str,
replace,
&$  subject 
)

Definición en la línea 64 del archivo outputfilter.trimwhitespace.php.

                                                                                      {
    $_len = strlen($search_str);
    $_pos = 0;
    for ($_i=0, $_count=count($replace); $_i<$_count; $_i++)
        if (($_pos=strpos($subject, $search_str, $_pos))!==false)
            $subject = substr_replace($subject, $replace[$_i], $_pos, $_len);
        else
            break;

}