Fix phpcs

This commit is contained in:
Laurent Destailleur 2018-10-24 03:38:12 +02:00
parent 01adaf253c
commit 047d130081

View File

@ -823,8 +823,8 @@ abstract class CommonDocGenerator
if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h); if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
$pdf->line($x, $y+$h, $x, $y); $pdf->line($x, $y+$h, $x, $y);
} }
/** /**
* uasort callback function to Sort colums fields * uasort callback function to Sort colums fields
* *
@ -832,55 +832,54 @@ abstract class CommonDocGenerator
* @param array $b PDF lines array fields configs * @param array $b PDF lines array fields configs
* @return int Return compare result * @return int Return compare result
*/ */
function columnSort($a, $b) { function columnSort($a, $b)
{
if(empty($a['rank'])){ $a['rank'] = 0; } if(empty($a['rank'])){ $a['rank'] = 0; }
if(empty($b['rank'])){ $b['rank'] = 0; } if(empty($b['rank'])){ $b['rank'] = 0; }
if ($a['rank'] == $b['rank']) { if ($a['rank'] == $b['rank']) {
return 0; return 0;
} }
return ($a['rank'] > $b['rank']) ? -1 : 1; return ($a['rank'] > $b['rank']) ? -1 : 1;
} }
/** /**
* Prepare Array Column Field * Prepare Array Column Field
* *
* @param object $object common object * @param object $object common object
* @param outputlangs $outputlangs langs * @param Translate $outputlangs langs
* @param int $hidedetails Do not show line details * @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc * @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref * @param int $hideref Do not show ref
* @return null * @return null
*/ */
function prepareArrayColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0){ function prepareArrayColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0)
{
global $conf; global $conf;
$this->defineColumnField($object,$outputlangs,$hidedetails,$hidedesc,$hideref); $this->defineColumnField($object,$outputlangs,$hidedetails,$hidedesc,$hideref);
// Sorting // Sorting
uasort ( $this->cols, array( $this, 'columnSort' ) ); uasort ( $this->cols, array( $this, 'columnSort' ) );
// Positionning // Positionning
$curX = $this->page_largeur-$this->marge_droite; // start from right $curX = $this->page_largeur-$this->marge_droite; // start from right
// Array witdh // Array witdh
$arrayWidth = $this->page_largeur-$this->marge_droite-$this->marge_gauche; $arrayWidth = $this->page_largeur-$this->marge_droite-$this->marge_gauche;
// Count flexible column // Count flexible column
$totalDefinedColWidth = 0; $totalDefinedColWidth = 0;
$countFlexCol = 0; $countFlexCol = 0;
foreach ($this->cols as $colKey =>& $colDef) foreach ($this->cols as $colKey =>& $colDef)
{ {
if(!$this->getColumnStatus($colKey)) continue; // continue if desable if(!$this->getColumnStatus($colKey)) continue; // continue if desable
if(!empty($colDef['scale'])){ if(!empty($colDef['scale'])){
// In case of column widht is defined by percentage // In case of column widht is defined by percentage
$colDef['width'] = abs($arrayWidth * $colDef['scale'] / 100 ); $colDef['width'] = abs($arrayWidth * $colDef['scale'] / 100 );
} }
if(empty($colDef['width'])){ if(empty($colDef['width'])){
$countFlexCol++; $countFlexCol++;
} }
@ -888,7 +887,7 @@ abstract class CommonDocGenerator
$totalDefinedColWidth += $colDef['width']; $totalDefinedColWidth += $colDef['width'];
} }
} }
foreach ($this->cols as $colKey =>& $colDef) foreach ($this->cols as $colKey =>& $colDef)
{ {
// setting empty conf with default // setting empty conf with default
@ -898,7 +897,7 @@ abstract class CommonDocGenerator
else{ else{
$colDef['title'] = $this->defaultTitlesFieldsStyle; $colDef['title'] = $this->defaultTitlesFieldsStyle;
} }
// setting empty conf with default // setting empty conf with default
if(!empty($colDef['content'])){ if(!empty($colDef['content'])){
$colDef['content'] = array_replace($this->defaultContentsFieldsStyle, $colDef['content']); $colDef['content'] = array_replace($this->defaultContentsFieldsStyle, $colDef['content']);
@ -906,14 +905,14 @@ abstract class CommonDocGenerator
else{ else{
$colDef['content'] = $this->defaultContentsFieldsStyle; $colDef['content'] = $this->defaultContentsFieldsStyle;
} }
if($this->getColumnStatus($colKey)) if($this->getColumnStatus($colKey))
{ {
// In case of flexible column // In case of flexible column
if(empty($colDef['width'])){ if(empty($colDef['width'])){
$colDef['width'] = abs(($arrayWidth - $totalDefinedColWidth)) / $countFlexCol; $colDef['width'] = abs(($arrayWidth - $totalDefinedColWidth)) / $countFlexCol;
} }
// Set positions // Set positions
$lastX = $curX; $lastX = $curX;
$curX = $lastX - $colDef['width']; $curX = $lastX - $colDef['width'];
@ -922,7 +921,7 @@ abstract class CommonDocGenerator
} }
} }
} }
/** /**
* get column content width from column key * get column content width from column key
* *
@ -934,8 +933,8 @@ abstract class CommonDocGenerator
$colDef = $this->cols[$colKey]; $colDef = $this->cols[$colKey];
return $colDef['width'] - $colDef['content']['padding'][3] - $colDef['content']['padding'][1]; return $colDef['width'] - $colDef['content']['padding'][3] - $colDef['content']['padding'][1];
} }
/** /**
* get column content X (abscissa) left position from column key * get column content X (abscissa) left position from column key
* *
@ -947,7 +946,7 @@ abstract class CommonDocGenerator
$colDef = $this->cols[$colKey]; $colDef = $this->cols[$colKey];
return $colDef['xStartPos'] + $colDef['content']['padding'][3]; return $colDef['xStartPos'] + $colDef['content']['padding'][3];
} }
/** /**
* get column position rank from column key * get column position rank from column key
* *
@ -959,7 +958,7 @@ abstract class CommonDocGenerator
if(!isset($this->cols[$colKey]['rank'])) return -1; if(!isset($this->cols[$colKey]['rank'])) return -1;
return $this->cols[$colKey]['rank']; return $this->cols[$colKey]['rank'];
} }
/** /**
* get column position rank from column key * get column position rank from column key
* *
@ -973,21 +972,21 @@ abstract class CommonDocGenerator
{ {
// prepare wanted rank // prepare wanted rank
$rank = -1; $rank = -1;
// try to get rank from target column // try to get rank from target column
if(!empty($targetCol)){ if(!empty($targetCol)){
$rank = $this->getColumnRank($targetCol); $rank = $this->getColumnRank($targetCol);
if($rank>=0 && $insertAfterTarget){ $rank++; } if($rank>=0 && $insertAfterTarget){ $rank++; }
} }
// get rank from new column definition // get rank from new column definition
if($rank<0 && !empty($defArray['rank'])){ if($rank<0 && !empty($defArray['rank'])){
$rank = $defArray['rank']; $rank = $defArray['rank'];
} }
// error: no rank // error: no rank
if($rank<0){ return -1; } if($rank<0){ return -1; }
foreach ($this->cols as $colKey =>& $colDef) foreach ($this->cols as $colKey =>& $colDef)
{ {
if( $rank <= $colDef['rank']) if( $rank <= $colDef['rank'])
@ -995,14 +994,14 @@ abstract class CommonDocGenerator
$colDef['rank'] = $colDef['rank'] + 1; $colDef['rank'] = $colDef['rank'] + 1;
} }
} }
$defArray['rank'] = $rank; $defArray['rank'] = $rank;
$this->cols[$newColKey] = $defArray; // array_replace is used to preserve keys $this->cols[$newColKey] = $defArray; // array_replace is used to preserve keys
return $rank; return $rank;
} }
/** /**
* print standard column content * print standard column content
* *
@ -1015,7 +1014,7 @@ abstract class CommonDocGenerator
function printStdColumnContent($pdf, &$curY, $colKey, $columnText = '') function printStdColumnContent($pdf, &$curY, $colKey, $columnText = '')
{ {
global $hookmanager; global $hookmanager;
$parameters=array( $parameters=array(
'object' => $object, 'object' => $object,
'curY' =>& $curY, 'curY' =>& $curY,
@ -1031,10 +1030,10 @@ abstract class CommonDocGenerator
$colDef = $this->cols[$colKey]; $colDef = $this->cols[$colKey];
$pdf->MultiCell( $this->getColumnContentWidth($colKey),2, $columnText,'',$colDef['content']['align']); $pdf->MultiCell( $this->getColumnContentWidth($colKey),2, $columnText,'',$colDef['content']['align']);
} }
} }
/** /**
* get column status from column key * get column status from column key
* *