Skip to content

Commit

Permalink
🔨 BASE update version 5.0.0-alpha22
Browse files Browse the repository at this point in the history
  • Loading branch information
bjverde committed Feb 8, 2021
1 parent 76b88a8 commit 8f87639
Show file tree
Hide file tree
Showing 16 changed files with 824 additions and 81 deletions.
28 changes: 28 additions & 0 deletions FormDin5/lib/widget/FormDin5/helpers/ArrayHelper.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,34 @@ public static function convertArray2OutputFormat($arrayData,$outputFormat = Arra
}
return $result;
}
//--------------------------------------------------------------------------------
/**
* Recebe um array do tipo ArrayHelper::TYPE_ADIANTI, ArrayHelper::TYPE_PDO, ArrayHelper::TYPE_FORMDIN
* para um array TYPE_PHP no formato 'KEY=VALUE,KEY=VALUE'
*
* @param array $arrayData - 1: Array de entrada
* @param string $keyColumn - 2: String nome da coluna chave
* @param string $valueColumn - 3: String nome da coluna valor
* @param const $typeCase - 4: Type Case. Default = PDO::CASE_NATURAL, PDO::CASE_UPPER, PDO::CASE_LOWER
* @return array
*/
public static function convertArray2PhpKeyValue($arrayData,$keyColumn,$valueColumn,$typeCase = PDO::CASE_NATURAL)
{
ValidateHelper::isString($keyColumn,__METHOD__,__LINE__);
ValidateHelper::isString($valueColumn,__METHOD__,__LINE__);
$arrayData = ArrayHelper::convertArray2OutputFormat($arrayData,ArrayHelper::TYPE_PDO,$typeCase);
if( !array_key_exists($keyColumn, $arrayData[0]) ) {
throw new InvalidArgumentException(TFormDinMessage::ERROR_TYPE_WRONG);
}
if( !array_key_exists($valueColumn, $arrayData[0]) ) {
throw new InvalidArgumentException(TFormDinMessage::ERROR_TYPE_WRONG);
}
$arrayResult = array();
foreach( $arrayData as $key => $arrayInterno ) {
$arrayResult[ $arrayInterno[$keyColumn] ] = $arrayInterno[$valueColumn];
}
return $arrayResult;
}

}
?>
26 changes: 22 additions & 4 deletions FormDin5/lib/widget/FormDin5/helpers/FormDinHelper.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
class FormDinHelper
{

const FORMDIN_VERSION = '5.0.0-alpha20';
const FORMDIN_VERSION = '5.0.0-alpha22';
const GRID_SIMPLE = 'GRID_SIMPLE';
const GRID_SCREEN_PAGINATION = 'GRID_SCREEN_PAGINATION';
const GRID_SQL_PAGINATION = 'GRID_SQL_PAGINATION';
Expand Down Expand Up @@ -234,6 +234,15 @@ public static function issetOrNotZero($variable,$testZero=true)

/**
* @codeCoverageIgnore
* Alias da função debug.
* Para depuração. Exibe o modulo a linha e a variável/objeto solicitado
* Retirado do FormDin 4.9.0
* https://github.com/bjverde/formDin/blob/master/base/includes/funcoes.inc
*
* @param [type] $mixExpression váriavel que irá mostrar o resultado
* @param string $strComentario Titulo que irá aparecer
* @param boolean $boolExit
* @return void
*/
public static function d( $mixExpression,$strComentario='Debug', $boolExit=FALSE )
{
Expand All @@ -245,6 +254,11 @@ public static function d( $mixExpression,$strComentario='Debug', $boolExit=FALSE
* função para depuração. Exibe o modulo a linha e a variável/objeto solicitado
* Retirado do FormDin 4.9.0
* https://github.com/bjverde/formDin/blob/master/base/includes/funcoes.inc
*
* @param [type] $mixExpression váriavel que irá mostrar o resultado
* @param string $strComentario Titulo que irá aparecer
* @param boolean $boolExit
* @return void
*/
public static function debug( $mixExpression,$strComentario='Debug', $boolExit=FALSE ) {
ini_set ( 'xdebug.max_nesting_level', 150 );
Expand All @@ -265,17 +279,21 @@ public static function debug( $mixExpression,$strComentario='Debug', $boolExit=F
echo '</pre>';
echo '</div>';
} else {
echo '<hr />';
echo '<div class="formDinDebug">';
echo "<script>try{fwUnblockUI();}catch(e){try{top.app_unblockUI();}catch(e){}}</script>";
echo "<fieldset style='text-align:left;'><legend><font color=\"#007000\">".$strComentario."</font></legend><pre>" ;
echo "<b>file</b>: ".$arrBacktrace[0]['file']."\n";
echo "<b>line</b>: ".$arrBacktrace[0]['line']."\n";
/*
foreach ( $arrBacktrace[0] as $strAttribute => $mixValue ) {
if( !is_array($mixValue) ) {
echo "<b>" . $strAttribute . "</b> ". $mixValue ."\n";
}
}
echo "</pre><hr />";
echo '<span style="color:red;"><blink>'.$strComentario.'</blink></span>'."\n";;
echo '<pre>';
*/
echo "<br>";
echo "<br>";
if( is_object($mixExpression) ) {
var_dump( $mixExpression );
} else {
Expand Down
44 changes: 44 additions & 0 deletions FormDin5/lib/widget/FormDin5/helpers/ValidateHelper.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ public static function methodLine($method,$line,$nameMethodValidate)
}
}

public static function isString($string,$method,$line)
{
self::methodLine($method, $line, __METHOD__);
if( empty($string) || !is_string($string) ){
throw new InvalidArgumentException(TFormDinMessage::ERROR_TYPE_NOT_STRING.'See the method: '.$method.' in the line: '.$line);
}
}

public static function isNumeric($id,$method,$line)
{
self::methodLine($method, $line, __METHOD__);
Expand Down Expand Up @@ -140,6 +148,18 @@ public static function typeErrorMsg($typeErroMsg)
return $complemento;
}
//--------------------------------------------------------------------------------
/**
* Usado para fazer a validação de um parametro do metodo da migração do FormDin4 para o FormDin5
*
* @param string $paramName nome do parametro
* @param [type] $paramValue valor informado
* @param const $typeErro ValidateHelper::NOTICIE, ValidateHelper::WARNING e ValidateHelper::ERROR
* @param const $typeErroMsg
* @param [type] $class
* @param [type] $method
* @param string $line
* @return void
*/
public static function validadeParam($paramName,$paramValue,$typeErro,$typeErroMsg,$class,$method,$line)
{
$test = isset($paramValue) && !empty($paramValue);
Expand All @@ -157,6 +177,30 @@ public static function validadeParam($paramName,$paramValue,$typeErro,$typeErroM
}
}
//--------------------------------------------------------------------------------
/**
* Usado para fazer a validação de um metodo da migração do FormDin4 para o FormDin5
*
* @param const $typeErro ValidateHelper::NOTICIE, ValidateHelper::WARNING e ValidateHelper::ERROR
* @param const $typeErroMsg
* @param const $method
* @param string $complementoMsg
* @param string $file
* @param string $line
*/
public static function validadeMethod($typeErro,$typeErroMsg,$method,$complementoMsg,$file,$line)
{
$complemento = self::typeErrorMsg($typeErroMsg);
$complemento = !empty($complementoMsg)?$complemento.' '.$complementoMsg:$complemento;

$msg = TFormDinMessage::ERROR_FD5_PARAM_MIGRA
.' O metodo: '.$method
.$complemento
.', no arquivo: '.$file
.', na linha: '.$line
;
self::triggerError($msg,$typeErro);
}
//--------------------------------------------------------------------------------
public static function migrarMensage($mensagem,$typeErro,$typeErroMsg,$class,$method,$line,$arquivo=null)
{
$test = isset($mensagem) && !empty($mensagem);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
<?php
/*
* ----------------------------------------------------------------------------
* Formdin 5 Framework
* SourceCode https://github.com/bjverde/formDin5
* @author Reinaldo A. Barrêto Junior
*
* É uma reconstrução do FormDin 4 Sobre o Adianti 7.X
* ----------------------------------------------------------------------------
* This file is part of Formdin Framework.
*
* Formdin Framework is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License version 3
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License version 3
* along with this program; if not, see <http://www.gnu.org/licenses/>
* or write to the Free Software Foundation, Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301, USA.
* ----------------------------------------------------------------------------
* Este arquivo é parte do Framework Formdin.
*
* O Framework Formdin é um software livre; você pode redistribuí-lo e/ou
* modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
* do Software Livre (FSF).
*
* Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
* GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
* APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
* para maiores detalhes.
*
* Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
* "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
* ou escreva para a Fundação do Software Livre (FSF) Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
*/


/**
* Classe para criação campo com mascará
* ------------------------------------------------------------------------
* Esse é o FormDin 5, que é uma reconstrução do FormDin 4 Sobre o Adianti 7.X
* os parâmetros do metodos foram marcados com:
*
* NOT_IMPLEMENTED = Parâmetro não implementados, talvez funcione em
* verões futuras do FormDin. Não vai fazer nada
* DEPRECATED = Parâmetro que não vai funcionar no Adianti e foi mantido
* para o impacto sobre as migrações. Vai gerar um Warning
* FORMDIN5 = Parâmetro novo disponivel apenas na nova versão
* ------------------------------------------------------------------------
*
* @author Reinaldo A. Barrêto Junior
*/
class TFormDinFileField extends TFormDinGenericField
{
private $maxSize;
private $maxSizeKb;
private $allowedFileTypes;
private $msgUploadException;


/**
* Campo de uso geral para insersão manual de códigos html na página
* ------------------------------------------------------------------------
* Esse é o FormDin 5, que é uma reconstrução do FormDin 4 Sobre o Adianti 7.X
* os parâmetros do metodos foram marcados veja documentação da classe para
* saber o que cada marca singinifica.
* ------------------------------------------------------------------------
*
* Se o label for null, não será criado o espaço referente a ele no formulário, para criar
* um label invisível defina como "" o seu valor
*
* criado o espaço
* @param string $strName - 01: ID do campo
* @param string $strValue - 02: Texto HTML que irá aparece dentro
* @param boolean $boolRequired - 03: Obrigatorio
* @param mixed $strAllowedFileTypes - 04: Tipos de arquivos. String separado por virgular ou array
* @param string $strIncludeFile - 05: NOT_IMPLEMENTED Arquivo que será incluido
* @param string $strLabel - 06: Label do campo
* @param string $strWidth - 07: NOT_IMPLEMENTED
* @param string $strHeight - 09: NOT_IMPLEMENTED
* @param boolean $enableFileHandling -13: FORMDIN5 Habilita barra de progresso
* @param boolean $enablePopover -14: FORMDIN5 Habilita o preview
* @return THtml Field
*/
public function __construct( string $id
, string $label
, $boolRequired = false
, $strAllowedFileTypes=null
, $intSize=null
, $strMaxSize=null
, $enableFileHandling = false
, $enablePopover = false
)
{
$this->setAllowedFileTypes( $strAllowedFileTypes );

$adiantiObj = new TFile($label);
$adiantiObj->setAllowedExtensions( $this->getAllowedFileTypes() );
//$adiantiObj->enableFileHandling();
//$adiantiObj->enablePopover();
$this->enableFileHandling($enableFileHandling);
if( $enablePopover==true ){
$this->enablePopover();
}

$post = $adiantiObj->getPostData();
//FormDinHelper::debug($post);

$label = is_null($label)?'':$label;
parent::__construct($adiantiObj,$id,$label,$boolRequired,null,null);

return $this->getAdiantiObj();
}

public function setAllowedFileTypes($strNewFileTypes=null)
{
if( is_string($strNewFileTypes) ){
$strNewFileTypes = strtolower($strNewFileTypes);
$strNewFileTypes = explode(',',$strNewFileTypes);
}
$this->allowedFileTypes = $strNewFileTypes;
}
public function getAllowedFileTypes()
{
return $this->allowedFileTypes;
}

public function setCompleteAction(TAction $action)
{
return $this->getAdiantiObj()->setCompleteAction($action);
}
public function setErrorAction(TAction $action)
{
return $this->getAdiantiObj()->setErrorAction($action);
}

/**
* Habilita barra de progresso
*
* @param boolean $enableFileHandling
*/
public function enableFileHandling($enableFileHandling=true)
{
if( $enableFileHandling==true ){
$this->getAdiantiObj()->enableFileHandling();
}
}

/**
* Habilita o preview
*
* @param string $title titulo
* @param string $content
*/
public function enablePopover($title = null, $content = '')
{
$this->getAdiantiObj()->enablePopover($title,$content);
}

/**
* Define a classe de serviço que irá processar o upload dos arquivos. O Valor padrão é AdiantiUploaderService
*
* @param string $service
*/
public function setService($service)
{
$this->getAdiantiObj()->setService($service);
}

}
Loading

0 comments on commit 8f87639

Please sign in to comment.