-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from italolelis/master
Novas funcionalidades de PDF e padronização da PSR-0
- Loading branch information
Showing
56 changed files
with
1,371 additions
and
725 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
{ | ||
"name": "umbrella/simpletablereport", | ||
"description": "PHP Simple Table Report. Export data as tables to PDF, CSV, Excel, etc...", | ||
"license": "APL", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "kelsoncm", | ||
"email": "[email protected]" | ||
}, | ||
{ | ||
"name": "Ítalo Lelis", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
|
||
}, | ||
"autoload": { | ||
"classmap": ["./src"] | ||
"psr-0": { | ||
"Umbrella\\SimpleReport": "src/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
239 changes: 129 additions & 110 deletions
239
...simpletablereport/api/FieldDefinition.php → ...ella/SimpleReport/Api/FieldDefinition.php
100644 → 100755
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,110 +1,129 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright 2013 kelsoncm. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* | ||
* @author kelsoncm | ||
*/ | ||
class FieldDefinition { | ||
|
||
private static $loadedFieldsTypes = array(); | ||
|
||
private $fieldName; | ||
private $fieldType; | ||
private $fieldSize; | ||
private $fieldWidth; | ||
private $fieldOrder; | ||
private $fieldCaption; | ||
|
||
function __construct($fieldName, $fieldCaption, $fieldType=FieldType::STRING, $fieldSize=null, $fieldWidth=null) { | ||
$this->fieldName = $fieldName; | ||
$this->fieldType = $fieldType; | ||
$this->fieldSize = $fieldSize; | ||
$this->fieldWidth = $fieldWidth; | ||
$this->fieldCaption = $fieldCaption; | ||
} | ||
|
||
public function getFieldName() { | ||
return $this->fieldName; | ||
} | ||
|
||
public function getFieldType() { | ||
return $this->fieldType; | ||
} | ||
|
||
public function getFieldTypeInstance($strategy = '') { | ||
$key = "{$this->fieldType}, {$strategy}"; | ||
if (!isset(FieldDefinition::$loadedFieldsTypes[$key])) { | ||
FieldDefinition::$loadedFieldsTypes[$key] = $this->createFieldType($this->fieldType, $strategy); | ||
} | ||
return FieldDefinition::$loadedFieldsTypes[$key]; | ||
} | ||
|
||
public function getFieldSize() { | ||
return $this->fieldSize; | ||
} | ||
|
||
public function getFieldWidth() { | ||
return $this->fieldWidth; | ||
} | ||
|
||
public function getFieldOrder() { | ||
return $this->fieldOrder; | ||
} | ||
|
||
public function getFieldCaption() { | ||
return $this->fieldCaption; | ||
} | ||
|
||
public function setFieldName($fieldName) { | ||
$this->fieldName = $fieldName; | ||
} | ||
|
||
public function setFieldType($fieldType) { | ||
$this->fieldType = $fieldType; | ||
} | ||
|
||
public function setFieldSize($fieldSize) { | ||
$this->fieldSize = $fieldSize; | ||
} | ||
|
||
public function setFieldWidth($fieldWidth) { | ||
$this->fieldWidth = $fieldWidth; | ||
} | ||
|
||
public function setFieldOrder($fieldOrder) { | ||
$this->fieldOrder = $fieldOrder; | ||
} | ||
|
||
public function setFieldCaption($fieldCaption) { | ||
$this->fieldCaption = $fieldCaption; | ||
} | ||
|
||
protected function createFieldType($fieldTypeName, $strategy) { | ||
$classnameBase = ucfirst(strtolower($fieldTypeName)) . 'Type'; | ||
$classnameConcrete = ucfirst(strtolower($strategy)) . $classnameBase; | ||
if (class_exists($classnameConcrete,true)) { | ||
return new $classnameConcrete(array()); | ||
} elseif(class_exists($classnameBase,true)) { | ||
return new $classnameBase(array()); | ||
} else { | ||
throw new Exception("Field class don't exists for field type '{$fieldTypeName}'."); | ||
} | ||
} | ||
|
||
} | ||
<?php | ||
|
||
/* | ||
* Copyright 2013 kelsoncm. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace Umbrella\SimpleReport\Api; | ||
|
||
use Exception; | ||
|
||
/** | ||
* | ||
* @author kelsoncm | ||
*/ | ||
class FieldDefinition | ||
{ | ||
|
||
private static $loadedFieldsTypes = array(); | ||
private $fieldName; | ||
private $fieldType; | ||
private $fieldSize; | ||
private $fieldWidth; | ||
private $fieldOrder; | ||
private $fieldCaption; | ||
|
||
function __construct($fieldName, $fieldCaption, $fieldType = FieldType::STRING, $fieldSize = null, $fieldWidth = null) | ||
{ | ||
$this->fieldName = $fieldName; | ||
$this->fieldType = $fieldType; | ||
$this->fieldSize = $fieldSize; | ||
$this->fieldWidth = $fieldWidth; | ||
$this->fieldCaption = $fieldCaption; | ||
} | ||
|
||
public function getFieldName() | ||
{ | ||
return $this->fieldName; | ||
} | ||
|
||
public function getFieldType() | ||
{ | ||
return $this->fieldType; | ||
} | ||
|
||
public function getFieldTypeInstance($strategy = '') | ||
{ | ||
$key = "{$this->fieldType}, {$strategy}"; | ||
if (!isset(FieldDefinition::$loadedFieldsTypes[$key])) { | ||
FieldDefinition::$loadedFieldsTypes[$key] = $this->createFieldType($this->fieldType, $strategy); | ||
} | ||
return FieldDefinition::$loadedFieldsTypes[$key]; | ||
} | ||
|
||
public function getFieldSize() | ||
{ | ||
return $this->fieldSize; | ||
} | ||
|
||
public function getFieldWidth() | ||
{ | ||
return $this->fieldWidth; | ||
} | ||
|
||
public function getFieldOrder() | ||
{ | ||
return $this->fieldOrder; | ||
} | ||
|
||
public function getFieldCaption() | ||
{ | ||
return $this->fieldCaption; | ||
} | ||
|
||
public function setFieldName($fieldName) | ||
{ | ||
$this->fieldName = $fieldName; | ||
} | ||
|
||
public function setFieldType($fieldType) | ||
{ | ||
$this->fieldType = $fieldType; | ||
} | ||
|
||
public function setFieldSize($fieldSize) | ||
{ | ||
$this->fieldSize = $fieldSize; | ||
} | ||
|
||
public function setFieldWidth($fieldWidth) | ||
{ | ||
$this->fieldWidth = $fieldWidth; | ||
} | ||
|
||
public function setFieldOrder($fieldOrder) | ||
{ | ||
$this->fieldOrder = $fieldOrder; | ||
} | ||
|
||
public function setFieldCaption($fieldCaption) | ||
{ | ||
$this->fieldCaption = $fieldCaption; | ||
} | ||
|
||
protected function createFieldType($fieldTypeName, $strategy) | ||
{ | ||
$classnameBase = ucfirst(strtolower($fieldTypeName)) . 'Type'; | ||
$classnameConcrete = ucfirst(strtolower($strategy)) . $classnameBase; | ||
if (class_exists($classnameConcrete, true)) { | ||
return new $classnameConcrete(array()); | ||
} elseif (class_exists($classnameBase, true)) { | ||
return new $classnameBase(array()); | ||
} else { | ||
throw new Exception("Field class don't exists for field type '{$fieldTypeName}'."); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,36 +16,40 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
namespace Umbrella\SimpleReport\Api; | ||
|
||
/** | ||
* Description of FieldType | ||
* | ||
* @author kelsoncm <[email protected]> | ||
*/ | ||
abstract class FieldType { | ||
|
||
abstract class FieldType | ||
{ | ||
|
||
const STRING = 'STRING'; | ||
|
||
const DATE = 'DATE'; | ||
const TIME = 'TIME'; | ||
const TIMESTAMP = 'TIMESTAMP'; | ||
|
||
const INTEGER = 'INTEGER'; | ||
const FLOAT = 'FLOAT'; | ||
const DECIMAL = 'DECIMAL'; | ||
const MONEY = 'MONEY'; | ||
|
||
protected $options; | ||
protected $typeprefix; | ||
|
||
function __construct($options) { | ||
|
||
function __construct($options) | ||
{ | ||
$this->options = $options; | ||
} | ||
|
||
public function render($value){ | ||
|
||
public function render($value) | ||
{ | ||
return $this->format($this->toPrimitiveType($value)); | ||
} | ||
|
||
public function getOption($optionName) { | ||
|
||
public function getOption($optionName) | ||
{ | ||
if (isset($this->options["simpletablereport.{$this->typeprefix}.{$optionName}"])) { | ||
return $this->options["simpletablereport.{$this->typeprefix}.{$optionName}"]; | ||
} elseif (isset($this->options["simpletablereport.{$optionName}"])) { | ||
|
@@ -56,6 +60,6 @@ public function getOption($optionName) { | |
} | ||
|
||
public abstract function format($value); | ||
public abstract function toPrimitiveType($value); | ||
|
||
public abstract function toPrimitiveType($value); | ||
} |
Oops, something went wrong.