Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 9
CRAP
0.00% covered (danger)
0.00%
0 / 36
TLink
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 9
182
0.00% covered (danger)
0.00%
0 / 36
 __construct
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 9
 show
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 4
 setOnClick
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getOnClick
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 setUrl
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getUrl
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 setTarget
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 getTarget
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 3
 getValue
0.00% covered (danger)
0.00%
0 / 1
20
0.00% covered (danger)
0.00%
0 / 12
1<?php
2/*
3 * Formdin Framework
4 * Copyright (C) 2012 Ministério do Planejamento
5 * Criado por Luís Eugênio Barbosa
6 * Essa versão é um Fork https://github.com/bjverde/formDin
7 *
8 * ----------------------------------------------------------------------------
9 * This file is part of Formdin Framework.
10 *
11 * Formdin Framework is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public License version 3
13 * as published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License version 3
21 * along with this program; if not,  see <http://www.gnu.org/licenses/>
22 * or write to the Free Software Foundation, Inc., 51 Franklin Street,
23 * Fifth Floor, Boston, MA  02110-1301, USA.
24 * ----------------------------------------------------------------------------
25 * Este arquivo é parte do Framework Formdin.
26 *
27 * O Framework Formdin é um software livre; você pode redistribuí-lo e/ou
28 * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
29 * do Software Livre (FSF).
30 *
31 * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
32 * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
33 * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
34 * para maiores detalhes.
35 *
36 * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
37 * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
38 * ou escreva para a Fundação do Software Livre (FSF) Inc.,
39 * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
40 */
41
42//------------------------------------------------------------------------------
43class TLink extends TControl
44{
45    private $onClick = null;
46    private $url     = null;
47    private $target     = null;
48    public function __construct($strName,$strValue=null,$strOnClick=null,$strUrl=null,$strTarget=null,$strHint=null)
49    {
50        parent::__construct('div',$strName,$strValue);
51        parent::setFieldType('link');
52        parent::setValue($strValue);
53        parent::setClass('fwLink');
54        $this->setOnClick($strOnClick);
55        $this->seturl($strUrl);
56        $this->setTarget($strTarget);
57        $this->setHint($strHint);
58
59    }
60    //--------------------------------------------------------------------
61    public function show($print=true)
62    {
63        $this->clearChildren();
64        $this->add($this->getValue());
65        $this->setValue(null);
66        return parent::show($print);
67    }
68    //---------------------------------------------------------------------
69    public function setOnClick($strFunctionJs=null)
70    {
71        $this->onClick = $strFunctionJs;
72    }
73    //---------------------------------------------------------------------
74    public function getOnClick()
75    {
76        return $this->onClick;
77    }
78    //---------------------------------------------------------------------
79    public function setUrl($strUrl=null)
80    {
81        $this->url = $strUrl;
82    }
83    //---------------------------------------------------------------------
84    public function getUrl()
85    {
86        return $this->url;
87    }
88    //---------------------------------------------------------------------
89    public function setTarget($strTarget=null)
90    {
91        $this->target = $strTarget;
92    }
93    //---------------------------------------------------------------------
94    public function getTarget()
95    {
96        if(is_null($this->target))
97        {
98            return '_blank';
99        }
100        return $this->target;
101    }
102    //----------------------------------------------------------------------
103    public function getValue()
104    {
105        $e = new TElement('a');
106        $e->add($this->value);
107        if( $this->getEnabled() )
108        {
109            if($this->getOnClick())
110            {
111                $e->addEvent('onclick',$this->getOnClick());
112                $e->setProperty('href','javascript:void(0);');
113                return $e->show(false);
114            }
115            else if( $this->getUrl() )
116            {
117                $e->setProperty('href',$this->getUrl());
118                $e->setProperty('target',$this->getTarget());
119                return $e->show(false);
120            }
121        }
122        return $this->value;
123    }
124}
125?>