Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 38 |
CRAP | |
0.00% |
0 / 257 |
| TPageControl | |
0.00% |
0 / 1 |
|
0.00% |
0 / 38 |
12432 | |
0.00% |
0 / 257 |
| __construct | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 7 |
|||
| addPage | |
0.00% |
0 / 1 |
42 | |
0.00% |
0 / 26 |
|||
| disableTab | |
0.00% |
0 / 1 |
30 | |
0.00% |
0 / 8 |
|||
| enableTab | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 4 |
|||
| hideTab | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 4 |
|||
| showTab | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 4 |
|||
| show | |
0.00% |
0 / 1 |
552 | |
0.00% |
0 / 99 |
|||
| setActivePage | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 8 |
|||
| getActivePage | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| setShowTabs | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 5 |
|||
| getShowTabs | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
|||
| getPages | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| getPage | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 6 |
|||
| setOnClick | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| setOnBeforeClick | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| getOnBeforeClick | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| setOnAfterClick | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| getOnAfterClick | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| validate | |
0.00% |
0 / 1 |
90 | |
0.00% |
0 / 13 |
|||
| getField | |
0.00% |
0 / 1 |
30 | |
0.00% |
0 / 7 |
|||
| setFocusField | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| getFocusField | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| disableFields | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 4 |
|||
| clearFields | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 4 |
|||
| getJsCss | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 7 |
|||
| deleteField | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 4 |
|||
| getFieldType | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| setColumns | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| getColumns | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| disableTabs | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 4 |
|||
| setVo | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 4 |
|||
| setWidth | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 5 |
|||
| getWidth | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| setHeight | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 5 |
|||
| getHeight | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| getLabel | |
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 6 |
|||
| setLabelsAlign | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| getLabelsAlign | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| 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 | /** |
| 43 | * Classe para criação de Abas ( pagecontrol ) |
| 44 | * |
| 45 | * Sintaxe para definir a aba ativa utilizando o $_POST |
| 46 | * |
| 47 | * $_POST[ [id do pagecontrol+"_current"]=id do pagecontrol+'_'+nome da aba desejada; |
| 48 | * ex: para definir a aba "Cadastro" do pagecontrol "aba_exemplo" seria: |
| 49 | * $_POST['aba_exemplo_current']='aba_exemplo_cadastro'; |
| 50 | */ |
| 51 | class TPageControl extends TTable |
| 52 | { |
| 53 | private $pages; |
| 54 | private $activePage; |
| 55 | private $showTabs; |
| 56 | private $hiddenField; |
| 57 | private $focusField; |
| 58 | private $onBeforeClick; |
| 59 | private $onAfterClick; |
| 60 | private $adjustFormHeight; |
| 61 | private $columns; |
| 62 | private $labelsAlign; |
| 63 | /** |
| 64 | * classe para criação de tab |
| 65 | * |
| 66 | * Widgh null para ficar com a largura do form |
| 67 | * Se for informado somente o nome da função, sem os parentes, no paramentro onBeforeClick |
| 68 | * a função receberá o rótulo da aba clicada,o nome do pagecontrol e o id da abaClicada. Se a função retorna false |
| 69 | * |
| 70 | * @param string $strName |
| 71 | * @param string $strHeight |
| 72 | * @param string $strWidth |
| 73 | * @param string $boolShowTabs |
| 74 | * @param string $strOnBeforeClick |
| 75 | * @param string $strOnAfterClick |
| 76 | * @return TPageControl |
| 77 | */ |
| 78 | public function __construct($strName,$strHeight=null,$strWidth=null,$boolShowTabs=null,$strOnBeforeClick=null,$strOnAfterClick=null) |
| 79 | { |
| 80 | parent::__construct(strtolower($strName)); |
| 81 | $this->setWidth($strWidth); |
| 82 | $this->setHeight($strHeight); |
| 83 | $this->setShowTabs((is_null($boolShowTabs) ? true : $boolShowTabs ) ); |
| 84 | $this->setOnBeforeClick($strOnBeforeClick); |
| 85 | $this->setOnAfterClick($strOnAfterClick); |
| 86 | } |
| 87 | //---------------------------------------------------------------------------------------------- |
| 88 | /** |
| 89 | * Adicionar aba ao pageControl |
| 90 | * boolDefaut - indica se a aba será a seleciona na criação do formulãrio |
| 91 | * @param mixed $strLabel - 1: Nome da Aba |
| 92 | * @param boolean $boolDefault - 2: indica se a aba será a seleciona na criação do formulário |
| 93 | * @param boolean $boolVisible - 3: Visivel |
| 94 | * @param string $strName - 4: |
| 95 | * @param boolean $boolDisableTab - Desabilita |
| 96 | * @return TForm |
| 97 | */ |
| 98 | public function addPage($strLabel,$boolDefault=null,$boolVisible=null,$strName=null,$boolDisableTab=null,$boolEnabled=null) { |
| 99 | $strName = ($strName==null) ? $strLabel : $strName; |
| 100 | $boolEnabled= ($boolEnabled===false) ? false : true; |
| 101 | $strName = strtolower(parent::removeIllegalChars($strName)); |
| 102 | $pageName = $strName; |
| 103 | $this->setAttribute('fieldType','pagecontrol'); |
| 104 | $page = new TForm(null,null,null,$pageName); |
| 105 | $page->setClass('tabsJsheet'); |
| 106 | $page->body->setAttribute('pagecontrol',$this->getId()); |
| 107 | $page->clearCss(); |
| 108 | $page->setCss('margin-top','10px'); |
| 109 | $page->setCss('margin-left','5px'); |
| 110 | $page->setColumns($this->columns); |
| 111 | $page->setFlat(true); |
| 112 | $page->setFieldType('tabsheet'); |
| 113 | $page->setTagType('div'); |
| 114 | $page->setValue(null,$strLabel); |
| 115 | $page->setEnabled($boolEnabled); |
| 116 | $page->setHeight($this->getHeight()); |
| 117 | if($boolVisible===false){ |
| 118 | $page->setCss('display','none'); |
| 119 | } |
| 120 | if($boolDisableTab){ |
| 121 | $page->setProperty('disabled','true'); |
| 122 | } |
| 123 | $this->pages[$pageName] = $page; |
| 124 | // definir como pagina default |
| 125 | if($boolDefault){ |
| 126 | $this->setActivePage($strName,false); |
| 127 | } |
| 128 | return $page; |
| 129 | } |
| 130 | /** |
| 131 | * Habilitar/desabilitar a Aba mas não os campos |
| 132 | * |
| 133 | * @param mixed $boolNewValue |
| 134 | */ |
| 135 | public function disableTab($tabName,$boolNewValue=null) |
| 136 | { |
| 137 | $boolNewValue = is_null($boolNewValue) ? true:$boolNewValue; |
| 138 | $tabName = strtolower($tabName); |
| 139 | if($boolNewValue) |
| 140 | { |
| 141 | if($this->pages[$tabName]) |
| 142 | { |
| 143 | $this->pages[$tabName]->setProperty('disabled','true'); |
| 144 | } |
| 145 | } |
| 146 | else |
| 147 | { |
| 148 | if($this->pages[$tabName]) |
| 149 | { |
| 150 | $this->pages[$tabName]->setProperty('disabled',''); |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | /** |
| 155 | * Desabilitar a aba para não poder ser acessada |
| 156 | * |
| 157 | * @param string $tabName |
| 158 | */ |
| 159 | public function enableTab($tabName) |
| 160 | { |
| 161 | $tabName = strtolower($tabName); |
| 162 | if($this->pages[$tabName]) |
| 163 | { |
| 164 | $this->pages[$tabName]->setProperty('disabled',''); |
| 165 | } |
| 166 | } |
| 167 | /** |
| 168 | * Tornar a aba invisível |
| 169 | * |
| 170 | * @param string $tabName |
| 171 | */ |
| 172 | public function hideTab($tabName) |
| 173 | { |
| 174 | $tabName = strtolower($tabName); |
| 175 | if($this->pages[$tabName]) |
| 176 | { |
| 177 | //$this->pages[$tabName]->setCss('display','none'); |
| 178 | $this->pages[$tabName]->setVisible(false); |
| 179 | } |
| 180 | } |
| 181 | /** |
| 182 | * Tornar a aba visível |
| 183 | * |
| 184 | * @param string $tabName |
| 185 | */ |
| 186 | public function showTab($tabName) |
| 187 | { |
| 188 | $tabName = strtolower($tabName); |
| 189 | if($this->pages[$tabName]) |
| 190 | { |
| 191 | //$this->pages[$tabName]->setCss('display','block'); |
| 192 | $this->pages[$tabName]->setVisible(true); |
| 193 | |
| 194 | } |
| 195 | } |
| 196 | //---------------------------------------------------------------------------------------------- |
| 197 | public function show($print=true) |
| 198 | { |
| 199 | // altura e largura das paginas |
| 200 | $width = $this->getCss('width'); |
| 201 | $height = $this->getCss('height'); |
| 202 | // css da tabela |
| 203 | $this->setProperty('cellpadding','0'); |
| 204 | $this->setProperty('cellspacing','0'); |
| 205 | $this->setCss('width','auto'); |
| 206 | $this->setCss('height','auto'); |
| 207 | $this->setCss('border','1px solid silver'); |
| 208 | // se não especificar a largura, assumir 100 % |
| 209 | if(!$width) |
| 210 | { |
| 211 | $this->setCss('width','100%'); |
| 212 | $this->setCss('border','none'); |
| 213 | if( !$this->getCss('background-color')) |
| 214 | { |
| 215 | $this->setCss('background-color','transparent'); |
| 216 | } |
| 217 | } |
| 218 | $tr = $this->addRow(); |
| 219 | $tr->clearCss(); |
| 220 | $td = $tr->addCell(); |
| 221 | // todo pagecontrol tem que ter um campo oculto para guardar a aba atual quando postar o formulario |
| 222 | $td->add( $this->hiddenField = new THidden($this->getId().'_current')); |
| 223 | $this->hiddenField->setValue(''); |
| 224 | if( isset( $_POST[$this->getId().'_current']) && $_POST[$this->getId().'_current'] ) |
| 225 | { |
| 226 | // verificar se aba postada como corrente existe no pagecontrol |
| 227 | if($this->getPages()) |
| 228 | { |
| 229 | forEach( $this->getPages() as $name=>$page) |
| 230 | { |
| 231 | if( $this->getId().'_'.$name == $_POST[$this->getId().'_current'] ) |
| 232 | { |
| 233 | $this->hiddenField->setValue($_POST[$this->getId().'_current']); |
| 234 | break; |
| 235 | } |
| 236 | } |
| 237 | } |
| 238 | } |
| 239 | if($this->hiddenField->getValue()) |
| 240 | { |
| 241 | $this->setActivePage( $this->hiddenField->getValue() ); |
| 242 | } |
| 243 | else |
| 244 | { |
| 245 | unset($_POST[$this->getId().'_current']); |
| 246 | } |
| 247 | $td->clearCss(); |
| 248 | $td->setCss('width',$width); |
| 249 | $td->setCss('overflow','hidden'); |
| 250 | $td->add($div = new TElement('div')); |
| 251 | $div->ClearCss(); |
| 252 | $div->setId($this->getId().'_container'); |
| 253 | $div->setClass('tabsJ'); |
| 254 | $div->add($ul = new TElement('ul')); |
| 255 | $ul->clearCss(); |
| 256 | $ul->setId($div->getId().'_page'); |
| 257 | |
| 258 | $tr2 = $this->addRow(); |
| 259 | $tr2->clearCss(); |
| 260 | $td2 = $tr2->addCell(); |
| 261 | $td2->clearCss(); |
| 262 | $td2->setId($this->getId().'_body'); |
| 263 | $td2->setCss('width',$width); |
| 264 | $td2->setCss('height',$height); |
| 265 | $td2->setCss('overflow','auto'); |
| 266 | $td2->setCss('border','none'); |
| 267 | $td2->setCss('vertical-align','top'); |
| 268 | if( ! $this->getShowTabs() ) |
| 269 | { |
| 270 | $div->setCss('display','none'); |
| 271 | } |
| 272 | foreach( $this->pages as $name=>$page) |
| 273 | { |
| 274 | // configurar as páginas |
| 275 | $page->setCss('width',$width); |
| 276 | $page->setCss('height',$height); |
| 277 | |
| 278 | // definir o alinhamento dos rótulos |
| 279 | if( ! $page->getLabelsAlign() && $this->getLabelsAlign() ) |
| 280 | { |
| 281 | $page->setLabelsAlign($this->getLabelsAlign()); |
| 282 | } |
| 283 | |
| 284 | // definir a cor de fundo da aba com a cor de fundo do pagecontrols se a aba não tiver cor própria |
| 285 | if( !$page->getCss('background-color')) |
| 286 | { |
| 287 | $page->setCss('background-color','transparent'); |
| 288 | } |
| 289 | $ul->add($li = new TElement('li')); |
| 290 | $li->ClearCss(); |
| 291 | $li->setId($ul->getId().'_'.$page->getId()); |
| 292 | $li->setProperty('tabref',$this->getId().'_'.$page->getId()); |
| 293 | if($page->getCss('display')=='none') |
| 294 | { |
| 295 | $li->setCss('display','none'); |
| 296 | } |
| 297 | // definir a aba ativa |
| 298 | //print $this->getid().'_'.$page->getId().'=='.$this->getActivePage().','; |
| 299 | if( $this->getId().'_'.$page->getId() == $this->getActivePage()) |
| 300 | { |
| 301 | $li->setProperty('class','activePageControl'); |
| 302 | // mostrar o conteúdo da aba |
| 303 | //$page->setCss('display','block'); |
| 304 | $page->setVisible(true); |
| 305 | } |
| 306 | |
| 307 | $li->add($a = new TElement('a')); |
| 308 | $a->clearCss(); |
| 309 | $a->setId($li->getId().'_link'); |
| 310 | $a->setProperty('title',$page->getValue()); |
| 311 | $a->setProperty('pagecontrol',$this->getId()); |
| 312 | $a->setProperty('href','javascript:void(0);'); |
| 313 | if( $onAfterClick = $this->getOnAfterClick() ) |
| 314 | { |
| 315 | if( strpos( $onAfterClick,'(') === false || strpos( $onAfterClick,'()') > 0 ) |
| 316 | { |
| 317 | $onAfterClick = preg_replace('/\(|\)/','',$onAfterClick); |
| 318 | $onAfterClick = $onAfterClick.'(\"'.$page->getValue().'\",\"'.$this->getId().'\",\"'.$page->getId().'\")'; |
| 319 | } |
| 320 | } |
| 321 | if(!$onBeforeClick = $this->getEvent('onClick')) |
| 322 | { |
| 323 | $onBeforeClick = $this->getOnBeforeClick(); |
| 324 | } |
| 325 | if( $onBeforeClick ) |
| 326 | { |
| 327 | if( strpos( $onBeforeClick,'(') === false ) |
| 328 | { |
| 329 | $onBeforeClick = 'if(!'.$onBeforeClick.'("'.$page->getValue().'","'.$this->getId().'","'.$page->getId().'")) return false'; |
| 330 | } |
| 331 | } |
| 332 | $onBeforeClick = 'if( this.getAttribute("tabDisabled")=="1"){return false};'.$onBeforeClick; |
| 333 | $a->add($span = new TElement('span')); |
| 334 | $span->clearCss(); |
| 335 | $span->setProperty('pagecontrol',$this->getId()); |
| 336 | $span->setAttribute('shortcut',$page->getAttribute('shortcut')); |
| 337 | $span->setAttribute('fieldtype','tabsheet'); |
| 338 | $span->setProperty('tabId',$page->getId()); |
| 339 | $span->setCss('white-space','nowrap'); |
| 340 | $span->setId($li->getId().'_span'); |
| 341 | $span->add($page->getValue()); |
| 342 | // se a pagina estiver desabilitada, não adicionar o evento onBeforeclick e alterar a cor da fonte para cinza |
| 343 | $a->addEvent('onclick',$onBeforeClick.';fwSelecionarAba(this,"","'.$onAfterClick.'")'); |
| 344 | if( !$page->getProperty('disabled') ) |
| 345 | { |
| 346 | $a->setProperty('tabDisabled','0'); |
| 347 | } |
| 348 | else |
| 349 | { |
| 350 | $span->setCss('color','#A9A9A9'); |
| 351 | $a->setProperty('tabDisabled','1'); |
| 352 | } |
| 353 | $page->setId($this->getId().'_'.$page->getId()); |
| 354 | //$td2->setProperty('nivel','TD2'); |
| 355 | $td2->add($page); |
| 356 | } |
| 357 | $this->setId($this->getId()); |
| 358 | $this->hiddenField->setValue($this->getActivePage()); |
| 359 | return parent::show($print); |
| 360 | } |
| 361 | /** |
| 362 | * Define a aba inicial |
| 363 | * Por padrão a aba postada sempre virá selecionada. |
| 364 | * Para selecionar a aba ativa independente da aba postada |
| 365 | * passe true para boolIgnorePost |
| 366 | * |
| 367 | * @param string $strPageName |
| 368 | * @param bool $boolIgnorePost |
| 369 | * @example $pg->setActivePate('Relatório',true); |
| 370 | * |
| 371 | */ |
| 372 | public function setActivePage($strPageName=null,$boolIgnorePost=null) |
| 373 | { |
| 374 | $this->activePage=null; |
| 375 | $strPageName = strtolower(parent::removeIllegalChars($strPageName)); |
| 376 | // se o nome da aba for passado sem o nome do container, adicionar o nome do container ao nome da aba |
| 377 | if(strpos($strPageName,$this->getId().'_') !==0 ) |
| 378 | { |
| 379 | $strPageName = $this->getId().'_'.$strPageName; |
| 380 | } |
| 381 | $this->activePage = $strPageName; |
| 382 | // sobrepor a aba que foi postada |
| 383 | if( (bool)$boolIgnorePost==true ) |
| 384 | { |
| 385 | $_POST[$this->getId().'_current']=$strPageName; |
| 386 | } |
| 387 | return $this; |
| 388 | } |
| 389 | /** |
| 390 | * Retorna a aba selecionada |
| 391 | * |
| 392 | */ |
| 393 | public function getActivePage() |
| 394 | { |
| 395 | return $this->activePage; |
| 396 | } |
| 397 | /** |
| 398 | * Habilitar/Desabilitar a exibição das orelhas |
| 399 | */ |
| 400 | public function setShowTabs($boolShow=null) |
| 401 | { |
| 402 | if(is_null($boolShow)) |
| 403 | { |
| 404 | return $this->showTabs; |
| 405 | } |
| 406 | $boolShow = $boolShow === false ? false : true; |
| 407 | $this->showTabs=(bool)$boolShow; |
| 408 | } |
| 409 | public function getShowTabs() |
| 410 | { |
| 411 | return $this->showTabs === false ? false : true; |
| 412 | } |
| 413 | |
| 414 | /** |
| 415 | * retorna as paginas adicionadas no PageControl |
| 416 | * |
| 417 | */ |
| 418 | public function getPages() |
| 419 | { |
| 420 | return $this->pages; |
| 421 | } |
| 422 | public function getPage($strPageName = null) |
| 423 | { |
| 424 | if( is_null( $strPageName ) ) |
| 425 | { |
| 426 | return null; |
| 427 | } |
| 428 | $strPageName = strtolower($strPageName); |
| 429 | if( isset( $this->pages[$strPageName] ) ) |
| 430 | { |
| 431 | return $this->pages[$strPageName]; |
| 432 | } |
| 433 | return null; |
| 434 | } |
| 435 | //----------------------- |
| 436 | public function setOnClick($strJsFunction=null) |
| 437 | { |
| 438 | $this->onClick = $strJsFunction; |
| 439 | return $this; |
| 440 | } |
| 441 | //----------------------- |
| 442 | public function setOnBeforeClick($strJsFunction=null) |
| 443 | { |
| 444 | $this->onBeforeClick = $strJsFunction; |
| 445 | return $this; |
| 446 | } |
| 447 | //----------------------- |
| 448 | public function getOnBeforeClick() |
| 449 | { |
| 450 | return $this->removeIllegalChars($this->onBeforeClick,'()'); |
| 451 | } |
| 452 | //----------------------- |
| 453 | public function setOnAfterClick($strJsFunction=null) |
| 454 | { |
| 455 | $this->onAfterClick = $strJsFunction; |
| 456 | return $this; |
| 457 | } |
| 458 | //----------------------- |
| 459 | public function getOnAfterClick() |
| 460 | { |
| 461 | return $this->removeIllegalChars($this->onAfterClick,'()'); |
| 462 | } |
| 463 | //--------------------------------------------------------------------------- |
| 464 | public function validate($strPage=null,$strFields=null,$strIgnoreFields=null) |
| 465 | { |
| 466 | if(is_array($this->pages)) |
| 467 | { |
| 468 | $strPage = $this->removeIllegalChars($strPage); |
| 469 | $result=true; |
| 470 | // validar os formularios das abas |
| 471 | forEach( $this->pages as $name=>$page) |
| 472 | { |
| 473 | // o nome da aba tem o nome do pagecontrol + o nome da aba em caixa baixa |
| 474 | if( $strPage=='' || $page->getid()==$this->getId().strtolower($strPage) || $page->getid()==$this->getId().'_'.strtolower($strPage) || $page->getid()==strtolower($strPage) ) |
| 475 | { |
| 476 | $page->validate(null, $strFields, $strIgnoreFields ); |
| 477 | if($result) { |
| 478 | $erros = $page->getErrors(); |
| 479 | $qtdErros = CountHelper::count($erros); |
| 480 | if($qtdErros > 0){ |
| 481 | $result = $qtdErros; |
| 482 | }else{ |
| 483 | $result = 0; |
| 484 | } |
| 485 | } |
| 486 | } |
| 487 | } |
| 488 | } |
| 489 | return $result; |
| 490 | } |
| 491 | //------------------------------------------------------------------------ |
| 492 | function getField($strFieldName) |
| 493 | { |
| 494 | $field=null; |
| 495 | if($strFieldName) |
| 496 | { |
| 497 | if(is_array($this->pages)) |
| 498 | { |
| 499 | // adicionar as páginas ( elementos li ) |
| 500 | forEach( $this->pages as $name=>$page) |
| 501 | { |
| 502 | if($field = $page->getField($strFieldName) ) |
| 503 | { |
| 504 | break; |
| 505 | } |
| 506 | } |
| 507 | } |
| 508 | } |
| 509 | return $field; |
| 510 | } |
| 511 | function setFocusField($strFieldName=null) |
| 512 | { |
| 513 | $this->focusField=$strFieldName; |
| 514 | return $this; |
| 515 | } |
| 516 | function getFocusField($strFieldName=null) |
| 517 | { |
| 518 | return $this->focusField; |
| 519 | } |
| 520 | /** |
| 521 | * Desabilitar/Habilitar campos do formulário |
| 522 | * Pode ser passado um campo ou varios separados por virgula, |
| 523 | * tambem pode ser um array de campos |
| 524 | * |
| 525 | * Ex: $obj->disableFields('nom_pessoa'); |
| 526 | * $obj->disableFields('nom_pessoa,des_endereco'); |
| 527 | * $obj->disableFields(array('nom_pessoa,des_endereco')); |
| 528 | * |
| 529 | * @param mixed $mixFields |
| 530 | * @param boolean $boolNewValue |
| 531 | */ |
| 532 | public function disableFields($mixFields=null,$mixIgnoreFields=null,$boolNewValue=null) |
| 533 | { |
| 534 | if(is_array($this->getPages())) |
| 535 | { |
| 536 | // adicionar as páginas ( elementos li ) |
| 537 | forEach( $this->pages as $name=>$page) |
| 538 | { |
| 539 | $page->disableFields($mixFields,$mixIgnoreFields,$boolNewValue); |
| 540 | } |
| 541 | } |
| 542 | } |
| 543 | //------------------------------------------------------------------------------------ |
| 544 | public function clearFields($mixFields=null,$mixIgnoreFields=null,$boolNewValue=null) |
| 545 | { |
| 546 | if(is_array($this->getPages())) |
| 547 | { |
| 548 | // adicionar as páginas ( elementos li ) |
| 549 | forEach( $this->pages as $name=>$page) |
| 550 | { |
| 551 | $page->clearFields($mixFields,$mixIgnoreFields,$boolNewValue); |
| 552 | } |
| 553 | } |
| 554 | } |
| 555 | //------------------------------------------------------------------------------------ |
| 556 | public function getJsCss() |
| 557 | { |
| 558 | $arrJsCss=array(); |
| 559 | if(is_array($this->getPages())) |
| 560 | { |
| 561 | forEach( $this->pages as $name=>$page) |
| 562 | { |
| 563 | $arrTemp = $page->getJsCss(); |
| 564 | $arrJsCss[0][]=$arrTemp[0]; |
| 565 | $arrJsCss[1][]=$arrTemp[1]; |
| 566 | } |
| 567 | } |
| 568 | return $arrJsCss; |
| 569 | } |
| 570 | //--------------------------------------------------------------------------------------- |
| 571 | public function deleteField($mixFields=null,$mixIgnoreFields=null) |
| 572 | { |
| 573 | if(is_array($this->getPages())) |
| 574 | { |
| 575 | // adicionar as páginas ( elementos li ) |
| 576 | forEach( $this->pages as $name=>$page) |
| 577 | { |
| 578 | $page->deleteField($mixFields,$mixIgnoreFields); |
| 579 | } |
| 580 | } |
| 581 | } |
| 582 | //------------------------------------------------------------------------------------------ |
| 583 | public function getFieldType() |
| 584 | { |
| 585 | return 'pagecontrol'; |
| 586 | } |
| 587 | |
| 588 | public function setColumns($mixColumns=null) |
| 589 | { |
| 590 | $this->columns=$mixColumns; |
| 591 | return $this; |
| 592 | } |
| 593 | public function getColumns() |
| 594 | { |
| 595 | return $this->columns; |
| 596 | } |
| 597 | public function disableTabs() |
| 598 | { |
| 599 | if(is_array($this->getPages())) |
| 600 | { |
| 601 | // adicionar as páginas ( elementos li ) |
| 602 | forEach( $this->pages as $name=>$page) |
| 603 | { |
| 604 | $this->disableTab($name); |
| 605 | } |
| 606 | } |
| 607 | } |
| 608 | public function setVo($vo) |
| 609 | { |
| 610 | if(is_array($this->getPages())) |
| 611 | { |
| 612 | forEach( $this->pages as $name=>$page) |
| 613 | { |
| 614 | $page->setVo($vo); |
| 615 | } |
| 616 | } |
| 617 | return $this; |
| 618 | } |
| 619 | public function setWidth($strNewValue=null) |
| 620 | { |
| 621 | $this->setCss('width',$strNewValue); |
| 622 | if(is_array( $this->getPages()) ) |
| 623 | { |
| 624 | // redimensionar as paginas |
| 625 | forEach( $this->pages as $name=>$page) |
| 626 | { |
| 627 | $page->setWidth($strNewValue); |
| 628 | } |
| 629 | } |
| 630 | return $this; |
| 631 | } |
| 632 | public function getWidth($strNewValue=null) |
| 633 | { |
| 634 | return $this->getCss('width'); |
| 635 | } |
| 636 | //----------------------------------------------------- |
| 637 | public function setHeight($strNewValue=null) |
| 638 | { |
| 639 | $this->setCss('height',$strNewValue); |
| 640 | if(is_array( $this->getPages()) ) |
| 641 | { |
| 642 | // redimensionar as paginas |
| 643 | forEach( $this->pages as $name=>$page) |
| 644 | { |
| 645 | $page->setHeight($strNewValue); |
| 646 | } |
| 647 | } |
| 648 | return $this; |
| 649 | } |
| 650 | public function getHeight($strNewValue=null) |
| 651 | { |
| 652 | return $this->getCss('height'); |
| 653 | } |
| 654 | //--------------------------------------------------------------------------------------- |
| 655 | public function getLabel($strFieldName=null) |
| 656 | { |
| 657 | $label=null; |
| 658 | if(is_array($this->getPages())) |
| 659 | { |
| 660 | // adicionar as páginas ( elementos li ) |
| 661 | forEach( $this->pages as $name=>$page) |
| 662 | { |
| 663 | if( $label = $page->getLabel($strFieldName) ) |
| 664 | { |
| 665 | break; |
| 666 | } |
| 667 | } |
| 668 | } |
| 669 | return $label; |
| 670 | } |
| 671 | /** |
| 672 | * Define o alinhamento dos rótulos dos campos. |
| 673 | * Os valores válidos são:center,left ou right. |
| 674 | * O padrão é left |
| 675 | * |
| 676 | * @param string $strNewValue |
| 677 | */ |
| 678 | public function setLabelsAlign($strNewValue=null) |
| 679 | { |
| 680 | $this->labelsAlign = $strNewValue; |
| 681 | } |
| 682 | //----------------------------------------------------------------------------- |
| 683 | public function getLabelsAlign() |
| 684 | { |
| 685 | return $this->labelsAlign; |
| 686 | } |
| 687 | //----------------------------------------------------------------------------- |
| 688 | |
| 689 | } |
| 690 | ?> |