1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the ReportBundle package |
5
|
|
|
* |
6
|
|
|
* (c) symball <http://simonball.me> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE file |
9
|
|
|
* that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Symball\ReportBundle\Patterns; |
13
|
|
|
|
14
|
|
|
use Symball\ReportBundle\Service\ReportBuilder; |
15
|
|
|
use Symball\ReportBundle\Interfaces\PatternInterface; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* This pattern draws the column headings for the current set |
19
|
|
|
* |
20
|
|
|
* @author Simon Ball <simonball at simonball dot me> |
21
|
|
|
*/ |
22
|
|
|
class SetHeadings implements PatternInterface |
23
|
|
|
{ |
24
|
|
|
|
25
|
|
|
public function run(ReportBuilder &$context) |
26
|
|
|
{ |
27
|
|
|
$nav = $context->nav(); |
28
|
|
|
$meta = $context->meta(); |
29
|
|
|
|
30
|
|
|
$nav |
31
|
|
|
->reset('set') |
32
|
|
|
->up(2); |
33
|
|
|
|
34
|
|
|
$context->write($context->query()->getTitle()); |
35
|
|
|
|
36
|
|
|
// Get the last column of the headings |
37
|
|
|
$rangeEndColumn = $nav->column()+$meta->columnCount()-1; |
38
|
|
|
$headingRange = $nav->coord().':'.$nav->coord($rangeEndColumn, false); |
39
|
|
|
|
40
|
|
|
$context->style('merge', $headingRange); |
41
|
|
|
$nav->down(); |
42
|
|
|
|
43
|
|
|
// Draw the main headings |
44
|
|
|
foreach ($meta->getIndex() as $key => $options) { |
45
|
|
|
// Is it hidden |
46
|
|
|
if ($options['visible'] !== true) { |
47
|
|
|
continue; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/* If auto-width on */ |
51
|
|
|
if ($meta->getOption('column_auto_width') == true) { |
52
|
|
|
$context->style('width', $nav->column('current', true)); |
53
|
|
|
} |
54
|
|
|
$context->write($options['title']); |
55
|
|
|
$context->style('bg', (string) $nav); |
56
|
|
|
|
57
|
|
|
$nav->right(); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
// Draw the edge line |
61
|
|
|
$start = $nav->coord('initial', 'current'); |
62
|
|
|
$end = $nav->coord(($nav->column() - 1), 'current'); |
63
|
|
|
|
64
|
|
|
$context->style('border', $start.':'.$end, ['edge' => 'bottom']); |
65
|
|
|
|
66
|
|
|
$nav->reset('set'); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|