-
Notifications
You must be signed in to change notification settings - Fork 35
Design Ideas
This is just ideas and I think it can not be all dont at once. I tried to figure out what would be the easiest route from what we have. I also wanted to make it so that we could do working releases step by step. And changes should create working code. Instead of a complete refractor.
But the basic concept is that we have a class that creates the report (parser). Another class that lays it out with the data (layout). And then one that outputs it to a format (OutputType)
I left out the components. I think it will be a big step. but should be done later.
Is the main class. It will call the parser, layout and output classes.
This should behave like 0.8c for compatibilty. So classes that are not provided by developer should be auto created. Some function could be considered legacy function that wrapper new behavore. Such as transferDBtoArray would create a PDO data object.
- run($out_method="I" , $options) : pass all object in as out put report
- PHPJasperXML($lang="en",$pdflib="") : if left empty will reply on the run $options for legacy support
- xml_dismantle :
- loadReport(/string/ $report) : convert the report from a string and calls xml_dismantle
- openReport(/string/ $filename) : opens report from a file and calls loadReport
- outpage : will actually call run.
- transferDBtoArray($server,$user,$pass,$db) : will create a JasperPDO class.
- setDatabase(/string/ $uri,$usernamse,$password) : creates a JasperPDO from a PDO URI oa a JasperData datebase object
$jasper = new PHPJasperXML();
$jasper->openReport('report.jrxml');
$jasper->setDatabase('mysql:localhost/database','user','password');
$jasper->run();
A base object for all data. Abstract class. not sure how well this will work with sub reports.
- load($report) - loads the data into memory
- getData - returns the data as an array
- getRow($index) - returns a row from array
- count() - returns length of array
gets xml data from a database using PDO. I dont know if we need anything else but PDO. We currently use direct calls to mysql but I think PDO is now standard in php so should not be a problem. transferDBtoArray could create a PDO uri.
- open($uri,$user,$pass) : opens a PDO database
$jasper = new PHPJasperXML();
$jasper->openReport('report.jrxml');
$pdo = new JasperPDO();
$pdo->open('mysql:localhost/database','user','password');
$jasper->setDatabase($pdo);
$jasper->run();
- setData($data) : sets the array data.
$jasper = new PHPJasperXML();
$jasper->openReport('report.jrxml');
$data = new JasperArrayData();
$data->setData($dataarray);
$jasper->setDatabase($data);
$jasper->run();
convert report xml object into an array or object tree that the layout engine can read.
- parseReport
Transforms the report and the data to an render raster. so a list of what needs to be render and where is created.
Roster Example
$this->raster[] = array('type' => 'newpage' );
$this->raster[] = array('type' => 'textfield', 'text'=>"Hello World" ,'size'=15, 'left'=400 , 'top'=600 );
JasperLayout layout would have to be able to call the outputType to find information like text height or length without rendering it.
Calls directly to $this->pdf would need be removed.
$this->pdf->AddPage();
becomes
$this->raster[] = array('type' => 'newpage' );
This would be extended to file types like pdf or xls
- output($out_method="I" , $roster) : called this the roster data from the layout class
- textHeight($text, $font_def) : get the font height for $text based on $font_def
- textWidth($text, $font_def) : get the font height for $text based on $font_def . Theses can be complicated with word wrap.
- a class that can be inherited to do eveluations such as groovy or javascript