source: branches/1.2/workflow/inc/smarty/wf_plugins/function.wf_make_link.php @ 1349

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

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

  • Property svn:executable set to *
Line 
1<?php
2/**
3 * Plugin para gerar link de retorno ou link genérico.
4 * @package Smarty
5 * @subpackage wf_plugins
6 * @author Mauricio Luiz Viani
7 * @param array $params Array de parâmetros
8 * - tab: (opcional) número da aba da interface do usuário. Default = 1. Ignorado se for informado o parâmetro url
9 * - text: (opcional) texto sobre o qual será feito o link. Default = 'Voltar'
10 * - url: (opcional) url completa para gerar o link. Se não informado irá gerar um link par a interface do usuário.
11 * - img: (opcional) nome de um arquivo de imagem (com extensão) sobre o qual será montado o link. Se informado, inibe o uso de parâmetro text.
12 * @param object &$smarty Instância do objeto smarty em uso
13 * @return string código com o link
14 * @access public
15 */
16function smarty_function_wf_make_link($params, &$smarty)
17{               
18        $defaultValues = array(
19                'tab' => '1',
20                'text' => 'Voltar',
21                'url' => '',
22                'img' => '');
23        $extractParams = array(
24                'tab',
25                'text',
26                'url',
27                'img');
28               
29        /* verifica se todos os parâmetros obrigatórios foram passados */
30        foreach ($defaultValues as $key => $value)
31                if (!isset($params[$key]))
32                        $params[$key] = $value;
33                       
34        /* atribui valores default para os parâmetros não passados */
35        foreach ($extractParams as $extract)
36                $$extract = $params[$extract];
37               
38        if ($img) {
39                $text = "<img src='" . $smarty->get_template_vars('wf_resources_path') . "/" . $img . "' border='0'>";
40        }
41
42        if ($url) {
43                $back_url = $url;
44        } else {
45                $back_url = '';
46                $back_url = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/workflow/index.php?start_tab=' . $tab;
47        }
48       
49        $output = '<a href="' . $back_url . '">'. $text . '</a>';
50        return $output;
51}
52?>
Note: See TracBrowser for help on using the repository browser.