source: branches/1.2/workflow/inc/smarty/wf_plugins/prefilter.wf_default_template.php @ 1349

Revision 1349, 1.4 KB checked in by niltonneto, 15 years ago (diff)

Ticket #561 - Inclusão do módulo Workflow faltante nessa versão.

Line 
1<?php
2/**
3* This plugin get the current template and adds a header and footer located in "$localPath".
4* @package Smarty
5* @subpackage wf_plugins
6* @version:             1.0     
7* @author               Everton Flávio Rufino Seára - rufino@celepar.pr.gov.br
8* @author               Sidnei Augusto Drovetto Jr. - drovetto@gmail.com
9* @param string $tpl Template de entrada
10* @param object &$smarty Instância do objeto smarty em uso
11* @return string tpl Template with header and footer
12* @access public
13*/
14function smarty_prefilter_wf_default_template($tpl, &$smarty) {
15
16
17        // Get the default smarty delimiter comment
18        $dl = $smarty->left_delimiter;
19        $dr = $smarty->right_delimiter;
20
21        // This first regex just remove the template's comments
22        $pattern = "/{$dl}\*[\s\S]*?\*{$dr}/";
23        // This second one search by the smarty plugin {wf_default_template}
24        $pattern2 = "/{$dl}\s*wf_default_template\s*{$dr}/";
25
26        // Remove the comments
27        $subject = preg_replace($pattern, "", $tpl);
28
29        // Search by the plugin and adds the header and footer if it was found
30        if (preg_match($pattern2, $subject) > 0)
31        {
32                /* get the header and footer location */
33                $templateServer = &$GLOBALS['workflow']['factory']->getInstance('TemplateServer');
34                $header = $templateServer->getSystemFile('processes/header.tpl');
35                $footer = $templateServer->getSystemFile('processes/footer.tpl');
36                $tpl = "{include file='{$header}'}" . $tpl . "{include file='{$footer}'}";
37        }
38
39        return $tpl;
40
41}
42?>
Note: See TracBrowser for help on using the repository browser.