@@ -38,97 +38,97 @@ |
||
38 | 38 | */ |
39 | 39 | class LoggerConfiguratorPhp implements LoggerConfigurator { |
40 | 40 | |
41 | - public function configure(LoggerHierarchy $hierarchy, $url = '') { |
|
42 | - return $this->doConfigure($url, $hierarchy); |
|
43 | - } |
|
41 | + public function configure(LoggerHierarchy $hierarchy, $url = '') { |
|
42 | + return $this->doConfigure($url, $hierarchy); |
|
43 | + } |
|
44 | 44 | |
45 | - private function doConfigure($url, LoggerHierarchy $hierarchy) { |
|
45 | + private function doConfigure($url, LoggerHierarchy $hierarchy) { |
|
46 | 46 | |
47 | - $config = require $url; |
|
47 | + $config = require $url; |
|
48 | 48 | |
49 | - // set threshold |
|
50 | - if(isset($config['threshold'])) { |
|
51 | - $hierarchy->setThreshold(LoggerOptionConverter::toLevel($config['threshold'], LoggerLevel::getLevelAll())); |
|
52 | - } |
|
49 | + // set threshold |
|
50 | + if(isset($config['threshold'])) { |
|
51 | + $hierarchy->setThreshold(LoggerOptionConverter::toLevel($config['threshold'], LoggerLevel::getLevelAll())); |
|
52 | + } |
|
53 | 53 | |
54 | - // parse and create appenders |
|
55 | - if(isset($config['appenders'])) { |
|
54 | + // parse and create appenders |
|
55 | + if(isset($config['appenders'])) { |
|
56 | 56 | |
57 | - foreach($config['appenders'] as $appenderName => $appenderProperties) { |
|
57 | + foreach($config['appenders'] as $appenderName => $appenderProperties) { |
|
58 | 58 | |
59 | - $appender = LoggerAppenderPool::getAppenderFromPool($appenderName, $appenderProperties['class']); |
|
59 | + $appender = LoggerAppenderPool::getAppenderFromPool($appenderName, $appenderProperties['class']); |
|
60 | 60 | |
61 | - if($appender->requiresLayout()) { |
|
61 | + if($appender->requiresLayout()) { |
|
62 | 62 | |
63 | - if(isset($appenderProperties['layout'])) { |
|
63 | + if(isset($appenderProperties['layout'])) { |
|
64 | 64 | |
65 | - if(isset($appenderProperties['layout']['class']) and !empty($appenderProperties['layout']['class'])) { |
|
66 | - $layoutClass = $appenderProperties['layout']['class']; |
|
67 | - } else { |
|
68 | - $layoutClass = 'LoggerLayoutSimple'; |
|
69 | - } |
|
65 | + if(isset($appenderProperties['layout']['class']) and !empty($appenderProperties['layout']['class'])) { |
|
66 | + $layoutClass = $appenderProperties['layout']['class']; |
|
67 | + } else { |
|
68 | + $layoutClass = 'LoggerLayoutSimple'; |
|
69 | + } |
|
70 | 70 | |
71 | - $layout = LoggerReflectionUtils::createObject($layoutClass); |
|
72 | - if($layout === null) { |
|
73 | - $layout = LoggerReflectionUtils::createObject('LoggerLayoutSimple'); |
|
74 | - } |
|
71 | + $layout = LoggerReflectionUtils::createObject($layoutClass); |
|
72 | + if($layout === null) { |
|
73 | + $layout = LoggerReflectionUtils::createObject('LoggerLayoutSimple'); |
|
74 | + } |
|
75 | 75 | |
76 | - if($layout instanceof LoggerLayoutPattern) { |
|
77 | - $layout->setConversionPattern($appenderProperties['layout']['conversionPattern']); |
|
78 | - } |
|
76 | + if($layout instanceof LoggerLayoutPattern) { |
|
77 | + $layout->setConversionPattern($appenderProperties['layout']['conversionPattern']); |
|
78 | + } |
|
79 | 79 | |
80 | - $appender->setLayout($layout); |
|
80 | + $appender->setLayout($layout); |
|
81 | 81 | |
82 | - } else { |
|
83 | - // TODO: throw exception? |
|
84 | - } |
|
82 | + } else { |
|
83 | + // TODO: throw exception? |
|
84 | + } |
|
85 | 85 | |
86 | - } |
|
86 | + } |
|
87 | 87 | |
88 | - } |
|
88 | + } |
|
89 | 89 | |
90 | - } |
|
90 | + } |
|
91 | 91 | |
92 | - // parse and create root logger |
|
93 | - if(isset($config['rootLogger'])) { |
|
94 | - $rootLogger = $hierarchy->getRootLogger(); |
|
95 | - if(isset($config['rootLogger']['level'])) { |
|
96 | - $rootLogger->setLevel(LoggerOptionConverter::toLevel($config['rootLogger']['level'], LoggerLevel::getLevelDebug())); |
|
97 | - if(isset($config['rootLogger']['appenders'])) { |
|
98 | - foreach($config['rootLogger']['appenders'] as $appenderName) { |
|
99 | - $appender = LoggerAppenderPool::getAppenderFromPool($appenderName); |
|
100 | - if($appender !== null) { |
|
101 | - $rootLogger->addAppender($appender); |
|
102 | - } |
|
103 | - } |
|
104 | - } |
|
105 | - } |
|
106 | - } |
|
92 | + // parse and create root logger |
|
93 | + if(isset($config['rootLogger'])) { |
|
94 | + $rootLogger = $hierarchy->getRootLogger(); |
|
95 | + if(isset($config['rootLogger']['level'])) { |
|
96 | + $rootLogger->setLevel(LoggerOptionConverter::toLevel($config['rootLogger']['level'], LoggerLevel::getLevelDebug())); |
|
97 | + if(isset($config['rootLogger']['appenders'])) { |
|
98 | + foreach($config['rootLogger']['appenders'] as $appenderName) { |
|
99 | + $appender = LoggerAppenderPool::getAppenderFromPool($appenderName); |
|
100 | + if($appender !== null) { |
|
101 | + $rootLogger->addAppender($appender); |
|
102 | + } |
|
103 | + } |
|
104 | + } |
|
105 | + } |
|
106 | + } |
|
107 | 107 | |
108 | - // parse and create loggers |
|
109 | - if(isset($config['loggers'])) { |
|
110 | - foreach($config['loggers'] as $loggerName => $loggerProperties) { |
|
111 | - if(is_string($loggerName)) { |
|
112 | - $logger = $hierarchy->getLogger($loggerName); |
|
108 | + // parse and create loggers |
|
109 | + if(isset($config['loggers'])) { |
|
110 | + foreach($config['loggers'] as $loggerName => $loggerProperties) { |
|
111 | + if(is_string($loggerName)) { |
|
112 | + $logger = $hierarchy->getLogger($loggerName); |
|
113 | 113 | |
114 | - if(isset($loggerProperties['level'])) { |
|
115 | - $logger->setLevel(LoggerOptionConverter::toLevel($loggerProperties['level'], LoggerLevel::getLevelDebug())); |
|
116 | - if(isset($loggerProperties['appenders'])) { |
|
117 | - foreach($loggerProperties['appenders'] as $appenderName) { |
|
118 | - $appender = LoggerAppenderPool::getAppenderFromPool($appenderName); |
|
119 | - if($appender !== null) { |
|
120 | - $logger->addAppender($appender); |
|
121 | - } |
|
122 | - } |
|
123 | - } |
|
124 | - } |
|
125 | - } else { |
|
126 | - // TODO: throw exception |
|
127 | - } |
|
128 | - } |
|
129 | - } |
|
114 | + if(isset($loggerProperties['level'])) { |
|
115 | + $logger->setLevel(LoggerOptionConverter::toLevel($loggerProperties['level'], LoggerLevel::getLevelDebug())); |
|
116 | + if(isset($loggerProperties['appenders'])) { |
|
117 | + foreach($loggerProperties['appenders'] as $appenderName) { |
|
118 | + $appender = LoggerAppenderPool::getAppenderFromPool($appenderName); |
|
119 | + if($appender !== null) { |
|
120 | + $logger->addAppender($appender); |
|
121 | + } |
|
122 | + } |
|
123 | + } |
|
124 | + } |
|
125 | + } else { |
|
126 | + // TODO: throw exception |
|
127 | + } |
|
128 | + } |
|
129 | + } |
|
130 | 130 | |
131 | - return true; |
|
132 | - } |
|
131 | + return true; |
|
132 | + } |
|
133 | 133 | |
134 | 134 | } |
@@ -26,12 +26,12 @@ discard block |
||
26 | 26 | * @subpackage helpers |
27 | 27 | */ |
28 | 28 | $GLOBALS['log4php.LoggerPatternConverter.spaces'] = array( |
29 | - " ", // 1 space |
|
30 | - " ", // 2 spaces |
|
31 | - " ", // 4 spaces |
|
32 | - " ", // 8 spaces |
|
33 | - " ", // 16 spaces |
|
34 | - " " ); // 32 spaces |
|
29 | + " ", // 1 space |
|
30 | + " ", // 2 spaces |
|
31 | + " ", // 4 spaces |
|
32 | + " ", // 8 spaces |
|
33 | + " ", // 16 spaces |
|
34 | + " " ); // 32 spaces |
|
35 | 35 | |
36 | 36 | |
37 | 37 | /** |
@@ -50,89 +50,89 @@ discard block |
||
50 | 50 | */ |
51 | 51 | class LoggerPatternConverter { |
52 | 52 | |
53 | - /** |
|
54 | - * @var LoggerPatternConverter next converter in converter chain |
|
55 | - */ |
|
56 | - public $next = null; |
|
53 | + /** |
|
54 | + * @var LoggerPatternConverter next converter in converter chain |
|
55 | + */ |
|
56 | + public $next = null; |
|
57 | 57 | |
58 | - public $min = -1; |
|
59 | - public $max = 0x7FFFFFFF; |
|
60 | - public $leftAlign = false; |
|
58 | + public $min = -1; |
|
59 | + public $max = 0x7FFFFFFF; |
|
60 | + public $leftAlign = false; |
|
61 | 61 | |
62 | - /** |
|
63 | - * Constructor |
|
64 | - * |
|
65 | - * @param LoggerFormattingInfo $fi |
|
66 | - */ |
|
67 | - public function __construct($fi = null) { |
|
68 | - if($fi !== null) { |
|
69 | - $this->min = $fi->min; |
|
70 | - $this->max = $fi->max; |
|
71 | - $this->leftAlign = $fi->leftAlign; |
|
72 | - } |
|
73 | - } |
|
62 | + /** |
|
63 | + * Constructor |
|
64 | + * |
|
65 | + * @param LoggerFormattingInfo $fi |
|
66 | + */ |
|
67 | + public function __construct($fi = null) { |
|
68 | + if($fi !== null) { |
|
69 | + $this->min = $fi->min; |
|
70 | + $this->max = $fi->max; |
|
71 | + $this->leftAlign = $fi->leftAlign; |
|
72 | + } |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Derived pattern converters must override this method in order to |
|
77 | - * convert conversion specifiers in the correct way. |
|
78 | - * |
|
79 | - * @param LoggerLoggingEvent $event |
|
80 | - */ |
|
81 | - public function convert($event) {} |
|
75 | + /** |
|
76 | + * Derived pattern converters must override this method in order to |
|
77 | + * convert conversion specifiers in the correct way. |
|
78 | + * |
|
79 | + * @param LoggerLoggingEvent $event |
|
80 | + */ |
|
81 | + public function convert($event) {} |
|
82 | 82 | |
83 | - /** |
|
84 | - * A template method for formatting in a converter specific way. |
|
85 | - * |
|
86 | - * @param string &$sbuf string buffer |
|
87 | - * @param LoggerLoggingEvent $e |
|
88 | - */ |
|
89 | - public function format(&$sbuf, $e) { |
|
90 | - $s = $this->convert($e); |
|
83 | + /** |
|
84 | + * A template method for formatting in a converter specific way. |
|
85 | + * |
|
86 | + * @param string &$sbuf string buffer |
|
87 | + * @param LoggerLoggingEvent $e |
|
88 | + */ |
|
89 | + public function format(&$sbuf, $e) { |
|
90 | + $s = $this->convert($e); |
|
91 | 91 | |
92 | - if($s == null or empty($s)) { |
|
93 | - if(0 < $this->min) { |
|
94 | - $this->spacePad($sbuf, $this->min); |
|
95 | - } |
|
96 | - return; |
|
97 | - } |
|
92 | + if($s == null or empty($s)) { |
|
93 | + if(0 < $this->min) { |
|
94 | + $this->spacePad($sbuf, $this->min); |
|
95 | + } |
|
96 | + return; |
|
97 | + } |
|
98 | 98 | |
99 | - $len = strlen($s); |
|
99 | + $len = strlen($s); |
|
100 | 100 | |
101 | - if($len > $this->max) { |
|
102 | - $sbuf .= substr($s , 0, ($len - $this->max)); |
|
103 | - } else if($len < $this->min) { |
|
104 | - if($this->leftAlign) { |
|
105 | - $sbuf .= $s; |
|
106 | - $this->spacePad($sbuf, ($this->min - $len)); |
|
107 | - } else { |
|
108 | - $this->spacePad($sbuf, ($this->min - $len)); |
|
109 | - $sbuf .= $s; |
|
110 | - } |
|
111 | - } else { |
|
112 | - $sbuf .= $s; |
|
113 | - } |
|
114 | - } |
|
101 | + if($len > $this->max) { |
|
102 | + $sbuf .= substr($s , 0, ($len - $this->max)); |
|
103 | + } else if($len < $this->min) { |
|
104 | + if($this->leftAlign) { |
|
105 | + $sbuf .= $s; |
|
106 | + $this->spacePad($sbuf, ($this->min - $len)); |
|
107 | + } else { |
|
108 | + $this->spacePad($sbuf, ($this->min - $len)); |
|
109 | + $sbuf .= $s; |
|
110 | + } |
|
111 | + } else { |
|
112 | + $sbuf .= $s; |
|
113 | + } |
|
114 | + } |
|
115 | 115 | |
116 | - /** |
|
117 | - * Fast space padding method. |
|
118 | - * |
|
119 | - * @param string $sbuf string buffer |
|
120 | - * @param integer $length pad length |
|
121 | - * |
|
122 | - * @todo reimplement using PHP string functions |
|
123 | - */ |
|
124 | - public function spacePad($sbuf, $length) { |
|
125 | - while($length >= 32) { |
|
126 | - $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][5]; |
|
127 | - $length -= 32; |
|
128 | - } |
|
116 | + /** |
|
117 | + * Fast space padding method. |
|
118 | + * |
|
119 | + * @param string $sbuf string buffer |
|
120 | + * @param integer $length pad length |
|
121 | + * |
|
122 | + * @todo reimplement using PHP string functions |
|
123 | + */ |
|
124 | + public function spacePad($sbuf, $length) { |
|
125 | + while($length >= 32) { |
|
126 | + $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][5]; |
|
127 | + $length -= 32; |
|
128 | + } |
|
129 | 129 | |
130 | - for($i = 4; $i >= 0; $i--) { |
|
131 | - if(($length & (1<<$i)) != 0) { |
|
132 | - $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][$i]; |
|
133 | - } |
|
134 | - } |
|
130 | + for($i = 4; $i >= 0; $i--) { |
|
131 | + if(($length & (1<<$i)) != 0) { |
|
132 | + $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][$i]; |
|
133 | + } |
|
134 | + } |
|
135 | 135 | |
136 | - // $sbuf = str_pad($sbuf, $length); |
|
137 | - } |
|
136 | + // $sbuf = str_pad($sbuf, $length); |
|
137 | + } |
|
138 | 138 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: table_row_group_frame_reflower.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,11 +46,11 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Table_Row_Group_Frame_Reflower extends Frame_Reflower { |
49 | 48 | |
50 | - function __construct($frame) { |
|
49 | + function __construct($frame) { |
|
51 | 50 | parent::__construct($frame); |
52 | - } |
|
51 | + } |
|
53 | 52 | |
54 | - function reflow() { |
|
53 | + function reflow() { |
|
55 | 54 | $page = $this->_frame->get_root(); |
56 | 55 | |
57 | 56 | $style = $this->_frame->get_style(); |
@@ -62,20 +61,20 @@ discard block |
||
62 | 61 | $cb = $this->_frame->get_containing_block(); |
63 | 62 | |
64 | 63 | foreach ( $this->_frame->get_children() as $child) { |
65 | - // Bail if the page is full |
|
66 | - if ( $page->is_full() ) |
|
64 | + // Bail if the page is full |
|
65 | + if ( $page->is_full() ) |
|
67 | 66 | return; |
68 | 67 | |
69 | - $child->set_containing_block($cb["x"], $cb["y"], $cb["w"], $cb["h"]); |
|
70 | - $child->reflow(); |
|
68 | + $child->set_containing_block($cb["x"], $cb["y"], $cb["w"], $cb["h"]); |
|
69 | + $child->reflow(); |
|
71 | 70 | |
72 | - // Check if a split has occured |
|
73 | - $page->check_page_break($child); |
|
71 | + // Check if a split has occured |
|
72 | + $page->check_page_break($child); |
|
74 | 73 | |
75 | 74 | } |
76 | 75 | |
77 | 76 | if ( $page->is_full() ) |
78 | - return; |
|
77 | + return; |
|
79 | 78 | |
80 | 79 | $cellmap = $table->get_cellmap(); |
81 | 80 | $style->width = $cellmap->get_frame_width($this->_frame); |
@@ -84,9 +83,9 @@ discard block |
||
84 | 83 | $this->_frame->set_position($cellmap->get_frame_position($this->_frame)); |
85 | 84 | |
86 | 85 | if ( $table->get_style()->border_collapse === "collapse" ) |
87 | - // Unset our borders because our cells are now using them |
|
88 | - $style->border_style = "none"; |
|
86 | + // Unset our borders because our cells are now using them |
|
87 | + $style->border_style = "none"; |
|
89 | 88 | |
90 | - } |
|
89 | + } |
|
91 | 90 | |
92 | 91 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: null_positioner.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,10 +46,10 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Null_Positioner extends Positioner { |
49 | 48 | |
50 | - function __construct(Frame_Decorator $frame) { |
|
49 | + function __construct(Frame_Decorator $frame) { |
|
51 | 50 | parent::__construct($frame); |
52 | - } |
|
51 | + } |
|
53 | 52 | |
54 | - function position() { return; } |
|
53 | + function position() { return; } |
|
55 | 54 | |
56 | 55 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: inline_renderer.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,13 +46,13 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Inline_Renderer extends Abstract_Renderer { |
49 | 48 | |
50 | - //........................................................................ |
|
49 | + //........................................................................ |
|
51 | 50 | |
52 | - function render(Frame $frame) { |
|
51 | + function render(Frame $frame) { |
|
53 | 52 | $style = $frame->get_style(); |
54 | 53 | |
55 | 54 | if ( !$frame->get_first_child() ) |
56 | - return; // No children, no service |
|
55 | + return; // No children, no service |
|
57 | 56 | |
58 | 57 | // Draw the left border if applicable |
59 | 58 | $bp = $style->get_border_properties(); |
@@ -73,10 +72,10 @@ discard block |
||
73 | 72 | $first_row = true; |
74 | 73 | |
75 | 74 | foreach ($frame->get_children() as $child) { |
76 | - list($child_x, $child_y, $child_w, $child_h) = $child->get_padding_box(); |
|
77 | - $child_h += $widths[2]; |
|
75 | + list($child_x, $child_y, $child_w, $child_h) = $child->get_padding_box(); |
|
76 | + $child_h += $widths[2]; |
|
78 | 77 | |
79 | - if ( !is_null($w) && $child_x < $x + $w ) { |
|
78 | + if ( !is_null($w) && $child_x < $x + $w ) { |
|
80 | 79 | //This branch seems to be supposed to being called on the first part |
81 | 80 | //of an inline html element, and the part after the if clause for the |
82 | 81 | //parts after a line break. |
@@ -88,37 +87,37 @@ discard block |
||
88 | 87 | |
89 | 88 | // Background: |
90 | 89 | if ( ($bg = $style->background_color) !== "transparent" ) |
91 | - $this->_canvas->filled_rectangle( $x, $y, $w, $h, $style->background_color); |
|
90 | + $this->_canvas->filled_rectangle( $x, $y, $w, $h, $style->background_color); |
|
92 | 91 | |
93 | 92 | if ( ($url = $style->background_image) && $url !== "none" ) { |
94 | - $this->_background_image($url, $x, $y, $w, $h, $style); |
|
93 | + $this->_background_image($url, $x, $y, $w, $h, $style); |
|
95 | 94 | } |
96 | 95 | |
97 | 96 | // If this is the first row, draw the left border |
98 | 97 | if ( $first_row ) { |
99 | 98 | |
100 | - if ( $bp["left"]["style"] !== "none" && $bp["left"]["width"] > 0 ) { |
|
99 | + if ( $bp["left"]["style"] !== "none" && $bp["left"]["width"] > 0 ) { |
|
101 | 100 | $method = "_border_" . $bp["left"]["style"]; |
102 | 101 | $this->$method($x, $y, $h + $widths[0] + $widths[2], $bp["left"]["color"], $widths, "left"); |
103 | - } |
|
104 | - $first_row = false; |
|
102 | + } |
|
103 | + $first_row = false; |
|
105 | 104 | } |
106 | 105 | |
107 | 106 | // Draw the top & bottom borders |
108 | 107 | if ( $bp["top"]["style"] !== "none" && $bp["top"]["width"] > 0 ) { |
109 | - $method = "_border_" . $bp["top"]["style"]; |
|
110 | - $this->$method($x, $y, $w + $widths[1] + $widths[3], $bp["top"]["color"], $widths, "top"); |
|
108 | + $method = "_border_" . $bp["top"]["style"]; |
|
109 | + $this->$method($x, $y, $w + $widths[1] + $widths[3], $bp["top"]["color"], $widths, "top"); |
|
111 | 110 | } |
112 | 111 | |
113 | 112 | if ( $bp["bottom"]["style"] !== "none" && $bp["bottom"]["width"] > 0 ) { |
114 | - $method = "_border_" . $bp["bottom"]["style"]; |
|
115 | - $this->$method($x, $y + $h + $widths[0] + $widths[2], $w + $widths[1] + $widths[3], $bp["bottom"]["color"], $widths, "bottom"); |
|
113 | + $method = "_border_" . $bp["bottom"]["style"]; |
|
114 | + $this->$method($x, $y + $h + $widths[0] + $widths[2], $w + $widths[1] + $widths[3], $bp["bottom"]["color"], $widths, "bottom"); |
|
116 | 115 | } |
117 | 116 | |
118 | 117 | // Handle anchors & links |
119 | 118 | if ( $frame->get_node()->nodeName === "a" ) { |
120 | 119 | |
121 | - if ( $href = $frame->get_node()->getAttribute("href") ) |
|
120 | + if ( $href = $frame->get_node()->getAttribute("href") ) |
|
122 | 121 | $this->_canvas->add_link($href, $x, $y, $w, $h); |
123 | 122 | |
124 | 123 | } |
@@ -128,20 +127,20 @@ discard block |
||
128 | 127 | $w = $child_w; |
129 | 128 | $h = $child_h; |
130 | 129 | continue; |
131 | - } |
|
130 | + } |
|
132 | 131 | |
133 | - if ( is_null($w) ) |
|
132 | + if ( is_null($w) ) |
|
134 | 133 | $w = $child_w; |
135 | - else |
|
134 | + else |
|
136 | 135 | $w += $child_w; |
137 | 136 | |
138 | - $h = max($h, $child_h); |
|
137 | + $h = max($h, $child_h); |
|
139 | 138 | } |
140 | 139 | |
141 | 140 | |
142 | 141 | // Handle the last child |
143 | 142 | if ( ($bg = $style->background_color) !== "transparent" ) |
144 | - $this->_canvas->filled_rectangle( $x + $widths[3], $y + $widths[0], $w, $h, $style->background_color); |
|
143 | + $this->_canvas->filled_rectangle( $x + $widths[3], $y + $widths[0], $w, $h, $style->background_color); |
|
145 | 144 | |
146 | 145 | //On continuation lines (after line break) of inline elements, the style got copied. |
147 | 146 | //But a non repeatable background image should not be repeated on the next line. |
@@ -152,7 +151,7 @@ discard block |
||
152 | 151 | // ... && (!($repeat = $style->background_repeat) || $repeat === "repeat" ... |
153 | 152 | //different position? $this->_background_image($url, $x, $y, $w, $h, $style); |
154 | 153 | if ( ($url = $style->background_image) && $url !== "none" ) |
155 | - $this->_background_image($url, $x + $widths[3], $y + $widths[0], $w, $h, $style); |
|
154 | + $this->_background_image($url, $x + $widths[3], $y + $widths[0], $w, $h, $style); |
|
156 | 155 | |
157 | 156 | // Add the border widths |
158 | 157 | $w += $widths[1] + $widths[3]; |
@@ -164,37 +163,37 @@ discard block |
||
164 | 163 | |
165 | 164 | // If this is the first row, draw the left border too |
166 | 165 | if ( $first_row && $bp["left"]["style"] !== "none" && $widths[3] > 0 ) { |
167 | - $method = "_border_" . $bp["left"]["style"]; |
|
168 | - $this->$method($x, $y, $h, $bp["left"]["color"], $widths, "left"); |
|
166 | + $method = "_border_" . $bp["left"]["style"]; |
|
167 | + $this->$method($x, $y, $h, $bp["left"]["color"], $widths, "left"); |
|
169 | 168 | } |
170 | 169 | |
171 | 170 | // Draw the top & bottom borders |
172 | 171 | if ( $bp["top"]["style"] !== "none" && $widths[0] > 0 ) { |
173 | - $method = "_border_" . $bp["top"]["style"]; |
|
174 | - $this->$method($x, $y, $w, $bp["top"]["color"], $widths, "top"); |
|
172 | + $method = "_border_" . $bp["top"]["style"]; |
|
173 | + $this->$method($x, $y, $w, $bp["top"]["color"], $widths, "top"); |
|
175 | 174 | } |
176 | 175 | |
177 | 176 | if ( $bp["bottom"]["style"] !== "none" && $widths[2] > 0 ) { |
178 | - $method = "_border_" . $bp["bottom"]["style"]; |
|
179 | - $this->$method($x, $y + $h, $w, $bp["bottom"]["color"], $widths, "bottom"); |
|
177 | + $method = "_border_" . $bp["bottom"]["style"]; |
|
178 | + $this->$method($x, $y + $h, $w, $bp["bottom"]["color"], $widths, "bottom"); |
|
180 | 179 | } |
181 | 180 | |
182 | 181 | // pre_var_dump(get_class($frame->get_next_sibling())); |
183 | 182 | // $last_row = get_class($frame->get_next_sibling()) !== 'Inline_Frame_Decorator'; |
184 | 183 | // Draw the right border if this is the last row |
185 | 184 | if ( $bp["right"]["style"] !== "none" && $widths[1] > 0 ) { |
186 | - $method = "_border_" . $bp["right"]["style"]; |
|
187 | - $this->$method($x + $w, $y, $h, $bp["right"]["color"], $widths, "right"); |
|
185 | + $method = "_border_" . $bp["right"]["style"]; |
|
186 | + $this->$method($x + $w, $y, $h, $bp["right"]["color"], $widths, "right"); |
|
188 | 187 | } |
189 | 188 | |
190 | 189 | // Handle anchors & links |
191 | 190 | if ( $frame->get_node()->nodeName === "a" ) { |
192 | 191 | |
193 | - if ( $name = $frame->get_node()->getAttribute("name") ) |
|
192 | + if ( $name = $frame->get_node()->getAttribute("name") ) |
|
194 | 193 | $this->_canvas->add_named_dest($name); |
195 | 194 | |
196 | - if ( $href = $frame->get_node()->getAttribute("href") ) |
|
195 | + if ( $href = $frame->get_node()->getAttribute("href") ) |
|
197 | 196 | $this->_canvas->add_link($href, $x, $y, $w, $h); |
198 | 197 | } |
199 | - } |
|
198 | + } |
|
200 | 199 | } |
@@ -61,25 +61,25 @@ discard block |
||
61 | 61 | */ |
62 | 62 | class Image_Cache { |
63 | 63 | |
64 | - /** |
|
65 | - * Array of downloaded images. Cached so that identical images are |
|
66 | - * not needlessly downloaded. |
|
67 | - * |
|
68 | - * @var array |
|
69 | - */ |
|
70 | - static protected $_cache = array(); |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * Resolve and fetch an image for use. |
|
75 | - * |
|
76 | - * @param string $url The url of the image |
|
77 | - * @param string $proto Default protocol if none specified in $url |
|
78 | - * @param string $host Default host if none specified in $url |
|
79 | - * @param string $base_path Default path if none specified in $url |
|
80 | - * @return array An array with two elements: The local path to the image and the image extension |
|
81 | - */ |
|
82 | - static function resolve_url($url, $proto, $host, $base_path) { |
|
64 | + /** |
|
65 | + * Array of downloaded images. Cached so that identical images are |
|
66 | + * not needlessly downloaded. |
|
67 | + * |
|
68 | + * @var array |
|
69 | + */ |
|
70 | + static protected $_cache = array(); |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * Resolve and fetch an image for use. |
|
75 | + * |
|
76 | + * @param string $url The url of the image |
|
77 | + * @param string $proto Default protocol if none specified in $url |
|
78 | + * @param string $host Default host if none specified in $url |
|
79 | + * @param string $base_path Default path if none specified in $url |
|
80 | + * @return array An array with two elements: The local path to the image and the image extension |
|
81 | + */ |
|
82 | + static function resolve_url($url, $proto, $host, $base_path) { |
|
83 | 83 | global $_dompdf_warnings; |
84 | 84 | |
85 | 85 | $parsed_url = explode_url($url); |
@@ -94,23 +94,23 @@ discard block |
||
94 | 94 | $remote = $remote || ($parsed_url['protocol'] != ""); |
95 | 95 | |
96 | 96 | if ( !DOMPDF_ENABLE_REMOTE && $remote ) { |
97 | - $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png"; |
|
98 | - $ext = "png"; |
|
97 | + $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png"; |
|
98 | + $ext = "png"; |
|
99 | 99 | |
100 | - //debugpng |
|
101 | - if ($DEBUGPNG) $full_url_dbg = '(blockedremote)'; |
|
100 | + //debugpng |
|
101 | + if ($DEBUGPNG) $full_url_dbg = '(blockedremote)'; |
|
102 | 102 | |
103 | 103 | } else if ( DOMPDF_ENABLE_REMOTE && $remote ) { |
104 | - // Download remote files to a temporary directory |
|
105 | - $full_url = build_url($proto, $host, $base_path, $url); |
|
104 | + // Download remote files to a temporary directory |
|
105 | + $full_url = build_url($proto, $host, $base_path, $url); |
|
106 | 106 | |
107 | - if ( isset(self::$_cache[$full_url]) ) { |
|
107 | + if ( isset(self::$_cache[$full_url]) ) { |
|
108 | 108 | list($resolved_url,$ext) = self::$_cache[$full_url]; |
109 | 109 | |
110 | 110 | //debugpng |
111 | 111 | if ($DEBUGPNG) $full_url_dbg = $full_url.'(cache)'; |
112 | 112 | |
113 | - } else { |
|
113 | + } else { |
|
114 | 114 | |
115 | 115 | $resolved_url = tempnam(DOMPDF_TEMP_DIR, "ca_dompdf_img_"); |
116 | 116 | //debugpng |
@@ -121,21 +121,21 @@ discard block |
||
121 | 121 | restore_error_handler(); |
122 | 122 | |
123 | 123 | if ( strlen($image) == 0 ) { |
124 | - //target image not found |
|
125 | - $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png"; |
|
126 | - $ext = "png"; |
|
124 | + //target image not found |
|
125 | + $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png"; |
|
126 | + $ext = "png"; |
|
127 | 127 | |
128 | - //debugpng |
|
129 | - if ($DEBUGPNG) $full_url_dbg = $full_url.'(missing)'; |
|
128 | + //debugpng |
|
129 | + if ($DEBUGPNG) $full_url_dbg = $full_url.'(missing)'; |
|
130 | 130 | |
131 | 131 | } else { |
132 | 132 | |
133 | 133 | file_put_contents($resolved_url, $image); |
134 | 134 | |
135 | - //e.g. fetch.php?media=url.jpg&cache=1 |
|
136 | - //- Image file name might be one of the dynamic parts of the url, don't strip off! |
|
137 | - // if ( preg_match("/.*\.(\w+)/",$url,$match) ) $ext = $match[1]; |
|
138 | - //- a remote url does not need to have a file extension at all |
|
135 | + //e.g. fetch.php?media=url.jpg&cache=1 |
|
136 | + //- Image file name might be one of the dynamic parts of the url, don't strip off! |
|
137 | + // if ( preg_match("/.*\.(\w+)/",$url,$match) ) $ext = $match[1]; |
|
138 | + //- a remote url does not need to have a file extension at all |
|
139 | 139 | //- local cached file does not have a matching file extension |
140 | 140 | //Therefore get image type from the content |
141 | 141 | |
@@ -146,33 +146,33 @@ discard block |
||
146 | 146 | $imagetypes = array('','gif','jpeg','png','swf'); |
147 | 147 | $ext = $imagetypes[$imagedim[2]]; |
148 | 148 | if ( rename($resolved_url,$resolved_url.'.'.$ext) ) { |
149 | - $resolved_url .= '.'.$ext; |
|
149 | + $resolved_url .= '.'.$ext; |
|
150 | 150 | } |
151 | 151 | |
152 | - //Don't put replacement image into cache - otherwise it will be deleted on cache cleanup. |
|
153 | - //Only execute on successfull caching of remote image. |
|
152 | + //Don't put replacement image into cache - otherwise it will be deleted on cache cleanup. |
|
153 | + //Only execute on successfull caching of remote image. |
|
154 | 154 | self::$_cache[$full_url] = array($resolved_url,$ext); |
155 | 155 | |
156 | 156 | } else { |
157 | - //target image is not valid. |
|
158 | - unlink($resolved_url); |
|
157 | + //target image is not valid. |
|
158 | + unlink($resolved_url); |
|
159 | 159 | |
160 | - $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png"; |
|
161 | - $ext = "png"; |
|
160 | + $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png"; |
|
161 | + $ext = "png"; |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | - } |
|
165 | + } |
|
166 | 166 | |
167 | 167 | } else { |
168 | 168 | |
169 | - $resolved_url = build_url($proto, $host, $base_path, $url); |
|
170 | - if ($DEBUGPNG) print 'build_url('.$proto.','.$host.','.$base_path.','.$url.')('.$resolved_url.')'; |
|
169 | + $resolved_url = build_url($proto, $host, $base_path, $url); |
|
170 | + if ($DEBUGPNG) print 'build_url('.$proto.','.$host.','.$base_path.','.$url.')('.$resolved_url.')'; |
|
171 | 171 | |
172 | - if ( !preg_match("/.*\.(\w+)/",$url,$match) ) { |
|
172 | + if ( !preg_match("/.*\.(\w+)/",$url,$match) ) { |
|
173 | 173 | //debugpng |
174 | 174 | if ($DEBUGPNG) print '[resolve_url exception '.$url.']'; |
175 | - throw new DOMPDF_Exception("Unknown image type: $url."); |
|
175 | + throw new DOMPDF_Exception("Unknown image type: $url."); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | $ext = $match[1]; |
@@ -184,35 +184,35 @@ discard block |
||
184 | 184 | |
185 | 185 | if ( !is_readable($resolved_url) || !filesize($resolved_url) ) { |
186 | 186 | |
187 | - //debugpng |
|
188 | - if ($DEBUGPNG) $full_url_dbg .= '(nocache'.$resolved_url.')'; |
|
187 | + //debugpng |
|
188 | + if ($DEBUGPNG) $full_url_dbg .= '(nocache'.$resolved_url.')'; |
|
189 | 189 | |
190 | - $_dompdf_warnings[] = "File " .$resolved_url . " is not readable or is an empty file.\n"; |
|
191 | - $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png"; |
|
192 | - $ext = "png"; |
|
190 | + $_dompdf_warnings[] = "File " .$resolved_url . " is not readable or is an empty file.\n"; |
|
191 | + $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png"; |
|
192 | + $ext = "png"; |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | //debugpng |
196 | 196 | if ($DEBUGPNG) print '[resolve_url '.$url.'|'.$full_url_dbg.'|'.$resolved_url.'|'.$ext.']'; |
197 | 197 | |
198 | 198 | return array($resolved_url, $ext); |
199 | - } |
|
199 | + } |
|
200 | 200 | |
201 | - /** |
|
202 | - * Unlink all cached images (i.e. temporary images either downloaded |
|
203 | - * or converted) |
|
204 | - */ |
|
205 | - static function clear() { |
|
201 | + /** |
|
202 | + * Unlink all cached images (i.e. temporary images either downloaded |
|
203 | + * or converted) |
|
204 | + */ |
|
205 | + static function clear() { |
|
206 | 206 | if ( count(self::$_cache) ) { |
207 | - while ($entry = array_shift(self::$_cache)) { |
|
207 | + while ($entry = array_shift(self::$_cache)) { |
|
208 | 208 | list($file, $ext) = $entry; |
209 | 209 | //debugpng |
210 | 210 | if (DEBUGPNG) print '[clear unlink '.$file.']'; |
211 | 211 | if (!DEBUGKEEPTEMP) |
212 | - //XXX: Should we have some kind of fallback or warning if unlink() fails? |
|
213 | - unlink($file); |
|
214 | - } |
|
212 | + //XXX: Should we have some kind of fallback or warning if unlink() fails? |
|
213 | + unlink($file); |
|
214 | + } |
|
215 | + } |
|
215 | 216 | } |
216 | - } |
|
217 | 217 | |
218 | 218 | } |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | * Declared here because PHP5 prevents constants from being declared with expressions |
61 | 61 | */ |
62 | 62 | if (file_exists(DOMPDF_FONT_DIR . "dompdf_font_family_cache")) { |
63 | - define('__DOMPDF_FONT_CACHE_FILE', DOMPDF_FONT_DIR . "dompdf_font_family_cache"); |
|
63 | + define('__DOMPDF_FONT_CACHE_FILE', DOMPDF_FONT_DIR . "dompdf_font_family_cache"); |
|
64 | 64 | } else { |
65 | - define('__DOMPDF_FONT_CACHE_FILE', DOMPDF_FONT_DIR . "dompdf_font_family_cache.dist"); |
|
65 | + define('__DOMPDF_FONT_CACHE_FILE', DOMPDF_FONT_DIR . "dompdf_font_family_cache.dist"); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | |
@@ -78,76 +78,76 @@ discard block |
||
78 | 78 | */ |
79 | 79 | class Font_Metrics { |
80 | 80 | |
81 | - /** |
|
82 | - * @see __DOMPDF_FONT_CACHE_FILE |
|
83 | - */ |
|
84 | - const CACHE_FILE = __DOMPDF_FONT_CACHE_FILE; |
|
81 | + /** |
|
82 | + * @see __DOMPDF_FONT_CACHE_FILE |
|
83 | + */ |
|
84 | + const CACHE_FILE = __DOMPDF_FONT_CACHE_FILE; |
|
85 | 85 | |
86 | - /** |
|
87 | - * Underlying {@link Cpdf} object to perform text size calculations |
|
88 | - * |
|
89 | - * @var Cpdf |
|
90 | - */ |
|
91 | - static protected $_pdf = null; |
|
92 | - |
|
93 | - /** |
|
94 | - * Array of font family names to font files |
|
95 | - * |
|
96 | - * Usually cached by the {@link load_font.php} script |
|
97 | - * |
|
98 | - * @var array |
|
99 | - */ |
|
100 | - static protected $_font_lookup = array(); |
|
86 | + /** |
|
87 | + * Underlying {@link Cpdf} object to perform text size calculations |
|
88 | + * |
|
89 | + * @var Cpdf |
|
90 | + */ |
|
91 | + static protected $_pdf = null; |
|
92 | + |
|
93 | + /** |
|
94 | + * Array of font family names to font files |
|
95 | + * |
|
96 | + * Usually cached by the {@link load_font.php} script |
|
97 | + * |
|
98 | + * @var array |
|
99 | + */ |
|
100 | + static protected $_font_lookup = array(); |
|
101 | 101 | |
102 | 102 | |
103 | - /** |
|
104 | - * Class initialization |
|
105 | - * |
|
106 | - */ |
|
107 | - static function init() { |
|
103 | + /** |
|
104 | + * Class initialization |
|
105 | + * |
|
106 | + */ |
|
107 | + static function init() { |
|
108 | 108 | if (!self::$_pdf) { |
109 | - self::load_font_families(); |
|
110 | - self::$_pdf = Canvas_Factory::get_instance(); |
|
109 | + self::load_font_families(); |
|
110 | + self::$_pdf = Canvas_Factory::get_instance(); |
|
111 | 111 | } |
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * Calculates text size, in points |
|
116 | - * |
|
117 | - * @param string $text the text to be sized |
|
118 | - * @param string $font the desired font |
|
119 | - * @param float $size the desired font size |
|
120 | - * @param float $spacing word spacing, if any |
|
121 | - * @return float |
|
122 | - */ |
|
123 | - static function get_text_width($text, $font, $size, $spacing = 0) { |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * Calculates text size, in points |
|
116 | + * |
|
117 | + * @param string $text the text to be sized |
|
118 | + * @param string $font the desired font |
|
119 | + * @param float $size the desired font size |
|
120 | + * @param float $spacing word spacing, if any |
|
121 | + * @return float |
|
122 | + */ |
|
123 | + static function get_text_width($text, $font, $size, $spacing = 0) { |
|
124 | 124 | return self::$_pdf->get_text_width($text, $font, $size, $spacing); |
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * Calculates font height |
|
129 | - * |
|
130 | - * @param string $font |
|
131 | - * @param float $size |
|
132 | - * @return float |
|
133 | - */ |
|
134 | - static function get_font_height($font, $size) { |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * Calculates font height |
|
129 | + * |
|
130 | + * @param string $font |
|
131 | + * @param float $size |
|
132 | + * @return float |
|
133 | + */ |
|
134 | + static function get_font_height($font, $size) { |
|
135 | 135 | return self::$_pdf->get_font_height($font, $size); |
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * Resolves a font family & subtype into an actual font file |
|
140 | - * |
|
141 | - * Subtype can be one of 'normal', 'bold', 'italic' or 'bold_italic'. If |
|
142 | - * the particular font family has no suitable font file, the default font |
|
143 | - * ({@link DOMPDF_DEFAULT_FONT}) is used. The font file returned |
|
144 | - * is the absolute pathname to the font file on the system. |
|
145 | - * |
|
146 | - * @param string $family |
|
147 | - * @param string $subtype |
|
148 | - * @return string |
|
149 | - */ |
|
150 | - static function get_font($family, $subtype = "normal") { |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * Resolves a font family & subtype into an actual font file |
|
140 | + * |
|
141 | + * Subtype can be one of 'normal', 'bold', 'italic' or 'bold_italic'. If |
|
142 | + * the particular font family has no suitable font file, the default font |
|
143 | + * ({@link DOMPDF_DEFAULT_FONT}) is used. The font file returned |
|
144 | + * is the absolute pathname to the font file on the system. |
|
145 | + * |
|
146 | + * @param string $family |
|
147 | + * @param string $subtype |
|
148 | + * @return string |
|
149 | + */ |
|
150 | + static function get_font($family, $subtype = "normal") { |
|
151 | 151 | |
152 | 152 | /* Allow calling for various fonts in search path. Therefore not immediately |
153 | 153 | * return replacement on non match. |
@@ -158,85 +158,85 @@ discard block |
||
158 | 158 | */ |
159 | 159 | |
160 | 160 | if ( $family ) { |
161 | - $family = str_replace( array("'", '"'), "", mb_strtolower($family)); |
|
162 | - $subtype = mb_strtolower($subtype); |
|
161 | + $family = str_replace( array("'", '"'), "", mb_strtolower($family)); |
|
162 | + $subtype = mb_strtolower($subtype); |
|
163 | 163 | |
164 | - if ( isset(self::$_font_lookup[$family][$subtype]) ) { |
|
164 | + if ( isset(self::$_font_lookup[$family][$subtype]) ) { |
|
165 | 165 | return self::$_font_lookup[$family][$subtype]; |
166 | - } |
|
167 | - return null; |
|
166 | + } |
|
167 | + return null; |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | $family = DOMPDF_DEFAULT_FONT; |
171 | 171 | |
172 | 172 | if ( isset(self::$_font_lookup[$family][$subtype]) ) { |
173 | - return self::$_font_lookup[$family][$subtype]; |
|
173 | + return self::$_font_lookup[$family][$subtype]; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | foreach ( self::$_font_lookup[$family] as $sub => $font ) { |
177 | - if (strpos($subtype, $sub) !== false) { |
|
177 | + if (strpos($subtype, $sub) !== false) { |
|
178 | 178 | return $font; |
179 | - } |
|
179 | + } |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | if ($subtype !== "normal") { |
183 | - foreach ( self::$_font_lookup[$family] as $sub => $font ) { |
|
183 | + foreach ( self::$_font_lookup[$family] as $sub => $font ) { |
|
184 | 184 | if ($sub !== "normal") { |
185 | - return $font; |
|
185 | + return $font; |
|
186 | + } |
|
186 | 187 | } |
187 | - } |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | $subtype = "normal"; |
191 | 191 | |
192 | 192 | if ( isset(self::$_font_lookup[$family][$subtype]) ) { |
193 | - return self::$_font_lookup[$family][$subtype]; |
|
193 | + return self::$_font_lookup[$family][$subtype]; |
|
194 | 194 | } |
195 | 195 | return null; |
196 | - } |
|
197 | - |
|
198 | - /** |
|
199 | - * Saves the stored font family cache |
|
200 | - * |
|
201 | - * The name and location of the cache file are determined by {@link |
|
202 | - * Font_Metrics::CACHE_FILE}. This file should be writable by the |
|
203 | - * webserver process. |
|
204 | - * |
|
205 | - * @see Font_Metrics::load_font_families() |
|
206 | - */ |
|
207 | - static function save_font_families() { |
|
196 | + } |
|
197 | + |
|
198 | + /** |
|
199 | + * Saves the stored font family cache |
|
200 | + * |
|
201 | + * The name and location of the cache file are determined by {@link |
|
202 | + * Font_Metrics::CACHE_FILE}. This file should be writable by the |
|
203 | + * webserver process. |
|
204 | + * |
|
205 | + * @see Font_Metrics::load_font_families() |
|
206 | + */ |
|
207 | + static function save_font_families() { |
|
208 | 208 | |
209 | 209 | file_put_contents(self::CACHE_FILE, var_export(self::$_font_lookup, true)); |
210 | 210 | |
211 | - } |
|
212 | - |
|
213 | - /** |
|
214 | - * Loads the stored font family cache |
|
215 | - * |
|
216 | - * @see save_font_families() |
|
217 | - */ |
|
218 | - static function load_font_families() { |
|
211 | + } |
|
212 | + |
|
213 | + /** |
|
214 | + * Loads the stored font family cache |
|
215 | + * |
|
216 | + * @see save_font_families() |
|
217 | + */ |
|
218 | + static function load_font_families() { |
|
219 | 219 | if ( !is_readable(self::CACHE_FILE) ) |
220 | - return; |
|
220 | + return; |
|
221 | 221 | |
222 | 222 | $data = file_get_contents(self::CACHE_FILE); |
223 | 223 | |
224 | 224 | if ( $data != "" ) |
225 | - eval ('self::$_font_lookup = ' . $data . ";"); |
|
226 | - } |
|
227 | - |
|
228 | - /** |
|
229 | - * Returns the current font lookup table |
|
230 | - * |
|
231 | - * @return array |
|
232 | - */ |
|
233 | - static function get_font_families() { |
|
225 | + eval ('self::$_font_lookup = ' . $data . ";"); |
|
226 | + } |
|
227 | + |
|
228 | + /** |
|
229 | + * Returns the current font lookup table |
|
230 | + * |
|
231 | + * @return array |
|
232 | + */ |
|
233 | + static function get_font_families() { |
|
234 | 234 | return self::$_font_lookup; |
235 | - } |
|
235 | + } |
|
236 | 236 | |
237 | - static function set_font_family($fontname, $entry) { |
|
237 | + static function set_font_family($fontname, $entry) { |
|
238 | 238 | self::$_font_lookup[mb_strtolower($fontname)] = $entry; |
239 | - } |
|
239 | + } |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | Font_Metrics::init(); |
@@ -35,7 +35,6 @@ discard block |
||
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @contributor Helmut Tischer <[email protected]> |
37 | 37 | * @package dompdf |
38 | - |
|
39 | 38 | * |
40 | 39 | * Changes |
41 | 40 | * @contributor Helmut Tischer <[email protected]> |
@@ -53,42 +52,42 @@ discard block |
||
53 | 52 | */ |
54 | 53 | class List_Bullet_Frame_Decorator extends Frame_Decorator { |
55 | 54 | |
56 | - const BULLET_PADDING = 1; // Distance from bullet to text in pt |
|
57 | - // As fraction of font size (including descent). See also DECO_THICKNESS. |
|
58 | - const BULLET_THICKNESS = 0.04; // Thickness of bullet outline. Screen: 0.08, print: better less, e.g. 0.04 |
|
59 | - const BULLET_DESCENT = 0.3; //descent of font below baseline. Todo: Guessed for now. |
|
60 | - const BULLET_SIZE = 0.35; // bullet diameter. For now 0.5 of font_size without descent. |
|
55 | + const BULLET_PADDING = 1; // Distance from bullet to text in pt |
|
56 | + // As fraction of font size (including descent). See also DECO_THICKNESS. |
|
57 | + const BULLET_THICKNESS = 0.04; // Thickness of bullet outline. Screen: 0.08, print: better less, e.g. 0.04 |
|
58 | + const BULLET_DESCENT = 0.3; //descent of font below baseline. Todo: Guessed for now. |
|
59 | + const BULLET_SIZE = 0.35; // bullet diameter. For now 0.5 of font_size without descent. |
|
61 | 60 | |
62 | - static $BULLET_TYPES = array("disc", "circle", "square"); |
|
61 | + static $BULLET_TYPES = array("disc", "circle", "square"); |
|
63 | 62 | |
64 | - //........................................................................ |
|
63 | + //........................................................................ |
|
65 | 64 | |
66 | - function __construct(Frame $frame, DOMPDF $dompdf) { |
|
65 | + function __construct(Frame $frame, DOMPDF $dompdf) { |
|
67 | 66 | parent::__construct($frame, $dompdf); |
68 | - } |
|
67 | + } |
|
69 | 68 | |
70 | - function get_margin_width() { |
|
69 | + function get_margin_width() { |
|
71 | 70 | $style = $this->_frame->get_style(); |
72 | 71 | // Small hack to prevent extra indenting of list text on list_style_position === "inside" |
73 | 72 | // and on suppressed bullet |
74 | 73 | if ( $style->list_style_position === "outside" || |
75 | 74 | $style->list_style_type === "none" ) |
76 | - return 0; |
|
75 | + return 0; |
|
77 | 76 | return $style->get_font_size()*self::BULLET_SIZE + 2 * self::BULLET_PADDING; |
78 | - } |
|
77 | + } |
|
79 | 78 | |
80 | - //hits only on "inset" lists items, to increase height of box |
|
81 | - function get_margin_height() { |
|
79 | + //hits only on "inset" lists items, to increase height of box |
|
80 | + function get_margin_height() { |
|
82 | 81 | return $this->_frame->get_style()->get_font_size()*self::BULLET_SIZE + 2 * self::BULLET_PADDING; |
83 | - } |
|
82 | + } |
|
84 | 83 | |
85 | - function get_width() { |
|
84 | + function get_width() { |
|
86 | 85 | return $this->_frame->get_style()->get_font_size()*self::BULLET_SIZE + 2 * self::BULLET_PADDING; |
87 | - } |
|
86 | + } |
|
88 | 87 | |
89 | - function get_height() { |
|
88 | + function get_height() { |
|
90 | 89 | return $this->_frame->get_style()->get_font_size()*self::BULLET_SIZE + 2 * self::BULLET_PADDING; |
91 | - } |
|
90 | + } |
|
92 | 91 | |
93 | - //........................................................................ |
|
92 | + //........................................................................ |
|
94 | 93 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: page_frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,137 +46,137 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Page_Frame_Decorator extends Frame_Decorator { |
49 | 48 | |
50 | - /** |
|
51 | - * y value of bottom page margin |
|
52 | - * |
|
53 | - * @var float |
|
54 | - */ |
|
55 | - protected $_bottom_page_margin; |
|
56 | - |
|
57 | - /** |
|
58 | - * Flag indicating page is full. |
|
59 | - * |
|
60 | - * @var bool |
|
61 | - */ |
|
62 | - protected $_page_full; |
|
63 | - |
|
64 | - /** |
|
65 | - * Number of tables currently being reflowed |
|
66 | - * |
|
67 | - * @var int |
|
68 | - */ |
|
69 | - protected $_in_table; |
|
70 | - |
|
71 | - /** |
|
72 | - * The pdf renderer |
|
73 | - * |
|
74 | - * @var Renderer |
|
75 | - */ |
|
76 | - protected $_renderer; |
|
77 | - |
|
78 | - //........................................................................ |
|
79 | - |
|
80 | - /** |
|
81 | - * Class constructor |
|
82 | - * |
|
83 | - * @param Frame $frame the frame to decorate |
|
84 | - */ |
|
85 | - function __construct(Frame $frame, DOMPDF $dompdf) { |
|
49 | + /** |
|
50 | + * y value of bottom page margin |
|
51 | + * |
|
52 | + * @var float |
|
53 | + */ |
|
54 | + protected $_bottom_page_margin; |
|
55 | + |
|
56 | + /** |
|
57 | + * Flag indicating page is full. |
|
58 | + * |
|
59 | + * @var bool |
|
60 | + */ |
|
61 | + protected $_page_full; |
|
62 | + |
|
63 | + /** |
|
64 | + * Number of tables currently being reflowed |
|
65 | + * |
|
66 | + * @var int |
|
67 | + */ |
|
68 | + protected $_in_table; |
|
69 | + |
|
70 | + /** |
|
71 | + * The pdf renderer |
|
72 | + * |
|
73 | + * @var Renderer |
|
74 | + */ |
|
75 | + protected $_renderer; |
|
76 | + |
|
77 | + //........................................................................ |
|
78 | + |
|
79 | + /** |
|
80 | + * Class constructor |
|
81 | + * |
|
82 | + * @param Frame $frame the frame to decorate |
|
83 | + */ |
|
84 | + function __construct(Frame $frame, DOMPDF $dompdf) { |
|
86 | 85 | parent::__construct($frame, $dompdf); |
87 | 86 | $this->_page_full = false; |
88 | 87 | $this->_in_table = 0; |
89 | 88 | $this->_bottom_page_margin = null; |
90 | - } |
|
89 | + } |
|
91 | 90 | |
92 | 91 | |
93 | - /** |
|
94 | - * Set the renderer used for this pdf |
|
95 | - * |
|
96 | - * @param Renderer $renderer the renderer to use |
|
97 | - */ |
|
98 | - function set_renderer($renderer) { |
|
92 | + /** |
|
93 | + * Set the renderer used for this pdf |
|
94 | + * |
|
95 | + * @param Renderer $renderer the renderer to use |
|
96 | + */ |
|
97 | + function set_renderer($renderer) { |
|
99 | 98 | $this->_renderer = $renderer; |
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Return the renderer used for this pdf |
|
104 | - * |
|
105 | - * @return Renderer |
|
106 | - */ |
|
107 | - function get_renderer() { |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * Return the renderer used for this pdf |
|
103 | + * |
|
104 | + * @return Renderer |
|
105 | + */ |
|
106 | + function get_renderer() { |
|
108 | 107 | return $this->_renderer; |
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Set the frame's containing block. Overridden to set $this->_bottom_page_margin. |
|
113 | - * |
|
114 | - * @param float $x |
|
115 | - * @param float $y |
|
116 | - * @param float $w |
|
117 | - * @param float $h |
|
118 | - */ |
|
119 | - function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * Set the frame's containing block. Overridden to set $this->_bottom_page_margin. |
|
112 | + * |
|
113 | + * @param float $x |
|
114 | + * @param float $y |
|
115 | + * @param float $w |
|
116 | + * @param float $h |
|
117 | + */ |
|
118 | + function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
|
120 | 119 | parent::set_containing_block($x,$y,$w,$h); |
121 | 120 | $w = $this->get_containing_block("w"); |
122 | 121 | if ( isset($h) ) |
123 | - $this->_bottom_page_margin = $h; // - $this->_frame->get_style()->length_in_pt($this->_frame->get_style()->margin_bottom, $w); |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Returns true if the page is full and is no longer accepting frames. |
|
128 | - * |
|
129 | - * @return bool |
|
130 | - */ |
|
131 | - function is_full() { |
|
122 | + $this->_bottom_page_margin = $h; // - $this->_frame->get_style()->length_in_pt($this->_frame->get_style()->margin_bottom, $w); |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * Returns true if the page is full and is no longer accepting frames. |
|
127 | + * |
|
128 | + * @return bool |
|
129 | + */ |
|
130 | + function is_full() { |
|
132 | 131 | return $this->_page_full; |
133 | - } |
|
132 | + } |
|
134 | 133 | |
135 | - /** |
|
136 | - * Start a new page by resetting the full flag. |
|
137 | - */ |
|
138 | - function next_page() { |
|
134 | + /** |
|
135 | + * Start a new page by resetting the full flag. |
|
136 | + */ |
|
137 | + function next_page() { |
|
139 | 138 | $this->_renderer->new_page(); |
140 | 139 | $this->_page_full = false; |
141 | - } |
|
140 | + } |
|
142 | 141 | |
143 | - /** |
|
144 | - * Indicate to the page that a table is currently being reflowed. |
|
145 | - */ |
|
146 | - function table_reflow_start() { |
|
142 | + /** |
|
143 | + * Indicate to the page that a table is currently being reflowed. |
|
144 | + */ |
|
145 | + function table_reflow_start() { |
|
147 | 146 | $this->_in_table++; |
148 | - } |
|
147 | + } |
|
149 | 148 | |
150 | - /** |
|
151 | - * Indicate to the page that table reflow is finished. |
|
152 | - */ |
|
153 | - function table_reflow_end() { |
|
149 | + /** |
|
150 | + * Indicate to the page that table reflow is finished. |
|
151 | + */ |
|
152 | + function table_reflow_end() { |
|
154 | 153 | $this->_in_table--; |
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * Return whether we are currently in a nested table or not |
|
159 | - * |
|
160 | - * @return bool |
|
161 | - */ |
|
162 | - function in_nested_table() { |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * Return whether we are currently in a nested table or not |
|
158 | + * |
|
159 | + * @return bool |
|
160 | + */ |
|
161 | + function in_nested_table() { |
|
163 | 162 | return $this->_in_table > 1; |
164 | - } |
|
163 | + } |
|
165 | 164 | |
166 | - /** |
|
167 | - * Check if a forced page break is required before $frame. This uses the |
|
168 | - * frame's page_break_before property as well as the preceeding frame's |
|
169 | - * page_break_after property. |
|
170 | - * |
|
171 | - * @link http://www.w3.org/TR/CSS21/page.html#forced |
|
172 | - * |
|
173 | - * @param Frame $frame the frame to check |
|
174 | - * @return bool true if a page break occured |
|
175 | - */ |
|
176 | - function check_forced_page_break(Frame $frame) { |
|
165 | + /** |
|
166 | + * Check if a forced page break is required before $frame. This uses the |
|
167 | + * frame's page_break_before property as well as the preceeding frame's |
|
168 | + * page_break_after property. |
|
169 | + * |
|
170 | + * @link http://www.w3.org/TR/CSS21/page.html#forced |
|
171 | + * |
|
172 | + * @param Frame $frame the frame to check |
|
173 | + * @return bool true if a page break occured |
|
174 | + */ |
|
175 | + function check_forced_page_break(Frame $frame) { |
|
177 | 176 | |
178 | 177 | // Skip check if page is already split |
179 | 178 | if ( $this->_page_full ) |
180 | - return; |
|
179 | + return; |
|
181 | 180 | |
182 | 181 | $block_types = array("block", "list-item", "table"); |
183 | 182 | $page_breaks = array("always", "left", "right"); |
@@ -185,42 +184,42 @@ discard block |
||
185 | 184 | $style = $frame->get_style(); |
186 | 185 | |
187 | 186 | if ( !in_array($style->display, $block_types) ) |
188 | - return false; |
|
187 | + return false; |
|
189 | 188 | |
190 | 189 | // Find the previous block-level sibling |
191 | 190 | $prev = $frame->get_prev_sibling(); |
192 | 191 | while ( $prev && !in_array($prev->get_style()->display, $block_types) ) |
193 | - $prev = $prev->get_prev_sibling(); |
|
192 | + $prev = $prev->get_prev_sibling(); |
|
194 | 193 | |
195 | 194 | if ( in_array($style->page_break_before, $page_breaks) ) { |
196 | 195 | |
197 | - // Prevent cascading splits |
|
198 | - $frame->split(); |
|
199 | - // We have to grab the style again here because split() resets |
|
200 | - // $frame->style to the frame's orignal style. |
|
201 | - $frame->get_style()->page_break_before = "auto"; |
|
202 | - $this->_page_full = true; |
|
203 | - return true; |
|
196 | + // Prevent cascading splits |
|
197 | + $frame->split(); |
|
198 | + // We have to grab the style again here because split() resets |
|
199 | + // $frame->style to the frame's orignal style. |
|
200 | + $frame->get_style()->page_break_before = "auto"; |
|
201 | + $this->_page_full = true; |
|
202 | + return true; |
|
204 | 203 | } |
205 | 204 | |
206 | 205 | if ( ($prev && in_array($prev->get_style()->page_break_after, $page_breaks)) ) { |
207 | - // Prevent cascading splits |
|
208 | - $frame->split(); |
|
209 | - $prev->get_style()->page_break_after = "auto"; |
|
210 | - $this->_page_full = true; |
|
211 | - return true; |
|
206 | + // Prevent cascading splits |
|
207 | + $frame->split(); |
|
208 | + $prev->get_style()->page_break_after = "auto"; |
|
209 | + $this->_page_full = true; |
|
210 | + return true; |
|
212 | 211 | } |
213 | 212 | |
214 | 213 | return false; |
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * Determine if a page break is allowed before $frame |
|
219 | - * |
|
220 | - * @param Frame $frame the frame to check |
|
221 | - * @return bool true if a break is allowed, false otherwise |
|
222 | - */ |
|
223 | - protected function _page_break_allowed(Frame $frame) { |
|
214 | + } |
|
215 | + |
|
216 | + /** |
|
217 | + * Determine if a page break is allowed before $frame |
|
218 | + * |
|
219 | + * @param Frame $frame the frame to check |
|
220 | + * @return bool true if a break is allowed, false otherwise |
|
221 | + */ |
|
222 | + protected function _page_break_allowed(Frame $frame) { |
|
224 | 223 | /** |
225 | 224 | * |
226 | 225 | * http://www.w3.org/TR/CSS21/page.html#allowed-page-breaks |
@@ -276,162 +275,162 @@ discard block |
||
276 | 275 | // Block Frames (1): |
277 | 276 | if ( in_array($display, $block_types) ) { |
278 | 277 | |
279 | - // Avoid breaks within table-cells |
|
280 | - if ( $this->_in_table ) { |
|
278 | + // Avoid breaks within table-cells |
|
279 | + if ( $this->_in_table ) { |
|
281 | 280 | dompdf_debug("page-break", "In table: " . $this->_in_table); |
282 | 281 | return false; |
283 | - } |
|
282 | + } |
|
284 | 283 | |
285 | - // Rules A & B |
|
284 | + // Rules A & B |
|
286 | 285 | |
287 | - if ( $frame->get_style()->page_break_before === "avoid" ) { |
|
286 | + if ( $frame->get_style()->page_break_before === "avoid" ) { |
|
288 | 287 | dompdf_debug("page-break", "before: avoid"); |
289 | 288 | return false; |
290 | - } |
|
289 | + } |
|
291 | 290 | |
292 | - // Find the preceeding block-level sibling |
|
293 | - $prev = $frame->get_prev_sibling(); |
|
294 | - while ( $prev && !in_array($prev->get_style()->display, $block_types) ) |
|
291 | + // Find the preceeding block-level sibling |
|
292 | + $prev = $frame->get_prev_sibling(); |
|
293 | + while ( $prev && !in_array($prev->get_style()->display, $block_types) ) |
|
295 | 294 | $prev = $prev->get_prev_sibling(); |
296 | 295 | |
297 | - // Does the previous element allow a page break after? |
|
298 | - if ( $prev && $prev->get_style()->page_break_after === "avoid" ) { |
|
296 | + // Does the previous element allow a page break after? |
|
297 | + if ( $prev && $prev->get_style()->page_break_after === "avoid" ) { |
|
299 | 298 | dompdf_debug("page-break", "after: avoid"); |
300 | 299 | return false; |
301 | - } |
|
300 | + } |
|
302 | 301 | |
303 | - // If both $prev & $frame have the same parent, check the parent's |
|
304 | - // page_break_inside property. |
|
305 | - $parent = $frame->get_parent(); |
|
306 | - if ( $prev && $parent && $parent->get_style()->page_break_inside === "avoid" ) { |
|
307 | - dompdf_debug("page-break", "parent inside: avoid"); |
|
302 | + // If both $prev & $frame have the same parent, check the parent's |
|
303 | + // page_break_inside property. |
|
304 | + $parent = $frame->get_parent(); |
|
305 | + if ( $prev && $parent && $parent->get_style()->page_break_inside === "avoid" ) { |
|
306 | + dompdf_debug("page-break", "parent inside: avoid"); |
|
308 | 307 | return false; |
309 | - } |
|
308 | + } |
|
310 | 309 | |
311 | - // To prevent cascading page breaks when a top-level element has |
|
312 | - // page-break-inside: avoid, ensure that at least one frame is |
|
313 | - // on the page before splitting. |
|
314 | - if ( $parent->get_node()->nodeName === "body" && !$prev ) { |
|
310 | + // To prevent cascading page breaks when a top-level element has |
|
311 | + // page-break-inside: avoid, ensure that at least one frame is |
|
312 | + // on the page before splitting. |
|
313 | + if ( $parent->get_node()->nodeName === "body" && !$prev ) { |
|
315 | 314 | // We are the body's first child |
316 | - dompdf_debug("page-break", "Body's first child."); |
|
315 | + dompdf_debug("page-break", "Body's first child."); |
|
317 | 316 | return false; |
318 | - } |
|
317 | + } |
|
319 | 318 | |
320 | - // If the frame is the first block-level frame, use the value from |
|
321 | - // $frame's parent instead. |
|
322 | - if ( !$prev && $parent ) |
|
319 | + // If the frame is the first block-level frame, use the value from |
|
320 | + // $frame's parent instead. |
|
321 | + if ( !$prev && $parent ) |
|
323 | 322 | return $this->_page_break_allowed( $parent ); |
324 | 323 | |
325 | - dompdf_debug("page-break", "block: break allowed"); |
|
326 | - return true; |
|
324 | + dompdf_debug("page-break", "block: break allowed"); |
|
325 | + return true; |
|
327 | 326 | |
328 | 327 | } |
329 | 328 | |
330 | 329 | // Inline frames (2): |
331 | 330 | else if ( in_array($display, Style::$INLINE_TYPES) ) { |
332 | 331 | |
333 | - // Avoid breaks within table-cells |
|
334 | - if ( $this->_in_table ) { |
|
335 | - dompdf_debug("page-break", "In table: " . $this->_in_table); |
|
332 | + // Avoid breaks within table-cells |
|
333 | + if ( $this->_in_table ) { |
|
334 | + dompdf_debug("page-break", "In table: " . $this->_in_table); |
|
336 | 335 | return false; |
337 | - } |
|
336 | + } |
|
338 | 337 | |
339 | - // Rule C |
|
340 | - $block_parent = $frame->find_block_parent(); |
|
341 | - if ( count($block_parent->get_lines() ) < $frame->get_style()->orphans ) { |
|
342 | - dompdf_debug("page-break", "orphans"); |
|
338 | + // Rule C |
|
339 | + $block_parent = $frame->find_block_parent(); |
|
340 | + if ( count($block_parent->get_lines() ) < $frame->get_style()->orphans ) { |
|
341 | + dompdf_debug("page-break", "orphans"); |
|
343 | 342 | return false; |
344 | - } |
|
343 | + } |
|
345 | 344 | |
346 | - // FIXME: Checking widows is tricky without having laid out the |
|
347 | - // remaining line boxes. Just ignore it for now... |
|
345 | + // FIXME: Checking widows is tricky without having laid out the |
|
346 | + // remaining line boxes. Just ignore it for now... |
|
348 | 347 | |
349 | - // Rule D |
|
350 | - $p = $block_parent; |
|
351 | - while ($p) { |
|
348 | + // Rule D |
|
349 | + $p = $block_parent; |
|
350 | + while ($p) { |
|
352 | 351 | if ( $p->get_style()->page_break_inside === "avoid" ) { |
353 | - dompdf_debug("page-break", "parent->inside: avoid"); |
|
354 | - return false; |
|
352 | + dompdf_debug("page-break", "parent->inside: avoid"); |
|
353 | + return false; |
|
355 | 354 | } |
356 | 355 | $p = $p->find_block_parent(); |
357 | - } |
|
356 | + } |
|
358 | 357 | |
359 | - // To prevent cascading page breaks when a top-level element has |
|
360 | - // page-break-inside: avoid, ensure that at least one frame with |
|
361 | - // some content is on the page before splitting. |
|
362 | - $prev = $frame->get_prev_sibling(); |
|
363 | - while ( $prev && ($prev->get_node()->nodeName === "#text" && trim($prev->get_node()->nodeValue) == "") ) |
|
358 | + // To prevent cascading page breaks when a top-level element has |
|
359 | + // page-break-inside: avoid, ensure that at least one frame with |
|
360 | + // some content is on the page before splitting. |
|
361 | + $prev = $frame->get_prev_sibling(); |
|
362 | + while ( $prev && ($prev->get_node()->nodeName === "#text" && trim($prev->get_node()->nodeValue) == "") ) |
|
364 | 363 | $prev = $prev->get_prev_sibling(); |
365 | 364 | |
366 | - if ( $block_parent->get_node()->nodeName === "body" && !$prev ) { |
|
365 | + if ( $block_parent->get_node()->nodeName === "body" && !$prev ) { |
|
367 | 366 | // We are the body's first child |
368 | - dompdf_debug("page-break", "Body's first child."); |
|
367 | + dompdf_debug("page-break", "Body's first child."); |
|
369 | 368 | return false; |
370 | - } |
|
369 | + } |
|
371 | 370 | |
372 | - // Skip breaks on empty text nodes |
|
373 | - if ( $frame->get_node()->nodeName === "#text" && |
|
371 | + // Skip breaks on empty text nodes |
|
372 | + if ( $frame->get_node()->nodeName === "#text" && |
|
374 | 373 | $frame->get_node()->nodeValue == "" ) |
375 | 374 | return false; |
376 | 375 | |
377 | - dompdf_debug("page-break", "inline: break allowed"); |
|
378 | - return true; |
|
376 | + dompdf_debug("page-break", "inline: break allowed"); |
|
377 | + return true; |
|
379 | 378 | |
380 | 379 | // Table-rows |
381 | 380 | } else if ( $display === "table-row" ) { |
382 | 381 | |
383 | - // Simply check if the parent table's page_break_inside property is |
|
384 | - // not 'avoid' |
|
385 | - $p = Table_Frame_Decorator::find_parent_table($frame); |
|
382 | + // Simply check if the parent table's page_break_inside property is |
|
383 | + // not 'avoid' |
|
384 | + $p = Table_Frame_Decorator::find_parent_table($frame); |
|
386 | 385 | |
387 | - while ($p) { |
|
386 | + while ($p) { |
|
388 | 387 | if ( $p->get_style()->page_break_inside === "avoid" ) { |
389 | - dompdf_debug("page-break", "parent->inside: avoid"); |
|
390 | - return false; |
|
388 | + dompdf_debug("page-break", "parent->inside: avoid"); |
|
389 | + return false; |
|
391 | 390 | } |
392 | 391 | $p = $p->find_block_parent(); |
393 | - } |
|
392 | + } |
|
394 | 393 | |
395 | - // Avoid breaking after the first row of a table |
|
396 | - if ( $p && $p->get_first_child() === $frame) { |
|
397 | - dompdf_debug("page-break", "table: first-row"); |
|
394 | + // Avoid breaking after the first row of a table |
|
395 | + if ( $p && $p->get_first_child() === $frame) { |
|
396 | + dompdf_debug("page-break", "table: first-row"); |
|
398 | 397 | return false; |
399 | - } |
|
398 | + } |
|
400 | 399 | |
401 | - // If this is a nested table, prevent the page from breaking |
|
402 | - if ( $this->_in_table > 1 ) { |
|
400 | + // If this is a nested table, prevent the page from breaking |
|
401 | + if ( $this->_in_table > 1 ) { |
|
403 | 402 | dompdf_debug("page-break", "table: nested table"); |
404 | 403 | return false; |
405 | - } |
|
404 | + } |
|
406 | 405 | |
407 | - dompdf_debug("page-break","table-row/row-groups: break allowed"); |
|
408 | - return true; |
|
406 | + dompdf_debug("page-break","table-row/row-groups: break allowed"); |
|
407 | + return true; |
|
409 | 408 | |
410 | 409 | } else if ( in_array($display, Table_Frame_Decorator::$ROW_GROUPS) ) { |
411 | 410 | |
412 | - // Disallow breaks at row-groups: only split at row boundaries |
|
413 | - return false; |
|
411 | + // Disallow breaks at row-groups: only split at row boundaries |
|
412 | + return false; |
|
414 | 413 | |
415 | 414 | } else { |
416 | 415 | |
417 | - dompdf_debug("page-break", "? " . $frame->get_style()->display . ""); |
|
418 | - return false; |
|
416 | + dompdf_debug("page-break", "? " . $frame->get_style()->display . ""); |
|
417 | + return false; |
|
419 | 418 | } |
420 | 419 | |
421 | - } |
|
422 | - |
|
423 | - /** |
|
424 | - * Check if $frame will fit on the page. If the frame does not fit, |
|
425 | - * the frame tree is modified so that a page break occurs in the |
|
426 | - * correct location. |
|
427 | - * |
|
428 | - * @param Frame $frame the frame to check |
|
429 | - * @return Frame the frame following the page break |
|
430 | - */ |
|
431 | - function check_page_break(Frame $frame) { |
|
420 | + } |
|
421 | + |
|
422 | + /** |
|
423 | + * Check if $frame will fit on the page. If the frame does not fit, |
|
424 | + * the frame tree is modified so that a page break occurs in the |
|
425 | + * correct location. |
|
426 | + * |
|
427 | + * @param Frame $frame the frame to check |
|
428 | + * @return Frame the frame following the page break |
|
429 | + */ |
|
430 | + function check_page_break(Frame $frame) { |
|
432 | 431 | // Do not split if we have already |
433 | 432 | if ( $this->_page_full ) |
434 | - return false; |
|
433 | + return false; |
|
435 | 434 | |
436 | 435 | // Determine the frame's maximum y value |
437 | 436 | $max_y = $frame->get_position("y") + $frame->get_margin_height(); |
@@ -440,18 +439,18 @@ discard block |
||
440 | 439 | // parents of $frame must fit on the page as well: |
441 | 440 | $p = $frame->get_parent(); |
442 | 441 | while ( $p ) { |
443 | - $style = $p->get_style(); |
|
444 | - $max_y += $style->length_in_pt(array($style->margin_bottom, |
|
445 | - $style->padding_bottom, |
|
446 | - $style->border_bottom_width)); |
|
447 | - $p = $p->get_parent(); |
|
442 | + $style = $p->get_style(); |
|
443 | + $max_y += $style->length_in_pt(array($style->margin_bottom, |
|
444 | + $style->padding_bottom, |
|
445 | + $style->border_bottom_width)); |
|
446 | + $p = $p->get_parent(); |
|
448 | 447 | } |
449 | 448 | |
450 | 449 | |
451 | 450 | // Check if $frame flows off the page |
452 | 451 | if ( $max_y <= $this->_bottom_page_margin ) |
453 | - // no: do nothing |
|
454 | - return false; |
|
452 | + // no: do nothing |
|
453 | + return false; |
|
455 | 454 | |
456 | 455 | dompdf_debug("page-break", "check_page_break"); |
457 | 456 | dompdf_debug("page-break", "in_table: " . $this->_in_table); |
@@ -466,58 +465,58 @@ discard block |
||
466 | 465 | dompdf_debug("page-break","Starting search"); |
467 | 466 | while ( $iter ) { |
468 | 467 | // echo "\nbacktrack: " .$iter->get_node()->nodeName ." ".spl_object_hash($iter->get_node()). ""; |
469 | - if ( $iter === $this ) { |
|
470 | - dompdf_debug("page-break", "reached root."); |
|
468 | + if ( $iter === $this ) { |
|
469 | + dompdf_debug("page-break", "reached root."); |
|
471 | 470 | // We've reached the root in our search. Just split at $frame. |
472 | 471 | break; |
473 | - } |
|
472 | + } |
|
474 | 473 | |
475 | - if ( $this->_page_break_allowed($iter) ) { |
|
474 | + if ( $this->_page_break_allowed($iter) ) { |
|
476 | 475 | dompdf_debug("page-break","break allowed, splitting."); |
477 | 476 | $iter->split(); |
478 | 477 | $this->_page_full = true; |
479 | 478 | $this->_in_table = $in_table; |
480 | 479 | return true; |
481 | - } |
|
480 | + } |
|
482 | 481 | |
483 | - if ( !$flg && $next = $iter->get_last_child() ) { |
|
484 | - dompdf_debug("page-break", "following last child."); |
|
482 | + if ( !$flg && $next = $iter->get_last_child() ) { |
|
483 | + dompdf_debug("page-break", "following last child."); |
|
485 | 484 | |
486 | 485 | if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) ) |
487 | - $this->_in_table++; |
|
486 | + $this->_in_table++; |
|
488 | 487 | |
489 | 488 | $iter = $next; |
490 | 489 | continue; |
491 | - } |
|
490 | + } |
|
492 | 491 | |
493 | - if ( $next = $iter->get_prev_sibling() ) { |
|
494 | - dompdf_debug("page-break", "following prev sibling."); |
|
492 | + if ( $next = $iter->get_prev_sibling() ) { |
|
493 | + dompdf_debug("page-break", "following prev sibling."); |
|
495 | 494 | |
496 | 495 | if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
497 | 496 | !in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
498 | - $this->_in_table++; |
|
497 | + $this->_in_table++; |
|
499 | 498 | |
500 | 499 | else if ( !in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
501 | 500 | in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
502 | - $this->_in_table--; |
|
501 | + $this->_in_table--; |
|
503 | 502 | |
504 | 503 | $iter = $next; |
505 | 504 | $flg = false; |
506 | 505 | continue; |
507 | - } |
|
506 | + } |
|
508 | 507 | |
509 | - if ( $next = $iter->get_parent() ) { |
|
510 | - dompdf_debug("page-break", "following parent."); |
|
508 | + if ( $next = $iter->get_parent() ) { |
|
509 | + dompdf_debug("page-break", "following parent."); |
|
511 | 510 | |
512 | 511 | if ( in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
513 | - $this->_in_table--; |
|
512 | + $this->_in_table--; |
|
514 | 513 | |
515 | 514 | $iter = $next; |
516 | 515 | $flg = true; |
517 | 516 | continue; |
518 | - } |
|
517 | + } |
|
519 | 518 | |
520 | - break; |
|
519 | + break; |
|
521 | 520 | |
522 | 521 | } |
523 | 522 | |
@@ -528,33 +527,33 @@ discard block |
||
528 | 527 | |
529 | 528 | // If we are in a table, backtrack to the nearest top-level table row |
530 | 529 | if ( $this->_in_table ) { |
531 | - $num_tables = $this->_in_table - 1; |
|
530 | + $num_tables = $this->_in_table - 1; |
|
532 | 531 | |
533 | - $iter = $frame; |
|
534 | - while ( $iter && $num_tables && $iter->get_style->display !== "table" ) { |
|
532 | + $iter = $frame; |
|
533 | + while ( $iter && $num_tables && $iter->get_style->display !== "table" ) { |
|
535 | 534 | $iter = $iter->get_parent(); |
536 | 535 | $num_tables--; |
537 | - } |
|
536 | + } |
|
538 | 537 | |
539 | - $iter = $frame; |
|
540 | - while ($iter && $iter->get_style()->display !== "table-row" ) |
|
538 | + $iter = $frame; |
|
539 | + while ($iter && $iter->get_style()->display !== "table-row" ) |
|
541 | 540 | $iter = $iter->get_parent(); |
542 | 541 | |
543 | - $iter->split(); |
|
544 | - $this->_page_full = true; |
|
545 | - return true; |
|
542 | + $iter->split(); |
|
543 | + $this->_page_full = true; |
|
544 | + return true; |
|
546 | 545 | } |
547 | 546 | |
548 | 547 | $frame->split(); |
549 | 548 | $this->_page_full = true; |
550 | 549 | return true; |
551 | 550 | |
552 | - } |
|
551 | + } |
|
553 | 552 | |
554 | - //........................................................................ |
|
553 | + //........................................................................ |
|
555 | 554 | |
556 | - function split($frame = null) { |
|
555 | + function split($frame = null) { |
|
557 | 556 | // Do nothing |
558 | - } |
|
557 | + } |
|
559 | 558 | |
560 | 559 | } |